@@ -112,6 +112,69 @@ func TestIngressValidator_Handle(t *testing.T) {
112112 },
113113 expectAllowed : false ,
114114 },
115+ {
116+ name : "Valid WAF Name (Allowed)" ,
117+ operation : admissionv1 .Create ,
118+ className : & managedIngressClassName ,
119+ annotations : map [string ]string {
120+ AnnotationWAFName : "my-valid-waf-123" ,
121+ },
122+ expectAllowed : true ,
123+ },
124+ {
125+ name : "Valid WAF Name Single Char (Allowed)" ,
126+ operation : admissionv1 .Create ,
127+ className : & managedIngressClassName ,
128+ annotations : map [string ]string {
129+ AnnotationWAFName : "a" ,
130+ },
131+ expectAllowed : true ,
132+ },
133+ {
134+ name : "Denied - Invalid WAF Name (Uppercase)" ,
135+ operation : admissionv1 .Create ,
136+ className : & managedIngressClassName ,
137+ annotations : map [string ]string {
138+ AnnotationWAFName : "My-Waf-Name" ,
139+ },
140+ expectAllowed : false ,
141+ },
142+ {
143+ name : "Denied - Invalid WAF Name (Starts with hyphen)" ,
144+ operation : admissionv1 .Create ,
145+ className : & managedIngressClassName ,
146+ annotations : map [string ]string {
147+ AnnotationWAFName : "-my-waf" ,
148+ },
149+ expectAllowed : false ,
150+ },
151+ {
152+ name : "Denied - Invalid WAF Name (Ends with hyphen)" ,
153+ operation : admissionv1 .Create ,
154+ className : & managedIngressClassName ,
155+ annotations : map [string ]string {
156+ AnnotationWAFName : "my-waf-" ,
157+ },
158+ expectAllowed : false ,
159+ },
160+ {
161+ name : "Denied - Invalid WAF Name (Invalid Character)" ,
162+ operation : admissionv1 .Create ,
163+ className : & managedIngressClassName ,
164+ annotations : map [string ]string {
165+ AnnotationWAFName : "my_waf_name" ,
166+ },
167+ expectAllowed : false ,
168+ },
169+ {
170+ name : "Denied - Invalid WAF Name (Too Long - 64 chars)" ,
171+ operation : admissionv1 .Create ,
172+ className : & managedIngressClassName ,
173+ annotations : map [string ]string {
174+ AnnotationWAFName : "a123456789012345678901234567890123456789012345678901234567890123" ,
175+ },
176+ expectAllowed : false ,
177+ },
115178 }
116179
117180 for _ , tt := range tests {
0 commit comments