Skip to content

Commit

Permalink
fix incorrect path for policy requests
Browse files Browse the repository at this point in the history
  • Loading branch information
alice-li-kp authored and mrodden committed Jan 22, 2020
1 parent f40ec3d commit e74bb5e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ type Policies struct {
func (c *Client) GetPolicy(ctx context.Context, id string) (*Policy, error) {
policyresponse := Policies{}

req, err := c.newRequest("GET", fmt.Sprintf("keys/%s/policy", id), nil)
req, err := c.newRequest("GET", fmt.Sprintf("keys/%s/policies", id), nil)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -358,7 +358,7 @@ func (c *Client) SetPolicy(ctx context.Context, id string, prefer PreferReturn,

policyresponse := Policies{}

req, err := c.newRequest("PUT", fmt.Sprintf("keys/%s/policy", id), &policyRequest)
req, err := c.newRequest("PUT", fmt.Sprintf("keys/%s/policies", id), &policyRequest)
if err != nil {
return nil, err
}
Expand Down
4 changes: 2 additions & 2 deletions kp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -797,7 +797,7 @@ func TestPolicies(t *testing.T) {
"Policy Replace",
func(t *testing.T, api *API, ctx context.Context) error {
MockAuthURL(keyURL, http.StatusOK, testKeys)
MockAuthURL("/api/v2/keys/"+testKey+"/policy", http.StatusOK, testKeys)
MockAuthURL("/api/v2/keys/"+testKey+"/policies", http.StatusOK, testKeys)

_, err := api.SetPolicy(ctx, testKey, ReturnMinimal, 3)
assert.NoError(t, err)
Expand All @@ -812,7 +812,7 @@ func TestPolicies(t *testing.T) {
"Policy Get",
func(t *testing.T, api *API, ctx context.Context) error {
MockAuthURL(keyURL, http.StatusOK, testKeys)
MockAuthURL("/api/v2/keys/"+testKey+"/policy", http.StatusOK, testKeys)
MockAuthURL("/api/v2/keys/"+testKey+"/policies", http.StatusOK, testKeys)

_, err := api.GetPolicy(ctx, testKey)
assert.NoError(t, err)
Expand Down

0 comments on commit e74bb5e

Please sign in to comment.