Skip to content

Commit

Permalink
more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
moukoublen committed Jan 30, 2025
1 parent 4cd6061 commit 540de53
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions internal/flavors/benchmark/aws_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"testing"

"github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/credentials"
"github.com/aws/aws-sdk-go-v2/credentials/stscreds"
libbeataws "github.com/elastic/beats/v7/x-pack/libbeat/common/aws"
"github.com/stretchr/testify/mock"
Expand Down Expand Up @@ -111,6 +112,46 @@ func TestAWS_Initialize(t *testing.T) {
fetching.S3Type,
},
},
{
name: "no credential cache in non cloud connectors setup",
cfg: config.Config{
Benchmark: "cis_aws",
CloudConfig: config.CloudConfig{
Aws: config.AwsConfig{
AccountType: config.SingleAccount,
Cred: libbeataws.ConfigAWS{
AccessKeyID: "keyid",
SecretAccessKey: "key",
},
CloudConnectors: false,
},
},
},
identityProvider: func() awslib.IdentityProviderGetter {
cfgMatcher := mock.MatchedBy(func(cfg aws.Config) bool {
_, is := cfg.Credentials.(credentials.StaticCredentialsProvider)
return is
})
identityProvider := &awslib.MockIdentityProviderGetter{}
identityProvider.EXPECT().GetIdentity(mock.Anything, cfgMatcher).Return(
&cloud.Identity{
Account: "test-account",
},
nil,
)

return identityProvider
}(),
want: []string{
fetching.IAMType,
fetching.KmsType,
fetching.TrailType,
fetching.AwsMonitoringType,
fetching.EC2NetworkingType,
fetching.RdsType,
fetching.S3Type,
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
Expand Down

0 comments on commit 540de53

Please sign in to comment.