@@ -3264,6 +3264,99 @@ func TestBackendTrafficPolicyTarget(t *testing.T) {
32643264 },
32653265 wantErrors : []string {},
32663266 },
3267+ {
3268+ desc : "invalid bandwidthLimit prefix with carriage return" ,
3269+ mutate : func (btp * egv1a1.BackendTrafficPolicy ) {
3270+ btp .Spec = egv1a1.BackendTrafficPolicySpec {
3271+ PolicyTargetReferences : egv1a1.PolicyTargetReferences {
3272+ TargetRef : & gwapiv1.LocalPolicyTargetReferenceWithSectionName {
3273+ LocalPolicyTargetReference : gwapiv1.LocalPolicyTargetReference {
3274+ Group : "gateway.networking.k8s.io" ,
3275+ Kind : "Gateway" ,
3276+ Name : "eg" ,
3277+ },
3278+ },
3279+ },
3280+ BandwidthLimit : & egv1a1.BandwidthLimitSpec {
3281+ Response : & egv1a1.BandwidthLimitResponseConfig {
3282+ Limit : egv1a1.BandwidthLimitValue {
3283+ Value : resource .MustParse ("10M" ),
3284+ Unit : egv1a1 .BandwidthLimitUnitSecond ,
3285+ },
3286+ ResponseTrailers : & egv1a1.BandwidthLimitResponseTrailers {
3287+ Prefix : new ("x - eg \r "),
3288+ },
3289+ },
3290+ },
3291+ }
3292+ },
3293+ wantErrors : []string {
3294+ "spec.bandwidthLimit.response.responseTrailers.prefix" ,
3295+ "in body should match" ,
3296+ },
3297+ },
3298+ {
3299+ desc : "invalid bandwidthLimit prefix with newline" ,
3300+ mutate : func (btp * egv1a1.BackendTrafficPolicy ) {
3301+ btp .Spec = egv1a1.BackendTrafficPolicySpec {
3302+ PolicyTargetReferences : egv1a1.PolicyTargetReferences {
3303+ TargetRef : & gwapiv1.LocalPolicyTargetReferenceWithSectionName {
3304+ LocalPolicyTargetReference : gwapiv1.LocalPolicyTargetReference {
3305+ Group : "gateway.networking.k8s.io" ,
3306+ Kind : "Gateway" ,
3307+ Name : "eg" ,
3308+ },
3309+ },
3310+ },
3311+ BandwidthLimit : & egv1a1.BandwidthLimitSpec {
3312+ Response : & egv1a1.BandwidthLimitResponseConfig {
3313+ Limit : egv1a1.BandwidthLimitValue {
3314+ Value : resource .MustParse ("10M" ),
3315+ Unit : egv1a1 .BandwidthLimitUnitSecond ,
3316+ },
3317+ ResponseTrailers : & egv1a1.BandwidthLimitResponseTrailers {
3318+ Prefix : new ("x - eg \n "),
3319+ },
3320+ },
3321+ },
3322+ }
3323+ },
3324+ wantErrors : []string {
3325+ "spec.bandwidthLimit.response.responseTrailers.prefix" ,
3326+ "in body should match" ,
3327+ },
3328+ },
3329+ {
3330+ desc : "invalid bandwidthLimit prefix with null byte" ,
3331+ mutate : func (btp * egv1a1.BackendTrafficPolicy ) {
3332+ btp .Spec = egv1a1.BackendTrafficPolicySpec {
3333+ PolicyTargetReferences : egv1a1.PolicyTargetReferences {
3334+ TargetRef : & gwapiv1.LocalPolicyTargetReferenceWithSectionName {
3335+ LocalPolicyTargetReference : gwapiv1.LocalPolicyTargetReference {
3336+ Group : "gateway.networking.k8s.io" ,
3337+ Kind : "Gateway" ,
3338+ Name : "eg" ,
3339+ },
3340+ },
3341+ },
3342+ BandwidthLimit : & egv1a1.BandwidthLimitSpec {
3343+ Response : & egv1a1.BandwidthLimitResponseConfig {
3344+ Limit : egv1a1.BandwidthLimitValue {
3345+ Value : resource .MustParse ("10M" ),
3346+ Unit : egv1a1 .BandwidthLimitUnitSecond ,
3347+ },
3348+ ResponseTrailers : & egv1a1.BandwidthLimitResponseTrailers {
3349+ Prefix : new ("x - eg \x00 "),
3350+ },
3351+ },
3352+ },
3353+ }
3354+ },
3355+ wantErrors : []string {
3356+ "spec.bandwidthLimit.response.responseTrailers.prefix" ,
3357+ "in body should match" ,
3358+ },
3359+ },
32673360 {
32683361 desc : "invalid bandwidthLimit with neither request nor response" ,
32693362 mutate : func (btp * egv1a1.BackendTrafficPolicy ) {
0 commit comments