Skip to content

Commit

Permalink
Merge pull request #21575 from hashicorp/remove-hardcoded-domain-name…
Browse files Browse the repository at this point in the history
…s-resources-c

Remove hardcoded domain names from acceptance tests for resources C
  • Loading branch information
gdavison authored Dec 9, 2021
2 parents 3f417e2 + cda5ae6 commit 2d1fffd
Show file tree
Hide file tree
Showing 34 changed files with 794 additions and 838 deletions.
43 changes: 26 additions & 17 deletions .semgrep.yml
Original file line number Diff line number Diff line change
Expand Up @@ -559,35 +559,44 @@ rules:
message: Domain names should be in the namespaces defined in RFC 6761 (https://datatracker.ietf.org/doc/html/rfc6761) as reserved for testing
paths:
include:
- internal/service/**/*_data_source_test.go
- internal/service/[a-b]*
- internal/service/d*
- internal/service/[f-z]*
- internal/service
exclude:
- internal/service/firehose/delivery_stream_test.go
- internal/service/globalaccelerator/accelerator_test.go
- internal/service/fsx/windows_file_system_test.go
- internal/service/iam/openid_connect_provider_test.go
- internal/service/lightsail/domain_test.go
- internal/service/mq/broker_test.go
- internal/service/opsworks/application_test.go
- internal/service/opsworks/stack_test.go
- internal/service/ram/resource_share_accepter_test.go
- internal/service/rds/instance_test.go
- internal/service/mq/forge_test.go
- internal/service/route53/sweep.go
- internal/service/s3/bucket_test.go
- internal/service/s3control/bucket_test.go
- internal/service/sagemaker/code_repository_test.go
- internal/service/sagemaker/notebook_instance_test.go
- internal/service/shield/protection_test.go
- internal/service/s3/bucket_object_test.go
- internal/service/storagegateway/cached_iscsi_volume.go
- internal/service/storagegateway/cached_iscsi_volume_test.go
- internal/service/storagegateway/stored_iscsi_volume_test.go
- internal/service/transfer/access_test.go
- internal/service/transfer/server_test.go
patterns:
- patterns:
- pattern-regex: '[\"`].*(?<!(example))\.(com|net|org)\b'
- pattern-regex: '[\"`].*(?<!(amazonaws))\.com\b'
- pattern-regex: '[\"`].*(?<!(awsapps))\.com\b'
- pattern-regex: '(([-a-zA-Z0-9]{2,}\.)|(%[sdftq]))+(com|net|org)\b'
- pattern-inside: '($X : string)'
- pattern-not-regex: 'amazonaws\.com'
- pattern-not-regex: 'awsapps\.com'
- pattern-not-regex: '@(([-a-zA-Z0-9]{2,}\.)|(%[sdftq]))+(com|net|org)\b' # exclude domain names in email addresses
- pattern-not-regex: '[^-a-zA-Z0-9]example\.com'
- pattern-not-regex: '[^-a-zA-Z0-9]example\.net'
- pattern-not-regex: '[^-a-zA-Z0-9]example\.org'
- pattern-not-regex: 'github\.com'
- pattern-not-regex: 'aws\.amazon\.com'
- pattern-not-regex: 'graph\.facebook\.com'
- pattern-not-regex: 'people\.googleapis\.com'
- pattern-not-regex: 'www\.googleapis\.com'
- pattern-not-regex: 'accounts\.google\.com'
- pattern-not-regex: '[-a-z0-9]+\.apps\.googleusercontent\.com'
- pattern-not-regex: 'elasticbeanstalk\.com'
- pattern-not-regex: 'awsglobalaccelerator\.com'
- pattern-not-regex: 'cloudfront\.net'
- pattern-not-regex: 'http://json-schema\.org/draft-0\d/schema'
- pattern-not-regex: 'http://activemq.apache.org/schema/core'
- pattern-not-regex: 'mcr.microsoft.com'
severity: WARNING

- id: email-address
Expand Down
9 changes: 4 additions & 5 deletions internal/service/cloudfront/distribution_data_source_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ import (
func TestAccCloudFrontDistributionDataSource_basic(t *testing.T) {
dataSourceName := "data.aws_cloudfront_distribution.test"
resourceName := "aws_cloudfront_distribution.s3_distribution"
rInt := sdkacctest.RandInt()
rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix)

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { acctest.PreCheck(t); acctest.PreCheckPartitionHasService(cloudfront.EndpointsID, t) },
ErrorCheck: acctest.ErrorCheck(t, cloudfront.EndpointsID),
Providers: acctest.Providers,
Steps: []resource.TestStep{
{
Config: testAccDistributionDataConfig(rInt),
Config: testAccDistributionDataConfig(rName),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttrPair(dataSourceName, "arn", resourceName, "arn"),
resource.TestCheckResourceAttrPair(dataSourceName, "domain_name", resourceName, "domain_name"),
Expand All @@ -35,10 +35,9 @@ func TestAccCloudFrontDistributionDataSource_basic(t *testing.T) {
})
}

func testAccDistributionDataConfig(rInt int) string {
func testAccDistributionDataConfig(rName string) string {
return acctest.ConfigCompose(
testAccDistributionS3WithTagsConfig(rInt),
`
testAccDistributionS3WithTagsConfig(rName), `
data "aws_cloudfront_distribution" "test" {
id = aws_cloudfront_distribution.s3_distribution.id
}
Expand Down
Loading

0 comments on commit 2d1fffd

Please sign in to comment.