@@ -41,7 +41,7 @@ func (suite *AccessControlSuite) Test_Whitelist() {
41
41
suite .Run ("Inline" , func () {
42
42
suite .tmplData .IngAnnotations = []struct { Key , Value string }{
43
43
{"src-ip-header" , " X-Client-IP" },
44
- {"whitelist " , " 192.168.2.0/24" },
44
+ {"allow-list " , " 192.168.2.0/24" },
45
45
}
46
46
47
47
suite .NoError (suite .test .Apply ("config/deploy.yaml.tmpl" , suite .test .GetNS (), suite .tmplData ))
@@ -50,10 +50,62 @@ func (suite *AccessControlSuite) Test_Whitelist() {
50
50
suite .eventuallyReturns ("192.168.5.3" , http .StatusForbidden )
51
51
})
52
52
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
+
53
78
suite .Run ("Patternfile" , func () {
54
79
suite .tmplData .IngAnnotations = []struct { Key , Value string }{
55
80
{"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" },
57
109
}
58
110
59
111
suite .NoError (suite .test .Apply ("config/deploy.yaml.tmpl" , suite .test .GetNS (), suite .tmplData ))
@@ -68,7 +120,7 @@ func (suite *AccessControlSuite) Test_Blacklist() {
68
120
suite .Run ("Inline" , func () {
69
121
suite .tmplData .IngAnnotations = []struct { Key , Value string }{
70
122
{"src-ip-header" , " X-Client-IP" },
71
- {"blacklist " , " 192.168.2.0/24" },
123
+ {"deny-list " , " 192.168.2.0/24" },
72
124
}
73
125
74
126
suite .NoError (suite .test .Apply ("config/deploy.yaml.tmpl" , suite .test .GetNS (), suite .tmplData ))
@@ -77,10 +129,35 @@ func (suite *AccessControlSuite) Test_Blacklist() {
77
129
suite .eventuallyReturns ("192.168.5.3" , http .StatusOK )
78
130
})
79
131
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
+
80
157
suite .Run ("Patternfile" , func () {
81
158
suite .tmplData .IngAnnotations = []struct { Key , Value string }{
82
159
{"src-ip-header" , " X-Client-IP" },
83
- {"blacklist " , " patterns/ips" },
160
+ {"deny-list " , "patterns/ips" },
84
161
}
85
162
86
163
suite .NoError (suite .test .Apply ("config/deploy.yaml.tmpl" , suite .test .GetNS (), suite .tmplData ))
@@ -89,4 +166,30 @@ func (suite *AccessControlSuite) Test_Blacklist() {
89
166
suite .eventuallyReturns ("192.168.0.3" , http .StatusForbidden )
90
167
suite .eventuallyReturns ("192.168.2.3" , http .StatusOK )
91
168
})
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
+ })
92
195
}
0 commit comments