github.com/aquasecurity/trivy-iac@v0.8.1-0.20240127024015-3d8e412cf0ab/pkg/scanners/cloudformation/parser/fn_base64_test.go (about) 1 package parser 2 3 import ( 4 "github.com/aquasecurity/defsec/pkg/types" 5 "github.com/aquasecurity/trivy-iac/pkg/scanners/cloudformation/cftypes" 6 "github.com/stretchr/testify/assert" 7 "github.com/stretchr/testify/require" 8 9 "testing" 10 ) 11 12 func Test_resolve_base64_value(t *testing.T) { 13 14 property := &Property{ 15 ctx: &FileContext{}, 16 name: "BucketName", 17 rng: types.NewRange("testfile", 1, 1, "", nil), 18 Inner: PropertyInner{ 19 Type: cftypes.Map, 20 Value: map[string]*Property{ 21 "Fn::Base64": { 22 Inner: PropertyInner{ 23 Type: cftypes.String, 24 Value: "HelloWorld", 25 }, 26 }, 27 }, 28 }, 29 } 30 31 resolvedProperty, success := ResolveIntrinsicFunc(property) 32 require.True(t, success) 33 34 assert.Equal(t, "SGVsbG9Xb3JsZA==", resolvedProperty.AsString()) 35 }