-
Notifications
You must be signed in to change notification settings - Fork 551
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
gcp auth: fix bound_labels not being applied #1028
Conversation
Unrelated CI failure but looking into it 👍 |
7f43324
to
5a37759
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This works fine when I try it manually, though if possible I would like to see the tests checking the response from vault against the tf state for bound_labels, and right now it looks like only the tf state is being checked.
It looks like the tricky part here is that the vault API input for bound_labels is a list, while the response is a map, so that's why testGCPAuthBackendRoleCheck_attrs()
doesn't quite work as-is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
(This comment is out of scope of this PR, just satisfying my own curiosity.) One more thing I noticed about "token_policies.#": "2",
"token_policies.505685419": "policy_a",
"token_policies.889812584": "policy_b", Something like this would help cover that case: diff --git a/vault/resource_gcp_auth_backend_role_test.go b/vault/resource_gcp_auth_backend_role_test.go
index 55cc29a4..42bc1a0b 100644
--- a/vault/resource_gcp_auth_backend_role_test.go
+++ b/vault/resource_gcp_auth_backend_role_test.go
@@ -176,7 +176,10 @@ func testGCPAuthBackendRoleCheck_attrs(backend, name string) resource.TestCheckF
for stateAttr, apiAttr := range attrs {
if resp.Data[apiAttr] == nil && instanceState.Attributes[stateAttr] == "" {
- continue
+ // lists have a different index in instanceState.Attributes
+ if instanceState.Attributes[stateAttr+".#"] == "" || instanceState.Attributes[stateAttr+".#"] == "0" {
+ continue
+ }
}
var match bool
switch resp.Data[apiAttr].(type) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
A typo in the
vault_gcp_auth_backend_role
resulted in roles not applyingbound_labels
, even if one was specified. Unfortunately the test suite didn't explicitly test for this value and the GCP auth method doesn't return empty values for roles: https://github.com/hashicorp/vault-plugin-auth-gcp/blob/master/plugin/path_role.go#L307-L310.I've changed the test code slightly to check Vault for the appropriate resources.
Fixes #996.
Manual Test