2021-01-29 11:35:11 +00:00
|
|
|
package aws_test
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
2021-02-04 21:06:09 +00:00
|
|
|
"time"
|
|
|
|
|
|
|
|
"github.com/aws/aws-sdk-go/service/sqs"
|
2021-03-31 14:33:25 +00:00
|
|
|
"github.com/cloudskiff/driftctl/test"
|
2021-02-04 21:06:09 +00:00
|
|
|
"github.com/cloudskiff/driftctl/test/acceptance/awsutils"
|
|
|
|
"github.com/sirupsen/logrus"
|
2021-01-29 11:35:11 +00:00
|
|
|
|
|
|
|
"github.com/cloudskiff/driftctl/test/acceptance"
|
|
|
|
)
|
|
|
|
|
2021-07-08 14:13:51 +00:00
|
|
|
func TestAcc_AwsSQSQueuePolicy(t *testing.T) {
|
2021-01-29 11:35:11 +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_sqs_queue_policy"},
|
2021-10-08 15:28:28 +00:00
|
|
|
Args: []string{"scan", "--deep"},
|
2021-01-29 11:35:11 +00:00
|
|
|
Checks: []acceptance.AccCheck{
|
|
|
|
{
|
|
|
|
Env: map[string]string{
|
|
|
|
"AWS_REGION": "us-east-1",
|
|
|
|
},
|
2021-02-04 21:06:09 +00:00
|
|
|
PreExec: func() {
|
|
|
|
err := acceptance.RetryFor(60*time.Second, func(doneCh chan struct{}) error {
|
|
|
|
return sqs.New(awsutils.Session()).ListQueuesPages(&sqs.ListQueuesInput{},
|
|
|
|
func(resp *sqs.ListQueuesOutput, lastPage bool) bool {
|
|
|
|
logrus.Debugf("Retrieved %d SQS queues", len(resp.QueueUrls))
|
2021-05-18 16:22:46 +00:00
|
|
|
if len(resp.QueueUrls) >= 3 {
|
2021-02-04 21:06:09 +00:00
|
|
|
doneCh <- struct{}{}
|
|
|
|
}
|
|
|
|
return !lastPage
|
|
|
|
},
|
|
|
|
)
|
|
|
|
})
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal("Timeout while fetching SQS queues")
|
|
|
|
}
|
|
|
|
},
|
2021-03-31 14:33:25 +00:00
|
|
|
Check: func(result *test.ScanResult, stdout string, err error) {
|
2021-01-29 11:35:11 +00:00
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
result.AssertInfrastructureIsInSync()
|
2021-05-18 16:22:46 +00:00
|
|
|
result.AssertManagedCount(2)
|
2021-01-29 11:35:11 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
})
|
|
|
|
}
|