@@ -23,10 +23,11 @@ func TestNamespaceQuotaValidator_Handle(t *testing.T) {
2323 const nsLimit = 2
2424
2525 tests := map [string ]struct {
26- initObjects []client.Object
27- object client.Object
28- allowed bool
29- matchMessage string
26+ initObjects []client.Object
27+ object client.Object
28+ allowed bool
29+ skipQuotaValidation bool
30+ matchMessage string
3031 }{
3132 "Allow Namespace" : {
3233 initObjects : []client.Object {
@@ -158,6 +159,42 @@ func TestNamespaceQuotaValidator_Handle(t *testing.T) {
158159 },
159160 allowed : false ,
160161 },
162+
163+ "SkipQuotaValidation Allow Namespace TooMany" : {
164+ initObjects : []client.Object {newNamespace ("a" , map [string ]string {orgLabel : "testorg" }, nil ), newNamespace ("b" , map [string ]string {orgLabel : "testorg" }, nil )},
165+ object : & corev1.Namespace {
166+ ObjectMeta : metav1.ObjectMeta {
167+ Name : "test" ,
168+ Labels : map [string ]string {
169+ orgLabel : "testorg" ,
170+ },
171+ },
172+ },
173+ skipQuotaValidation : true ,
174+ allowed : true ,
175+ },
176+ "SkipQuotaValidation Allow ProjectRequest TooMany" : {
177+ initObjects : []client.Object {newNamespace ("a" , map [string ]string {orgLabel : "testorg" }, nil ), newNamespace ("b" , map [string ]string {orgLabel : "testorg" }, nil )},
178+ object : & projectv1.ProjectRequest {
179+ ObjectMeta : metav1.ObjectMeta {
180+ Name : "test" ,
181+ Labels : map [string ]string {
182+ orgLabel : "testorg" ,
183+ },
184+ },
185+ },
186+ skipQuotaValidation : true ,
187+ allowed : true ,
188+ },
189+ "SkipQuotaValidation Deny NoOrganizationLabelAndNoUser" : {
190+ object : & corev1.Namespace {
191+ ObjectMeta : metav1.ObjectMeta {
192+ Name : "test" ,
193+ },
194+ },
195+ skipQuotaValidation : true ,
196+ allowed : false ,
197+ },
161198 }
162199
163200 for name , test := range tests {
@@ -168,6 +205,8 @@ func TestNamespaceQuotaValidator_Handle(t *testing.T) {
168205 Client : c ,
169206 Skipper : skipper.StaticSkipper {ShouldSkip : false },
170207
208+ SkipValidateQuota : test .skipQuotaValidation ,
209+
171210 OrganizationLabel : orgLabel ,
172211 UserDefaultOrganizationAnnotation : userDefaultOrgAnnotation ,
173212
0 commit comments