test(middlewares): aws security group rule defaults
parent
f01227d35a
commit
2c8a0f7fc1
|
@ -7,6 +7,8 @@ import (
|
|||
"github.com/cloudskiff/driftctl/pkg/resource/aws"
|
||||
)
|
||||
|
||||
const defaultAwsSecurityGroupName = "default"
|
||||
|
||||
// When scanning a brand new AWS account, some users may see irrelevant results about default AWS role policies.
|
||||
// We ignore these resources by default when strict mode is disabled.
|
||||
type AwsSecurityGroupDefaults struct{}
|
||||
|
@ -33,7 +35,7 @@ func (m AwsSecurityGroupDefaults) Execute(remoteResources, resourcesFromState *[
|
|||
}
|
||||
}
|
||||
|
||||
if existInState || *remoteResource.(*aws.AwsSecurityGroup).Name != "default" {
|
||||
if existInState || *remoteResource.(*aws.AwsSecurityGroup).Name != defaultAwsSecurityGroupName {
|
||||
newRemoteResources = append(newRemoteResources, remoteResource)
|
||||
continue
|
||||
}
|
||||
|
|
|
@ -7,8 +7,6 @@ import (
|
|||
"github.com/cloudskiff/driftctl/pkg/resource/aws"
|
||||
)
|
||||
|
||||
const defaultAwsSecurityGroupName = "default"
|
||||
|
||||
// When scanning a brand new AWS account, some users may see irrelevant results about default AWS role policies.
|
||||
// We ignore these resources by default when strict mode is disabled.
|
||||
type AwsSecurityGroupRuleDefaults struct{}
|
||||
|
|
|
@ -54,7 +54,17 @@ func TestAwsSecurityGroupRuleDefaults_Execute(t *testing.T) {
|
|||
GatewayId: awssdk.String("local"),
|
||||
},
|
||||
},
|
||||
diff.Changelog{},
|
||||
diff.Changelog{
|
||||
{
|
||||
Type: "delete",
|
||||
Path: []string{"0"},
|
||||
From: &aws.AwsSecurityGroup{
|
||||
Id: defaultSecurityGroupId,
|
||||
Name: &defaultSecurityGroupName,
|
||||
},
|
||||
To: nil,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
"default security group when they're managed by IaC",
|
||||
|
@ -110,10 +120,7 @@ func TestAwsSecurityGroupRuleDefaults_Execute(t *testing.T) {
|
|||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
m := NewChain(
|
||||
NewAwsSecurityGroupDefaults(),
|
||||
NewAwsSecurityGroupRuleDefaults(),
|
||||
)
|
||||
m := NewAwsSecurityGroupRuleDefaults()
|
||||
err := m.Execute(&tt.remoteResources, &tt.resourcesFromState)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
|
|
Loading…
Reference in New Issue