2021-02-05 10:03:45 +00:00
|
|
|
package aws_test
|
|
|
|
|
|
|
|
import (
|
2022-06-28 07:23:29 +00:00
|
|
|
"github.com/snyk/driftctl/enumeration/remote/aws/repository"
|
|
|
|
"github.com/snyk/driftctl/enumeration/remote/cache"
|
2021-02-05 10:03:45 +00:00
|
|
|
"testing"
|
2021-02-09 15:54:50 +00:00
|
|
|
"time"
|
2021-02-05 10:03:45 +00:00
|
|
|
|
2021-02-09 15:54:50 +00:00
|
|
|
"github.com/sirupsen/logrus"
|
2021-12-06 13:29:39 +00:00
|
|
|
"github.com/snyk/driftctl/test"
|
|
|
|
"github.com/snyk/driftctl/test/acceptance"
|
|
|
|
"github.com/snyk/driftctl/test/acceptance/awsutils"
|
2021-02-05 10:03:45 +00:00
|
|
|
)
|
|
|
|
|
2022-01-25 14:29:57 +00:00
|
|
|
func TestAcc_Aws_SNSTopicSubscription(t *testing.T) {
|
2021-02-05 10:03:45 +00:00
|
|
|
acceptance.Run(t, acceptance.AccTestCase{
|
2021-08-26 12:04:23 +00:00
|
|
|
TerraformVersion: "0.15.5",
|
2021-04-09 16:37:27 +00:00
|
|
|
Paths: []string{"./testdata/acc/aws_sns_topic_subscription"},
|
2021-10-08 15:28:28 +00:00
|
|
|
Args: []string{"scan", "--deep"},
|
2021-02-05 10:03:45 +00:00
|
|
|
Checks: []acceptance.AccCheck{
|
|
|
|
{
|
|
|
|
Env: map[string]string{
|
|
|
|
"AWS_REGION": "us-east-1",
|
|
|
|
},
|
2021-02-09 15:54:50 +00:00
|
|
|
PreExec: func() {
|
|
|
|
err := acceptance.RetryFor(60*time.Second, func(doneCh chan struct{}) error {
|
2021-06-28 16:21:12 +00:00
|
|
|
client := repository.NewSNSRepository(awsutils.Session(), cache.New(0))
|
2021-02-09 15:54:50 +00:00
|
|
|
topics, err := client.ListAllSubscriptions()
|
|
|
|
if err != nil {
|
|
|
|
logrus.Warnf("Cannot list Subscriptions: %+v", err)
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if len(topics) == 2 {
|
|
|
|
doneCh <- struct{}{}
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
})
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal("Timeout while fetching SNS Subscriptions")
|
|
|
|
}
|
|
|
|
},
|
2021-03-31 14:33:25 +00:00
|
|
|
Check: func(result *test.ScanResult, stdout string, err error) {
|
2021-02-05 10:03:45 +00:00
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
2021-05-18 15:06:11 +00:00
|
|
|
result.AssertInfrastructureIsInSync()
|
2021-02-05 10:03:45 +00:00
|
|
|
result.AssertManagedCount(2)
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
})
|
|
|
|
}
|