From 531c5c06d35f96abd0111ed4b10dc084c33166ce Mon Sep 17 00:00:00 2001 From: Shraddha Bang Date: Thu, 9 May 2024 14:13:59 -0700 Subject: [PATCH] Add non-alphanumeric input validation test for vpcID --- webhooks/elbv2/targetgroupbinding_validator_test.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/webhooks/elbv2/targetgroupbinding_validator_test.go b/webhooks/elbv2/targetgroupbinding_validator_test.go index 7bbabf71e..386995fbd 100644 --- a/webhooks/elbv2/targetgroupbinding_validator_test.go +++ b/webhooks/elbv2/targetgroupbinding_validator_test.go @@ -1136,6 +1136,18 @@ func Test_targetGroupBindingValidator_checkTargetGroupVpcID(t *testing.T) { }, wantErr: errors.New("ValidationError: vpcID vpcid-123 failed to satisfy constraint: VPC Id must begin with 'vpc-' followed by 8 or 17 lowercase letters (a-f) or numbers."), }, + { + name: "[err] vpcID is not valid - non alphanumeric value", + args: args{ + obj: &elbv2api.TargetGroupBinding{ + Spec: elbv2api.TargetGroupBindingSpec{ + TargetGroupARN: "tg-2", + VpcID: "vpcid-@34!dv", + }, + }, + }, + wantErr: errors.New("ValidationError: vpcID vpcid-@34!dv failed to satisfy constraint: VPC Id must begin with 'vpc-' followed by 8 or 17 lowercase letters (a-f) or numbers."), + }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) {