-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
api: add wrapper functions for GET auth and mount #25499
Conversation
CI Results: |
Build Results: |
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.
👍
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.
Seems good. Would be great if there could be some corresponding tests.
Thanks Ben! I had the same thought and will work on adding some. It doesn't look like there are unit tests for this file so I will see if I should create one or if there are other places where we are testing these API methods. FWIW, we are testing these in TFVP hashicorp/terraform-provider-vault#2145 :) |
func (c *Sys) GetAuth(path string) (*AuthMount, error) { | ||
return c.GetAuthWithContext(context.Background(), path) | ||
} |
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.
Do we need this one if we have the one below? From my experience, usually we add the *WithContext
and keep the one method without *WithContext
for backwards compatibility, but since these are both new, I think we could get away with just having GetAuthWithContext
.
With that said, the Vault conventions could be different.
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.
I had the same question but kept it for consistency.
api/sys_mounts_test.go
Outdated
@@ -9,8 +9,34 @@ import ( | |||
"testing" | |||
) | |||
|
|||
func TestGetMount(t *testing.T) { | |||
mockVaultServer := httptest.NewServer(http.HandlerFunc(mockVaultGetMountHandler)) |
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.
Would it be possible to test getting a real mount from a real / test vault server? I think this would mostly be testing the parsing / decoding logic.
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.
Done in 63344e0
I think it makes sense to support these endpoints in our go api:
Additionally, these are useful for TFVP