@@ -124,6 +124,14 @@ func (m *MockedFakeEC2) CreateSecurityGroup(ctx context.Context, request *ec2.Cr
124124 return args .Get (0 ).(* ec2.CreateSecurityGroupOutput ), args .Error (1 )
125125}
126126
127+ func (m * MockedFakeEC2 ) AuthorizeSecurityGroupIngress (ctx context.Context , request * ec2.AuthorizeSecurityGroupIngressInput , optFns ... func (* ec2.Options )) (* ec2.AuthorizeSecurityGroupIngressOutput , error ) {
128+ args := m .Called (request )
129+ if args .Get (0 ) == nil {
130+ return nil , args .Error (1 )
131+ }
132+ return args .Get (0 ).(* ec2.AuthorizeSecurityGroupIngressOutput ), args .Error (1 )
133+ }
134+
127135func (m * MockedFakeEC2 ) DescribeInstanceTopology (ctx context.Context , request * ec2.DescribeInstanceTopologyInput , optFns ... func (* ec2.Options )) ([]ec2types.InstanceTopology , error ) {
128136 args := m .Called (ctx , request )
129137 if args .Get (1 ) != nil {
@@ -4193,6 +4201,11 @@ func TestEnsureLoadBalancer(t *testing.T) {
41934201 },
41944202 }, nil )
41954203
4204+ // Mock AuthorizeSecurityGroupIngress for NLB managed security group
4205+ awsServices .ec2 .(* MockedFakeEC2 ).On ("AuthorizeSecurityGroupIngress" , mock .MatchedBy (func (input * ec2.AuthorizeSecurityGroupIngressInput ) bool {
4206+ return input .GroupId != nil && * input .GroupId == "sg-123456789"
4207+ })).Return (& ec2.AuthorizeSecurityGroupIngressOutput {}, nil ).Maybe ()
4208+
41964209 awsServices .ec2 .(* MockedFakeEC2 ).On ("DescribeSecurityGroups" , & ec2.DescribeSecurityGroupsInput {
41974210 Filters : []ec2types.Filter {
41984211 {
@@ -4210,6 +4223,11 @@ func TestEnsureLoadBalancer(t *testing.T) {
42104223 GroupIds : []string {fakeSecurityGroupID },
42114224 }).Return ([]ec2types.SecurityGroup {{GroupId : aws .String (fakeSecurityGroupID )}}, nil )
42124225
4226+ // Mock AuthorizeSecurityGroupIngress for security group rule creation
4227+ awsServices .ec2 .(* MockedFakeEC2 ).On ("AuthorizeSecurityGroupIngress" , mock .Anything ).Return (
4228+ & ec2.AuthorizeSecurityGroupIngressOutput {}, nil ,
4229+ ).Maybe ()
4230+
42134231 awsServices .ec2 .(* MockedFakeEC2 ).On ("DescribeSecurityGroups" , & ec2.DescribeSecurityGroupsInput {
42144232 Filters : nil ,
42154233 GroupIds : nil ,
0 commit comments