8000 Add tests to confirm lb-method annotation does not accept special cha… · nginx/kubernetes-ingress@64b4b1a · GitHub
[go: up one dir, main page]

Skip to content

Commit 64b4b1a

Browse files
author
“shaun-nx”
committed
Add tests to confirm lb-method annotation does not accept special characters
1 parent f3d905b commit 64b4b1a

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