@@ -41,7 +41,7 @@ func (suite *AccessControlSuite) Test_Whitelist() {
4141 suite .Run ("Inline" , func () {
4242 suite .tmplData .IngAnnotations = []struct { Key , Value string }{
4343 {"src-ip-header" , " X-Client-IP" },
44- {"whitelist " , " 192.168.2.0/24" },
44+ {"allow-list " , " 192.168.2.0/24" },
4545 }
4646
4747 suite .NoError (suite .test .Apply ("config/deploy.yaml.tmpl" , suite .test .GetNS (), suite .tmplData ))
@@ -50,10 +50,62 @@ func (suite *AccessControlSuite) Test_Whitelist() {
5050 suite .eventuallyReturns ("192.168.5.3" , http .StatusForbidden )
5151 })
5252
53+ suite .Run ("Inline deprecated annotation name" , func () {
54+ suite .tmplData .IngAnnotations = []struct { Key , Value string }{
55+ {"src-ip-header" , " X-Client-IP" },
56+ {"whitelist" , "192.168.4.0/24" },
57+ }
58+
59+ suite .NoError (suite .test .Apply ("config/deploy.yaml.tmpl" , suite .test .GetNS (), suite .tmplData ))
60+
61+ suite .eventuallyReturns ("192.168.4.3" , http .StatusOK )
62+ suite .eventuallyReturns ("192.168.5.3" , http .StatusForbidden )
63+ })
64+
65+ suite .Run ("Inline: when new and deprecated annotation names are defined then only new name is considered" , func () {
66+ suite .tmplData .IngAnnotations = []struct { Key , Value string }{
67+ {"src-ip-header" , " X-Client-IP" },
68+ {"whitelist" , "192.168.4.0/24" },
69+ {"allow-list" , "192.168.5.0/24" },
70+ }
71+
72+ suite .NoError (suite .test .Apply ("config/deploy.yaml.tmpl" , suite .test .GetNS (), suite .tmplData ))
73+
74+ suite .eventuallyReturns ("192.168.5.3" , http .StatusOK )
75+ suite .eventuallyReturns ("192.168.4.3" , http .StatusForbidden )
76+ })
77+
5378 suite .Run ("Patternfile" , func () {
5479 suite .tmplData .IngAnnotations = []struct { Key , Value string }{
5580 {"src-ip-header" , " X-Client-IP" },
56- {"whitelist" , " patterns/ips" },
81+ {"allow-list" , " patterns/ips" },
82+ }
83+
84+ suite .NoError (suite .test .Apply ("config/deploy.yaml.tmpl" , suite .test .GetNS (), suite .tmplData ))
85+ suite .NoError (suite .test .Apply ("config/patternfile-a.yml" , "" , nil ))
86+
87+ suite .eventuallyReturns ("192.168.0.3" , http .StatusOK )
88+ suite .eventuallyReturns ("192.168.2.3" , http .StatusForbidden )
89+ })
90+
91+ suite .Run ("Patternfile deprecated annotation name" , func () {
92+ suite .tmplData .IngAnnotations = []struct { Key , Value string }{
93+ {"src-ip-header" , " X-Client-IP" },
94+ {"whitelist" , " patterns/ips2" },
95+ }
96+
97+ suite .NoError (suite .test .Apply ("config/deploy.yaml.tmpl" , suite .test .GetNS (), suite .tmplData ))
98+ suite .NoError (suite .test .Apply ("config/patternfile-a.yml" , "" , nil ))
99+
100+ suite .eventuallyReturns ("192.169.0.3" , http .StatusOK )
101+ suite .eventuallyReturns ("192.168.2.3" , http .StatusForbidden )
102+ })
103+
104+ suite .Run ("Patternfile: when new and deprecated annotation names are defined then only new name is considered" , func () {
105+ suite .tmplData .IngAnnotations = []struct { Key , Value string }{
106+ {"src-ip-header" , " X-Client-IP" },
107+ {"whitelist" , " patterns/ips2" },
108+ {"allow-list" , " patterns/ips" },
57109 }
58110
59111 suite .NoError (suite .test .Apply ("config/deploy.yaml.tmpl" , suite .test .GetNS (), suite .tmplData ))
@@ -68,7 +120,7 @@ func (suite *AccessControlSuite) Test_Blacklist() {
68120 suite .Run ("Inline" , func () {
69121 suite .tmplData .IngAnnotations = []struct { Key , Value string }{
70122 {"src-ip-header" , " X-Client-IP" },
71- {"blacklist " , " 192.168.2.0/24" },
123+ {"deny-list " , " 192.168.2.0/24" },
72124 }
73125
74126 suite .NoError (suite .test .Apply ("config/deploy.yaml.tmpl" , suite .test .GetNS (), suite .tmplData ))
@@ -77,10 +129,35 @@ func (suite *AccessControlSuite) Test_Blacklist() {
77129 suite .eventuallyReturns ("192.168.5.3" , http .StatusOK )
78130 })
79131
132+ suite .Run ("Inline deprecated annotation name" , func () {
133+ suite .tmplData .IngAnnotations = []struct { Key , Value string }{
134+ {"src-ip-header" , " X-Client-IP" },
135+ {"blacklist" , "192.168.4.0/24" },
136+ }
137+
138+ suite .NoError (suite .test .Apply ("config/deploy.yaml.tmpl" , suite .test .GetNS (), suite .tmplData ))
139+
140+ suite .eventuallyReturns ("192.168.4.3" , http .StatusForbidden )
141+ suite .eventuallyReturns ("192.168.5.3" , http .StatusOK )
142+ })
143+
144+ suite .Run ("Inline: when new and deprecated annotation names are defined then only new name is considered" , func () {
145+ suite .tmplData .IngAnnotations = []struct { Key , Value string }{
146+ {"src-ip-header" , " X-Client-IP" },
147+ {"blacklist" , "192.168.4.0/24" },
148+ {"deny-list" , "192.168.5.0/24" },
149+ }
150+
151+ suite .NoError (suite .test .Apply ("config/deploy.yaml.tmpl" , suite .test .GetNS (), suite .tmplData ))
152+
153+ suite .eventuallyReturns ("192.168.5.3" , http .StatusForbidden )
154+ suite .eventuallyReturns ("192.168.4.3" , http .StatusOK )
155+ })
156+
80157 suite .Run ("Patternfile" , func () {
81158 suite .tmplData .IngAnnotations = []struct { Key , Value string }{
82159 {"src-ip-header" , " X-Client-IP" },
83- {"blacklist " , " patterns/ips" },
160+ {"deny-list " , "patterns/ips" },
84161 }
85162
86163 suite .NoError (suite .test .Apply ("config/deploy.yaml.tmpl" , suite .test .GetNS (), suite .tmplData ))
@@ -89,4 +166,30 @@ func (suite *AccessControlSuite) Test_Blacklist() {
89166 suite .eventuallyReturns ("192.168.0.3" , http .StatusForbidden )
90167 suite .eventuallyReturns ("192.168.2.3" , http .StatusOK )
91168 })
169+
170+ suite .Run ("Patternfile deprecated annotation name" , func () {
171+ suite .tmplData .IngAnnotations = []struct { Key , Value string }{
172+ {"src-ip-header" , " X-Client-IP" },
173+ {"blacklist" , " patterns/ips2" },
174+ }
175+
176+ suite .NoError (suite .test .Apply ("config/deploy.yaml.tmpl" , suite .test .GetNS (), suite .tmplData ))
177+ suite .NoError (suite .test .Apply ("config/patternfile-a.yml" , "" , nil ))
178+
179+ suite .eventuallyReturns ("192.169.0.3" , http .StatusForbidden )
180+ suite .eventuallyReturns ("192.168.2.3" , http .StatusOK )
181+ })
182+ suite .Run ("Patternfile: when new and deprecated annotation names are defined then only new name is considered" , func () {
183+ suite .tmplData .IngAnnotations = []struct { Key , Value string }{
184+ {"src-ip-header" , " X-Client-IP" },
185+ {"blacklist" , "patterns/ips2" },
186+ {"deny-list" , "patterns/ips" },
187+ }
188+
189+ suite .NoError (suite .test .Apply ("config/deploy.yaml.tmpl" , suite .test .GetNS (), suite .tmplData ))
190+ suite .NoError (suite .test .Apply ("config/patternfile-a.yml" , "" , nil ))
191+
192+ suite .eventuallyReturns ("192.168.0.3" , http .StatusForbidden )
193+ suite .eventuallyReturns ("192.169.2.3" , http .StatusOK )
194+ })
92195}
0 commit comments