openapi: Fix response schema for pki list roles (#20782)

This commit is contained in:
Anton Averchenkov 2023-05-25 13:34:34 -04:00 committed by GitHub
parent 2fa0953759
commit 5b510ffeca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 11 deletions

View File

@ -37,9 +37,9 @@ func pathListRoles(b *backend) *framework.Path {
Description: "OK",
Fields: map[string]*framework.FieldSchema{
"keys": {
Type: framework.TypeMap,
Description: `List of keys`,
Required: false,
Type: framework.TypeStringSlice,
Description: "List of roles",
Required: true,
},
},
}},
@ -53,7 +53,7 @@ func pathListRoles(b *backend) *framework.Path {
}
func pathRoles(b *backend) *framework.Path {
pathRolesResponse := map[string]*framework.FieldSchema{
pathRolesResponseFields := map[string]*framework.FieldSchema{
"ttl": {
Type: framework.TypeDurationSecond,
Required: true,
@ -826,7 +826,7 @@ serviced by this role.`,
Responses: map[int][]framework.Response{
http.StatusOK: {{
Description: "OK",
Fields: pathRolesResponse,
Fields: pathRolesResponseFields,
}},
},
},
@ -835,7 +835,7 @@ serviced by this role.`,
Responses: map[int][]framework.Response{
http.StatusOK: {{
Description: "OK",
Fields: pathRolesResponse,
Fields: pathRolesResponseFields,
}},
},
// Read more about why these flags are set in backend.go.
@ -858,7 +858,7 @@ serviced by this role.`,
Responses: map[int][]framework.Response{
http.StatusOK: {{
Description: "OK",
Fields: pathRolesResponse,
Fields: pathRolesResponseFields,
}},
},
// Read more about why these flags are set in backend.go.

View File

@ -12,10 +12,9 @@ import (
"fmt"
"testing"
"github.com/hashicorp/vault/sdk/helper/testhelpers/schema"
"github.com/go-errors/errors"
"github.com/hashicorp/go-secure-stdlib/strutil"
"github.com/hashicorp/vault/sdk/helper/testhelpers/schema"
"github.com/hashicorp/vault/sdk/logical"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
@ -146,14 +145,14 @@ func TestPki_RoleKeyUsage(t *testing.T) {
}
resp, err = b.HandleRequest(context.Background(), roleReq)
schema.ValidateResponse(t, schema.GetResponseSchema(t, b.Route("roles/testrole"), logical.UpdateOperation), resp, true)
schema.ValidateResponse(t, schema.GetResponseSchema(t, b.Route(roleReq.Path), logical.UpdateOperation), resp, true)
if err != nil || (resp != nil && resp.IsError()) {
t.Fatalf("bad: err: %v resp: %#v", err, resp)
}
roleReq.Operation = logical.ReadOperation
resp, err = b.HandleRequest(context.Background(), roleReq)
schema.ValidateResponse(t, schema.GetResponseSchema(t, b.Route("roles/testrole"), logical.ReadOperation), resp, true)
schema.ValidateResponse(t, schema.GetResponseSchema(t, b.Route(roleReq.Path), logical.ReadOperation), resp, true)
if err != nil || (resp != nil && resp.IsError()) {
t.Fatalf("bad: err: %v resp: %#v", err, resp)
}