@@ -529,7 +529,7 @@ func TestFilter(t *testing.T) {
529
529
* simpleLabelSelector ,
530
530
},
531
531
}),
532
- enableSelectors : true ,
532
+ enableSelectors : false ,
533
533
compatibilityVersion : v130 ,
534
534
},
535
535
{
@@ -602,7 +602,7 @@ func TestFilter(t *testing.T) {
602
602
attributes : newValidAttribute (& podObject , false ),
603
603
results : []EvaluationResult {
604
604
{
605
- EvalResult : celtypes . True ,
605
+ Error : fmt . Errorf ( "fieldSelector" ) ,
606
606
},
607
607
},
608
608
authorizer : newAuthzAllowMatch (authorizer.AttributesRecord {
@@ -615,6 +615,7 @@ func TestFilter(t *testing.T) {
615
615
Verb : "create" ,
616
616
APIVersion : "*" ,
617
617
}),
618
+ enableSelectors : false ,
618
619
compatibilityVersion : v131 ,
619
620
},
620
621
{
@@ -871,6 +872,7 @@ func TestFilter(t *testing.T) {
871
872
872
873
for _ , tc := range cases {
873
874
t .Run (tc .name , func (t * testing.T ) {
875
+ environment .DisableBaseEnvSetCachingForTests ()
874
876
if tc .enableSelectors {
875
877
featuregatetesting .SetFeatureGateDuringTest (t , utilfeature .DefaultFeatureGate , genericfeatures .AuthorizeWithSelectors , true )
876
878
}
@@ -896,6 +898,7 @@ func TestFilter(t *testing.T) {
896
898
if f == nil {
897
899
t .Fatalf ("unexpected nil validator" )
898
900
}
901
+
899
902
validations := tc .validations
900
903
CompilationResults := f .(* filter ).compilationResults
901
904
require .Equal (t , len (validations ), len (CompilationResults ))
@@ -913,8 +916,13 @@ func TestFilter(t *testing.T) {
913
916
}
914
917
require .Equal (t , len (evalResults ), len (tc .results ))
915
918
for i , result := range tc .results {
919
+ if result .Error != nil && evalResults [i ].Error == nil {
920
+ t .Errorf ("Expected error result containing '%v' but got non-error" , result .Error )
921
+ continue
922
+ }
916
923
if result .Error != nil && ! strings .Contains (evalResults [i ].Error .Error (), result .Error .Error ()) {
917
924
t .Errorf ("Expected result '%v' but got '%v'" , result .Error , evalResults [i ].Error )
925
+ continue
918
926
}
919
927
if result .Error == nil && evalResults [i ].Error != nil {
920
928
t .Errorf ("Expected result '%v' but got error '%v'" , result .EvalResult , evalResults [i ].Error )
0 commit comments