Skip to content

Commit

Permalink
[Fleet] Removes messageSigningService api definition from openApi spec (
Browse files Browse the repository at this point in the history
elastic#156376)

## Summary

- Removes message signing service api definition from openAPI spec.
- Updates warning message when `acknowledge` param is missing or set to
false.
  • Loading branch information
dasansol92 authored May 2, 2023
1 parent 8da8f89 commit b961399
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 105 deletions.
40 changes: 0 additions & 40 deletions x-pack/plugins/fleet/common/openapi/bundled.json
Original file line number Diff line number Diff line change
Expand Up @@ -3402,46 +3402,6 @@
},
"parameters": []
},
"/message_signing_service/rotate_key_pair": {
"post": {
"summary": "Rotate key pair",
"tags": [
"Message Signing Service"
],
"operationId": "rotate-key-pair",
"parameters": [
{
"schema": {
"type": "boolean"
},
"in": "query",
"name": "acknowledge",
"required": true,
"description": "When set to true, rotate key pair is done. If set to false or missing, it returns an error."
}
],
"responses": {
"200": {
"description": "OK",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"message": {
"type": "string"
}
}
}
}
}
},
"400": {
"$ref": "#/components/responses/error"
}
}
}
},
"/data_streams": {
"get": {
"summary": "List data streams",
Expand Down
27 changes: 0 additions & 27 deletions x-pack/plugins/fleet/common/openapi/bundled.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2113,33 +2113,6 @@ paths:
parameters:
- $ref: '#/components/parameters/kbn_xsrf'
parameters: []
/message_signing_service/rotate_key_pair:
post:
summary: Rotate key pair
tags:
- Message Signing Service
operationId: rotate-key-pair
parameters:
- schema:
type: boolean
in: query
name: acknowledge
required: true
description: >-
When set to true, rotate key pair is done. If set to false or
missing, it returns an error.
responses:
'200':
description: OK
content:
application/json:
schema:
type: object
properties:
message:
type: string
'400':
$ref: '#/components/responses/error'
/data_streams:
get:
summary: List data streams
Expand Down
4 changes: 0 additions & 4 deletions x-pack/plugins/fleet/common/openapi/entrypoint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,6 @@ paths:
/agent_policies/delete:
$ref: paths/agent_policies@delete.yaml

# Message signing service
/message_signing_service/rotate_key_pair:
$ref: paths/message_signing_service@rotate_key_pair.yaml

# Data streams endpoints
/data_streams:
$ref: paths/data_streams.yaml
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,19 @@
* 2.0.
*/

import { RotateKeyPairSchema } from './message_signing_service';
import { errorMessage, RotateKeyPairSchema } from './message_signing_service';

describe('RotateKeyPairSchema', () => {
it('should throw on `false` values for acknowledge', () => {
expect(() =>
RotateKeyPairSchema.query.validate({
acknowledge: false,
})
).toThrowError(
'You must acknowledge the risks of rotating the key pair with acknowledge=true in the request parameters.'
);
).toThrowError(errorMessage);
});

it('should allow without any query', () => {
expect(() => RotateKeyPairSchema.query.validate({})).toThrowError(
'You must acknowledge the risks of rotating the key pair with acknowledge=true in the request parameters.'
);
expect(() => RotateKeyPairSchema.query.validate({})).toThrowError(errorMessage);
});

it.each([1, 'string'])('should not allow non-boolean `%s` values for acknowledge', (value) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

import { schema } from '@kbn/config-schema';

export const errorMessage =
'Warning: this API will cause a key pair to rotate and should not be necessary in normal operation. If you proceed, you may need to reinstall Agents in your network. You must acknowledge the risks of rotating the key pair with acknowledge=true in the request parameters. For more information, reach out to your administrator.';
export const RotateKeyPairSchema = {
query: schema.maybe(
schema.object(
Expand All @@ -19,9 +21,7 @@ export const RotateKeyPairSchema = {
defaultValue: { acknowledge: false },
validate: (value: { acknowledge: boolean }) => {
if (!value || !value.acknowledge) {
throw new Error(
'You must acknowledge the risks of rotating the key pair with acknowledge=true in the request parameters.'
);
throw new Error(errorMessage);
}
},
}
Expand Down

0 comments on commit b961399

Please sign in to comment.