Skip to content

Commit

Permalink
Improve test for ldap backend
Browse files Browse the repository at this point in the history
  • Loading branch information
lawliet89 committed Sep 25, 2018
1 parent b4d19be commit 9e3e39e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
12 changes: 6 additions & 6 deletions vault/resource_aws_auth_backend_role_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,12 +219,12 @@ func testAccAWSAuthBackendRoleCheck_attrs(backend, role string) resource.TestChe
"inferred_entity_type": "inferred_entity_type",
"inferred_aws_region": "inferred_aws_region",
"resolve_aws_unique_ids": "resolve_aws_unique_ids",
"ttl": "ttl",
"max_ttl": "max_ttl",
"period": "period",
"policies": "policies",
"allow_instance_migration": "allow_instance_migration",
"disallow_reauthentication": "disallow_reauthentication",
"ttl": "ttl",
"max_ttl": "max_ttl",
"period": "period",
"policies": "policies",
"allow_instance_migration": "allow_instance_migration",
"disallow_reauthentication": "disallow_reauthentication",
}
for stateAttr, apiAttr := range attrs {
if resp.Data[apiAttr] == nil && instanceState.Attributes[stateAttr] == "" {
Expand Down
10 changes: 9 additions & 1 deletion vault/resource_ldap_auth_backend_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,11 @@ func testLDAPAuthBackendCheck_attrs(path string) resource.TestCheckFunc {
return err
}

// Check that `bindpass`, if present in the state, is not returned by the API
if instanceState.Attributes["bindpass"] != "" && resp.Data["bindpass"] != nil {
return fmt.Errorf("expected api field bindpass to not be returned, but was %q", resp.Data["bindpass"])
}

attrs := map[string]string{
"url": "url",
"starttls": "starttls",
Expand All @@ -94,7 +99,6 @@ func testLDAPAuthBackendCheck_attrs(path string) resource.TestCheckFunc {
"insecure_tls": "insecure_tls",
"certificate": "certificate",
"binddn": "binddn",
"bindpass": "bindpass",
"userdn": "userdn",
"userattr": "userattr",
"discoverdn": "discoverdn",
Expand Down Expand Up @@ -180,6 +184,10 @@ resource "vault_ldap_auth_backend" "test" {
tls_min_version = "tls11"
tls_max_version = "tls12"
insecure_tls = false
binddn = "cn=example.com"
bindpass = "supersecurepassword"
discoverdn = false
deny_null_bind = true
}
`, path)

Expand Down

0 comments on commit 9e3e39e

Please sign in to comment.