Skip to content

Commit

Permalink
Add new tests for new GCE role specific attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
petems committed Oct 26, 2018
1 parent 85119dc commit 8e57629
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions vault/resource_gcp_auth_backend_role_test.go
Expand Up @@ -32,6 +32,24 @@ func TestGCPAuthBackendRole_basic(t *testing.T) {
})
}

func TestGCPAuthBackendRole_gce(t *testing.T) {
backend := acctest.RandomWithPrefix("tf-test-gcp-backend")
name := acctest.RandomWithPrefix("tf-test-gcp-role")
projectId := acctest.RandomWithPrefix("tf-test-gcp-project-id")

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testProviders,
CheckDestroy: testGCPAuthBackendRoleDestroy,
Steps: []resource.TestStep{
{
Config: testGCPAuthBackendRoleConfig_gce(backend, name, projectId),
Check: testGCPAuthBackendRoleCheck_attrs(backend, name),
},
},
})
}

func testGCPAuthBackendRoleDestroy(s *terraform.State) error {
client := testProvider.Meta().(*api.Client)

Expand Down Expand Up @@ -192,3 +210,28 @@ resource "vault_gcp_auth_backend_role" "test" {
`, backend, name, serviceAccount, projectId)

}

func testGCPAuthBackendRoleConfig_gce(backend, name, projectId string) string {

return fmt.Sprintf(`
resource "vault_auth_backend" "gcp" {
path = "%s"
type = "gcp"
}
resource "vault_gcp_auth_backend_role" "test" {
backend = "${vault_auth_backend.gcp.path}"
role = "%s"
type = "gce"
project_id = "%s"
ttl = 300
max_ttl = 600
policies = ["policy_a", "policy_b"]
bound_region = ["eu-west2"]
bound_zone = ["europe-west2-c"]
bound_labels = ["foo"]
}
`, backend, name, projectId)

}

0 comments on commit 8e57629

Please sign in to comment.