chore: fix mess with repository imports
parent
7fcbbf915f
commit
4fcd0e8685
|
@ -1,19 +1,19 @@
|
|||
package aws
|
||||
|
||||
import (
|
||||
repository2 "github.com/snyk/driftctl/enumeration/remote/aws/repository"
|
||||
"github.com/snyk/driftctl/enumeration/remote/aws/repository"
|
||||
remoteerror "github.com/snyk/driftctl/enumeration/remote/error"
|
||||
"github.com/snyk/driftctl/enumeration/resource"
|
||||
"github.com/snyk/driftctl/enumeration/resource/aws"
|
||||
)
|
||||
|
||||
type ApiGatewayV2MappingEnumerator struct {
|
||||
repository repository2.ApiGatewayV2Repository
|
||||
repositoryV1 repository2.ApiGatewayRepository
|
||||
repository repository.ApiGatewayV2Repository
|
||||
repositoryV1 repository.ApiGatewayRepository
|
||||
factory resource.ResourceFactory
|
||||
}
|
||||
|
||||
func NewApiGatewayV2MappingEnumerator(repo repository2.ApiGatewayV2Repository, repov1 repository2.ApiGatewayRepository, factory resource.ResourceFactory) *ApiGatewayV2MappingEnumerator {
|
||||
func NewApiGatewayV2MappingEnumerator(repo repository.ApiGatewayV2Repository, repov1 repository.ApiGatewayRepository, factory resource.ResourceFactory) *ApiGatewayV2MappingEnumerator {
|
||||
return &ApiGatewayV2MappingEnumerator{
|
||||
repository: repo,
|
||||
repositoryV1: repov1,
|
||||
|
|
|
@ -4,7 +4,7 @@ import (
|
|||
"github.com/snyk/driftctl/enumeration"
|
||||
"github.com/snyk/driftctl/enumeration/alerter"
|
||||
"github.com/snyk/driftctl/enumeration/remote/aws/client"
|
||||
repository2 "github.com/snyk/driftctl/enumeration/remote/aws/repository"
|
||||
"github.com/snyk/driftctl/enumeration/remote/aws/repository"
|
||||
"github.com/snyk/driftctl/enumeration/remote/cache"
|
||||
common2 "github.com/snyk/driftctl/enumeration/remote/common"
|
||||
"github.com/snyk/driftctl/enumeration/resource"
|
||||
|
@ -40,26 +40,26 @@ func Init(version string, alerter *alerter.Alerter,
|
|||
|
||||
repositoryCache := cache.New(100)
|
||||
|
||||
s3Repository := repository2.NewS3Repository(client.NewAWSClientFactory(provider.session), repositoryCache)
|
||||
ec2repository := repository2.NewEC2Repository(provider.session, repositoryCache)
|
||||
elbv2Repository := repository2.NewELBV2Repository(provider.session, repositoryCache)
|
||||
route53repository := repository2.NewRoute53Repository(provider.session, repositoryCache)
|
||||
lambdaRepository := repository2.NewLambdaRepository(provider.session, repositoryCache)
|
||||
rdsRepository := repository2.NewRDSRepository(provider.session, repositoryCache)
|
||||
sqsRepository := repository2.NewSQSRepository(provider.session, repositoryCache)
|
||||
snsRepository := repository2.NewSNSRepository(provider.session, repositoryCache)
|
||||
cloudfrontRepository := repository2.NewCloudfrontRepository(provider.session, repositoryCache)
|
||||
dynamoDBRepository := repository2.NewDynamoDBRepository(provider.session, repositoryCache)
|
||||
ecrRepository := repository2.NewECRRepository(provider.session, repositoryCache)
|
||||
kmsRepository := repository2.NewKMSRepository(provider.session, repositoryCache)
|
||||
iamRepository := repository2.NewIAMRepository(provider.session, repositoryCache)
|
||||
cloudformationRepository := repository2.NewCloudformationRepository(provider.session, repositoryCache)
|
||||
apigatewayRepository := repository2.NewApiGatewayRepository(provider.session, repositoryCache)
|
||||
appAutoScalingRepository := repository2.NewAppAutoScalingRepository(provider.session, repositoryCache)
|
||||
apigatewayv2Repository := repository2.NewApiGatewayV2Repository(provider.session, repositoryCache)
|
||||
autoscalingRepository := repository2.NewAutoScalingRepository(provider.session, repositoryCache)
|
||||
elbRepository := repository2.NewELBRepository(provider.session, repositoryCache)
|
||||
elasticacheRepository := repository2.NewElastiCacheRepository(provider.session, repositoryCache)
|
||||
s3Repository := repository.NewS3Repository(client.NewAWSClientFactory(provider.session), repositoryCache)
|
||||
ec2repository := repository.NewEC2Repository(provider.session, repositoryCache)
|
||||
elbv2Repository := repository.NewELBV2Repository(provider.session, repositoryCache)
|
||||
route53repository := repository.NewRoute53Repository(provider.session, repositoryCache)
|
||||
lambdaRepository := repository.NewLambdaRepository(provider.session, repositoryCache)
|
||||
rdsRepository := repository.NewRDSRepository(provider.session, repositoryCache)
|
||||
sqsRepository := repository.NewSQSRepository(provider.session, repositoryCache)
|
||||
snsRepository := repository.NewSNSRepository(provider.session, repositoryCache)
|
||||
cloudfrontRepository := repository.NewCloudfrontRepository(provider.session, repositoryCache)
|
||||
dynamoDBRepository := repository.NewDynamoDBRepository(provider.session, repositoryCache)
|
||||
ecrRepository := repository.NewECRRepository(provider.session, repositoryCache)
|
||||
kmsRepository := repository.NewKMSRepository(provider.session, repositoryCache)
|
||||
iamRepository := repository.NewIAMRepository(provider.session, repositoryCache)
|
||||
cloudformationRepository := repository.NewCloudformationRepository(provider.session, repositoryCache)
|
||||
apigatewayRepository := repository.NewApiGatewayRepository(provider.session, repositoryCache)
|
||||
appAutoScalingRepository := repository.NewAppAutoScalingRepository(provider.session, repositoryCache)
|
||||
apigatewayv2Repository := repository.NewApiGatewayV2Repository(provider.session, repositoryCache)
|
||||
autoscalingRepository := repository.NewAutoScalingRepository(provider.session, repositoryCache)
|
||||
elbRepository := repository.NewELBRepository(provider.session, repositoryCache)
|
||||
elasticacheRepository := repository.NewElastiCacheRepository(provider.session, repositoryCache)
|
||||
|
||||
deserializer := resource.NewDeserializer(factory)
|
||||
providerLibrary.AddProvider(terraform.AWS, provider)
|
||||
|
|
|
@ -9,7 +9,7 @@ import (
|
|||
"github.com/snyk/driftctl/enumeration"
|
||||
"github.com/snyk/driftctl/enumeration/remote/alerts"
|
||||
aws2 "github.com/snyk/driftctl/enumeration/remote/aws"
|
||||
repository2 "github.com/snyk/driftctl/enumeration/remote/aws/repository"
|
||||
"github.com/snyk/driftctl/enumeration/remote/aws/repository"
|
||||
common2 "github.com/snyk/driftctl/enumeration/remote/common"
|
||||
remoteerr "github.com/snyk/driftctl/enumeration/remote/error"
|
||||
"github.com/snyk/driftctl/enumeration/resource"
|
||||
|
@ -28,13 +28,13 @@ func TestApiGatewayRestApi(t *testing.T) {
|
|||
|
||||
tests := []struct {
|
||||
test string
|
||||
mocks func(*repository2.MockApiGatewayRepository, *mocks.AlerterInterface)
|
||||
mocks func(*repository.MockApiGatewayRepository, *mocks.AlerterInterface)
|
||||
assertExpected func(t *testing.T, got []*resource.Resource)
|
||||
wantErr error
|
||||
}{
|
||||
{
|
||||
test: "no api gateway rest apis",
|
||||
mocks: func(repository *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) {
|
||||
repository.On("ListAllRestApis").Return([]*apigateway.RestApi{}, nil)
|
||||
},
|
||||
assertExpected: func(t *testing.T, got []*resource.Resource) {
|
||||
|
@ -43,7 +43,7 @@ func TestApiGatewayRestApi(t *testing.T) {
|
|||
},
|
||||
{
|
||||
test: "multiple api gateway rest apis",
|
||||
mocks: func(repository *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) {
|
||||
repository.On("ListAllRestApis").Return([]*apigateway.RestApi{
|
||||
{Id: awssdk.String("3of73v5ob4")},
|
||||
{Id: awssdk.String("1jitcobwol")},
|
||||
|
@ -61,7 +61,7 @@ func TestApiGatewayRestApi(t *testing.T) {
|
|||
},
|
||||
{
|
||||
test: "cannot list api gateway rest apis",
|
||||
mocks: func(repository *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) {
|
||||
repository.On("ListAllRestApis").Return(nil, dummyError)
|
||||
alerter.On("SendAlert", resourceaws.AwsApiGatewayRestApiResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayRestApiResourceType, resourceaws.AwsApiGatewayRestApiResourceType), alerts.EnumerationPhase)).Return()
|
||||
},
|
||||
|
@ -81,10 +81,10 @@ func TestApiGatewayRestApi(t *testing.T) {
|
|||
|
||||
// Initialize mocks
|
||||
alerter := &mocks.AlerterInterface{}
|
||||
fakeRepo := &repository2.MockApiGatewayRepository{}
|
||||
fakeRepo := &repository.MockApiGatewayRepository{}
|
||||
c.mocks(fakeRepo, alerter)
|
||||
|
||||
var repo repository2.ApiGatewayRepository = fakeRepo
|
||||
var repo repository.ApiGatewayRepository = fakeRepo
|
||||
|
||||
remoteLibrary.AddEnumerator(aws2.NewApiGatewayRestApiEnumerator(repo, factory))
|
||||
|
||||
|
@ -111,13 +111,13 @@ func TestApiGatewayAccount(t *testing.T) {
|
|||
|
||||
tests := []struct {
|
||||
test string
|
||||
mocks func(*repository2.MockApiGatewayRepository, *mocks.AlerterInterface)
|
||||
mocks func(*repository.MockApiGatewayRepository, *mocks.AlerterInterface)
|
||||
assertExpected func(t *testing.T, got []*resource.Resource)
|
||||
wantErr error
|
||||
}{
|
||||
{
|
||||
test: "no api gateway account",
|
||||
mocks: func(repository *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) {
|
||||
repository.On("GetAccount").Return(nil, nil)
|
||||
},
|
||||
assertExpected: func(t *testing.T, got []*resource.Resource) {
|
||||
|
@ -126,7 +126,7 @@ func TestApiGatewayAccount(t *testing.T) {
|
|||
},
|
||||
{
|
||||
test: "empty api gateway account",
|
||||
mocks: func(repository *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) {
|
||||
repository.On("GetAccount").Return(&apigateway.Account{}, nil)
|
||||
},
|
||||
assertExpected: func(t *testing.T, got []*resource.Resource) {
|
||||
|
@ -138,7 +138,7 @@ func TestApiGatewayAccount(t *testing.T) {
|
|||
},
|
||||
{
|
||||
test: "cannot get api gateway account",
|
||||
mocks: func(repository *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) {
|
||||
repository.On("GetAccount").Return(nil, dummyError)
|
||||
alerter.On("SendAlert", resourceaws.AwsApiGatewayAccountResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayAccountResourceType, resourceaws.AwsApiGatewayAccountResourceType), alerts.EnumerationPhase)).Return()
|
||||
},
|
||||
|
@ -158,10 +158,10 @@ func TestApiGatewayAccount(t *testing.T) {
|
|||
|
||||
// Initialize mocks
|
||||
alerter := &mocks.AlerterInterface{}
|
||||
fakeRepo := &repository2.MockApiGatewayRepository{}
|
||||
fakeRepo := &repository.MockApiGatewayRepository{}
|
||||
c.mocks(fakeRepo, alerter)
|
||||
|
||||
var repo repository2.ApiGatewayRepository = fakeRepo
|
||||
var repo repository.ApiGatewayRepository = fakeRepo
|
||||
|
||||
remoteLibrary.AddEnumerator(aws2.NewApiGatewayAccountEnumerator(repo, factory))
|
||||
|
||||
|
@ -188,13 +188,13 @@ func TestApiGatewayApiKey(t *testing.T) {
|
|||
|
||||
tests := []struct {
|
||||
test string
|
||||
mocks func(*repository2.MockApiGatewayRepository, *mocks.AlerterInterface)
|
||||
mocks func(*repository.MockApiGatewayRepository, *mocks.AlerterInterface)
|
||||
assertExpected func(t *testing.T, got []*resource.Resource)
|
||||
wantErr error
|
||||
}{
|
||||
{
|
||||
test: "no api gateway api keys",
|
||||
mocks: func(repository *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) {
|
||||
repository.On("ListAllApiKeys").Return([]*apigateway.ApiKey{}, nil)
|
||||
},
|
||||
assertExpected: func(t *testing.T, got []*resource.Resource) {
|
||||
|
@ -203,7 +203,7 @@ func TestApiGatewayApiKey(t *testing.T) {
|
|||
},
|
||||
{
|
||||
test: "multiple api gateway api keys",
|
||||
mocks: func(repository *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) {
|
||||
repository.On("ListAllApiKeys").Return([]*apigateway.ApiKey{
|
||||
{Id: awssdk.String("fuwnl8lrva")},
|
||||
{Id: awssdk.String("9ge737dd45")},
|
||||
|
@ -221,7 +221,7 @@ func TestApiGatewayApiKey(t *testing.T) {
|
|||
},
|
||||
{
|
||||
test: "cannot list api gateway api keys",
|
||||
mocks: func(repository *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) {
|
||||
repository.On("ListAllApiKeys").Return(nil, dummyError)
|
||||
alerter.On("SendAlert", resourceaws.AwsApiGatewayApiKeyResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayApiKeyResourceType, resourceaws.AwsApiGatewayApiKeyResourceType), alerts.EnumerationPhase)).Return()
|
||||
},
|
||||
|
@ -241,10 +241,10 @@ func TestApiGatewayApiKey(t *testing.T) {
|
|||
|
||||
// Initialize mocks
|
||||
alerter := &mocks.AlerterInterface{}
|
||||
fakeRepo := &repository2.MockApiGatewayRepository{}
|
||||
fakeRepo := &repository.MockApiGatewayRepository{}
|
||||
c.mocks(fakeRepo, alerter)
|
||||
|
||||
var repo repository2.ApiGatewayRepository = fakeRepo
|
||||
var repo repository.ApiGatewayRepository = fakeRepo
|
||||
|
||||
remoteLibrary.AddEnumerator(aws2.NewApiGatewayApiKeyEnumerator(repo, factory))
|
||||
|
||||
|
@ -275,13 +275,13 @@ func TestApiGatewayAuthorizer(t *testing.T) {
|
|||
|
||||
tests := []struct {
|
||||
test string
|
||||
mocks func(*repository2.MockApiGatewayRepository, *mocks.AlerterInterface)
|
||||
mocks func(*repository.MockApiGatewayRepository, *mocks.AlerterInterface)
|
||||
assertExpected func(t *testing.T, got []*resource.Resource)
|
||||
wantErr error
|
||||
}{
|
||||
{
|
||||
test: "no api gateway authorizers",
|
||||
mocks: func(repo *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) {
|
||||
repo.On("ListAllRestApis").Return(apis, nil)
|
||||
repo.On("ListAllRestApiAuthorizers", *apis[0].Id).Return([]*apigateway.Authorizer{}, nil).Once()
|
||||
repo.On("ListAllRestApiAuthorizers", *apis[1].Id).Return([]*apigateway.Authorizer{}, nil).Once()
|
||||
|
@ -292,7 +292,7 @@ func TestApiGatewayAuthorizer(t *testing.T) {
|
|||
},
|
||||
{
|
||||
test: "multiple api gateway authorizers",
|
||||
mocks: func(repo *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) {
|
||||
repo.On("ListAllRestApis").Return(apis, nil)
|
||||
repo.On("ListAllRestApiAuthorizers", *apis[0].Id).Return([]*apigateway.Authorizer{
|
||||
{Id: awssdk.String("ypcpde")},
|
||||
|
@ -313,7 +313,7 @@ func TestApiGatewayAuthorizer(t *testing.T) {
|
|||
},
|
||||
{
|
||||
test: "cannot list rest apis",
|
||||
mocks: func(repo *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) {
|
||||
repo.On("ListAllRestApis").Return(nil, dummyError)
|
||||
alerter.On("SendAlert", resourceaws.AwsApiGatewayAuthorizerResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayAuthorizerResourceType, resourceaws.AwsApiGatewayRestApiResourceType), alerts.EnumerationPhase)).Return()
|
||||
},
|
||||
|
@ -321,7 +321,7 @@ func TestApiGatewayAuthorizer(t *testing.T) {
|
|||
},
|
||||
{
|
||||
test: "cannot list api gateway resources",
|
||||
mocks: func(repo *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) {
|
||||
repo.On("ListAllRestApis").Return(apis, nil)
|
||||
repo.On("ListAllRestApiAuthorizers", *apis[0].Id).Return(nil, dummyError)
|
||||
alerter.On("SendAlert", resourceaws.AwsApiGatewayAuthorizerResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayAuthorizerResourceType, resourceaws.AwsApiGatewayAuthorizerResourceType), alerts.EnumerationPhase)).Return()
|
||||
|
@ -342,10 +342,10 @@ func TestApiGatewayAuthorizer(t *testing.T) {
|
|||
|
||||
// Initialize mocks
|
||||
alerter := &mocks.AlerterInterface{}
|
||||
fakeRepo := &repository2.MockApiGatewayRepository{}
|
||||
fakeRepo := &repository.MockApiGatewayRepository{}
|
||||
c.mocks(fakeRepo, alerter)
|
||||
|
||||
var repo repository2.ApiGatewayRepository = fakeRepo
|
||||
var repo repository.ApiGatewayRepository = fakeRepo
|
||||
|
||||
remoteLibrary.AddEnumerator(aws2.NewApiGatewayAuthorizerEnumerator(repo, factory))
|
||||
|
||||
|
@ -375,13 +375,13 @@ func TestApiGatewayStage(t *testing.T) {
|
|||
|
||||
tests := []struct {
|
||||
test string
|
||||
mocks func(*repository2.MockApiGatewayRepository, *mocks.AlerterInterface)
|
||||
mocks func(*repository.MockApiGatewayRepository, *mocks.AlerterInterface)
|
||||
assertExpected func(t *testing.T, got []*resource.Resource)
|
||||
wantErr error
|
||||
}{
|
||||
{
|
||||
test: "no api gateway stages",
|
||||
mocks: func(repo *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) {
|
||||
repo.On("ListAllRestApis").Return(apis, nil)
|
||||
repo.On("ListAllRestApiStages", *apis[0].Id).Return([]*apigateway.Stage{}, nil)
|
||||
},
|
||||
|
@ -391,7 +391,7 @@ func TestApiGatewayStage(t *testing.T) {
|
|||
},
|
||||
{
|
||||
test: "multiple api gateway stages",
|
||||
mocks: func(repo *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) {
|
||||
repo.On("ListAllRestApis").Return(apis, nil)
|
||||
repo.On("ListAllRestApiStages", *apis[0].Id).Return([]*apigateway.Stage{
|
||||
{StageName: awssdk.String("foo")},
|
||||
|
@ -410,7 +410,7 @@ func TestApiGatewayStage(t *testing.T) {
|
|||
},
|
||||
{
|
||||
test: "cannot list rest apis",
|
||||
mocks: func(repo *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) {
|
||||
repo.On("ListAllRestApis").Return(nil, dummyError)
|
||||
alerter.On("SendAlert", resourceaws.AwsApiGatewayStageResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayStageResourceType, resourceaws.AwsApiGatewayRestApiResourceType), alerts.EnumerationPhase)).Return()
|
||||
},
|
||||
|
@ -418,7 +418,7 @@ func TestApiGatewayStage(t *testing.T) {
|
|||
},
|
||||
{
|
||||
test: "cannot list api gateway stages",
|
||||
mocks: func(repo *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) {
|
||||
repo.On("ListAllRestApis").Return(apis, nil)
|
||||
repo.On("ListAllRestApiStages", *apis[0].Id).Return(nil, dummyError)
|
||||
alerter.On("SendAlert", resourceaws.AwsApiGatewayStageResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayStageResourceType, resourceaws.AwsApiGatewayStageResourceType), alerts.EnumerationPhase)).Return()
|
||||
|
@ -439,10 +439,10 @@ func TestApiGatewayStage(t *testing.T) {
|
|||
|
||||
// Initialize mocks
|
||||
alerter := &mocks.AlerterInterface{}
|
||||
fakeRepo := &repository2.MockApiGatewayRepository{}
|
||||
fakeRepo := &repository.MockApiGatewayRepository{}
|
||||
c.mocks(fakeRepo, alerter)
|
||||
|
||||
var repo repository2.ApiGatewayRepository = fakeRepo
|
||||
var repo repository.ApiGatewayRepository = fakeRepo
|
||||
|
||||
remoteLibrary.AddEnumerator(aws2.NewApiGatewayStageEnumerator(repo, factory))
|
||||
|
||||
|
@ -472,13 +472,13 @@ func TestApiGatewayResource(t *testing.T) {
|
|||
|
||||
tests := []struct {
|
||||
test string
|
||||
mocks func(*repository2.MockApiGatewayRepository, *mocks.AlerterInterface)
|
||||
mocks func(*repository.MockApiGatewayRepository, *mocks.AlerterInterface)
|
||||
assertExpected func(t *testing.T, got []*resource.Resource)
|
||||
wantErr error
|
||||
}{
|
||||
{
|
||||
test: "no api gateway resources",
|
||||
mocks: func(repo *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) {
|
||||
repo.On("ListAllRestApis").Return(apis, nil)
|
||||
repo.On("ListAllRestApiResources", *apis[0].Id).Return([]*apigateway.Resource{}, nil)
|
||||
},
|
||||
|
@ -488,7 +488,7 @@ func TestApiGatewayResource(t *testing.T) {
|
|||
},
|
||||
{
|
||||
test: "multiple api gateway resources",
|
||||
mocks: func(repo *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) {
|
||||
repo.On("ListAllRestApis").Return(apis, nil)
|
||||
repo.On("ListAllRestApiResources", *apis[0].Id).Return([]*apigateway.Resource{
|
||||
{Id: awssdk.String("21zk4y"), Path: awssdk.String("/")},
|
||||
|
@ -507,7 +507,7 @@ func TestApiGatewayResource(t *testing.T) {
|
|||
},
|
||||
{
|
||||
test: "cannot list rest apis",
|
||||
mocks: func(repo *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) {
|
||||
repo.On("ListAllRestApis").Return(nil, dummyError)
|
||||
alerter.On("SendAlert", resourceaws.AwsApiGatewayResourceResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayResourceResourceType, resourceaws.AwsApiGatewayRestApiResourceType), alerts.EnumerationPhase)).Return()
|
||||
},
|
||||
|
@ -515,7 +515,7 @@ func TestApiGatewayResource(t *testing.T) {
|
|||
},
|
||||
{
|
||||
test: "cannot list api gateway resources",
|
||||
mocks: func(repo *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) {
|
||||
repo.On("ListAllRestApis").Return(apis, nil)
|
||||
repo.On("ListAllRestApiResources", *apis[0].Id).Return(nil, dummyError)
|
||||
alerter.On("SendAlert", resourceaws.AwsApiGatewayResourceResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayResourceResourceType, resourceaws.AwsApiGatewayResourceResourceType), alerts.EnumerationPhase)).Return()
|
||||
|
@ -536,10 +536,10 @@ func TestApiGatewayResource(t *testing.T) {
|
|||
|
||||
// Initialize mocks
|
||||
alerter := &mocks.AlerterInterface{}
|
||||
fakeRepo := &repository2.MockApiGatewayRepository{}
|
||||
fakeRepo := &repository.MockApiGatewayRepository{}
|
||||
c.mocks(fakeRepo, alerter)
|
||||
|
||||
var repo repository2.ApiGatewayRepository = fakeRepo
|
||||
var repo repository.ApiGatewayRepository = fakeRepo
|
||||
|
||||
remoteLibrary.AddEnumerator(aws2.NewApiGatewayResourceEnumerator(repo, factory))
|
||||
|
||||
|
@ -566,13 +566,13 @@ func TestApiGatewayDomainName(t *testing.T) {
|
|||
|
||||
tests := []struct {
|
||||
test string
|
||||
mocks func(*repository2.MockApiGatewayRepository, *mocks.AlerterInterface)
|
||||
mocks func(*repository.MockApiGatewayRepository, *mocks.AlerterInterface)
|
||||
assertExpected func(t *testing.T, got []*resource.Resource)
|
||||
wantErr error
|
||||
}{
|
||||
{
|
||||
test: "no api gateway domain names",
|
||||
mocks: func(repository *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) {
|
||||
repository.On("ListAllDomainNames").Return([]*apigateway.DomainName{}, nil)
|
||||
},
|
||||
assertExpected: func(t *testing.T, got []*resource.Resource) {
|
||||
|
@ -581,7 +581,7 @@ func TestApiGatewayDomainName(t *testing.T) {
|
|||
},
|
||||
{
|
||||
test: "single api gateway domain name",
|
||||
mocks: func(repository *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) {
|
||||
repository.On("ListAllDomainNames").Return([]*apigateway.DomainName{
|
||||
{DomainName: awssdk.String("example-driftctl.com")},
|
||||
}, nil)
|
||||
|
@ -595,7 +595,7 @@ func TestApiGatewayDomainName(t *testing.T) {
|
|||
},
|
||||
{
|
||||
test: "cannot list api gateway domain names",
|
||||
mocks: func(repository *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) {
|
||||
repository.On("ListAllDomainNames").Return(nil, dummyError)
|
||||
alerter.On("SendAlert", resourceaws.AwsApiGatewayDomainNameResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayDomainNameResourceType, resourceaws.AwsApiGatewayDomainNameResourceType), alerts.EnumerationPhase)).Return()
|
||||
},
|
||||
|
@ -615,10 +615,10 @@ func TestApiGatewayDomainName(t *testing.T) {
|
|||
|
||||
// Initialize mocks
|
||||
alerter := &mocks.AlerterInterface{}
|
||||
fakeRepo := &repository2.MockApiGatewayRepository{}
|
||||
fakeRepo := &repository.MockApiGatewayRepository{}
|
||||
c.mocks(fakeRepo, alerter)
|
||||
|
||||
var repo repository2.ApiGatewayRepository = fakeRepo
|
||||
var repo repository.ApiGatewayRepository = fakeRepo
|
||||
|
||||
remoteLibrary.AddEnumerator(aws2.NewApiGatewayDomainNameEnumerator(repo, factory))
|
||||
|
||||
|
@ -645,13 +645,13 @@ func TestApiGatewayVpcLink(t *testing.T) {
|
|||
|
||||
tests := []struct {
|
||||
test string
|
||||
mocks func(*repository2.MockApiGatewayRepository, *mocks.AlerterInterface)
|
||||
mocks func(*repository.MockApiGatewayRepository, *mocks.AlerterInterface)
|
||||
assertExpected func(t *testing.T, got []*resource.Resource)
|
||||
wantErr error
|
||||
}{
|
||||
{
|
||||
test: "no api gateway vpc links",
|
||||
mocks: func(repository *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) {
|
||||
repository.On("ListAllVpcLinks").Return([]*apigateway.UpdateVpcLinkOutput{}, nil)
|
||||
},
|
||||
assertExpected: func(t *testing.T, got []*resource.Resource) {
|
||||
|
@ -660,7 +660,7 @@ func TestApiGatewayVpcLink(t *testing.T) {
|
|||
},
|
||||
{
|
||||
test: "single api gateway vpc link",
|
||||
mocks: func(repository *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) {
|
||||
repository.On("ListAllVpcLinks").Return([]*apigateway.UpdateVpcLinkOutput{
|
||||
{Id: awssdk.String("ipu24n")},
|
||||
}, nil)
|
||||
|
@ -674,7 +674,7 @@ func TestApiGatewayVpcLink(t *testing.T) {
|
|||
},
|
||||
{
|
||||
test: "cannot list api gateway vpc links",
|
||||
mocks: func(repository *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) {
|
||||
repository.On("ListAllVpcLinks").Return(nil, dummyError)
|
||||
alerter.On("SendAlert", resourceaws.AwsApiGatewayVpcLinkResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayVpcLinkResourceType, resourceaws.AwsApiGatewayVpcLinkResourceType), alerts.EnumerationPhase)).Return()
|
||||
},
|
||||
|
@ -694,10 +694,10 @@ func TestApiGatewayVpcLink(t *testing.T) {
|
|||
|
||||
// Initialize mocks
|
||||
alerter := &mocks.AlerterInterface{}
|
||||
fakeRepo := &repository2.MockApiGatewayRepository{}
|
||||
fakeRepo := &repository.MockApiGatewayRepository{}
|
||||
c.mocks(fakeRepo, alerter)
|
||||
|
||||
var repo repository2.ApiGatewayRepository = fakeRepo
|
||||
var repo repository.ApiGatewayRepository = fakeRepo
|
||||
|
||||
remoteLibrary.AddEnumerator(aws2.NewApiGatewayVpcLinkEnumerator(repo, factory))
|
||||
|
||||
|
@ -727,13 +727,13 @@ func TestApiGatewayRequestValidator(t *testing.T) {
|
|||
|
||||
tests := []struct {
|
||||
test string
|
||||
mocks func(*repository2.MockApiGatewayRepository, *mocks.AlerterInterface)
|
||||
mocks func(*repository.MockApiGatewayRepository, *mocks.AlerterInterface)
|
||||
assertExpected func(t *testing.T, got []*resource.Resource)
|
||||
wantErr error
|
||||
}{
|
||||
{
|
||||
test: "no api gateway request validators",
|
||||
mocks: func(repo *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) {
|
||||
repo.On("ListAllRestApis").Return(apis, nil)
|
||||
repo.On("ListAllRestApiRequestValidators", *apis[0].Id).Return([]*apigateway.UpdateRequestValidatorOutput{}, nil)
|
||||
},
|
||||
|
@ -743,7 +743,7 @@ func TestApiGatewayRequestValidator(t *testing.T) {
|
|||
},
|
||||
{
|
||||
test: "multiple api gateway request validators",
|
||||
mocks: func(repo *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) {
|
||||
repo.On("ListAllRestApis").Return(apis, nil)
|
||||
repo.On("ListAllRestApiRequestValidators", *apis[0].Id).Return([]*apigateway.UpdateRequestValidatorOutput{
|
||||
{Id: awssdk.String("ywlcuf")},
|
||||
|
@ -762,7 +762,7 @@ func TestApiGatewayRequestValidator(t *testing.T) {
|
|||
},
|
||||
{
|
||||
test: "cannot list rest apis",
|
||||
mocks: func(repo *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) {
|
||||
repo.On("ListAllRestApis").Return(nil, dummyError)
|
||||
alerter.On("SendAlert", resourceaws.AwsApiGatewayRequestValidatorResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayRequestValidatorResourceType, resourceaws.AwsApiGatewayRestApiResourceType), alerts.EnumerationPhase)).Return()
|
||||
},
|
||||
|
@ -770,7 +770,7 @@ func TestApiGatewayRequestValidator(t *testing.T) {
|
|||
},
|
||||
{
|
||||
test: "cannot list api gateway request validators",
|
||||
mocks: func(repo *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) {
|
||||
repo.On("ListAllRestApis").Return(apis, nil)
|
||||
repo.On("ListAllRestApiRequestValidators", *apis[0].Id).Return(nil, dummyError)
|
||||
alerter.On("SendAlert", resourceaws.AwsApiGatewayRequestValidatorResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayRequestValidatorResourceType, resourceaws.AwsApiGatewayRequestValidatorResourceType), alerts.EnumerationPhase)).Return()
|
||||
|
@ -791,10 +791,10 @@ func TestApiGatewayRequestValidator(t *testing.T) {
|
|||
|
||||
// Initialize mocks
|
||||
alerter := &mocks.AlerterInterface{}
|
||||
fakeRepo := &repository2.MockApiGatewayRepository{}
|
||||
fakeRepo := &repository.MockApiGatewayRepository{}
|
||||
c.mocks(fakeRepo, alerter)
|
||||
|
||||
var repo repository2.ApiGatewayRepository = fakeRepo
|
||||
var repo repository.ApiGatewayRepository = fakeRepo
|
||||
|
||||
remoteLibrary.AddEnumerator(aws2.NewApiGatewayRequestValidatorEnumerator(repo, factory))
|
||||
|
||||
|
@ -821,13 +821,13 @@ func TestApiGatewayRestApiPolicy(t *testing.T) {
|
|||
|
||||
tests := []struct {
|
||||
test string
|
||||
mocks func(*repository2.MockApiGatewayRepository, *mocks.AlerterInterface)
|
||||
mocks func(*repository.MockApiGatewayRepository, *mocks.AlerterInterface)
|
||||
assertExpected func(t *testing.T, got []*resource.Resource)
|
||||
wantErr error
|
||||
}{
|
||||
{
|
||||
test: "no api gateway rest api policies",
|
||||
mocks: func(repository *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) {
|
||||
repository.On("ListAllRestApis").Return([]*apigateway.RestApi{
|
||||
{Id: awssdk.String("3of73v5ob4")},
|
||||
{Id: awssdk.String("9x7kq9pbyh"), Policy: awssdk.String("")},
|
||||
|
@ -839,7 +839,7 @@ func TestApiGatewayRestApiPolicy(t *testing.T) {
|
|||
},
|
||||
{
|
||||
test: "multiple api gateway rest api policies",
|
||||
mocks: func(repository *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) {
|
||||
repository.On("ListAllRestApis").Return([]*apigateway.RestApi{
|
||||
{Id: awssdk.String("c3n3aqga5d"), Policy: awssdk.String("{\"Version\":\"2012-10-17\",\"Statement\":[{\"Effect\":\"Allow\",\"Principal\":{\"AWS\":\"*\"},\"Action\":\"execute-api:Invoke\",\"Resource\":\"arn:aws:execute-api:us-east-1:111111111111:c3n3aqga5d/*\",\"Condition\":{\"IpAddress\":{\"aws:SourceIp\":\"123.123.123.123/32\"}}}]}")},
|
||||
{Id: awssdk.String("9y1eus3hr7"), Policy: awssdk.String("{\"Version\":\"2012-10-17\",\"Statement\":[{\"Effect\":\"Allow\",\"Principal\":{\"AWS\":\"*\"},\"Action\":\"execute-api:Invoke\",\"Resource\":\"arn:aws:execute-api:us-east-1:111111111111:9y1eus3hr7/*\",\"Condition\":{\"IpAddress\":{\"aws:SourceIp\":\"123.123.123.123/32\"}}}]}")},
|
||||
|
@ -857,7 +857,7 @@ func TestApiGatewayRestApiPolicy(t *testing.T) {
|
|||
},
|
||||
{
|
||||
test: "cannot list rest apis",
|
||||
mocks: func(repo *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) {
|
||||
repo.On("ListAllRestApis").Return(nil, dummyError)
|
||||
alerter.On("SendAlert", resourceaws.AwsApiGatewayRestApiPolicyResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayRestApiPolicyResourceType, resourceaws.AwsApiGatewayRestApiResourceType), alerts.EnumerationPhase)).Return()
|
||||
},
|
||||
|
@ -877,10 +877,10 @@ func TestApiGatewayRestApiPolicy(t *testing.T) {
|
|||
|
||||
// Initialize mocks
|
||||
alerter := &mocks.AlerterInterface{}
|
||||
fakeRepo := &repository2.MockApiGatewayRepository{}
|
||||
fakeRepo := &repository.MockApiGatewayRepository{}
|
||||
c.mocks(fakeRepo, alerter)
|
||||
|
||||
var repo repository2.ApiGatewayRepository = fakeRepo
|
||||
var repo repository.ApiGatewayRepository = fakeRepo
|
||||
|
||||
remoteLibrary.AddEnumerator(aws2.NewApiGatewayRestApiPolicyEnumerator(repo, factory))
|
||||
|
||||
|
@ -910,13 +910,13 @@ func TestApiGatewayBasePathMapping(t *testing.T) {
|
|||
|
||||
tests := []struct {
|
||||
test string
|
||||
mocks func(*repository2.MockApiGatewayRepository, *mocks.AlerterInterface)
|
||||
mocks func(*repository.MockApiGatewayRepository, *mocks.AlerterInterface)
|
||||
assertExpected func(t *testing.T, got []*resource.Resource)
|
||||
wantErr error
|
||||
}{
|
||||
{
|
||||
test: "no domain name base path mappings",
|
||||
mocks: func(repo *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) {
|
||||
repo.On("ListAllDomainNames").Return(domainNames, nil)
|
||||
repo.On("ListAllDomainNameBasePathMappings", *domainNames[0].DomainName).Return([]*apigateway.BasePathMapping{}, nil)
|
||||
},
|
||||
|
@ -926,7 +926,7 @@ func TestApiGatewayBasePathMapping(t *testing.T) {
|
|||
},
|
||||
{
|
||||
test: "multiple domain name base path mappings",
|
||||
mocks: func(repo *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) {
|
||||
repo.On("ListAllDomainNames").Return(domainNames, nil)
|
||||
repo.On("ListAllDomainNameBasePathMappings", *domainNames[0].DomainName).Return([]*apigateway.BasePathMapping{
|
||||
{BasePath: awssdk.String("foo")},
|
||||
|
@ -945,7 +945,7 @@ func TestApiGatewayBasePathMapping(t *testing.T) {
|
|||
},
|
||||
{
|
||||
test: "cannot list domain names",
|
||||
mocks: func(repo *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) {
|
||||
repo.On("ListAllDomainNames").Return(nil, dummyError)
|
||||
alerter.On("SendAlert", resourceaws.AwsApiGatewayBasePathMappingResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayBasePathMappingResourceType, resourceaws.AwsApiGatewayDomainNameResourceType), alerts.EnumerationPhase)).Return()
|
||||
},
|
||||
|
@ -953,7 +953,7 @@ func TestApiGatewayBasePathMapping(t *testing.T) {
|
|||
},
|
||||
{
|
||||
test: "cannot list domain name base path mappings",
|
||||
mocks: func(repo *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) {
|
||||
repo.On("ListAllDomainNames").Return(domainNames, nil)
|
||||
repo.On("ListAllDomainNameBasePathMappings", *domainNames[0].DomainName).Return(nil, dummyError)
|
||||
alerter.On("SendAlert", resourceaws.AwsApiGatewayBasePathMappingResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayBasePathMappingResourceType, resourceaws.AwsApiGatewayBasePathMappingResourceType), alerts.EnumerationPhase)).Return()
|
||||
|
@ -974,10 +974,10 @@ func TestApiGatewayBasePathMapping(t *testing.T) {
|
|||
|
||||
// Initialize mocks
|
||||
alerter := &mocks.AlerterInterface{}
|
||||
fakeRepo := &repository2.MockApiGatewayRepository{}
|
||||
fakeRepo := &repository.MockApiGatewayRepository{}
|
||||
c.mocks(fakeRepo, alerter)
|
||||
|
||||
var repo repository2.ApiGatewayRepository = fakeRepo
|
||||
var repo repository.ApiGatewayRepository = fakeRepo
|
||||
|
||||
remoteLibrary.AddEnumerator(aws2.NewApiGatewayBasePathMappingEnumerator(repo, factory))
|
||||
|
||||
|
@ -1007,13 +1007,13 @@ func TestApiGatewayMethod(t *testing.T) {
|
|||
|
||||
tests := []struct {
|
||||
test string
|
||||
mocks func(*repository2.MockApiGatewayRepository, *mocks.AlerterInterface)
|
||||
mocks func(*repository.MockApiGatewayRepository, *mocks.AlerterInterface)
|
||||
assertExpected func(t *testing.T, got []*resource.Resource)
|
||||
wantErr error
|
||||
}{
|
||||
{
|
||||
test: "no api gateway methods",
|
||||
mocks: func(repo *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) {
|
||||
repo.On("ListAllRestApis").Return(apis, nil)
|
||||
repo.On("ListAllRestApiResources", *apis[0].Id).Return([]*apigateway.Resource{
|
||||
{Id: awssdk.String("hl7ksq"), Path: awssdk.String("/foo")},
|
||||
|
@ -1025,7 +1025,7 @@ func TestApiGatewayMethod(t *testing.T) {
|
|||
},
|
||||
{
|
||||
test: "multiple api gateway methods",
|
||||
mocks: func(repo *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) {
|
||||
repo.On("ListAllRestApis").Return(apis, nil)
|
||||
repo.On("ListAllRestApiResources", *apis[0].Id).Return([]*apigateway.Resource{
|
||||
{Id: awssdk.String("hl7ksq"), Path: awssdk.String("/foo"), ResourceMethods: map[string]*apigateway.Method{
|
||||
|
@ -1050,7 +1050,7 @@ func TestApiGatewayMethod(t *testing.T) {
|
|||
},
|
||||
{
|
||||
test: "cannot list rest apis",
|
||||
mocks: func(repo *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) {
|
||||
repo.On("ListAllRestApis").Return(nil, dummyError)
|
||||
alerter.On("SendAlert", resourceaws.AwsApiGatewayMethodResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayMethodResourceType, resourceaws.AwsApiGatewayRestApiResourceType), alerts.EnumerationPhase)).Return()
|
||||
},
|
||||
|
@ -1058,7 +1058,7 @@ func TestApiGatewayMethod(t *testing.T) {
|
|||
},
|
||||
{
|
||||
test: "cannot list api gateway resources",
|
||||
mocks: func(repo *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) {
|
||||
repo.On("ListAllRestApis").Return(apis, nil)
|
||||
repo.On("ListAllRestApiResources", *apis[0].Id).Return(nil, dummyError)
|
||||
alerter.On("SendAlert", resourceaws.AwsApiGatewayMethodResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayMethodResourceType, resourceaws.AwsApiGatewayResourceResourceType), alerts.EnumerationPhase)).Return()
|
||||
|
@ -1079,10 +1079,10 @@ func TestApiGatewayMethod(t *testing.T) {
|
|||
|
||||
// Initialize mocks
|
||||
alerter := &mocks.AlerterInterface{}
|
||||
fakeRepo := &repository2.MockApiGatewayRepository{}
|
||||
fakeRepo := &repository.MockApiGatewayRepository{}
|
||||
c.mocks(fakeRepo, alerter)
|
||||
|
||||
var repo repository2.ApiGatewayRepository = fakeRepo
|
||||
var repo repository.ApiGatewayRepository = fakeRepo
|
||||
|
||||
remoteLibrary.AddEnumerator(aws2.NewApiGatewayMethodEnumerator(repo, factory))
|
||||
|
||||
|
@ -1112,13 +1112,13 @@ func TestApiGatewayModel(t *testing.T) {
|
|||
|
||||
tests := []struct {
|
||||
test string
|
||||
mocks func(*repository2.MockApiGatewayRepository, *mocks.AlerterInterface)
|
||||
mocks func(*repository.MockApiGatewayRepository, *mocks.AlerterInterface)
|
||||
assertExpected func(t *testing.T, got []*resource.Resource)
|
||||
wantErr error
|
||||
}{
|
||||
{
|
||||
test: "no api gateway models",
|
||||
mocks: func(repo *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) {
|
||||
repo.On("ListAllRestApis").Return(apis, nil)
|
||||
repo.On("ListAllRestApiModels", *apis[0].Id).Return([]*apigateway.Model{}, nil)
|
||||
},
|
||||
|
@ -1128,7 +1128,7 @@ func TestApiGatewayModel(t *testing.T) {
|
|||
},
|
||||
{
|
||||
test: "multiple api gateway models",
|
||||
mocks: func(repo *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) {
|
||||
repo.On("ListAllRestApis").Return(apis, nil)
|
||||
repo.On("ListAllRestApiModels", *apis[0].Id).Return([]*apigateway.Model{
|
||||
{Id: awssdk.String("g68a4s")},
|
||||
|
@ -1147,7 +1147,7 @@ func TestApiGatewayModel(t *testing.T) {
|
|||
},
|
||||
{
|
||||
test: "cannot list rest apis",
|
||||
mocks: func(repo *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) {
|
||||
repo.On("ListAllRestApis").Return(nil, dummyError)
|
||||
alerter.On("SendAlert", resourceaws.AwsApiGatewayModelResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayModelResourceType, resourceaws.AwsApiGatewayRestApiResourceType), alerts.EnumerationPhase)).Return()
|
||||
},
|
||||
|
@ -1155,7 +1155,7 @@ func TestApiGatewayModel(t *testing.T) {
|
|||
},
|
||||
{
|
||||
test: "cannot list api gateway models",
|
||||
mocks: func(repo *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) {
|
||||
repo.On("ListAllRestApis").Return(apis, nil)
|
||||
repo.On("ListAllRestApiModels", *apis[0].Id).Return(nil, dummyError)
|
||||
alerter.On("SendAlert", resourceaws.AwsApiGatewayModelResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayModelResourceType, resourceaws.AwsApiGatewayModelResourceType), alerts.EnumerationPhase)).Return()
|
||||
|
@ -1176,10 +1176,10 @@ func TestApiGatewayModel(t *testing.T) {
|
|||
|
||||
// Initialize mocks
|
||||
alerter := &mocks.AlerterInterface{}
|
||||
fakeRepo := &repository2.MockApiGatewayRepository{}
|
||||
fakeRepo := &repository.MockApiGatewayRepository{}
|
||||
c.mocks(fakeRepo, alerter)
|
||||
|
||||
var repo repository2.ApiGatewayRepository = fakeRepo
|
||||
var repo repository.ApiGatewayRepository = fakeRepo
|
||||
|
||||
remoteLibrary.AddEnumerator(aws2.NewApiGatewayModelEnumerator(repo, factory))
|
||||
|
||||
|
@ -1209,13 +1209,13 @@ func TestApiGatewayMethodResponse(t *testing.T) {
|
|||
|
||||
tests := []struct {
|
||||
test string
|
||||
mocks func(*repository2.MockApiGatewayRepository, *mocks.AlerterInterface)
|
||||
mocks func(*repository.MockApiGatewayRepository, *mocks.AlerterInterface)
|
||||
assertExpected func(t *testing.T, got []*resource.Resource)
|
||||
wantErr error
|
||||
}{
|
||||
{
|
||||
test: "no api gateway method responses",
|
||||
mocks: func(repo *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) {
|
||||
repo.On("ListAllRestApis").Return(apis, nil)
|
||||
repo.On("ListAllRestApiResources", *apis[0].Id).Return([]*apigateway.Resource{
|
||||
{Id: awssdk.String("hl7ksq"), Path: awssdk.String("/foo"), ResourceMethods: map[string]*apigateway.Method{
|
||||
|
@ -1229,7 +1229,7 @@ func TestApiGatewayMethodResponse(t *testing.T) {
|
|||
},
|
||||
{
|
||||
test: "multiple api gateway method responses",
|
||||
mocks: func(repo *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) {
|
||||
repo.On("ListAllRestApis").Return(apis, nil)
|
||||
repo.On("ListAllRestApiResources", *apis[0].Id).Return([]*apigateway.Resource{
|
||||
{Id: awssdk.String("hl7ksq"), Path: awssdk.String("/foo"), ResourceMethods: map[string]*apigateway.Method{
|
||||
|
@ -1256,7 +1256,7 @@ func TestApiGatewayMethodResponse(t *testing.T) {
|
|||
},
|
||||
{
|
||||
test: "cannot list rest apis",
|
||||
mocks: func(repo *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) {
|
||||
repo.On("ListAllRestApis").Return(nil, dummyError)
|
||||
alerter.On("SendAlert", resourceaws.AwsApiGatewayMethodResponseResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayMethodResponseResourceType, resourceaws.AwsApiGatewayRestApiResourceType), alerts.EnumerationPhase)).Return()
|
||||
},
|
||||
|
@ -1264,7 +1264,7 @@ func TestApiGatewayMethodResponse(t *testing.T) {
|
|||
},
|
||||
{
|
||||
test: "cannot list api gateway resources",
|
||||
mocks: func(repo *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) {
|
||||
repo.On("ListAllRestApis").Return(apis, nil)
|
||||
repo.On("ListAllRestApiResources", *apis[0].Id).Return(nil, dummyError)
|
||||
alerter.On("SendAlert", resourceaws.AwsApiGatewayMethodResponseResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayMethodResponseResourceType, resourceaws.AwsApiGatewayResourceResourceType), alerts.EnumerationPhase)).Return()
|
||||
|
@ -1285,10 +1285,10 @@ func TestApiGatewayMethodResponse(t *testing.T) {
|
|||
|
||||
// Initialize mocks
|
||||
alerter := &mocks.AlerterInterface{}
|
||||
fakeRepo := &repository2.MockApiGatewayRepository{}
|
||||
fakeRepo := &repository.MockApiGatewayRepository{}
|
||||
c.mocks(fakeRepo, alerter)
|
||||
|
||||
var repo repository2.ApiGatewayRepository = fakeRepo
|
||||
var repo repository.ApiGatewayRepository = fakeRepo
|
||||
|
||||
remoteLibrary.AddEnumerator(aws2.NewApiGatewayMethodResponseEnumerator(repo, factory))
|
||||
|
||||
|
@ -1318,13 +1318,13 @@ func TestApiGatewayGatewayResponse(t *testing.T) {
|
|||
|
||||
tests := []struct {
|
||||
test string
|
||||
mocks func(*repository2.MockApiGatewayRepository, *mocks.AlerterInterface)
|
||||
mocks func(*repository.MockApiGatewayRepository, *mocks.AlerterInterface)
|
||||
assertExpected func(t *testing.T, got []*resource.Resource)
|
||||
wantErr error
|
||||
}{
|
||||
{
|
||||
test: "no api gateway gateway responses",
|
||||
mocks: func(repo *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) {
|
||||
repo.On("ListAllRestApis").Return(apis, nil)
|
||||
repo.On("ListAllRestApiGatewayResponses", *apis[0].Id).Return([]*apigateway.UpdateGatewayResponseOutput{}, nil)
|
||||
},
|
||||
|
@ -1334,7 +1334,7 @@ func TestApiGatewayGatewayResponse(t *testing.T) {
|
|||
},
|
||||
{
|
||||
test: "multiple api gateway gateway responses",
|
||||
mocks: func(repo *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) {
|
||||
repo.On("ListAllRestApis").Return(apis, nil)
|
||||
repo.On("ListAllRestApiGatewayResponses", *apis[0].Id).Return([]*apigateway.UpdateGatewayResponseOutput{
|
||||
{ResponseType: awssdk.String("UNAUTHORIZED")},
|
||||
|
@ -1353,7 +1353,7 @@ func TestApiGatewayGatewayResponse(t *testing.T) {
|
|||
},
|
||||
{
|
||||
test: "cannot list rest apis",
|
||||
mocks: func(repo *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) {
|
||||
repo.On("ListAllRestApis").Return(nil, dummyError)
|
||||
alerter.On("SendAlert", resourceaws.AwsApiGatewayGatewayResponseResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayGatewayResponseResourceType, resourceaws.AwsApiGatewayRestApiResourceType), alerts.EnumerationPhase)).Return()
|
||||
},
|
||||
|
@ -1361,7 +1361,7 @@ func TestApiGatewayGatewayResponse(t *testing.T) {
|
|||
},
|
||||
{
|
||||
test: "cannot list api gateway gateway responses",
|
||||
mocks: func(repo *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) {
|
||||
repo.On("ListAllRestApis").Return(apis, nil)
|
||||
repo.On("ListAllRestApiGatewayResponses", *apis[0].Id).Return(nil, dummyError)
|
||||
alerter.On("SendAlert", resourceaws.AwsApiGatewayGatewayResponseResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayGatewayResponseResourceType, resourceaws.AwsApiGatewayGatewayResponseResourceType), alerts.EnumerationPhase)).Return()
|
||||
|
@ -1382,10 +1382,10 @@ func TestApiGatewayGatewayResponse(t *testing.T) {
|
|||
|
||||
// Initialize mocks
|
||||
alerter := &mocks.AlerterInterface{}
|
||||
fakeRepo := &repository2.MockApiGatewayRepository{}
|
||||
fakeRepo := &repository.MockApiGatewayRepository{}
|
||||
c.mocks(fakeRepo, alerter)
|
||||
|
||||
var repo repository2.ApiGatewayRepository = fakeRepo
|
||||
var repo repository.ApiGatewayRepository = fakeRepo
|
||||
|
||||
remoteLibrary.AddEnumerator(aws2.NewApiGatewayGatewayResponseEnumerator(repo, factory))
|
||||
|
||||
|
@ -1415,13 +1415,13 @@ func TestApiGatewayMethodSettings(t *testing.T) {
|
|||
|
||||
tests := []struct {
|
||||
test string
|
||||
mocks func(*repository2.MockApiGatewayRepository, *mocks.AlerterInterface)
|
||||
mocks func(*repository.MockApiGatewayRepository, *mocks.AlerterInterface)
|
||||
assertExpected func(t *testing.T, got []*resource.Resource)
|
||||
wantErr error
|
||||
}{
|
||||
{
|
||||
test: "no api gateway method settings",
|
||||
mocks: func(repo *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) {
|
||||
repo.On("ListAllRestApis").Return(apis, nil)
|
||||
repo.On("ListAllRestApiStages", *apis[0].Id).Return([]*apigateway.Stage{
|
||||
{StageName: awssdk.String("foo"), MethodSettings: map[string]*apigateway.MethodSetting{}},
|
||||
|
@ -1433,7 +1433,7 @@ func TestApiGatewayMethodSettings(t *testing.T) {
|
|||
},
|
||||
{
|
||||
test: "multiple api gateway method settings",
|
||||
mocks: func(repo *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) {
|
||||
repo.On("ListAllRestApis").Return(apis, nil)
|
||||
repo.On("ListAllRestApiStages", *apis[0].Id).Return([]*apigateway.Stage{
|
||||
{StageName: awssdk.String("foo"), MethodSettings: map[string]*apigateway.MethodSetting{
|
||||
|
@ -1458,7 +1458,7 @@ func TestApiGatewayMethodSettings(t *testing.T) {
|
|||
},
|
||||
{
|
||||
test: "cannot list rest apis",
|
||||
mocks: func(repo *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) {
|
||||
repo.On("ListAllRestApis").Return(nil, dummyError)
|
||||
alerter.On("SendAlert", resourceaws.AwsApiGatewayMethodSettingsResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayMethodSettingsResourceType, resourceaws.AwsApiGatewayRestApiResourceType), alerts.EnumerationPhase)).Return()
|
||||
},
|
||||
|
@ -1466,7 +1466,7 @@ func TestApiGatewayMethodSettings(t *testing.T) {
|
|||
},
|
||||
{
|
||||
test: "cannot list api gateway settings",
|
||||
mocks: func(repo *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) {
|
||||
repo.On("ListAllRestApis").Return(apis, nil)
|
||||
repo.On("ListAllRestApiStages", *apis[0].Id).Return(nil, dummyError)
|
||||
alerter.On("SendAlert", resourceaws.AwsApiGatewayMethodSettingsResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayMethodSettingsResourceType, resourceaws.AwsApiGatewayStageResourceType), alerts.EnumerationPhase)).Return()
|
||||
|
@ -1487,10 +1487,10 @@ func TestApiGatewayMethodSettings(t *testing.T) {
|
|||
|
||||
// Initialize mocks
|
||||
alerter := &mocks.AlerterInterface{}
|
||||
fakeRepo := &repository2.MockApiGatewayRepository{}
|
||||
fakeRepo := &repository.MockApiGatewayRepository{}
|
||||
c.mocks(fakeRepo, alerter)
|
||||
|
||||
var repo repository2.ApiGatewayRepository = fakeRepo
|
||||
var repo repository.ApiGatewayRepository = fakeRepo
|
||||
|
||||
remoteLibrary.AddEnumerator(aws2.NewApiGatewayMethodSettingsEnumerator(repo, factory))
|
||||
|
||||
|
@ -1520,13 +1520,13 @@ func TestApiGatewayIntegration(t *testing.T) {
|
|||
|
||||
tests := []struct {
|
||||
test string
|
||||
mocks func(*repository2.MockApiGatewayRepository, *mocks.AlerterInterface)
|
||||
mocks func(*repository.MockApiGatewayRepository, *mocks.AlerterInterface)
|
||||
assertExpected func(t *testing.T, got []*resource.Resource)
|
||||
wantErr error
|
||||
}{
|
||||
{
|
||||
test: "no api gateway integrations",
|
||||
mocks: func(repo *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) {
|
||||
repo.On("ListAllRestApis").Return(apis, nil)
|
||||
repo.On("ListAllRestApiResources", *apis[0].Id).Return([]*apigateway.Resource{
|
||||
{Id: awssdk.String("z9ag20"), Path: awssdk.String("/foo")},
|
||||
|
@ -1538,7 +1538,7 @@ func TestApiGatewayIntegration(t *testing.T) {
|
|||
},
|
||||
{
|
||||
test: "multiple api gateway integrations",
|
||||
mocks: func(repo *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) {
|
||||
repo.On("ListAllRestApis").Return(apis, nil)
|
||||
repo.On("ListAllRestApiResources", *apis[0].Id).Return([]*apigateway.Resource{
|
||||
{Id: awssdk.String("z9ag20"), Path: awssdk.String("/foo"), ResourceMethods: map[string]*apigateway.Method{
|
||||
|
@ -1563,7 +1563,7 @@ func TestApiGatewayIntegration(t *testing.T) {
|
|||
},
|
||||
{
|
||||
test: "cannot list rest apis",
|
||||
mocks: func(repo *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) {
|
||||
repo.On("ListAllRestApis").Return(nil, dummyError)
|
||||
alerter.On("SendAlert", resourceaws.AwsApiGatewayIntegrationResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayIntegrationResourceType, resourceaws.AwsApiGatewayRestApiResourceType), alerts.EnumerationPhase)).Return()
|
||||
},
|
||||
|
@ -1571,7 +1571,7 @@ func TestApiGatewayIntegration(t *testing.T) {
|
|||
},
|
||||
{
|
||||
test: "cannot list api gateway resources",
|
||||
mocks: func(repo *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) {
|
||||
repo.On("ListAllRestApis").Return(apis, nil)
|
||||
repo.On("ListAllRestApiResources", *apis[0].Id).Return(nil, dummyError)
|
||||
alerter.On("SendAlert", resourceaws.AwsApiGatewayIntegrationResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayIntegrationResourceType, resourceaws.AwsApiGatewayResourceResourceType), alerts.EnumerationPhase)).Return()
|
||||
|
@ -1592,10 +1592,10 @@ func TestApiGatewayIntegration(t *testing.T) {
|
|||
|
||||
// Initialize mocks
|
||||
alerter := &mocks.AlerterInterface{}
|
||||
fakeRepo := &repository2.MockApiGatewayRepository{}
|
||||
fakeRepo := &repository.MockApiGatewayRepository{}
|
||||
c.mocks(fakeRepo, alerter)
|
||||
|
||||
var repo repository2.ApiGatewayRepository = fakeRepo
|
||||
var repo repository.ApiGatewayRepository = fakeRepo
|
||||
|
||||
remoteLibrary.AddEnumerator(aws2.NewApiGatewayIntegrationEnumerator(repo, factory))
|
||||
|
||||
|
@ -1625,13 +1625,13 @@ func TestApiGatewayIntegrationResponse(t *testing.T) {
|
|||
|
||||
tests := []struct {
|
||||
test string
|
||||
mocks func(*repository2.MockApiGatewayRepository, *mocks.AlerterInterface)
|
||||
mocks func(*repository.MockApiGatewayRepository, *mocks.AlerterInterface)
|
||||
assertExpected func(t *testing.T, got []*resource.Resource)
|
||||
wantErr error
|
||||
}{
|
||||
{
|
||||
test: "no api gateway integration responses",
|
||||
mocks: func(repo *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) {
|
||||
repo.On("ListAllRestApis").Return(apis, nil)
|
||||
repo.On("ListAllRestApiResources", *apis[0].Id).Return([]*apigateway.Resource{
|
||||
{Id: awssdk.String("z9ag20"), Path: awssdk.String("/foo"), ResourceMethods: map[string]*apigateway.Method{
|
||||
|
@ -1645,7 +1645,7 @@ func TestApiGatewayIntegrationResponse(t *testing.T) {
|
|||
},
|
||||
{
|
||||
test: "multiple api gateway integration responses",
|
||||
mocks: func(repo *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) {
|
||||
repo.On("ListAllRestApis").Return(apis, nil)
|
||||
repo.On("ListAllRestApiResources", *apis[0].Id).Return([]*apigateway.Resource{
|
||||
{Id: awssdk.String("z9ag20"), Path: awssdk.String("/foo"), ResourceMethods: map[string]*apigateway.Method{
|
||||
|
@ -1672,7 +1672,7 @@ func TestApiGatewayIntegrationResponse(t *testing.T) {
|
|||
},
|
||||
{
|
||||
test: "cannot list rest apis",
|
||||
mocks: func(repo *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) {
|
||||
repo.On("ListAllRestApis").Return(nil, dummyError)
|
||||
alerter.On("SendAlert", resourceaws.AwsApiGatewayIntegrationResponseResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayIntegrationResponseResourceType, resourceaws.AwsApiGatewayRestApiResourceType), alerts.EnumerationPhase)).Return()
|
||||
},
|
||||
|
@ -1680,7 +1680,7 @@ func TestApiGatewayIntegrationResponse(t *testing.T) {
|
|||
},
|
||||
{
|
||||
test: "cannot list api gateway resources",
|
||||
mocks: func(repo *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repo *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) {
|
||||
repo.On("ListAllRestApis").Return(apis, nil)
|
||||
repo.On("ListAllRestApiResources", *apis[0].Id).Return(nil, dummyError)
|
||||
alerter.On("SendAlert", resourceaws.AwsApiGatewayIntegrationResponseResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayIntegrationResponseResourceType, resourceaws.AwsApiGatewayResourceResourceType), alerts.EnumerationPhase)).Return()
|
||||
|
@ -1701,10 +1701,10 @@ func TestApiGatewayIntegrationResponse(t *testing.T) {
|
|||
|
||||
// Initialize mocks
|
||||
alerter := &mocks.AlerterInterface{}
|
||||
fakeRepo := &repository2.MockApiGatewayRepository{}
|
||||
fakeRepo := &repository.MockApiGatewayRepository{}
|
||||
c.mocks(fakeRepo, alerter)
|
||||
|
||||
var repo repository2.ApiGatewayRepository = fakeRepo
|
||||
var repo repository.ApiGatewayRepository = fakeRepo
|
||||
|
||||
remoteLibrary.AddEnumerator(aws2.NewApiGatewayIntegrationResponseEnumerator(repo, factory))
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ import (
|
|||
"github.com/snyk/driftctl/enumeration"
|
||||
"github.com/snyk/driftctl/enumeration/remote/alerts"
|
||||
aws2 "github.com/snyk/driftctl/enumeration/remote/aws"
|
||||
repository2 "github.com/snyk/driftctl/enumeration/remote/aws/repository"
|
||||
"github.com/snyk/driftctl/enumeration/remote/aws/repository"
|
||||
common2 "github.com/snyk/driftctl/enumeration/remote/common"
|
||||
remoteerr "github.com/snyk/driftctl/enumeration/remote/error"
|
||||
"github.com/snyk/driftctl/enumeration/terraform"
|
||||
|
@ -29,13 +29,13 @@ func TestApiGatewayV2Api(t *testing.T) {
|
|||
|
||||
tests := []struct {
|
||||
test string
|
||||
mocks func(*repository2.MockApiGatewayV2Repository, *mocks.AlerterInterface)
|
||||
mocks func(*repository.MockApiGatewayV2Repository, *mocks.AlerterInterface)
|
||||
assertExpected func(t *testing.T, got []*resource.Resource)
|
||||
wantErr error
|
||||
}{
|
||||
{
|
||||
test: "no api gateway v2 api",
|
||||
mocks: func(repository *repository2.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) {
|
||||
repository.On("ListAllApis").Return([]*apigatewayv2.Api{}, nil)
|
||||
},
|
||||
assertExpected: func(t *testing.T, got []*resource.Resource) {
|
||||
|
@ -44,7 +44,7 @@ func TestApiGatewayV2Api(t *testing.T) {
|
|||
},
|
||||
{
|
||||
test: "single api gateway v2 api",
|
||||
mocks: func(repository *repository2.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) {
|
||||
repository.On("ListAllApis").Return([]*apigatewayv2.Api{
|
||||
{ApiId: awssdk.String("f5vdrg12tk")},
|
||||
}, nil)
|
||||
|
@ -58,7 +58,7 @@ func TestApiGatewayV2Api(t *testing.T) {
|
|||
},
|
||||
{
|
||||
test: "cannot list api gateway v2 apis",
|
||||
mocks: func(repository *repository2.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) {
|
||||
repository.On("ListAllApis").Return(nil, dummyError)
|
||||
alerter.On("SendAlert", resourceaws.AwsApiGatewayV2ApiResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayV2ApiResourceType, resourceaws.AwsApiGatewayV2ApiResourceType), alerts.EnumerationPhase)).Return()
|
||||
},
|
||||
|
@ -78,10 +78,10 @@ func TestApiGatewayV2Api(t *testing.T) {
|
|||
|
||||
// Initialize mocks
|
||||
alerter := &mocks.AlerterInterface{}
|
||||
fakeRepo := &repository2.MockApiGatewayV2Repository{}
|
||||
fakeRepo := &repository.MockApiGatewayV2Repository{}
|
||||
c.mocks(fakeRepo, alerter)
|
||||
|
||||
var repo repository2.ApiGatewayV2Repository = fakeRepo
|
||||
var repo repository.ApiGatewayV2Repository = fakeRepo
|
||||
|
||||
remoteLibrary.AddEnumerator(aws2.NewApiGatewayV2ApiEnumerator(repo, factory))
|
||||
|
||||
|
@ -108,13 +108,13 @@ func TestApiGatewayV2Route(t *testing.T) {
|
|||
|
||||
tests := []struct {
|
||||
test string
|
||||
mocks func(*repository2.MockApiGatewayV2Repository, *mocks.AlerterInterface)
|
||||
mocks func(*repository.MockApiGatewayV2Repository, *mocks.AlerterInterface)
|
||||
assertExpected func(t *testing.T, got []*resource.Resource)
|
||||
wantErr error
|
||||
}{
|
||||
{
|
||||
test: "no api gateway v2 api",
|
||||
mocks: func(repository *repository2.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) {
|
||||
repository.On("ListAllApis").Return([]*apigatewayv2.Api{}, nil)
|
||||
},
|
||||
assertExpected: func(t *testing.T, got []*resource.Resource) {
|
||||
|
@ -123,7 +123,7 @@ func TestApiGatewayV2Route(t *testing.T) {
|
|||
},
|
||||
{
|
||||
test: "single api gateway v2 api with a single route",
|
||||
mocks: func(repository *repository2.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) {
|
||||
repository.On("ListAllApis").Return([]*apigatewayv2.Api{
|
||||
{ApiId: awssdk.String("a-gateway")},
|
||||
}, nil)
|
||||
|
@ -147,7 +147,7 @@ func TestApiGatewayV2Route(t *testing.T) {
|
|||
},
|
||||
{
|
||||
test: "cannot list api gateway v2 apis",
|
||||
mocks: func(repository *repository2.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) {
|
||||
repository.On("ListAllApis").Return(nil, dummyError)
|
||||
alerter.On("SendAlert", resourceaws.AwsApiGatewayV2RouteResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayV2ApiResourceType, resourceaws.AwsApiGatewayV2RouteResourceType), alerts.EnumerationPhase)).Return()
|
||||
},
|
||||
|
@ -167,10 +167,10 @@ func TestApiGatewayV2Route(t *testing.T) {
|
|||
|
||||
// Initialize mocks
|
||||
alerter := &mocks.AlerterInterface{}
|
||||
fakeRepo := &repository2.MockApiGatewayV2Repository{}
|
||||
fakeRepo := &repository.MockApiGatewayV2Repository{}
|
||||
c.mocks(fakeRepo, alerter)
|
||||
|
||||
var repo repository2.ApiGatewayV2Repository = fakeRepo
|
||||
var repo repository.ApiGatewayV2Repository = fakeRepo
|
||||
|
||||
remoteLibrary.AddEnumerator(aws2.NewApiGatewayV2RouteEnumerator(repo, factory))
|
||||
|
||||
|
@ -197,13 +197,13 @@ func TestApiGatewayV2Deployment(t *testing.T) {
|
|||
|
||||
tests := []struct {
|
||||
test string
|
||||
mocks func(*repository2.MockApiGatewayV2Repository, *mocks.AlerterInterface)
|
||||
mocks func(*repository.MockApiGatewayV2Repository, *mocks.AlerterInterface)
|
||||
assertExpected func(t *testing.T, got []*resource.Resource)
|
||||
wantErr error
|
||||
}{
|
||||
{
|
||||
test: "single api gateway v2 api with a single deployment",
|
||||
mocks: func(repository *repository2.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) {
|
||||
repository.On("ListAllApis").Return([]*apigatewayv2.Api{
|
||||
{ApiId: awssdk.String("a-gateway")},
|
||||
}, nil)
|
||||
|
@ -223,7 +223,7 @@ func TestApiGatewayV2Deployment(t *testing.T) {
|
|||
},
|
||||
{
|
||||
test: "no API gateways",
|
||||
mocks: func(repository *repository2.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) {
|
||||
repository.On("ListAllApis").Return([]*apigatewayv2.Api{}, nil)
|
||||
},
|
||||
assertExpected: func(t *testing.T, got []*resource.Resource) {
|
||||
|
@ -232,7 +232,7 @@ func TestApiGatewayV2Deployment(t *testing.T) {
|
|||
},
|
||||
{
|
||||
test: "single API gateway with no deployments",
|
||||
mocks: func(repository *repository2.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) {
|
||||
repository.On("ListAllApis").Return([]*apigatewayv2.Api{
|
||||
{ApiId: awssdk.String("a-gateway")},
|
||||
}, nil)
|
||||
|
@ -245,7 +245,7 @@ func TestApiGatewayV2Deployment(t *testing.T) {
|
|||
},
|
||||
{
|
||||
test: "error listing API gateways",
|
||||
mocks: func(repository *repository2.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) {
|
||||
repository.On("ListAllApis").Return(nil, dummyError)
|
||||
alerter.On("SendAlert", resourceaws.AwsApiGatewayV2DeploymentResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayV2ApiResourceType, resourceaws.AwsApiGatewayV2RouteResourceType), alerts.EnumerationPhase)).Return()
|
||||
},
|
||||
|
@ -253,7 +253,7 @@ func TestApiGatewayV2Deployment(t *testing.T) {
|
|||
},
|
||||
{
|
||||
test: "error listing deployments of an API",
|
||||
mocks: func(repository *repository2.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) {
|
||||
repository.On("ListAllApis").Return([]*apigatewayv2.Api{
|
||||
{ApiId: awssdk.String("a-gateway")},
|
||||
}, nil)
|
||||
|
@ -276,10 +276,10 @@ func TestApiGatewayV2Deployment(t *testing.T) {
|
|||
|
||||
// Initialize mocks
|
||||
alerter := &mocks.AlerterInterface{}
|
||||
fakeRepo := &repository2.MockApiGatewayV2Repository{}
|
||||
fakeRepo := &repository.MockApiGatewayV2Repository{}
|
||||
c.mocks(fakeRepo, alerter)
|
||||
|
||||
var repo repository2.ApiGatewayV2Repository = fakeRepo
|
||||
var repo repository.ApiGatewayV2Repository = fakeRepo
|
||||
|
||||
remoteLibrary.AddEnumerator(aws2.NewApiGatewayV2DeploymentEnumerator(repo, factory))
|
||||
|
||||
|
@ -306,13 +306,13 @@ func TestApiGatewayV2VpcLink(t *testing.T) {
|
|||
|
||||
tests := []struct {
|
||||
test string
|
||||
mocks func(*repository2.MockApiGatewayV2Repository, *mocks.AlerterInterface)
|
||||
mocks func(*repository.MockApiGatewayV2Repository, *mocks.AlerterInterface)
|
||||
assertExpected func(t *testing.T, got []*resource.Resource)
|
||||
wantErr error
|
||||
}{
|
||||
{
|
||||
test: "no api gateway v2 vpc links",
|
||||
mocks: func(repository *repository2.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) {
|
||||
repository.On("ListAllVpcLinks").Return([]*apigatewayv2.VpcLink{}, nil)
|
||||
},
|
||||
assertExpected: func(t *testing.T, got []*resource.Resource) {
|
||||
|
@ -321,7 +321,7 @@ func TestApiGatewayV2VpcLink(t *testing.T) {
|
|||
},
|
||||
{
|
||||
test: "single api gateway v2 vpc link",
|
||||
mocks: func(repository *repository2.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) {
|
||||
repository.On("ListAllVpcLinks").Return([]*apigatewayv2.VpcLink{
|
||||
{VpcLinkId: awssdk.String("b8r351")},
|
||||
}, nil)
|
||||
|
@ -335,7 +335,7 @@ func TestApiGatewayV2VpcLink(t *testing.T) {
|
|||
},
|
||||
{
|
||||
test: "cannot list api gateway v2 vpc links",
|
||||
mocks: func(repository *repository2.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) {
|
||||
repository.On("ListAllVpcLinks").Return(nil, dummyError)
|
||||
alerter.On("SendAlert", resourceaws.AwsApiGatewayV2VpcLinkResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayV2VpcLinkResourceType, resourceaws.AwsApiGatewayV2VpcLinkResourceType), alerts.EnumerationPhase)).Return()
|
||||
},
|
||||
|
@ -355,10 +355,10 @@ func TestApiGatewayV2VpcLink(t *testing.T) {
|
|||
|
||||
// Initialize mocks
|
||||
alerter := &mocks.AlerterInterface{}
|
||||
fakeRepo := &repository2.MockApiGatewayV2Repository{}
|
||||
fakeRepo := &repository.MockApiGatewayV2Repository{}
|
||||
c.mocks(fakeRepo, alerter)
|
||||
|
||||
var repo repository2.ApiGatewayV2Repository = fakeRepo
|
||||
var repo repository.ApiGatewayV2Repository = fakeRepo
|
||||
|
||||
remoteLibrary.AddEnumerator(aws2.NewApiGatewayV2VpcLinkEnumerator(repo, factory))
|
||||
|
||||
|
@ -390,13 +390,13 @@ func TestApiGatewayV2Authorizer(t *testing.T) {
|
|||
|
||||
tests := []struct {
|
||||
test string
|
||||
mocks func(*repository2.MockApiGatewayV2Repository, *mocks.AlerterInterface)
|
||||
mocks func(*repository.MockApiGatewayV2Repository, *mocks.AlerterInterface)
|
||||
assertExpected func(t *testing.T, got []*resource.Resource)
|
||||
wantErr error
|
||||
}{
|
||||
{
|
||||
test: "no api gateway v2 authorizers",
|
||||
mocks: func(repo *repository2.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repo *repository.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) {
|
||||
repo.On("ListAllApis").Return(apis, nil)
|
||||
repo.On("ListAllApiAuthorizers", *apis[0].ApiId).Return([]*apigatewayv2.Authorizer{}, nil).Once()
|
||||
repo.On("ListAllApiAuthorizers", *apis[1].ApiId).Return([]*apigatewayv2.Authorizer{}, nil).Once()
|
||||
|
@ -407,7 +407,7 @@ func TestApiGatewayV2Authorizer(t *testing.T) {
|
|||
},
|
||||
{
|
||||
test: "multiple api gateway v2 authorizers",
|
||||
mocks: func(repo *repository2.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repo *repository.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) {
|
||||
repo.On("ListAllApis").Return(apis, nil)
|
||||
repo.On("ListAllApiAuthorizers", *apis[0].ApiId).Return([]*apigatewayv2.Authorizer{
|
||||
{AuthorizerId: awssdk.String("xaappu")},
|
||||
|
@ -428,7 +428,7 @@ func TestApiGatewayV2Authorizer(t *testing.T) {
|
|||
},
|
||||
{
|
||||
test: "cannot list apis",
|
||||
mocks: func(repo *repository2.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repo *repository.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) {
|
||||
repo.On("ListAllApis").Return(nil, dummyError)
|
||||
alerter.On("SendAlert", resourceaws.AwsApiGatewayV2AuthorizerResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayV2AuthorizerResourceType, resourceaws.AwsApiGatewayV2ApiResourceType), alerts.EnumerationPhase)).Return()
|
||||
},
|
||||
|
@ -436,7 +436,7 @@ func TestApiGatewayV2Authorizer(t *testing.T) {
|
|||
},
|
||||
{
|
||||
test: "cannot list api gateway v2 authorizers",
|
||||
mocks: func(repo *repository2.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repo *repository.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) {
|
||||
repo.On("ListAllApis").Return(apis, nil)
|
||||
repo.On("ListAllApiAuthorizers", *apis[0].ApiId).Return(nil, dummyError)
|
||||
alerter.On("SendAlert", resourceaws.AwsApiGatewayV2AuthorizerResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayV2AuthorizerResourceType, resourceaws.AwsApiGatewayV2AuthorizerResourceType), alerts.EnumerationPhase)).Return()
|
||||
|
@ -457,10 +457,10 @@ func TestApiGatewayV2Authorizer(t *testing.T) {
|
|||
|
||||
// Initialize mocks
|
||||
alerter := &mocks.AlerterInterface{}
|
||||
fakeRepo := &repository2.MockApiGatewayV2Repository{}
|
||||
fakeRepo := &repository.MockApiGatewayV2Repository{}
|
||||
c.mocks(fakeRepo, alerter)
|
||||
|
||||
var repo repository2.ApiGatewayV2Repository = fakeRepo
|
||||
var repo repository.ApiGatewayV2Repository = fakeRepo
|
||||
|
||||
remoteLibrary.AddEnumerator(aws2.NewApiGatewayV2AuthorizerEnumerator(repo, factory))
|
||||
|
||||
|
@ -492,13 +492,13 @@ func TestApiGatewayV2Integration(t *testing.T) {
|
|||
|
||||
tests := []struct {
|
||||
test string
|
||||
mocks func(*repository2.MockApiGatewayV2Repository, *mocks.AlerterInterface)
|
||||
mocks func(*repository.MockApiGatewayV2Repository, *mocks.AlerterInterface)
|
||||
assertExpected func(t *testing.T, got []*resource.Resource)
|
||||
wantErr error
|
||||
}{
|
||||
{
|
||||
test: "no api gateway v2 integrations",
|
||||
mocks: func(repo *repository2.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repo *repository.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) {
|
||||
repo.On("ListAllApis").Return(apis, nil)
|
||||
repo.On("ListAllApiIntegrations", *apis[0].ApiId).Return([]*apigatewayv2.Integration{}, nil).Once()
|
||||
repo.On("ListAllApiIntegrations", *apis[1].ApiId).Return([]*apigatewayv2.Integration{}, nil).Once()
|
||||
|
@ -509,7 +509,7 @@ func TestApiGatewayV2Integration(t *testing.T) {
|
|||
},
|
||||
{
|
||||
test: "multiple api gateway v2 integrations",
|
||||
mocks: func(repo *repository2.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repo *repository.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) {
|
||||
repo.On("ListAllApis").Return(apis, nil)
|
||||
repo.On("ListAllApiIntegrations", *apis[0].ApiId).Return([]*apigatewayv2.Integration{
|
||||
{
|
||||
|
@ -536,7 +536,7 @@ func TestApiGatewayV2Integration(t *testing.T) {
|
|||
},
|
||||
{
|
||||
test: "cannot list apis",
|
||||
mocks: func(repo *repository2.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repo *repository.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) {
|
||||
repo.On("ListAllApis").Return(nil, dummyError)
|
||||
alerter.On("SendAlert", resourceaws.AwsApiGatewayV2IntegrationResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayV2IntegrationResourceType, resourceaws.AwsApiGatewayV2ApiResourceType), alerts.EnumerationPhase)).Return()
|
||||
},
|
||||
|
@ -544,7 +544,7 @@ func TestApiGatewayV2Integration(t *testing.T) {
|
|||
},
|
||||
{
|
||||
test: "cannot list api gateway v2 integrations",
|
||||
mocks: func(repo *repository2.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repo *repository.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) {
|
||||
repo.On("ListAllApis").Return(apis, nil)
|
||||
repo.On("ListAllApiIntegrations", *apis[0].ApiId).Return(nil, dummyError)
|
||||
alerter.On("SendAlert", resourceaws.AwsApiGatewayV2IntegrationResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayV2IntegrationResourceType, resourceaws.AwsApiGatewayV2IntegrationResourceType), alerts.EnumerationPhase)).Return()
|
||||
|
@ -565,10 +565,10 @@ func TestApiGatewayV2Integration(t *testing.T) {
|
|||
|
||||
// Initialize mocks
|
||||
alerter := &mocks.AlerterInterface{}
|
||||
fakeRepo := &repository2.MockApiGatewayV2Repository{}
|
||||
fakeRepo := &repository.MockApiGatewayV2Repository{}
|
||||
c.mocks(fakeRepo, alerter)
|
||||
|
||||
var repo repository2.ApiGatewayV2Repository = fakeRepo
|
||||
var repo repository.ApiGatewayV2Repository = fakeRepo
|
||||
|
||||
remoteLibrary.AddEnumerator(aws2.NewApiGatewayV2IntegrationEnumerator(repo, factory))
|
||||
|
||||
|
@ -600,13 +600,13 @@ func TestApiGatewayV2Model(t *testing.T) {
|
|||
|
||||
tests := []struct {
|
||||
test string
|
||||
mocks func(*repository2.MockApiGatewayV2Repository, *mocks.AlerterInterface)
|
||||
mocks func(*repository.MockApiGatewayV2Repository, *mocks.AlerterInterface)
|
||||
assertExpected func(t *testing.T, got []*resource.Resource)
|
||||
wantErr error
|
||||
}{
|
||||
{
|
||||
test: "no api gateway v2 models",
|
||||
mocks: func(repo *repository2.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repo *repository.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) {
|
||||
repo.On("ListAllApis").Return(apis, nil)
|
||||
repo.On("ListAllApiModels", *apis[0].ApiId).Return([]*apigatewayv2.Model{}, nil).Once()
|
||||
repo.On("ListAllApiModels", *apis[1].ApiId).Return([]*apigatewayv2.Model{}, nil).Once()
|
||||
|
@ -617,7 +617,7 @@ func TestApiGatewayV2Model(t *testing.T) {
|
|||
},
|
||||
{
|
||||
test: "multiple api gateway v2 models",
|
||||
mocks: func(repo *repository2.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repo *repository.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) {
|
||||
repo.On("ListAllApis").Return(apis, nil)
|
||||
repo.On("ListAllApiModels", *apis[0].ApiId).Return([]*apigatewayv2.Model{
|
||||
{
|
||||
|
@ -647,7 +647,7 @@ func TestApiGatewayV2Model(t *testing.T) {
|
|||
},
|
||||
{
|
||||
test: "cannot list apis",
|
||||
mocks: func(repo *repository2.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repo *repository.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) {
|
||||
repo.On("ListAllApis").Return(nil, dummyError)
|
||||
alerter.On("SendAlert", resourceaws.AwsApiGatewayV2ModelResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayV2ModelResourceType, resourceaws.AwsApiGatewayV2ApiResourceType), alerts.EnumerationPhase)).Return()
|
||||
},
|
||||
|
@ -655,7 +655,7 @@ func TestApiGatewayV2Model(t *testing.T) {
|
|||
},
|
||||
{
|
||||
test: "cannot list api gateway v2 model",
|
||||
mocks: func(repo *repository2.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repo *repository.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) {
|
||||
repo.On("ListAllApis").Return(apis, nil)
|
||||
repo.On("ListAllApiModels", *apis[0].ApiId).Return(nil, dummyError)
|
||||
alerter.On("SendAlert", resourceaws.AwsApiGatewayV2ModelResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayV2ModelResourceType, resourceaws.AwsApiGatewayV2ModelResourceType), alerts.EnumerationPhase)).Return()
|
||||
|
@ -676,10 +676,10 @@ func TestApiGatewayV2Model(t *testing.T) {
|
|||
|
||||
// Initialize mocks
|
||||
alerter := &mocks.AlerterInterface{}
|
||||
fakeRepo := &repository2.MockApiGatewayV2Repository{}
|
||||
fakeRepo := &repository.MockApiGatewayV2Repository{}
|
||||
c.mocks(fakeRepo, alerter)
|
||||
|
||||
var repo repository2.ApiGatewayV2Repository = fakeRepo
|
||||
var repo repository.ApiGatewayV2Repository = fakeRepo
|
||||
|
||||
remoteLibrary.AddEnumerator(aws2.NewApiGatewayV2ModelEnumerator(repo, factory))
|
||||
|
||||
|
@ -706,13 +706,13 @@ func TestApiGatewayV2Stage(t *testing.T) {
|
|||
|
||||
tests := []struct {
|
||||
test string
|
||||
mocks func(*repository2.MockApiGatewayV2Repository, *mocks.AlerterInterface)
|
||||
mocks func(*repository.MockApiGatewayV2Repository, *mocks.AlerterInterface)
|
||||
assertExpected func(t *testing.T, got []*resource.Resource)
|
||||
wantErr error
|
||||
}{
|
||||
{
|
||||
test: "no api gateway v2 api",
|
||||
mocks: func(repository *repository2.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) {
|
||||
repository.On("ListAllApis").Return([]*apigatewayv2.Api{}, nil)
|
||||
},
|
||||
assertExpected: func(t *testing.T, got []*resource.Resource) {
|
||||
|
@ -721,7 +721,7 @@ func TestApiGatewayV2Stage(t *testing.T) {
|
|||
},
|
||||
{
|
||||
test: "single api gateway v2 api with a single stage",
|
||||
mocks: func(repository *repository2.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) {
|
||||
repository.On("ListAllApis").Return([]*apigatewayv2.Api{
|
||||
{ApiId: awssdk.String("a-gateway")},
|
||||
}, nil)
|
||||
|
@ -739,7 +739,7 @@ func TestApiGatewayV2Stage(t *testing.T) {
|
|||
},
|
||||
{
|
||||
test: "cannot list api gateway v2 apis",
|
||||
mocks: func(repository *repository2.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) {
|
||||
repository.On("ListAllApis").Return(nil, dummyError)
|
||||
alerter.On("SendAlert", resourceaws.AwsApiGatewayV2StageResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayV2ApiResourceType, resourceaws.AwsApiGatewayV2StageResourceType), alerts.EnumerationPhase)).Return()
|
||||
},
|
||||
|
@ -759,10 +759,10 @@ func TestApiGatewayV2Stage(t *testing.T) {
|
|||
|
||||
// Initialize mocks
|
||||
alerter := &mocks.AlerterInterface{}
|
||||
fakeRepo := &repository2.MockApiGatewayV2Repository{}
|
||||
fakeRepo := &repository.MockApiGatewayV2Repository{}
|
||||
c.mocks(fakeRepo, alerter)
|
||||
|
||||
var repo repository2.ApiGatewayV2Repository = fakeRepo
|
||||
var repo repository.ApiGatewayV2Repository = fakeRepo
|
||||
|
||||
remoteLibrary.AddEnumerator(aws2.NewApiGatewayV2StageEnumerator(repo, factory))
|
||||
|
||||
|
@ -789,13 +789,13 @@ func TestApiGatewayV2RouteResponse(t *testing.T) {
|
|||
|
||||
tests := []struct {
|
||||
test string
|
||||
mocks func(*repository2.MockApiGatewayV2Repository, *mocks.AlerterInterface)
|
||||
mocks func(*repository.MockApiGatewayV2Repository, *mocks.AlerterInterface)
|
||||
assertExpected func(t *testing.T, got []*resource.Resource)
|
||||
wantErr error
|
||||
}{
|
||||
{
|
||||
test: "no api gateway v2 route responses",
|
||||
mocks: func(repository *repository2.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) {
|
||||
repository.On("ListAllApis").Return([]*apigatewayv2.Api{
|
||||
{ApiId: awssdk.String("77ooqulkke")},
|
||||
}, nil)
|
||||
|
@ -812,7 +812,7 @@ func TestApiGatewayV2RouteResponse(t *testing.T) {
|
|||
},
|
||||
{
|
||||
test: "single api gateway v2 route with one route response",
|
||||
mocks: func(repository *repository2.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) {
|
||||
repository.On("ListAllApis").Return([]*apigatewayv2.Api{
|
||||
{ApiId: awssdk.String("77ooqulkke")},
|
||||
}, nil)
|
||||
|
@ -834,7 +834,7 @@ func TestApiGatewayV2RouteResponse(t *testing.T) {
|
|||
},
|
||||
{
|
||||
test: "cannot list api gateway v2 apis",
|
||||
mocks: func(repository *repository2.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) {
|
||||
repository.On("ListAllApis").Return(nil, dummyError)
|
||||
alerter.On("SendAlert", resourceaws.AwsApiGatewayV2RouteResponseResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayV2ApiResourceType, resourceaws.AwsApiGatewayV2RouteResponseResourceType), alerts.EnumerationPhase)).Return()
|
||||
},
|
||||
|
@ -842,7 +842,7 @@ func TestApiGatewayV2RouteResponse(t *testing.T) {
|
|||
},
|
||||
{
|
||||
test: "cannot list api gateway v2 routes",
|
||||
mocks: func(repository *repository2.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) {
|
||||
repository.On("ListAllApis").Return([]*apigatewayv2.Api{
|
||||
{ApiId: awssdk.String("77ooqulkke")},
|
||||
}, nil)
|
||||
|
@ -853,7 +853,7 @@ func TestApiGatewayV2RouteResponse(t *testing.T) {
|
|||
},
|
||||
{
|
||||
test: "cannot list api gateway v2 route responses",
|
||||
mocks: func(repository *repository2.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) {
|
||||
repository.On("ListAllApis").Return([]*apigatewayv2.Api{
|
||||
{ApiId: awssdk.String("77ooqulkke")},
|
||||
}, nil)
|
||||
|
@ -880,10 +880,10 @@ func TestApiGatewayV2RouteResponse(t *testing.T) {
|
|||
|
||||
// Initialize mocks
|
||||
alerter := &mocks.AlerterInterface{}
|
||||
fakeRepo := &repository2.MockApiGatewayV2Repository{}
|
||||
fakeRepo := &repository.MockApiGatewayV2Repository{}
|
||||
c.mocks(fakeRepo, alerter)
|
||||
|
||||
var repo repository2.ApiGatewayV2Repository = fakeRepo
|
||||
var repo repository.ApiGatewayV2Repository = fakeRepo
|
||||
|
||||
remoteLibrary.AddEnumerator(aws2.NewApiGatewayV2RouteResponseEnumerator(repo, factory))
|
||||
|
||||
|
@ -910,13 +910,13 @@ func TestApiGatewayV2Mapping(t *testing.T) {
|
|||
|
||||
tests := []struct {
|
||||
test string
|
||||
mocks func(*repository2.MockApiGatewayRepository, *repository2.MockApiGatewayV2Repository, *mocks.AlerterInterface)
|
||||
mocks func(*repository.MockApiGatewayRepository, *repository.MockApiGatewayV2Repository, *mocks.AlerterInterface)
|
||||
assertExpected func(t *testing.T, got []*resource.Resource)
|
||||
wantErr error
|
||||
}{
|
||||
{
|
||||
test: "no api gateway v2 domains",
|
||||
mocks: func(repositoryV1 *repository2.MockApiGatewayRepository, repository *repository2.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repositoryV1 *repository.MockApiGatewayRepository, repository *repository.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) {
|
||||
repositoryV1.On("ListAllDomainNames").Return([]*apigateway.DomainName{}, nil)
|
||||
},
|
||||
assertExpected: func(t *testing.T, got []*resource.Resource) {
|
||||
|
@ -925,7 +925,7 @@ func TestApiGatewayV2Mapping(t *testing.T) {
|
|||
},
|
||||
{
|
||||
test: "single api gateway v2 domain with a single mapping",
|
||||
mocks: func(repositoryV1 *repository2.MockApiGatewayRepository, repository *repository2.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repositoryV1 *repository.MockApiGatewayRepository, repository *repository.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) {
|
||||
repositoryV1.On("ListAllDomainNames").Return([]*apigateway.DomainName{
|
||||
{DomainName: awssdk.String("example.com")},
|
||||
}, nil)
|
||||
|
@ -945,7 +945,7 @@ func TestApiGatewayV2Mapping(t *testing.T) {
|
|||
},
|
||||
{
|
||||
test: "cannot list api gateway v2 domains",
|
||||
mocks: func(repositoryV1 *repository2.MockApiGatewayRepository, repository *repository2.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repositoryV1 *repository.MockApiGatewayRepository, repository *repository.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) {
|
||||
repositoryV1.On("ListAllDomainNames").Return(nil, dummyError)
|
||||
alerter.On("SendAlert", resourceaws.AwsApiGatewayV2MappingResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayDomainNameResourceType, resourceaws.AwsApiGatewayV2MappingResourceType), alerts.EnumerationPhase)).Return()
|
||||
},
|
||||
|
@ -953,7 +953,7 @@ func TestApiGatewayV2Mapping(t *testing.T) {
|
|||
},
|
||||
{
|
||||
test: "cannot list api gateway v2 mappings",
|
||||
mocks: func(repositoryV1 *repository2.MockApiGatewayRepository, repository *repository2.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repositoryV1 *repository.MockApiGatewayRepository, repository *repository.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) {
|
||||
repositoryV1.On("ListAllDomainNames").Return([]*apigateway.DomainName{
|
||||
{DomainName: awssdk.String("example.com")},
|
||||
}, nil)
|
||||
|
@ -965,7 +965,7 @@ func TestApiGatewayV2Mapping(t *testing.T) {
|
|||
},
|
||||
{
|
||||
test: "returning mapping with invalid attributes",
|
||||
mocks: func(repositoryV1 *repository2.MockApiGatewayRepository, repository *repository2.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repositoryV1 *repository.MockApiGatewayRepository, repository *repository.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) {
|
||||
repositoryV1.On("ListAllDomainNames").Return([]*apigateway.DomainName{
|
||||
{DomainName: awssdk.String("example.com")},
|
||||
}, nil)
|
||||
|
@ -1005,8 +1005,8 @@ func TestApiGatewayV2Mapping(t *testing.T) {
|
|||
|
||||
// Initialize mocks
|
||||
alerter := &mocks.AlerterInterface{}
|
||||
fakeRepoV1 := &repository2.MockApiGatewayRepository{}
|
||||
fakeRepo := &repository2.MockApiGatewayV2Repository{}
|
||||
fakeRepoV1 := &repository.MockApiGatewayRepository{}
|
||||
fakeRepo := &repository.MockApiGatewayV2Repository{}
|
||||
c.mocks(fakeRepoV1, fakeRepo, alerter)
|
||||
|
||||
remoteLibrary.AddEnumerator(aws2.NewApiGatewayV2MappingEnumerator(fakeRepo, fakeRepoV1, factory))
|
||||
|
@ -1035,13 +1035,13 @@ func TestApiGatewayV2DomainName(t *testing.T) {
|
|||
|
||||
tests := []struct {
|
||||
test string
|
||||
mocks func(*repository2.MockApiGatewayRepository, *mocks.AlerterInterface)
|
||||
mocks func(*repository.MockApiGatewayRepository, *mocks.AlerterInterface)
|
||||
assertExpected func(t *testing.T, got []*resource.Resource)
|
||||
wantErr error
|
||||
}{
|
||||
{
|
||||
test: "no api gateway v2 domain names",
|
||||
mocks: func(repository *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) {
|
||||
repository.On("ListAllDomainNames").Return([]*apigateway.DomainName{}, nil)
|
||||
},
|
||||
assertExpected: func(t *testing.T, got []*resource.Resource) {
|
||||
|
@ -1050,7 +1050,7 @@ func TestApiGatewayV2DomainName(t *testing.T) {
|
|||
},
|
||||
{
|
||||
test: "single api gateway v2 domain name",
|
||||
mocks: func(repository *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) {
|
||||
repository.On("ListAllDomainNames").Return([]*apigateway.DomainName{
|
||||
{DomainName: awssdk.String("b8r351.example.com")},
|
||||
}, nil)
|
||||
|
@ -1064,7 +1064,7 @@ func TestApiGatewayV2DomainName(t *testing.T) {
|
|||
},
|
||||
{
|
||||
test: "cannot list api gateway v2 domain names",
|
||||
mocks: func(repository *repository2.MockApiGatewayRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockApiGatewayRepository, alerter *mocks.AlerterInterface) {
|
||||
repository.On("ListAllDomainNames").Return(nil, dummyError)
|
||||
alerter.On("SendAlert", resourceaws.AwsApiGatewayV2DomainNameResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayV2DomainNameResourceType, resourceaws.AwsApiGatewayV2DomainNameResourceType), alerts.EnumerationPhase)).Return()
|
||||
},
|
||||
|
@ -1084,10 +1084,10 @@ func TestApiGatewayV2DomainName(t *testing.T) {
|
|||
|
||||
// Initialize mocks
|
||||
alerter := &mocks.AlerterInterface{}
|
||||
fakeRepo := &repository2.MockApiGatewayRepository{}
|
||||
fakeRepo := &repository.MockApiGatewayRepository{}
|
||||
c.mocks(fakeRepo, alerter)
|
||||
|
||||
var repo repository2.ApiGatewayRepository = fakeRepo
|
||||
var repo repository.ApiGatewayRepository = fakeRepo
|
||||
|
||||
remoteLibrary.AddEnumerator(aws2.NewApiGatewayV2DomainNameEnumerator(repo, factory))
|
||||
|
||||
|
@ -1114,13 +1114,13 @@ func TestApiGatewayV2IntegrationResponse(t *testing.T) {
|
|||
|
||||
tests := []struct {
|
||||
test string
|
||||
mocks func(*repository2.MockApiGatewayV2Repository, *mocks.AlerterInterface)
|
||||
mocks func(*repository.MockApiGatewayV2Repository, *mocks.AlerterInterface)
|
||||
assertExpected func(t *testing.T, got []*resource.Resource)
|
||||
wantErr error
|
||||
}{
|
||||
{
|
||||
test: "no api gateway v2 integration responses",
|
||||
mocks: func(repository *repository2.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) {
|
||||
repository.On("ListAllApis").Return([]*apigatewayv2.Api{
|
||||
{ApiId: awssdk.String("yw28nwdf34")},
|
||||
}, nil)
|
||||
|
@ -1137,7 +1137,7 @@ func TestApiGatewayV2IntegrationResponse(t *testing.T) {
|
|||
},
|
||||
{
|
||||
test: "single api gateway v2 integration with one integration response",
|
||||
mocks: func(repository *repository2.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) {
|
||||
repository.On("ListAllApis").Return([]*apigatewayv2.Api{
|
||||
{ApiId: awssdk.String("yw28nwdf34")},
|
||||
}, nil)
|
||||
|
@ -1159,7 +1159,7 @@ func TestApiGatewayV2IntegrationResponse(t *testing.T) {
|
|||
},
|
||||
{
|
||||
test: "cannot list api gateway v2 apis",
|
||||
mocks: func(repository *repository2.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) {
|
||||
repository.On("ListAllApis").Return(nil, dummyError)
|
||||
alerter.On("SendAlert", resourceaws.AwsApiGatewayV2IntegrationResponseResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsApiGatewayV2ApiResourceType, resourceaws.AwsApiGatewayV2IntegrationResponseResourceType), alerts.EnumerationPhase)).Return()
|
||||
},
|
||||
|
@ -1167,7 +1167,7 @@ func TestApiGatewayV2IntegrationResponse(t *testing.T) {
|
|||
},
|
||||
{
|
||||
test: "cannot list api gateway v2 integrations",
|
||||
mocks: func(repository *repository2.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) {
|
||||
repository.On("ListAllApis").Return([]*apigatewayv2.Api{
|
||||
{ApiId: awssdk.String("yw28nwdf34")},
|
||||
}, nil)
|
||||
|
@ -1178,7 +1178,7 @@ func TestApiGatewayV2IntegrationResponse(t *testing.T) {
|
|||
},
|
||||
{
|
||||
test: "cannot list api gateway v2 integration responses",
|
||||
mocks: func(repository *repository2.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockApiGatewayV2Repository, alerter *mocks.AlerterInterface) {
|
||||
repository.On("ListAllApis").Return([]*apigatewayv2.Api{
|
||||
{ApiId: awssdk.String("yw28nwdf34")},
|
||||
}, nil)
|
||||
|
@ -1205,10 +1205,10 @@ func TestApiGatewayV2IntegrationResponse(t *testing.T) {
|
|||
|
||||
// Initialize mocks
|
||||
alerter := &mocks.AlerterInterface{}
|
||||
fakeRepo := &repository2.MockApiGatewayV2Repository{}
|
||||
fakeRepo := &repository.MockApiGatewayV2Repository{}
|
||||
c.mocks(fakeRepo, alerter)
|
||||
|
||||
var repo repository2.ApiGatewayV2Repository = fakeRepo
|
||||
var repo repository.ApiGatewayV2Repository = fakeRepo
|
||||
|
||||
remoteLibrary.AddEnumerator(aws2.NewApiGatewayV2IntegrationResponseEnumerator(repo, factory))
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ import (
|
|||
|
||||
"github.com/snyk/driftctl/enumeration"
|
||||
aws2 "github.com/snyk/driftctl/enumeration/remote/aws"
|
||||
repository2 "github.com/snyk/driftctl/enumeration/remote/aws/repository"
|
||||
"github.com/snyk/driftctl/enumeration/remote/aws/repository"
|
||||
"github.com/snyk/driftctl/enumeration/remote/cache"
|
||||
common2 "github.com/snyk/driftctl/enumeration/remote/common"
|
||||
remoteerror "github.com/snyk/driftctl/enumeration/remote/error"
|
||||
|
@ -31,13 +31,13 @@ func TestAppAutoScalingTarget(t *testing.T) {
|
|||
tests := []struct {
|
||||
test string
|
||||
dirName string
|
||||
mocks func(*repository2.MockAppAutoScalingRepository, *mocks.AlerterInterface)
|
||||
mocks func(*repository.MockAppAutoScalingRepository, *mocks.AlerterInterface)
|
||||
wantErr error
|
||||
}{
|
||||
{
|
||||
test: "should return one target",
|
||||
dirName: "aws_appautoscaling_target_single",
|
||||
mocks: func(client *repository2.MockAppAutoScalingRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(client *repository.MockAppAutoScalingRepository, alerter *mocks.AlerterInterface) {
|
||||
client.On("ServiceNamespaceValues").Return(applicationautoscaling.ServiceNamespace_Values()).Once()
|
||||
|
||||
client.On("DescribeScalableTargets", "dynamodb").Return([]*applicationautoscaling.ScalableTarget{
|
||||
|
@ -58,7 +58,7 @@ func TestAppAutoScalingTarget(t *testing.T) {
|
|||
{
|
||||
test: "should return remote error",
|
||||
dirName: "aws_appautoscaling_target_single",
|
||||
mocks: func(client *repository2.MockAppAutoScalingRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(client *repository.MockAppAutoScalingRepository, alerter *mocks.AlerterInterface) {
|
||||
client.On("ServiceNamespaceValues").Return(applicationautoscaling.ServiceNamespace_Values()).Once()
|
||||
|
||||
client.On("DescribeScalableTargets", mock.AnythingOfType("string")).Return(nil, errors.New("remote error")).Once()
|
||||
|
@ -86,10 +86,10 @@ func TestAppAutoScalingTarget(t *testing.T) {
|
|||
|
||||
// Initialize mocks
|
||||
alerter := &mocks.AlerterInterface{}
|
||||
fakeRepo := &repository2.MockAppAutoScalingRepository{}
|
||||
fakeRepo := &repository.MockAppAutoScalingRepository{}
|
||||
c.mocks(fakeRepo, alerter)
|
||||
|
||||
var repo repository2.AppAutoScalingRepository = fakeRepo
|
||||
var repo repository.AppAutoScalingRepository = fakeRepo
|
||||
providerVersion := "3.19.0"
|
||||
realProvider, err := terraform2.InitTestAwsProvider(providerLibrary, providerVersion)
|
||||
if err != nil {
|
||||
|
@ -105,7 +105,7 @@ func TestAppAutoScalingTarget(t *testing.T) {
|
|||
t.Fatal(err)
|
||||
}
|
||||
provider.ShouldUpdate()
|
||||
repo = repository2.NewAppAutoScalingRepository(sess, cache.New(0))
|
||||
repo = repository.NewAppAutoScalingRepository(sess, cache.New(0))
|
||||
}
|
||||
|
||||
remoteLibrary.AddEnumerator(aws2.NewAppAutoscalingTargetEnumerator(repo, factory))
|
||||
|
@ -136,13 +136,13 @@ func TestAppAutoScalingPolicy(t *testing.T) {
|
|||
tests := []struct {
|
||||
test string
|
||||
dirName string
|
||||
mocks func(*repository2.MockAppAutoScalingRepository, *mocks.AlerterInterface)
|
||||
mocks func(*repository.MockAppAutoScalingRepository, *mocks.AlerterInterface)
|
||||
wantErr error
|
||||
}{
|
||||
{
|
||||
test: "should return one policy",
|
||||
dirName: "aws_appautoscaling_policy_single",
|
||||
mocks: func(client *repository2.MockAppAutoScalingRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(client *repository.MockAppAutoScalingRepository, alerter *mocks.AlerterInterface) {
|
||||
client.On("ServiceNamespaceValues").Return(applicationautoscaling.ServiceNamespace_Values()).Once()
|
||||
|
||||
client.On("DescribeScalingPolicies", "dynamodb").Return([]*applicationautoscaling.ScalingPolicy{
|
||||
|
@ -161,7 +161,7 @@ func TestAppAutoScalingPolicy(t *testing.T) {
|
|||
{
|
||||
test: "should return remote error",
|
||||
dirName: "aws_appautoscaling_policy_single",
|
||||
mocks: func(client *repository2.MockAppAutoScalingRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(client *repository.MockAppAutoScalingRepository, alerter *mocks.AlerterInterface) {
|
||||
client.On("ServiceNamespaceValues").Return(applicationautoscaling.ServiceNamespace_Values()).Once()
|
||||
|
||||
client.On("DescribeScalingPolicies", mock.AnythingOfType("string")).Return(nil, errors.New("remote error")).Once()
|
||||
|
@ -189,10 +189,10 @@ func TestAppAutoScalingPolicy(t *testing.T) {
|
|||
|
||||
// Initialize mocks
|
||||
alerter := &mocks.AlerterInterface{}
|
||||
fakeRepo := &repository2.MockAppAutoScalingRepository{}
|
||||
fakeRepo := &repository.MockAppAutoScalingRepository{}
|
||||
c.mocks(fakeRepo, alerter)
|
||||
|
||||
var repo repository2.AppAutoScalingRepository = fakeRepo
|
||||
var repo repository.AppAutoScalingRepository = fakeRepo
|
||||
providerVersion := "3.19.0"
|
||||
realProvider, err := terraform2.InitTestAwsProvider(providerLibrary, providerVersion)
|
||||
if err != nil {
|
||||
|
@ -208,7 +208,7 @@ func TestAppAutoScalingPolicy(t *testing.T) {
|
|||
t.Fatal(err)
|
||||
}
|
||||
provider.ShouldUpdate()
|
||||
repo = repository2.NewAppAutoScalingRepository(sess, cache.New(0))
|
||||
repo = repository.NewAppAutoScalingRepository(sess, cache.New(0))
|
||||
}
|
||||
|
||||
remoteLibrary.AddEnumerator(aws2.NewAppAutoscalingPolicyEnumerator(repo, factory))
|
||||
|
@ -240,13 +240,13 @@ func TestAppAutoScalingScheduledAction(t *testing.T) {
|
|||
|
||||
tests := []struct {
|
||||
test string
|
||||
mocks func(*repository2.MockAppAutoScalingRepository, *mocks.AlerterInterface)
|
||||
mocks func(*repository.MockAppAutoScalingRepository, *mocks.AlerterInterface)
|
||||
assertExpected func(t *testing.T, got []*resource.Resource)
|
||||
wantErr error
|
||||
}{
|
||||
{
|
||||
test: "should return one scheduled action",
|
||||
mocks: func(client *repository2.MockAppAutoScalingRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(client *repository.MockAppAutoScalingRepository, alerter *mocks.AlerterInterface) {
|
||||
matchServiceNamespaceFunc := func(ns string) bool {
|
||||
for _, n := range applicationautoscaling.ServiceNamespace_Values() {
|
||||
if n == ns {
|
||||
|
@ -278,7 +278,7 @@ func TestAppAutoScalingScheduledAction(t *testing.T) {
|
|||
},
|
||||
{
|
||||
test: "should return remote error",
|
||||
mocks: func(client *repository2.MockAppAutoScalingRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(client *repository.MockAppAutoScalingRepository, alerter *mocks.AlerterInterface) {
|
||||
client.On("ServiceNamespaceValues").Return(applicationautoscaling.ServiceNamespace_Values()).Once()
|
||||
|
||||
client.On("DescribeScheduledActions", mock.AnythingOfType("string")).Return(nil, dummyError).Once()
|
||||
|
@ -302,10 +302,10 @@ func TestAppAutoScalingScheduledAction(t *testing.T) {
|
|||
|
||||
// Initialize mocks
|
||||
alerter := &mocks.AlerterInterface{}
|
||||
fakeRepo := &repository2.MockAppAutoScalingRepository{}
|
||||
fakeRepo := &repository.MockAppAutoScalingRepository{}
|
||||
c.mocks(fakeRepo, alerter)
|
||||
|
||||
var repo repository2.AppAutoScalingRepository = fakeRepo
|
||||
var repo repository.AppAutoScalingRepository = fakeRepo
|
||||
|
||||
remoteLibrary.AddEnumerator(aws2.NewAppAutoscalingScheduledActionEnumerator(repo, factory))
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ import (
|
|||
"github.com/snyk/driftctl/enumeration"
|
||||
"github.com/snyk/driftctl/enumeration/remote/alerts"
|
||||
"github.com/snyk/driftctl/enumeration/remote/aws"
|
||||
repository2 "github.com/snyk/driftctl/enumeration/remote/aws/repository"
|
||||
"github.com/snyk/driftctl/enumeration/remote/aws/repository"
|
||||
common2 "github.com/snyk/driftctl/enumeration/remote/common"
|
||||
remoteerr "github.com/snyk/driftctl/enumeration/remote/error"
|
||||
"github.com/snyk/driftctl/enumeration/terraform"
|
||||
|
@ -27,13 +27,13 @@ import (
|
|||
func TestAutoscaling_LaunchConfiguration(t *testing.T) {
|
||||
tests := []struct {
|
||||
test string
|
||||
mocks func(*repository2.MockAutoScalingRepository, *mocks.AlerterInterface)
|
||||
mocks func(*repository.MockAutoScalingRepository, *mocks.AlerterInterface)
|
||||
assertExpected func(*testing.T, []*resource.Resource)
|
||||
wantErr error
|
||||
}{
|
||||
{
|
||||
test: "no launch configuration",
|
||||
mocks: func(repository *repository2.MockAutoScalingRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockAutoScalingRepository, alerter *mocks.AlerterInterface) {
|
||||
repository.On("DescribeLaunchConfigurations").Return([]*autoscaling.LaunchConfiguration{}, nil)
|
||||
},
|
||||
assertExpected: func(t *testing.T, got []*resource.Resource) {
|
||||
|
@ -42,7 +42,7 @@ func TestAutoscaling_LaunchConfiguration(t *testing.T) {
|
|||
},
|
||||
{
|
||||
test: "multiple launch configurations",
|
||||
mocks: func(repository *repository2.MockAutoScalingRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockAutoScalingRepository, alerter *mocks.AlerterInterface) {
|
||||
repository.On("DescribeLaunchConfigurations").Return([]*autoscaling.LaunchConfiguration{
|
||||
{LaunchConfigurationName: awssdk.String("web_config_1")},
|
||||
{LaunchConfigurationName: awssdk.String("web_config_2")},
|
||||
|
@ -60,7 +60,7 @@ func TestAutoscaling_LaunchConfiguration(t *testing.T) {
|
|||
},
|
||||
{
|
||||
test: "cannot list launch configurations",
|
||||
mocks: func(repository *repository2.MockAutoScalingRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockAutoScalingRepository, alerter *mocks.AlerterInterface) {
|
||||
awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "")
|
||||
repository.On("DescribeLaunchConfigurations").Return(nil, awsError)
|
||||
|
||||
|
@ -85,10 +85,10 @@ func TestAutoscaling_LaunchConfiguration(t *testing.T) {
|
|||
|
||||
// Initialize mocks
|
||||
alerter := &mocks.AlerterInterface{}
|
||||
fakeRepo := &repository2.MockAutoScalingRepository{}
|
||||
fakeRepo := &repository.MockAutoScalingRepository{}
|
||||
c.mocks(fakeRepo, alerter)
|
||||
|
||||
var repo repository2.AutoScalingRepository = fakeRepo
|
||||
var repo repository.AutoScalingRepository = fakeRepo
|
||||
|
||||
remoteLibrary.AddEnumerator(aws.NewLaunchConfigurationEnumerator(repo, factory))
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ import (
|
|||
"github.com/snyk/driftctl/enumeration"
|
||||
"github.com/snyk/driftctl/enumeration/remote/alerts"
|
||||
"github.com/snyk/driftctl/enumeration/remote/aws"
|
||||
repository2 "github.com/snyk/driftctl/enumeration/remote/aws/repository"
|
||||
"github.com/snyk/driftctl/enumeration/remote/aws/repository"
|
||||
"github.com/snyk/driftctl/enumeration/remote/cache"
|
||||
common2 "github.com/snyk/driftctl/enumeration/remote/common"
|
||||
remoteerr "github.com/snyk/driftctl/enumeration/remote/error"
|
||||
|
@ -33,20 +33,20 @@ func TestCloudformationStack(t *testing.T) {
|
|||
tests := []struct {
|
||||
test string
|
||||
dirName string
|
||||
mocks func(*repository2.MockCloudformationRepository, *mocks.AlerterInterface)
|
||||
mocks func(*repository.MockCloudformationRepository, *mocks.AlerterInterface)
|
||||
wantErr error
|
||||
}{
|
||||
{
|
||||
test: "no cloudformation stacks",
|
||||
dirName: "aws_cloudformation_stack_empty",
|
||||
mocks: func(repository *repository2.MockCloudformationRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockCloudformationRepository, alerter *mocks.AlerterInterface) {
|
||||
repository.On("ListAllStacks").Return([]*cloudformation.Stack{}, nil)
|
||||
},
|
||||
},
|
||||
{
|
||||
test: "multiple cloudformation stacks",
|
||||
dirName: "aws_cloudformation_stack_multiple",
|
||||
mocks: func(repository *repository2.MockCloudformationRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockCloudformationRepository, alerter *mocks.AlerterInterface) {
|
||||
repository.On("ListAllStacks").Return([]*cloudformation.Stack{
|
||||
{StackId: awssdk.String("arn:aws:cloudformation:us-east-1:047081014315:stack/bar-stack/c7a96e70-0f21-11ec-bd2a-0a2d95c2b2ab")},
|
||||
{StackId: awssdk.String("arn:aws:cloudformation:us-east-1:047081014315:stack/foo-stack/c7aa0ab0-0f21-11ec-ba25-129d8c0b3757")},
|
||||
|
@ -56,7 +56,7 @@ func TestCloudformationStack(t *testing.T) {
|
|||
{
|
||||
test: "cannot list cloudformation stacks",
|
||||
dirName: "aws_cloudformation_stack_list",
|
||||
mocks: func(repository *repository2.MockCloudformationRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockCloudformationRepository, alerter *mocks.AlerterInterface) {
|
||||
awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 400, "")
|
||||
repository.On("ListAllStacks").Return(nil, awsError)
|
||||
|
||||
|
@ -85,10 +85,10 @@ func TestCloudformationStack(t *testing.T) {
|
|||
|
||||
// Initialize mocks
|
||||
alerter := &mocks.AlerterInterface{}
|
||||
fakeRepo := &repository2.MockCloudformationRepository{}
|
||||
fakeRepo := &repository.MockCloudformationRepository{}
|
||||
c.mocks(fakeRepo, alerter)
|
||||
|
||||
var repo repository2.CloudformationRepository = fakeRepo
|
||||
var repo repository.CloudformationRepository = fakeRepo
|
||||
providerVersion := "3.19.0"
|
||||
realProvider, err := terraform2.InitTestAwsProvider(providerLibrary, providerVersion)
|
||||
if err != nil {
|
||||
|
@ -104,7 +104,7 @@ func TestCloudformationStack(t *testing.T) {
|
|||
t.Fatal(err)
|
||||
}
|
||||
provider.ShouldUpdate()
|
||||
repo = repository2.NewCloudformationRepository(sess, cache.New(0))
|
||||
repo = repository.NewCloudformationRepository(sess, cache.New(0))
|
||||
}
|
||||
|
||||
remoteLibrary.AddEnumerator(aws.NewCloudformationStackEnumerator(repo, factory))
|
||||
|
|
|
@ -6,7 +6,7 @@ import (
|
|||
"github.com/snyk/driftctl/enumeration"
|
||||
"github.com/snyk/driftctl/enumeration/remote/alerts"
|
||||
"github.com/snyk/driftctl/enumeration/remote/aws"
|
||||
repository2 "github.com/snyk/driftctl/enumeration/remote/aws/repository"
|
||||
"github.com/snyk/driftctl/enumeration/remote/aws/repository"
|
||||
"github.com/snyk/driftctl/enumeration/remote/cache"
|
||||
common2 "github.com/snyk/driftctl/enumeration/remote/common"
|
||||
remoteerr "github.com/snyk/driftctl/enumeration/remote/error"
|
||||
|
@ -33,20 +33,20 @@ func TestCloudfrontDistribution(t *testing.T) {
|
|||
tests := []struct {
|
||||
test string
|
||||
dirName string
|
||||
mocks func(*repository2.MockCloudfrontRepository, *mocks.AlerterInterface)
|
||||
mocks func(*repository.MockCloudfrontRepository, *mocks.AlerterInterface)
|
||||
wantErr error
|
||||
}{
|
||||
{
|
||||
test: "no cloudfront distributions",
|
||||
dirName: "aws_cloudfront_distribution_empty",
|
||||
mocks: func(repository *repository2.MockCloudfrontRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockCloudfrontRepository, alerter *mocks.AlerterInterface) {
|
||||
repository.On("ListAllDistributions").Return([]*cloudfront.DistributionSummary{}, nil)
|
||||
},
|
||||
},
|
||||
{
|
||||
test: "single cloudfront distribution",
|
||||
dirName: "aws_cloudfront_distribution_single",
|
||||
mocks: func(repository *repository2.MockCloudfrontRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockCloudfrontRepository, alerter *mocks.AlerterInterface) {
|
||||
repository.On("ListAllDistributions").Return([]*cloudfront.DistributionSummary{
|
||||
{Id: awssdk.String("E1M9CNS0XSHI19")},
|
||||
}, nil)
|
||||
|
@ -55,7 +55,7 @@ func TestCloudfrontDistribution(t *testing.T) {
|
|||
{
|
||||
test: "cannot list cloudfront distributions",
|
||||
dirName: "aws_cloudfront_distribution_list",
|
||||
mocks: func(repository *repository2.MockCloudfrontRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockCloudfrontRepository, alerter *mocks.AlerterInterface) {
|
||||
awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 400, "")
|
||||
repository.On("ListAllDistributions").Return(nil, awsError)
|
||||
|
||||
|
@ -84,10 +84,10 @@ func TestCloudfrontDistribution(t *testing.T) {
|
|||
|
||||
// Initialize mocks
|
||||
alerter := &mocks.AlerterInterface{}
|
||||
fakeRepo := &repository2.MockCloudfrontRepository{}
|
||||
fakeRepo := &repository.MockCloudfrontRepository{}
|
||||
c.mocks(fakeRepo, alerter)
|
||||
|
||||
var repo repository2.CloudfrontRepository = fakeRepo
|
||||
var repo repository.CloudfrontRepository = fakeRepo
|
||||
providerVersion := "3.19.0"
|
||||
realProvider, err := terraform2.InitTestAwsProvider(providerLibrary, providerVersion)
|
||||
if err != nil {
|
||||
|
@ -103,7 +103,7 @@ func TestCloudfrontDistribution(t *testing.T) {
|
|||
t.Fatal(err)
|
||||
}
|
||||
provider.ShouldUpdate()
|
||||
repo = repository2.NewCloudfrontRepository(sess, cache.New(0))
|
||||
repo = repository.NewCloudfrontRepository(sess, cache.New(0))
|
||||
}
|
||||
|
||||
remoteLibrary.AddEnumerator(aws.NewCloudfrontDistributionEnumerator(repo, factory))
|
||||
|
|
|
@ -7,7 +7,7 @@ import (
|
|||
"github.com/snyk/driftctl/enumeration"
|
||||
"github.com/snyk/driftctl/enumeration/remote/alerts"
|
||||
"github.com/snyk/driftctl/enumeration/remote/aws"
|
||||
repository2 "github.com/snyk/driftctl/enumeration/remote/aws/repository"
|
||||
"github.com/snyk/driftctl/enumeration/remote/aws/repository"
|
||||
"github.com/snyk/driftctl/enumeration/remote/cache"
|
||||
common2 "github.com/snyk/driftctl/enumeration/remote/common"
|
||||
remoteerr "github.com/snyk/driftctl/enumeration/remote/error"
|
||||
|
@ -32,13 +32,13 @@ func TestDynamoDBTable(t *testing.T) {
|
|||
tests := []struct {
|
||||
test string
|
||||
dirName string
|
||||
mocks func(*repository2.MockDynamoDBRepository, *mocks.AlerterInterface)
|
||||
mocks func(*repository.MockDynamoDBRepository, *mocks.AlerterInterface)
|
||||
wantErr error
|
||||
}{
|
||||
{
|
||||
test: "no DynamoDB Table",
|
||||
dirName: "aws_dynamodb_table_empty",
|
||||
mocks: func(client *repository2.MockDynamoDBRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(client *repository.MockDynamoDBRepository, alerter *mocks.AlerterInterface) {
|
||||
client.On("ListAllTables").Return([]*string{}, nil)
|
||||
},
|
||||
wantErr: nil,
|
||||
|
@ -46,7 +46,7 @@ func TestDynamoDBTable(t *testing.T) {
|
|||
{
|
||||
test: "Multiple DynamoDB Table",
|
||||
dirName: "aws_dynamodb_table_multiple",
|
||||
mocks: func(client *repository2.MockDynamoDBRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(client *repository.MockDynamoDBRepository, alerter *mocks.AlerterInterface) {
|
||||
client.On("ListAllTables").Return([]*string{
|
||||
awssdk.String("GameScores"),
|
||||
awssdk.String("example"),
|
||||
|
@ -57,7 +57,7 @@ func TestDynamoDBTable(t *testing.T) {
|
|||
{
|
||||
test: "cannot list DynamoDB Table",
|
||||
dirName: "aws_dynamodb_table_list",
|
||||
mocks: func(client *repository2.MockDynamoDBRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(client *repository.MockDynamoDBRepository, alerter *mocks.AlerterInterface) {
|
||||
awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 400, "")
|
||||
client.On("ListAllTables").Return(nil, awsError)
|
||||
|
||||
|
@ -86,10 +86,10 @@ func TestDynamoDBTable(t *testing.T) {
|
|||
|
||||
// Initialize mocks
|
||||
alerter := &mocks.AlerterInterface{}
|
||||
fakeRepo := &repository2.MockDynamoDBRepository{}
|
||||
fakeRepo := &repository.MockDynamoDBRepository{}
|
||||
c.mocks(fakeRepo, alerter)
|
||||
|
||||
var repo repository2.DynamoDBRepository = fakeRepo
|
||||
var repo repository.DynamoDBRepository = fakeRepo
|
||||
providerVersion := "3.19.0"
|
||||
realProvider, err := terraform2.InitTestAwsProvider(providerLibrary, providerVersion)
|
||||
if err != nil {
|
||||
|
@ -105,7 +105,7 @@ func TestDynamoDBTable(t *testing.T) {
|
|||
t.Fatal(err)
|
||||
}
|
||||
provider.ShouldUpdate()
|
||||
repo = repository2.NewDynamoDBRepository(sess, cache.New(0))
|
||||
repo = repository.NewDynamoDBRepository(sess, cache.New(0))
|
||||
}
|
||||
|
||||
remoteLibrary.AddEnumerator(aws.NewDynamoDBTableEnumerator(repo, factory))
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -6,7 +6,7 @@ import (
|
|||
"github.com/snyk/driftctl/enumeration"
|
||||
"github.com/snyk/driftctl/enumeration/remote/alerts"
|
||||
aws2 "github.com/snyk/driftctl/enumeration/remote/aws"
|
||||
repository2 "github.com/snyk/driftctl/enumeration/remote/aws/repository"
|
||||
"github.com/snyk/driftctl/enumeration/remote/aws/repository"
|
||||
"github.com/snyk/driftctl/enumeration/remote/cache"
|
||||
common2 "github.com/snyk/driftctl/enumeration/remote/common"
|
||||
remoteerr "github.com/snyk/driftctl/enumeration/remote/error"
|
||||
|
@ -33,13 +33,13 @@ func TestECRRepository(t *testing.T) {
|
|||
tests := []struct {
|
||||
test string
|
||||
dirName string
|
||||
mocks func(*repository2.MockECRRepository, *mocks.AlerterInterface)
|
||||
mocks func(*repository.MockECRRepository, *mocks.AlerterInterface)
|
||||
err error
|
||||
}{
|
||||
{
|
||||
test: "no repository",
|
||||
dirName: "aws_ecr_repository_empty",
|
||||
mocks: func(client *repository2.MockECRRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(client *repository.MockECRRepository, alerter *mocks.AlerterInterface) {
|
||||
client.On("ListAllRepositories").Return([]*ecr.Repository{}, nil)
|
||||
},
|
||||
err: nil,
|
||||
|
@ -47,7 +47,7 @@ func TestECRRepository(t *testing.T) {
|
|||
{
|
||||
test: "multiple repositories",
|
||||
dirName: "aws_ecr_repository_multiple",
|
||||
mocks: func(client *repository2.MockECRRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(client *repository.MockECRRepository, alerter *mocks.AlerterInterface) {
|
||||
client.On("ListAllRepositories").Return([]*ecr.Repository{
|
||||
{RepositoryName: awssdk.String("test_ecr")},
|
||||
{RepositoryName: awssdk.String("bar")},
|
||||
|
@ -58,7 +58,7 @@ func TestECRRepository(t *testing.T) {
|
|||
{
|
||||
test: "cannot list repository",
|
||||
dirName: "aws_ecr_repository_empty",
|
||||
mocks: func(client *repository2.MockECRRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(client *repository.MockECRRepository, alerter *mocks.AlerterInterface) {
|
||||
awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "")
|
||||
client.On("ListAllRepositories").Return(nil, awsError)
|
||||
|
||||
|
@ -87,10 +87,10 @@ func TestECRRepository(t *testing.T) {
|
|||
|
||||
// Initialize mocks
|
||||
alerter := &mocks.AlerterInterface{}
|
||||
fakeRepo := &repository2.MockECRRepository{}
|
||||
fakeRepo := &repository.MockECRRepository{}
|
||||
c.mocks(fakeRepo, alerter)
|
||||
|
||||
var repo repository2.ECRRepository = fakeRepo
|
||||
var repo repository.ECRRepository = fakeRepo
|
||||
providerVersion := "3.19.0"
|
||||
realProvider, err := terraform2.InitTestAwsProvider(providerLibrary, providerVersion)
|
||||
if err != nil {
|
||||
|
@ -106,7 +106,7 @@ func TestECRRepository(t *testing.T) {
|
|||
t.Fatal(err)
|
||||
}
|
||||
provider.ShouldUpdate()
|
||||
repo = repository2.NewECRRepository(sess, cache.New(0))
|
||||
repo = repository.NewECRRepository(sess, cache.New(0))
|
||||
}
|
||||
|
||||
remoteLibrary.AddEnumerator(aws2.NewECRRepositoryEnumerator(repo, factory))
|
||||
|
@ -131,13 +131,13 @@ func TestECRRepository(t *testing.T) {
|
|||
func TestECRRepositoryPolicy(t *testing.T) {
|
||||
tests := []struct {
|
||||
test string
|
||||
mocks func(*repository2.MockECRRepository, *mocks.AlerterInterface)
|
||||
mocks func(*repository.MockECRRepository, *mocks.AlerterInterface)
|
||||
assertExpected func(t *testing.T, got []*resource.Resource)
|
||||
err error
|
||||
}{
|
||||
{
|
||||
test: "single repository policy",
|
||||
mocks: func(client *repository2.MockECRRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(client *repository.MockECRRepository, alerter *mocks.AlerterInterface) {
|
||||
client.On("ListAllRepositories").Return([]*ecr.Repository{
|
||||
{RepositoryName: awssdk.String("test_ecr_repo_policy")},
|
||||
{RepositoryName: awssdk.String("test_ecr_repo_without_policy")},
|
||||
|
@ -173,10 +173,10 @@ func TestECRRepositoryPolicy(t *testing.T) {
|
|||
|
||||
// Initialize mocks
|
||||
alerter := &mocks.AlerterInterface{}
|
||||
fakeRepo := &repository2.MockECRRepository{}
|
||||
fakeRepo := &repository.MockECRRepository{}
|
||||
c.mocks(fakeRepo, alerter)
|
||||
|
||||
var repo repository2.ECRRepository = fakeRepo
|
||||
var repo repository.ECRRepository = fakeRepo
|
||||
|
||||
remoteLibrary.AddEnumerator(aws2.NewECRRepositoryPolicyEnumerator(repo, factory))
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ import (
|
|||
"github.com/snyk/driftctl/enumeration"
|
||||
"github.com/snyk/driftctl/enumeration/remote/alerts"
|
||||
"github.com/snyk/driftctl/enumeration/remote/aws"
|
||||
repository2 "github.com/snyk/driftctl/enumeration/remote/aws/repository"
|
||||
"github.com/snyk/driftctl/enumeration/remote/aws/repository"
|
||||
common2 "github.com/snyk/driftctl/enumeration/remote/common"
|
||||
remoteerr "github.com/snyk/driftctl/enumeration/remote/error"
|
||||
"github.com/snyk/driftctl/enumeration/terraform"
|
||||
|
@ -29,13 +29,13 @@ func TestElastiCacheCluster(t *testing.T) {
|
|||
|
||||
tests := []struct {
|
||||
test string
|
||||
mocks func(*repository2.MockElastiCacheRepository, *mocks.AlerterInterface)
|
||||
mocks func(*repository.MockElastiCacheRepository, *mocks.AlerterInterface)
|
||||
assertExpected func(t *testing.T, got []*resource.Resource)
|
||||
wantErr error
|
||||
}{
|
||||
{
|
||||
test: "no elasticache clusters",
|
||||
mocks: func(repository *repository2.MockElastiCacheRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockElastiCacheRepository, alerter *mocks.AlerterInterface) {
|
||||
repository.On("ListAllCacheClusters").Return([]*elasticache.CacheCluster{}, nil)
|
||||
},
|
||||
assertExpected: func(t *testing.T, got []*resource.Resource) {
|
||||
|
@ -44,7 +44,7 @@ func TestElastiCacheCluster(t *testing.T) {
|
|||
},
|
||||
{
|
||||
test: "should list elasticache clusters",
|
||||
mocks: func(repository *repository2.MockElastiCacheRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockElastiCacheRepository, alerter *mocks.AlerterInterface) {
|
||||
repository.On("ListAllCacheClusters").Return([]*elasticache.CacheCluster{
|
||||
{CacheClusterId: awssdk.String("cluster-foo")},
|
||||
}, nil)
|
||||
|
@ -57,7 +57,7 @@ func TestElastiCacheCluster(t *testing.T) {
|
|||
},
|
||||
{
|
||||
test: "cannot list elasticache clusters (403)",
|
||||
mocks: func(repository *repository2.MockElastiCacheRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockElastiCacheRepository, alerter *mocks.AlerterInterface) {
|
||||
awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "")
|
||||
repository.On("ListAllCacheClusters").Return(nil, awsError)
|
||||
alerter.On("SendAlert", resourceaws.AwsElastiCacheClusterResourceType, alerts.NewRemoteAccessDeniedAlert(common2.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(awsError, resourceaws.AwsElastiCacheClusterResourceType, resourceaws.AwsElastiCacheClusterResourceType), alerts.EnumerationPhase)).Return()
|
||||
|
@ -68,7 +68,7 @@ func TestElastiCacheCluster(t *testing.T) {
|
|||
},
|
||||
{
|
||||
test: "cannot list elasticache clusters (dummy error)",
|
||||
mocks: func(repository *repository2.MockElastiCacheRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockElastiCacheRepository, alerter *mocks.AlerterInterface) {
|
||||
repository.On("ListAllCacheClusters").Return(nil, dummyError)
|
||||
},
|
||||
assertExpected: func(t *testing.T, got []*resource.Resource) {
|
||||
|
@ -90,10 +90,10 @@ func TestElastiCacheCluster(t *testing.T) {
|
|||
|
||||
// Initialize mocks
|
||||
alerter := &mocks.AlerterInterface{}
|
||||
fakeRepo := &repository2.MockElastiCacheRepository{}
|
||||
fakeRepo := &repository.MockElastiCacheRepository{}
|
||||
c.mocks(fakeRepo, alerter)
|
||||
|
||||
var repo repository2.ElastiCacheRepository = fakeRepo
|
||||
var repo repository.ElastiCacheRepository = fakeRepo
|
||||
|
||||
remoteLibrary.AddEnumerator(aws.NewElastiCacheClusterEnumerator(repo, factory))
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ import (
|
|||
"github.com/snyk/driftctl/enumeration"
|
||||
"github.com/snyk/driftctl/enumeration/remote/alerts"
|
||||
"github.com/snyk/driftctl/enumeration/remote/aws"
|
||||
repository2 "github.com/snyk/driftctl/enumeration/remote/aws/repository"
|
||||
"github.com/snyk/driftctl/enumeration/remote/aws/repository"
|
||||
common2 "github.com/snyk/driftctl/enumeration/remote/common"
|
||||
remoteerr "github.com/snyk/driftctl/enumeration/remote/error"
|
||||
"github.com/snyk/driftctl/enumeration/terraform"
|
||||
|
@ -29,13 +29,13 @@ func TestELB_LoadBalancer(t *testing.T) {
|
|||
|
||||
tests := []struct {
|
||||
test string
|
||||
mocks func(*repository2.MockELBRepository, *mocks.AlerterInterface)
|
||||
mocks func(*repository.MockELBRepository, *mocks.AlerterInterface)
|
||||
assertExpected func(t *testing.T, got []*resource.Resource)
|
||||
wantErr error
|
||||
}{
|
||||
{
|
||||
test: "no load balancer",
|
||||
mocks: func(repository *repository2.MockELBRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockELBRepository, alerter *mocks.AlerterInterface) {
|
||||
repository.On("ListAllLoadBalancers").Return([]*elb.LoadBalancerDescription{}, nil)
|
||||
},
|
||||
assertExpected: func(t *testing.T, got []*resource.Resource) {
|
||||
|
@ -44,7 +44,7 @@ func TestELB_LoadBalancer(t *testing.T) {
|
|||
},
|
||||
{
|
||||
test: "should list load balancers",
|
||||
mocks: func(repository *repository2.MockELBRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockELBRepository, alerter *mocks.AlerterInterface) {
|
||||
repository.On("ListAllLoadBalancers").Return([]*elb.LoadBalancerDescription{
|
||||
{
|
||||
LoadBalancerName: awssdk.String("acc-test-lb-tf"),
|
||||
|
@ -59,7 +59,7 @@ func TestELB_LoadBalancer(t *testing.T) {
|
|||
},
|
||||
{
|
||||
test: "cannot list load balancers",
|
||||
mocks: func(repository *repository2.MockELBRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockELBRepository, alerter *mocks.AlerterInterface) {
|
||||
awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "")
|
||||
repository.On("ListAllLoadBalancers").Return(nil, awsError)
|
||||
|
||||
|
@ -71,7 +71,7 @@ func TestELB_LoadBalancer(t *testing.T) {
|
|||
},
|
||||
{
|
||||
test: "cannot list load balancers (dummy error)",
|
||||
mocks: func(repository *repository2.MockELBRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockELBRepository, alerter *mocks.AlerterInterface) {
|
||||
repository.On("ListAllLoadBalancers").Return(nil, dummyError)
|
||||
},
|
||||
assertExpected: func(t *testing.T, got []*resource.Resource) {
|
||||
|
@ -93,10 +93,10 @@ func TestELB_LoadBalancer(t *testing.T) {
|
|||
|
||||
// Initialize mocks
|
||||
alerter := &mocks.AlerterInterface{}
|
||||
fakeRepo := &repository2.MockELBRepository{}
|
||||
fakeRepo := &repository.MockELBRepository{}
|
||||
c.mocks(fakeRepo, alerter)
|
||||
|
||||
var repo repository2.ELBRepository = fakeRepo
|
||||
var repo repository.ELBRepository = fakeRepo
|
||||
|
||||
remoteLibrary.AddEnumerator(aws.NewClassicLoadBalancerEnumerator(repo, factory))
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ import (
|
|||
"github.com/snyk/driftctl/enumeration"
|
||||
"github.com/snyk/driftctl/enumeration/remote/alerts"
|
||||
aws2 "github.com/snyk/driftctl/enumeration/remote/aws"
|
||||
repository2 "github.com/snyk/driftctl/enumeration/remote/aws/repository"
|
||||
"github.com/snyk/driftctl/enumeration/remote/aws/repository"
|
||||
common2 "github.com/snyk/driftctl/enumeration/remote/common"
|
||||
remoteerr "github.com/snyk/driftctl/enumeration/remote/error"
|
||||
"github.com/snyk/driftctl/enumeration/terraform"
|
||||
|
@ -29,13 +29,13 @@ func TestELBV2_LoadBalancer(t *testing.T) {
|
|||
|
||||
tests := []struct {
|
||||
test string
|
||||
mocks func(*repository2.MockELBV2Repository, *mocks.AlerterInterface)
|
||||
mocks func(*repository.MockELBV2Repository, *mocks.AlerterInterface)
|
||||
assertExpected func(t *testing.T, got []*resource.Resource)
|
||||
wantErr error
|
||||
}{
|
||||
{
|
||||
test: "no load balancer",
|
||||
mocks: func(repository *repository2.MockELBV2Repository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockELBV2Repository, alerter *mocks.AlerterInterface) {
|
||||
repository.On("ListAllLoadBalancers").Return([]*elbv2.LoadBalancer{}, nil)
|
||||
},
|
||||
assertExpected: func(t *testing.T, got []*resource.Resource) {
|
||||
|
@ -44,7 +44,7 @@ func TestELBV2_LoadBalancer(t *testing.T) {
|
|||
},
|
||||
{
|
||||
test: "should list load balancers",
|
||||
mocks: func(repository *repository2.MockELBV2Repository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockELBV2Repository, alerter *mocks.AlerterInterface) {
|
||||
repository.On("ListAllLoadBalancers").Return([]*elbv2.LoadBalancer{
|
||||
{
|
||||
LoadBalancerArn: awssdk.String("arn:aws:elasticloadbalancing:us-east-1:533948124879:loadbalancer/app/acc-test-lb-tf/9114c60e08560420"),
|
||||
|
@ -60,7 +60,7 @@ func TestELBV2_LoadBalancer(t *testing.T) {
|
|||
},
|
||||
{
|
||||
test: "cannot list load balancers (403)",
|
||||
mocks: func(repository *repository2.MockELBV2Repository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockELBV2Repository, alerter *mocks.AlerterInterface) {
|
||||
awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "")
|
||||
repository.On("ListAllLoadBalancers").Return(nil, awsError)
|
||||
|
||||
|
@ -72,7 +72,7 @@ func TestELBV2_LoadBalancer(t *testing.T) {
|
|||
},
|
||||
{
|
||||
test: "cannot list load balancers (dummy error)",
|
||||
mocks: func(repository *repository2.MockELBV2Repository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockELBV2Repository, alerter *mocks.AlerterInterface) {
|
||||
repository.On("ListAllLoadBalancers").Return(nil, dummyError)
|
||||
},
|
||||
assertExpected: func(t *testing.T, got []*resource.Resource) {
|
||||
|
@ -94,10 +94,10 @@ func TestELBV2_LoadBalancer(t *testing.T) {
|
|||
|
||||
// Initialize mocks
|
||||
alerter := &mocks.AlerterInterface{}
|
||||
fakeRepo := &repository2.MockELBV2Repository{}
|
||||
fakeRepo := &repository.MockELBV2Repository{}
|
||||
c.mocks(fakeRepo, alerter)
|
||||
|
||||
var repo repository2.ELBV2Repository = fakeRepo
|
||||
var repo repository.ELBV2Repository = fakeRepo
|
||||
|
||||
remoteLibrary.AddEnumerator(aws2.NewLoadBalancerEnumerator(repo, factory))
|
||||
|
||||
|
@ -123,13 +123,13 @@ func TestELBV2_LoadBalancerListener(t *testing.T) {
|
|||
|
||||
tests := []struct {
|
||||
test string
|
||||
mocks func(*repository2.MockELBV2Repository, *mocks.AlerterInterface)
|
||||
mocks func(*repository.MockELBV2Repository, *mocks.AlerterInterface)
|
||||
assertExpected func(t *testing.T, got []*resource.Resource)
|
||||
wantErr error
|
||||
}{
|
||||
{
|
||||
test: "no load balancer listener",
|
||||
mocks: func(repository *repository2.MockELBV2Repository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockELBV2Repository, alerter *mocks.AlerterInterface) {
|
||||
repository.On("ListAllLoadBalancers").Return([]*elbv2.LoadBalancer{
|
||||
{
|
||||
LoadBalancerArn: awssdk.String("test-lb"),
|
||||
|
@ -143,7 +143,7 @@ func TestELBV2_LoadBalancerListener(t *testing.T) {
|
|||
},
|
||||
{
|
||||
test: "should list load balancer listener",
|
||||
mocks: func(repository *repository2.MockELBV2Repository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockELBV2Repository, alerter *mocks.AlerterInterface) {
|
||||
repository.On("ListAllLoadBalancers").Return([]*elbv2.LoadBalancer{
|
||||
{
|
||||
LoadBalancerArn: awssdk.String("test-lb"),
|
||||
|
@ -164,7 +164,7 @@ func TestELBV2_LoadBalancerListener(t *testing.T) {
|
|||
},
|
||||
{
|
||||
test: "cannot list load balancer listeners (403)",
|
||||
mocks: func(repository *repository2.MockELBV2Repository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockELBV2Repository, alerter *mocks.AlerterInterface) {
|
||||
repository.On("ListAllLoadBalancers").Return([]*elbv2.LoadBalancer{
|
||||
{
|
||||
LoadBalancerArn: awssdk.String("test-lb"),
|
||||
|
@ -182,7 +182,7 @@ func TestELBV2_LoadBalancerListener(t *testing.T) {
|
|||
},
|
||||
{
|
||||
test: "cannot list load balancers (403)",
|
||||
mocks: func(repository *repository2.MockELBV2Repository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockELBV2Repository, alerter *mocks.AlerterInterface) {
|
||||
awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "")
|
||||
repository.On("ListAllLoadBalancers").Return(nil, awsError)
|
||||
|
||||
|
@ -194,7 +194,7 @@ func TestELBV2_LoadBalancerListener(t *testing.T) {
|
|||
},
|
||||
{
|
||||
test: "cannot list load balancer listeners (dummy error)",
|
||||
mocks: func(repository *repository2.MockELBV2Repository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockELBV2Repository, alerter *mocks.AlerterInterface) {
|
||||
repository.On("ListAllLoadBalancers").Return([]*elbv2.LoadBalancer{
|
||||
{
|
||||
LoadBalancerArn: awssdk.String("test-lb"),
|
||||
|
@ -222,10 +222,10 @@ func TestELBV2_LoadBalancerListener(t *testing.T) {
|
|||
|
||||
// Initialize mocks
|
||||
alerter := &mocks.AlerterInterface{}
|
||||
fakeRepo := &repository2.MockELBV2Repository{}
|
||||
fakeRepo := &repository.MockELBV2Repository{}
|
||||
c.mocks(fakeRepo, alerter)
|
||||
|
||||
var repo repository2.ELBV2Repository = fakeRepo
|
||||
var repo repository.ELBV2Repository = fakeRepo
|
||||
|
||||
remoteLibrary.AddEnumerator(aws2.NewLoadBalancerListenerEnumerator(repo, factory))
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ import (
|
|||
"github.com/snyk/driftctl/enumeration"
|
||||
"github.com/snyk/driftctl/enumeration/remote/alerts"
|
||||
aws2 "github.com/snyk/driftctl/enumeration/remote/aws"
|
||||
repository2 "github.com/snyk/driftctl/enumeration/remote/aws/repository"
|
||||
"github.com/snyk/driftctl/enumeration/remote/aws/repository"
|
||||
"github.com/snyk/driftctl/enumeration/remote/cache"
|
||||
common2 "github.com/snyk/driftctl/enumeration/remote/common"
|
||||
remoteerr "github.com/snyk/driftctl/enumeration/remote/error"
|
||||
|
@ -34,13 +34,13 @@ func TestIamUser(t *testing.T) {
|
|||
cases := []struct {
|
||||
test string
|
||||
dirName string
|
||||
mocks func(*repository2.MockIAMRepository, *mocks.AlerterInterface)
|
||||
mocks func(*repository.MockIAMRepository, *mocks.AlerterInterface)
|
||||
wantErr error
|
||||
}{
|
||||
{
|
||||
test: "no iam user",
|
||||
dirName: "aws_iam_user_empty",
|
||||
mocks: func(repo *repository2.MockIAMRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repo *repository.MockIAMRepository, alerter *mocks.AlerterInterface) {
|
||||
repo.On("ListAllUsers").Return([]*iam.User{}, nil)
|
||||
},
|
||||
wantErr: nil,
|
||||
|
@ -48,7 +48,7 @@ func TestIamUser(t *testing.T) {
|
|||
{
|
||||
test: "iam multiples users",
|
||||
dirName: "aws_iam_user_multiple",
|
||||
mocks: func(repo *repository2.MockIAMRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repo *repository.MockIAMRepository, alerter *mocks.AlerterInterface) {
|
||||
repo.On("ListAllUsers").Return([]*iam.User{
|
||||
{
|
||||
UserName: aws.String("test-driftctl-0"),
|
||||
|
@ -66,7 +66,7 @@ func TestIamUser(t *testing.T) {
|
|||
{
|
||||
test: "cannot list iam user",
|
||||
dirName: "aws_iam_user_empty",
|
||||
mocks: func(repo *repository2.MockIAMRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repo *repository.MockIAMRepository, alerter *mocks.AlerterInterface) {
|
||||
awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "")
|
||||
repo.On("ListAllUsers").Return(nil, awsError)
|
||||
|
||||
|
@ -94,10 +94,10 @@ func TestIamUser(t *testing.T) {
|
|||
|
||||
// Initialize mocks
|
||||
alerter := &mocks.AlerterInterface{}
|
||||
fakeRepo := &repository2.MockIAMRepository{}
|
||||
fakeRepo := &repository.MockIAMRepository{}
|
||||
c.mocks(fakeRepo, alerter)
|
||||
|
||||
var repo repository2.IAMRepository = fakeRepo
|
||||
var repo repository.IAMRepository = fakeRepo
|
||||
providerVersion := "3.19.0"
|
||||
realProvider, err := terraform2.InitTestAwsProvider(providerLibrary, providerVersion)
|
||||
if err != nil {
|
||||
|
@ -113,7 +113,7 @@ func TestIamUser(t *testing.T) {
|
|||
t.Fatal(err)
|
||||
}
|
||||
provider.ShouldUpdate()
|
||||
repo = repository2.NewIAMRepository(sess, cache.New(0))
|
||||
repo = repository.NewIAMRepository(sess, cache.New(0))
|
||||
}
|
||||
|
||||
remoteLibrary.AddEnumerator(aws2.NewIamUserEnumerator(repo, factory))
|
||||
|
@ -140,13 +140,13 @@ func TestIamUserPolicy(t *testing.T) {
|
|||
cases := []struct {
|
||||
test string
|
||||
dirName string
|
||||
mocks func(*repository2.MockIAMRepository, *mocks.AlerterInterface)
|
||||
mocks func(*repository.MockIAMRepository, *mocks.AlerterInterface)
|
||||
wantErr error
|
||||
}{
|
||||
{
|
||||
test: "no iam user policy",
|
||||
dirName: "aws_iam_user_policy_empty",
|
||||
mocks: func(repo *repository2.MockIAMRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repo *repository.MockIAMRepository, alerter *mocks.AlerterInterface) {
|
||||
users := []*iam.User{
|
||||
{
|
||||
UserName: aws.String("loadbalancer"),
|
||||
|
@ -160,7 +160,7 @@ func TestIamUserPolicy(t *testing.T) {
|
|||
{
|
||||
test: "iam multiples users multiple policies",
|
||||
dirName: "aws_iam_user_policy_multiple",
|
||||
mocks: func(repo *repository2.MockIAMRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repo *repository.MockIAMRepository, alerter *mocks.AlerterInterface) {
|
||||
users := []*iam.User{
|
||||
{
|
||||
UserName: aws.String("loadbalancer"),
|
||||
|
@ -193,7 +193,7 @@ func TestIamUserPolicy(t *testing.T) {
|
|||
{
|
||||
test: "cannot list user",
|
||||
dirName: "aws_iam_user_policy_empty",
|
||||
mocks: func(repo *repository2.MockIAMRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repo *repository.MockIAMRepository, alerter *mocks.AlerterInterface) {
|
||||
awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "")
|
||||
repo.On("ListAllUsers").Return(nil, awsError)
|
||||
|
||||
|
@ -204,7 +204,7 @@ func TestIamUserPolicy(t *testing.T) {
|
|||
{
|
||||
test: "cannot list user policy",
|
||||
dirName: "aws_iam_user_policy_empty",
|
||||
mocks: func(repo *repository2.MockIAMRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repo *repository.MockIAMRepository, alerter *mocks.AlerterInterface) {
|
||||
repo.On("ListAllUsers").Once().Return([]*iam.User{}, nil)
|
||||
awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "")
|
||||
repo.On("ListAllUserPolicies", mock.Anything).Return(nil, awsError)
|
||||
|
@ -233,10 +233,10 @@ func TestIamUserPolicy(t *testing.T) {
|
|||
|
||||
// Initialize mocks
|
||||
alerter := &mocks.AlerterInterface{}
|
||||
fakeRepo := &repository2.MockIAMRepository{}
|
||||
fakeRepo := &repository.MockIAMRepository{}
|
||||
c.mocks(fakeRepo, alerter)
|
||||
|
||||
var repo repository2.IAMRepository = fakeRepo
|
||||
var repo repository.IAMRepository = fakeRepo
|
||||
providerVersion := "3.19.0"
|
||||
realProvider, err := terraform2.InitTestAwsProvider(providerLibrary, providerVersion)
|
||||
if err != nil {
|
||||
|
@ -252,7 +252,7 @@ func TestIamUserPolicy(t *testing.T) {
|
|||
t.Fatal(err)
|
||||
}
|
||||
provider.ShouldUpdate()
|
||||
repo = repository2.NewIAMRepository(sess, cache.New(0))
|
||||
repo = repository.NewIAMRepository(sess, cache.New(0))
|
||||
}
|
||||
|
||||
remoteLibrary.AddEnumerator(aws2.NewIamUserPolicyEnumerator(repo, factory))
|
||||
|
@ -279,13 +279,13 @@ func TestIamPolicy(t *testing.T) {
|
|||
cases := []struct {
|
||||
test string
|
||||
dirName string
|
||||
mocks func(*repository2.MockIAMRepository, *mocks.AlerterInterface)
|
||||
mocks func(*repository.MockIAMRepository, *mocks.AlerterInterface)
|
||||
wantErr error
|
||||
}{
|
||||
{
|
||||
test: "no iam custom policies",
|
||||
dirName: "aws_iam_policy_empty",
|
||||
mocks: func(repo *repository2.MockIAMRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repo *repository.MockIAMRepository, alerter *mocks.AlerterInterface) {
|
||||
repo.On("ListAllPolicies").Once().Return([]*iam.Policy{}, nil)
|
||||
},
|
||||
wantErr: nil,
|
||||
|
@ -293,7 +293,7 @@ func TestIamPolicy(t *testing.T) {
|
|||
{
|
||||
test: "iam multiples custom policies",
|
||||
dirName: "aws_iam_policy_multiple",
|
||||
mocks: func(repo *repository2.MockIAMRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repo *repository.MockIAMRepository, alerter *mocks.AlerterInterface) {
|
||||
repo.On("ListAllPolicies").Once().Return([]*iam.Policy{
|
||||
{
|
||||
Arn: aws.String("arn:aws:iam::929327065333:policy/policy-0"),
|
||||
|
@ -311,7 +311,7 @@ func TestIamPolicy(t *testing.T) {
|
|||
{
|
||||
test: "cannot list iam custom policies",
|
||||
dirName: "aws_iam_policy_empty",
|
||||
mocks: func(repo *repository2.MockIAMRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repo *repository.MockIAMRepository, alerter *mocks.AlerterInterface) {
|
||||
awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "")
|
||||
repo.On("ListAllPolicies").Once().Return(nil, awsError)
|
||||
|
||||
|
@ -340,10 +340,10 @@ func TestIamPolicy(t *testing.T) {
|
|||
|
||||
// Initialize mocks
|
||||
alerter := &mocks.AlerterInterface{}
|
||||
fakeRepo := &repository2.MockIAMRepository{}
|
||||
fakeRepo := &repository.MockIAMRepository{}
|
||||
c.mocks(fakeRepo, alerter)
|
||||
|
||||
var repo repository2.IAMRepository = fakeRepo
|
||||
var repo repository.IAMRepository = fakeRepo
|
||||
providerVersion := "3.19.0"
|
||||
realProvider, err := terraform2.InitTestAwsProvider(providerLibrary, providerVersion)
|
||||
if err != nil {
|
||||
|
@ -359,7 +359,7 @@ func TestIamPolicy(t *testing.T) {
|
|||
t.Fatal(err)
|
||||
}
|
||||
provider.ShouldUpdate()
|
||||
repo = repository2.NewIAMRepository(sess, cache.New(0))
|
||||
repo = repository.NewIAMRepository(sess, cache.New(0))
|
||||
}
|
||||
|
||||
remoteLibrary.AddEnumerator(aws2.NewIamPolicyEnumerator(repo, factory))
|
||||
|
@ -386,13 +386,13 @@ func TestIamRole(t *testing.T) {
|
|||
cases := []struct {
|
||||
test string
|
||||
dirName string
|
||||
mocks func(*repository2.MockIAMRepository, *mocks.AlerterInterface)
|
||||
mocks func(*repository.MockIAMRepository, *mocks.AlerterInterface)
|
||||
wantErr error
|
||||
}{
|
||||
{
|
||||
test: "no iam roles",
|
||||
dirName: "aws_iam_role_empty",
|
||||
mocks: func(repo *repository2.MockIAMRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repo *repository.MockIAMRepository, alerter *mocks.AlerterInterface) {
|
||||
repo.On("ListAllRoles").Return([]*iam.Role{}, nil)
|
||||
},
|
||||
wantErr: nil,
|
||||
|
@ -400,7 +400,7 @@ func TestIamRole(t *testing.T) {
|
|||
{
|
||||
test: "iam multiples roles",
|
||||
dirName: "aws_iam_role_multiple",
|
||||
mocks: func(repo *repository2.MockIAMRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repo *repository.MockIAMRepository, alerter *mocks.AlerterInterface) {
|
||||
repo.On("ListAllRoles").Return([]*iam.Role{
|
||||
{
|
||||
RoleName: aws.String("test_role_0"),
|
||||
|
@ -421,7 +421,7 @@ func TestIamRole(t *testing.T) {
|
|||
{
|
||||
test: "iam roles ignore services roles",
|
||||
dirName: "aws_iam_role_ignore_services_roles",
|
||||
mocks: func(repo *repository2.MockIAMRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repo *repository.MockIAMRepository, alerter *mocks.AlerterInterface) {
|
||||
repo.On("ListAllRoles").Return([]*iam.Role{
|
||||
{
|
||||
RoleName: aws.String("AWSServiceRoleForOrganizations"),
|
||||
|
@ -460,10 +460,10 @@ func TestIamRole(t *testing.T) {
|
|||
|
||||
// Initialize mocks
|
||||
alerter := &mocks.AlerterInterface{}
|
||||
fakeRepo := &repository2.MockIAMRepository{}
|
||||
fakeRepo := &repository.MockIAMRepository{}
|
||||
c.mocks(fakeRepo, alerter)
|
||||
|
||||
var repo repository2.IAMRepository = fakeRepo
|
||||
var repo repository.IAMRepository = fakeRepo
|
||||
providerVersion := "3.19.0"
|
||||
realProvider, err := terraform2.InitTestAwsProvider(providerLibrary, providerVersion)
|
||||
if err != nil {
|
||||
|
@ -479,7 +479,7 @@ func TestIamRole(t *testing.T) {
|
|||
t.Fatal(err)
|
||||
}
|
||||
provider.ShouldUpdate()
|
||||
repo = repository2.NewIAMRepository(sess, cache.New(0))
|
||||
repo = repository.NewIAMRepository(sess, cache.New(0))
|
||||
}
|
||||
|
||||
remoteLibrary.AddEnumerator(aws2.NewIamRoleEnumerator(repo, factory))
|
||||
|
@ -506,27 +506,27 @@ func TestIamRolePolicyAttachment(t *testing.T) {
|
|||
cases := []struct {
|
||||
test string
|
||||
dirName string
|
||||
mocks func(*repository2.MockIAMRepository, *mocks.AlerterInterface)
|
||||
mocks func(*repository.MockIAMRepository, *mocks.AlerterInterface)
|
||||
err error
|
||||
}{
|
||||
{
|
||||
test: "no iam role policy",
|
||||
dirName: "aws_aws_iam_role_policy_empty",
|
||||
mocks: func(repo *repository2.MockIAMRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repo *repository.MockIAMRepository, alerter *mocks.AlerterInterface) {
|
||||
roles := []*iam.Role{
|
||||
{
|
||||
RoleName: aws.String("test-role"),
|
||||
},
|
||||
}
|
||||
repo.On("ListAllRoles").Return(roles, nil)
|
||||
repo.On("ListAllRolePolicyAttachments", roles).Return([]*repository2.AttachedRolePolicy{}, nil)
|
||||
repo.On("ListAllRolePolicyAttachments", roles).Return([]*repository.AttachedRolePolicy{}, nil)
|
||||
},
|
||||
err: nil,
|
||||
},
|
||||
{
|
||||
test: "iam multiples roles multiple policies",
|
||||
dirName: "aws_iam_role_policy_attachment_multiple",
|
||||
mocks: func(repo *repository2.MockIAMRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repo *repository.MockIAMRepository, alerter *mocks.AlerterInterface) {
|
||||
roles := []*iam.Role{
|
||||
{
|
||||
RoleName: aws.String("test-role"),
|
||||
|
@ -536,7 +536,7 @@ func TestIamRolePolicyAttachment(t *testing.T) {
|
|||
},
|
||||
}
|
||||
repo.On("ListAllRoles").Return(roles, nil)
|
||||
repo.On("ListAllRolePolicyAttachments", roles).Return([]*repository2.AttachedRolePolicy{
|
||||
repo.On("ListAllRolePolicyAttachments", roles).Return([]*repository.AttachedRolePolicy{
|
||||
{
|
||||
AttachedPolicy: iam.AttachedPolicy{
|
||||
PolicyArn: aws.String("arn:aws:iam::929327065333:policy/test-policy"),
|
||||
|
@ -586,7 +586,7 @@ func TestIamRolePolicyAttachment(t *testing.T) {
|
|||
{
|
||||
test: "iam multiples roles for ignored roles",
|
||||
dirName: "aws_iam_role_policy_attachment_empty",
|
||||
mocks: func(repo *repository2.MockIAMRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repo *repository.MockIAMRepository, alerter *mocks.AlerterInterface) {
|
||||
roles := []*iam.Role{
|
||||
{
|
||||
RoleName: aws.String("AWSServiceRoleForSupport"),
|
||||
|
@ -604,7 +604,7 @@ func TestIamRolePolicyAttachment(t *testing.T) {
|
|||
{
|
||||
test: "Cannot list roles",
|
||||
dirName: "aws_iam_role_policy_attachment_empty",
|
||||
mocks: func(repo *repository2.MockIAMRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repo *repository.MockIAMRepository, alerter *mocks.AlerterInterface) {
|
||||
awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "")
|
||||
repo.On("ListAllRoles").Once().Return(nil, awsError)
|
||||
|
||||
|
@ -614,7 +614,7 @@ func TestIamRolePolicyAttachment(t *testing.T) {
|
|||
{
|
||||
test: "Cannot list roles policy attachment",
|
||||
dirName: "aws_iam_role_policy_attachment_empty",
|
||||
mocks: func(repo *repository2.MockIAMRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repo *repository.MockIAMRepository, alerter *mocks.AlerterInterface) {
|
||||
repo.On("ListAllRoles").Once().Return([]*iam.Role{{RoleName: aws.String("test")}}, nil)
|
||||
awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "")
|
||||
repo.On("ListAllRolePolicyAttachments", mock.Anything).Return(nil, awsError)
|
||||
|
@ -643,10 +643,10 @@ func TestIamRolePolicyAttachment(t *testing.T) {
|
|||
|
||||
// Initialize mocks
|
||||
alerter := &mocks.AlerterInterface{}
|
||||
fakeRepo := &repository2.MockIAMRepository{}
|
||||
fakeRepo := &repository.MockIAMRepository{}
|
||||
c.mocks(fakeRepo, alerter)
|
||||
|
||||
var repo repository2.IAMRepository = fakeRepo
|
||||
var repo repository.IAMRepository = fakeRepo
|
||||
providerVersion := "3.19.0"
|
||||
realProvider, err := terraform2.InitTestAwsProvider(providerLibrary, providerVersion)
|
||||
if err != nil {
|
||||
|
@ -662,7 +662,7 @@ func TestIamRolePolicyAttachment(t *testing.T) {
|
|||
t.Fatal(err)
|
||||
}
|
||||
provider.ShouldUpdate()
|
||||
repo = repository2.NewIAMRepository(sess, cache.New(0))
|
||||
repo = repository.NewIAMRepository(sess, cache.New(0))
|
||||
}
|
||||
|
||||
remoteLibrary.AddEnumerator(aws2.NewIamRolePolicyAttachmentEnumerator(repo, factory))
|
||||
|
@ -689,13 +689,13 @@ func TestIamAccessKey(t *testing.T) {
|
|||
cases := []struct {
|
||||
test string
|
||||
dirName string
|
||||
mocks func(*repository2.MockIAMRepository, *mocks.AlerterInterface)
|
||||
mocks func(*repository.MockIAMRepository, *mocks.AlerterInterface)
|
||||
wantErr error
|
||||
}{
|
||||
{
|
||||
test: "no iam access_key",
|
||||
dirName: "aws_iam_access_key_empty",
|
||||
mocks: func(repo *repository2.MockIAMRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repo *repository.MockIAMRepository, alerter *mocks.AlerterInterface) {
|
||||
users := []*iam.User{
|
||||
{
|
||||
UserName: aws.String("test-driftctl"),
|
||||
|
@ -709,7 +709,7 @@ func TestIamAccessKey(t *testing.T) {
|
|||
{
|
||||
test: "iam multiples keys for multiples users",
|
||||
dirName: "aws_iam_access_key_multiple",
|
||||
mocks: func(repo *repository2.MockIAMRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repo *repository.MockIAMRepository, alerter *mocks.AlerterInterface) {
|
||||
users := []*iam.User{
|
||||
{
|
||||
UserName: aws.String("test-driftctl"),
|
||||
|
@ -740,7 +740,7 @@ func TestIamAccessKey(t *testing.T) {
|
|||
{
|
||||
test: "Cannot list iam user",
|
||||
dirName: "aws_iam_access_key_empty",
|
||||
mocks: func(repo *repository2.MockIAMRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repo *repository.MockIAMRepository, alerter *mocks.AlerterInterface) {
|
||||
awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "")
|
||||
repo.On("ListAllUsers").Once().Return(nil, awsError)
|
||||
|
||||
|
@ -751,7 +751,7 @@ func TestIamAccessKey(t *testing.T) {
|
|||
{
|
||||
test: "Cannot list iam access_key",
|
||||
dirName: "aws_iam_access_key_empty",
|
||||
mocks: func(repo *repository2.MockIAMRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repo *repository.MockIAMRepository, alerter *mocks.AlerterInterface) {
|
||||
repo.On("ListAllUsers").Once().Return([]*iam.User{}, nil)
|
||||
awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "")
|
||||
repo.On("ListAllAccessKeys", mock.Anything).Return(nil, awsError)
|
||||
|
@ -781,10 +781,10 @@ func TestIamAccessKey(t *testing.T) {
|
|||
|
||||
// Initialize mocks
|
||||
alerter := &mocks.AlerterInterface{}
|
||||
fakeRepo := &repository2.MockIAMRepository{}
|
||||
fakeRepo := &repository.MockIAMRepository{}
|
||||
c.mocks(fakeRepo, alerter)
|
||||
|
||||
var repo repository2.IAMRepository = fakeRepo
|
||||
var repo repository.IAMRepository = fakeRepo
|
||||
providerVersion := "3.19.0"
|
||||
realProvider, err := terraform2.InitTestAwsProvider(providerLibrary, providerVersion)
|
||||
if err != nil {
|
||||
|
@ -800,7 +800,7 @@ func TestIamAccessKey(t *testing.T) {
|
|||
t.Fatal(err)
|
||||
}
|
||||
provider.ShouldUpdate()
|
||||
repo = repository2.NewIAMRepository(sess, cache.New(0))
|
||||
repo = repository.NewIAMRepository(sess, cache.New(0))
|
||||
}
|
||||
|
||||
remoteLibrary.AddEnumerator(aws2.NewIamAccessKeyEnumerator(repo, factory))
|
||||
|
@ -827,27 +827,27 @@ func TestIamUserPolicyAttachment(t *testing.T) {
|
|||
cases := []struct {
|
||||
test string
|
||||
dirName string
|
||||
mocks func(*repository2.MockIAMRepository, *mocks.AlerterInterface)
|
||||
mocks func(*repository.MockIAMRepository, *mocks.AlerterInterface)
|
||||
wantErr error
|
||||
}{
|
||||
{
|
||||
test: "no iam user policy",
|
||||
dirName: "aws_iam_user_policy_empty",
|
||||
mocks: func(repo *repository2.MockIAMRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repo *repository.MockIAMRepository, alerter *mocks.AlerterInterface) {
|
||||
users := []*iam.User{
|
||||
{
|
||||
UserName: aws.String("loadbalancer"),
|
||||
},
|
||||
}
|
||||
repo.On("ListAllUsers").Return(users, nil)
|
||||
repo.On("ListAllUserPolicyAttachments", users).Return([]*repository2.AttachedUserPolicy{}, nil)
|
||||
repo.On("ListAllUserPolicyAttachments", users).Return([]*repository.AttachedUserPolicy{}, nil)
|
||||
},
|
||||
wantErr: nil,
|
||||
},
|
||||
{
|
||||
test: "iam multiples users multiple policies",
|
||||
dirName: "aws_iam_user_policy_attachment_multiple",
|
||||
mocks: func(repo *repository2.MockIAMRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repo *repository.MockIAMRepository, alerter *mocks.AlerterInterface) {
|
||||
users := []*iam.User{
|
||||
{
|
||||
UserName: aws.String("loadbalancer"),
|
||||
|
@ -860,7 +860,7 @@ func TestIamUserPolicyAttachment(t *testing.T) {
|
|||
},
|
||||
}
|
||||
repo.On("ListAllUsers").Return(users, nil)
|
||||
repo.On("ListAllUserPolicyAttachments", users).Return([]*repository2.AttachedUserPolicy{
|
||||
repo.On("ListAllUserPolicyAttachments", users).Return([]*repository.AttachedUserPolicy{
|
||||
{
|
||||
AttachedPolicy: iam.AttachedPolicy{
|
||||
PolicyArn: aws.String("arn:aws:iam::726421854799:policy/test"),
|
||||
|
@ -953,7 +953,7 @@ func TestIamUserPolicyAttachment(t *testing.T) {
|
|||
{
|
||||
test: "cannot list user",
|
||||
dirName: "aws_iam_user_policy_empty",
|
||||
mocks: func(repo *repository2.MockIAMRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repo *repository.MockIAMRepository, alerter *mocks.AlerterInterface) {
|
||||
awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "")
|
||||
repo.On("ListAllUsers").Return(nil, awsError)
|
||||
|
||||
|
@ -964,7 +964,7 @@ func TestIamUserPolicyAttachment(t *testing.T) {
|
|||
{
|
||||
test: "cannot list user policies attachment",
|
||||
dirName: "aws_iam_user_policy_empty",
|
||||
mocks: func(repo *repository2.MockIAMRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repo *repository.MockIAMRepository, alerter *mocks.AlerterInterface) {
|
||||
repo.On("ListAllUsers").Once().Return([]*iam.User{}, nil)
|
||||
awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "")
|
||||
repo.On("ListAllUserPolicyAttachments", mock.Anything).Return(nil, awsError)
|
||||
|
@ -994,10 +994,10 @@ func TestIamUserPolicyAttachment(t *testing.T) {
|
|||
|
||||
// Initialize mocks
|
||||
alerter := &mocks.AlerterInterface{}
|
||||
fakeRepo := &repository2.MockIAMRepository{}
|
||||
fakeRepo := &repository.MockIAMRepository{}
|
||||
c.mocks(fakeRepo, alerter)
|
||||
|
||||
var repo repository2.IAMRepository = fakeRepo
|
||||
var repo repository.IAMRepository = fakeRepo
|
||||
providerVersion := "3.19.0"
|
||||
realProvider, err := terraform2.InitTestAwsProvider(providerLibrary, providerVersion)
|
||||
if err != nil {
|
||||
|
@ -1013,7 +1013,7 @@ func TestIamUserPolicyAttachment(t *testing.T) {
|
|||
t.Fatal(err)
|
||||
}
|
||||
provider.ShouldUpdate()
|
||||
repo = repository2.NewIAMRepository(sess, cache.New(0))
|
||||
repo = repository.NewIAMRepository(sess, cache.New(0))
|
||||
}
|
||||
|
||||
remoteLibrary.AddEnumerator(aws2.NewIamUserPolicyAttachmentEnumerator(repo, factory))
|
||||
|
@ -1040,27 +1040,27 @@ func TestIamRolePolicy(t *testing.T) {
|
|||
cases := []struct {
|
||||
test string
|
||||
dirName string
|
||||
mocks func(*repository2.MockIAMRepository, *mocks.AlerterInterface)
|
||||
mocks func(*repository.MockIAMRepository, *mocks.AlerterInterface)
|
||||
wantErr error
|
||||
}{
|
||||
{
|
||||
test: "no iam role policy",
|
||||
dirName: "aws_iam_role_policy_empty",
|
||||
mocks: func(repo *repository2.MockIAMRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repo *repository.MockIAMRepository, alerter *mocks.AlerterInterface) {
|
||||
roles := []*iam.Role{
|
||||
{
|
||||
RoleName: aws.String("test_role"),
|
||||
},
|
||||
}
|
||||
repo.On("ListAllRoles").Return(roles, nil)
|
||||
repo.On("ListAllRolePolicies", roles).Return([]repository2.RolePolicy{}, nil)
|
||||
repo.On("ListAllRolePolicies", roles).Return([]repository.RolePolicy{}, nil)
|
||||
},
|
||||
wantErr: nil,
|
||||
},
|
||||
{
|
||||
test: "multiples roles with inline policies",
|
||||
dirName: "aws_iam_role_policy_multiple",
|
||||
mocks: func(repo *repository2.MockIAMRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repo *repository.MockIAMRepository, alerter *mocks.AlerterInterface) {
|
||||
roles := []*iam.Role{
|
||||
{
|
||||
RoleName: aws.String("test_role_0"),
|
||||
|
@ -1070,7 +1070,7 @@ func TestIamRolePolicy(t *testing.T) {
|
|||
},
|
||||
}
|
||||
repo.On("ListAllRoles").Return(roles, nil)
|
||||
repo.On("ListAllRolePolicies", roles).Return([]repository2.RolePolicy{
|
||||
repo.On("ListAllRolePolicies", roles).Return([]repository.RolePolicy{
|
||||
{Policy: "policy-role0-0", RoleName: "test_role_0"},
|
||||
{Policy: "policy-role0-1", RoleName: "test_role_0"},
|
||||
{Policy: "policy-role0-2", RoleName: "test_role_0"},
|
||||
|
@ -1084,7 +1084,7 @@ func TestIamRolePolicy(t *testing.T) {
|
|||
{
|
||||
test: "Cannot list roles",
|
||||
dirName: "aws_iam_role_policy_empty",
|
||||
mocks: func(repo *repository2.MockIAMRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repo *repository.MockIAMRepository, alerter *mocks.AlerterInterface) {
|
||||
awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "")
|
||||
repo.On("ListAllRoles").Once().Return(nil, awsError)
|
||||
|
||||
|
@ -1095,7 +1095,7 @@ func TestIamRolePolicy(t *testing.T) {
|
|||
{
|
||||
test: "cannot list role policy",
|
||||
dirName: "aws_iam_role_policy_empty",
|
||||
mocks: func(repo *repository2.MockIAMRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repo *repository.MockIAMRepository, alerter *mocks.AlerterInterface) {
|
||||
repo.On("ListAllRoles").Once().Return([]*iam.Role{}, nil)
|
||||
awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "")
|
||||
repo.On("ListAllRolePolicies", mock.Anything).Return(nil, awsError)
|
||||
|
@ -1125,10 +1125,10 @@ func TestIamRolePolicy(t *testing.T) {
|
|||
|
||||
// Initialize mocks
|
||||
alerter := &mocks.AlerterInterface{}
|
||||
fakeRepo := &repository2.MockIAMRepository{}
|
||||
fakeRepo := &repository.MockIAMRepository{}
|
||||
c.mocks(fakeRepo, alerter)
|
||||
|
||||
var repo repository2.IAMRepository = fakeRepo
|
||||
var repo repository.IAMRepository = fakeRepo
|
||||
providerVersion := "3.19.0"
|
||||
realProvider, err := terraform2.InitTestAwsProvider(providerLibrary, providerVersion)
|
||||
if err != nil {
|
||||
|
@ -1144,7 +1144,7 @@ func TestIamRolePolicy(t *testing.T) {
|
|||
t.Fatal(err)
|
||||
}
|
||||
provider.ShouldUpdate()
|
||||
repo = repository2.NewIAMRepository(sess, cache.New(0))
|
||||
repo = repository.NewIAMRepository(sess, cache.New(0))
|
||||
}
|
||||
|
||||
remoteLibrary.AddEnumerator(aws2.NewIamRolePolicyEnumerator(repo, factory))
|
||||
|
@ -1171,13 +1171,13 @@ func TestIamGroupPolicy(t *testing.T) {
|
|||
|
||||
tests := []struct {
|
||||
test string
|
||||
mocks func(*repository2.MockIAMRepository)
|
||||
mocks func(*repository.MockIAMRepository)
|
||||
assertExpected func(t *testing.T, got []*resource.Resource)
|
||||
wantErr error
|
||||
}{
|
||||
{
|
||||
test: "multiple groups, with multiples policies",
|
||||
mocks: func(repository *repository2.MockIAMRepository) {
|
||||
mocks: func(repository *repository.MockIAMRepository) {
|
||||
repository.On("ListAllGroups").Return(nil, nil)
|
||||
repository.On("ListAllGroupPolicies", []*iam.Group(nil)).
|
||||
Return([]string{"group1:policy1", "group2:policy2"}, nil)
|
||||
|
@ -1192,14 +1192,14 @@ func TestIamGroupPolicy(t *testing.T) {
|
|||
},
|
||||
{
|
||||
test: "cannot list groups",
|
||||
mocks: func(repository *repository2.MockIAMRepository) {
|
||||
mocks: func(repository *repository.MockIAMRepository) {
|
||||
repository.On("ListAllGroups").Return(nil, dummyError)
|
||||
},
|
||||
wantErr: remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsIamGroupPolicyResourceType, resourceaws.AwsIamGroupResourceType),
|
||||
},
|
||||
{
|
||||
test: "cannot list policies",
|
||||
mocks: func(repository *repository2.MockIAMRepository) {
|
||||
mocks: func(repository *repository.MockIAMRepository) {
|
||||
repository.On("ListAllGroups").Return(nil, nil)
|
||||
repository.On("ListAllGroupPolicies", []*iam.Group(nil)).Return(nil, dummyError)
|
||||
},
|
||||
|
@ -1219,10 +1219,10 @@ func TestIamGroupPolicy(t *testing.T) {
|
|||
|
||||
// Initialize mocks
|
||||
alerter := &mocks.AlerterInterface{}
|
||||
fakeRepo := &repository2.MockIAMRepository{}
|
||||
fakeRepo := &repository.MockIAMRepository{}
|
||||
c.mocks(fakeRepo)
|
||||
|
||||
var repo repository2.IAMRepository = fakeRepo
|
||||
var repo repository.IAMRepository = fakeRepo
|
||||
|
||||
remoteLibrary.AddEnumerator(aws2.NewIamGroupPolicyEnumerator(
|
||||
repo, factory,
|
||||
|
@ -1251,13 +1251,13 @@ func TestIamGroup(t *testing.T) {
|
|||
|
||||
tests := []struct {
|
||||
test string
|
||||
mocks func(*repository2.MockIAMRepository)
|
||||
mocks func(*repository.MockIAMRepository)
|
||||
assertExpected func(t *testing.T, got []*resource.Resource)
|
||||
wantErr error
|
||||
}{
|
||||
{
|
||||
test: "multiple groups, with multiples groups",
|
||||
mocks: func(repository *repository2.MockIAMRepository) {
|
||||
mocks: func(repository *repository.MockIAMRepository) {
|
||||
repository.On("ListAllGroups").Return([]*iam.Group{
|
||||
{
|
||||
GroupName: aws.String("group1"),
|
||||
|
@ -1277,7 +1277,7 @@ func TestIamGroup(t *testing.T) {
|
|||
},
|
||||
{
|
||||
test: "cannot list groups",
|
||||
mocks: func(repository *repository2.MockIAMRepository) {
|
||||
mocks: func(repository *repository.MockIAMRepository) {
|
||||
repository.On("ListAllGroups").Return(nil, dummyError)
|
||||
},
|
||||
wantErr: remoteerr.NewResourceListingError(dummyError, resourceaws.AwsIamGroupResourceType),
|
||||
|
@ -1296,10 +1296,10 @@ func TestIamGroup(t *testing.T) {
|
|||
|
||||
// Initialize mocks
|
||||
alerter := &mocks.AlerterInterface{}
|
||||
fakeRepo := &repository2.MockIAMRepository{}
|
||||
fakeRepo := &repository.MockIAMRepository{}
|
||||
c.mocks(fakeRepo)
|
||||
|
||||
var repo repository2.IAMRepository = fakeRepo
|
||||
var repo repository.IAMRepository = fakeRepo
|
||||
|
||||
remoteLibrary.AddEnumerator(aws2.NewIamGroupEnumerator(
|
||||
repo, factory,
|
||||
|
|
|
@ -6,7 +6,7 @@ import (
|
|||
"github.com/snyk/driftctl/enumeration"
|
||||
"github.com/snyk/driftctl/enumeration/remote/alerts"
|
||||
aws2 "github.com/snyk/driftctl/enumeration/remote/aws"
|
||||
repository2 "github.com/snyk/driftctl/enumeration/remote/aws/repository"
|
||||
"github.com/snyk/driftctl/enumeration/remote/aws/repository"
|
||||
"github.com/snyk/driftctl/enumeration/remote/cache"
|
||||
common2 "github.com/snyk/driftctl/enumeration/remote/common"
|
||||
remoteerr "github.com/snyk/driftctl/enumeration/remote/error"
|
||||
|
@ -33,20 +33,20 @@ func TestKMSKey(t *testing.T) {
|
|||
tests := []struct {
|
||||
test string
|
||||
dirName string
|
||||
mocks func(*repository2.MockKMSRepository, *mocks.AlerterInterface)
|
||||
mocks func(*repository.MockKMSRepository, *mocks.AlerterInterface)
|
||||
wantErr error
|
||||
}{
|
||||
{
|
||||
test: "no keys",
|
||||
dirName: "aws_kms_key_empty",
|
||||
mocks: func(repository *repository2.MockKMSRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockKMSRepository, alerter *mocks.AlerterInterface) {
|
||||
repository.On("ListAllKeys").Return([]*kms.KeyListEntry{}, nil)
|
||||
},
|
||||
},
|
||||
{
|
||||
test: "multiple keys",
|
||||
dirName: "aws_kms_key_multiple",
|
||||
mocks: func(repository *repository2.MockKMSRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockKMSRepository, alerter *mocks.AlerterInterface) {
|
||||
repository.On("ListAllKeys").Return([]*kms.KeyListEntry{
|
||||
{KeyId: awssdk.String("8ee21d91-c000-428c-8032-235aac55da36")},
|
||||
{KeyId: awssdk.String("5d765f32-bfdc-4610-b6ab-f82db5d0601b")},
|
||||
|
@ -57,7 +57,7 @@ func TestKMSKey(t *testing.T) {
|
|||
{
|
||||
test: "cannot list keys",
|
||||
dirName: "aws_kms_key_list",
|
||||
mocks: func(repository *repository2.MockKMSRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockKMSRepository, alerter *mocks.AlerterInterface) {
|
||||
awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "")
|
||||
repository.On("ListAllKeys").Return(nil, awsError)
|
||||
|
||||
|
@ -86,10 +86,10 @@ func TestKMSKey(t *testing.T) {
|
|||
|
||||
// Initialize mocks
|
||||
alerter := &mocks.AlerterInterface{}
|
||||
fakeRepo := &repository2.MockKMSRepository{}
|
||||
fakeRepo := &repository.MockKMSRepository{}
|
||||
c.mocks(fakeRepo, alerter)
|
||||
|
||||
var repo repository2.KMSRepository = fakeRepo
|
||||
var repo repository.KMSRepository = fakeRepo
|
||||
providerVersion := "3.19.0"
|
||||
realProvider, err := terraform2.InitTestAwsProvider(providerLibrary, providerVersion)
|
||||
if err != nil {
|
||||
|
@ -105,7 +105,7 @@ func TestKMSKey(t *testing.T) {
|
|||
t.Fatal(err)
|
||||
}
|
||||
provider.ShouldUpdate()
|
||||
repo = repository2.NewKMSRepository(sess, cache.New(0))
|
||||
repo = repository.NewKMSRepository(sess, cache.New(0))
|
||||
}
|
||||
|
||||
remoteLibrary.AddEnumerator(aws2.NewKMSKeyEnumerator(repo, factory))
|
||||
|
@ -131,20 +131,20 @@ func TestKMSAlias(t *testing.T) {
|
|||
tests := []struct {
|
||||
test string
|
||||
dirName string
|
||||
mocks func(*repository2.MockKMSRepository, *mocks.AlerterInterface)
|
||||
mocks func(*repository.MockKMSRepository, *mocks.AlerterInterface)
|
||||
wantErr error
|
||||
}{
|
||||
{
|
||||
test: "no aliases",
|
||||
dirName: "aws_kms_alias_empty",
|
||||
mocks: func(repository *repository2.MockKMSRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockKMSRepository, alerter *mocks.AlerterInterface) {
|
||||
repository.On("ListAllAliases").Return([]*kms.AliasListEntry{}, nil)
|
||||
},
|
||||
},
|
||||
{
|
||||
test: "multiple aliases",
|
||||
dirName: "aws_kms_alias_multiple",
|
||||
mocks: func(repository *repository2.MockKMSRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockKMSRepository, alerter *mocks.AlerterInterface) {
|
||||
repository.On("ListAllAliases").Return([]*kms.AliasListEntry{
|
||||
{AliasName: awssdk.String("alias/foo")},
|
||||
{AliasName: awssdk.String("alias/bar")},
|
||||
|
@ -155,7 +155,7 @@ func TestKMSAlias(t *testing.T) {
|
|||
{
|
||||
test: "cannot list aliases",
|
||||
dirName: "aws_kms_alias_list",
|
||||
mocks: func(repository *repository2.MockKMSRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockKMSRepository, alerter *mocks.AlerterInterface) {
|
||||
awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "")
|
||||
repository.On("ListAllAliases").Return(nil, awsError)
|
||||
|
||||
|
@ -184,10 +184,10 @@ func TestKMSAlias(t *testing.T) {
|
|||
|
||||
// Initialize mocks
|
||||
alerter := &mocks.AlerterInterface{}
|
||||
fakeRepo := &repository2.MockKMSRepository{}
|
||||
fakeRepo := &repository.MockKMSRepository{}
|
||||
c.mocks(fakeRepo, alerter)
|
||||
|
||||
var repo repository2.KMSRepository = fakeRepo
|
||||
var repo repository.KMSRepository = fakeRepo
|
||||
providerVersion := "3.19.0"
|
||||
realProvider, err := terraform2.InitTestAwsProvider(providerLibrary, providerVersion)
|
||||
if err != nil {
|
||||
|
@ -203,7 +203,7 @@ func TestKMSAlias(t *testing.T) {
|
|||
t.Fatal(err)
|
||||
}
|
||||
provider.ShouldUpdate()
|
||||
repo = repository2.NewKMSRepository(sess, cache.New(0))
|
||||
repo = repository.NewKMSRepository(sess, cache.New(0))
|
||||
}
|
||||
|
||||
remoteLibrary.AddEnumerator(aws2.NewKMSAliasEnumerator(repo, factory))
|
||||
|
|
|
@ -6,7 +6,7 @@ import (
|
|||
"github.com/snyk/driftctl/enumeration"
|
||||
"github.com/snyk/driftctl/enumeration/remote/alerts"
|
||||
aws2 "github.com/snyk/driftctl/enumeration/remote/aws"
|
||||
repository2 "github.com/snyk/driftctl/enumeration/remote/aws/repository"
|
||||
"github.com/snyk/driftctl/enumeration/remote/aws/repository"
|
||||
"github.com/snyk/driftctl/enumeration/remote/cache"
|
||||
common2 "github.com/snyk/driftctl/enumeration/remote/common"
|
||||
remoteerr "github.com/snyk/driftctl/enumeration/remote/error"
|
||||
|
@ -36,13 +36,13 @@ func TestScanLambdaFunction(t *testing.T) {
|
|||
tests := []struct {
|
||||
test string
|
||||
dirName string
|
||||
mocks func(*repository2.MockLambdaRepository, *mocks.AlerterInterface)
|
||||
mocks func(*repository.MockLambdaRepository, *mocks.AlerterInterface)
|
||||
err error
|
||||
}{
|
||||
{
|
||||
test: "no lambda functions",
|
||||
dirName: "aws_lambda_function_empty",
|
||||
mocks: func(repo *repository2.MockLambdaRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repo *repository.MockLambdaRepository, alerter *mocks.AlerterInterface) {
|
||||
repo.On("ListAllLambdaFunctions").Return([]*lambda.FunctionConfiguration{}, nil)
|
||||
},
|
||||
err: nil,
|
||||
|
@ -50,7 +50,7 @@ func TestScanLambdaFunction(t *testing.T) {
|
|||
{
|
||||
test: "with lambda functions",
|
||||
dirName: "aws_lambda_function_multiple",
|
||||
mocks: func(repo *repository2.MockLambdaRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repo *repository.MockLambdaRepository, alerter *mocks.AlerterInterface) {
|
||||
repo.On("ListAllLambdaFunctions").Return([]*lambda.FunctionConfiguration{
|
||||
{
|
||||
FunctionName: awssdk.String("foo"),
|
||||
|
@ -65,7 +65,7 @@ func TestScanLambdaFunction(t *testing.T) {
|
|||
{
|
||||
test: "One lambda with signing",
|
||||
dirName: "aws_lambda_function_signed",
|
||||
mocks: func(repo *repository2.MockLambdaRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repo *repository.MockLambdaRepository, alerter *mocks.AlerterInterface) {
|
||||
repo.On("ListAllLambdaFunctions").Return([]*lambda.FunctionConfiguration{
|
||||
{
|
||||
FunctionName: awssdk.String("foo"),
|
||||
|
@ -77,7 +77,7 @@ func TestScanLambdaFunction(t *testing.T) {
|
|||
{
|
||||
test: "cannot list lambda functions",
|
||||
dirName: "aws_lambda_function_empty",
|
||||
mocks: func(repo *repository2.MockLambdaRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repo *repository.MockLambdaRepository, alerter *mocks.AlerterInterface) {
|
||||
awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "")
|
||||
repo.On("ListAllLambdaFunctions").Return([]*lambda.FunctionConfiguration{}, awsError)
|
||||
|
||||
|
@ -106,10 +106,10 @@ func TestScanLambdaFunction(t *testing.T) {
|
|||
|
||||
// Initialize mocks
|
||||
alerter := &mocks.AlerterInterface{}
|
||||
fakeRepo := &repository2.MockLambdaRepository{}
|
||||
fakeRepo := &repository.MockLambdaRepository{}
|
||||
c.mocks(fakeRepo, alerter)
|
||||
|
||||
var repo repository2.LambdaRepository = fakeRepo
|
||||
var repo repository.LambdaRepository = fakeRepo
|
||||
providerVersion := "3.19.0"
|
||||
realProvider, err := terraform2.InitTestAwsProvider(providerLibrary, providerVersion)
|
||||
if err != nil {
|
||||
|
@ -125,7 +125,7 @@ func TestScanLambdaFunction(t *testing.T) {
|
|||
t.Fatal(err)
|
||||
}
|
||||
provider.ShouldUpdate()
|
||||
repo = repository2.NewLambdaRepository(session, cache.New(0))
|
||||
repo = repository.NewLambdaRepository(session, cache.New(0))
|
||||
}
|
||||
|
||||
remoteLibrary.AddEnumerator(aws2.NewLambdaFunctionEnumerator(repo, factory))
|
||||
|
@ -152,13 +152,13 @@ func TestScanLambdaEventSourceMapping(t *testing.T) {
|
|||
tests := []struct {
|
||||
test string
|
||||
dirName string
|
||||
mocks func(*repository2.MockLambdaRepository, *mocks.AlerterInterface)
|
||||
mocks func(*repository.MockLambdaRepository, *mocks.AlerterInterface)
|
||||
err error
|
||||
}{
|
||||
{
|
||||
test: "no EventSourceMapping",
|
||||
dirName: "aws_lambda_source_mapping_empty",
|
||||
mocks: func(repo *repository2.MockLambdaRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repo *repository.MockLambdaRepository, alerter *mocks.AlerterInterface) {
|
||||
repo.On("ListAllLambdaEventSourceMappings").Return([]*lambda.EventSourceMappingConfiguration{}, nil)
|
||||
},
|
||||
err: nil,
|
||||
|
@ -166,7 +166,7 @@ func TestScanLambdaEventSourceMapping(t *testing.T) {
|
|||
{
|
||||
test: "with 2 sqs EventSourceMapping",
|
||||
dirName: "aws_lambda_source_mapping_sqs_multiple",
|
||||
mocks: func(repo *repository2.MockLambdaRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repo *repository.MockLambdaRepository, alerter *mocks.AlerterInterface) {
|
||||
repo.On("ListAllLambdaEventSourceMappings").Return([]*lambda.EventSourceMappingConfiguration{
|
||||
{
|
||||
UUID: awssdk.String("13ff66f8-37eb-4ad6-a0a8-594fea72df4f"),
|
||||
|
@ -181,7 +181,7 @@ func TestScanLambdaEventSourceMapping(t *testing.T) {
|
|||
{
|
||||
test: "with dynamo EventSourceMapping",
|
||||
dirName: "aws_lambda_source_mapping_dynamo_multiple",
|
||||
mocks: func(repo *repository2.MockLambdaRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repo *repository.MockLambdaRepository, alerter *mocks.AlerterInterface) {
|
||||
repo.On("ListAllLambdaEventSourceMappings").Return([]*lambda.EventSourceMappingConfiguration{
|
||||
{
|
||||
UUID: awssdk.String("1aa9c4a0-060b-41c1-a9ae-dc304ebcdb00"),
|
||||
|
@ -193,7 +193,7 @@ func TestScanLambdaEventSourceMapping(t *testing.T) {
|
|||
{
|
||||
test: "cannot list lambda functions",
|
||||
dirName: "aws_lambda_function_empty",
|
||||
mocks: func(repo *repository2.MockLambdaRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repo *repository.MockLambdaRepository, alerter *mocks.AlerterInterface) {
|
||||
awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "")
|
||||
repo.On("ListAllLambdaEventSourceMappings").Return([]*lambda.EventSourceMappingConfiguration{}, awsError)
|
||||
|
||||
|
@ -222,10 +222,10 @@ func TestScanLambdaEventSourceMapping(t *testing.T) {
|
|||
|
||||
// Initialize mocks
|
||||
alerter := &mocks.AlerterInterface{}
|
||||
fakeRepo := &repository2.MockLambdaRepository{}
|
||||
fakeRepo := &repository.MockLambdaRepository{}
|
||||
c.mocks(fakeRepo, alerter)
|
||||
|
||||
var repo repository2.LambdaRepository = fakeRepo
|
||||
var repo repository.LambdaRepository = fakeRepo
|
||||
providerVersion := "3.19.0"
|
||||
realProvider, err := terraform2.InitTestAwsProvider(providerLibrary, providerVersion)
|
||||
if err != nil {
|
||||
|
@ -241,7 +241,7 @@ func TestScanLambdaEventSourceMapping(t *testing.T) {
|
|||
t.Fatal(err)
|
||||
}
|
||||
provider.ShouldUpdate()
|
||||
repo = repository2.NewLambdaRepository(session, cache.New(0))
|
||||
repo = repository.NewLambdaRepository(session, cache.New(0))
|
||||
}
|
||||
|
||||
remoteLibrary.AddEnumerator(aws2.NewLambdaEventSourceMappingEnumerator(repo, factory))
|
||||
|
|
|
@ -6,7 +6,7 @@ import (
|
|||
"github.com/snyk/driftctl/enumeration"
|
||||
"github.com/snyk/driftctl/enumeration/remote/alerts"
|
||||
aws2 "github.com/snyk/driftctl/enumeration/remote/aws"
|
||||
repository2 "github.com/snyk/driftctl/enumeration/remote/aws/repository"
|
||||
"github.com/snyk/driftctl/enumeration/remote/aws/repository"
|
||||
"github.com/snyk/driftctl/enumeration/remote/cache"
|
||||
common2 "github.com/snyk/driftctl/enumeration/remote/common"
|
||||
remoteerr "github.com/snyk/driftctl/enumeration/remote/error"
|
||||
|
@ -33,20 +33,20 @@ func TestRDSDBInstance(t *testing.T) {
|
|||
tests := []struct {
|
||||
test string
|
||||
dirName string
|
||||
mocks func(*repository2.MockRDSRepository, *mocks.AlerterInterface)
|
||||
mocks func(*repository.MockRDSRepository, *mocks.AlerterInterface)
|
||||
wantErr error
|
||||
}{
|
||||
{
|
||||
test: "no db instances",
|
||||
dirName: "aws_rds_db_instance_empty",
|
||||
mocks: func(repository *repository2.MockRDSRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockRDSRepository, alerter *mocks.AlerterInterface) {
|
||||
repository.On("ListAllDBInstances").Return([]*rds.DBInstance{}, nil)
|
||||
},
|
||||
},
|
||||
{
|
||||
test: "single db instance",
|
||||
dirName: "aws_rds_db_instance_single",
|
||||
mocks: func(repository *repository2.MockRDSRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockRDSRepository, alerter *mocks.AlerterInterface) {
|
||||
repository.On("ListAllDBInstances").Return([]*rds.DBInstance{
|
||||
{DBInstanceIdentifier: awssdk.String("terraform-20201015115018309600000001")},
|
||||
}, nil)
|
||||
|
@ -55,7 +55,7 @@ func TestRDSDBInstance(t *testing.T) {
|
|||
{
|
||||
test: "multiple mixed db instances",
|
||||
dirName: "aws_rds_db_instance_multiple",
|
||||
mocks: func(repository *repository2.MockRDSRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockRDSRepository, alerter *mocks.AlerterInterface) {
|
||||
repository.On("ListAllDBInstances").Return([]*rds.DBInstance{
|
||||
{DBInstanceIdentifier: awssdk.String("terraform-20201015115018309600000001")},
|
||||
{DBInstanceIdentifier: awssdk.String("database-1")},
|
||||
|
@ -65,7 +65,7 @@ func TestRDSDBInstance(t *testing.T) {
|
|||
{
|
||||
test: "cannot list db instances",
|
||||
dirName: "aws_rds_db_instance_list",
|
||||
mocks: func(repository *repository2.MockRDSRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockRDSRepository, alerter *mocks.AlerterInterface) {
|
||||
awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "")
|
||||
repository.On("ListAllDBInstances").Return(nil, awsError)
|
||||
|
||||
|
@ -94,10 +94,10 @@ func TestRDSDBInstance(t *testing.T) {
|
|||
|
||||
// Initialize mocks
|
||||
alerter := &mocks.AlerterInterface{}
|
||||
fakeRepo := &repository2.MockRDSRepository{}
|
||||
fakeRepo := &repository.MockRDSRepository{}
|
||||
c.mocks(fakeRepo, alerter)
|
||||
|
||||
var repo repository2.RDSRepository = fakeRepo
|
||||
var repo repository.RDSRepository = fakeRepo
|
||||
providerVersion := "3.19.0"
|
||||
realProvider, err := terraform2.InitTestAwsProvider(providerLibrary, providerVersion)
|
||||
if err != nil {
|
||||
|
@ -113,7 +113,7 @@ func TestRDSDBInstance(t *testing.T) {
|
|||
t.Fatal(err)
|
||||
}
|
||||
provider.ShouldUpdate()
|
||||
repo = repository2.NewRDSRepository(sess, cache.New(0))
|
||||
repo = repository.NewRDSRepository(sess, cache.New(0))
|
||||
}
|
||||
|
||||
remoteLibrary.AddEnumerator(aws2.NewRDSDBInstanceEnumerator(repo, factory))
|
||||
|
@ -139,20 +139,20 @@ func TestRDSDBSubnetGroup(t *testing.T) {
|
|||
tests := []struct {
|
||||
test string
|
||||
dirName string
|
||||
mocks func(*repository2.MockRDSRepository, *mocks.AlerterInterface)
|
||||
mocks func(*repository.MockRDSRepository, *mocks.AlerterInterface)
|
||||
wantErr error
|
||||
}{
|
||||
{
|
||||
test: "no db subnet groups",
|
||||
dirName: "aws_rds_db_subnet_group_empty",
|
||||
mocks: func(repository *repository2.MockRDSRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockRDSRepository, alerter *mocks.AlerterInterface) {
|
||||
repository.On("ListAllDBSubnetGroups").Return([]*rds.DBSubnetGroup{}, nil)
|
||||
},
|
||||
},
|
||||
{
|
||||
test: "multiple db subnet groups",
|
||||
dirName: "aws_rds_db_subnet_group_multiple",
|
||||
mocks: func(repository *repository2.MockRDSRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockRDSRepository, alerter *mocks.AlerterInterface) {
|
||||
repository.On("ListAllDBSubnetGroups").Return([]*rds.DBSubnetGroup{
|
||||
{DBSubnetGroupName: awssdk.String("foo")},
|
||||
{DBSubnetGroupName: awssdk.String("bar")},
|
||||
|
@ -162,7 +162,7 @@ func TestRDSDBSubnetGroup(t *testing.T) {
|
|||
{
|
||||
test: "cannot list db subnet groups",
|
||||
dirName: "aws_rds_db_subnet_group_list",
|
||||
mocks: func(repository *repository2.MockRDSRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockRDSRepository, alerter *mocks.AlerterInterface) {
|
||||
awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "")
|
||||
repository.On("ListAllDBSubnetGroups").Return(nil, awsError)
|
||||
|
||||
|
@ -191,10 +191,10 @@ func TestRDSDBSubnetGroup(t *testing.T) {
|
|||
|
||||
// Initialize mocks
|
||||
alerter := &mocks.AlerterInterface{}
|
||||
fakeRepo := &repository2.MockRDSRepository{}
|
||||
fakeRepo := &repository.MockRDSRepository{}
|
||||
c.mocks(fakeRepo, alerter)
|
||||
|
||||
var repo repository2.RDSRepository = fakeRepo
|
||||
var repo repository.RDSRepository = fakeRepo
|
||||
providerVersion := "3.19.0"
|
||||
realProvider, err := terraform2.InitTestAwsProvider(providerLibrary, providerVersion)
|
||||
if err != nil {
|
||||
|
@ -210,7 +210,7 @@ func TestRDSDBSubnetGroup(t *testing.T) {
|
|||
t.Fatal(err)
|
||||
}
|
||||
provider.ShouldUpdate()
|
||||
repo = repository2.NewRDSRepository(sess, cache.New(0))
|
||||
repo = repository.NewRDSRepository(sess, cache.New(0))
|
||||
}
|
||||
|
||||
remoteLibrary.AddEnumerator(aws2.NewRDSDBSubnetGroupEnumerator(repo, factory))
|
||||
|
@ -236,20 +236,20 @@ func TestRDSCluster(t *testing.T) {
|
|||
tests := []struct {
|
||||
test string
|
||||
dirName string
|
||||
mocks func(*repository2.MockRDSRepository, *mocks.AlerterInterface)
|
||||
mocks func(*repository.MockRDSRepository, *mocks.AlerterInterface)
|
||||
wantErr error
|
||||
}{
|
||||
{
|
||||
test: "no cluster",
|
||||
dirName: "aws_rds_cluster_empty",
|
||||
mocks: func(repository *repository2.MockRDSRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockRDSRepository, alerter *mocks.AlerterInterface) {
|
||||
repository.On("ListAllDBClusters").Return([]*rds.DBCluster{}, nil)
|
||||
},
|
||||
},
|
||||
{
|
||||
test: "should return one result",
|
||||
dirName: "aws_rds_clusters_results",
|
||||
mocks: func(repository *repository2.MockRDSRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockRDSRepository, alerter *mocks.AlerterInterface) {
|
||||
repository.On("ListAllDBClusters").Return([]*rds.DBCluster{
|
||||
{
|
||||
DBClusterIdentifier: awssdk.String("aurora-cluster-demo"),
|
||||
|
@ -264,7 +264,7 @@ func TestRDSCluster(t *testing.T) {
|
|||
{
|
||||
test: "cannot list clusters",
|
||||
dirName: "aws_rds_cluster_denied",
|
||||
mocks: func(repository *repository2.MockRDSRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockRDSRepository, alerter *mocks.AlerterInterface) {
|
||||
awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 400, "")
|
||||
repository.On("ListAllDBClusters").Return(nil, awsError).Once()
|
||||
|
||||
|
@ -293,10 +293,10 @@ func TestRDSCluster(t *testing.T) {
|
|||
|
||||
// Initialize mocks
|
||||
alerter := &mocks.AlerterInterface{}
|
||||
fakeRepo := &repository2.MockRDSRepository{}
|
||||
fakeRepo := &repository.MockRDSRepository{}
|
||||
c.mocks(fakeRepo, alerter)
|
||||
|
||||
var repo repository2.RDSRepository = fakeRepo
|
||||
var repo repository.RDSRepository = fakeRepo
|
||||
providerVersion := "3.19.0"
|
||||
realProvider, err := terraform2.InitTestAwsProvider(providerLibrary, providerVersion)
|
||||
if err != nil {
|
||||
|
@ -312,7 +312,7 @@ func TestRDSCluster(t *testing.T) {
|
|||
t.Fatal(err)
|
||||
}
|
||||
provider.ShouldUpdate()
|
||||
repo = repository2.NewRDSRepository(sess, cache.New(0))
|
||||
repo = repository.NewRDSRepository(sess, cache.New(0))
|
||||
}
|
||||
|
||||
remoteLibrary.AddEnumerator(aws2.NewRDSClusterEnumerator(repo, factory))
|
||||
|
|
|
@ -4,7 +4,7 @@ import (
|
|||
"github.com/snyk/driftctl/enumeration"
|
||||
"github.com/snyk/driftctl/enumeration/remote/alerts"
|
||||
aws2 "github.com/snyk/driftctl/enumeration/remote/aws"
|
||||
repository2 "github.com/snyk/driftctl/enumeration/remote/aws/repository"
|
||||
"github.com/snyk/driftctl/enumeration/remote/aws/repository"
|
||||
"github.com/snyk/driftctl/enumeration/remote/cache"
|
||||
common2 "github.com/snyk/driftctl/enumeration/remote/common"
|
||||
remoteerr "github.com/snyk/driftctl/enumeration/remote/error"
|
||||
|
@ -35,13 +35,13 @@ func TestRoute53_HealthCheck(t *testing.T) {
|
|||
tests := []struct {
|
||||
test string
|
||||
dirName string
|
||||
mocks func(*repository2.MockRoute53Repository, *mocks.AlerterInterface)
|
||||
mocks func(*repository.MockRoute53Repository, *mocks.AlerterInterface)
|
||||
err error
|
||||
}{
|
||||
{
|
||||
test: "no health check",
|
||||
dirName: "aws_route53_health_check_empty",
|
||||
mocks: func(client *repository2.MockRoute53Repository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(client *repository.MockRoute53Repository, alerter *mocks.AlerterInterface) {
|
||||
client.On("ListAllHealthChecks").Return([]*route53.HealthCheck{}, nil)
|
||||
},
|
||||
err: nil,
|
||||
|
@ -49,7 +49,7 @@ func TestRoute53_HealthCheck(t *testing.T) {
|
|||
{
|
||||
test: "Multiple health check",
|
||||
dirName: "aws_route53_health_check_multiple",
|
||||
mocks: func(client *repository2.MockRoute53Repository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(client *repository.MockRoute53Repository, alerter *mocks.AlerterInterface) {
|
||||
client.On("ListAllHealthChecks").Return([]*route53.HealthCheck{
|
||||
{Id: awssdk.String("7001a9df-ded4-4802-9909-668eb80b972b")},
|
||||
{Id: awssdk.String("84fc318a-2e0d-41d6-b638-280e2f0f4e26")},
|
||||
|
@ -60,7 +60,7 @@ func TestRoute53_HealthCheck(t *testing.T) {
|
|||
{
|
||||
test: "cannot list health check",
|
||||
dirName: "aws_route53_health_check_empty",
|
||||
mocks: func(client *repository2.MockRoute53Repository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(client *repository.MockRoute53Repository, alerter *mocks.AlerterInterface) {
|
||||
awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "")
|
||||
client.On("ListAllHealthChecks").Return(nil, awsError)
|
||||
|
||||
|
@ -89,10 +89,10 @@ func TestRoute53_HealthCheck(t *testing.T) {
|
|||
|
||||
// Initialize mocks
|
||||
alerter := &mocks.AlerterInterface{}
|
||||
fakeRepo := &repository2.MockRoute53Repository{}
|
||||
fakeRepo := &repository.MockRoute53Repository{}
|
||||
c.mocks(fakeRepo, alerter)
|
||||
|
||||
var repo repository2.Route53Repository = fakeRepo
|
||||
var repo repository.Route53Repository = fakeRepo
|
||||
providerVersion := "3.19.0"
|
||||
realProvider, err := terraform2.InitTestAwsProvider(providerLibrary, providerVersion)
|
||||
if err != nil {
|
||||
|
@ -108,7 +108,7 @@ func TestRoute53_HealthCheck(t *testing.T) {
|
|||
t.Fatal(err)
|
||||
}
|
||||
provider.ShouldUpdate()
|
||||
repo = repository2.NewRoute53Repository(session, cache.New(0))
|
||||
repo = repository.NewRoute53Repository(session, cache.New(0))
|
||||
}
|
||||
|
||||
remoteLibrary.AddEnumerator(aws2.NewRoute53HealthCheckEnumerator(repo, factory))
|
||||
|
@ -135,13 +135,13 @@ func TestRoute53_Zone(t *testing.T) {
|
|||
tests := []struct {
|
||||
test string
|
||||
dirName string
|
||||
mocks func(*repository2.MockRoute53Repository, *mocks.AlerterInterface)
|
||||
mocks func(*repository.MockRoute53Repository, *mocks.AlerterInterface)
|
||||
err error
|
||||
}{
|
||||
{
|
||||
test: "no zones",
|
||||
dirName: "aws_route53_zone_empty",
|
||||
mocks: func(client *repository2.MockRoute53Repository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(client *repository.MockRoute53Repository, alerter *mocks.AlerterInterface) {
|
||||
client.On("ListAllZones").Return(
|
||||
[]*route53.HostedZone{},
|
||||
nil,
|
||||
|
@ -152,7 +152,7 @@ func TestRoute53_Zone(t *testing.T) {
|
|||
{
|
||||
test: "single zone",
|
||||
dirName: "aws_route53_zone_single",
|
||||
mocks: func(client *repository2.MockRoute53Repository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(client *repository.MockRoute53Repository, alerter *mocks.AlerterInterface) {
|
||||
client.On("ListAllZones").Return(
|
||||
[]*route53.HostedZone{
|
||||
{
|
||||
|
@ -168,7 +168,7 @@ func TestRoute53_Zone(t *testing.T) {
|
|||
{
|
||||
test: "multiples zone (test pagination)",
|
||||
dirName: "aws_route53_zone_multiples",
|
||||
mocks: func(client *repository2.MockRoute53Repository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(client *repository.MockRoute53Repository, alerter *mocks.AlerterInterface) {
|
||||
client.On("ListAllZones").Return(
|
||||
[]*route53.HostedZone{
|
||||
{
|
||||
|
@ -192,7 +192,7 @@ func TestRoute53_Zone(t *testing.T) {
|
|||
{
|
||||
test: "cannot list zones",
|
||||
dirName: "aws_route53_zone_empty",
|
||||
mocks: func(client *repository2.MockRoute53Repository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(client *repository.MockRoute53Repository, alerter *mocks.AlerterInterface) {
|
||||
awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "")
|
||||
client.On("ListAllZones").Return(
|
||||
[]*route53.HostedZone{},
|
||||
|
@ -224,10 +224,10 @@ func TestRoute53_Zone(t *testing.T) {
|
|||
|
||||
// Initialize mocks
|
||||
alerter := &mocks.AlerterInterface{}
|
||||
fakeRepo := &repository2.MockRoute53Repository{}
|
||||
fakeRepo := &repository.MockRoute53Repository{}
|
||||
c.mocks(fakeRepo, alerter)
|
||||
|
||||
var repo repository2.Route53Repository = fakeRepo
|
||||
var repo repository.Route53Repository = fakeRepo
|
||||
providerVersion := "3.19.0"
|
||||
realProvider, err := terraform2.InitTestAwsProvider(providerLibrary, providerVersion)
|
||||
if err != nil {
|
||||
|
@ -243,7 +243,7 @@ func TestRoute53_Zone(t *testing.T) {
|
|||
t.Fatal(err)
|
||||
}
|
||||
provider.ShouldUpdate()
|
||||
repo = repository2.NewRoute53Repository(session, cache.New(0))
|
||||
repo = repository.NewRoute53Repository(session, cache.New(0))
|
||||
}
|
||||
|
||||
remoteLibrary.AddEnumerator(aws2.NewRoute53ZoneEnumerator(repo, factory))
|
||||
|
@ -270,13 +270,13 @@ func TestRoute53_Record(t *testing.T) {
|
|||
tests := []struct {
|
||||
test string
|
||||
dirName string
|
||||
mocks func(*repository2.MockRoute53Repository, *mocks.AlerterInterface)
|
||||
mocks func(*repository.MockRoute53Repository, *mocks.AlerterInterface)
|
||||
err error
|
||||
}{
|
||||
{
|
||||
test: "no records",
|
||||
dirName: "aws_route53_zone_with_no_record",
|
||||
mocks: func(client *repository2.MockRoute53Repository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(client *repository.MockRoute53Repository, alerter *mocks.AlerterInterface) {
|
||||
client.On("ListAllZones").Return(
|
||||
[]*route53.HostedZone{
|
||||
{
|
||||
|
@ -293,7 +293,7 @@ func TestRoute53_Record(t *testing.T) {
|
|||
{
|
||||
test: "multiples records in multiples zones",
|
||||
dirName: "aws_route53_record_multiples",
|
||||
mocks: func(client *repository2.MockRoute53Repository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(client *repository.MockRoute53Repository, alerter *mocks.AlerterInterface) {
|
||||
client.On("ListAllZones").Return(
|
||||
[]*route53.HostedZone{
|
||||
{
|
||||
|
@ -341,7 +341,7 @@ func TestRoute53_Record(t *testing.T) {
|
|||
{
|
||||
test: "explicit subdomain records",
|
||||
dirName: "aws_route53_record_explicit_subdomain",
|
||||
mocks: func(client *repository2.MockRoute53Repository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(client *repository.MockRoute53Repository, alerter *mocks.AlerterInterface) {
|
||||
client.On("ListAllZones").Return(
|
||||
[]*route53.HostedZone{
|
||||
{
|
||||
|
@ -383,7 +383,7 @@ func TestRoute53_Record(t *testing.T) {
|
|||
{
|
||||
test: "cannot list zones",
|
||||
dirName: "aws_route53_zone_with_no_record",
|
||||
mocks: func(client *repository2.MockRoute53Repository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(client *repository.MockRoute53Repository, alerter *mocks.AlerterInterface) {
|
||||
awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "")
|
||||
client.On("ListAllZones").Return(
|
||||
[]*route53.HostedZone{},
|
||||
|
@ -396,7 +396,7 @@ func TestRoute53_Record(t *testing.T) {
|
|||
{
|
||||
test: "cannot list records",
|
||||
dirName: "aws_route53_zone_with_no_record",
|
||||
mocks: func(client *repository2.MockRoute53Repository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(client *repository.MockRoute53Repository, alerter *mocks.AlerterInterface) {
|
||||
client.On("ListAllZones").Return(
|
||||
[]*route53.HostedZone{
|
||||
{
|
||||
|
@ -434,10 +434,10 @@ func TestRoute53_Record(t *testing.T) {
|
|||
|
||||
// Initialize mocks
|
||||
alerter := &mocks.AlerterInterface{}
|
||||
fakeRepo := &repository2.MockRoute53Repository{}
|
||||
fakeRepo := &repository.MockRoute53Repository{}
|
||||
c.mocks(fakeRepo, alerter)
|
||||
|
||||
var repo repository2.Route53Repository = fakeRepo
|
||||
var repo repository.Route53Repository = fakeRepo
|
||||
providerVersion := "3.19.0"
|
||||
realProvider, err := terraform2.InitTestAwsProvider(providerLibrary, providerVersion)
|
||||
if err != nil {
|
||||
|
@ -453,7 +453,7 @@ func TestRoute53_Record(t *testing.T) {
|
|||
t.Fatal(err)
|
||||
}
|
||||
provider.ShouldUpdate()
|
||||
repo = repository2.NewRoute53Repository(session, cache.New(0))
|
||||
repo = repository.NewRoute53Repository(session, cache.New(0))
|
||||
}
|
||||
|
||||
remoteLibrary.AddEnumerator(aws2.NewRoute53RecordEnumerator(repo, factory))
|
||||
|
|
|
@ -7,7 +7,7 @@ import (
|
|||
"github.com/snyk/driftctl/enumeration/remote/alerts"
|
||||
aws2 "github.com/snyk/driftctl/enumeration/remote/aws"
|
||||
"github.com/snyk/driftctl/enumeration/remote/aws/client"
|
||||
repository2 "github.com/snyk/driftctl/enumeration/remote/aws/repository"
|
||||
"github.com/snyk/driftctl/enumeration/remote/aws/repository"
|
||||
"github.com/snyk/driftctl/enumeration/remote/cache"
|
||||
common2 "github.com/snyk/driftctl/enumeration/remote/common"
|
||||
remoteerr "github.com/snyk/driftctl/enumeration/remote/error"
|
||||
|
@ -38,12 +38,12 @@ func TestS3Bucket(t *testing.T) {
|
|||
tests := []struct {
|
||||
test string
|
||||
dirName string
|
||||
mocks func(*repository2.MockS3Repository, *mocks.AlerterInterface)
|
||||
mocks func(*repository.MockS3Repository, *mocks.AlerterInterface)
|
||||
wantErr error
|
||||
}{
|
||||
{
|
||||
test: "multiple bucket", dirName: "aws_s3_bucket_multiple",
|
||||
mocks: func(repository *repository2.MockS3Repository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockS3Repository, alerter *mocks.AlerterInterface) {
|
||||
repository.On(
|
||||
"ListAllBuckets",
|
||||
).Return([]*s3.Bucket{
|
||||
|
@ -79,7 +79,7 @@ func TestS3Bucket(t *testing.T) {
|
|||
},
|
||||
{
|
||||
test: "cannot list bucket", dirName: "aws_s3_bucket_list",
|
||||
mocks: func(repository *repository2.MockS3Repository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockS3Repository, alerter *mocks.AlerterInterface) {
|
||||
awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "")
|
||||
repository.On("ListAllBuckets").Return(nil, awsError)
|
||||
|
||||
|
@ -108,9 +108,9 @@ func TestS3Bucket(t *testing.T) {
|
|||
|
||||
// Initialize mocks
|
||||
alerter := &mocks.AlerterInterface{}
|
||||
fakeRepo := &repository2.MockS3Repository{}
|
||||
fakeRepo := &repository.MockS3Repository{}
|
||||
c.mocks(fakeRepo, alerter)
|
||||
var repo repository2.S3Repository = fakeRepo
|
||||
var repo repository.S3Repository = fakeRepo
|
||||
providerVersion := "3.19.0"
|
||||
realProvider, err := terraform2.InitTestAwsProvider(providerLibrary, providerVersion)
|
||||
if err != nil {
|
||||
|
@ -126,7 +126,7 @@ func TestS3Bucket(t *testing.T) {
|
|||
t.Fatal(err)
|
||||
}
|
||||
provider.ShouldUpdate()
|
||||
repo = repository2.NewS3Repository(client.NewAWSClientFactory(session), cache.New(0))
|
||||
repo = repository.NewS3Repository(client.NewAWSClientFactory(session), cache.New(0))
|
||||
}
|
||||
|
||||
remoteLibrary.AddEnumerator(aws2.NewS3BucketEnumerator(repo, factory, tf.TerraformProviderConfig{
|
||||
|
@ -156,12 +156,12 @@ func TestS3BucketInventory(t *testing.T) {
|
|||
tests := []struct {
|
||||
test string
|
||||
dirName string
|
||||
mocks func(*repository2.MockS3Repository, *mocks.AlerterInterface)
|
||||
mocks func(*repository.MockS3Repository, *mocks.AlerterInterface)
|
||||
wantErr error
|
||||
}{
|
||||
{
|
||||
test: "multiple bucket with multiple inventories", dirName: "aws_s3_bucket_inventories_multiple",
|
||||
mocks: func(repository *repository2.MockS3Repository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockS3Repository, alerter *mocks.AlerterInterface) {
|
||||
repository.On(
|
||||
"ListAllBuckets",
|
||||
).Return([]*s3.Bucket{
|
||||
|
@ -209,7 +209,7 @@ func TestS3BucketInventory(t *testing.T) {
|
|||
},
|
||||
{
|
||||
test: "cannot list bucket", dirName: "aws_s3_bucket_inventories_list_bucket",
|
||||
mocks: func(repository *repository2.MockS3Repository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockS3Repository, alerter *mocks.AlerterInterface) {
|
||||
awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "")
|
||||
repository.On("ListAllBuckets").Return(nil, awsError)
|
||||
|
||||
|
@ -219,7 +219,7 @@ func TestS3BucketInventory(t *testing.T) {
|
|||
},
|
||||
{
|
||||
test: "cannot list bucket inventories", dirName: "aws_s3_bucket_inventories_list_inventories",
|
||||
mocks: func(repository *repository2.MockS3Repository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockS3Repository, alerter *mocks.AlerterInterface) {
|
||||
repository.On("ListAllBuckets").Return(
|
||||
[]*s3.Bucket{
|
||||
{Name: awssdk.String("bucket-martin-test-drift")},
|
||||
|
@ -268,9 +268,9 @@ func TestS3BucketInventory(t *testing.T) {
|
|||
|
||||
// Initialize mocks
|
||||
alerter := &mocks.AlerterInterface{}
|
||||
fakeRepo := &repository2.MockS3Repository{}
|
||||
fakeRepo := &repository.MockS3Repository{}
|
||||
c.mocks(fakeRepo, alerter)
|
||||
var repo repository2.S3Repository = fakeRepo
|
||||
var repo repository.S3Repository = fakeRepo
|
||||
providerVersion := "3.19.0"
|
||||
realProvider, err := terraform2.InitTestAwsProvider(providerLibrary, providerVersion)
|
||||
if err != nil {
|
||||
|
@ -286,7 +286,7 @@ func TestS3BucketInventory(t *testing.T) {
|
|||
t.Fatal(err)
|
||||
}
|
||||
provider.ShouldUpdate()
|
||||
repo = repository2.NewS3Repository(client.NewAWSClientFactory(session), cache.New(0))
|
||||
repo = repository.NewS3Repository(client.NewAWSClientFactory(session), cache.New(0))
|
||||
}
|
||||
|
||||
remoteLibrary.AddEnumerator(aws2.NewS3BucketInventoryEnumerator(repo, factory, tf.TerraformProviderConfig{
|
||||
|
@ -316,13 +316,13 @@ func TestS3BucketNotification(t *testing.T) {
|
|||
tests := []struct {
|
||||
test string
|
||||
dirName string
|
||||
mocks func(*repository2.MockS3Repository, *mocks.AlerterInterface)
|
||||
mocks func(*repository.MockS3Repository, *mocks.AlerterInterface)
|
||||
wantErr error
|
||||
}{
|
||||
{
|
||||
test: "single bucket without notifications",
|
||||
dirName: "aws_s3_bucket_notifications_no_notif",
|
||||
mocks: func(repository *repository2.MockS3Repository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockS3Repository, alerter *mocks.AlerterInterface) {
|
||||
repository.On(
|
||||
"ListAllBuckets",
|
||||
).Return([]*s3.Bucket{
|
||||
|
@ -349,7 +349,7 @@ func TestS3BucketNotification(t *testing.T) {
|
|||
},
|
||||
{
|
||||
test: "multiple bucket with notifications", dirName: "aws_s3_bucket_notifications_multiple",
|
||||
mocks: func(repository *repository2.MockS3Repository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockS3Repository, alerter *mocks.AlerterInterface) {
|
||||
repository.On(
|
||||
"ListAllBuckets",
|
||||
).Return([]*s3.Bucket{
|
||||
|
@ -403,7 +403,7 @@ func TestS3BucketNotification(t *testing.T) {
|
|||
},
|
||||
{
|
||||
test: "Cannot get bucket notification", dirName: "aws_s3_bucket_notifications_list_bucket",
|
||||
mocks: func(repository *repository2.MockS3Repository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockS3Repository, alerter *mocks.AlerterInterface) {
|
||||
repository.On(
|
||||
"ListAllBuckets",
|
||||
).Return([]*s3.Bucket{
|
||||
|
@ -425,7 +425,7 @@ func TestS3BucketNotification(t *testing.T) {
|
|||
},
|
||||
{
|
||||
test: "Cannot list bucket", dirName: "aws_s3_bucket_notifications_list_bucket",
|
||||
mocks: func(repository *repository2.MockS3Repository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockS3Repository, alerter *mocks.AlerterInterface) {
|
||||
awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "")
|
||||
repository.On("ListAllBuckets").Return(nil, awsError)
|
||||
|
||||
|
@ -454,9 +454,9 @@ func TestS3BucketNotification(t *testing.T) {
|
|||
|
||||
// Initialize mocks
|
||||
alerter := &mocks.AlerterInterface{}
|
||||
fakeRepo := &repository2.MockS3Repository{}
|
||||
fakeRepo := &repository.MockS3Repository{}
|
||||
c.mocks(fakeRepo, alerter)
|
||||
var repo repository2.S3Repository = fakeRepo
|
||||
var repo repository.S3Repository = fakeRepo
|
||||
providerVersion := "3.19.0"
|
||||
realProvider, err := terraform2.InitTestAwsProvider(providerLibrary, providerVersion)
|
||||
if err != nil {
|
||||
|
@ -472,7 +472,7 @@ func TestS3BucketNotification(t *testing.T) {
|
|||
t.Fatal(err)
|
||||
}
|
||||
provider.ShouldUpdate()
|
||||
repo = repository2.NewS3Repository(client.NewAWSClientFactory(session), cache.New(0))
|
||||
repo = repository.NewS3Repository(client.NewAWSClientFactory(session), cache.New(0))
|
||||
}
|
||||
|
||||
remoteLibrary.AddEnumerator(aws2.NewS3BucketNotificationEnumerator(repo, factory, tf.TerraformProviderConfig{
|
||||
|
@ -502,12 +502,12 @@ func TestS3BucketMetrics(t *testing.T) {
|
|||
tests := []struct {
|
||||
test string
|
||||
dirName string
|
||||
mocks func(*repository2.MockS3Repository, *mocks.AlerterInterface)
|
||||
mocks func(*repository.MockS3Repository, *mocks.AlerterInterface)
|
||||
wantErr error
|
||||
}{
|
||||
{
|
||||
test: "multiple bucket with multiple metrics", dirName: "aws_s3_bucket_metrics_multiple",
|
||||
mocks: func(repository *repository2.MockS3Repository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockS3Repository, alerter *mocks.AlerterInterface) {
|
||||
repository.On(
|
||||
"ListAllBuckets",
|
||||
).Return([]*s3.Bucket{
|
||||
|
@ -555,7 +555,7 @@ func TestS3BucketMetrics(t *testing.T) {
|
|||
},
|
||||
{
|
||||
test: "cannot list bucket", dirName: "aws_s3_bucket_metrics_list_bucket",
|
||||
mocks: func(repository *repository2.MockS3Repository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockS3Repository, alerter *mocks.AlerterInterface) {
|
||||
awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "")
|
||||
repository.On("ListAllBuckets").Return(nil, awsError)
|
||||
|
||||
|
@ -565,7 +565,7 @@ func TestS3BucketMetrics(t *testing.T) {
|
|||
},
|
||||
{
|
||||
test: "cannot list metrics", dirName: "aws_s3_bucket_metrics_list_metrics",
|
||||
mocks: func(repository *repository2.MockS3Repository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockS3Repository, alerter *mocks.AlerterInterface) {
|
||||
repository.On("ListAllBuckets").Return(
|
||||
[]*s3.Bucket{
|
||||
{Name: awssdk.String("bucket-martin-test-drift")},
|
||||
|
@ -615,9 +615,9 @@ func TestS3BucketMetrics(t *testing.T) {
|
|||
|
||||
// Initialize mocks
|
||||
alerter := &mocks.AlerterInterface{}
|
||||
fakeRepo := &repository2.MockS3Repository{}
|
||||
fakeRepo := &repository.MockS3Repository{}
|
||||
c.mocks(fakeRepo, alerter)
|
||||
var repo repository2.S3Repository = fakeRepo
|
||||
var repo repository.S3Repository = fakeRepo
|
||||
providerVersion := "3.19.0"
|
||||
realProvider, err := terraform2.InitTestAwsProvider(providerLibrary, providerVersion)
|
||||
if err != nil {
|
||||
|
@ -633,7 +633,7 @@ func TestS3BucketMetrics(t *testing.T) {
|
|||
t.Fatal(err)
|
||||
}
|
||||
provider.ShouldUpdate()
|
||||
repo = repository2.NewS3Repository(client.NewAWSClientFactory(session), cache.New(0))
|
||||
repo = repository.NewS3Repository(client.NewAWSClientFactory(session), cache.New(0))
|
||||
}
|
||||
|
||||
remoteLibrary.AddEnumerator(aws2.NewS3BucketMetricsEnumerator(repo, factory, tf.TerraformProviderConfig{
|
||||
|
@ -663,13 +663,13 @@ func TestS3BucketPolicy(t *testing.T) {
|
|||
tests := []struct {
|
||||
test string
|
||||
dirName string
|
||||
mocks func(*repository2.MockS3Repository, *mocks.AlerterInterface)
|
||||
mocks func(*repository.MockS3Repository, *mocks.AlerterInterface)
|
||||
wantErr error
|
||||
}{
|
||||
{
|
||||
test: "single bucket without policy",
|
||||
dirName: "aws_s3_bucket_policy_no_policy",
|
||||
mocks: func(repository *repository2.MockS3Repository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockS3Repository, alerter *mocks.AlerterInterface) {
|
||||
repository.On(
|
||||
"ListAllBuckets",
|
||||
).Return([]*s3.Bucket{
|
||||
|
@ -696,7 +696,7 @@ func TestS3BucketPolicy(t *testing.T) {
|
|||
},
|
||||
{
|
||||
test: "multiple bucket with policies", dirName: "aws_s3_bucket_policies_multiple",
|
||||
mocks: func(repository *repository2.MockS3Repository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockS3Repository, alerter *mocks.AlerterInterface) {
|
||||
repository.On(
|
||||
"ListAllBuckets",
|
||||
).Return([]*s3.Bucket{
|
||||
|
@ -744,7 +744,7 @@ func TestS3BucketPolicy(t *testing.T) {
|
|||
},
|
||||
{
|
||||
test: "cannot list bucket", dirName: "aws_s3_bucket_policies_list_bucket",
|
||||
mocks: func(repository *repository2.MockS3Repository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockS3Repository, alerter *mocks.AlerterInterface) {
|
||||
awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "")
|
||||
repository.On("ListAllBuckets").Return(nil, awsError)
|
||||
|
||||
|
@ -773,9 +773,9 @@ func TestS3BucketPolicy(t *testing.T) {
|
|||
|
||||
// Initialize mocks
|
||||
alerter := &mocks.AlerterInterface{}
|
||||
fakeRepo := &repository2.MockS3Repository{}
|
||||
fakeRepo := &repository.MockS3Repository{}
|
||||
c.mocks(fakeRepo, alerter)
|
||||
var repo repository2.S3Repository = fakeRepo
|
||||
var repo repository.S3Repository = fakeRepo
|
||||
providerVersion := "3.19.0"
|
||||
realProvider, err := terraform2.InitTestAwsProvider(providerLibrary, providerVersion)
|
||||
if err != nil {
|
||||
|
@ -791,7 +791,7 @@ func TestS3BucketPolicy(t *testing.T) {
|
|||
t.Fatal(err)
|
||||
}
|
||||
provider.ShouldUpdate()
|
||||
repo = repository2.NewS3Repository(client.NewAWSClientFactory(session), cache.New(0))
|
||||
repo = repository.NewS3Repository(client.NewAWSClientFactory(session), cache.New(0))
|
||||
}
|
||||
|
||||
remoteLibrary.AddEnumerator(aws2.NewS3BucketPolicyEnumerator(repo, factory, tf.TerraformProviderConfig{
|
||||
|
@ -821,13 +821,13 @@ func TestS3BucketPublicAccessBlock(t *testing.T) {
|
|||
|
||||
tests := []struct {
|
||||
test string
|
||||
mocks func(*repository2.MockS3Repository, *mocks.AlerterInterface)
|
||||
mocks func(*repository.MockS3Repository, *mocks.AlerterInterface)
|
||||
assertExpected func(t *testing.T, got []*resource.Resource)
|
||||
wantErr error
|
||||
}{
|
||||
{
|
||||
test: "multiple bucket, one with access block",
|
||||
mocks: func(repository *repository2.MockS3Repository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockS3Repository, alerter *mocks.AlerterInterface) {
|
||||
repository.On("ListAllBuckets").Return([]*s3.Bucket{
|
||||
{Name: awssdk.String("bucket-with-public-access-block")},
|
||||
{Name: awssdk.String("bucket-without-public-access-block")},
|
||||
|
@ -861,14 +861,14 @@ func TestS3BucketPublicAccessBlock(t *testing.T) {
|
|||
},
|
||||
{
|
||||
test: "cannot list bucket",
|
||||
mocks: func(repository *repository2.MockS3Repository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockS3Repository, alerter *mocks.AlerterInterface) {
|
||||
repository.On("ListAllBuckets").Return(nil, dummyError)
|
||||
},
|
||||
wantErr: remoteerr.NewResourceListingErrorWithType(dummyError, resourceaws.AwsS3BucketPublicAccessBlockResourceType, resourceaws.AwsS3BucketResourceType),
|
||||
},
|
||||
{
|
||||
test: "cannot list public access block",
|
||||
mocks: func(repository *repository2.MockS3Repository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockS3Repository, alerter *mocks.AlerterInterface) {
|
||||
repository.On("ListAllBuckets").Return([]*s3.Bucket{{Name: awssdk.String("foobar")}}, nil)
|
||||
repository.On("GetBucketLocation", "foobar").Return("us-east-1", nil)
|
||||
repository.On("GetBucketPublicAccessBlock", "foobar", "us-east-1").Return(nil, dummyError)
|
||||
|
@ -892,10 +892,10 @@ func TestS3BucketPublicAccessBlock(t *testing.T) {
|
|||
|
||||
// Initialize mocks
|
||||
alerter := &mocks.AlerterInterface{}
|
||||
fakeRepo := &repository2.MockS3Repository{}
|
||||
fakeRepo := &repository.MockS3Repository{}
|
||||
c.mocks(fakeRepo, alerter)
|
||||
|
||||
var repo repository2.S3Repository = fakeRepo
|
||||
var repo repository.S3Repository = fakeRepo
|
||||
|
||||
remoteLibrary.AddEnumerator(aws2.NewS3BucketPublicAccessBlockEnumerator(
|
||||
repo, factory,
|
||||
|
@ -926,13 +926,13 @@ func TestS3BucketAnalytic(t *testing.T) {
|
|||
tests := []struct {
|
||||
test string
|
||||
dirName string
|
||||
mocks func(*repository2.MockS3Repository, *mocks.AlerterInterface)
|
||||
mocks func(*repository.MockS3Repository, *mocks.AlerterInterface)
|
||||
wantErr error
|
||||
}{
|
||||
{
|
||||
test: "multiple bucket with multiple analytics",
|
||||
dirName: "aws_s3_bucket_analytics_multiple",
|
||||
mocks: func(repository *repository2.MockS3Repository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockS3Repository, alerter *mocks.AlerterInterface) {
|
||||
repository.On(
|
||||
"ListAllBuckets",
|
||||
).Return([]*s3.Bucket{
|
||||
|
@ -980,7 +980,7 @@ func TestS3BucketAnalytic(t *testing.T) {
|
|||
},
|
||||
{
|
||||
test: "cannot list bucket", dirName: "aws_s3_bucket_analytics_list_bucket",
|
||||
mocks: func(repository *repository2.MockS3Repository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockS3Repository, alerter *mocks.AlerterInterface) {
|
||||
awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "")
|
||||
repository.On("ListAllBuckets").Return(nil, awsError)
|
||||
|
||||
|
@ -990,7 +990,7 @@ func TestS3BucketAnalytic(t *testing.T) {
|
|||
},
|
||||
{
|
||||
test: "cannot list Analytics", dirName: "aws_s3_bucket_analytics_list_analytics",
|
||||
mocks: func(repository *repository2.MockS3Repository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockS3Repository, alerter *mocks.AlerterInterface) {
|
||||
repository.On("ListAllBuckets").Return(
|
||||
[]*s3.Bucket{
|
||||
{Name: awssdk.String("bucket-martin-test-drift")},
|
||||
|
@ -1040,9 +1040,9 @@ func TestS3BucketAnalytic(t *testing.T) {
|
|||
|
||||
// Initialize mocks
|
||||
alerter := &mocks.AlerterInterface{}
|
||||
fakeRepo := &repository2.MockS3Repository{}
|
||||
fakeRepo := &repository.MockS3Repository{}
|
||||
c.mocks(fakeRepo, alerter)
|
||||
var repo repository2.S3Repository = fakeRepo
|
||||
var repo repository.S3Repository = fakeRepo
|
||||
providerVersion := "3.19.0"
|
||||
realProvider, err := terraform2.InitTestAwsProvider(providerLibrary, providerVersion)
|
||||
if err != nil {
|
||||
|
@ -1058,7 +1058,7 @@ func TestS3BucketAnalytic(t *testing.T) {
|
|||
t.Fatal(err)
|
||||
}
|
||||
provider.ShouldUpdate()
|
||||
repo = repository2.NewS3Repository(client.NewAWSClientFactory(session), cache.New(0))
|
||||
repo = repository.NewS3Repository(client.NewAWSClientFactory(session), cache.New(0))
|
||||
}
|
||||
|
||||
remoteLibrary.AddEnumerator(aws2.NewS3BucketAnalyticEnumerator(repo, factory, tf.TerraformProviderConfig{
|
||||
|
|
|
@ -6,7 +6,7 @@ import (
|
|||
"github.com/snyk/driftctl/enumeration"
|
||||
"github.com/snyk/driftctl/enumeration/remote/alerts"
|
||||
aws2 "github.com/snyk/driftctl/enumeration/remote/aws"
|
||||
repository2 "github.com/snyk/driftctl/enumeration/remote/aws/repository"
|
||||
"github.com/snyk/driftctl/enumeration/remote/aws/repository"
|
||||
"github.com/snyk/driftctl/enumeration/remote/cache"
|
||||
common2 "github.com/snyk/driftctl/enumeration/remote/common"
|
||||
remoteerr "github.com/snyk/driftctl/enumeration/remote/error"
|
||||
|
@ -36,13 +36,13 @@ func TestScanSNSTopic(t *testing.T) {
|
|||
cases := []struct {
|
||||
test string
|
||||
dirName string
|
||||
mocks func(*repository2.MockSNSRepository, *mocks.AlerterInterface)
|
||||
mocks func(*repository.MockSNSRepository, *mocks.AlerterInterface)
|
||||
err error
|
||||
}{
|
||||
{
|
||||
test: "no SNS Topic",
|
||||
dirName: "aws_sns_topic_empty",
|
||||
mocks: func(client *repository2.MockSNSRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(client *repository.MockSNSRepository, alerter *mocks.AlerterInterface) {
|
||||
client.On("ListAllTopics").Return([]*sns.Topic{}, nil)
|
||||
},
|
||||
err: nil,
|
||||
|
@ -50,7 +50,7 @@ func TestScanSNSTopic(t *testing.T) {
|
|||
{
|
||||
test: "Multiple SNSTopic",
|
||||
dirName: "aws_sns_topic_multiple",
|
||||
mocks: func(client *repository2.MockSNSRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(client *repository.MockSNSRepository, alerter *mocks.AlerterInterface) {
|
||||
client.On("ListAllTopics").Return([]*sns.Topic{
|
||||
{TopicArn: awssdk.String("arn:aws:sns:eu-west-3:526954929923:user-updates-topic")},
|
||||
{TopicArn: awssdk.String("arn:aws:sns:eu-west-3:526954929923:user-updates-topic2")},
|
||||
|
@ -62,7 +62,7 @@ func TestScanSNSTopic(t *testing.T) {
|
|||
{
|
||||
test: "cannot list SNSTopic",
|
||||
dirName: "aws_sns_topic_empty",
|
||||
mocks: func(client *repository2.MockSNSRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(client *repository.MockSNSRepository, alerter *mocks.AlerterInterface) {
|
||||
awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "")
|
||||
client.On("ListAllTopics").Return(nil, awsError)
|
||||
|
||||
|
@ -91,10 +91,10 @@ func TestScanSNSTopic(t *testing.T) {
|
|||
|
||||
// Initialize mocks
|
||||
alerter := &mocks.AlerterInterface{}
|
||||
fakeRepo := &repository2.MockSNSRepository{}
|
||||
fakeRepo := &repository.MockSNSRepository{}
|
||||
c.mocks(fakeRepo, alerter)
|
||||
|
||||
var repo repository2.SNSRepository = fakeRepo
|
||||
var repo repository.SNSRepository = fakeRepo
|
||||
providerVersion := "3.19.0"
|
||||
realProvider, err := terraform2.InitTestAwsProvider(providerLibrary, providerVersion)
|
||||
if err != nil {
|
||||
|
@ -110,7 +110,7 @@ func TestScanSNSTopic(t *testing.T) {
|
|||
t.Fatal(err)
|
||||
}
|
||||
provider.ShouldUpdate()
|
||||
repo = repository2.NewSNSRepository(sess, cache.New(0))
|
||||
repo = repository.NewSNSRepository(sess, cache.New(0))
|
||||
}
|
||||
|
||||
remoteLibrary.AddEnumerator(aws2.NewSNSTopicEnumerator(repo, factory))
|
||||
|
@ -137,13 +137,13 @@ func TestSNSTopicPolicyScan(t *testing.T) {
|
|||
cases := []struct {
|
||||
test string
|
||||
dirName string
|
||||
mocks func(*repository2.MockSNSRepository, *mocks.AlerterInterface)
|
||||
mocks func(*repository.MockSNSRepository, *mocks.AlerterInterface)
|
||||
err error
|
||||
}{
|
||||
{
|
||||
test: "no SNS Topic policy",
|
||||
dirName: "aws_sns_topic_policy_empty",
|
||||
mocks: func(client *repository2.MockSNSRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(client *repository.MockSNSRepository, alerter *mocks.AlerterInterface) {
|
||||
client.On("ListAllTopics").Return([]*sns.Topic{}, nil)
|
||||
},
|
||||
err: nil,
|
||||
|
@ -151,7 +151,7 @@ func TestSNSTopicPolicyScan(t *testing.T) {
|
|||
{
|
||||
test: "Multiple SNSTopicPolicy",
|
||||
dirName: "aws_sns_topic_policy_multiple",
|
||||
mocks: func(client *repository2.MockSNSRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(client *repository.MockSNSRepository, alerter *mocks.AlerterInterface) {
|
||||
client.On("ListAllTopics").Return([]*sns.Topic{
|
||||
{TopicArn: awssdk.String("arn:aws:sns:us-east-1:526954929923:my-topic-with-policy")},
|
||||
{TopicArn: awssdk.String("arn:aws:sns:us-east-1:526954929923:my-topic-with-policy2")},
|
||||
|
@ -162,7 +162,7 @@ func TestSNSTopicPolicyScan(t *testing.T) {
|
|||
{
|
||||
test: "cannot list SNSTopic",
|
||||
dirName: "aws_sns_topic_policy_topic_list",
|
||||
mocks: func(client *repository2.MockSNSRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(client *repository.MockSNSRepository, alerter *mocks.AlerterInterface) {
|
||||
awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "")
|
||||
client.On("ListAllTopics").Return(nil, awsError)
|
||||
|
||||
|
@ -191,10 +191,10 @@ func TestSNSTopicPolicyScan(t *testing.T) {
|
|||
|
||||
// Initialize mocks
|
||||
alerter := &mocks.AlerterInterface{}
|
||||
fakeRepo := &repository2.MockSNSRepository{}
|
||||
fakeRepo := &repository.MockSNSRepository{}
|
||||
c.mocks(fakeRepo, alerter)
|
||||
|
||||
var repo repository2.SNSRepository = fakeRepo
|
||||
var repo repository.SNSRepository = fakeRepo
|
||||
providerVersion := "3.19.0"
|
||||
realProvider, err := terraform2.InitTestAwsProvider(providerLibrary, providerVersion)
|
||||
if err != nil {
|
||||
|
@ -210,7 +210,7 @@ func TestSNSTopicPolicyScan(t *testing.T) {
|
|||
t.Fatal(err)
|
||||
}
|
||||
provider.ShouldUpdate()
|
||||
repo = repository2.NewSNSRepository(sess, cache.New(0))
|
||||
repo = repository.NewSNSRepository(sess, cache.New(0))
|
||||
}
|
||||
|
||||
remoteLibrary.AddEnumerator(aws2.NewSNSTopicPolicyEnumerator(repo, factory))
|
||||
|
@ -237,13 +237,13 @@ func TestSNSTopicSubscriptionScan(t *testing.T) {
|
|||
cases := []struct {
|
||||
test string
|
||||
dirName string
|
||||
mocks func(*repository2.MockSNSRepository, *mocks.AlerterInterface)
|
||||
mocks func(*repository.MockSNSRepository, *mocks.AlerterInterface)
|
||||
err error
|
||||
}{
|
||||
{
|
||||
test: "no SNS Topic Subscription",
|
||||
dirName: "aws_sns_topic_subscription_empty",
|
||||
mocks: func(client *repository2.MockSNSRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(client *repository.MockSNSRepository, alerter *mocks.AlerterInterface) {
|
||||
client.On("ListAllSubscriptions").Return([]*sns.Subscription{}, nil)
|
||||
},
|
||||
err: nil,
|
||||
|
@ -251,7 +251,7 @@ func TestSNSTopicSubscriptionScan(t *testing.T) {
|
|||
{
|
||||
test: "Multiple SNSTopic Subscription",
|
||||
dirName: "aws_sns_topic_subscription_multiple",
|
||||
mocks: func(client *repository2.MockSNSRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(client *repository.MockSNSRepository, alerter *mocks.AlerterInterface) {
|
||||
client.On("ListAllSubscriptions").Return([]*sns.Subscription{
|
||||
{SubscriptionArn: awssdk.String("arn:aws:sns:us-east-1:526954929923:user-updates-topic2:c0f794c5-a009-4db4-9147-4c55959787fa")},
|
||||
{SubscriptionArn: awssdk.String("arn:aws:sns:us-east-1:526954929923:user-updates-topic:b6e66147-2b31-4486-8d4b-2a2272264c8e")},
|
||||
|
@ -262,7 +262,7 @@ func TestSNSTopicSubscriptionScan(t *testing.T) {
|
|||
{
|
||||
test: "Multiple SNSTopic Subscription with one pending and one incorrect",
|
||||
dirName: "aws_sns_topic_subscription_multiple",
|
||||
mocks: func(client *repository2.MockSNSRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(client *repository.MockSNSRepository, alerter *mocks.AlerterInterface) {
|
||||
client.On("ListAllSubscriptions").Return([]*sns.Subscription{
|
||||
{SubscriptionArn: awssdk.String("PendingConfirmation"), Endpoint: awssdk.String("TEST")},
|
||||
{SubscriptionArn: awssdk.String("Incorrect"), Endpoint: awssdk.String("INCORRECT")},
|
||||
|
@ -279,7 +279,7 @@ func TestSNSTopicSubscriptionScan(t *testing.T) {
|
|||
{
|
||||
test: "cannot list SNSTopic subscription",
|
||||
dirName: "aws_sns_topic_subscription_list",
|
||||
mocks: func(client *repository2.MockSNSRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(client *repository.MockSNSRepository, alerter *mocks.AlerterInterface) {
|
||||
awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "")
|
||||
client.On("ListAllSubscriptions").Return(nil, awsError)
|
||||
|
||||
|
@ -308,10 +308,10 @@ func TestSNSTopicSubscriptionScan(t *testing.T) {
|
|||
|
||||
// Initialize mocks
|
||||
alerter := &mocks.AlerterInterface{}
|
||||
fakeRepo := &repository2.MockSNSRepository{}
|
||||
fakeRepo := &repository.MockSNSRepository{}
|
||||
c.mocks(fakeRepo, alerter)
|
||||
|
||||
var repo repository2.SNSRepository = fakeRepo
|
||||
var repo repository.SNSRepository = fakeRepo
|
||||
providerVersion := "3.19.0"
|
||||
realProvider, err := terraform2.InitTestAwsProvider(providerLibrary, providerVersion)
|
||||
if err != nil {
|
||||
|
@ -327,7 +327,7 @@ func TestSNSTopicSubscriptionScan(t *testing.T) {
|
|||
t.Fatal(err)
|
||||
}
|
||||
provider.ShouldUpdate()
|
||||
repo = repository2.NewSNSRepository(sess, cache.New(0))
|
||||
repo = repository.NewSNSRepository(sess, cache.New(0))
|
||||
}
|
||||
|
||||
remoteLibrary.AddEnumerator(aws2.NewSNSTopicSubscriptionEnumerator(repo, factory, alerter))
|
||||
|
|
|
@ -6,7 +6,7 @@ import (
|
|||
"github.com/snyk/driftctl/enumeration"
|
||||
"github.com/snyk/driftctl/enumeration/remote/alerts"
|
||||
aws2 "github.com/snyk/driftctl/enumeration/remote/aws"
|
||||
repository2 "github.com/snyk/driftctl/enumeration/remote/aws/repository"
|
||||
"github.com/snyk/driftctl/enumeration/remote/aws/repository"
|
||||
"github.com/snyk/driftctl/enumeration/remote/cache"
|
||||
common2 "github.com/snyk/driftctl/enumeration/remote/common"
|
||||
remoteerr "github.com/snyk/driftctl/enumeration/remote/error"
|
||||
|
@ -33,13 +33,13 @@ func TestSQSQueue(t *testing.T) {
|
|||
cases := []struct {
|
||||
test string
|
||||
dirName string
|
||||
mocks func(*repository2.MockSQSRepository, *mocks.AlerterInterface)
|
||||
mocks func(*repository.MockSQSRepository, *mocks.AlerterInterface)
|
||||
wantErr error
|
||||
}{
|
||||
{
|
||||
test: "no sqs queues",
|
||||
dirName: "aws_sqs_queue_empty",
|
||||
mocks: func(client *repository2.MockSQSRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(client *repository.MockSQSRepository, alerter *mocks.AlerterInterface) {
|
||||
client.On("ListAllQueues").Return([]*string{}, nil)
|
||||
},
|
||||
wantErr: nil,
|
||||
|
@ -47,7 +47,7 @@ func TestSQSQueue(t *testing.T) {
|
|||
{
|
||||
test: "multiple sqs queues",
|
||||
dirName: "aws_sqs_queue_multiple",
|
||||
mocks: func(client *repository2.MockSQSRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(client *repository.MockSQSRepository, alerter *mocks.AlerterInterface) {
|
||||
client.On("ListAllQueues").Return([]*string{
|
||||
awssdk.String("https://sqs.eu-west-3.amazonaws.com/047081014315/bar.fifo"),
|
||||
awssdk.String("https://sqs.eu-west-3.amazonaws.com/047081014315/foo"),
|
||||
|
@ -58,7 +58,7 @@ func TestSQSQueue(t *testing.T) {
|
|||
{
|
||||
test: "cannot list sqs queues",
|
||||
dirName: "aws_sqs_queue_empty",
|
||||
mocks: func(client *repository2.MockSQSRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(client *repository.MockSQSRepository, alerter *mocks.AlerterInterface) {
|
||||
awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "")
|
||||
client.On("ListAllQueues").Return(nil, awsError)
|
||||
|
||||
|
@ -87,9 +87,9 @@ func TestSQSQueue(t *testing.T) {
|
|||
|
||||
// Initialize mocks
|
||||
alerter := &mocks.AlerterInterface{}
|
||||
fakeRepo := &repository2.MockSQSRepository{}
|
||||
fakeRepo := &repository.MockSQSRepository{}
|
||||
c.mocks(fakeRepo, alerter)
|
||||
var repo repository2.SQSRepository = fakeRepo
|
||||
var repo repository.SQSRepository = fakeRepo
|
||||
providerVersion := "3.19.0"
|
||||
realProvider, err := terraform2.InitTestAwsProvider(providerLibrary, providerVersion)
|
||||
if err != nil {
|
||||
|
@ -105,7 +105,7 @@ func TestSQSQueue(t *testing.T) {
|
|||
t.Fatal(err)
|
||||
}
|
||||
provider.ShouldUpdate()
|
||||
repo = repository2.NewSQSRepository(sess, cache.New(0))
|
||||
repo = repository.NewSQSRepository(sess, cache.New(0))
|
||||
}
|
||||
|
||||
remoteLibrary.AddEnumerator(aws2.NewSQSQueueEnumerator(repo, factory))
|
||||
|
@ -131,7 +131,7 @@ func TestSQSQueuePolicy(t *testing.T) {
|
|||
cases := []struct {
|
||||
test string
|
||||
dirName string
|
||||
mocks func(*repository2.MockSQSRepository, *mocks.AlerterInterface)
|
||||
mocks func(*repository.MockSQSRepository, *mocks.AlerterInterface)
|
||||
wantErr error
|
||||
}{
|
||||
{
|
||||
|
@ -139,7 +139,7 @@ func TestSQSQueuePolicy(t *testing.T) {
|
|||
// as a default SQSDefaultPolicy (e.g. policy="") will always be present in each queue
|
||||
test: "no sqs queue policies",
|
||||
dirName: "aws_sqs_queue_policy_empty",
|
||||
mocks: func(client *repository2.MockSQSRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(client *repository.MockSQSRepository, alerter *mocks.AlerterInterface) {
|
||||
client.On("ListAllQueues").Return([]*string{}, nil)
|
||||
},
|
||||
wantErr: nil,
|
||||
|
@ -147,7 +147,7 @@ func TestSQSQueuePolicy(t *testing.T) {
|
|||
{
|
||||
test: "multiple sqs queue policies (default or not)",
|
||||
dirName: "aws_sqs_queue_policy_multiple",
|
||||
mocks: func(client *repository2.MockSQSRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(client *repository.MockSQSRepository, alerter *mocks.AlerterInterface) {
|
||||
client.On("ListAllQueues").Return([]*string{
|
||||
awssdk.String("https://sqs.eu-west-3.amazonaws.com/047081014315/bar.fifo"),
|
||||
awssdk.String("https://sqs.eu-west-3.amazonaws.com/047081014315/foo"),
|
||||
|
@ -168,7 +168,7 @@ func TestSQSQueuePolicy(t *testing.T) {
|
|||
{
|
||||
test: "multiple sqs queue policies (with nil attributes)",
|
||||
dirName: "aws_sqs_queue_policy_multiple",
|
||||
mocks: func(client *repository2.MockSQSRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(client *repository.MockSQSRepository, alerter *mocks.AlerterInterface) {
|
||||
client.On("ListAllQueues").Return([]*string{
|
||||
awssdk.String("https://sqs.eu-west-3.amazonaws.com/047081014315/bar.fifo"),
|
||||
awssdk.String("https://sqs.eu-west-3.amazonaws.com/047081014315/foo"),
|
||||
|
@ -185,7 +185,7 @@ func TestSQSQueuePolicy(t *testing.T) {
|
|||
{
|
||||
test: "cannot list sqs queues, thus sqs queue policies",
|
||||
dirName: "aws_sqs_queue_policy_empty",
|
||||
mocks: func(client *repository2.MockSQSRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(client *repository.MockSQSRepository, alerter *mocks.AlerterInterface) {
|
||||
awsError := awserr.NewRequestFailure(awserr.New("AccessDeniedException", "", errors.New("")), 403, "")
|
||||
client.On("ListAllQueues").Return(nil, awsError)
|
||||
|
||||
|
@ -214,9 +214,9 @@ func TestSQSQueuePolicy(t *testing.T) {
|
|||
|
||||
// Initialize mocks
|
||||
alerter := &mocks.AlerterInterface{}
|
||||
fakeRepo := &repository2.MockSQSRepository{}
|
||||
fakeRepo := &repository.MockSQSRepository{}
|
||||
c.mocks(fakeRepo, alerter)
|
||||
var repo repository2.SQSRepository = fakeRepo
|
||||
var repo repository.SQSRepository = fakeRepo
|
||||
providerVersion := "3.19.0"
|
||||
realProvider, err := terraform2.InitTestAwsProvider(providerLibrary, providerVersion)
|
||||
if err != nil {
|
||||
|
@ -232,7 +232,7 @@ func TestSQSQueuePolicy(t *testing.T) {
|
|||
t.Fatal(err)
|
||||
}
|
||||
provider.ShouldUpdate()
|
||||
repo = repository2.NewSQSRepository(sess, cache.New(0))
|
||||
repo = repository.NewSQSRepository(sess, cache.New(0))
|
||||
}
|
||||
|
||||
remoteLibrary.AddEnumerator(aws2.NewSQSQueuePolicyEnumerator(repo, factory))
|
||||
|
|
|
@ -5,7 +5,7 @@ import (
|
|||
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
|
||||
"github.com/snyk/driftctl/enumeration"
|
||||
"github.com/snyk/driftctl/enumeration/alerter"
|
||||
repository2 "github.com/snyk/driftctl/enumeration/remote/azurerm/repository"
|
||||
"github.com/snyk/driftctl/enumeration/remote/azurerm/repository"
|
||||
"github.com/snyk/driftctl/enumeration/remote/cache"
|
||||
common2 "github.com/snyk/driftctl/enumeration/remote/common"
|
||||
"github.com/snyk/driftctl/enumeration/resource"
|
||||
|
@ -45,13 +45,13 @@ func Init(
|
|||
|
||||
c := cache.New(100)
|
||||
|
||||
storageAccountRepo := repository2.NewStorageRepository(cred, clientOptions, providerConfig, c)
|
||||
networkRepo := repository2.NewNetworkRepository(cred, clientOptions, providerConfig, c)
|
||||
resourcesRepo := repository2.NewResourcesRepository(cred, clientOptions, providerConfig, c)
|
||||
containerRegistryRepo := repository2.NewContainerRegistryRepository(cred, clientOptions, providerConfig, c)
|
||||
postgresqlRepo := repository2.NewPostgresqlRepository(cred, clientOptions, providerConfig, c)
|
||||
privateDNSRepo := repository2.NewPrivateDNSRepository(cred, clientOptions, providerConfig, c)
|
||||
computeRepo := repository2.NewComputeRepository(cred, clientOptions, providerConfig, c)
|
||||
storageAccountRepo := repository.NewStorageRepository(cred, clientOptions, providerConfig, c)
|
||||
networkRepo := repository.NewNetworkRepository(cred, clientOptions, providerConfig, c)
|
||||
resourcesRepo := repository.NewResourcesRepository(cred, clientOptions, providerConfig, c)
|
||||
containerRegistryRepo := repository.NewContainerRegistryRepository(cred, clientOptions, providerConfig, c)
|
||||
postgresqlRepo := repository.NewPostgresqlRepository(cred, clientOptions, providerConfig, c)
|
||||
privateDNSRepo := repository.NewPrivateDNSRepository(cred, clientOptions, providerConfig, c)
|
||||
computeRepo := repository.NewComputeRepository(cred, clientOptions, providerConfig, c)
|
||||
|
||||
providerLibrary.AddProvider(terraform.AZURE, provider)
|
||||
deserializer := resource.NewDeserializer(factory)
|
||||
|
|
|
@ -5,7 +5,7 @@ import (
|
|||
|
||||
"github.com/snyk/driftctl/enumeration"
|
||||
azurerm2 "github.com/snyk/driftctl/enumeration/remote/azurerm"
|
||||
repository2 "github.com/snyk/driftctl/enumeration/remote/azurerm/repository"
|
||||
"github.com/snyk/driftctl/enumeration/remote/azurerm/repository"
|
||||
"github.com/snyk/driftctl/enumeration/remote/cache"
|
||||
common2 "github.com/snyk/driftctl/enumeration/remote/common"
|
||||
remoteerr "github.com/snyk/driftctl/enumeration/remote/error"
|
||||
|
@ -34,13 +34,13 @@ func TestAzurermCompute_Image(t *testing.T) {
|
|||
|
||||
tests := []struct {
|
||||
test string
|
||||
mocks func(*repository2.MockComputeRepository, *mocks.AlerterInterface)
|
||||
mocks func(*repository.MockComputeRepository, *mocks.AlerterInterface)
|
||||
assertExpected func(t *testing.T, got []*resource.Resource)
|
||||
wantErr error
|
||||
}{
|
||||
{
|
||||
test: "no images",
|
||||
mocks: func(repository *repository2.MockComputeRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockComputeRepository, alerter *mocks.AlerterInterface) {
|
||||
repository.On("ListAllImages").Return([]*armcompute.Image{}, nil)
|
||||
},
|
||||
assertExpected: func(t *testing.T, got []*resource.Resource) {
|
||||
|
@ -49,14 +49,14 @@ func TestAzurermCompute_Image(t *testing.T) {
|
|||
},
|
||||
{
|
||||
test: "error listing images",
|
||||
mocks: func(repository *repository2.MockComputeRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockComputeRepository, alerter *mocks.AlerterInterface) {
|
||||
repository.On("ListAllImages").Return(nil, dummyError)
|
||||
},
|
||||
wantErr: remoteerr.NewResourceListingError(dummyError, resourceazure.AzureImageResourceType),
|
||||
},
|
||||
{
|
||||
test: "multiple images including an invalid ID",
|
||||
mocks: func(repository *repository2.MockComputeRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockComputeRepository, alerter *mocks.AlerterInterface) {
|
||||
repository.On("ListAllImages").Return([]*armcompute.Image{
|
||||
{
|
||||
Resource: armcompute.Resource{
|
||||
|
@ -102,7 +102,7 @@ func TestAzurermCompute_Image(t *testing.T) {
|
|||
|
||||
// Initialize mocks
|
||||
alerter := &mocks.AlerterInterface{}
|
||||
fakeRepo := &repository2.MockComputeRepository{}
|
||||
fakeRepo := &repository.MockComputeRepository{}
|
||||
c.mocks(fakeRepo, alerter)
|
||||
|
||||
remoteLibrary.AddEnumerator(azurerm2.NewAzurermImageEnumerator(fakeRepo, factory))
|
||||
|
@ -131,20 +131,20 @@ func TestAzurermCompute_SSHPublicKey(t *testing.T) {
|
|||
tests := []struct {
|
||||
test string
|
||||
dirName string
|
||||
mocks func(*repository2.MockComputeRepository, *mocks.AlerterInterface)
|
||||
mocks func(*repository.MockComputeRepository, *mocks.AlerterInterface)
|
||||
wantErr error
|
||||
}{
|
||||
{
|
||||
test: "no public key",
|
||||
dirName: "azurerm_ssh_public_key_empty",
|
||||
mocks: func(repository *repository2.MockComputeRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockComputeRepository, alerter *mocks.AlerterInterface) {
|
||||
repository.On("ListAllSSHPublicKeys").Return([]*armcompute.SSHPublicKeyResource{}, nil)
|
||||
},
|
||||
},
|
||||
{
|
||||
test: "error listing public keys",
|
||||
dirName: "azurerm_ssh_public_key_empty",
|
||||
mocks: func(repository *repository2.MockComputeRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockComputeRepository, alerter *mocks.AlerterInterface) {
|
||||
repository.On("ListAllSSHPublicKeys").Return(nil, dummyError)
|
||||
},
|
||||
wantErr: remoteerr.NewResourceListingError(dummyError, resourceazure.AzureSSHPublicKeyResourceType),
|
||||
|
@ -152,7 +152,7 @@ func TestAzurermCompute_SSHPublicKey(t *testing.T) {
|
|||
{
|
||||
test: "multiple public keys",
|
||||
dirName: "azurerm_ssh_public_key_multiple",
|
||||
mocks: func(repository *repository2.MockComputeRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockComputeRepository, alerter *mocks.AlerterInterface) {
|
||||
repository.On("ListAllSSHPublicKeys").Return([]*armcompute.SSHPublicKeyResource{
|
||||
{
|
||||
Resource: armcompute.Resource{
|
||||
|
@ -187,10 +187,10 @@ func TestAzurermCompute_SSHPublicKey(t *testing.T) {
|
|||
|
||||
// Initialize mocks
|
||||
alerter := &mocks.AlerterInterface{}
|
||||
fakeRepo := &repository2.MockComputeRepository{}
|
||||
fakeRepo := &repository.MockComputeRepository{}
|
||||
c.mocks(fakeRepo, alerter)
|
||||
|
||||
var repo repository2.ComputeRepository = fakeRepo
|
||||
var repo repository.ComputeRepository = fakeRepo
|
||||
providerVersion := "2.71.0"
|
||||
realProvider, err := terraform2.InitTestAzureProvider(providerLibrary, providerVersion)
|
||||
if err != nil {
|
||||
|
@ -211,7 +211,7 @@ func TestAzurermCompute_SSHPublicKey(t *testing.T) {
|
|||
t.Fatal(err)
|
||||
}
|
||||
clientOptions := &arm.ClientOptions{}
|
||||
repo = repository2.NewComputeRepository(cred, clientOptions, realProvider.GetConfig(), cache.New(0))
|
||||
repo = repository.NewComputeRepository(cred, clientOptions, realProvider.GetConfig(), cache.New(0))
|
||||
}
|
||||
|
||||
remoteLibrary.AddEnumerator(azurerm2.NewAzurermSSHPublicKeyEnumerator(repo, factory))
|
||||
|
|
|
@ -5,7 +5,7 @@ import (
|
|||
|
||||
"github.com/snyk/driftctl/enumeration"
|
||||
"github.com/snyk/driftctl/enumeration/remote/azurerm"
|
||||
repository2 "github.com/snyk/driftctl/enumeration/remote/azurerm/repository"
|
||||
"github.com/snyk/driftctl/enumeration/remote/azurerm/repository"
|
||||
"github.com/snyk/driftctl/enumeration/remote/common"
|
||||
error2 "github.com/snyk/driftctl/enumeration/remote/error"
|
||||
"github.com/snyk/driftctl/enumeration/terraform"
|
||||
|
@ -28,13 +28,13 @@ func TestAzurermContainerRegistry(t *testing.T) {
|
|||
|
||||
tests := []struct {
|
||||
test string
|
||||
mocks func(*repository2.MockContainerRegistryRepository, *mocks.AlerterInterface)
|
||||
mocks func(*repository.MockContainerRegistryRepository, *mocks.AlerterInterface)
|
||||
assertExpected func(t *testing.T, got []*resource.Resource)
|
||||
wantErr error
|
||||
}{
|
||||
{
|
||||
test: "no container registry",
|
||||
mocks: func(repository *repository2.MockContainerRegistryRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockContainerRegistryRepository, alerter *mocks.AlerterInterface) {
|
||||
repository.On("ListAllContainerRegistries").Return([]*armcontainerregistry.Registry{}, nil)
|
||||
},
|
||||
assertExpected: func(t *testing.T, got []*resource.Resource) {
|
||||
|
@ -43,14 +43,14 @@ func TestAzurermContainerRegistry(t *testing.T) {
|
|||
},
|
||||
{
|
||||
test: "error listing container registry",
|
||||
mocks: func(repository *repository2.MockContainerRegistryRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockContainerRegistryRepository, alerter *mocks.AlerterInterface) {
|
||||
repository.On("ListAllContainerRegistries").Return(nil, dummyError)
|
||||
},
|
||||
wantErr: error2.NewResourceListingError(dummyError, resourceazure.AzureContainerRegistryResourceType),
|
||||
},
|
||||
{
|
||||
test: "multiple container registries",
|
||||
mocks: func(repository *repository2.MockContainerRegistryRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockContainerRegistryRepository, alerter *mocks.AlerterInterface) {
|
||||
repository.On("ListAllContainerRegistries").Return([]*armcontainerregistry.Registry{
|
||||
{
|
||||
Resource: armcontainerregistry.Resource{
|
||||
|
@ -89,10 +89,10 @@ func TestAzurermContainerRegistry(t *testing.T) {
|
|||
|
||||
// Initialize mocks
|
||||
alerter := &mocks.AlerterInterface{}
|
||||
fakeRepo := &repository2.MockContainerRegistryRepository{}
|
||||
fakeRepo := &repository.MockContainerRegistryRepository{}
|
||||
c.mocks(fakeRepo, alerter)
|
||||
|
||||
var repo repository2.ContainerRegistryRepository = fakeRepo
|
||||
var repo repository.ContainerRegistryRepository = fakeRepo
|
||||
|
||||
remoteLibrary.AddEnumerator(azurerm.NewAzurermContainerRegistryEnumerator(repo, factory))
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ import (
|
|||
|
||||
"github.com/snyk/driftctl/enumeration"
|
||||
azurerm2 "github.com/snyk/driftctl/enumeration/remote/azurerm"
|
||||
repository2 "github.com/snyk/driftctl/enumeration/remote/azurerm/repository"
|
||||
"github.com/snyk/driftctl/enumeration/remote/azurerm/repository"
|
||||
"github.com/snyk/driftctl/enumeration/remote/cache"
|
||||
common2 "github.com/snyk/driftctl/enumeration/remote/common"
|
||||
error2 "github.com/snyk/driftctl/enumeration/remote/error"
|
||||
|
@ -34,13 +34,13 @@ func TestAzurermVirtualNetwork(t *testing.T) {
|
|||
|
||||
tests := []struct {
|
||||
test string
|
||||
mocks func(*repository2.MockNetworkRepository, *mocks.AlerterInterface)
|
||||
mocks func(*repository.MockNetworkRepository, *mocks.AlerterInterface)
|
||||
assertExpected func(t *testing.T, got []*resource.Resource)
|
||||
wantErr error
|
||||
}{
|
||||
{
|
||||
test: "no virtual network",
|
||||
mocks: func(repository *repository2.MockNetworkRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockNetworkRepository, alerter *mocks.AlerterInterface) {
|
||||
repository.On("ListAllVirtualNetworks").Return([]*armnetwork.VirtualNetwork{}, nil)
|
||||
},
|
||||
assertExpected: func(t *testing.T, got []*resource.Resource) {
|
||||
|
@ -49,14 +49,14 @@ func TestAzurermVirtualNetwork(t *testing.T) {
|
|||
},
|
||||
{
|
||||
test: "error listing virtual network",
|
||||
mocks: func(repository *repository2.MockNetworkRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockNetworkRepository, alerter *mocks.AlerterInterface) {
|
||||
repository.On("ListAllVirtualNetworks").Return(nil, dummyError)
|
||||
},
|
||||
wantErr: error2.NewResourceListingError(dummyError, resourceazure.AzureVirtualNetworkResourceType),
|
||||
},
|
||||
{
|
||||
test: "multiple virtual network",
|
||||
mocks: func(repository *repository2.MockNetworkRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockNetworkRepository, alerter *mocks.AlerterInterface) {
|
||||
repository.On("ListAllVirtualNetworks").Return([]*armnetwork.VirtualNetwork{
|
||||
{
|
||||
Resource: armnetwork.Resource{
|
||||
|
@ -97,10 +97,10 @@ func TestAzurermVirtualNetwork(t *testing.T) {
|
|||
|
||||
// Initialize mocks
|
||||
alerter := &mocks.AlerterInterface{}
|
||||
fakeRepo := &repository2.MockNetworkRepository{}
|
||||
fakeRepo := &repository.MockNetworkRepository{}
|
||||
c.mocks(fakeRepo, alerter)
|
||||
|
||||
var repo repository2.NetworkRepository = fakeRepo
|
||||
var repo repository.NetworkRepository = fakeRepo
|
||||
|
||||
remoteLibrary.AddEnumerator(azurerm2.NewAzurermVirtualNetworkEnumerator(repo, factory))
|
||||
|
||||
|
@ -127,13 +127,13 @@ func TestAzurermRouteTables(t *testing.T) {
|
|||
|
||||
tests := []struct {
|
||||
test string
|
||||
mocks func(*repository2.MockNetworkRepository, *mocks.AlerterInterface)
|
||||
mocks func(*repository.MockNetworkRepository, *mocks.AlerterInterface)
|
||||
assertExpected func(t *testing.T, got []*resource.Resource)
|
||||
wantErr error
|
||||
}{
|
||||
{
|
||||
test: "no route tables",
|
||||
mocks: func(repository *repository2.MockNetworkRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockNetworkRepository, alerter *mocks.AlerterInterface) {
|
||||
repository.On("ListAllRouteTables").Return([]*armnetwork.RouteTable{}, nil)
|
||||
},
|
||||
assertExpected: func(t *testing.T, got []*resource.Resource) {
|
||||
|
@ -142,14 +142,14 @@ func TestAzurermRouteTables(t *testing.T) {
|
|||
},
|
||||
{
|
||||
test: "error listing route tables",
|
||||
mocks: func(repository *repository2.MockNetworkRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockNetworkRepository, alerter *mocks.AlerterInterface) {
|
||||
repository.On("ListAllRouteTables").Return(nil, dummyError)
|
||||
},
|
||||
wantErr: error2.NewResourceListingError(dummyError, resourceazure.AzureRouteTableResourceType),
|
||||
},
|
||||
{
|
||||
test: "multiple route tables",
|
||||
mocks: func(repository *repository2.MockNetworkRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockNetworkRepository, alerter *mocks.AlerterInterface) {
|
||||
repository.On("ListAllRouteTables").Return([]*armnetwork.RouteTable{
|
||||
{
|
||||
Resource: armnetwork.Resource{
|
||||
|
@ -190,10 +190,10 @@ func TestAzurermRouteTables(t *testing.T) {
|
|||
|
||||
// Initialize mocks
|
||||
alerter := &mocks.AlerterInterface{}
|
||||
fakeRepo := &repository2.MockNetworkRepository{}
|
||||
fakeRepo := &repository.MockNetworkRepository{}
|
||||
c.mocks(fakeRepo, alerter)
|
||||
|
||||
var repo repository2.NetworkRepository = fakeRepo
|
||||
var repo repository.NetworkRepository = fakeRepo
|
||||
|
||||
remoteLibrary.AddEnumerator(azurerm2.NewAzurermRouteTableEnumerator(repo, factory))
|
||||
|
||||
|
@ -220,13 +220,13 @@ func TestAzurermRoutes(t *testing.T) {
|
|||
|
||||
tests := []struct {
|
||||
test string
|
||||
mocks func(*repository2.MockNetworkRepository, *mocks.AlerterInterface)
|
||||
mocks func(*repository.MockNetworkRepository, *mocks.AlerterInterface)
|
||||
assertExpected func(t *testing.T, got []*resource.Resource)
|
||||
wantErr error
|
||||
}{
|
||||
{
|
||||
test: "no route tables",
|
||||
mocks: func(repository *repository2.MockNetworkRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockNetworkRepository, alerter *mocks.AlerterInterface) {
|
||||
repository.On("ListAllRouteTables").Return([]*armnetwork.RouteTable{}, nil)
|
||||
},
|
||||
assertExpected: func(t *testing.T, got []*resource.Resource) {
|
||||
|
@ -235,7 +235,7 @@ func TestAzurermRoutes(t *testing.T) {
|
|||
},
|
||||
{
|
||||
test: "no routes",
|
||||
mocks: func(repository *repository2.MockNetworkRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockNetworkRepository, alerter *mocks.AlerterInterface) {
|
||||
repository.On("ListAllRouteTables").Return([]*armnetwork.RouteTable{
|
||||
{
|
||||
Properties: &armnetwork.RouteTablePropertiesFormat{
|
||||
|
@ -255,14 +255,14 @@ func TestAzurermRoutes(t *testing.T) {
|
|||
},
|
||||
{
|
||||
test: "error listing route tables",
|
||||
mocks: func(repository *repository2.MockNetworkRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockNetworkRepository, alerter *mocks.AlerterInterface) {
|
||||
repository.On("ListAllRouteTables").Return(nil, dummyError)
|
||||
},
|
||||
wantErr: error2.NewResourceListingErrorWithType(dummyError, resourceazure.AzureRouteResourceType, resourceazure.AzureRouteTableResourceType),
|
||||
},
|
||||
{
|
||||
test: "multiple routes",
|
||||
mocks: func(repository *repository2.MockNetworkRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockNetworkRepository, alerter *mocks.AlerterInterface) {
|
||||
repository.On("ListAllRouteTables").Return([]*armnetwork.RouteTable{
|
||||
{
|
||||
Resource: armnetwork.Resource{
|
||||
|
@ -339,10 +339,10 @@ func TestAzurermRoutes(t *testing.T) {
|
|||
|
||||
// Initialize mocks
|
||||
alerter := &mocks.AlerterInterface{}
|
||||
fakeRepo := &repository2.MockNetworkRepository{}
|
||||
fakeRepo := &repository.MockNetworkRepository{}
|
||||
c.mocks(fakeRepo, alerter)
|
||||
|
||||
var repo repository2.NetworkRepository = fakeRepo
|
||||
var repo repository.NetworkRepository = fakeRepo
|
||||
|
||||
remoteLibrary.AddEnumerator(azurerm2.NewAzurermRouteEnumerator(repo, factory))
|
||||
|
||||
|
@ -382,13 +382,13 @@ func TestAzurermSubnets(t *testing.T) {
|
|||
|
||||
tests := []struct {
|
||||
test string
|
||||
mocks func(*repository2.MockNetworkRepository, *mocks.AlerterInterface)
|
||||
mocks func(*repository.MockNetworkRepository, *mocks.AlerterInterface)
|
||||
assertExpected func(t *testing.T, got []*resource.Resource)
|
||||
wantErr error
|
||||
}{
|
||||
{
|
||||
test: "no subnets",
|
||||
mocks: func(repository *repository2.MockNetworkRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockNetworkRepository, alerter *mocks.AlerterInterface) {
|
||||
repository.On("ListAllVirtualNetworks").Return(networks, nil)
|
||||
repository.On("ListAllSubnets", networks[0]).Return([]*armnetwork.Subnet{}, nil).Times(1)
|
||||
repository.On("ListAllSubnets", networks[1]).Return([]*armnetwork.Subnet{}, nil).Times(1)
|
||||
|
@ -399,14 +399,14 @@ func TestAzurermSubnets(t *testing.T) {
|
|||
},
|
||||
{
|
||||
test: "error listing virtual network",
|
||||
mocks: func(repository *repository2.MockNetworkRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockNetworkRepository, alerter *mocks.AlerterInterface) {
|
||||
repository.On("ListAllVirtualNetworks").Return(nil, dummyError)
|
||||
},
|
||||
wantErr: error2.NewResourceListingErrorWithType(dummyError, resourceazure.AzureSubnetResourceType, resourceazure.AzureVirtualNetworkResourceType),
|
||||
},
|
||||
{
|
||||
test: "error listing subnets",
|
||||
mocks: func(repository *repository2.MockNetworkRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockNetworkRepository, alerter *mocks.AlerterInterface) {
|
||||
repository.On("ListAllVirtualNetworks").Return(networks, nil)
|
||||
repository.On("ListAllSubnets", networks[0]).Return(nil, dummyError).Times(1)
|
||||
},
|
||||
|
@ -414,7 +414,7 @@ func TestAzurermSubnets(t *testing.T) {
|
|||
},
|
||||
{
|
||||
test: "multiple subnets",
|
||||
mocks: func(repository *repository2.MockNetworkRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockNetworkRepository, alerter *mocks.AlerterInterface) {
|
||||
repository.On("ListAllVirtualNetworks").Return(networks, nil)
|
||||
repository.On("ListAllSubnets", networks[0]).Return([]*armnetwork.Subnet{
|
||||
{
|
||||
|
@ -472,10 +472,10 @@ func TestAzurermSubnets(t *testing.T) {
|
|||
|
||||
// Initialize mocks
|
||||
alerter := &mocks.AlerterInterface{}
|
||||
fakeRepo := &repository2.MockNetworkRepository{}
|
||||
fakeRepo := &repository.MockNetworkRepository{}
|
||||
c.mocks(fakeRepo, alerter)
|
||||
|
||||
var repo repository2.NetworkRepository = fakeRepo
|
||||
var repo repository.NetworkRepository = fakeRepo
|
||||
|
||||
remoteLibrary.AddEnumerator(azurerm2.NewAzurermSubnetEnumerator(repo, factory))
|
||||
|
||||
|
@ -502,13 +502,13 @@ func TestAzurermFirewalls(t *testing.T) {
|
|||
|
||||
tests := []struct {
|
||||
test string
|
||||
mocks func(*repository2.MockNetworkRepository, *mocks.AlerterInterface)
|
||||
mocks func(*repository.MockNetworkRepository, *mocks.AlerterInterface)
|
||||
assertExpected func(t *testing.T, got []*resource.Resource)
|
||||
wantErr error
|
||||
}{
|
||||
{
|
||||
test: "no firewall",
|
||||
mocks: func(repository *repository2.MockNetworkRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockNetworkRepository, alerter *mocks.AlerterInterface) {
|
||||
repository.On("ListAllFirewalls").Return([]*armnetwork.AzureFirewall{}, nil)
|
||||
},
|
||||
assertExpected: func(t *testing.T, got []*resource.Resource) {
|
||||
|
@ -517,14 +517,14 @@ func TestAzurermFirewalls(t *testing.T) {
|
|||
},
|
||||
{
|
||||
test: "error listing firewalls",
|
||||
mocks: func(repository *repository2.MockNetworkRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockNetworkRepository, alerter *mocks.AlerterInterface) {
|
||||
repository.On("ListAllFirewalls").Return(nil, dummyError)
|
||||
},
|
||||
wantErr: error2.NewResourceListingError(dummyError, resourceazure.AzureFirewallResourceType),
|
||||
},
|
||||
{
|
||||
test: "multiple firewalls",
|
||||
mocks: func(repository *repository2.MockNetworkRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockNetworkRepository, alerter *mocks.AlerterInterface) {
|
||||
repository.On("ListAllFirewalls").Return([]*armnetwork.AzureFirewall{
|
||||
{
|
||||
Resource: armnetwork.Resource{
|
||||
|
@ -565,10 +565,10 @@ func TestAzurermFirewalls(t *testing.T) {
|
|||
|
||||
// Initialize mocks
|
||||
alerter := &mocks.AlerterInterface{}
|
||||
fakeRepo := &repository2.MockNetworkRepository{}
|
||||
fakeRepo := &repository.MockNetworkRepository{}
|
||||
c.mocks(fakeRepo, alerter)
|
||||
|
||||
var repo repository2.NetworkRepository = fakeRepo
|
||||
var repo repository.NetworkRepository = fakeRepo
|
||||
|
||||
remoteLibrary.AddEnumerator(azurerm2.NewAzurermFirewallsEnumerator(repo, factory))
|
||||
|
||||
|
@ -595,13 +595,13 @@ func TestAzurermPublicIP(t *testing.T) {
|
|||
|
||||
tests := []struct {
|
||||
test string
|
||||
mocks func(*repository2.MockNetworkRepository, *mocks.AlerterInterface)
|
||||
mocks func(*repository.MockNetworkRepository, *mocks.AlerterInterface)
|
||||
assertExpected func(t *testing.T, got []*resource.Resource)
|
||||
wantErr error
|
||||
}{
|
||||
{
|
||||
test: "no public IP",
|
||||
mocks: func(repository *repository2.MockNetworkRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockNetworkRepository, alerter *mocks.AlerterInterface) {
|
||||
repository.On("ListAllPublicIPAddresses").Return([]*armnetwork.PublicIPAddress{}, nil)
|
||||
},
|
||||
assertExpected: func(t *testing.T, got []*resource.Resource) {
|
||||
|
@ -610,14 +610,14 @@ func TestAzurermPublicIP(t *testing.T) {
|
|||
},
|
||||
{
|
||||
test: "error listing public IPs",
|
||||
mocks: func(repository *repository2.MockNetworkRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockNetworkRepository, alerter *mocks.AlerterInterface) {
|
||||
repository.On("ListAllPublicIPAddresses").Return(nil, dummyError)
|
||||
},
|
||||
wantErr: error2.NewResourceListingError(dummyError, resourceazure.AzurePublicIPResourceType),
|
||||
},
|
||||
{
|
||||
test: "multiple public IP",
|
||||
mocks: func(repository *repository2.MockNetworkRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockNetworkRepository, alerter *mocks.AlerterInterface) {
|
||||
repository.On("ListAllPublicIPAddresses").Return([]*armnetwork.PublicIPAddress{
|
||||
{
|
||||
Resource: armnetwork.Resource{
|
||||
|
@ -658,10 +658,10 @@ func TestAzurermPublicIP(t *testing.T) {
|
|||
|
||||
// Initialize mocks
|
||||
alerter := &mocks.AlerterInterface{}
|
||||
fakeRepo := &repository2.MockNetworkRepository{}
|
||||
fakeRepo := &repository.MockNetworkRepository{}
|
||||
c.mocks(fakeRepo, alerter)
|
||||
|
||||
var repo repository2.NetworkRepository = fakeRepo
|
||||
var repo repository.NetworkRepository = fakeRepo
|
||||
|
||||
remoteLibrary.AddEnumerator(azurerm2.NewAzurermPublicIPEnumerator(repo, factory))
|
||||
|
||||
|
@ -689,20 +689,20 @@ func TestAzurermSecurityGroups(t *testing.T) {
|
|||
tests := []struct {
|
||||
test string
|
||||
dirName string
|
||||
mocks func(*repository2.MockNetworkRepository, *mocks.AlerterInterface)
|
||||
mocks func(*repository.MockNetworkRepository, *mocks.AlerterInterface)
|
||||
wantErr error
|
||||
}{
|
||||
{
|
||||
test: "no security group",
|
||||
dirName: "azurerm_network_security_group_empty",
|
||||
mocks: func(repository *repository2.MockNetworkRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockNetworkRepository, alerter *mocks.AlerterInterface) {
|
||||
repository.On("ListAllSecurityGroups").Return([]*armnetwork.NetworkSecurityGroup{}, nil)
|
||||
},
|
||||
},
|
||||
{
|
||||
test: "error listing security groups",
|
||||
dirName: "azurerm_network_security_group_empty",
|
||||
mocks: func(repository *repository2.MockNetworkRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockNetworkRepository, alerter *mocks.AlerterInterface) {
|
||||
repository.On("ListAllSecurityGroups").Return(nil, dummyError)
|
||||
},
|
||||
wantErr: error2.NewResourceListingError(dummyError, resourceazure.AzureNetworkSecurityGroupResourceType),
|
||||
|
@ -710,7 +710,7 @@ func TestAzurermSecurityGroups(t *testing.T) {
|
|||
{
|
||||
test: "multiple security groups",
|
||||
dirName: "azurerm_network_security_group_multiple",
|
||||
mocks: func(repository *repository2.MockNetworkRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockNetworkRepository, alerter *mocks.AlerterInterface) {
|
||||
repository.On("ListAllSecurityGroups").Return([]*armnetwork.NetworkSecurityGroup{
|
||||
{
|
||||
Resource: armnetwork.Resource{
|
||||
|
@ -745,10 +745,10 @@ func TestAzurermSecurityGroups(t *testing.T) {
|
|||
|
||||
// Initialize mocks
|
||||
alerter := &mocks.AlerterInterface{}
|
||||
fakeRepo := &repository2.MockNetworkRepository{}
|
||||
fakeRepo := &repository.MockNetworkRepository{}
|
||||
c.mocks(fakeRepo, alerter)
|
||||
|
||||
var repo repository2.NetworkRepository = fakeRepo
|
||||
var repo repository.NetworkRepository = fakeRepo
|
||||
providerVersion := "2.71.0"
|
||||
realProvider, err := terraform2.InitTestAzureProvider(providerLibrary, providerVersion)
|
||||
if err != nil {
|
||||
|
@ -769,7 +769,7 @@ func TestAzurermSecurityGroups(t *testing.T) {
|
|||
t.Fatal(err)
|
||||
}
|
||||
clientOptions := &arm.ClientOptions{}
|
||||
repo = repository2.NewNetworkRepository(cred, clientOptions, realProvider.GetConfig(), cache.New(0))
|
||||
repo = repository.NewNetworkRepository(cred, clientOptions, realProvider.GetConfig(), cache.New(0))
|
||||
}
|
||||
|
||||
remoteLibrary.AddEnumerator(azurerm2.NewAzurermNetworkSecurityGroupEnumerator(repo, factory))
|
||||
|
@ -798,13 +798,13 @@ func TestAzurermLoadBalancers(t *testing.T) {
|
|||
|
||||
tests := []struct {
|
||||
test string
|
||||
mocks func(*repository2.MockNetworkRepository, *mocks.AlerterInterface)
|
||||
mocks func(*repository.MockNetworkRepository, *mocks.AlerterInterface)
|
||||
assertExpected func(t *testing.T, got []*resource.Resource)
|
||||
wantErr error
|
||||
}{
|
||||
{
|
||||
test: "no load balancer",
|
||||
mocks: func(repository *repository2.MockNetworkRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockNetworkRepository, alerter *mocks.AlerterInterface) {
|
||||
repository.On("ListAllLoadBalancers").Return([]*armnetwork.LoadBalancer{}, nil)
|
||||
},
|
||||
assertExpected: func(t *testing.T, got []*resource.Resource) {
|
||||
|
@ -813,14 +813,14 @@ func TestAzurermLoadBalancers(t *testing.T) {
|
|||
},
|
||||
{
|
||||
test: "error listing load balancers",
|
||||
mocks: func(repository *repository2.MockNetworkRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockNetworkRepository, alerter *mocks.AlerterInterface) {
|
||||
repository.On("ListAllLoadBalancers").Return(nil, dummyError)
|
||||
},
|
||||
wantErr: error2.NewResourceListingError(dummyError, resourceazure.AzureLoadBalancerResourceType),
|
||||
},
|
||||
{
|
||||
test: "multiple load balancers",
|
||||
mocks: func(repository *repository2.MockNetworkRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockNetworkRepository, alerter *mocks.AlerterInterface) {
|
||||
repository.On("ListAllLoadBalancers").Return([]*armnetwork.LoadBalancer{
|
||||
{
|
||||
Resource: armnetwork.Resource{
|
||||
|
@ -861,10 +861,10 @@ func TestAzurermLoadBalancers(t *testing.T) {
|
|||
|
||||
// Initialize mocks
|
||||
alerter := &mocks.AlerterInterface{}
|
||||
fakeRepo := &repository2.MockNetworkRepository{}
|
||||
fakeRepo := &repository.MockNetworkRepository{}
|
||||
c.mocks(fakeRepo, alerter)
|
||||
|
||||
var repo repository2.NetworkRepository = fakeRepo
|
||||
var repo repository.NetworkRepository = fakeRepo
|
||||
|
||||
remoteLibrary.AddEnumerator(azurerm2.NewAzurermLoadBalancerEnumerator(repo, factory))
|
||||
|
||||
|
@ -892,13 +892,13 @@ func TestAzurermLoadBalancerRules(t *testing.T) {
|
|||
tests := []struct {
|
||||
test string
|
||||
dirName string
|
||||
mocks func(*repository2.MockNetworkRepository, *mocks.AlerterInterface)
|
||||
mocks func(*repository.MockNetworkRepository, *mocks.AlerterInterface)
|
||||
wantErr error
|
||||
}{
|
||||
{
|
||||
test: "no load balancer rule",
|
||||
dirName: "azurerm_lb_rule_empty",
|
||||
mocks: func(repository *repository2.MockNetworkRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockNetworkRepository, alerter *mocks.AlerterInterface) {
|
||||
loadbalancer := &armnetwork.LoadBalancer{
|
||||
Resource: armnetwork.Resource{
|
||||
ID: to.StringPtr("/subscriptions/8cb43347-a79f-4bb2-a8b4-c838b41fa5a5/resourceGroups/raphael-dev/providers/Microsoft.Network/loadBalancers/TestLoadBalancer/frontendIPConfigurations/PublicIPAddress"),
|
||||
|
@ -914,7 +914,7 @@ func TestAzurermLoadBalancerRules(t *testing.T) {
|
|||
{
|
||||
test: "error listing load balancer rules",
|
||||
dirName: "azurerm_lb_rule_empty",
|
||||
mocks: func(repository *repository2.MockNetworkRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockNetworkRepository, alerter *mocks.AlerterInterface) {
|
||||
repository.On("ListAllLoadBalancers").Return(nil, dummyError)
|
||||
},
|
||||
wantErr: error2.NewResourceListingErrorWithType(dummyError, resourceazure.AzureLoadBalancerRuleResourceType, resourceazure.AzureLoadBalancerResourceType),
|
||||
|
@ -922,7 +922,7 @@ func TestAzurermLoadBalancerRules(t *testing.T) {
|
|||
{
|
||||
test: "multiple load balancer rules",
|
||||
dirName: "azurerm_lb_rule_multiple",
|
||||
mocks: func(repository *repository2.MockNetworkRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockNetworkRepository, alerter *mocks.AlerterInterface) {
|
||||
loadbalancer := &armnetwork.LoadBalancer{
|
||||
Resource: armnetwork.Resource{
|
||||
ID: to.StringPtr("/subscriptions/8cb43347-a79f-4bb2-a8b4-c838b41fa5a5/resourceGroups/raphael-dev/providers/Microsoft.Network/loadBalancers/TestLoadBalancer/frontendIPConfigurations/PublicIPAddress"),
|
||||
|
@ -966,10 +966,10 @@ func TestAzurermLoadBalancerRules(t *testing.T) {
|
|||
|
||||
// Initialize mocks
|
||||
alerter := &mocks.AlerterInterface{}
|
||||
fakeRepo := &repository2.MockNetworkRepository{}
|
||||
fakeRepo := &repository.MockNetworkRepository{}
|
||||
c.mocks(fakeRepo, alerter)
|
||||
|
||||
var repo repository2.NetworkRepository = fakeRepo
|
||||
var repo repository.NetworkRepository = fakeRepo
|
||||
providerVersion := "2.71.0"
|
||||
realProvider, err := terraform2.InitTestAzureProvider(providerLibrary, providerVersion)
|
||||
if err != nil {
|
||||
|
@ -990,7 +990,7 @@ func TestAzurermLoadBalancerRules(t *testing.T) {
|
|||
t.Fatal(err)
|
||||
}
|
||||
clientOptions := &arm.ClientOptions{}
|
||||
repo = repository2.NewNetworkRepository(cred, clientOptions, realProvider.GetConfig(), cache.New(0))
|
||||
repo = repository.NewNetworkRepository(cred, clientOptions, realProvider.GetConfig(), cache.New(0))
|
||||
}
|
||||
|
||||
remoteLibrary.AddEnumerator(azurerm2.NewAzurermLoadBalancerRuleEnumerator(repo, factory))
|
||||
|
|
|
@ -5,7 +5,7 @@ import (
|
|||
|
||||
"github.com/snyk/driftctl/enumeration"
|
||||
azurerm2 "github.com/snyk/driftctl/enumeration/remote/azurerm"
|
||||
repository2 "github.com/snyk/driftctl/enumeration/remote/azurerm/repository"
|
||||
"github.com/snyk/driftctl/enumeration/remote/azurerm/repository"
|
||||
"github.com/snyk/driftctl/enumeration/remote/common"
|
||||
remoteerr "github.com/snyk/driftctl/enumeration/remote/error"
|
||||
"github.com/snyk/driftctl/enumeration/terraform"
|
||||
|
@ -28,13 +28,13 @@ func TestAzurermPostgresqlServer(t *testing.T) {
|
|||
|
||||
tests := []struct {
|
||||
test string
|
||||
mocks func(*repository2.MockPostgresqlRespository, *mocks.AlerterInterface)
|
||||
mocks func(*repository.MockPostgresqlRespository, *mocks.AlerterInterface)
|
||||
assertExpected func(t *testing.T, got []*resource.Resource)
|
||||
wantErr error
|
||||
}{
|
||||
{
|
||||
test: "no postgres server",
|
||||
mocks: func(repository *repository2.MockPostgresqlRespository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockPostgresqlRespository, alerter *mocks.AlerterInterface) {
|
||||
repository.On("ListAllServers").Return([]*armpostgresql.Server{}, nil)
|
||||
},
|
||||
assertExpected: func(t *testing.T, got []*resource.Resource) {
|
||||
|
@ -43,14 +43,14 @@ func TestAzurermPostgresqlServer(t *testing.T) {
|
|||
},
|
||||
{
|
||||
test: "error listing postgres servers",
|
||||
mocks: func(repository *repository2.MockPostgresqlRespository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockPostgresqlRespository, alerter *mocks.AlerterInterface) {
|
||||
repository.On("ListAllServers").Return(nil, dummyError)
|
||||
},
|
||||
wantErr: remoteerr.NewResourceListingError(dummyError, resourceazure.AzurePostgresqlServerResourceType),
|
||||
},
|
||||
{
|
||||
test: "multiple postgres servers",
|
||||
mocks: func(repository *repository2.MockPostgresqlRespository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockPostgresqlRespository, alerter *mocks.AlerterInterface) {
|
||||
repository.On("ListAllServers").Return([]*armpostgresql.Server{
|
||||
{
|
||||
TrackedResource: armpostgresql.TrackedResource{
|
||||
|
@ -95,10 +95,10 @@ func TestAzurermPostgresqlServer(t *testing.T) {
|
|||
|
||||
// Initialize mocks
|
||||
alerter := &mocks.AlerterInterface{}
|
||||
fakeRepo := &repository2.MockPostgresqlRespository{}
|
||||
fakeRepo := &repository.MockPostgresqlRespository{}
|
||||
c.mocks(fakeRepo, alerter)
|
||||
|
||||
var repo repository2.PostgresqlRespository = fakeRepo
|
||||
var repo repository.PostgresqlRespository = fakeRepo
|
||||
|
||||
remoteLibrary.AddEnumerator(azurerm2.NewAzurermPostgresqlServerEnumerator(repo, factory))
|
||||
|
||||
|
@ -125,13 +125,13 @@ func TestAzurermPostgresqlDatabase(t *testing.T) {
|
|||
|
||||
tests := []struct {
|
||||
test string
|
||||
mocks func(*repository2.MockPostgresqlRespository, *mocks.AlerterInterface)
|
||||
mocks func(*repository.MockPostgresqlRespository, *mocks.AlerterInterface)
|
||||
assertExpected func(t *testing.T, got []*resource.Resource)
|
||||
wantErr error
|
||||
}{
|
||||
{
|
||||
test: "no postgres database",
|
||||
mocks: func(repository *repository2.MockPostgresqlRespository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockPostgresqlRespository, alerter *mocks.AlerterInterface) {
|
||||
repository.On("ListAllServers").Return([]*armpostgresql.Server{}, nil)
|
||||
},
|
||||
assertExpected: func(t *testing.T, got []*resource.Resource) {
|
||||
|
@ -140,14 +140,14 @@ func TestAzurermPostgresqlDatabase(t *testing.T) {
|
|||
},
|
||||
{
|
||||
test: "error listing postgres servers",
|
||||
mocks: func(repository *repository2.MockPostgresqlRespository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockPostgresqlRespository, alerter *mocks.AlerterInterface) {
|
||||
repository.On("ListAllServers").Return(nil, dummyError)
|
||||
},
|
||||
wantErr: remoteerr.NewResourceListingErrorWithType(dummyError, resourceazure.AzurePostgresqlDatabaseResourceType, resourceazure.AzurePostgresqlServerResourceType),
|
||||
},
|
||||
{
|
||||
test: "error listing postgres databases",
|
||||
mocks: func(repository *repository2.MockPostgresqlRespository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockPostgresqlRespository, alerter *mocks.AlerterInterface) {
|
||||
repository.On("ListAllServers").Return([]*armpostgresql.Server{
|
||||
{
|
||||
TrackedResource: armpostgresql.TrackedResource{
|
||||
|
@ -165,7 +165,7 @@ func TestAzurermPostgresqlDatabase(t *testing.T) {
|
|||
},
|
||||
{
|
||||
test: "multiple postgres databases",
|
||||
mocks: func(repository *repository2.MockPostgresqlRespository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockPostgresqlRespository, alerter *mocks.AlerterInterface) {
|
||||
repository.On("ListAllServers").Return([]*armpostgresql.Server{
|
||||
{
|
||||
TrackedResource: armpostgresql.TrackedResource{
|
||||
|
@ -221,10 +221,10 @@ func TestAzurermPostgresqlDatabase(t *testing.T) {
|
|||
|
||||
// Initialize mocks
|
||||
alerter := &mocks.AlerterInterface{}
|
||||
fakeRepo := &repository2.MockPostgresqlRespository{}
|
||||
fakeRepo := &repository.MockPostgresqlRespository{}
|
||||
c.mocks(fakeRepo, alerter)
|
||||
|
||||
var repo repository2.PostgresqlRespository = fakeRepo
|
||||
var repo repository.PostgresqlRespository = fakeRepo
|
||||
|
||||
remoteLibrary.AddEnumerator(azurerm2.NewAzurermPostgresqlDatabaseEnumerator(repo, factory))
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ import (
|
|||
|
||||
"github.com/snyk/driftctl/enumeration"
|
||||
azurerm2 "github.com/snyk/driftctl/enumeration/remote/azurerm"
|
||||
repository2 "github.com/snyk/driftctl/enumeration/remote/azurerm/repository"
|
||||
"github.com/snyk/driftctl/enumeration/remote/azurerm/repository"
|
||||
"github.com/snyk/driftctl/enumeration/remote/cache"
|
||||
common2 "github.com/snyk/driftctl/enumeration/remote/common"
|
||||
remoteerr "github.com/snyk/driftctl/enumeration/remote/error"
|
||||
|
@ -35,20 +35,20 @@ func TestAzurermPrivateDNSZone(t *testing.T) {
|
|||
tests := []struct {
|
||||
test string
|
||||
dirName string
|
||||
mocks func(*repository2.MockPrivateDNSRepository, *mocks.AlerterInterface)
|
||||
mocks func(*repository.MockPrivateDNSRepository, *mocks.AlerterInterface)
|
||||
wantErr error
|
||||
}{
|
||||
{
|
||||
test: "no private zone",
|
||||
dirName: "azurerm_private_dns_private_zone_empty",
|
||||
mocks: func(repository *repository2.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) {
|
||||
repository.On("ListAllPrivateZones").Return([]*armprivatedns.PrivateZone{}, nil)
|
||||
},
|
||||
},
|
||||
{
|
||||
test: "error listing private zones",
|
||||
dirName: "azurerm_private_dns_private_zone_empty",
|
||||
mocks: func(repository *repository2.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) {
|
||||
repository.On("ListAllPrivateZones").Return(nil, dummyError)
|
||||
},
|
||||
wantErr: remoteerr.NewResourceListingError(dummyError, resourceazure.AzurePrivateDNSZoneResourceType),
|
||||
|
@ -56,7 +56,7 @@ func TestAzurermPrivateDNSZone(t *testing.T) {
|
|||
{
|
||||
test: "multiple private zones",
|
||||
dirName: "azurerm_private_dns_private_zone_multiple",
|
||||
mocks: func(repository *repository2.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) {
|
||||
repository.On("ListAllPrivateZones").Return([]*armprivatedns.PrivateZone{
|
||||
{
|
||||
TrackedResource: armprivatedns.TrackedResource{
|
||||
|
@ -103,10 +103,10 @@ func TestAzurermPrivateDNSZone(t *testing.T) {
|
|||
|
||||
// Initialize mocks
|
||||
alerter := &mocks.AlerterInterface{}
|
||||
fakeRepo := &repository2.MockPrivateDNSRepository{}
|
||||
fakeRepo := &repository.MockPrivateDNSRepository{}
|
||||
c.mocks(fakeRepo, alerter)
|
||||
|
||||
var repo repository2.PrivateDNSRepository = fakeRepo
|
||||
var repo repository.PrivateDNSRepository = fakeRepo
|
||||
providerVersion := "2.71.0"
|
||||
realProvider, err := terraformtest.InitTestAzureProvider(providerLibrary, providerVersion)
|
||||
if err != nil {
|
||||
|
@ -127,7 +127,7 @@ func TestAzurermPrivateDNSZone(t *testing.T) {
|
|||
t.Fatal(err)
|
||||
}
|
||||
clientOptions := &arm.ClientOptions{}
|
||||
repo = repository2.NewPrivateDNSRepository(cred, clientOptions, realProvider.GetConfig(), cache.New(0))
|
||||
repo = repository.NewPrivateDNSRepository(cred, clientOptions, realProvider.GetConfig(), cache.New(0))
|
||||
}
|
||||
|
||||
remoteLibrary.AddEnumerator(azurerm2.NewAzurermPrivateDNSZoneEnumerator(repo, factory))
|
||||
|
@ -157,20 +157,20 @@ func TestAzurermPrivateDNSARecord(t *testing.T) {
|
|||
tests := []struct {
|
||||
test string
|
||||
dirName string
|
||||
mocks func(*repository2.MockPrivateDNSRepository, *mocks.AlerterInterface)
|
||||
mocks func(*repository.MockPrivateDNSRepository, *mocks.AlerterInterface)
|
||||
wantErr error
|
||||
}{
|
||||
{
|
||||
test: "no private a record",
|
||||
dirName: "azurerm_private_dns_a_record_empty",
|
||||
mocks: func(repository *repository2.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) {
|
||||
repository.On("ListAllPrivateZones").Return([]*armprivatedns.PrivateZone{}, nil)
|
||||
},
|
||||
},
|
||||
{
|
||||
test: "error listing private zone",
|
||||
dirName: "azurerm_private_dns_a_record_empty",
|
||||
mocks: func(repository *repository2.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) {
|
||||
repository.On("ListAllPrivateZones").Return(nil, dummyError)
|
||||
},
|
||||
wantErr: remoteerr.NewResourceListingErrorWithType(dummyError, resourceazure.AzurePrivateDNSARecordResourceType, resourceazure.AzurePrivateDNSZoneResourceType),
|
||||
|
@ -178,7 +178,7 @@ func TestAzurermPrivateDNSARecord(t *testing.T) {
|
|||
{
|
||||
test: "error listing private a records",
|
||||
dirName: "azurerm_private_dns_a_record_empty",
|
||||
mocks: func(repository *repository2.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) {
|
||||
repository.On("ListAllPrivateZones").Return([]*armprivatedns.PrivateZone{
|
||||
{
|
||||
TrackedResource: armprivatedns.TrackedResource{
|
||||
|
@ -196,7 +196,7 @@ func TestAzurermPrivateDNSARecord(t *testing.T) {
|
|||
{
|
||||
test: "multiple private a records",
|
||||
dirName: "azurerm_private_dns_a_record_multiple",
|
||||
mocks: func(repository *repository2.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) {
|
||||
repository.On("ListAllPrivateZones").Return([]*armprivatedns.PrivateZone{
|
||||
{
|
||||
TrackedResource: armprivatedns.TrackedResource{
|
||||
|
@ -257,10 +257,10 @@ func TestAzurermPrivateDNSARecord(t *testing.T) {
|
|||
|
||||
// Initialize mocks
|
||||
alerter := &mocks.AlerterInterface{}
|
||||
fakeRepo := &repository2.MockPrivateDNSRepository{}
|
||||
fakeRepo := &repository.MockPrivateDNSRepository{}
|
||||
c.mocks(fakeRepo, alerter)
|
||||
|
||||
var repo repository2.PrivateDNSRepository = fakeRepo
|
||||
var repo repository.PrivateDNSRepository = fakeRepo
|
||||
providerVersion := "2.71.0"
|
||||
realProvider, err := terraformtest.InitTestAzureProvider(providerLibrary, providerVersion)
|
||||
if err != nil {
|
||||
|
@ -281,7 +281,7 @@ func TestAzurermPrivateDNSARecord(t *testing.T) {
|
|||
t.Fatal(err)
|
||||
}
|
||||
clientOptions := &arm.ClientOptions{}
|
||||
repo = repository2.NewPrivateDNSRepository(cred, clientOptions, realProvider.GetConfig(), cache.New(0))
|
||||
repo = repository.NewPrivateDNSRepository(cred, clientOptions, realProvider.GetConfig(), cache.New(0))
|
||||
}
|
||||
|
||||
remoteLibrary.AddEnumerator(azurerm2.NewAzurermPrivateDNSARecordEnumerator(repo, factory))
|
||||
|
@ -311,20 +311,20 @@ func TestAzurermPrivateDNSAAAARecord(t *testing.T) {
|
|||
tests := []struct {
|
||||
test string
|
||||
dirName string
|
||||
mocks func(*repository2.MockPrivateDNSRepository, *mocks.AlerterInterface)
|
||||
mocks func(*repository.MockPrivateDNSRepository, *mocks.AlerterInterface)
|
||||
wantErr error
|
||||
}{
|
||||
{
|
||||
test: "no private aaaa record",
|
||||
dirName: "azurerm_private_dns_aaaa_record_empty",
|
||||
mocks: func(repository *repository2.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) {
|
||||
repository.On("ListAllPrivateZones").Return([]*armprivatedns.PrivateZone{}, nil)
|
||||
},
|
||||
},
|
||||
{
|
||||
test: "error listing private zone",
|
||||
dirName: "azurerm_private_dns_aaaa_record_empty",
|
||||
mocks: func(repository *repository2.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) {
|
||||
repository.On("ListAllPrivateZones").Return(nil, dummyError)
|
||||
},
|
||||
wantErr: remoteerr.NewResourceListingErrorWithType(dummyError, resourceazure.AzurePrivateDNSAAAARecordResourceType, resourceazure.AzurePrivateDNSZoneResourceType),
|
||||
|
@ -332,7 +332,7 @@ func TestAzurermPrivateDNSAAAARecord(t *testing.T) {
|
|||
{
|
||||
test: "error listing private aaaa records",
|
||||
dirName: "azurerm_private_dns_aaaa_record_empty",
|
||||
mocks: func(repository *repository2.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) {
|
||||
repository.On("ListAllPrivateZones").Return([]*armprivatedns.PrivateZone{
|
||||
{
|
||||
TrackedResource: armprivatedns.TrackedResource{
|
||||
|
@ -350,7 +350,7 @@ func TestAzurermPrivateDNSAAAARecord(t *testing.T) {
|
|||
{
|
||||
test: "multiple private aaaaa records",
|
||||
dirName: "azurerm_private_dns_aaaaa_record_multiple",
|
||||
mocks: func(repository *repository2.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) {
|
||||
repository.On("ListAllPrivateZones").Return([]*armprivatedns.PrivateZone{
|
||||
{
|
||||
TrackedResource: armprivatedns.TrackedResource{
|
||||
|
@ -412,10 +412,10 @@ func TestAzurermPrivateDNSAAAARecord(t *testing.T) {
|
|||
|
||||
// Initialize mocks
|
||||
alerter := &mocks.AlerterInterface{}
|
||||
fakeRepo := &repository2.MockPrivateDNSRepository{}
|
||||
fakeRepo := &repository.MockPrivateDNSRepository{}
|
||||
c.mocks(fakeRepo, alerter)
|
||||
|
||||
var repo repository2.PrivateDNSRepository = fakeRepo
|
||||
var repo repository.PrivateDNSRepository = fakeRepo
|
||||
providerVersion := "2.71.0"
|
||||
realProvider, err := terraformtest.InitTestAzureProvider(providerLibrary, providerVersion)
|
||||
if err != nil {
|
||||
|
@ -436,7 +436,7 @@ func TestAzurermPrivateDNSAAAARecord(t *testing.T) {
|
|||
t.Fatal(err)
|
||||
}
|
||||
clientOptions := &arm.ClientOptions{}
|
||||
repo = repository2.NewPrivateDNSRepository(cred, clientOptions, realProvider.GetConfig(), cache.New(0))
|
||||
repo = repository.NewPrivateDNSRepository(cred, clientOptions, realProvider.GetConfig(), cache.New(0))
|
||||
}
|
||||
|
||||
remoteLibrary.AddEnumerator(azurerm2.NewAzurermPrivateDNSAAAARecordEnumerator(repo, factory))
|
||||
|
@ -466,20 +466,20 @@ func TestAzurermPrivateDNSCNAMERecord(t *testing.T) {
|
|||
tests := []struct {
|
||||
test string
|
||||
dirName string
|
||||
mocks func(*repository2.MockPrivateDNSRepository, *mocks.AlerterInterface)
|
||||
mocks func(*repository.MockPrivateDNSRepository, *mocks.AlerterInterface)
|
||||
wantErr error
|
||||
}{
|
||||
{
|
||||
test: "no private cname record",
|
||||
dirName: "azurerm_private_dns_cname_record_empty",
|
||||
mocks: func(repository *repository2.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) {
|
||||
repository.On("ListAllPrivateZones").Return([]*armprivatedns.PrivateZone{}, nil)
|
||||
},
|
||||
},
|
||||
{
|
||||
test: "error listing private zone",
|
||||
dirName: "azurerm_private_dns_cname_record_empty",
|
||||
mocks: func(repository *repository2.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) {
|
||||
repository.On("ListAllPrivateZones").Return(nil, dummyError)
|
||||
},
|
||||
wantErr: remoteerr.NewResourceListingErrorWithType(dummyError, resourceazure.AzurePrivateDNSCNameRecordResourceType, resourceazure.AzurePrivateDNSZoneResourceType),
|
||||
|
@ -487,7 +487,7 @@ func TestAzurermPrivateDNSCNAMERecord(t *testing.T) {
|
|||
{
|
||||
test: "error listing private cname records",
|
||||
dirName: "azurerm_private_dns_cname_record_empty",
|
||||
mocks: func(repository *repository2.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) {
|
||||
repository.On("ListAllPrivateZones").Return([]*armprivatedns.PrivateZone{
|
||||
{
|
||||
TrackedResource: armprivatedns.TrackedResource{
|
||||
|
@ -505,7 +505,7 @@ func TestAzurermPrivateDNSCNAMERecord(t *testing.T) {
|
|||
{
|
||||
test: "multiple private cname records",
|
||||
dirName: "azurerm_private_dns_cname_record_multiple",
|
||||
mocks: func(repository *repository2.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) {
|
||||
repository.On("ListAllPrivateZones").Return([]*armprivatedns.PrivateZone{
|
||||
{
|
||||
TrackedResource: armprivatedns.TrackedResource{
|
||||
|
@ -555,10 +555,10 @@ func TestAzurermPrivateDNSCNAMERecord(t *testing.T) {
|
|||
|
||||
// Initialize mocks
|
||||
alerter := &mocks.AlerterInterface{}
|
||||
fakeRepo := &repository2.MockPrivateDNSRepository{}
|
||||
fakeRepo := &repository.MockPrivateDNSRepository{}
|
||||
c.mocks(fakeRepo, alerter)
|
||||
|
||||
var repo repository2.PrivateDNSRepository = fakeRepo
|
||||
var repo repository.PrivateDNSRepository = fakeRepo
|
||||
providerVersion := "2.71.0"
|
||||
realProvider, err := terraformtest.InitTestAzureProvider(providerLibrary, providerVersion)
|
||||
if err != nil {
|
||||
|
@ -579,7 +579,7 @@ func TestAzurermPrivateDNSCNAMERecord(t *testing.T) {
|
|||
t.Fatal(err)
|
||||
}
|
||||
clientOptions := &arm.ClientOptions{}
|
||||
repo = repository2.NewPrivateDNSRepository(cred, clientOptions, realProvider.GetConfig(), cache.New(0))
|
||||
repo = repository.NewPrivateDNSRepository(cred, clientOptions, realProvider.GetConfig(), cache.New(0))
|
||||
}
|
||||
|
||||
remoteLibrary.AddEnumerator(azurerm2.NewAzurermPrivateDNSCNameRecordEnumerator(repo, factory))
|
||||
|
@ -609,20 +609,20 @@ func TestAzurermPrivateDNSPTRRecord(t *testing.T) {
|
|||
tests := []struct {
|
||||
test string
|
||||
dirName string
|
||||
mocks func(*repository2.MockPrivateDNSRepository, *mocks.AlerterInterface)
|
||||
mocks func(*repository.MockPrivateDNSRepository, *mocks.AlerterInterface)
|
||||
wantErr error
|
||||
}{
|
||||
{
|
||||
test: "no private ptr record",
|
||||
dirName: "azurerm_private_dns_ptr_record_empty",
|
||||
mocks: func(repository *repository2.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) {
|
||||
repository.On("ListAllPrivateZones").Return([]*armprivatedns.PrivateZone{}, nil)
|
||||
},
|
||||
},
|
||||
{
|
||||
test: "error listing private zone",
|
||||
dirName: "azurerm_private_dns_ptr_record_empty",
|
||||
mocks: func(repository *repository2.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) {
|
||||
repository.On("ListAllPrivateZones").Return(nil, dummyError)
|
||||
},
|
||||
wantErr: remoteerr.NewResourceListingErrorWithType(dummyError, resourceazure.AzurePrivateDNSPTRRecordResourceType, resourceazure.AzurePrivateDNSZoneResourceType),
|
||||
|
@ -630,7 +630,7 @@ func TestAzurermPrivateDNSPTRRecord(t *testing.T) {
|
|||
{
|
||||
test: "error listing private ptr records",
|
||||
dirName: "azurerm_private_dns_ptr_record_empty",
|
||||
mocks: func(repository *repository2.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) {
|
||||
repository.On("ListAllPrivateZones").Return([]*armprivatedns.PrivateZone{
|
||||
{
|
||||
TrackedResource: armprivatedns.TrackedResource{
|
||||
|
@ -648,7 +648,7 @@ func TestAzurermPrivateDNSPTRRecord(t *testing.T) {
|
|||
{
|
||||
test: "multiple private ptra records",
|
||||
dirName: "azurerm_private_dns_ptr_record_multiple",
|
||||
mocks: func(repository *repository2.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) {
|
||||
repository.On("ListAllPrivateZones").Return([]*armprivatedns.PrivateZone{
|
||||
{
|
||||
TrackedResource: armprivatedns.TrackedResource{
|
||||
|
@ -709,10 +709,10 @@ func TestAzurermPrivateDNSPTRRecord(t *testing.T) {
|
|||
|
||||
// Initialize mocks
|
||||
alerter := &mocks.AlerterInterface{}
|
||||
fakeRepo := &repository2.MockPrivateDNSRepository{}
|
||||
fakeRepo := &repository.MockPrivateDNSRepository{}
|
||||
c.mocks(fakeRepo, alerter)
|
||||
|
||||
var repo repository2.PrivateDNSRepository = fakeRepo
|
||||
var repo repository.PrivateDNSRepository = fakeRepo
|
||||
providerVersion := "2.71.0"
|
||||
realProvider, err := terraformtest.InitTestAzureProvider(providerLibrary, providerVersion)
|
||||
if err != nil {
|
||||
|
@ -733,7 +733,7 @@ func TestAzurermPrivateDNSPTRRecord(t *testing.T) {
|
|||
t.Fatal(err)
|
||||
}
|
||||
clientOptions := &arm.ClientOptions{}
|
||||
repo = repository2.NewPrivateDNSRepository(cred, clientOptions, realProvider.GetConfig(), cache.New(0))
|
||||
repo = repository.NewPrivateDNSRepository(cred, clientOptions, realProvider.GetConfig(), cache.New(0))
|
||||
}
|
||||
|
||||
remoteLibrary.AddEnumerator(azurerm2.NewAzurermPrivateDNSPTRRecordEnumerator(repo, factory))
|
||||
|
@ -763,20 +763,20 @@ func TestAzurermPrivateDNSMXRecord(t *testing.T) {
|
|||
tests := []struct {
|
||||
test string
|
||||
dirName string
|
||||
mocks func(*repository2.MockPrivateDNSRepository, *mocks.AlerterInterface)
|
||||
mocks func(*repository.MockPrivateDNSRepository, *mocks.AlerterInterface)
|
||||
wantErr error
|
||||
}{
|
||||
{
|
||||
test: "no private mx record",
|
||||
dirName: "azurerm_private_dns_mx_record_empty",
|
||||
mocks: func(repository *repository2.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) {
|
||||
repository.On("ListAllPrivateZones").Return([]*armprivatedns.PrivateZone{}, nil)
|
||||
},
|
||||
},
|
||||
{
|
||||
test: "error listing private zone",
|
||||
dirName: "azurerm_private_dns_mx_record_empty",
|
||||
mocks: func(repository *repository2.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) {
|
||||
repository.On("ListAllPrivateZones").Return(nil, dummyError)
|
||||
},
|
||||
wantErr: remoteerr.NewResourceListingErrorWithType(dummyError, resourceazure.AzurePrivateDNSMXRecordResourceType, resourceazure.AzurePrivateDNSZoneResourceType),
|
||||
|
@ -784,7 +784,7 @@ func TestAzurermPrivateDNSMXRecord(t *testing.T) {
|
|||
{
|
||||
test: "error listing private mx records",
|
||||
dirName: "azurerm_private_dns_mx_record_empty",
|
||||
mocks: func(repository *repository2.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) {
|
||||
repository.On("ListAllPrivateZones").Return([]*armprivatedns.PrivateZone{
|
||||
{
|
||||
TrackedResource: armprivatedns.TrackedResource{
|
||||
|
@ -802,7 +802,7 @@ func TestAzurermPrivateDNSMXRecord(t *testing.T) {
|
|||
{
|
||||
test: "multiple private mx records",
|
||||
dirName: "azurerm_private_dns_mx_record_multiple",
|
||||
mocks: func(repository *repository2.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) {
|
||||
repository.On("ListAllPrivateZones").Return([]*armprivatedns.PrivateZone{
|
||||
{
|
||||
TrackedResource: armprivatedns.TrackedResource{
|
||||
|
@ -864,10 +864,10 @@ func TestAzurermPrivateDNSMXRecord(t *testing.T) {
|
|||
|
||||
// Initialize mocks
|
||||
alerter := &mocks.AlerterInterface{}
|
||||
fakeRepo := &repository2.MockPrivateDNSRepository{}
|
||||
fakeRepo := &repository.MockPrivateDNSRepository{}
|
||||
c.mocks(fakeRepo, alerter)
|
||||
|
||||
var repo repository2.PrivateDNSRepository = fakeRepo
|
||||
var repo repository.PrivateDNSRepository = fakeRepo
|
||||
providerVersion := "2.71.0"
|
||||
realProvider, err := terraformtest.InitTestAzureProvider(providerLibrary, providerVersion)
|
||||
if err != nil {
|
||||
|
@ -888,7 +888,7 @@ func TestAzurermPrivateDNSMXRecord(t *testing.T) {
|
|||
t.Fatal(err)
|
||||
}
|
||||
clientOptions := &arm.ClientOptions{}
|
||||
repo = repository2.NewPrivateDNSRepository(cred, clientOptions, realProvider.GetConfig(), cache.New(0))
|
||||
repo = repository.NewPrivateDNSRepository(cred, clientOptions, realProvider.GetConfig(), cache.New(0))
|
||||
}
|
||||
|
||||
remoteLibrary.AddEnumerator(azurerm2.NewAzurermPrivateDNSMXRecordEnumerator(repo, factory))
|
||||
|
@ -918,20 +918,20 @@ func TestAzurermPrivateDNSSRVRecord(t *testing.T) {
|
|||
tests := []struct {
|
||||
test string
|
||||
dirName string
|
||||
mocks func(*repository2.MockPrivateDNSRepository, *mocks.AlerterInterface)
|
||||
mocks func(*repository.MockPrivateDNSRepository, *mocks.AlerterInterface)
|
||||
wantErr error
|
||||
}{
|
||||
{
|
||||
test: "no private srv record",
|
||||
dirName: "azurerm_private_dns_srv_record_empty",
|
||||
mocks: func(repository *repository2.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) {
|
||||
repository.On("ListAllPrivateZones").Return([]*armprivatedns.PrivateZone{}, nil)
|
||||
},
|
||||
},
|
||||
{
|
||||
test: "error listing private zone",
|
||||
dirName: "azurerm_private_dns_srv_record_empty",
|
||||
mocks: func(repository *repository2.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) {
|
||||
repository.On("ListAllPrivateZones").Return(nil, dummyError)
|
||||
},
|
||||
wantErr: remoteerr.NewResourceListingErrorWithType(dummyError, resourceazure.AzurePrivateDNSSRVRecordResourceType, resourceazure.AzurePrivateDNSZoneResourceType),
|
||||
|
@ -939,7 +939,7 @@ func TestAzurermPrivateDNSSRVRecord(t *testing.T) {
|
|||
{
|
||||
test: "error listing private srv records",
|
||||
dirName: "azurerm_private_dns_srv_record_empty",
|
||||
mocks: func(repository *repository2.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) {
|
||||
repository.On("ListAllPrivateZones").Return([]*armprivatedns.PrivateZone{
|
||||
{
|
||||
TrackedResource: armprivatedns.TrackedResource{
|
||||
|
@ -957,7 +957,7 @@ func TestAzurermPrivateDNSSRVRecord(t *testing.T) {
|
|||
{
|
||||
test: "multiple private srv records",
|
||||
dirName: "azurerm_private_dns_srv_record_multiple",
|
||||
mocks: func(repository *repository2.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) {
|
||||
repository.On("ListAllPrivateZones").Return([]*armprivatedns.PrivateZone{
|
||||
{
|
||||
TrackedResource: armprivatedns.TrackedResource{
|
||||
|
@ -1018,10 +1018,10 @@ func TestAzurermPrivateDNSSRVRecord(t *testing.T) {
|
|||
|
||||
// Initialize mocks
|
||||
alerter := &mocks.AlerterInterface{}
|
||||
fakeRepo := &repository2.MockPrivateDNSRepository{}
|
||||
fakeRepo := &repository.MockPrivateDNSRepository{}
|
||||
c.mocks(fakeRepo, alerter)
|
||||
|
||||
var repo repository2.PrivateDNSRepository = fakeRepo
|
||||
var repo repository.PrivateDNSRepository = fakeRepo
|
||||
providerVersion := "2.71.0"
|
||||
realProvider, err := terraformtest.InitTestAzureProvider(providerLibrary, providerVersion)
|
||||
if err != nil {
|
||||
|
@ -1042,7 +1042,7 @@ func TestAzurermPrivateDNSSRVRecord(t *testing.T) {
|
|||
t.Fatal(err)
|
||||
}
|
||||
clientOptions := &arm.ClientOptions{}
|
||||
repo = repository2.NewPrivateDNSRepository(cred, clientOptions, realProvider.GetConfig(), cache.New(0))
|
||||
repo = repository.NewPrivateDNSRepository(cred, clientOptions, realProvider.GetConfig(), cache.New(0))
|
||||
}
|
||||
|
||||
remoteLibrary.AddEnumerator(azurerm2.NewAzurermPrivateDNSSRVRecordEnumerator(repo, factory))
|
||||
|
@ -1072,20 +1072,20 @@ func TestAzurermPrivateDNSTXTRecord(t *testing.T) {
|
|||
tests := []struct {
|
||||
test string
|
||||
dirName string
|
||||
mocks func(*repository2.MockPrivateDNSRepository, *mocks.AlerterInterface)
|
||||
mocks func(*repository.MockPrivateDNSRepository, *mocks.AlerterInterface)
|
||||
wantErr error
|
||||
}{
|
||||
{
|
||||
test: "no private txt record",
|
||||
dirName: "azurerm_private_dns_txt_record_empty",
|
||||
mocks: func(repository *repository2.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) {
|
||||
repository.On("ListAllPrivateZones").Return([]*armprivatedns.PrivateZone{}, nil)
|
||||
},
|
||||
},
|
||||
{
|
||||
test: "error listing private zone",
|
||||
dirName: "azurerm_private_dns_txt_record_empty",
|
||||
mocks: func(repository *repository2.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) {
|
||||
repository.On("ListAllPrivateZones").Return(nil, dummyError)
|
||||
},
|
||||
wantErr: remoteerr.NewResourceListingErrorWithType(dummyError, resourceazure.AzurePrivateDNSTXTRecordResourceType, resourceazure.AzurePrivateDNSZoneResourceType),
|
||||
|
@ -1093,7 +1093,7 @@ func TestAzurermPrivateDNSTXTRecord(t *testing.T) {
|
|||
{
|
||||
test: "error listing private txt records",
|
||||
dirName: "azurerm_private_dns_txt_record_empty",
|
||||
mocks: func(repository *repository2.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) {
|
||||
repository.On("ListAllPrivateZones").Return([]*armprivatedns.PrivateZone{
|
||||
{
|
||||
TrackedResource: armprivatedns.TrackedResource{
|
||||
|
@ -1111,7 +1111,7 @@ func TestAzurermPrivateDNSTXTRecord(t *testing.T) {
|
|||
{
|
||||
test: "multiple private txt records",
|
||||
dirName: "azurerm_private_dns_txt_record_multiple",
|
||||
mocks: func(repository *repository2.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockPrivateDNSRepository, alerter *mocks.AlerterInterface) {
|
||||
repository.On("ListAllPrivateZones").Return([]*armprivatedns.PrivateZone{
|
||||
{
|
||||
TrackedResource: armprivatedns.TrackedResource{
|
||||
|
@ -1172,10 +1172,10 @@ func TestAzurermPrivateDNSTXTRecord(t *testing.T) {
|
|||
|
||||
// Initialize mocks
|
||||
alerter := &mocks.AlerterInterface{}
|
||||
fakeRepo := &repository2.MockPrivateDNSRepository{}
|
||||
fakeRepo := &repository.MockPrivateDNSRepository{}
|
||||
c.mocks(fakeRepo, alerter)
|
||||
|
||||
var repo repository2.PrivateDNSRepository = fakeRepo
|
||||
var repo repository.PrivateDNSRepository = fakeRepo
|
||||
providerVersion := "2.71.0"
|
||||
realProvider, err := terraformtest.InitTestAzureProvider(providerLibrary, providerVersion)
|
||||
if err != nil {
|
||||
|
@ -1196,7 +1196,7 @@ func TestAzurermPrivateDNSTXTRecord(t *testing.T) {
|
|||
t.Fatal(err)
|
||||
}
|
||||
clientOptions := &arm.ClientOptions{}
|
||||
repo = repository2.NewPrivateDNSRepository(cred, clientOptions, realProvider.GetConfig(), cache.New(0))
|
||||
repo = repository.NewPrivateDNSRepository(cred, clientOptions, realProvider.GetConfig(), cache.New(0))
|
||||
}
|
||||
|
||||
remoteLibrary.AddEnumerator(azurerm2.NewAzurermPrivateDNSTXTRecordEnumerator(repo, factory))
|
||||
|
|
|
@ -5,7 +5,7 @@ import (
|
|||
|
||||
"github.com/snyk/driftctl/enumeration"
|
||||
"github.com/snyk/driftctl/enumeration/remote/azurerm"
|
||||
repository2 "github.com/snyk/driftctl/enumeration/remote/azurerm/repository"
|
||||
"github.com/snyk/driftctl/enumeration/remote/azurerm/repository"
|
||||
"github.com/snyk/driftctl/enumeration/remote/common"
|
||||
error2 "github.com/snyk/driftctl/enumeration/remote/error"
|
||||
"github.com/snyk/driftctl/enumeration/terraform"
|
||||
|
@ -28,13 +28,13 @@ func TestAzurermResourceGroups(t *testing.T) {
|
|||
|
||||
tests := []struct {
|
||||
test string
|
||||
mocks func(*repository2.MockResourcesRepository, *mocks.AlerterInterface)
|
||||
mocks func(*repository.MockResourcesRepository, *mocks.AlerterInterface)
|
||||
assertExpected func(t *testing.T, got []*resource.Resource)
|
||||
wantErr error
|
||||
}{
|
||||
{
|
||||
test: "no resource group",
|
||||
mocks: func(repository *repository2.MockResourcesRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockResourcesRepository, alerter *mocks.AlerterInterface) {
|
||||
repository.On("ListAllResourceGroups").Return([]*armresources.ResourceGroup{}, nil)
|
||||
},
|
||||
assertExpected: func(t *testing.T, got []*resource.Resource) {
|
||||
|
@ -43,14 +43,14 @@ func TestAzurermResourceGroups(t *testing.T) {
|
|||
},
|
||||
{
|
||||
test: "error listing resource groups",
|
||||
mocks: func(repository *repository2.MockResourcesRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockResourcesRepository, alerter *mocks.AlerterInterface) {
|
||||
repository.On("ListAllResourceGroups").Return(nil, dummyError)
|
||||
},
|
||||
wantErr: error2.NewResourceListingError(dummyError, resourceazure.AzureResourceGroupResourceType),
|
||||
},
|
||||
{
|
||||
test: "multiple resource groups",
|
||||
mocks: func(repository *repository2.MockResourcesRepository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockResourcesRepository, alerter *mocks.AlerterInterface) {
|
||||
repository.On("ListAllResourceGroups").Return([]*armresources.ResourceGroup{
|
||||
{
|
||||
ID: to.StringPtr("group1"),
|
||||
|
@ -87,10 +87,10 @@ func TestAzurermResourceGroups(t *testing.T) {
|
|||
|
||||
// Initialize mocks
|
||||
alerter := &mocks.AlerterInterface{}
|
||||
fakeRepo := &repository2.MockResourcesRepository{}
|
||||
fakeRepo := &repository.MockResourcesRepository{}
|
||||
c.mocks(fakeRepo, alerter)
|
||||
|
||||
var repo repository2.ResourcesRepository = fakeRepo
|
||||
var repo repository.ResourcesRepository = fakeRepo
|
||||
|
||||
remoteLibrary.AddEnumerator(azurerm.NewAzurermResourceGroupEnumerator(repo, factory))
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ import (
|
|||
|
||||
"github.com/snyk/driftctl/enumeration"
|
||||
azurerm2 "github.com/snyk/driftctl/enumeration/remote/azurerm"
|
||||
repository2 "github.com/snyk/driftctl/enumeration/remote/azurerm/repository"
|
||||
"github.com/snyk/driftctl/enumeration/remote/azurerm/repository"
|
||||
"github.com/snyk/driftctl/enumeration/remote/common"
|
||||
error2 "github.com/snyk/driftctl/enumeration/remote/error"
|
||||
"github.com/snyk/driftctl/enumeration/terraform"
|
||||
|
@ -27,13 +27,13 @@ func TestAzurermStorageAccount(t *testing.T) {
|
|||
|
||||
tests := []struct {
|
||||
test string
|
||||
mocks func(*repository2.MockStorageRespository, *mocks.AlerterInterface)
|
||||
mocks func(*repository.MockStorageRespository, *mocks.AlerterInterface)
|
||||
assertExpected func(t *testing.T, got []*resource.Resource)
|
||||
wantErr error
|
||||
}{
|
||||
{
|
||||
test: "no storage accounts",
|
||||
mocks: func(repository *repository2.MockStorageRespository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockStorageRespository, alerter *mocks.AlerterInterface) {
|
||||
repository.On("ListAllStorageAccount").Return([]*armstorage.StorageAccount{}, nil)
|
||||
},
|
||||
assertExpected: func(t *testing.T, got []*resource.Resource) {
|
||||
|
@ -42,14 +42,14 @@ func TestAzurermStorageAccount(t *testing.T) {
|
|||
},
|
||||
{
|
||||
test: "error listing storage accounts",
|
||||
mocks: func(repository *repository2.MockStorageRespository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockStorageRespository, alerter *mocks.AlerterInterface) {
|
||||
repository.On("ListAllStorageAccount").Return(nil, dummyError)
|
||||
},
|
||||
wantErr: error2.NewResourceListingError(dummyError, resourceazure.AzureStorageAccountResourceType),
|
||||
},
|
||||
{
|
||||
test: "multiple storage accounts",
|
||||
mocks: func(repository *repository2.MockStorageRespository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockStorageRespository, alerter *mocks.AlerterInterface) {
|
||||
repository.On("ListAllStorageAccount").Return([]*armstorage.StorageAccount{
|
||||
{
|
||||
TrackedResource: armstorage.TrackedResource{
|
||||
|
@ -92,10 +92,10 @@ func TestAzurermStorageAccount(t *testing.T) {
|
|||
|
||||
// Initialize mocks
|
||||
alerter := &mocks.AlerterInterface{}
|
||||
fakeRepo := &repository2.MockStorageRespository{}
|
||||
fakeRepo := &repository.MockStorageRespository{}
|
||||
c.mocks(fakeRepo, alerter)
|
||||
|
||||
var repo repository2.StorageRespository = fakeRepo
|
||||
var repo repository.StorageRespository = fakeRepo
|
||||
|
||||
remoteLibrary.AddEnumerator(azurerm2.NewAzurermStorageAccountEnumerator(repo, factory))
|
||||
|
||||
|
@ -122,13 +122,13 @@ func TestAzurermStorageContainer(t *testing.T) {
|
|||
|
||||
tests := []struct {
|
||||
test string
|
||||
mocks func(*repository2.MockStorageRespository, *mocks.AlerterInterface)
|
||||
mocks func(*repository.MockStorageRespository, *mocks.AlerterInterface)
|
||||
assertExpected func(t *testing.T, got []*resource.Resource)
|
||||
wantErr error
|
||||
}{
|
||||
{
|
||||
test: "no storage accounts",
|
||||
mocks: func(repository *repository2.MockStorageRespository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockStorageRespository, alerter *mocks.AlerterInterface) {
|
||||
repository.On("ListAllStorageAccount").Return([]*armstorage.StorageAccount{}, nil)
|
||||
},
|
||||
assertExpected: func(t *testing.T, got []*resource.Resource) {
|
||||
|
@ -137,7 +137,7 @@ func TestAzurermStorageContainer(t *testing.T) {
|
|||
},
|
||||
{
|
||||
test: "no storage containers",
|
||||
mocks: func(repository *repository2.MockStorageRespository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockStorageRespository, alerter *mocks.AlerterInterface) {
|
||||
account1 := &armstorage.StorageAccount{
|
||||
TrackedResource: armstorage.TrackedResource{
|
||||
Resource: armstorage.Resource{
|
||||
|
@ -165,14 +165,14 @@ func TestAzurermStorageContainer(t *testing.T) {
|
|||
},
|
||||
{
|
||||
test: "error listing storage accounts",
|
||||
mocks: func(repository *repository2.MockStorageRespository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockStorageRespository, alerter *mocks.AlerterInterface) {
|
||||
repository.On("ListAllStorageAccount").Return(nil, dummyError)
|
||||
},
|
||||
wantErr: error2.NewResourceListingErrorWithType(dummyError, resourceazure.AzureStorageContainerResourceType, resourceazure.AzureStorageAccountResourceType),
|
||||
},
|
||||
{
|
||||
test: "error listing storage container",
|
||||
mocks: func(repository *repository2.MockStorageRespository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockStorageRespository, alerter *mocks.AlerterInterface) {
|
||||
account := &armstorage.StorageAccount{
|
||||
TrackedResource: armstorage.TrackedResource{
|
||||
Resource: armstorage.Resource{
|
||||
|
@ -187,7 +187,7 @@ func TestAzurermStorageContainer(t *testing.T) {
|
|||
},
|
||||
{
|
||||
test: "multiple storage containers",
|
||||
mocks: func(repository *repository2.MockStorageRespository, alerter *mocks.AlerterInterface) {
|
||||
mocks: func(repository *repository.MockStorageRespository, alerter *mocks.AlerterInterface) {
|
||||
account1 := &armstorage.StorageAccount{
|
||||
TrackedResource: armstorage.TrackedResource{
|
||||
Resource: armstorage.Resource{
|
||||
|
@ -237,10 +237,10 @@ func TestAzurermStorageContainer(t *testing.T) {
|
|||
|
||||
// Initialize mocks
|
||||
alerter := &mocks.AlerterInterface{}
|
||||
fakeRepo := &repository2.MockStorageRespository{}
|
||||
fakeRepo := &repository.MockStorageRespository{}
|
||||
c.mocks(fakeRepo, alerter)
|
||||
|
||||
var repo repository2.StorageRespository = fakeRepo
|
||||
var repo repository.StorageRespository = fakeRepo
|
||||
|
||||
remoteLibrary.AddEnumerator(azurerm2.NewAzurermStorageContainerEnumerator(repo, factory))
|
||||
|
||||
|
|
|
@ -3,19 +3,19 @@ package google
|
|||
import (
|
||||
"fmt"
|
||||
remoteerror "github.com/snyk/driftctl/enumeration/remote/error"
|
||||
repository2 "github.com/snyk/driftctl/enumeration/remote/google/repository"
|
||||
"github.com/snyk/driftctl/enumeration/remote/google/repository"
|
||||
|
||||
"github.com/snyk/driftctl/enumeration/resource"
|
||||
"github.com/snyk/driftctl/enumeration/resource/google"
|
||||
)
|
||||
|
||||
type GoogleStorageBucketIamMemberEnumerator struct {
|
||||
repository repository2.AssetRepository
|
||||
storageRepository repository2.StorageRepository
|
||||
repository repository.AssetRepository
|
||||
storageRepository repository.StorageRepository
|
||||
factory resource.ResourceFactory
|
||||
}
|
||||
|
||||
func NewGoogleStorageBucketIamMemberEnumerator(repo repository2.AssetRepository, storageRepo repository2.StorageRepository, factory resource.ResourceFactory) *GoogleStorageBucketIamMemberEnumerator {
|
||||
func NewGoogleStorageBucketIamMemberEnumerator(repo repository.AssetRepository, storageRepo repository.StorageRepository, factory resource.ResourceFactory) *GoogleStorageBucketIamMemberEnumerator {
|
||||
return &GoogleStorageBucketIamMemberEnumerator{
|
||||
repository: repo,
|
||||
storageRepository: storageRepo,
|
||||
|
|
|
@ -8,7 +8,7 @@ import (
|
|||
"github.com/snyk/driftctl/enumeration/alerter"
|
||||
"github.com/snyk/driftctl/enumeration/remote/cache"
|
||||
common2 "github.com/snyk/driftctl/enumeration/remote/common"
|
||||
repository2 "github.com/snyk/driftctl/enumeration/remote/google/repository"
|
||||
"github.com/snyk/driftctl/enumeration/remote/google/repository"
|
||||
"github.com/snyk/driftctl/enumeration/terraform"
|
||||
|
||||
asset "cloud.google.com/go/asset/apiv1"
|
||||
|
@ -59,9 +59,9 @@ func Init(version string, alerter *alerter.Alerter,
|
|||
return err
|
||||
}
|
||||
|
||||
assetRepository := repository2.NewAssetRepository(assetClient, provider.GetConfig(), repositoryCache)
|
||||
storageRepository := repository2.NewStorageRepository(storageClient, repositoryCache)
|
||||
iamRepository := repository2.NewCloudResourceManagerRepository(crmService, provider.GetConfig(), repositoryCache)
|
||||
assetRepository := repository.NewAssetRepository(assetClient, provider.GetConfig(), repositoryCache)
|
||||
storageRepository := repository.NewStorageRepository(storageClient, repositoryCache)
|
||||
iamRepository := repository.NewCloudResourceManagerRepository(crmService, provider.GetConfig(), repositoryCache)
|
||||
|
||||
providerLibrary.AddProvider(terraform.GOOGLE, provider)
|
||||
deserializer := resource.NewDeserializer(factory)
|
||||
|
|
|
@ -10,7 +10,7 @@ import (
|
|||
common2 "github.com/snyk/driftctl/enumeration/remote/common"
|
||||
remoteerr "github.com/snyk/driftctl/enumeration/remote/error"
|
||||
google2 "github.com/snyk/driftctl/enumeration/remote/google"
|
||||
repository2 "github.com/snyk/driftctl/enumeration/remote/google/repository"
|
||||
"github.com/snyk/driftctl/enumeration/remote/google/repository"
|
||||
terraform3 "github.com/snyk/driftctl/enumeration/terraform"
|
||||
|
||||
asset "cloud.google.com/go/asset/apiv1"
|
||||
|
@ -140,7 +140,7 @@ func TestGoogleStorageBucket(t *testing.T) {
|
|||
provider.ShouldUpdate()
|
||||
}
|
||||
|
||||
repo := repository2.NewAssetRepository(assetClient, realProvider.GetConfig(), cache.New(0))
|
||||
repo := repository.NewAssetRepository(assetClient, realProvider.GetConfig(), cache.New(0))
|
||||
|
||||
remoteLibrary.AddEnumerator(google2.NewGoogleStorageBucketEnumerator(repo, factory))
|
||||
remoteLibrary.AddDetailsFetcher(resType, common2.NewGenericDetailsFetcher(resType, provider, deserializer))
|
||||
|
@ -166,8 +166,8 @@ func TestGoogleStorageBucketIAMMember(t *testing.T) {
|
|||
cases := []struct {
|
||||
test string
|
||||
dirName string
|
||||
assetRepositoryMock func(assetRepository *repository2.MockAssetRepository)
|
||||
storageRepositoryMock func(storageRepository *repository2.MockStorageRepository)
|
||||
assetRepositoryMock func(assetRepository *repository.MockAssetRepository)
|
||||
storageRepositoryMock func(storageRepository *repository.MockStorageRepository)
|
||||
responseErr error
|
||||
setupAlerterMock func(alerter *mocks.AlerterInterface)
|
||||
wantErr error
|
||||
|
@ -175,7 +175,7 @@ func TestGoogleStorageBucketIAMMember(t *testing.T) {
|
|||
{
|
||||
test: "no storage buckets",
|
||||
dirName: "google_storage_bucket_member_empty",
|
||||
assetRepositoryMock: func(assetRepository *repository2.MockAssetRepository) {
|
||||
assetRepositoryMock: func(assetRepository *repository.MockAssetRepository) {
|
||||
assetRepository.On("SearchAllBuckets").Return([]*assetpb.ResourceSearchResult{}, nil)
|
||||
},
|
||||
wantErr: nil,
|
||||
|
@ -183,7 +183,7 @@ func TestGoogleStorageBucketIAMMember(t *testing.T) {
|
|||
{
|
||||
test: "multiples storage buckets, no bindings",
|
||||
dirName: "google_storage_bucket_member_empty",
|
||||
assetRepositoryMock: func(assetRepository *repository2.MockAssetRepository) {
|
||||
assetRepositoryMock: func(assetRepository *repository.MockAssetRepository) {
|
||||
assetRepository.On("SearchAllBuckets").Return([]*assetpb.ResourceSearchResult{
|
||||
{
|
||||
AssetType: "storage.googleapis.com/Bucket",
|
||||
|
@ -195,7 +195,7 @@ func TestGoogleStorageBucketIAMMember(t *testing.T) {
|
|||
},
|
||||
}, nil)
|
||||
},
|
||||
storageRepositoryMock: func(storageRepository *repository2.MockStorageRepository) {
|
||||
storageRepositoryMock: func(storageRepository *repository.MockStorageRepository) {
|
||||
storageRepository.On("ListAllBindings", "dctlgstoragebucketiambinding-1").Return(map[string][]string{}, nil)
|
||||
storageRepository.On("ListAllBindings", "dctlgstoragebucketiambinding-2").Return(map[string][]string{}, nil)
|
||||
},
|
||||
|
@ -204,7 +204,7 @@ func TestGoogleStorageBucketIAMMember(t *testing.T) {
|
|||
{
|
||||
test: "Cannot list bindings",
|
||||
dirName: "google_storage_bucket_member_listing_error",
|
||||
assetRepositoryMock: func(assetRepository *repository2.MockAssetRepository) {
|
||||
assetRepositoryMock: func(assetRepository *repository.MockAssetRepository) {
|
||||
assetRepository.On("SearchAllBuckets").Return([]*assetpb.ResourceSearchResult{
|
||||
{
|
||||
AssetType: "storage.googleapis.com/Bucket",
|
||||
|
@ -212,7 +212,7 @@ func TestGoogleStorageBucketIAMMember(t *testing.T) {
|
|||
},
|
||||
}, nil)
|
||||
},
|
||||
storageRepositoryMock: func(storageRepository *repository2.MockStorageRepository) {
|
||||
storageRepositoryMock: func(storageRepository *repository.MockStorageRepository) {
|
||||
storageRepository.On("ListAllBindings", "dctlgstoragebucketiambinding-1").Return(
|
||||
map[string][]string{},
|
||||
errors.New("googleapi: Error 403: driftctl-acc-circle@driftctl-qa-1.iam.gserviceaccount.com does not have storage.buckets.getIamPolicy access to the Google Cloud Storage bucket., forbidden"))
|
||||
|
@ -236,7 +236,7 @@ func TestGoogleStorageBucketIAMMember(t *testing.T) {
|
|||
{
|
||||
test: "multiples storage buckets, multiple bindings",
|
||||
dirName: "google_storage_bucket_member_listing_multiple",
|
||||
assetRepositoryMock: func(assetRepository *repository2.MockAssetRepository) {
|
||||
assetRepositoryMock: func(assetRepository *repository.MockAssetRepository) {
|
||||
assetRepository.On("SearchAllBuckets").Return([]*assetpb.ResourceSearchResult{
|
||||
{
|
||||
AssetType: "storage.googleapis.com/Bucket",
|
||||
|
@ -248,7 +248,7 @@ func TestGoogleStorageBucketIAMMember(t *testing.T) {
|
|||
},
|
||||
}, nil)
|
||||
},
|
||||
storageRepositoryMock: func(storageRepository *repository2.MockStorageRepository) {
|
||||
storageRepositoryMock: func(storageRepository *repository.MockStorageRepository) {
|
||||
storageRepository.On("ListAllBindings", "dctlgstoragebucketiambinding-1").Return(map[string][]string{
|
||||
"roles/storage.admin": {"user:elie.charra@cloudskiff.com"},
|
||||
"roles/storage.objectViewer": {"user:william.beuil@cloudskiff.com"},
|
||||
|
@ -286,24 +286,24 @@ func TestGoogleStorageBucketIAMMember(t *testing.T) {
|
|||
c.setupAlerterMock(alerter)
|
||||
}
|
||||
|
||||
storageRepo := &repository2.MockStorageRepository{}
|
||||
storageRepo := &repository.MockStorageRepository{}
|
||||
if c.storageRepositoryMock != nil {
|
||||
c.storageRepositoryMock(storageRepo)
|
||||
}
|
||||
var storageRepository repository2.StorageRepository = storageRepo
|
||||
var storageRepository repository.StorageRepository = storageRepo
|
||||
if shouldUpdate {
|
||||
storageClient, err := storage.NewClient(context.Background())
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
storageRepository = repository2.NewStorageRepository(storageClient, repositoryCache)
|
||||
storageRepository = repository.NewStorageRepository(storageClient, repositoryCache)
|
||||
}
|
||||
|
||||
assetRepo := &repository2.MockAssetRepository{}
|
||||
assetRepo := &repository.MockAssetRepository{}
|
||||
if c.assetRepositoryMock != nil {
|
||||
c.assetRepositoryMock(assetRepo)
|
||||
}
|
||||
var assetRepository repository2.AssetRepository = assetRepo
|
||||
var assetRepository repository.AssetRepository = assetRepo
|
||||
|
||||
realProvider, err := terraform2.InitTestGoogleProvider(providerLibrary, providerVersion)
|
||||
if err != nil {
|
||||
|
|
Loading…
Reference in New Issue