Skip to content

Commit

Permalink
add tests for import and update
Browse files Browse the repository at this point in the history
  • Loading branch information
kpcraig committed Dec 11, 2024
1 parent ca2ddcf commit badbb8a
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions vault/resource_aws_secret_backend_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,26 @@ func TestAccAWSSecretBackend_fallback(t *testing.T) {
resource.TestCheckResourceAttr(resourceName, consts.FieldSTSRegion, "us-west-1"),
resource.TestCheckResourceAttr(resourceName, consts.FieldSTSFallbackRegions+".0", "us-east-2"),
resource.TestCheckResourceAttr(resourceName, consts.FieldSTSFallbackRegions+".1", "us-east-1"),
resource.TestCheckResourceAttr(resourceName, consts.FieldSTSFallbackRegions+".#", "2"),
resource.TestCheckResourceAttr(resourceName, consts.FieldSTSFallbackEndpoints+".0", "https://sts.us-east-2.amazonaws.com"),
resource.TestCheckResourceAttr(resourceName, consts.FieldSTSFallbackEndpoints+".1", "https://sts.us-east-1.amazonaws.com"),
resource.TestCheckResourceAttr(resourceName, consts.FieldSTSFallbackEndpoints+".#", "2"),
),
},
testutil.GetImportTestStep(resourceName, false, nil, consts.FieldSecretKey, consts.FieldDisableRemount),
{
Config: testAccAWSSecretBackendConfig_fallbackUpdated(path, accessKey, secretKey),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr(resourceName, consts.FieldPath, path),
resource.TestCheckResourceAttr(resourceName, consts.FieldDescription, "updated description"),
resource.TestCheckResourceAttr(resourceName, consts.FieldSTSEndpoint, "https://sts.us-central-2.amazonaws.com"),
resource.TestCheckResourceAttr(resourceName, consts.FieldSTSRegion, "us-central-2"),
resource.TestCheckResourceAttr(resourceName, consts.FieldSTSFallbackRegions+".0", "us-east-2"),
resource.TestCheckResourceAttr(resourceName, consts.FieldSTSFallbackRegions+".1", "eu-central-1"),
resource.TestCheckResourceAttr(resourceName, consts.FieldSTSFallbackRegions+".#", "2"),
resource.TestCheckResourceAttr(resourceName, consts.FieldSTSFallbackEndpoints+".0", "https://sts.us-east-2.amazonaws.com"),
resource.TestCheckResourceAttr(resourceName, consts.FieldSTSFallbackEndpoints+".1", "https://sts.eu-central-1.amazonaws.com"),
resource.TestCheckResourceAttr(resourceName, consts.FieldSTSFallbackEndpoints+".#", "2"),
),
},
},
Expand Down Expand Up @@ -241,6 +259,25 @@ resource "vault_aws_secret_backend" "test" {
}`, path, accessKey, secretKey)
}

func testAccAWSSecretBackendConfig_fallbackUpdated(path, accessKey, secretKey string) string {
return fmt.Sprintf(`
resource "vault_aws_secret_backend" "test" {
path = "%s"
description = "updated description"
default_lease_ttl_seconds = 60
max_lease_ttl_seconds = 1000
access_key = "%s"
secret_key = "%s"
region = "us-central-2"
sts_endpoint = "https://sts.us-central-2.amazonaws.com"
sts_region = "us-central-2"
sts_fallback_regions = ["us-east-2", "eu-central-1"]
sts_fallback_endpoints = ["https://sts.us-east-2.amazonaws.com","https://sts.eu-central-1.amazonaws.com"]
}`, path, accessKey, secretKey)
}

func testAccAWSSecretBackendConfig_wifBasic(path string) string {
return fmt.Sprintf(`
resource "vault_aws_secret_backend" "test" {
Expand Down

0 comments on commit badbb8a

Please sign in to comment.