github.com/aquasecurity/trivy-iac@v0.8.1-0.20240127024015-3d8e412cf0ab/internal/adapters/terraform/aws/apigateway/namesv1_test.go (about) 1 package apigateway 2 3 import ( 4 "testing" 5 6 v1 "github.com/aquasecurity/defsec/pkg/providers/aws/apigateway/v1" 7 "github.com/aquasecurity/trivy-iac/internal/adapters/terraform/tftestutil" 8 "github.com/aquasecurity/trivy-iac/test/testutil" 9 ) 10 11 func Test_adaptDomainNamesV1(t *testing.T) { 12 tests := []struct { 13 name string 14 terraform string 15 expected []v1.DomainName 16 }{ 17 { 18 name: "defaults", 19 terraform: ` 20 resource "aws_api_gateway_domain_name" "example" { 21 } 22 `, 23 expected: []v1.DomainName{ 24 { 25 Name: String(""), 26 SecurityPolicy: String("TLS_1_0"), 27 }, 28 }, 29 }, 30 { 31 name: "basic", 32 terraform: ` 33 resource "aws_api_gateway_domain_name" "example" { 34 domain_name = "testing.com" 35 security_policy = "TLS_1_2" 36 } 37 `, 38 expected: []v1.DomainName{ 39 { 40 Name: String("testing.com"), 41 SecurityPolicy: String("TLS_1_2"), 42 }, 43 }, 44 }, 45 } 46 47 for _, test := range tests { 48 t.Run(test.name, func(t *testing.T) { 49 modules := tftestutil.CreateModulesFromSource(t, test.terraform, ".tf") 50 adapted := adaptDomainNamesV1(modules) 51 testutil.AssertDefsecEqual(t, test.expected, adapted) 52 }) 53 } 54 }