2021-01-27 10:49:25 +00:00
|
|
|
package aws_test
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
2021-02-04 21:06:09 +00:00
|
|
|
"time"
|
|
|
|
|
2022-08-26 10:22:45 +00:00
|
|
|
"github.com/aws/aws-sdk-go/aws"
|
|
|
|
"github.com/aws/aws-sdk-go/service/sqs"
|
|
|
|
"github.com/r3labs/diff/v2"
|
2022-06-28 07:23:29 +00:00
|
|
|
awsresources "github.com/snyk/driftctl/enumeration/resource/aws"
|
2021-12-06 13:29:39 +00:00
|
|
|
"github.com/snyk/driftctl/pkg/analyser"
|
|
|
|
"github.com/snyk/driftctl/test"
|
|
|
|
"github.com/snyk/driftctl/test/acceptance"
|
|
|
|
"github.com/snyk/driftctl/test/acceptance/awsutils"
|
2021-01-27 10:49:25 +00:00
|
|
|
)
|
|
|
|
|
2022-01-25 14:29:57 +00:00
|
|
|
func TestAcc_Aws_SQSQueue(t *testing.T) {
|
2021-02-03 20:08:57 +00:00
|
|
|
var mutatedQueue string
|
2021-01-27 10:49:25 +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"},
|
2021-10-08 15:28:28 +00:00
|
|
|
Args: []string{"scan", "--deep"},
|
2021-01-27 10:49:25 +00:00
|
|
|
Checks: []acceptance.AccCheck{
|
|
|
|
{
|
|
|
|
Env: map[string]string{
|
|
|
|
"AWS_REGION": "us-east-1",
|
|
|
|
},
|
2022-08-26 10:22:45 +00:00
|
|
|
ShouldRetry: acceptance.LinearBackoff(10 * time.Minute),
|
2021-03-31 14:33:25 +00:00
|
|
|
Check: func(result *test.ScanResult, stdout string, err error) {
|
2021-01-27 10:49:25 +00:00
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
result.AssertInfrastructureIsInSync()
|
|
|
|
result.Equal(2, result.Summary().TotalManaged)
|
2021-08-18 13:58:28 +00:00
|
|
|
mutatedQueue = result.Managed()[0].ResourceId()
|
2021-02-03 20:08:57 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Env: map[string]string{
|
|
|
|
"AWS_REGION": "us-east-1",
|
|
|
|
},
|
|
|
|
PreExec: func() {
|
|
|
|
client := sqs.New(awsutils.Session())
|
|
|
|
attributes := make(map[string]*string)
|
|
|
|
attributes["DelaySeconds"] = aws.String("200")
|
|
|
|
_, err := client.SetQueueAttributes(&sqs.SetQueueAttributesInput{
|
|
|
|
Attributes: attributes,
|
|
|
|
QueueUrl: aws.String(mutatedQueue),
|
|
|
|
})
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
},
|
2021-03-31 14:33:25 +00:00
|
|
|
Check: func(result *test.ScanResult, stdout string, err error) {
|
2021-02-03 20:08:57 +00:00
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
result.AssertDriftCountTotal(1)
|
|
|
|
result.AssertResourceHasDrift(
|
|
|
|
mutatedQueue,
|
|
|
|
awsresources.AwsSqsQueueResourceType,
|
|
|
|
analyser.Change{
|
|
|
|
Change: diff.Change{
|
|
|
|
Type: diff.UPDATE,
|
2021-05-18 16:22:46 +00:00
|
|
|
Path: []string{"delay_seconds"},
|
2021-02-03 20:08:57 +00:00
|
|
|
From: float64(0),
|
|
|
|
To: float64(200),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
)
|
2021-01-27 10:49:25 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
})
|
|
|
|
}
|