8000 Add additional unit tests to confirm special characters can't be used… · nginx/kubernetes-ingress@a077ac4 · GitHub
[go: up one dir, main page]

Skip to content

Commit a077ac4

Browse files
shaun-nx“shaun-nx”
andauthored
Add additional unit tests to confirm special characters can't be used in the lb-method annotation (#2742)
Add tests to confirm lb-method annotation does not accept special characters Co-authored-by: “shaun-nx” <“s.odonovan@f5.com”>
1 parent 2723d04 commit a077ac4

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

internal/k8s/validation_test.go

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,48 @@ func TestValidateNginxIngressAnnotations(t *testing.T) {
252252
},
253253
msg: "invalid nginx.org/lb-method annotation, nginx plus only",
254254
},
255+
{
256+
annotations: map[string]string{
257+
"nginx.org/lb-method": "least_time header;",
258+
},
259+
specServices: map[string]bool{},
260+
isPlus: true,
261+
appProtectEnabled: false,
262+
appProtectDosEnabled: false,
263+
internalRoutesEnabled: false,
264+
expectedErrors: []string{
265+
`annotations.nginx.org/lb-method: Invalid value: "least_time header;": Invalid load balancing method: "least_time header;"`,
266+
},
267+
msg: "invalid nginx.org/lb-method annotation",
268+
},
269+
{
270+
annotations: map[string]string{
271+
"nginx.org/lb-method": "{least_time header}",
272+
},
273+
specServices: map[string]bool{},
274+
isPlus: true,
275+
appProtectEnabled: false,
276+
appProtectDosEnabled: false,
277+
internalRoutesEnabled: false,
278+
expectedErrors: []string{
279+
`annotations.nginx.org/lb-method: Invalid value: "{least_time header}": Invalid load balancing method: "{least_time header}"`,
280+
},
281+
msg: "invalid nginx.org/lb-method annotation",
282+
},
283+
{
284+
annotations: map[string]string{
285+
"nginx.org/lb-method": "$least_time header",
286+
},
287+
specServices: map[string]bool{},
288+
isPlus: true,
289+
appProtectEnabled: false,
290+
appProtectDosEnabled: false,
291+
internalRoutesEnabled: false,
292+
expectedErrors: []string{
293+
`annotations.nginx.org/lb-method: Invalid value: "$least_time header": Invalid load balancing method: "$least_time header"`,
294+
},
295+
msg: "invalid nginx.org/lb-method annotation",
296+
},
255297
{
256298
annotations: map[string]string{
257299
"nginx.org/lb-method": "invalid_method",

0 commit comments

Comments
 (0)
0