Skip to content

Commit

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

# Backport

This will backport the following commits from `main` to `8.8`:
- [[Fleet] Removes messageSigningService api definition from openApi
spec (elastic#156376)](elastic#156376)

<!--- Backport version: 8.9.7 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"David
Sánchez","email":"david.sanchezsoler@elastic.co"},"sourceCommit":{"committedDate":"2023-05-02T14:28:11Z","message":"[Fleet]
Removes messageSigningService api definition from openApi spec
(elastic#156376)\n\n## Summary\r\n\r\n- Removes message signing service api
definition from openAPI spec.\r\n- Updates warning message when
`acknowledge` param is missing or set
to\r\nfalse.","sha":"b9613994b11ce23bf511f097d3f4b2a974bfce93","branchLabelMapping":{"^v8.9.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","Team:Fleet","Team:Defend
Workflows","v8.8.0","v8.9.0"],"number":156376,"url":"elastic#156376
Removes messageSigningService api definition from openApi spec
(elastic#156376)\n\n## Summary\r\n\r\n- Removes message signing service api
definition from openAPI spec.\r\n- Updates warning message when
`acknowledge` param is missing or set
to\r\nfalse.","sha":"b9613994b11ce23bf511f097d3f4b2a974bfce93"}},"sourceBranch":"main","suggestedTargetBranches":["8.8"],"targetPullRequestStates":[{"branch":"8.8","label":"v8.8.0","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v8.9.0","labelRegex":"^v8.9.0$","isSourceBranch":true,"state":"MERGED","url":"elastic#156376
Removes messageSigningService api definition from openApi spec
(elastic#156376)\n\n## Summary\r\n\r\n- Removes message signing service api
definition from openAPI spec.\r\n- Updates warning message when
`acknowledge` param is missing or set
to\r\nfalse.","sha":"b9613994b11ce23bf511f097d3f4b2a974bfce93"}}]}]
BACKPORT-->

Co-authored-by: David Sánchez <david.sanchezsoler@elastic.co>
  • Loading branch information
kibanamachine and dasansol92 committed May 2, 2023
1 parent 2cd6d1b commit c7be057
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 c7be057

Please sign in to comment.