Add cases to tests AdmissionWebhook
MatchConditions size limit (#119404)
This commit is contained in:
parent
ef4907eddd
commit
eb4063f0ce
@ -24,6 +24,7 @@ import (
|
|||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/http/httptest"
|
"net/http/httptest"
|
||||||
|
"strconv"
|
||||||
"sync"
|
"sync"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
@ -649,7 +650,16 @@ func TestMatchConditions_validation(t *testing.T) {
|
|||||||
Expression: "oldObject == null",
|
Expression: "oldObject == null",
|
||||||
}},
|
}},
|
||||||
expectError: true,
|
expectError: true,
|
||||||
}}
|
}, {
|
||||||
|
name: "less than 65 match conditions should pass",
|
||||||
|
matchConditions: repeatedMatchConditions(64),
|
||||||
|
expectError: false,
|
||||||
|
}, {
|
||||||
|
name: "more than 64 match conditions should error",
|
||||||
|
matchConditions: repeatedMatchConditions(65),
|
||||||
|
expectError: true,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
dryRunCreate := metav1.CreateOptions{
|
dryRunCreate := metav1.CreateOptions{
|
||||||
DryRun: []string{metav1.DryRunAll},
|
DryRun: []string{metav1.DryRunAll},
|
||||||
@ -952,3 +962,14 @@ func newMarkerPod(namespace string) *corev1.Pod {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func repeatedMatchConditions(size int) []admissionregistrationv1.MatchCondition {
|
||||||
|
matchConditions := make([]admissionregistrationv1.MatchCondition, 0, size)
|
||||||
|
for i := 0; i < size; i++ {
|
||||||
|
matchConditions = append(matchConditions, admissionregistrationv1.MatchCondition{
|
||||||
|
Name: "repeated-" + strconv.Itoa(i),
|
||||||
|
Expression: "true",
|
||||||
|
})
|
||||||
|
}
|
||||||
|
return matchConditions
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user