Skip to content

Commit

Permalink
backport of commit df30401 (#21457)
Browse files Browse the repository at this point in the history
Co-authored-by: Anton Averchenkov <[email protected]>
  • Loading branch information
1 parent 2863464 commit 4b00b33
Show file tree
Hide file tree
Showing 9 changed files with 38 additions and 27 deletions.
6 changes: 6 additions & 0 deletions builtin/logical/pki/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,8 @@ func TestIntegration_SetSignedWithBackwardsPemBundles(t *testing.T) {
require.False(t, resp.IsError(), "got an error from generating root ca: %#v", resp)
rootCert := resp.Data["certificate"].(string)

schema.ValidateResponse(t, schema.GetResponseSchema(t, rootBackend.Route("issuers/generate/root/internal"), logical.UpdateOperation), resp, true)

// generate intermediate
resp, err = intBackend.HandleRequest(context.Background(), &logical.Request{
Operation: logical.UpdateOperation,
Expand Down Expand Up @@ -298,6 +300,8 @@ func TestIntegration_SetSignedWithBackwardsPemBundles(t *testing.T) {
require.NoError(t, err, "failed setting up role example")
require.NotNil(t, resp, "got nil response from setting up role example: %#v", resp)

schema.ValidateResponse(t, schema.GetResponseSchema(t, intBackend.Route("roles/example"), logical.UpdateOperation), resp, true)

// Issue cert
resp, err = intBackend.HandleRequest(context.Background(), &logical.Request{
Operation: logical.UpdateOperation,
Expand All @@ -312,6 +316,8 @@ func TestIntegration_SetSignedWithBackwardsPemBundles(t *testing.T) {
require.NoError(t, err, "failed issuing a leaf cert from int ca")
require.NotNil(t, resp, "got nil response issuing a leaf cert from int ca")
require.False(t, resp.IsError(), "got an error issuing a leaf cert from int ca: %#v", resp)

schema.ValidateResponse(t, schema.GetResponseSchema(t, intBackend.Route("issue/example"), logical.UpdateOperation), resp, true)
}

func TestIntegration_CSRGeneration(t *testing.T) {
Expand Down
4 changes: 2 additions & 2 deletions builtin/logical/pki/path_fetch.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ var pathFetchReadSchema = map[int][]framework.Response{
Required: false,
},
"revocation_time": {
Type: framework.TypeString,
Type: framework.TypeInt64,
Description: `Revocation time`,
Required: false,
},
Expand All @@ -43,7 +43,7 @@ var pathFetchReadSchema = map[int][]framework.Response{
Required: false,
},
"ca_chain": {
Type: framework.TypeStringSlice,
Type: framework.TypeString,
Description: `Issuing CA Chain`,
Required: false,
},
Expand Down
2 changes: 1 addition & 1 deletion builtin/logical/pki/path_fetch_issuers.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ to be set on all PR secondary clusters.`,
Required: false,
},
"usage": {
Type: framework.TypeStringSlice,
Type: framework.TypeString,
Description: `Usage`,
Required: false,
},
Expand Down
14 changes: 7 additions & 7 deletions builtin/logical/pki/path_issue_sign.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,12 @@ func buildPathIssue(b *backend, pattern string, displayAttrs *framework.DisplayA
"serial_number": {
Type: framework.TypeString,
Description: `Serial Number`,
Required: false,
Required: true,
},
"expiration": {
Type: framework.TypeString,
Type: framework.TypeInt64,
Description: `Time of expiration`,
Required: false,
Required: true,
},
"private_key": {
Type: framework.TypeString,
Expand Down Expand Up @@ -163,7 +163,7 @@ func buildPathSign(b *backend, pattern string, displayAttrs *framework.DisplayAt
Required: true,
},
"expiration": {
Type: framework.TypeString,
Type: framework.TypeInt64,
Description: `Time of expiration`,
Required: true,
},
Expand Down Expand Up @@ -253,12 +253,12 @@ func buildPathIssuerSignVerbatim(b *backend, pattern string, displayAttrs *frame
"serial_number": {
Type: framework.TypeString,
Description: `Serial Number`,
Required: false,
Required: true,
},
"expiration": {
Type: framework.TypeString,
Type: framework.TypeInt64,
Description: `Time of expiration`,
Required: false,
Required: true,
},
"private_key": {
Type: framework.TypeString,
Expand Down
6 changes: 3 additions & 3 deletions builtin/logical/pki/path_manage_issuers.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func pathRotateRoot(b *backend) *framework.Path {
pattern := "root/rotate/" + framework.GenericNameRegex("exported")

displayAttrs := &framework.DisplayAttributes{
OperationPrefix: operationPrefixPKIIssuers,
OperationPrefix: operationPrefixPKI,
OperationVerb: "rotate",
OperationSuffix: "root",
}
Expand All @@ -55,8 +55,8 @@ func buildPathGenerateRoot(b *backend, pattern string, displayAttrs *framework.D
Description: "OK",
Fields: map[string]*framework.FieldSchema{
"expiration": {
Type: framework.TypeString,
Description: `The expiration of the given.`,
Type: framework.TypeInt64,
Description: `The expiration of the given issuer.`,
Required: true,
},
"serial_number": {
Expand Down
4 changes: 2 additions & 2 deletions builtin/logical/pki/path_revoke.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ signed by an issuer in this mount.`,
Description: "OK",
Fields: map[string]*framework.FieldSchema{
"revocation_time": {
Type: framework.TypeDurationSecond,
Type: framework.TypeInt64,
Description: `Revocation Time`,
Required: false,
},
Expand Down Expand Up @@ -176,7 +176,7 @@ be in PEM format.`,
Description: "OK",
Fields: map[string]*framework.FieldSchema{
"revocation_time": {
Type: framework.TypeDurationSecond,
Type: framework.TypeInt64,
Description: `Revocation Time`,
Required: false,
},
Expand Down
8 changes: 4 additions & 4 deletions builtin/logical/pki/path_roles.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func pathListRoles(b *backend) *framework.Path {
func pathRoles(b *backend) *framework.Path {
pathRolesResponseFields := map[string]*framework.FieldSchema{
"ttl": {
Type: framework.TypeDurationSecond,
Type: framework.TypeInt64,
Required: true,
Description: `The lease duration (validity period of the
certificate) if no specific lease duration is requested.
Expand All @@ -65,7 +65,7 @@ value or the value of max_ttl, whichever is shorter.`,
},

"max_ttl": {
Type: framework.TypeDurationSecond,
Type: framework.TypeInt64,
Required: true,
Description: `The maximum allowed lease duration. If not
set, defaults to the system maximum lease TTL.`,
Expand Down Expand Up @@ -384,8 +384,8 @@ information, which must include an oid, and may include a notice and/or cps url,
Description: `Mark Basic Constraints valid when issuing non-CA certificates.`,
},
"not_before_duration": {
Type: framework.TypeDurationSecond,
Description: `The duration before now which the certificate needs to be backdated by.`,
Type: framework.TypeInt64,
Description: `The duration in seconds before now which the certificate needs to be backdated by.`,
},
"not_after": {
Type: framework.TypeString,
Expand Down
18 changes: 10 additions & 8 deletions builtin/logical/pki/path_tidy.go
Original file line number Diff line number Diff line change
Expand Up @@ -279,8 +279,9 @@ func pathTidyCancel(b *backend) *framework.Path {
Required: false,
},
"tidy_cross_cluster_revoked_certs": {
Type: framework.TypeBool,
Required: false,
Type: framework.TypeBool,
Description: `Tidy the cross-cluster revoked certificate store`,
Required: false,
},
"tidy_revocation_queue": {
Type: framework.TypeBool,
Expand Down Expand Up @@ -387,8 +388,8 @@ func pathTidyStatus(b *backend) *framework.Path {
Required: true,
},
"tidy_cross_cluster_revoked_certs": {
Type: framework.TypeString,
Description: ``,
Type: framework.TypeBool,
Description: `Tidy the cross-cluster revoked certificate store`,
Required: false,
},
"tidy_acme": {
Expand Down Expand Up @@ -617,7 +618,7 @@ available on the tidy-status endpoint.`,
Required: true,
},
"revocation_queue_safety_buffer": {
Type: framework.TypeDurationSecond,
Type: framework.TypeInt,
Required: true,
},
"publish_stored_certificate_count_metrics": {
Expand Down Expand Up @@ -698,8 +699,9 @@ available on the tidy-status endpoint.`,
Required: true,
},
"tidy_cross_cluster_revoked_certs": {
Type: framework.TypeBool,
Required: true,
Type: framework.TypeBool,
Description: `Tidy the cross-cluster revoked certificate store`,
Required: true,
},
"tidy_revocation_queue": {
Type: framework.TypeBool,
Expand All @@ -710,7 +712,7 @@ available on the tidy-status endpoint.`,
Required: true,
},
"revocation_queue_safety_buffer": {
Type: framework.TypeDurationSecond,
Type: framework.TypeInt,
Required: true,
},
"publish_stored_certificate_count_metrics": {
Expand Down
3 changes: 3 additions & 0 deletions changelog/21449.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
openapi: Fix response schema for PKI Issue requests
```

0 comments on commit 4b00b33

Please sign in to comment.