Skip to content

Commit d16013a

Browse files
committed
test: secrets manager access token config
OTT-6909
1 parent 4879b8d commit d16013a

File tree

1 file changed

+63
-0
lines changed

1 file changed

+63
-0
lines changed

awsmt/resource_source_location_test.go

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,12 @@ func TestAccSourceLocationResourceUpdateAccessControl(t *testing.T) {
112112
resource.TestCheckResourceAttr(resourceName, "tags.Environment", "dev"),
113113
),
114114
},
115+
// Import resource by arn
116+
{
117+
ResourceName: resourceName,
118+
ImportState: true,
119+
ImportStateId: "arn:aws:mediatailor:eu-central-1:985600762523:sourceLocation/" + name,
120+
},
115121
// Update and Read testing
116122
{
117123
Config: basicSourceLocationWithAccessConfig(name, baseUrl2, k3, v3, k2, v2),
@@ -130,6 +136,37 @@ func TestAccSourceLocationResourceUpdateAccessControl(t *testing.T) {
130136
})
131137
}
132138

139+
func TestAccSourceLocationAccessConfiguration_SMATC(t *testing.T) {
140+
secretStringKey := "access-token"
141+
headerName := "ACCESS-TOKEN"
142+
secretArn := "arn:aws:secretsmanager:eu-central-1:985600762523:secret:terraform-provider-aws-acceptance-testing-Hr2kg1"
143+
144+
resourceName := "awsmt_source_location.test_source_location_smatc"
145+
146+
resource.ParallelTest(t, resource.TestCase{
147+
PreCheck: func() {
148+
testAccPreCheck(t)
149+
},
150+
ProtoV6ProviderFactories: testAccProtoV6ProviderFactories,
151+
Steps: []resource.TestStep{
152+
{
153+
Config: sourceLocationWithSMATC(secretArn, secretStringKey, headerName),
154+
Check: resource.ComposeTestCheckFunc(
155+
resource.TestCheckResourceAttr(resourceName, "access_configuration.access_type", "SECRETS_MANAGER_ACCESS_TOKEN"),
156+
resource.TestCheckResourceAttr(resourceName, "access_configuration.smatc.header_name", headerName),
157+
resource.TestCheckResourceAttr(resourceName, "access_configuration.smatc.secret_arn", secretArn),
158+
resource.TestCheckResourceAttr(resourceName, "access_configuration.smatc.secret_string_key", secretStringKey),
159+
),
160+
},
161+
// Import resource
162+
{
163+
ResourceName: resourceName,
164+
ImportState: true,
165+
},
166+
},
167+
})
168+
}
169+
133170
func TestAccSourceLocationDeleteVodResource(t *testing.T) {
134171
resourceName := "awsmt_source_location.test_source_location"
135172
resource.Test(t, resource.TestCase{
@@ -260,3 +297,29 @@ func basicSourceLocationWithVodSource() string {
260297
}
261298
`
262299
}
300+
301+
func sourceLocationWithSMATC(secretArn, secretStringKey, headerName string) string {
302+
return fmt.Sprintf(`
303+
resource "awsmt_source_location" "test_source_location_smatc"{
304+
name = "sl-smatc"
305+
http_configuration = {
306+
base_url = "https://ott-mediatailor-test.s3.eu-central-1.amazonaws.com"
307+
}
308+
access_configuration = {
309+
access_type = "SECRETS_MANAGER_ACCESS_TOKEN"
310+
smatc = {
311+
header_name = "%[1]s"
312+
secret_arn = "%[2]s"
313+
secret_string_key = "%[3]s"
314+
}
315+
}
316+
}
317+
data "awsmt_source_location" "read" {
318+
name = awsmt_source_location.test_source_location_smatc.name
319+
}
320+
output "awsmt_source_location" {
321+
value = data.awsmt_source_location.read
322+
}
323+
324+
`, headerName, secretArn, secretStringKey)
325+
}

0 commit comments

Comments
 (0)