mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
[Response Ops][Actions] Remove deprecated HTTP APIs (#197510)
Resolves https://github.com/elastic/kibana/issues/90382 ## Summary Removes legacy action APIs for 9.0 and updates all tests that still used the legacy APIs to use the current APIs. Also did some renaming of action -> connector in the files I had to touch. Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
This commit is contained in:
parent
c7b8ca00de
commit
dd90b67a87
122 changed files with 677 additions and 4841 deletions
|
@ -344,530 +344,6 @@
|
|||
},
|
||||
"openapi": "3.0.0",
|
||||
"paths": {
|
||||
"/api/actions": {
|
||||
"get": {
|
||||
"deprecated": true,
|
||||
"operationId": "%2Fapi%2Factions#0",
|
||||
"parameters": [
|
||||
{
|
||||
"description": "The version of the API to use",
|
||||
"in": "header",
|
||||
"name": "elastic-api-version",
|
||||
"schema": {
|
||||
"default": "2023-10-31",
|
||||
"enum": [
|
||||
"2023-10-31"
|
||||
],
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {},
|
||||
"summary": "Get all connectors",
|
||||
"tags": [
|
||||
"connectors"
|
||||
]
|
||||
}
|
||||
},
|
||||
"/api/actions/action": {
|
||||
"post": {
|
||||
"deprecated": true,
|
||||
"operationId": "%2Fapi%2Factions%2Faction#0",
|
||||
"parameters": [
|
||||
{
|
||||
"description": "The version of the API to use",
|
||||
"in": "header",
|
||||
"name": "elastic-api-version",
|
||||
"schema": {
|
||||
"default": "2023-10-31",
|
||||
"enum": [
|
||||
"2023-10-31"
|
||||
],
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
{
|
||||
"description": "A required header to protect against CSRF attacks",
|
||||
"in": "header",
|
||||
"name": "kbn-xsrf",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"example": "true",
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
],
|
||||
"requestBody": {
|
||||
"content": {
|
||||
"application/json; Elastic-Api-Version=2023-10-31": {
|
||||
"schema": {
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"actionTypeId": {
|
||||
"description": "The connector type identifier.",
|
||||
"type": "string"
|
||||
},
|
||||
"config": {
|
||||
"additionalProperties": {},
|
||||
"default": {},
|
||||
"type": "object"
|
||||
},
|
||||
"name": {
|
||||
"description": "The display name for the connector.",
|
||||
"type": "string"
|
||||
},
|
||||
"secrets": {
|
||||
"additionalProperties": {},
|
||||
"default": {},
|
||||
"type": "object"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"name",
|
||||
"actionTypeId"
|
||||
],
|
||||
"type": "object"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"responses": {
|
||||
"200": {
|
||||
"content": {
|
||||
"application/json; Elastic-Api-Version=2023-10-31": {
|
||||
"schema": {
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"config": {
|
||||
"additionalProperties": {},
|
||||
"type": "object"
|
||||
},
|
||||
"connector_type_id": {
|
||||
"description": "The connector type identifier.",
|
||||
"type": "string"
|
||||
},
|
||||
"id": {
|
||||
"description": "The identifier for the connector.",
|
||||
"type": "string"
|
||||
},
|
||||
"is_deprecated": {
|
||||
"description": "Indicates whether the connector is deprecated.",
|
||||
"type": "boolean"
|
||||
},
|
||||
"is_missing_secrets": {
|
||||
"description": "Indicates whether the connector is missing secrets.",
|
||||
"type": "boolean"
|
||||
},
|
||||
"is_preconfigured": {
|
||||
"description": "Indicates whether the connector is preconfigured. If true, the `config` and `is_missing_secrets` properties are omitted from the response. ",
|
||||
"type": "boolean"
|
||||
},
|
||||
"is_system_action": {
|
||||
"description": "Indicates whether the connector is used for system actions.",
|
||||
"type": "boolean"
|
||||
},
|
||||
"name": {
|
||||
"description": " The name of the rule.",
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"id",
|
||||
"name",
|
||||
"connector_type_id",
|
||||
"is_preconfigured",
|
||||
"is_deprecated",
|
||||
"is_system_action"
|
||||
],
|
||||
"type": "object"
|
||||
}
|
||||
}
|
||||
},
|
||||
"description": "Indicates a successful call."
|
||||
}
|
||||
},
|
||||
"summary": "Create a connector",
|
||||
"tags": [
|
||||
"connectors"
|
||||
]
|
||||
}
|
||||
},
|
||||
"/api/actions/action/{id}": {
|
||||
"delete": {
|
||||
"deprecated": true,
|
||||
"description": "WARNING: When you delete a connector, it cannot be recovered.",
|
||||
"operationId": "%2Fapi%2Factions%2Faction%2F%7Bid%7D#0",
|
||||
"parameters": [
|
||||
{
|
||||
"description": "The version of the API to use",
|
||||
"in": "header",
|
||||
"name": "elastic-api-version",
|
||||
"schema": {
|
||||
"default": "2023-10-31",
|
||||
"enum": [
|
||||
"2023-10-31"
|
||||
],
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
{
|
||||
"description": "A required header to protect against CSRF attacks",
|
||||
"in": "header",
|
||||
"name": "kbn-xsrf",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"example": "true",
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
{
|
||||
"description": "An identifier for the connector.",
|
||||
"in": "path",
|
||||
"name": "id",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"204": {
|
||||
"description": "Indicates a successful call."
|
||||
}
|
||||
},
|
||||
"summary": "Delete a connector",
|
||||
"tags": [
|
||||
"connectors"
|
||||
]
|
||||
},
|
||||
"get": {
|
||||
"deprecated": true,
|
||||
"operationId": "%2Fapi%2Factions%2Faction%2F%7Bid%7D#1",
|
||||
"parameters": [
|
||||
{
|
||||
"description": "The version of the API to use",
|
||||
"in": "header",
|
||||
"name": "elastic-api-version",
|
||||
"schema": {
|
||||
"default": "2023-10-31",
|
||||
"enum": [
|
||||
"2023-10-31"
|
||||
],
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
{
|
||||
"description": "An identifier for the connector.",
|
||||
"in": "path",
|
||||
"name": "id",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"content": {
|
||||
"application/json; Elastic-Api-Version=2023-10-31": {
|
||||
"schema": {
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"config": {
|
||||
"additionalProperties": {},
|
||||
"type": "object"
|
||||
},
|
||||
"connector_type_id": {
|
||||
"description": "The connector type identifier.",
|
||||
"type": "string"
|
||||
},
|
||||
"id": {
|
||||
"description": "The identifier for the connector.",
|
||||
"type": "string"
|
||||
},
|
||||
"is_deprecated": {
|
||||
"description": "Indicates whether the connector is deprecated.",
|
||||
"type": "boolean"
|
||||
},
|
||||
"is_missing_secrets": {
|
||||
"description": "Indicates whether the connector is missing secrets.",
|
||||
"type": "boolean"
|
||||
},
|
||||
"is_preconfigured": {
|
||||
"description": "Indicates whether the connector is preconfigured. If true, the `config` and `is_missing_secrets` properties are omitted from the response. ",
|
||||
"type": "boolean"
|
||||
},
|
||||
"is_system_action": {
|
||||
"description": "Indicates whether the connector is used for system actions.",
|
||||
"type": "boolean"
|
||||
},
|
||||
"name": {
|
||||
"description": " The name of the rule.",
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"id",
|
||||
"name",
|
||||
"connector_type_id",
|
||||
"is_preconfigured",
|
||||
"is_deprecated",
|
||||
"is_system_action"
|
||||
],
|
||||
"type": "object"
|
||||
}
|
||||
}
|
||||
},
|
||||
"description": "Indicates a successful call."
|
||||
}
|
||||
},
|
||||
"summary": "Get connector information",
|
||||
"tags": [
|
||||
"connectors"
|
||||
]
|
||||
},
|
||||
"put": {
|
||||
"deprecated": true,
|
||||
"operationId": "%2Fapi%2Factions%2Faction%2F%7Bid%7D#2",
|
||||
"parameters": [
|
||||
{
|
||||
"description": "The version of the API to use",
|
||||
"in": "header",
|
||||
"name": "elastic-api-version",
|
||||
"schema": {
|
||||
"default": "2023-10-31",
|
||||
"enum": [
|
||||
"2023-10-31"
|
||||
],
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
{
|
||||
"description": "A required header to protect against CSRF attacks",
|
||||
"in": "header",
|
||||
"name": "kbn-xsrf",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"example": "true",
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
{
|
||||
"description": "An identifier for the connector.",
|
||||
"in": "path",
|
||||
"name": "id",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
],
|
||||
"requestBody": {
|
||||
"content": {
|
||||
"application/json; Elastic-Api-Version=2023-10-31": {
|
||||
"schema": {
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"config": {
|
||||
"additionalProperties": {},
|
||||
"default": {},
|
||||
"type": "object"
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
},
|
||||
"secrets": {
|
||||
"additionalProperties": {},
|
||||
"default": {},
|
||||
"type": "object"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"name"
|
||||
],
|
||||
"type": "object"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"responses": {
|
||||
"200": {
|
||||
"content": {
|
||||
"application/json; Elastic-Api-Version=2023-10-31": {
|
||||
"schema": {
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"config": {
|
||||
"additionalProperties": {},
|
||||
"type": "object"
|
||||
},
|
||||
"connector_type_id": {
|
||||
"description": "The connector type identifier.",
|
||||
"type": "string"
|
||||
},
|
||||
"id": {
|
||||
"description": "The identifier for the connector.",
|
||||
"type": "string"
|
||||
},
|
||||
"is_deprecated": {
|
||||
"description": "Indicates whether the connector is deprecated.",
|
||||
"type": "boolean"
|
||||
},
|
||||
"is_missing_secrets": {
|
||||
"description": "Indicates whether the connector is missing secrets.",
|
||||
"type": "boolean"
|
||||
},
|
||||
"is_preconfigured": {
|
||||
"description": "Indicates whether the connector is preconfigured. If true, the `config` and `is_missing_secrets` properties are omitted from the response. ",
|
||||
"type": "boolean"
|
||||
},
|
||||
"is_system_action": {
|
||||
"description": "Indicates whether the connector is used for system actions.",
|
||||
"type": "boolean"
|
||||
},
|
||||
"name": {
|
||||
"description": " The name of the rule.",
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"id",
|
||||
"name",
|
||||
"connector_type_id",
|
||||
"is_preconfigured",
|
||||
"is_deprecated",
|
||||
"is_system_action"
|
||||
],
|
||||
"type": "object"
|
||||
}
|
||||
}
|
||||
},
|
||||
"description": "Indicates a successful call."
|
||||
}
|
||||
},
|
||||
"summary": "Update a connector",
|
||||
"tags": [
|
||||
"connectors"
|
||||
]
|
||||
}
|
||||
},
|
||||
"/api/actions/action/{id}/_execute": {
|
||||
"post": {
|
||||
"deprecated": true,
|
||||
"operationId": "%2Fapi%2Factions%2Faction%2F%7Bid%7D%2F_execute#0",
|
||||
"parameters": [
|
||||
{
|
||||
"description": "The version of the API to use",
|
||||
"in": "header",
|
||||
"name": "elastic-api-version",
|
||||
"schema": {
|
||||
"default": "2023-10-31",
|
||||
"enum": [
|
||||
"2023-10-31"
|
||||
],
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
{
|
||||
"description": "A required header to protect against CSRF attacks",
|
||||
"in": "header",
|
||||
"name": "kbn-xsrf",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"example": "true",
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
{
|
||||
"description": "An identifier for the connector.",
|
||||
"in": "path",
|
||||
"name": "id",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
],
|
||||
"requestBody": {
|
||||
"content": {
|
||||
"application/json; Elastic-Api-Version=2023-10-31": {
|
||||
"schema": {
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"params": {
|
||||
"additionalProperties": {},
|
||||
"type": "object"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"params"
|
||||
],
|
||||
"type": "object"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"responses": {
|
||||
"200": {
|
||||
"content": {
|
||||
"application/json; Elastic-Api-Version=2023-10-31": {
|
||||
"schema": {
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"config": {
|
||||
"additionalProperties": {},
|
||||
"type": "object"
|
||||
},
|
||||
"connector_type_id": {
|
||||
"description": "The connector type identifier.",
|
||||
"type": "string"
|
||||
},
|
||||
"id": {
|
||||
"description": "The identifier for the connector.",
|
||||
"type": "string"
|
||||
},
|
||||
"is_deprecated": {
|
||||
"description": "Indicates whether the connector is deprecated.",
|
||||
"type": "boolean"
|
||||
},
|
||||
"is_missing_secrets": {
|
||||
"description": "Indicates whether the connector is missing secrets.",
|
||||
"type": "boolean"
|
||||
},
|
||||
"is_preconfigured": {
|
||||
"description": "Indicates whether the connector is preconfigured. If true, the `config` and `is_missing_secrets` properties are omitted from the response. ",
|
||||
"type": "boolean"
|
||||
},
|
||||
"is_system_action": {
|
||||
"description": "Indicates whether the connector is used for system actions.",
|
||||
"type": "boolean"
|
||||
},
|
||||
"name": {
|
||||
"description": " The name of the rule.",
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"id",
|
||||
"name",
|
||||
"connector_type_id",
|
||||
"is_preconfigured",
|
||||
"is_deprecated",
|
||||
"is_system_action"
|
||||
],
|
||||
"type": "object"
|
||||
}
|
||||
}
|
||||
},
|
||||
"description": "Indicates a successful call."
|
||||
}
|
||||
},
|
||||
"summary": "Run a connector",
|
||||
"tags": [
|
||||
"connectors"
|
||||
]
|
||||
}
|
||||
},
|
||||
"/api/actions/connector/{id}": {
|
||||
"delete": {
|
||||
"description": "WARNING: When you delete a connector, it cannot be recovered.",
|
||||
|
@ -1429,31 +905,6 @@
|
|||
]
|
||||
}
|
||||
},
|
||||
"/api/actions/list_action_types": {
|
||||
"get": {
|
||||
"deprecated": true,
|
||||
"operationId": "%2Fapi%2Factions%2Flist_action_types#0",
|
||||
"parameters": [
|
||||
{
|
||||
"description": "The version of the API to use",
|
||||
"in": "header",
|
||||
"name": "elastic-api-version",
|
||||
"schema": {
|
||||
"default": "2023-10-31",
|
||||
"enum": [
|
||||
"2023-10-31"
|
||||
],
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {},
|
||||
"summary": "Get connector types",
|
||||
"tags": [
|
||||
"connectors"
|
||||
]
|
||||
}
|
||||
},
|
||||
"/api/alerting/rule/{id}": {
|
||||
"delete": {
|
||||
"operationId": "%2Fapi%2Falerting%2Frule%2F%7Bid%7D#2",
|
||||
|
|
|
@ -344,530 +344,6 @@
|
|||
},
|
||||
"openapi": "3.0.0",
|
||||
"paths": {
|
||||
"/api/actions": {
|
||||
"get": {
|
||||
"deprecated": true,
|
||||
"operationId": "%2Fapi%2Factions#0",
|
||||
"parameters": [
|
||||
{
|
||||
"description": "The version of the API to use",
|
||||
"in": "header",
|
||||
"name": "elastic-api-version",
|
||||
"schema": {
|
||||
"default": "2023-10-31",
|
||||
"enum": [
|
||||
"2023-10-31"
|
||||
],
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {},
|
||||
"summary": "Get all connectors",
|
||||
"tags": [
|
||||
"connectors"
|
||||
]
|
||||
}
|
||||
},
|
||||
"/api/actions/action": {
|
||||
"post": {
|
||||
"deprecated": true,
|
||||
"operationId": "%2Fapi%2Factions%2Faction#0",
|
||||
"parameters": [
|
||||
{
|
||||
"description": "The version of the API to use",
|
||||
"in": "header",
|
||||
"name": "elastic-api-version",
|
||||
"schema": {
|
||||
"default": "2023-10-31",
|
||||
"enum": [
|
||||
"2023-10-31"
|
||||
],
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
{
|
||||
"description": "A required header to protect against CSRF attacks",
|
||||
"in": "header",
|
||||
"name": "kbn-xsrf",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"example": "true",
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
],
|
||||
"requestBody": {
|
||||
"content": {
|
||||
"application/json; Elastic-Api-Version=2023-10-31": {
|
||||
"schema": {
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"actionTypeId": {
|
||||
"description": "The connector type identifier.",
|
||||
"type": "string"
|
||||
},
|
||||
"config": {
|
||||
"additionalProperties": {},
|
||||
"default": {},
|
||||
"type": "object"
|
||||
},
|
||||
"name": {
|
||||
"description": "The display name for the connector.",
|
||||
"type": "string"
|
||||
},
|
||||
"secrets": {
|
||||
"additionalProperties": {},
|
||||
"default": {},
|
||||
"type": "object"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"name",
|
||||
"actionTypeId"
|
||||
],
|
||||
"type": "object"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"responses": {
|
||||
"200": {
|
||||
"content": {
|
||||
"application/json; Elastic-Api-Version=2023-10-31": {
|
||||
"schema": {
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"config": {
|
||||
"additionalProperties": {},
|
||||
"type": "object"
|
||||
},
|
||||
"connector_type_id": {
|
||||
"description": "The connector type identifier.",
|
||||
"type": "string"
|
||||
},
|
||||
"id": {
|
||||
"description": "The identifier for the connector.",
|
||||
"type": "string"
|
||||
},
|
||||
"is_deprecated": {
|
||||
"description": "Indicates whether the connector is deprecated.",
|
||||
"type": "boolean"
|
||||
},
|
||||
"is_missing_secrets": {
|
||||
"description": "Indicates whether the connector is missing secrets.",
|
||||
"type": "boolean"
|
||||
},
|
||||
"is_preconfigured": {
|
||||
"description": "Indicates whether the connector is preconfigured. If true, the `config` and `is_missing_secrets` properties are omitted from the response. ",
|
||||
"type": "boolean"
|
||||
},
|
||||
"is_system_action": {
|
||||
"description": "Indicates whether the connector is used for system actions.",
|
||||
"type": "boolean"
|
||||
},
|
||||
"name": {
|
||||
"description": " The name of the rule.",
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"id",
|
||||
"name",
|
||||
"connector_type_id",
|
||||
"is_preconfigured",
|
||||
"is_deprecated",
|
||||
"is_system_action"
|
||||
],
|
||||
"type": "object"
|
||||
}
|
||||
}
|
||||
},
|
||||
"description": "Indicates a successful call."
|
||||
}
|
||||
},
|
||||
"summary": "Create a connector",
|
||||
"tags": [
|
||||
"connectors"
|
||||
]
|
||||
}
|
||||
},
|
||||
"/api/actions/action/{id}": {
|
||||
"delete": {
|
||||
"deprecated": true,
|
||||
"description": "WARNING: When you delete a connector, it cannot be recovered.",
|
||||
"operationId": "%2Fapi%2Factions%2Faction%2F%7Bid%7D#0",
|
||||
"parameters": [
|
||||
{
|
||||
"description": "The version of the API to use",
|
||||
"in": "header",
|
||||
"name": "elastic-api-version",
|
||||
"schema": {
|
||||
"default": "2023-10-31",
|
||||
"enum": [
|
||||
"2023-10-31"
|
||||
],
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
{
|
||||
"description": "A required header to protect against CSRF attacks",
|
||||
"in": "header",
|
||||
"name": "kbn-xsrf",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"example": "true",
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
{
|
||||
"description": "An identifier for the connector.",
|
||||
"in": "path",
|
||||
"name": "id",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"204": {
|
||||
"description": "Indicates a successful call."
|
||||
}
|
||||
},
|
||||
"summary": "Delete a connector",
|
||||
"tags": [
|
||||
"connectors"
|
||||
]
|
||||
},
|
||||
"get": {
|
||||
"deprecated": true,
|
||||
"operationId": "%2Fapi%2Factions%2Faction%2F%7Bid%7D#1",
|
||||
"parameters": [
|
||||
{
|
||||
"description": "The version of the API to use",
|
||||
"in": "header",
|
||||
"name": "elastic-api-version",
|
||||
"schema": {
|
||||
"default": "2023-10-31",
|
||||
"enum": [
|
||||
"2023-10-31"
|
||||
],
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
{
|
||||
"description": "An identifier for the connector.",
|
||||
"in": "path",
|
||||
"name": "id",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"content": {
|
||||
"application/json; Elastic-Api-Version=2023-10-31": {
|
||||
"schema": {
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"config": {
|
||||
"additionalProperties": {},
|
||||
"type": "object"
|
||||
},
|
||||
"connector_type_id": {
|
||||
"description": "The connector type identifier.",
|
||||
"type": "string"
|
||||
},
|
||||
"id": {
|
||||
"description": "The identifier for the connector.",
|
||||
"type": "string"
|
||||
},
|
||||
"is_deprecated": {
|
||||
"description": "Indicates whether the connector is deprecated.",
|
||||
"type": "boolean"
|
||||
},
|
||||
"is_missing_secrets": {
|
||||
"description": "Indicates whether the connector is missing secrets.",
|
||||
"type": "boolean"
|
||||
},
|
||||
"is_preconfigured": {
|
||||
"description": "Indicates whether the connector is preconfigured. If true, the `config` and `is_missing_secrets` properties are omitted from the response. ",
|
||||
"type": "boolean"
|
||||
},
|
||||
"is_system_action": {
|
||||
"description": "Indicates whether the connector is used for system actions.",
|
||||
"type": "boolean"
|
||||
},
|
||||
"name": {
|
||||
"description": " The name of the rule.",
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"id",
|
||||
"name",
|
||||
"connector_type_id",
|
||||
"is_preconfigured",
|
||||
"is_deprecated",
|
||||
"is_system_action"
|
||||
],
|
||||
"type": "object"
|
||||
}
|
||||
}
|
||||
},
|
||||
"description": "Indicates a successful call."
|
||||
}
|
||||
},
|
||||
"summary": "Get connector information",
|
||||
"tags": [
|
||||
"connectors"
|
||||
]
|
||||
},
|
||||
"put": {
|
||||
"deprecated": true,
|
||||
"operationId": "%2Fapi%2Factions%2Faction%2F%7Bid%7D#2",
|
||||
"parameters": [
|
||||
{
|
||||
"description": "The version of the API to use",
|
||||
"in": "header",
|
||||
"name": "elastic-api-version",
|
||||
"schema": {
|
||||
"default": "2023-10-31",
|
||||
"enum": [
|
||||
"2023-10-31"
|
||||
],
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
{
|
||||
"description": "A required header to protect against CSRF attacks",
|
||||
"in": "header",
|
||||
"name": "kbn-xsrf",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"example": "true",
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
{
|
||||
"description": "An identifier for the connector.",
|
||||
"in": "path",
|
||||
"name": "id",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
],
|
||||
"requestBody": {
|
||||
"content": {
|
||||
"application/json; Elastic-Api-Version=2023-10-31": {
|
||||
"schema": {
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"config": {
|
||||
"additionalProperties": {},
|
||||
"default": {},
|
||||
"type": "object"
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
},
|
||||
"secrets": {
|
||||
"additionalProperties": {},
|
||||
"default": {},
|
||||
"type": "object"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"name"
|
||||
],
|
||||
"type": "object"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"responses": {
|
||||
"200": {
|
||||
"content": {
|
||||
"application/json; Elastic-Api-Version=2023-10-31": {
|
||||
"schema": {
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"config": {
|
||||
"additionalProperties": {},
|
||||
"type": "object"
|
||||
},
|
||||
"connector_type_id": {
|
||||
"description": "The connector type identifier.",
|
||||
"type": "string"
|
||||
},
|
||||
"id": {
|
||||
"description": "The identifier for the connector.",
|
||||
"type": "string"
|
||||
},
|
||||
"is_deprecated": {
|
||||
"description": "Indicates whether the connector is deprecated.",
|
||||
"type": "boolean"
|
||||
},
|
||||
"is_missing_secrets": {
|
||||
"description": "Indicates whether the connector is missing secrets.",
|
||||
"type": "boolean"
|
||||
},
|
||||
"is_preconfigured": {
|
||||
"description": "Indicates whether the connector is preconfigured. If true, the `config` and `is_missing_secrets` properties are omitted from the response. ",
|
||||
"type": "boolean"
|
||||
},
|
||||
"is_system_action": {
|
||||
"description": "Indicates whether the connector is used for system actions.",
|
||||
"type": "boolean"
|
||||
},
|
||||
"name": {
|
||||
"description": " The name of the rule.",
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"id",
|
||||
"name",
|
||||
"connector_type_id",
|
||||
"is_preconfigured",
|
||||
"is_deprecated",
|
||||
"is_system_action"
|
||||
],
|
||||
"type": "object"
|
||||
}
|
||||
}
|
||||
},
|
||||
"description": "Indicates a successful call."
|
||||
}
|
||||
},
|
||||
"summary": "Update a connector",
|
||||
"tags": [
|
||||
"connectors"
|
||||
]
|
||||
}
|
||||
},
|
||||
"/api/actions/action/{id}/_execute": {
|
||||
"post": {
|
||||
"deprecated": true,
|
||||
"operationId": "%2Fapi%2Factions%2Faction%2F%7Bid%7D%2F_execute#0",
|
||||
"parameters": [
|
||||
{
|
||||
"description": "The version of the API to use",
|
||||
"in": "header",
|
||||
"name": "elastic-api-version",
|
||||
"schema": {
|
||||
"default": "2023-10-31",
|
||||
"enum": [
|
||||
"2023-10-31"
|
||||
],
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
{
|
||||
"description": "A required header to protect against CSRF attacks",
|
||||
"in": "header",
|
||||
"name": "kbn-xsrf",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"example": "true",
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
{
|
||||
"description": "An identifier for the connector.",
|
||||
"in": "path",
|
||||
"name": "id",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
],
|
||||
"requestBody": {
|
||||
"content": {
|
||||
"application/json; Elastic-Api-Version=2023-10-31": {
|
||||
"schema": {
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"params": {
|
||||
"additionalProperties": {},
|
||||
"type": "object"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"params"
|
||||
],
|
||||
"type": "object"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"responses": {
|
||||
"200": {
|
||||
"content": {
|
||||
"application/json; Elastic-Api-Version=2023-10-31": {
|
||||
"schema": {
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"config": {
|
||||
"additionalProperties": {},
|
||||
"type": "object"
|
||||
},
|
||||
"connector_type_id": {
|
||||
"description": "The connector type identifier.",
|
||||
"type": "string"
|
||||
},
|
||||
"id": {
|
||||
"description": "The identifier for the connector.",
|
||||
"type": "string"
|
||||
},
|
||||
"is_deprecated": {
|
||||
"description": "Indicates whether the connector is deprecated.",
|
||||
"type": "boolean"
|
||||
},
|
||||
"is_missing_secrets": {
|
||||
"description": "Indicates whether the connector is missing secrets.",
|
||||
"type": "boolean"
|
||||
},
|
||||
"is_preconfigured": {
|
||||
"description": "Indicates whether the connector is preconfigured. If true, the `config` and `is_missing_secrets` properties are omitted from the response. ",
|
||||
"type": "boolean"
|
||||
},
|
||||
"is_system_action": {
|
||||
"description": "Indicates whether the connector is used for system actions.",
|
||||
"type": "boolean"
|
||||
},
|
||||
"name": {
|
||||
"description": " The name of the rule.",
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"id",
|
||||
"name",
|
||||
"connector_type_id",
|
||||
"is_preconfigured",
|
||||
"is_deprecated",
|
||||
"is_system_action"
|
||||
],
|
||||
"type": "object"
|
||||
}
|
||||
}
|
||||
},
|
||||
"description": "Indicates a successful call."
|
||||
}
|
||||
},
|
||||
"summary": "Run a connector",
|
||||
"tags": [
|
||||
"connectors"
|
||||
]
|
||||
}
|
||||
},
|
||||
"/api/actions/connector/{id}": {
|
||||
"delete": {
|
||||
"description": "WARNING: When you delete a connector, it cannot be recovered.",
|
||||
|
@ -1429,31 +905,6 @@
|
|||
]
|
||||
}
|
||||
},
|
||||
"/api/actions/list_action_types": {
|
||||
"get": {
|
||||
"deprecated": true,
|
||||
"operationId": "%2Fapi%2Factions%2Flist_action_types#0",
|
||||
"parameters": [
|
||||
{
|
||||
"description": "The version of the API to use",
|
||||
"in": "header",
|
||||
"name": "elastic-api-version",
|
||||
"schema": {
|
||||
"default": "2023-10-31",
|
||||
"enum": [
|
||||
"2023-10-31"
|
||||
],
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {},
|
||||
"summary": "Get connector types",
|
||||
"tags": [
|
||||
"connectors"
|
||||
]
|
||||
}
|
||||
},
|
||||
"/api/alerting/rule/{id}": {
|
||||
"delete": {
|
||||
"operationId": "%2Fapi%2Falerting%2Frule%2F%7Bid%7D#2",
|
||||
|
|
|
@ -82,392 +82,6 @@ servers:
|
|||
- description: local
|
||||
url: http://localhost:5601
|
||||
paths:
|
||||
/api/actions:
|
||||
get:
|
||||
deprecated: true
|
||||
operationId: '%2Fapi%2Factions#0'
|
||||
parameters:
|
||||
- description: The version of the API to use
|
||||
in: header
|
||||
name: elastic-api-version
|
||||
schema:
|
||||
default: '2023-10-31'
|
||||
enum:
|
||||
- '2023-10-31'
|
||||
type: string
|
||||
responses: {}
|
||||
summary: Get all connectors
|
||||
tags:
|
||||
- connectors
|
||||
/api/actions/action:
|
||||
post:
|
||||
deprecated: true
|
||||
operationId: '%2Fapi%2Factions%2Faction#0'
|
||||
parameters:
|
||||
- description: The version of the API to use
|
||||
in: header
|
||||
name: elastic-api-version
|
||||
schema:
|
||||
default: '2023-10-31'
|
||||
enum:
|
||||
- '2023-10-31'
|
||||
type: string
|
||||
- description: A required header to protect against CSRF attacks
|
||||
in: header
|
||||
name: kbn-xsrf
|
||||
required: true
|
||||
schema:
|
||||
example: 'true'
|
||||
type: string
|
||||
requestBody:
|
||||
content:
|
||||
application/json; Elastic-Api-Version=2023-10-31:
|
||||
schema:
|
||||
additionalProperties: false
|
||||
type: object
|
||||
properties:
|
||||
actionTypeId:
|
||||
description: The connector type identifier.
|
||||
type: string
|
||||
config:
|
||||
additionalProperties: {}
|
||||
default: {}
|
||||
type: object
|
||||
name:
|
||||
description: The display name for the connector.
|
||||
type: string
|
||||
secrets:
|
||||
additionalProperties: {}
|
||||
default: {}
|
||||
type: object
|
||||
required:
|
||||
- name
|
||||
- actionTypeId
|
||||
responses:
|
||||
'200':
|
||||
content:
|
||||
application/json; Elastic-Api-Version=2023-10-31:
|
||||
schema:
|
||||
additionalProperties: false
|
||||
type: object
|
||||
properties:
|
||||
config:
|
||||
additionalProperties: {}
|
||||
type: object
|
||||
connector_type_id:
|
||||
description: The connector type identifier.
|
||||
type: string
|
||||
id:
|
||||
description: The identifier for the connector.
|
||||
type: string
|
||||
is_deprecated:
|
||||
description: Indicates whether the connector is deprecated.
|
||||
type: boolean
|
||||
is_missing_secrets:
|
||||
description: Indicates whether the connector is missing secrets.
|
||||
type: boolean
|
||||
is_preconfigured:
|
||||
description: >-
|
||||
Indicates whether the connector is preconfigured. If true,
|
||||
the `config` and `is_missing_secrets` properties are
|
||||
omitted from the response.
|
||||
type: boolean
|
||||
is_system_action:
|
||||
description: >-
|
||||
Indicates whether the connector is used for system
|
||||
actions.
|
||||
type: boolean
|
||||
name:
|
||||
description: ' The name of the rule.'
|
||||
type: string
|
||||
required:
|
||||
- id
|
||||
- name
|
||||
- connector_type_id
|
||||
- is_preconfigured
|
||||
- is_deprecated
|
||||
- is_system_action
|
||||
description: Indicates a successful call.
|
||||
summary: Create a connector
|
||||
tags:
|
||||
- connectors
|
||||
/api/actions/action/{id}:
|
||||
delete:
|
||||
deprecated: true
|
||||
description: 'WARNING: When you delete a connector, it cannot be recovered.'
|
||||
operationId: '%2Fapi%2Factions%2Faction%2F%7Bid%7D#0'
|
||||
parameters:
|
||||
- description: The version of the API to use
|
||||
in: header
|
||||
name: elastic-api-version
|
||||
schema:
|
||||
default: '2023-10-31'
|
||||
enum:
|
||||
- '2023-10-31'
|
||||
type: string
|
||||
- description: A required header to protect against CSRF attacks
|
||||
in: header
|
||||
name: kbn-xsrf
|
||||
required: true
|
||||
schema:
|
||||
example: 'true'
|
||||
type: string
|
||||
- description: An identifier for the connector.
|
||||
in: path
|
||||
name: id
|
||||
required: true
|
||||
schema:
|
||||
type: string
|
||||
responses:
|
||||
'204':
|
||||
description: Indicates a successful call.
|
||||
summary: Delete a connector
|
||||
tags:
|
||||
- connectors
|
||||
get:
|
||||
deprecated: true
|
||||
operationId: '%2Fapi%2Factions%2Faction%2F%7Bid%7D#1'
|
||||
parameters:
|
||||
- description: The version of the API to use
|
||||
in: header
|
||||
name: elastic-api-version
|
||||
schema:
|
||||
default: '2023-10-31'
|
||||
enum:
|
||||
- '2023-10-31'
|
||||
type: string
|
||||
- description: An identifier for the connector.
|
||||
in: path
|
||||
name: id
|
||||
required: true
|
||||
schema:
|
||||
type: string
|
||||
responses:
|
||||
'200':
|
||||
content:
|
||||
application/json; Elastic-Api-Version=2023-10-31:
|
||||
schema:
|
||||
additionalProperties: false
|
||||
type: object
|
||||
properties:
|
||||
config:
|
||||
additionalProperties: {}
|
||||
type: object
|
||||
connector_type_id:
|
||||
description: The connector type identifier.
|
||||
type: string
|
||||
id:
|
||||
description: The identifier for the connector.
|
||||
type: string
|
||||
is_deprecated:
|
||||
description: Indicates whether the connector is deprecated.
|
||||
type: boolean
|
||||
is_missing_secrets:
|
||||
description: Indicates whether the connector is missing secrets.
|
||||
type: boolean
|
||||
is_preconfigured:
|
||||
description: >-
|
||||
Indicates whether the connector is preconfigured. If true,
|
||||
the `config` and `is_missing_secrets` properties are
|
||||
omitted from the response.
|
||||
type: boolean
|
||||
is_system_action:
|
||||
description: >-
|
||||
Indicates whether the connector is used for system
|
||||
actions.
|
||||
type: boolean
|
||||
name:
|
||||
description: ' The name of the rule.'
|
||||
type: string
|
||||
required:
|
||||
- id
|
||||
- name
|
||||
- connector_type_id
|
||||
- is_preconfigured
|
||||
- is_deprecated
|
||||
- is_system_action
|
||||
description: Indicates a successful call.
|
||||
summary: Get connector information
|
||||
tags:
|
||||
- connectors
|
||||
put:
|
||||
deprecated: true
|
||||
operationId: '%2Fapi%2Factions%2Faction%2F%7Bid%7D#2'
|
||||
parameters:
|
||||
- description: The version of the API to use
|
||||
in: header
|
||||
name: elastic-api-version
|
||||
schema:
|
||||
default: '2023-10-31'
|
||||
enum:
|
||||
- '2023-10-31'
|
||||
type: string
|
||||
- description: A required header to protect against CSRF attacks
|
||||
in: header
|
||||
name: kbn-xsrf
|
||||
required: true
|
||||
schema:
|
||||
example: 'true'
|
||||
type: string
|
||||
- description: An identifier for the connector.
|
||||
in: path
|
||||
name: id
|
||||
required: true
|
||||
schema:
|
||||
type: string
|
||||
requestBody:
|
||||
content:
|
||||
application/json; Elastic-Api-Version=2023-10-31:
|
||||
schema:
|
||||
additionalProperties: false
|
||||
type: object
|
||||
properties:
|
||||
config:
|
||||
additionalProperties: {}
|
||||
default: {}
|
||||
type: object
|
||||
name:
|
||||
type: string
|
||||
secrets:
|
||||
additionalProperties: {}
|
||||
default: {}
|
||||
type: object
|
||||
required:
|
||||
- name
|
||||
responses:
|
||||
'200':
|
||||
content:
|
||||
application/json; Elastic-Api-Version=2023-10-31:
|
||||
schema:
|
||||
additionalProperties: false
|
||||
type: object
|
||||
properties:
|
||||
config:
|
||||
additionalProperties: {}
|
||||
type: object
|
||||
connector_type_id:
|
||||
description: The connector type identifier.
|
||||
type: string
|
||||
id:
|
||||
description: The identifier for the connector.
|
||||
type: string
|
||||
is_deprecated:
|
||||
description: Indicates whether the connector is deprecated.
|
||||
type: boolean
|
||||
is_missing_secrets:
|
||||
description: Indicates whether the connector is missing secrets.
|
||||
type: boolean
|
||||
is_preconfigured:
|
||||
description: >-
|
||||
Indicates whether the connector is preconfigured. If true,
|
||||
the `config` and `is_missing_secrets` properties are
|
||||
omitted from the response.
|
||||
type: boolean
|
||||
is_system_action:
|
||||
description: >-
|
||||
Indicates whether the connector is used for system
|
||||
actions.
|
||||
type: boolean
|
||||
name:
|
||||
description: ' The name of the rule.'
|
||||
type: string
|
||||
required:
|
||||
- id
|
||||
- name
|
||||
- connector_type_id
|
||||
- is_preconfigured
|
||||
- is_deprecated
|
||||
- is_system_action
|
||||
description: Indicates a successful call.
|
||||
summary: Update a connector
|
||||
tags:
|
||||
- connectors
|
||||
/api/actions/action/{id}/_execute:
|
||||
post:
|
||||
deprecated: true
|
||||
operationId: '%2Fapi%2Factions%2Faction%2F%7Bid%7D%2F_execute#0'
|
||||
parameters:
|
||||
- description: The version of the API to use
|
||||
in: header
|
||||
name: elastic-api-version
|
||||
schema:
|
||||
default: '2023-10-31'
|
||||
enum:
|
||||
- '2023-10-31'
|
||||
type: string
|
||||
- description: A required header to protect against CSRF attacks
|
||||
in: header
|
||||
name: kbn-xsrf
|
||||
required: true
|
||||
schema:
|
||||
example: 'true'
|
||||
type: string
|
||||
- description: An identifier for the connector.
|
||||
in: path
|
||||
name: id
|
||||
required: true
|
||||
schema:
|
||||
type: string
|
||||
requestBody:
|
||||
content:
|
||||
application/json; Elastic-Api-Version=2023-10-31:
|
||||
schema:
|
||||
additionalProperties: false
|
||||
type: object
|
||||
properties:
|
||||
params:
|
||||
additionalProperties: {}
|
||||
type: object
|
||||
required:
|
||||
- params
|
||||
responses:
|
||||
'200':
|
||||
content:
|
||||
application/json; Elastic-Api-Version=2023-10-31:
|
||||
schema:
|
||||
additionalProperties: false
|
||||
type: object
|
||||
properties:
|
||||
config:
|
||||
additionalProperties: {}
|
||||
type: object
|
||||
connector_type_id:
|
||||
description: The connector type identifier.
|
||||
type: string
|
||||
id:
|
||||
description: The identifier for the connector.
|
||||
type: string
|
||||
is_deprecated:
|
||||
description: Indicates whether the connector is deprecated.
|
||||
type: boolean
|
||||
is_missing_secrets:
|
||||
description: Indicates whether the connector is missing secrets.
|
||||
type: boolean
|
||||
is_preconfigured:
|
||||
description: >-
|
||||
Indicates whether the connector is preconfigured. If true,
|
||||
the `config` and `is_missing_secrets` properties are
|
||||
omitted from the response.
|
||||
type: boolean
|
||||
is_system_action:
|
||||
description: >-
|
||||
Indicates whether the connector is used for system
|
||||
actions.
|
||||
type: boolean
|
||||
name:
|
||||
description: ' The name of the rule.'
|
||||
type: string
|
||||
required:
|
||||
- id
|
||||
- name
|
||||
- connector_type_id
|
||||
- is_preconfigured
|
||||
- is_deprecated
|
||||
- is_system_action
|
||||
description: Indicates a successful call.
|
||||
summary: Run a connector
|
||||
tags:
|
||||
- connectors
|
||||
/api/actions/connector_types:
|
||||
get:
|
||||
description: You do not need any Kibana feature privileges to run this API.
|
||||
|
@ -882,23 +496,6 @@ paths:
|
|||
summary: Get all connectors
|
||||
tags:
|
||||
- connectors
|
||||
/api/actions/list_action_types:
|
||||
get:
|
||||
deprecated: true
|
||||
operationId: '%2Fapi%2Factions%2Flist_action_types#0'
|
||||
parameters:
|
||||
- description: The version of the API to use
|
||||
in: header
|
||||
name: elastic-api-version
|
||||
schema:
|
||||
default: '2023-10-31'
|
||||
enum:
|
||||
- '2023-10-31'
|
||||
type: string
|
||||
responses: {}
|
||||
summary: Get connector types
|
||||
tags:
|
||||
- connectors
|
||||
/api/alerting/rule/{id}:
|
||||
delete:
|
||||
operationId: '%2Fapi%2Falerting%2Frule%2F%7Bid%7D#2'
|
||||
|
|
|
@ -79,392 +79,6 @@ servers:
|
|||
kibana_url:
|
||||
default: localhost:5601
|
||||
paths:
|
||||
/api/actions:
|
||||
get:
|
||||
deprecated: true
|
||||
operationId: '%2Fapi%2Factions#0'
|
||||
parameters:
|
||||
- description: The version of the API to use
|
||||
in: header
|
||||
name: elastic-api-version
|
||||
schema:
|
||||
default: '2023-10-31'
|
||||
enum:
|
||||
- '2023-10-31'
|
||||
type: string
|
||||
responses: {}
|
||||
summary: Get all connectors
|
||||
tags:
|
||||
- connectors
|
||||
/api/actions/action:
|
||||
post:
|
||||
deprecated: true
|
||||
operationId: '%2Fapi%2Factions%2Faction#0'
|
||||
parameters:
|
||||
- description: The version of the API to use
|
||||
in: header
|
||||
name: elastic-api-version
|
||||
schema:
|
||||
default: '2023-10-31'
|
||||
enum:
|
||||
- '2023-10-31'
|
||||
type: string
|
||||
- description: A required header to protect against CSRF attacks
|
||||
in: header
|
||||
name: kbn-xsrf
|
||||
required: true
|
||||
schema:
|
||||
example: 'true'
|
||||
type: string
|
||||
requestBody:
|
||||
content:
|
||||
application/json; Elastic-Api-Version=2023-10-31:
|
||||
schema:
|
||||
additionalProperties: false
|
||||
type: object
|
||||
properties:
|
||||
actionTypeId:
|
||||
description: The connector type identifier.
|
||||
type: string
|
||||
config:
|
||||
additionalProperties: {}
|
||||
default: {}
|
||||
type: object
|
||||
name:
|
||||
description: The display name for the connector.
|
||||
type: string
|
||||
secrets:
|
||||
additionalProperties: {}
|
||||
default: {}
|
||||
type: object
|
||||
required:
|
||||
- name
|
||||
- actionTypeId
|
||||
responses:
|
||||
'200':
|
||||
content:
|
||||
application/json; Elastic-Api-Version=2023-10-31:
|
||||
schema:
|
||||
additionalProperties: false
|
||||
type: object
|
||||
properties:
|
||||
config:
|
||||
additionalProperties: {}
|
||||
type: object
|
||||
connector_type_id:
|
||||
description: The connector type identifier.
|
||||
type: string
|
||||
id:
|
||||
description: The identifier for the connector.
|
||||
type: string
|
||||
is_deprecated:
|
||||
description: Indicates whether the connector is deprecated.
|
||||
type: boolean
|
||||
is_missing_secrets:
|
||||
description: Indicates whether the connector is missing secrets.
|
||||
type: boolean
|
||||
is_preconfigured:
|
||||
description: >-
|
||||
Indicates whether the connector is preconfigured. If true,
|
||||
the `config` and `is_missing_secrets` properties are
|
||||
omitted from the response.
|
||||
type: boolean
|
||||
is_system_action:
|
||||
description: >-
|
||||
Indicates whether the connector is used for system
|
||||
actions.
|
||||
type: boolean
|
||||
name:
|
||||
description: ' The name of the rule.'
|
||||
type: string
|
||||
required:
|
||||
- id
|
||||
- name
|
||||
- connector_type_id
|
||||
- is_preconfigured
|
||||
- is_deprecated
|
||||
- is_system_action
|
||||
description: Indicates a successful call.
|
||||
summary: Create a connector
|
||||
tags:
|
||||
- connectors
|
||||
/api/actions/action/{id}:
|
||||
delete:
|
||||
deprecated: true
|
||||
description: 'WARNING: When you delete a connector, it cannot be recovered.'
|
||||
operationId: '%2Fapi%2Factions%2Faction%2F%7Bid%7D#0'
|
||||
parameters:
|
||||
- description: The version of the API to use
|
||||
in: header
|
||||
name: elastic-api-version
|
||||
schema:
|
||||
default: '2023-10-31'
|
||||
enum:
|
||||
- '2023-10-31'
|
||||
type: string
|
||||
- description: A required header to protect against CSRF attacks
|
||||
in: header
|
||||
name: kbn-xsrf
|
||||
required: true
|
||||
schema:
|
||||
example: 'true'
|
||||
type: string
|
||||
- description: An identifier for the connector.
|
||||
in: path
|
||||
name: id
|
||||
required: true
|
||||
schema:
|
||||
type: string
|
||||
responses:
|
||||
'204':
|
||||
description: Indicates a successful call.
|
||||
summary: Delete a connector
|
||||
tags:
|
||||
- connectors
|
||||
get:
|
||||
deprecated: true
|
||||
operationId: '%2Fapi%2Factions%2Faction%2F%7Bid%7D#1'
|
||||
parameters:
|
||||
- description: The version of the API to use
|
||||
in: header
|
||||
name: elastic-api-version
|
||||
schema:
|
||||
default: '2023-10-31'
|
||||
enum:
|
||||
- '2023-10-31'
|
||||
type: string
|
||||
- description: An identifier for the connector.
|
||||
in: path
|
||||
name: id
|
||||
required: true
|
||||
schema:
|
||||
type: string
|
||||
responses:
|
||||
'200':
|
||||
content:
|
||||
application/json; Elastic-Api-Version=2023-10-31:
|
||||
schema:
|
||||
additionalProperties: false
|
||||
type: object
|
||||
properties:
|
||||
config:
|
||||
additionalProperties: {}
|
||||
type: object
|
||||
connector_type_id:
|
||||
description: The connector type identifier.
|
||||
type: string
|
||||
id:
|
||||
description: The identifier for the connector.
|
||||
type: string
|
||||
is_deprecated:
|
||||
description: Indicates whether the connector is deprecated.
|
||||
type: boolean
|
||||
is_missing_secrets:
|
||||
description: Indicates whether the connector is missing secrets.
|
||||
type: boolean
|
||||
is_preconfigured:
|
||||
description: >-
|
||||
Indicates whether the connector is preconfigured. If true,
|
||||
the `config` and `is_missing_secrets` properties are
|
||||
omitted from the response.
|
||||
type: boolean
|
||||
is_system_action:
|
||||
description: >-
|
||||
Indicates whether the connector is used for system
|
||||
actions.
|
||||
type: boolean
|
||||
name:
|
||||
description: ' The name of the rule.'
|
||||
type: string
|
||||
required:
|
||||
- id
|
||||
- name
|
||||
- connector_type_id
|
||||
- is_preconfigured
|
||||
- is_deprecated
|
||||
- is_system_action
|
||||
description: Indicates a successful call.
|
||||
summary: Get connector information
|
||||
tags:
|
||||
- connectors
|
||||
put:
|
||||
deprecated: true
|
||||
operationId: '%2Fapi%2Factions%2Faction%2F%7Bid%7D#2'
|
||||
parameters:
|
||||
- description: The version of the API to use
|
||||
in: header
|
||||
name: elastic-api-version
|
||||
schema:
|
||||
default: '2023-10-31'
|
||||
enum:
|
||||
- '2023-10-31'
|
||||
type: string
|
||||
- description: A required header to protect against CSRF attacks
|
||||
in: header
|
||||
name: kbn-xsrf
|
||||
required: true
|
||||
schema:
|
||||
example: 'true'
|
||||
type: string
|
||||
- description: An identifier for the connector.
|
||||
in: path
|
||||
name: id
|
||||
required: true
|
||||
schema:
|
||||
type: string
|
||||
requestBody:
|
||||
content:
|
||||
application/json; Elastic-Api-Version=2023-10-31:
|
||||
schema:
|
||||
additionalProperties: false
|
||||
type: object
|
||||
properties:
|
||||
config:
|
||||
additionalProperties: {}
|
||||
default: {}
|
||||
type: object
|
||||
name:
|
||||
type: string
|
||||
secrets:
|
||||
additionalProperties: {}
|
||||
default: {}
|
||||
type: object
|
||||
required:
|
||||
- name
|
||||
responses:
|
||||
'200':
|
||||
content:
|
||||
application/json; Elastic-Api-Version=2023-10-31:
|
||||
schema:
|
||||
additionalProperties: false
|
||||
type: object
|
||||
properties:
|
||||
config:
|
||||
additionalProperties: {}
|
||||
type: object
|
||||
connector_type_id:
|
||||
description: The connector type identifier.
|
||||
type: string
|
||||
id:
|
||||
description: The identifier for the connector.
|
||||
type: string
|
||||
is_deprecated:
|
||||
description: Indicates whether the connector is deprecated.
|
||||
type: boolean
|
||||
is_missing_secrets:
|
||||
description: Indicates whether the connector is missing secrets.
|
||||
type: boolean
|
||||
is_preconfigured:
|
||||
description: >-
|
||||
Indicates whether the connector is preconfigured. If true,
|
||||
the `config` and `is_missing_secrets` properties are
|
||||
omitted from the response.
|
||||
type: boolean
|
||||
is_system_action:
|
||||
description: >-
|
||||
Indicates whether the connector is used for system
|
||||
actions.
|
||||
type: boolean
|
||||
name:
|
||||
description: ' The name of the rule.'
|
||||
type: string
|
||||
required:
|
||||
- id
|
||||
- name
|
||||
- connector_type_id
|
||||
- is_preconfigured
|
||||
- is_deprecated
|
||||
- is_system_action
|
||||
description: Indicates a successful call.
|
||||
summary: Update a connector
|
||||
tags:
|
||||
- connectors
|
||||
/api/actions/action/{id}/_execute:
|
||||
post:
|
||||
deprecated: true
|
||||
operationId: '%2Fapi%2Factions%2Faction%2F%7Bid%7D%2F_execute#0'
|
||||
parameters:
|
||||
- description: The version of the API to use
|
||||
in: header
|
||||
name: elastic-api-version
|
||||
schema:
|
||||
default: '2023-10-31'
|
||||
enum:
|
||||
- '2023-10-31'
|
||||
type: string
|
||||
- description: A required header to protect against CSRF attacks
|
||||
in: header
|
||||
name: kbn-xsrf
|
||||
required: true
|
||||
schema:
|
||||
example: 'true'
|
||||
type: string
|
||||
- description: An identifier for the connector.
|
||||
in: path
|
||||
name: id
|
||||
required: true
|
||||
schema:
|
||||
type: string
|
||||
requestBody:
|
||||
content:
|
||||
application/json; Elastic-Api-Version=2023-10-31:
|
||||
schema:
|
||||
additionalProperties: false
|
||||
type: object
|
||||
properties:
|
||||
params:
|
||||
additionalProperties: {}
|
||||
type: object
|
||||
required:
|
||||
- params
|
||||
responses:
|
||||
'200':
|
||||
content:
|
||||
application/json; Elastic-Api-Version=2023-10-31:
|
||||
schema:
|
||||
additionalProperties: false
|
||||
type: object
|
||||
properties:
|
||||
config:
|
||||
additionalProperties: {}
|
||||
type: object
|
||||
connector_type_id:
|
||||
description: The connector type identifier.
|
||||
type: string
|
||||
id:
|
||||
description: The identifier for the connector.
|
||||
type: string
|
||||
is_deprecated:
|
||||
description: Indicates whether the connector is deprecated.
|
||||
type: boolean
|
||||
is_missing_secrets:
|
||||
description: Indicates whether the connector is missing secrets.
|
||||
type: boolean
|
||||
is_preconfigured:
|
||||
description: >-
|
||||
Indicates whether the connector is preconfigured. If true,
|
||||
the `config` and `is_missing_secrets` properties are
|
||||
omitted from the response.
|
||||
type: boolean
|
||||
is_system_action:
|
||||
description: >-
|
||||
Indicates whether the connector is used for system
|
||||
actions.
|
||||
type: boolean
|
||||
name:
|
||||
description: ' The name of the rule.'
|
||||
type: string
|
||||
required:
|
||||
- id
|
||||
- name
|
||||
- connector_type_id
|
||||
- is_preconfigured
|
||||
- is_deprecated
|
||||
- is_system_action
|
||||
description: Indicates a successful call.
|
||||
summary: Run a connector
|
||||
tags:
|
||||
- connectors
|
||||
/api/actions/connector_types:
|
||||
get:
|
||||
description: You do not need any Kibana feature privileges to run this API.
|
||||
|
@ -879,23 +493,6 @@ paths:
|
|||
summary: Get all connectors
|
||||
tags:
|
||||
- connectors
|
||||
/api/actions/list_action_types:
|
||||
get:
|
||||
deprecated: true
|
||||
operationId: '%2Fapi%2Factions%2Flist_action_types#0'
|
||||
parameters:
|
||||
- description: The version of the API to use
|
||||
in: header
|
||||
name: elastic-api-version
|
||||
schema:
|
||||
default: '2023-10-31'
|
||||
enum:
|
||||
- '2023-10-31'
|
||||
type: string
|
||||
responses: {}
|
||||
summary: Get connector types
|
||||
tags:
|
||||
- connectors
|
||||
/api/alerting/_health:
|
||||
get:
|
||||
description: >
|
||||
|
|
|
@ -9,10 +9,10 @@ import { KibanaRequest, KibanaResponseFactory } from '@kbn/core/server';
|
|||
import { identity } from 'lodash';
|
||||
import type { MethodKeysOf } from '@kbn/utility-types';
|
||||
import { httpServerMock } from '@kbn/core/server/mocks';
|
||||
import { ActionsRequestHandlerContext } from '../../types';
|
||||
import { actionsClientMock } from '../../mocks';
|
||||
import { ActionsClientMock } from '../../actions_client/actions_client.mock';
|
||||
import { ConnectorType } from '../../application/connector/types';
|
||||
import { ActionsRequestHandlerContext } from '../types';
|
||||
import { actionsClientMock } from '../mocks';
|
||||
import { ActionsClientMock } from '../actions_client/actions_client.mock';
|
||||
import { ConnectorType } from '../application/connector/types';
|
||||
|
||||
export function mockHandlerArguments(
|
||||
{
|
|
@ -8,7 +8,7 @@
|
|||
import { createConnectorRoute } from './create';
|
||||
import { httpServiceMock } from '@kbn/core/server/mocks';
|
||||
import { licenseStateMock } from '../../../lib/license_state.mock';
|
||||
import { mockHandlerArguments } from '../../legacy/_mock_handler_arguments';
|
||||
import { mockHandlerArguments } from '../../_mock_handler_arguments';
|
||||
import { verifyAccessAndContext } from '../../verify_access_and_context';
|
||||
import { omit } from 'lodash';
|
||||
import { actionsClientMock } from '../../../actions_client/actions_client.mock';
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
import { deleteConnectorRoute } from './delete';
|
||||
import { httpServiceMock } from '@kbn/core/server/mocks';
|
||||
import { licenseStateMock } from '../../../lib/license_state.mock';
|
||||
import { mockHandlerArguments } from '../../legacy/_mock_handler_arguments';
|
||||
import { mockHandlerArguments } from '../../_mock_handler_arguments';
|
||||
import { actionsClientMock } from '../../../mocks';
|
||||
import { verifyAccessAndContext } from '../../verify_access_and_context';
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
import { executeConnectorRoute } from './execute';
|
||||
import { httpServiceMock } from '@kbn/core/server/mocks';
|
||||
import { licenseStateMock } from '../../../lib/license_state.mock';
|
||||
import { mockHandlerArguments } from '../../legacy/_mock_handler_arguments';
|
||||
import { mockHandlerArguments } from '../../_mock_handler_arguments';
|
||||
import { asHttpRequestExecutionSource } from '../../../lib';
|
||||
import { actionsClientMock } from '../../../actions_client/actions_client.mock';
|
||||
import { ActionTypeExecutorResult } from '../../../types';
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
import { getConnectorRoute } from './get';
|
||||
import { httpServiceMock } from '@kbn/core/server/mocks';
|
||||
import { licenseStateMock } from '../../../lib/license_state.mock';
|
||||
import { mockHandlerArguments } from '../../legacy/_mock_handler_arguments';
|
||||
import { mockHandlerArguments } from '../../_mock_handler_arguments';
|
||||
import { actionsClientMock } from '../../../actions_client/actions_client.mock';
|
||||
import { verifyAccessAndContext } from '../../verify_access_and_context';
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
import { getAllConnectorsRoute } from './get_all';
|
||||
import { httpServiceMock } from '@kbn/core/server/mocks';
|
||||
import { licenseStateMock } from '../../../lib/license_state.mock';
|
||||
import { mockHandlerArguments } from '../../legacy/_mock_handler_arguments';
|
||||
import { mockHandlerArguments } from '../../_mock_handler_arguments';
|
||||
import { verifyAccessAndContext } from '../../verify_access_and_context';
|
||||
import { actionsClientMock } from '../../../actions_client/actions_client.mock';
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
import { getAllConnectorsIncludingSystemRoute } from './get_all_system';
|
||||
import { httpServiceMock } from '@kbn/core/server/mocks';
|
||||
import { licenseStateMock } from '../../../lib/license_state.mock';
|
||||
import { mockHandlerArguments } from '../../legacy/_mock_handler_arguments';
|
||||
import { mockHandlerArguments } from '../../_mock_handler_arguments';
|
||||
import { verifyAccessAndContext } from '../../verify_access_and_context';
|
||||
import { actionsClientMock } from '../../../actions_client/actions_client.mock';
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
import { httpServiceMock } from '@kbn/core/server/mocks';
|
||||
import { LicenseType } from '@kbn/licensing-plugin/server';
|
||||
import { licenseStateMock } from '../../../lib/license_state.mock';
|
||||
import { mockHandlerArguments } from '../../legacy/_mock_handler_arguments';
|
||||
import { mockHandlerArguments } from '../../_mock_handler_arguments';
|
||||
import { listTypesRoute } from './list_types';
|
||||
import { verifyAccessAndContext } from '../../verify_access_and_context';
|
||||
import { actionsClientMock } from '../../../mocks';
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
import { httpServiceMock } from '@kbn/core/server/mocks';
|
||||
import { LicenseType } from '@kbn/licensing-plugin/server';
|
||||
import { licenseStateMock } from '../../../lib/license_state.mock';
|
||||
import { mockHandlerArguments } from '../../legacy/_mock_handler_arguments';
|
||||
import { mockHandlerArguments } from '../../_mock_handler_arguments';
|
||||
import { listTypesWithSystemRoute } from './list_types_system';
|
||||
import { verifyAccessAndContext } from '../../verify_access_and_context';
|
||||
import { actionsClientMock } from '../../../mocks';
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
import { updateConnectorRoute } from './update';
|
||||
import { httpServiceMock } from '@kbn/core/server/mocks';
|
||||
import { licenseStateMock } from '../../../lib/license_state.mock';
|
||||
import { mockHandlerArguments } from '../../legacy/_mock_handler_arguments';
|
||||
import { mockHandlerArguments } from '../../_mock_handler_arguments';
|
||||
import { actionsClientMock } from '../../../actions_client/actions_client.mock';
|
||||
import { verifyAccessAndContext } from '../../verify_access_and_context';
|
||||
import { updateConnectorBodySchema } from '../../../../common/routes/connector/apis/update';
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
import { httpServiceMock } from '@kbn/core/server/mocks';
|
||||
import { licenseStateMock } from '../lib/license_state.mock';
|
||||
import { mockHandlerArguments } from './legacy/_mock_handler_arguments';
|
||||
import { mockHandlerArguments } from './_mock_handler_arguments';
|
||||
import { actionsClientMock } from '../actions_client/actions_client.mock';
|
||||
import { getGlobalExecutionKPIRoute } from './get_global_execution_kpi';
|
||||
import { verifyAccessAndContext } from './verify_access_and_context';
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
import { getGlobalExecutionLogRoute } from './get_global_execution_logs';
|
||||
import { httpServiceMock } from '@kbn/core/server/mocks';
|
||||
import { licenseStateMock } from '../lib/license_state.mock';
|
||||
import { mockHandlerArguments } from './legacy/_mock_handler_arguments';
|
||||
import { mockHandlerArguments } from './_mock_handler_arguments';
|
||||
import { actionsClientMock } from '../actions_client/actions_client.mock';
|
||||
import { IExecutionLogResult } from '../../common';
|
||||
import { verifyAccessAndContext } from './verify_access_and_context';
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
import { getOAuthAccessToken } from './get_oauth_access_token';
|
||||
import { httpServiceMock } from '@kbn/core/server/mocks';
|
||||
import { licenseStateMock } from '../lib/license_state.mock';
|
||||
import { mockHandlerArguments } from './legacy/_mock_handler_arguments';
|
||||
import { mockHandlerArguments } from './_mock_handler_arguments';
|
||||
import { verifyAccessAndContext } from './verify_access_and_context';
|
||||
import { actionsConfigMock } from '../actions_config.mock';
|
||||
import { actionsClientMock } from '../actions_client/actions_client.mock';
|
||||
|
|
|
@ -19,7 +19,6 @@ import { executeConnectorRoute } from './connector/execute';
|
|||
import { getConnectorRoute } from './connector/get';
|
||||
import { updateConnectorRoute } from './connector/update';
|
||||
import { getOAuthAccessToken } from './get_oauth_access_token';
|
||||
import { defineLegacyRoutes } from './legacy';
|
||||
import { ActionsConfigurationUtilities } from '../actions_config';
|
||||
import { getGlobalExecutionLogRoute } from './get_global_execution_logs';
|
||||
import { getGlobalExecutionKPIRoute } from './get_global_execution_kpi';
|
||||
|
@ -32,9 +31,7 @@ export interface RouteOptions {
|
|||
}
|
||||
|
||||
export function defineRoutes(opts: RouteOptions) {
|
||||
const { router, licenseState, actionsConfigUtils, usageCounter } = opts;
|
||||
|
||||
defineLegacyRoutes(router, licenseState, usageCounter);
|
||||
const { router, licenseState, actionsConfigUtils } = opts;
|
||||
|
||||
createConnectorRoute(router, licenseState);
|
||||
deleteConnectorRoute(router, licenseState);
|
||||
|
|
|
@ -1,158 +0,0 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License
|
||||
* 2.0; you may not use this file except in compliance with the Elastic License
|
||||
* 2.0.
|
||||
*/
|
||||
|
||||
import { createActionRoute } from './create';
|
||||
import { httpServiceMock } from '@kbn/core/server/mocks';
|
||||
import { licenseStateMock } from '../../lib/license_state.mock';
|
||||
import { mockHandlerArguments } from './_mock_handler_arguments';
|
||||
import { actionsClientMock } from '../../actions_client/actions_client.mock';
|
||||
import { verifyAccessAndContext } from '../verify_access_and_context';
|
||||
import { trackLegacyRouteUsage } from '../../lib/track_legacy_route_usage';
|
||||
import { usageCountersServiceMock } from '@kbn/usage-collection-plugin/server/usage_counters/usage_counters_service.mock';
|
||||
|
||||
jest.mock('../verify_access_and_context', () => ({
|
||||
verifyAccessAndContext: jest.fn(),
|
||||
}));
|
||||
|
||||
jest.mock('../../lib/track_legacy_route_usage', () => ({
|
||||
trackLegacyRouteUsage: jest.fn(),
|
||||
}));
|
||||
|
||||
const mockUsageCountersSetup = usageCountersServiceMock.createSetupContract();
|
||||
const mockUsageCounter = mockUsageCountersSetup.createUsageCounter('test');
|
||||
|
||||
beforeEach(() => {
|
||||
jest.resetAllMocks();
|
||||
(verifyAccessAndContext as jest.Mock).mockImplementation((license, handler) => handler);
|
||||
});
|
||||
|
||||
describe('createActionRoute', () => {
|
||||
it('creates an action with proper parameters', async () => {
|
||||
const licenseState = licenseStateMock.create();
|
||||
const router = httpServiceMock.createRouter();
|
||||
|
||||
createActionRoute(router, licenseState);
|
||||
|
||||
const [config, handler] = router.post.mock.calls[0];
|
||||
|
||||
expect(config.path).toMatchInlineSnapshot(`"/api/actions/action"`);
|
||||
|
||||
const createResult = {
|
||||
id: '1',
|
||||
name: 'My name',
|
||||
actionTypeId: 'abc',
|
||||
config: { foo: true },
|
||||
isPreconfigured: false,
|
||||
isDeprecated: false,
|
||||
isSystemAction: false,
|
||||
};
|
||||
|
||||
const actionsClient = actionsClientMock.create();
|
||||
actionsClient.create.mockResolvedValueOnce(createResult);
|
||||
|
||||
const [context, req, res] = mockHandlerArguments(
|
||||
{ actionsClient },
|
||||
{
|
||||
body: {
|
||||
name: 'My name',
|
||||
actionTypeId: 'abc',
|
||||
config: { foo: true },
|
||||
secrets: {},
|
||||
},
|
||||
},
|
||||
['ok']
|
||||
);
|
||||
|
||||
expect(await handler(context, req, res)).toEqual({ body: createResult });
|
||||
|
||||
expect(actionsClient.create).toHaveBeenCalledTimes(1);
|
||||
expect(actionsClient.create.mock.calls[0]).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
Object {
|
||||
"action": Object {
|
||||
"actionTypeId": "abc",
|
||||
"config": Object {
|
||||
"foo": true,
|
||||
},
|
||||
"name": "My name",
|
||||
"secrets": Object {},
|
||||
},
|
||||
},
|
||||
]
|
||||
`);
|
||||
|
||||
expect(res.ok).toHaveBeenCalledWith({
|
||||
body: createResult,
|
||||
});
|
||||
});
|
||||
|
||||
it('ensures the license allows creating actions', async () => {
|
||||
const licenseState = licenseStateMock.create();
|
||||
const router = httpServiceMock.createRouter();
|
||||
|
||||
createActionRoute(router, licenseState);
|
||||
|
||||
const [, handler] = router.post.mock.calls[0];
|
||||
|
||||
const actionsClient = actionsClientMock.create();
|
||||
actionsClient.create.mockResolvedValueOnce({
|
||||
id: '1',
|
||||
name: 'My name',
|
||||
actionTypeId: 'abc',
|
||||
config: { foo: true },
|
||||
isPreconfigured: false,
|
||||
isDeprecated: false,
|
||||
isSystemAction: false,
|
||||
});
|
||||
|
||||
const [context, req, res] = mockHandlerArguments({ actionsClient }, {});
|
||||
|
||||
await handler(context, req, res);
|
||||
|
||||
expect(verifyAccessAndContext).toHaveBeenCalledWith(licenseState, expect.any(Function));
|
||||
});
|
||||
|
||||
it('ensures the license check prevents creating actions', async () => {
|
||||
const licenseState = licenseStateMock.create();
|
||||
const router = httpServiceMock.createRouter();
|
||||
|
||||
(verifyAccessAndContext as jest.Mock).mockImplementation(() => async () => {
|
||||
throw new Error('OMG');
|
||||
});
|
||||
|
||||
createActionRoute(router, licenseState);
|
||||
|
||||
const [, handler] = router.post.mock.calls[0];
|
||||
|
||||
const actionsClient = actionsClientMock.create();
|
||||
actionsClient.create.mockResolvedValueOnce({
|
||||
id: '1',
|
||||
name: 'My name',
|
||||
actionTypeId: 'abc',
|
||||
config: { foo: true },
|
||||
isPreconfigured: false,
|
||||
isDeprecated: false,
|
||||
isSystemAction: false,
|
||||
});
|
||||
|
||||
const [context, req, res] = mockHandlerArguments({ actionsClient }, {});
|
||||
|
||||
await expect(handler(context, req, res)).rejects.toMatchInlineSnapshot(`[Error: OMG]`);
|
||||
});
|
||||
|
||||
it('should track every call', async () => {
|
||||
const licenseState = licenseStateMock.create();
|
||||
const router = httpServiceMock.createRouter();
|
||||
const actionsClient = actionsClientMock.create();
|
||||
|
||||
createActionRoute(router, licenseState, mockUsageCounter);
|
||||
const [, handler] = router.post.mock.calls[0];
|
||||
const [context, req, res] = mockHandlerArguments({ actionsClient }, {});
|
||||
await handler(context, req, res);
|
||||
expect(trackLegacyRouteUsage).toHaveBeenCalledWith('create', mockUsageCounter);
|
||||
});
|
||||
});
|
|
@ -1,67 +0,0 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License
|
||||
* 2.0; you may not use this file except in compliance with the Elastic License
|
||||
* 2.0.
|
||||
*/
|
||||
|
||||
import { schema } from '@kbn/config-schema';
|
||||
import { UsageCounter } from '@kbn/usage-collection-plugin/server';
|
||||
import { IRouter } from '@kbn/core/server';
|
||||
import { ActionsRequestHandlerContext } from '../../types';
|
||||
import { ILicenseState } from '../../lib';
|
||||
import { BASE_ACTION_API_PATH } from '../../../common';
|
||||
import { verifyAccessAndContext } from '../verify_access_and_context';
|
||||
import { trackLegacyRouteUsage } from '../../lib/track_legacy_route_usage';
|
||||
import { connectorResponseSchemaV1 } from '../../../common/routes/connector/response';
|
||||
|
||||
export const bodySchema = schema.object({
|
||||
name: schema.string({
|
||||
meta: { description: 'The display name for the connector.' },
|
||||
}),
|
||||
actionTypeId: schema.string({
|
||||
meta: { description: 'The connector type identifier.' },
|
||||
}),
|
||||
config: schema.recordOf(schema.string(), schema.any(), { defaultValue: {} }),
|
||||
secrets: schema.recordOf(schema.string(), schema.any(), { defaultValue: {} }),
|
||||
});
|
||||
|
||||
export const createActionRoute = (
|
||||
router: IRouter<ActionsRequestHandlerContext>,
|
||||
licenseState: ILicenseState,
|
||||
usageCounter?: UsageCounter
|
||||
) => {
|
||||
router.post(
|
||||
{
|
||||
path: `${BASE_ACTION_API_PATH}/action`,
|
||||
options: {
|
||||
access: 'public',
|
||||
summary: `Create a connector`,
|
||||
tags: ['oas-tag:connectors'],
|
||||
// @ts-expect-error TODO(https://github.com/elastic/kibana/issues/196095): Replace {RouteDeprecationInfo}
|
||||
deprecated: true,
|
||||
},
|
||||
validate: {
|
||||
request: {
|
||||
body: bodySchema,
|
||||
},
|
||||
response: {
|
||||
200: {
|
||||
description: 'Indicates a successful call.',
|
||||
body: () => connectorResponseSchemaV1,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
router.handleLegacyErrors(
|
||||
verifyAccessAndContext(licenseState, async function (context, req, res) {
|
||||
const actionsClient = (await context.actions).getActionsClient();
|
||||
const action = req.body;
|
||||
trackLegacyRouteUsage('create', usageCounter);
|
||||
return res.ok({
|
||||
body: await actionsClient.create({ action }),
|
||||
});
|
||||
})
|
||||
)
|
||||
);
|
||||
};
|
|
@ -1,138 +0,0 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License
|
||||
* 2.0; you may not use this file except in compliance with the Elastic License
|
||||
* 2.0.
|
||||
*/
|
||||
|
||||
import { deleteActionRoute } from './delete';
|
||||
import { httpServiceMock } from '@kbn/core/server/mocks';
|
||||
import { licenseStateMock } from '../../lib/license_state.mock';
|
||||
import { verifyApiAccess } from '../../lib';
|
||||
import { mockHandlerArguments } from './_mock_handler_arguments';
|
||||
import { actionsClientMock } from '../../mocks';
|
||||
import { trackLegacyRouteUsage } from '../../lib/track_legacy_route_usage';
|
||||
import { usageCountersServiceMock } from '@kbn/usage-collection-plugin/server/usage_counters/usage_counters_service.mock';
|
||||
|
||||
jest.mock('../../lib/verify_api_access', () => ({
|
||||
verifyApiAccess: jest.fn(),
|
||||
}));
|
||||
|
||||
jest.mock('../../lib/track_legacy_route_usage', () => ({
|
||||
trackLegacyRouteUsage: jest.fn(),
|
||||
}));
|
||||
|
||||
const mockUsageCountersSetup = usageCountersServiceMock.createSetupContract();
|
||||
const mockUsageCounter = mockUsageCountersSetup.createUsageCounter('test');
|
||||
|
||||
beforeEach(() => {
|
||||
jest.resetAllMocks();
|
||||
});
|
||||
|
||||
describe('deleteActionRoute', () => {
|
||||
it('deletes an action with proper parameters', async () => {
|
||||
const licenseState = licenseStateMock.create();
|
||||
const router = httpServiceMock.createRouter();
|
||||
|
||||
deleteActionRoute(router, licenseState);
|
||||
|
||||
const [config, handler] = router.delete.mock.calls[0];
|
||||
|
||||
expect(config.path).toMatchInlineSnapshot(`"/api/actions/action/{id}"`);
|
||||
|
||||
const actionsClient = actionsClientMock.create();
|
||||
actionsClient.delete.mockResolvedValueOnce({});
|
||||
|
||||
const [context, req, res] = mockHandlerArguments(
|
||||
{ actionsClient },
|
||||
{
|
||||
params: {
|
||||
id: '1',
|
||||
},
|
||||
},
|
||||
['noContent']
|
||||
);
|
||||
|
||||
expect(await handler(context, req, res)).toEqual(undefined);
|
||||
|
||||
expect(actionsClient.delete).toHaveBeenCalledTimes(1);
|
||||
expect(actionsClient.delete.mock.calls[0]).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
Object {
|
||||
"id": "1",
|
||||
},
|
||||
]
|
||||
`);
|
||||
|
||||
expect(res.noContent).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('ensures the license allows deleting actions', async () => {
|
||||
const licenseState = licenseStateMock.create();
|
||||
const router = httpServiceMock.createRouter();
|
||||
|
||||
deleteActionRoute(router, licenseState);
|
||||
|
||||
const [, handler] = router.delete.mock.calls[0];
|
||||
|
||||
const actionsClient = actionsClientMock.create();
|
||||
actionsClient.delete.mockResolvedValueOnce({});
|
||||
|
||||
const [context, req, res] = mockHandlerArguments(
|
||||
{ actionsClient },
|
||||
{
|
||||
params: { id: '1' },
|
||||
}
|
||||
);
|
||||
|
||||
await handler(context, req, res);
|
||||
|
||||
expect(verifyApiAccess).toHaveBeenCalledWith(licenseState);
|
||||
});
|
||||
|
||||
it('ensures the license check prevents deleting actions', async () => {
|
||||
const licenseState = licenseStateMock.create();
|
||||
const router = httpServiceMock.createRouter();
|
||||
|
||||
(verifyApiAccess as jest.Mock).mockImplementation(() => {
|
||||
throw new Error('OMG');
|
||||
});
|
||||
|
||||
deleteActionRoute(router, licenseState);
|
||||
|
||||
const [, handler] = router.delete.mock.calls[0];
|
||||
|
||||
const actionsClient = actionsClientMock.create();
|
||||
actionsClient.delete.mockResolvedValueOnce({});
|
||||
|
||||
const [context, req, res] = mockHandlerArguments(
|
||||
{ actionsClient },
|
||||
{
|
||||
id: '1',
|
||||
}
|
||||
);
|
||||
|
||||
await expect(handler(context, req, res)).rejects.toMatchInlineSnapshot(`[Error: OMG]`);
|
||||
|
||||
expect(verifyApiAccess).toHaveBeenCalledWith(licenseState);
|
||||
});
|
||||
|
||||
it('should track every call', async () => {
|
||||
const licenseState = licenseStateMock.create();
|
||||
const router = httpServiceMock.createRouter();
|
||||
const actionsClient = actionsClientMock.create();
|
||||
|
||||
deleteActionRoute(router, licenseState, mockUsageCounter);
|
||||
const [, handler] = router.delete.mock.calls[0];
|
||||
const [context, req, res] = mockHandlerArguments(
|
||||
{ actionsClient },
|
||||
{
|
||||
params: {
|
||||
id: '1',
|
||||
},
|
||||
}
|
||||
);
|
||||
await handler(context, req, res);
|
||||
expect(trackLegacyRouteUsage).toHaveBeenCalledWith('delete', mockUsageCounter);
|
||||
});
|
||||
});
|
|
@ -1,68 +0,0 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License
|
||||
* 2.0; you may not use this file except in compliance with the Elastic License
|
||||
* 2.0.
|
||||
*/
|
||||
|
||||
import { schema } from '@kbn/config-schema';
|
||||
import { UsageCounter } from '@kbn/usage-collection-plugin/server';
|
||||
import { IRouter } from '@kbn/core/server';
|
||||
import { ILicenseState, verifyApiAccess, isErrorThatHandlesItsOwnResponse } from '../../lib';
|
||||
import { BASE_ACTION_API_PATH } from '../../../common';
|
||||
import { ActionsRequestHandlerContext } from '../../types';
|
||||
import { trackLegacyRouteUsage } from '../../lib/track_legacy_route_usage';
|
||||
|
||||
const paramSchema = schema.object({
|
||||
id: schema.string({
|
||||
meta: { description: 'An identifier for the connector.' },
|
||||
}),
|
||||
});
|
||||
|
||||
export const deleteActionRoute = (
|
||||
router: IRouter<ActionsRequestHandlerContext>,
|
||||
licenseState: ILicenseState,
|
||||
usageCounter?: UsageCounter
|
||||
) => {
|
||||
router.delete(
|
||||
{
|
||||
path: `${BASE_ACTION_API_PATH}/action/{id}`,
|
||||
options: {
|
||||
access: 'public',
|
||||
summary: `Delete a connector`,
|
||||
description: 'WARNING: When you delete a connector, it cannot be recovered.',
|
||||
tags: ['oas-tag:connectors'],
|
||||
// @ts-expect-error TODO(https://github.com/elastic/kibana/issues/196095): Replace {RouteDeprecationInfo}
|
||||
deprecated: true,
|
||||
},
|
||||
validate: {
|
||||
request: {
|
||||
params: paramSchema,
|
||||
},
|
||||
response: {
|
||||
204: {
|
||||
description: 'Indicates a successful call.',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
router.handleLegacyErrors(async function (context, req, res) {
|
||||
verifyApiAccess(licenseState);
|
||||
if (!context.actions) {
|
||||
return res.badRequest({ body: 'RouteHandlerContext is not registered for actions' });
|
||||
}
|
||||
const actionsClient = (await context.actions).getActionsClient();
|
||||
const { id } = req.params;
|
||||
trackLegacyRouteUsage('delete', usageCounter);
|
||||
try {
|
||||
await actionsClient.delete({ id });
|
||||
return res.noContent();
|
||||
} catch (e) {
|
||||
if (isErrorThatHandlesItsOwnResponse(e)) {
|
||||
return e.sendResponse(res);
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
})
|
||||
);
|
||||
};
|
|
@ -1,214 +0,0 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License
|
||||
* 2.0; you may not use this file except in compliance with the Elastic License
|
||||
* 2.0.
|
||||
*/
|
||||
|
||||
import { executeActionRoute } from './execute';
|
||||
import { httpServiceMock } from '@kbn/core/server/mocks';
|
||||
import { licenseStateMock } from '../../lib/license_state.mock';
|
||||
import { mockHandlerArguments } from './_mock_handler_arguments';
|
||||
import { verifyApiAccess, ActionTypeDisabledError, asHttpRequestExecutionSource } from '../../lib';
|
||||
import { actionsClientMock } from '../../actions_client/actions_client.mock';
|
||||
import { ActionTypeExecutorResult } from '../../types';
|
||||
import { trackLegacyRouteUsage } from '../../lib/track_legacy_route_usage';
|
||||
import { usageCountersServiceMock } from '@kbn/usage-collection-plugin/server/usage_counters/usage_counters_service.mock';
|
||||
|
||||
jest.mock('../../lib/verify_api_access', () => ({
|
||||
verifyApiAccess: jest.fn(),
|
||||
}));
|
||||
|
||||
jest.mock('../../lib/track_legacy_route_usage', () => ({
|
||||
trackLegacyRouteUsage: jest.fn(),
|
||||
}));
|
||||
|
||||
const mockUsageCountersSetup = usageCountersServiceMock.createSetupContract();
|
||||
const mockUsageCounter = mockUsageCountersSetup.createUsageCounter('test');
|
||||
|
||||
beforeEach(() => {
|
||||
jest.resetAllMocks();
|
||||
});
|
||||
|
||||
describe('executeActionRoute', () => {
|
||||
it('executes an action with proper parameters', async () => {
|
||||
const licenseState = licenseStateMock.create();
|
||||
const router = httpServiceMock.createRouter();
|
||||
|
||||
const actionsClient = actionsClientMock.create();
|
||||
actionsClient.execute.mockResolvedValueOnce({ status: 'ok', actionId: '1' });
|
||||
|
||||
const [context, req, res] = mockHandlerArguments(
|
||||
{ actionsClient },
|
||||
{
|
||||
body: {
|
||||
params: {
|
||||
someData: 'data',
|
||||
},
|
||||
},
|
||||
params: {
|
||||
id: '1',
|
||||
},
|
||||
},
|
||||
['ok']
|
||||
);
|
||||
|
||||
const executeResult = {
|
||||
actionId: '1',
|
||||
status: 'ok',
|
||||
};
|
||||
|
||||
executeActionRoute(router, licenseState);
|
||||
|
||||
const [config, handler] = router.post.mock.calls[0];
|
||||
|
||||
expect(config.path).toMatchInlineSnapshot(`"/api/actions/action/{id}/_execute"`);
|
||||
|
||||
expect(await handler(context, req, res)).toEqual({ body: executeResult });
|
||||
|
||||
expect(actionsClient.execute).toHaveBeenCalledWith({
|
||||
actionId: '1',
|
||||
params: {
|
||||
someData: 'data',
|
||||
},
|
||||
source: asHttpRequestExecutionSource(req),
|
||||
relatedSavedObjects: [],
|
||||
});
|
||||
|
||||
expect(res.ok).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('returns a "204 NO CONTENT" when the executor returns a nullish value', async () => {
|
||||
const licenseState = licenseStateMock.create();
|
||||
const router = httpServiceMock.createRouter();
|
||||
|
||||
const actionsClient = actionsClientMock.create();
|
||||
actionsClient.execute.mockResolvedValueOnce(null as unknown as ActionTypeExecutorResult<void>);
|
||||
|
||||
const [context, req, res] = mockHandlerArguments(
|
||||
{ actionsClient },
|
||||
{
|
||||
body: {
|
||||
params: {},
|
||||
},
|
||||
params: {
|
||||
id: '1',
|
||||
},
|
||||
},
|
||||
['noContent']
|
||||
);
|
||||
|
||||
executeActionRoute(router, licenseState);
|
||||
|
||||
const [, handler] = router.post.mock.calls[0];
|
||||
|
||||
expect(await handler(context, req, res)).toEqual(undefined);
|
||||
|
||||
expect(actionsClient.execute).toHaveBeenCalledWith({
|
||||
actionId: '1',
|
||||
params: {},
|
||||
source: asHttpRequestExecutionSource(req),
|
||||
relatedSavedObjects: [],
|
||||
});
|
||||
|
||||
expect(res.ok).not.toHaveBeenCalled();
|
||||
expect(res.noContent).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('ensures the license allows action execution', async () => {
|
||||
const licenseState = licenseStateMock.create();
|
||||
const router = httpServiceMock.createRouter();
|
||||
|
||||
const actionsClient = actionsClientMock.create();
|
||||
actionsClient.execute.mockResolvedValue({
|
||||
actionId: '1',
|
||||
status: 'ok',
|
||||
});
|
||||
|
||||
const [context, req, res] = mockHandlerArguments(
|
||||
{ actionsClient },
|
||||
{
|
||||
body: {},
|
||||
params: {},
|
||||
},
|
||||
['ok']
|
||||
);
|
||||
|
||||
executeActionRoute(router, licenseState);
|
||||
|
||||
const [, handler] = router.post.mock.calls[0];
|
||||
|
||||
await handler(context, req, res);
|
||||
|
||||
expect(verifyApiAccess).toHaveBeenCalledWith(licenseState);
|
||||
});
|
||||
|
||||
it('ensures the license check prevents action execution', async () => {
|
||||
const licenseState = licenseStateMock.create();
|
||||
const router = httpServiceMock.createRouter();
|
||||
|
||||
const actionsClient = actionsClientMock.create();
|
||||
actionsClient.execute.mockResolvedValue({
|
||||
actionId: '1',
|
||||
status: 'ok',
|
||||
});
|
||||
|
||||
(verifyApiAccess as jest.Mock).mockImplementation(() => {
|
||||
throw new Error('OMG');
|
||||
});
|
||||
|
||||
const [context, req, res] = mockHandlerArguments(
|
||||
{ actionsClient },
|
||||
{
|
||||
body: {},
|
||||
params: {},
|
||||
},
|
||||
['ok']
|
||||
);
|
||||
|
||||
executeActionRoute(router, licenseState);
|
||||
|
||||
const [, handler] = router.post.mock.calls[0];
|
||||
|
||||
await expect(handler(context, req, res)).rejects.toMatchInlineSnapshot(`[Error: OMG]`);
|
||||
|
||||
expect(verifyApiAccess).toHaveBeenCalledWith(licenseState);
|
||||
});
|
||||
|
||||
it('ensures the action type gets validated for the license', async () => {
|
||||
const licenseState = licenseStateMock.create();
|
||||
const router = httpServiceMock.createRouter();
|
||||
|
||||
const actionsClient = actionsClientMock.create();
|
||||
actionsClient.execute.mockRejectedValue(new ActionTypeDisabledError('Fail', 'license_invalid'));
|
||||
|
||||
const [context, req, res] = mockHandlerArguments(
|
||||
{ actionsClient },
|
||||
{
|
||||
body: {},
|
||||
params: {},
|
||||
},
|
||||
['ok', 'forbidden']
|
||||
);
|
||||
|
||||
executeActionRoute(router, licenseState);
|
||||
|
||||
const [, handler] = router.post.mock.calls[0];
|
||||
|
||||
await handler(context, req, res);
|
||||
|
||||
expect(res.forbidden).toHaveBeenCalledWith({ body: { message: 'Fail' } });
|
||||
});
|
||||
|
||||
it('should track every call', async () => {
|
||||
const licenseState = licenseStateMock.create();
|
||||
const router = httpServiceMock.createRouter();
|
||||
const actionsClient = actionsClientMock.create();
|
||||
|
||||
executeActionRoute(router, licenseState, mockUsageCounter);
|
||||
const [, handler] = router.post.mock.calls[0];
|
||||
const [context, req, res] = mockHandlerArguments({ actionsClient }, { body: {}, params: {} });
|
||||
await handler(context, req, res);
|
||||
expect(trackLegacyRouteUsage).toHaveBeenCalledWith('execute', mockUsageCounter);
|
||||
});
|
||||
});
|
|
@ -1,88 +0,0 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License
|
||||
* 2.0; you may not use this file except in compliance with the Elastic License
|
||||
* 2.0.
|
||||
*/
|
||||
|
||||
import { schema } from '@kbn/config-schema';
|
||||
import { UsageCounter } from '@kbn/usage-collection-plugin/server';
|
||||
import { IRouter } from '@kbn/core/server';
|
||||
import { ILicenseState, verifyApiAccess, isErrorThatHandlesItsOwnResponse } from '../../lib';
|
||||
|
||||
import { ActionTypeExecutorResult, ActionsRequestHandlerContext } from '../../types';
|
||||
import { BASE_ACTION_API_PATH } from '../../../common';
|
||||
import { asHttpRequestExecutionSource } from '../../lib/action_execution_source';
|
||||
import { trackLegacyRouteUsage } from '../../lib/track_legacy_route_usage';
|
||||
import { connectorResponseSchemaV1 } from '../../../common/routes/connector/response';
|
||||
|
||||
const paramSchema = schema.object({
|
||||
id: schema.string({
|
||||
meta: { description: 'An identifier for the connector.' },
|
||||
}),
|
||||
});
|
||||
|
||||
const bodySchema = schema.object({
|
||||
params: schema.recordOf(schema.string(), schema.any()),
|
||||
});
|
||||
|
||||
export const executeActionRoute = (
|
||||
router: IRouter<ActionsRequestHandlerContext>,
|
||||
licenseState: ILicenseState,
|
||||
usageCounter?: UsageCounter
|
||||
) => {
|
||||
router.post(
|
||||
{
|
||||
path: `${BASE_ACTION_API_PATH}/action/{id}/_execute`,
|
||||
options: {
|
||||
access: 'public',
|
||||
summary: `Run a connector`,
|
||||
// @ts-expect-error TODO(https://github.com/elastic/kibana/issues/196095): Replace {RouteDeprecationInfo}
|
||||
deprecated: true,
|
||||
tags: ['oas-tag:connectors'],
|
||||
},
|
||||
validate: {
|
||||
request: {
|
||||
body: bodySchema,
|
||||
params: paramSchema,
|
||||
},
|
||||
response: {
|
||||
200: {
|
||||
description: 'Indicates a successful call.',
|
||||
body: () => connectorResponseSchemaV1,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
router.handleLegacyErrors(async function (context, req, res) {
|
||||
verifyApiAccess(licenseState);
|
||||
|
||||
if (!context.actions) {
|
||||
return res.badRequest({ body: 'RouteHandlerContext is not registered for actions' });
|
||||
}
|
||||
|
||||
const actionsClient = (await context.actions).getActionsClient();
|
||||
const { params } = req.body;
|
||||
const { id } = req.params;
|
||||
trackLegacyRouteUsage('execute', usageCounter);
|
||||
try {
|
||||
const body: ActionTypeExecutorResult<unknown> = await actionsClient.execute({
|
||||
params,
|
||||
actionId: id,
|
||||
source: asHttpRequestExecutionSource(req),
|
||||
relatedSavedObjects: [],
|
||||
});
|
||||
return body
|
||||
? res.ok({
|
||||
body,
|
||||
})
|
||||
: res.noContent();
|
||||
} catch (e) {
|
||||
if (isErrorThatHandlesItsOwnResponse(e)) {
|
||||
return e.sendResponse(res);
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
})
|
||||
);
|
||||
};
|
|
@ -1,165 +0,0 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License
|
||||
* 2.0; you may not use this file except in compliance with the Elastic License
|
||||
* 2.0.
|
||||
*/
|
||||
|
||||
import { getActionRoute } from './get';
|
||||
import { httpServiceMock } from '@kbn/core/server/mocks';
|
||||
import { licenseStateMock } from '../../lib/license_state.mock';
|
||||
import { verifyApiAccess } from '../../lib';
|
||||
import { mockHandlerArguments } from './_mock_handler_arguments';
|
||||
import { actionsClientMock } from '../../actions_client/actions_client.mock';
|
||||
import { trackLegacyRouteUsage } from '../../lib/track_legacy_route_usage';
|
||||
import { usageCountersServiceMock } from '@kbn/usage-collection-plugin/server/usage_counters/usage_counters_service.mock';
|
||||
|
||||
jest.mock('../../lib/verify_api_access', () => ({
|
||||
verifyApiAccess: jest.fn(),
|
||||
}));
|
||||
|
||||
jest.mock('../../lib/track_legacy_route_usage', () => ({
|
||||
trackLegacyRouteUsage: jest.fn(),
|
||||
}));
|
||||
|
||||
const mockUsageCountersSetup = usageCountersServiceMock.createSetupContract();
|
||||
const mockUsageCounter = mockUsageCountersSetup.createUsageCounter('test');
|
||||
|
||||
beforeEach(() => {
|
||||
jest.resetAllMocks();
|
||||
});
|
||||
|
||||
describe('getActionRoute', () => {
|
||||
it('gets an action with proper parameters', async () => {
|
||||
const licenseState = licenseStateMock.create();
|
||||
const router = httpServiceMock.createRouter();
|
||||
|
||||
getActionRoute(router, licenseState);
|
||||
|
||||
const [config, handler] = router.get.mock.calls[0];
|
||||
|
||||
expect(config.path).toMatchInlineSnapshot(`"/api/actions/action/{id}"`);
|
||||
|
||||
const getResult = {
|
||||
id: '1',
|
||||
actionTypeId: '2',
|
||||
name: 'action name',
|
||||
config: {},
|
||||
isPreconfigured: false,
|
||||
isDeprecated: false,
|
||||
isSystemAction: false,
|
||||
};
|
||||
|
||||
const actionsClient = actionsClientMock.create();
|
||||
actionsClient.get.mockResolvedValueOnce(getResult);
|
||||
|
||||
const [context, req, res] = mockHandlerArguments(
|
||||
{ actionsClient },
|
||||
{
|
||||
params: { id: '1' },
|
||||
},
|
||||
['ok']
|
||||
);
|
||||
|
||||
expect(await handler(context, req, res)).toMatchInlineSnapshot(`
|
||||
Object {
|
||||
"body": Object {
|
||||
"actionTypeId": "2",
|
||||
"config": Object {},
|
||||
"id": "1",
|
||||
"isDeprecated": false,
|
||||
"isPreconfigured": false,
|
||||
"isSystemAction": false,
|
||||
"name": "action name",
|
||||
},
|
||||
}
|
||||
`);
|
||||
|
||||
expect(actionsClient.get).toHaveBeenCalledTimes(1);
|
||||
expect(actionsClient.get.mock.calls[0][0].id).toEqual('1');
|
||||
|
||||
expect(res.ok).toHaveBeenCalledWith({
|
||||
body: getResult,
|
||||
});
|
||||
});
|
||||
|
||||
it('ensures the license allows getting actions', async () => {
|
||||
const licenseState = licenseStateMock.create();
|
||||
const router = httpServiceMock.createRouter();
|
||||
|
||||
getActionRoute(router, licenseState);
|
||||
|
||||
const [, handler] = router.get.mock.calls[0];
|
||||
|
||||
const actionsClient = actionsClientMock.create();
|
||||
actionsClient.get.mockResolvedValueOnce({
|
||||
id: '1',
|
||||
actionTypeId: '2',
|
||||
name: 'action name',
|
||||
config: {},
|
||||
isPreconfigured: false,
|
||||
isDeprecated: false,
|
||||
isSystemAction: false,
|
||||
});
|
||||
|
||||
const [context, req, res] = mockHandlerArguments(
|
||||
{ actionsClient },
|
||||
{
|
||||
params: { id: '1' },
|
||||
},
|
||||
['ok']
|
||||
);
|
||||
|
||||
await handler(context, req, res);
|
||||
|
||||
expect(verifyApiAccess).toHaveBeenCalledWith(licenseState);
|
||||
});
|
||||
|
||||
it('ensures the license check prevents getting actions', async () => {
|
||||
const licenseState = licenseStateMock.create();
|
||||
const router = httpServiceMock.createRouter();
|
||||
|
||||
(verifyApiAccess as jest.Mock).mockImplementation(() => {
|
||||
throw new Error('OMG');
|
||||
});
|
||||
|
||||
getActionRoute(router, licenseState);
|
||||
|
||||
const [, handler] = router.get.mock.calls[0];
|
||||
|
||||
const actionsClient = actionsClientMock.create();
|
||||
actionsClient.get.mockResolvedValueOnce({
|
||||
id: '1',
|
||||
actionTypeId: '2',
|
||||
name: 'action name',
|
||||
config: {},
|
||||
isPreconfigured: false,
|
||||
isDeprecated: false,
|
||||
isSystemAction: false,
|
||||
});
|
||||
|
||||
const [context, req, res] = mockHandlerArguments(
|
||||
{ actionsClient },
|
||||
{
|
||||
params: { id: '1' },
|
||||
},
|
||||
['ok']
|
||||
);
|
||||
|
||||
await expect(handler(context, req, res)).rejects.toMatchInlineSnapshot(`[Error: OMG]`);
|
||||
|
||||
expect(verifyApiAccess).toHaveBeenCalledWith(licenseState);
|
||||
});
|
||||
|
||||
it('should track every call', async () => {
|
||||
const licenseState = licenseStateMock.create();
|
||||
const router = httpServiceMock.createRouter();
|
||||
const actionsClient = actionsClientMock.create();
|
||||
|
||||
getActionRoute(router, licenseState, mockUsageCounter);
|
||||
const [, handler] = router.get.mock.calls[0];
|
||||
const [context, req, res] = mockHandlerArguments({ actionsClient }, { params: { id: '1' } });
|
||||
await handler(context, req, res);
|
||||
expect(trackLegacyRouteUsage).toHaveBeenCalledWith('get', mockUsageCounter);
|
||||
});
|
||||
});
|
|
@ -1,63 +0,0 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License
|
||||
* 2.0; you may not use this file except in compliance with the Elastic License
|
||||
* 2.0.
|
||||
*/
|
||||
|
||||
import { schema } from '@kbn/config-schema';
|
||||
import { UsageCounter } from '@kbn/usage-collection-plugin/server';
|
||||
import { IRouter } from '@kbn/core/server';
|
||||
import { ILicenseState, verifyApiAccess } from '../../lib';
|
||||
import { BASE_ACTION_API_PATH } from '../../../common';
|
||||
import { ActionsRequestHandlerContext } from '../../types';
|
||||
import { trackLegacyRouteUsage } from '../../lib/track_legacy_route_usage';
|
||||
import { connectorResponseSchemaV1 } from '../../../common/routes/connector/response';
|
||||
|
||||
const paramSchema = schema.object({
|
||||
id: schema.string({
|
||||
meta: { description: 'An identifier for the connector.' },
|
||||
}),
|
||||
});
|
||||
|
||||
export const getActionRoute = (
|
||||
router: IRouter<ActionsRequestHandlerContext>,
|
||||
licenseState: ILicenseState,
|
||||
usageCounter?: UsageCounter
|
||||
) => {
|
||||
router.get(
|
||||
{
|
||||
path: `${BASE_ACTION_API_PATH}/action/{id}`,
|
||||
options: {
|
||||
access: 'public',
|
||||
summary: `Get connector information`,
|
||||
// @ts-expect-error TODO(https://github.com/elastic/kibana/issues/196095): Replace {RouteDeprecationInfo}
|
||||
deprecated: true,
|
||||
tags: ['oas-tag:connectors'],
|
||||
},
|
||||
validate: {
|
||||
request: {
|
||||
params: paramSchema,
|
||||
},
|
||||
response: {
|
||||
200: {
|
||||
description: 'Indicates a successful call.',
|
||||
body: () => connectorResponseSchemaV1,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
router.handleLegacyErrors(async function (context, req, res) {
|
||||
verifyApiAccess(licenseState);
|
||||
if (!context.actions) {
|
||||
return res.badRequest({ body: 'RouteHandlerContext is not registered for actions' });
|
||||
}
|
||||
const actionsClient = (await context.actions).getActionsClient();
|
||||
const { id } = req.params;
|
||||
trackLegacyRouteUsage('get', usageCounter);
|
||||
return res.ok({
|
||||
body: await actionsClient.get({ id }),
|
||||
});
|
||||
})
|
||||
);
|
||||
};
|
|
@ -1,116 +0,0 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License
|
||||
* 2.0; you may not use this file except in compliance with the Elastic License
|
||||
* 2.0.
|
||||
*/
|
||||
|
||||
import { getAllActionRoute } from './get_all';
|
||||
import { httpServiceMock } from '@kbn/core/server/mocks';
|
||||
import { licenseStateMock } from '../../lib/license_state.mock';
|
||||
import { verifyApiAccess } from '../../lib';
|
||||
import { mockHandlerArguments } from './_mock_handler_arguments';
|
||||
import { actionsClientMock } from '../../actions_client/actions_client.mock';
|
||||
import { trackLegacyRouteUsage } from '../../lib/track_legacy_route_usage';
|
||||
import { usageCountersServiceMock } from '@kbn/usage-collection-plugin/server/usage_counters/usage_counters_service.mock';
|
||||
|
||||
jest.mock('../../lib/verify_api_access', () => ({
|
||||
verifyApiAccess: jest.fn(),
|
||||
}));
|
||||
|
||||
jest.mock('../../lib/track_legacy_route_usage', () => ({
|
||||
trackLegacyRouteUsage: jest.fn(),
|
||||
}));
|
||||
|
||||
const mockUsageCountersSetup = usageCountersServiceMock.createSetupContract();
|
||||
const mockUsageCounter = mockUsageCountersSetup.createUsageCounter('test');
|
||||
|
||||
beforeEach(() => {
|
||||
jest.resetAllMocks();
|
||||
});
|
||||
|
||||
describe('getAllActionRoute', () => {
|
||||
it('get all actions with proper parameters', async () => {
|
||||
const licenseState = licenseStateMock.create();
|
||||
const router = httpServiceMock.createRouter();
|
||||
|
||||
getAllActionRoute(router, licenseState);
|
||||
|
||||
const [config, handler] = router.get.mock.calls[0];
|
||||
|
||||
expect(config.path).toMatchInlineSnapshot(`"/api/actions"`);
|
||||
|
||||
const actionsClient = actionsClientMock.create();
|
||||
actionsClient.getAll.mockResolvedValueOnce([]);
|
||||
|
||||
const [context, req, res] = mockHandlerArguments({ actionsClient }, {}, ['ok']);
|
||||
|
||||
expect(await handler(context, req, res)).toMatchInlineSnapshot(`
|
||||
Object {
|
||||
"body": Array [],
|
||||
}
|
||||
`);
|
||||
|
||||
expect(actionsClient.getAll).toHaveBeenCalledTimes(1);
|
||||
|
||||
expect(res.ok).toHaveBeenCalledWith({
|
||||
body: [],
|
||||
});
|
||||
});
|
||||
|
||||
it('ensures the license allows getting all actions', async () => {
|
||||
const licenseState = licenseStateMock.create();
|
||||
const router = httpServiceMock.createRouter();
|
||||
|
||||
getAllActionRoute(router, licenseState);
|
||||
|
||||
const [config, handler] = router.get.mock.calls[0];
|
||||
|
||||
expect(config.path).toMatchInlineSnapshot(`"/api/actions"`);
|
||||
|
||||
const actionsClient = actionsClientMock.create();
|
||||
actionsClient.getAll.mockResolvedValueOnce([]);
|
||||
|
||||
const [context, req, res] = mockHandlerArguments({ actionsClient }, {}, ['ok']);
|
||||
|
||||
await handler(context, req, res);
|
||||
|
||||
expect(verifyApiAccess).toHaveBeenCalledWith(licenseState);
|
||||
});
|
||||
|
||||
it('ensures the license check prevents getting all actions', async () => {
|
||||
const licenseState = licenseStateMock.create();
|
||||
const router = httpServiceMock.createRouter();
|
||||
|
||||
(verifyApiAccess as jest.Mock).mockImplementation(() => {
|
||||
throw new Error('OMG');
|
||||
});
|
||||
|
||||
getAllActionRoute(router, licenseState);
|
||||
|
||||
const [config, handler] = router.get.mock.calls[0];
|
||||
|
||||
expect(config.path).toMatchInlineSnapshot(`"/api/actions"`);
|
||||
|
||||
const actionsClient = actionsClientMock.create();
|
||||
actionsClient.getAll.mockResolvedValueOnce([]);
|
||||
|
||||
const [context, req, res] = mockHandlerArguments({ actionsClient }, {}, ['ok']);
|
||||
|
||||
await expect(handler(context, req, res)).rejects.toMatchInlineSnapshot(`[Error: OMG]`);
|
||||
|
||||
expect(verifyApiAccess).toHaveBeenCalledWith(licenseState);
|
||||
});
|
||||
|
||||
it('should track every call', async () => {
|
||||
const licenseState = licenseStateMock.create();
|
||||
const router = httpServiceMock.createRouter();
|
||||
const actionsClient = actionsClientMock.create();
|
||||
|
||||
getAllActionRoute(router, licenseState, mockUsageCounter);
|
||||
const [, handler] = router.get.mock.calls[0];
|
||||
const [context, req, res] = mockHandlerArguments({ actionsClient }, {});
|
||||
await handler(context, req, res);
|
||||
expect(trackLegacyRouteUsage).toHaveBeenCalledWith('getAll', mockUsageCounter);
|
||||
});
|
||||
});
|
|
@ -1,45 +0,0 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License
|
||||
* 2.0; you may not use this file except in compliance with the Elastic License
|
||||
* 2.0.
|
||||
*/
|
||||
|
||||
import { IRouter } from '@kbn/core/server';
|
||||
import { UsageCounter } from '@kbn/usage-collection-plugin/server';
|
||||
import { ILicenseState, verifyApiAccess } from '../../lib';
|
||||
import { BASE_ACTION_API_PATH } from '../../../common';
|
||||
import { ActionsRequestHandlerContext } from '../../types';
|
||||
import { trackLegacyRouteUsage } from '../../lib/track_legacy_route_usage';
|
||||
|
||||
export const getAllActionRoute = (
|
||||
router: IRouter<ActionsRequestHandlerContext>,
|
||||
licenseState: ILicenseState,
|
||||
usageCounter?: UsageCounter
|
||||
) => {
|
||||
router.get(
|
||||
{
|
||||
path: `${BASE_ACTION_API_PATH}`,
|
||||
options: {
|
||||
access: 'public',
|
||||
summary: `Get all connectors`,
|
||||
// @ts-expect-error TODO(https://github.com/elastic/kibana/issues/196095): Replace {RouteDeprecationInfo}
|
||||
deprecated: true,
|
||||
tags: ['oas-tag:connectors'],
|
||||
},
|
||||
validate: {},
|
||||
},
|
||||
router.handleLegacyErrors(async function (context, req, res) {
|
||||
verifyApiAccess(licenseState);
|
||||
if (!context.actions) {
|
||||
return res.badRequest({ body: 'RouteHandlerContext is not registered for actions' });
|
||||
}
|
||||
const actionsClient = (await context.actions).getActionsClient();
|
||||
const result = await actionsClient.getAll();
|
||||
trackLegacyRouteUsage('getAll', usageCounter);
|
||||
return res.ok({
|
||||
body: result,
|
||||
});
|
||||
})
|
||||
);
|
||||
};
|
|
@ -1,32 +0,0 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License
|
||||
* 2.0; you may not use this file except in compliance with the Elastic License
|
||||
* 2.0.
|
||||
*/
|
||||
|
||||
import { IRouter } from '@kbn/core/server';
|
||||
import { UsageCounter } from '@kbn/usage-collection-plugin/server';
|
||||
import { ILicenseState } from '../../lib';
|
||||
import { ActionsRequestHandlerContext } from '../../types';
|
||||
import { createActionRoute } from './create';
|
||||
import { deleteActionRoute } from './delete';
|
||||
import { getAllActionRoute } from './get_all';
|
||||
import { getActionRoute } from './get';
|
||||
import { updateActionRoute } from './update';
|
||||
import { listActionTypesRoute } from './list_action_types';
|
||||
import { executeActionRoute } from './execute';
|
||||
|
||||
export function defineLegacyRoutes(
|
||||
router: IRouter<ActionsRequestHandlerContext>,
|
||||
licenseState: ILicenseState,
|
||||
usageCounter?: UsageCounter
|
||||
) {
|
||||
createActionRoute(router, licenseState, usageCounter);
|
||||
deleteActionRoute(router, licenseState, usageCounter);
|
||||
getActionRoute(router, licenseState, usageCounter);
|
||||
getAllActionRoute(router, licenseState, usageCounter);
|
||||
updateActionRoute(router, licenseState, usageCounter);
|
||||
listActionTypesRoute(router, licenseState, usageCounter);
|
||||
executeActionRoute(router, licenseState, usageCounter);
|
||||
}
|
|
@ -1,178 +0,0 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License
|
||||
* 2.0; you may not use this file except in compliance with the Elastic License
|
||||
* 2.0.
|
||||
*/
|
||||
|
||||
import { listActionTypesRoute } from './list_action_types';
|
||||
import { httpServiceMock } from '@kbn/core/server/mocks';
|
||||
import { licenseStateMock } from '../../lib/license_state.mock';
|
||||
import { verifyApiAccess } from '../../lib';
|
||||
import { mockHandlerArguments } from './_mock_handler_arguments';
|
||||
import { LicenseType } from '@kbn/licensing-plugin/server';
|
||||
import { actionsClientMock } from '../../mocks';
|
||||
import { trackLegacyRouteUsage } from '../../lib/track_legacy_route_usage';
|
||||
import { usageCountersServiceMock } from '@kbn/usage-collection-plugin/server/usage_counters/usage_counters_service.mock';
|
||||
|
||||
jest.mock('../../lib/verify_api_access', () => ({
|
||||
verifyApiAccess: jest.fn(),
|
||||
}));
|
||||
|
||||
jest.mock('../../lib/track_legacy_route_usage', () => ({
|
||||
trackLegacyRouteUsage: jest.fn(),
|
||||
}));
|
||||
|
||||
const mockUsageCountersSetup = usageCountersServiceMock.createSetupContract();
|
||||
const mockUsageCounter = mockUsageCountersSetup.createUsageCounter('test');
|
||||
|
||||
beforeEach(() => {
|
||||
jest.resetAllMocks();
|
||||
});
|
||||
|
||||
describe('listActionTypesRoute', () => {
|
||||
it('lists action types with proper parameters', async () => {
|
||||
const licenseState = licenseStateMock.create();
|
||||
const router = httpServiceMock.createRouter();
|
||||
|
||||
listActionTypesRoute(router, licenseState);
|
||||
|
||||
const [config, handler] = router.get.mock.calls[0];
|
||||
|
||||
expect(config.path).toMatchInlineSnapshot(`"/api/actions/list_action_types"`);
|
||||
|
||||
const listTypes = [
|
||||
{
|
||||
id: '1',
|
||||
name: 'name',
|
||||
enabled: true,
|
||||
enabledInConfig: true,
|
||||
enabledInLicense: true,
|
||||
minimumLicenseRequired: 'gold' as LicenseType,
|
||||
supportedFeatureIds: ['alerting'],
|
||||
isSystemActionType: false,
|
||||
},
|
||||
];
|
||||
|
||||
const actionsClient = actionsClientMock.create();
|
||||
actionsClient.listTypes.mockResolvedValueOnce(listTypes);
|
||||
const [context, req, res] = mockHandlerArguments({ actionsClient }, {}, ['ok']);
|
||||
|
||||
expect(await handler(context, req, res)).toMatchInlineSnapshot(`
|
||||
Object {
|
||||
"body": Array [
|
||||
Object {
|
||||
"enabled": true,
|
||||
"enabledInConfig": true,
|
||||
"enabledInLicense": true,
|
||||
"id": "1",
|
||||
"isSystemActionType": false,
|
||||
"minimumLicenseRequired": "gold",
|
||||
"name": "name",
|
||||
"supportedFeatureIds": Array [
|
||||
"alerting",
|
||||
],
|
||||
},
|
||||
],
|
||||
}
|
||||
`);
|
||||
|
||||
expect(res.ok).toHaveBeenCalledWith({
|
||||
body: listTypes,
|
||||
});
|
||||
});
|
||||
|
||||
it('ensures the license allows listing action types', async () => {
|
||||
const licenseState = licenseStateMock.create();
|
||||
const router = httpServiceMock.createRouter();
|
||||
|
||||
listActionTypesRoute(router, licenseState);
|
||||
|
||||
const [config, handler] = router.get.mock.calls[0];
|
||||
|
||||
expect(config.path).toMatchInlineSnapshot(`"/api/actions/list_action_types"`);
|
||||
|
||||
const listTypes = [
|
||||
{
|
||||
id: '1',
|
||||
name: 'name',
|
||||
enabled: true,
|
||||
enabledInConfig: true,
|
||||
enabledInLicense: true,
|
||||
minimumLicenseRequired: 'gold' as LicenseType,
|
||||
supportedFeatureIds: ['alerting'],
|
||||
isSystemActionType: false,
|
||||
},
|
||||
];
|
||||
|
||||
const actionsClient = actionsClientMock.create();
|
||||
actionsClient.listTypes.mockResolvedValueOnce(listTypes);
|
||||
|
||||
const [context, req, res] = mockHandlerArguments(
|
||||
{ actionsClient },
|
||||
{
|
||||
params: { id: '1' },
|
||||
},
|
||||
['ok']
|
||||
);
|
||||
|
||||
await handler(context, req, res);
|
||||
|
||||
expect(verifyApiAccess).toHaveBeenCalledWith(licenseState);
|
||||
});
|
||||
|
||||
it('ensures the license check prevents listing action types', async () => {
|
||||
const licenseState = licenseStateMock.create();
|
||||
const router = httpServiceMock.createRouter();
|
||||
|
||||
(verifyApiAccess as jest.Mock).mockImplementation(() => {
|
||||
throw new Error('OMG');
|
||||
});
|
||||
|
||||
listActionTypesRoute(router, licenseState);
|
||||
|
||||
const [config, handler] = router.get.mock.calls[0];
|
||||
|
||||
expect(config.path).toMatchInlineSnapshot(`"/api/actions/list_action_types"`);
|
||||
|
||||
const listTypes = [
|
||||
{
|
||||
id: '1',
|
||||
name: 'name',
|
||||
enabled: true,
|
||||
enabledInConfig: true,
|
||||
enabledInLicense: true,
|
||||
minimumLicenseRequired: 'gold' as LicenseType,
|
||||
supportedFeatureIds: ['alerting'],
|
||||
isSystemActionType: false,
|
||||
},
|
||||
];
|
||||
|
||||
const actionsClient = actionsClientMock.create();
|
||||
actionsClient.listTypes.mockResolvedValueOnce(listTypes);
|
||||
|
||||
const [context, req, res] = mockHandlerArguments(
|
||||
{ actionsClient },
|
||||
{
|
||||
params: { id: '1' },
|
||||
},
|
||||
['ok']
|
||||
);
|
||||
|
||||
await expect(handler(context, req, res)).rejects.toMatchInlineSnapshot(`[Error: OMG]`);
|
||||
|
||||
expect(verifyApiAccess).toHaveBeenCalledWith(licenseState);
|
||||
});
|
||||
|
||||
it('should track every call', async () => {
|
||||
const licenseState = licenseStateMock.create();
|
||||
const router = httpServiceMock.createRouter();
|
||||
const actionsClient = actionsClientMock.create();
|
||||
|
||||
listActionTypesRoute(router, licenseState, mockUsageCounter);
|
||||
const [, handler] = router.get.mock.calls[0];
|
||||
const [context, req, res] = mockHandlerArguments({ actionsClient }, {});
|
||||
await handler(context, req, res);
|
||||
expect(trackLegacyRouteUsage).toHaveBeenCalledWith('listActionTypes', mockUsageCounter);
|
||||
});
|
||||
});
|
|
@ -1,48 +0,0 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License
|
||||
* 2.0; you may not use this file except in compliance with the Elastic License
|
||||
* 2.0.
|
||||
*/
|
||||
|
||||
import { IRouter } from '@kbn/core/server';
|
||||
import { UsageCounter } from '@kbn/usage-collection-plugin/server';
|
||||
import { ILicenseState, verifyApiAccess } from '../../lib';
|
||||
import { BASE_ACTION_API_PATH } from '../../../common';
|
||||
import { ActionsRequestHandlerContext } from '../../types';
|
||||
import { trackLegacyRouteUsage } from '../../lib/track_legacy_route_usage';
|
||||
|
||||
/**
|
||||
* Return all available action types
|
||||
* expect system action types
|
||||
*/
|
||||
export const listActionTypesRoute = (
|
||||
router: IRouter<ActionsRequestHandlerContext>,
|
||||
licenseState: ILicenseState,
|
||||
usageCounter?: UsageCounter
|
||||
) => {
|
||||
router.get(
|
||||
{
|
||||
path: `${BASE_ACTION_API_PATH}/list_action_types`,
|
||||
options: {
|
||||
access: 'public',
|
||||
summary: `Get connector types`,
|
||||
// @ts-expect-error TODO(https://github.com/elastic/kibana/issues/196095): Replace {RouteDeprecationInfo}
|
||||
deprecated: true,
|
||||
tags: ['oas-tag:connectors'],
|
||||
},
|
||||
validate: {},
|
||||
},
|
||||
router.handleLegacyErrors(async function (context, req, res) {
|
||||
verifyApiAccess(licenseState);
|
||||
if (!context.actions) {
|
||||
return res.badRequest({ body: 'RouteHandlerContext is not registered for actions' });
|
||||
}
|
||||
const actionsClient = (await context.actions).getActionsClient();
|
||||
trackLegacyRouteUsage('listActionTypes', usageCounter);
|
||||
return res.ok({
|
||||
body: await actionsClient.listTypes(),
|
||||
});
|
||||
})
|
||||
);
|
||||
};
|
|
@ -1,215 +0,0 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License
|
||||
* 2.0; you may not use this file except in compliance with the Elastic License
|
||||
* 2.0.
|
||||
*/
|
||||
|
||||
import { updateActionRoute } from './update';
|
||||
import { httpServiceMock } from '@kbn/core/server/mocks';
|
||||
import { licenseStateMock } from '../../lib/license_state.mock';
|
||||
import { verifyApiAccess, ActionTypeDisabledError } from '../../lib';
|
||||
import { mockHandlerArguments } from './_mock_handler_arguments';
|
||||
import { actionsClientMock } from '../../actions_client/actions_client.mock';
|
||||
import { trackLegacyRouteUsage } from '../../lib/track_legacy_route_usage';
|
||||
import { usageCountersServiceMock } from '@kbn/usage-collection-plugin/server/usage_counters/usage_counters_service.mock';
|
||||
|
||||
jest.mock('../../lib/verify_api_access', () => ({
|
||||
verifyApiAccess: jest.fn(),
|
||||
}));
|
||||
|
||||
jest.mock('../../lib/track_legacy_route_usage', () => ({
|
||||
trackLegacyRouteUsage: jest.fn(),
|
||||
}));
|
||||
|
||||
const mockUsageCountersSetup = usageCountersServiceMock.createSetupContract();
|
||||
const mockUsageCounter = mockUsageCountersSetup.createUsageCounter('test');
|
||||
|
||||
beforeEach(() => {
|
||||
jest.resetAllMocks();
|
||||
});
|
||||
|
||||
describe('updateActionRoute', () => {
|
||||
it('updates an action with proper parameters', async () => {
|
||||
const licenseState = licenseStateMock.create();
|
||||
const router = httpServiceMock.createRouter();
|
||||
|
||||
updateActionRoute(router, licenseState);
|
||||
|
||||
const [config, handler] = router.put.mock.calls[0];
|
||||
|
||||
expect(config.path).toMatchInlineSnapshot(`"/api/actions/action/{id}"`);
|
||||
|
||||
const updateResult = {
|
||||
id: '1',
|
||||
actionTypeId: 'my-action-type-id',
|
||||
name: 'My name',
|
||||
config: { foo: true },
|
||||
isPreconfigured: false,
|
||||
isDeprecated: false,
|
||||
isSystemAction: false,
|
||||
};
|
||||
|
||||
const actionsClient = actionsClientMock.create();
|
||||
actionsClient.update.mockResolvedValueOnce(updateResult);
|
||||
|
||||
const [context, req, res] = mockHandlerArguments(
|
||||
{ actionsClient },
|
||||
{
|
||||
params: {
|
||||
id: '1',
|
||||
},
|
||||
body: {
|
||||
name: 'My name',
|
||||
config: { foo: true },
|
||||
secrets: { key: 'i8oh34yf9783y39' },
|
||||
},
|
||||
},
|
||||
['ok']
|
||||
);
|
||||
|
||||
expect(await handler(context, req, res)).toEqual({ body: updateResult });
|
||||
|
||||
expect(actionsClient.update).toHaveBeenCalledTimes(1);
|
||||
expect(actionsClient.update.mock.calls[0]).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
Object {
|
||||
"action": Object {
|
||||
"config": Object {
|
||||
"foo": true,
|
||||
},
|
||||
"name": "My name",
|
||||
"secrets": Object {
|
||||
"key": "i8oh34yf9783y39",
|
||||
},
|
||||
},
|
||||
"id": "1",
|
||||
},
|
||||
]
|
||||
`);
|
||||
|
||||
expect(res.ok).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('ensures the license allows deleting actions', async () => {
|
||||
const licenseState = licenseStateMock.create();
|
||||
const router = httpServiceMock.createRouter();
|
||||
|
||||
updateActionRoute(router, licenseState);
|
||||
|
||||
const [, handler] = router.put.mock.calls[0];
|
||||
|
||||
const updateResult = {
|
||||
id: '1',
|
||||
actionTypeId: 'my-action-type-id',
|
||||
name: 'My name',
|
||||
config: { foo: true },
|
||||
isPreconfigured: false,
|
||||
isDeprecated: false,
|
||||
isSystemAction: false,
|
||||
};
|
||||
|
||||
const actionsClient = actionsClientMock.create();
|
||||
actionsClient.update.mockResolvedValueOnce(updateResult);
|
||||
|
||||
const [context, req, res] = mockHandlerArguments(
|
||||
{ actionsClient },
|
||||
{
|
||||
params: {
|
||||
id: '1',
|
||||
},
|
||||
body: {
|
||||
name: 'My name',
|
||||
config: { foo: true },
|
||||
secrets: { key: 'i8oh34yf9783y39' },
|
||||
},
|
||||
},
|
||||
['ok']
|
||||
);
|
||||
|
||||
await handler(context, req, res);
|
||||
|
||||
expect(verifyApiAccess).toHaveBeenCalledWith(licenseState);
|
||||
});
|
||||
|
||||
it('ensures the license check prevents deleting actions', async () => {
|
||||
const licenseState = licenseStateMock.create();
|
||||
const router = httpServiceMock.createRouter();
|
||||
|
||||
(verifyApiAccess as jest.Mock).mockImplementation(() => {
|
||||
throw new Error('OMG');
|
||||
});
|
||||
|
||||
updateActionRoute(router, licenseState);
|
||||
|
||||
const [, handler] = router.put.mock.calls[0];
|
||||
|
||||
const updateResult = {
|
||||
id: '1',
|
||||
actionTypeId: 'my-action-type-id',
|
||||
name: 'My name',
|
||||
config: { foo: true },
|
||||
isPreconfigured: false,
|
||||
isDeprecated: false,
|
||||
isSystemAction: false,
|
||||
};
|
||||
|
||||
const actionsClient = actionsClientMock.create();
|
||||
actionsClient.update.mockResolvedValueOnce(updateResult);
|
||||
|
||||
const [context, req, res] = mockHandlerArguments(
|
||||
{ actionsClient },
|
||||
{
|
||||
params: {
|
||||
id: '1',
|
||||
},
|
||||
body: {
|
||||
name: 'My name',
|
||||
config: { foo: true },
|
||||
secrets: { key: 'i8oh34yf9783y39' },
|
||||
},
|
||||
},
|
||||
['ok']
|
||||
);
|
||||
|
||||
await expect(handler(context, req, res)).rejects.toMatchInlineSnapshot(`[Error: OMG]`);
|
||||
|
||||
expect(verifyApiAccess).toHaveBeenCalledWith(licenseState);
|
||||
});
|
||||
|
||||
it('ensures the action type gets validated for the license', async () => {
|
||||
const licenseState = licenseStateMock.create();
|
||||
const router = httpServiceMock.createRouter();
|
||||
|
||||
updateActionRoute(router, licenseState);
|
||||
|
||||
const [, handler] = router.put.mock.calls[0];
|
||||
|
||||
const actionsClient = actionsClientMock.create();
|
||||
actionsClient.update.mockRejectedValue(new ActionTypeDisabledError('Fail', 'license_invalid'));
|
||||
|
||||
const [context, req, res] = mockHandlerArguments({ actionsClient }, { params: {}, body: {} }, [
|
||||
'ok',
|
||||
'forbidden',
|
||||
]);
|
||||
|
||||
await handler(context, req, res);
|
||||
|
||||
expect(res.forbidden).toHaveBeenCalledWith({ body: { message: 'Fail' } });
|
||||
});
|
||||
|
||||
it('should track every call', async () => {
|
||||
const licenseState = licenseStateMock.create();
|
||||
const router = httpServiceMock.createRouter();
|
||||
const actionsClient = actionsClientMock.create();
|
||||
|
||||
updateActionRoute(router, licenseState, mockUsageCounter);
|
||||
const [, handler] = router.put.mock.calls[0];
|
||||
const [context, req, res] = mockHandlerArguments(
|
||||
{ actionsClient },
|
||||
{ params: { id: '1' }, body: {} }
|
||||
);
|
||||
await handler(context, req, res);
|
||||
expect(trackLegacyRouteUsage).toHaveBeenCalledWith('update', mockUsageCounter);
|
||||
});
|
||||
});
|
|
@ -1,82 +0,0 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License
|
||||
* 2.0; you may not use this file except in compliance with the Elastic License
|
||||
* 2.0.
|
||||
*/
|
||||
|
||||
import { schema } from '@kbn/config-schema';
|
||||
import { UsageCounter } from '@kbn/usage-collection-plugin/server';
|
||||
import { IRouter } from '@kbn/core/server';
|
||||
import { ILicenseState, verifyApiAccess, isErrorThatHandlesItsOwnResponse } from '../../lib';
|
||||
import { BASE_ACTION_API_PATH } from '../../../common';
|
||||
import { ActionsRequestHandlerContext } from '../../types';
|
||||
import { trackLegacyRouteUsage } from '../../lib/track_legacy_route_usage';
|
||||
import { connectorResponseSchemaV1 } from '../../../common/routes/connector/response';
|
||||
|
||||
const paramSchema = schema.object({
|
||||
id: schema.string({
|
||||
meta: { description: 'An identifier for the connector.' },
|
||||
}),
|
||||
});
|
||||
|
||||
const bodySchema = schema.object({
|
||||
name: schema.string(),
|
||||
config: schema.recordOf(schema.string(), schema.any(), { defaultValue: {} }),
|
||||
secrets: schema.recordOf(schema.string(), schema.any(), { defaultValue: {} }),
|
||||
});
|
||||
|
||||
export const updateActionRoute = (
|
||||
router: IRouter<ActionsRequestHandlerContext>,
|
||||
licenseState: ILicenseState,
|
||||
usageCounter?: UsageCounter
|
||||
) => {
|
||||
router.put(
|
||||
{
|
||||
path: `${BASE_ACTION_API_PATH}/action/{id}`,
|
||||
options: {
|
||||
access: 'public',
|
||||
summary: `Update a connector`,
|
||||
// @ts-expect-error TODO(https://github.com/elastic/kibana/issues/196095): Replace {RouteDeprecationInfo}
|
||||
deprecated: true,
|
||||
tags: ['oas-tag:connectors'],
|
||||
},
|
||||
validate: {
|
||||
request: {
|
||||
body: bodySchema,
|
||||
params: paramSchema,
|
||||
},
|
||||
response: {
|
||||
200: {
|
||||
description: 'Indicates a successful call.',
|
||||
body: () => connectorResponseSchemaV1,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
router.handleLegacyErrors(async function (context, req, res) {
|
||||
verifyApiAccess(licenseState);
|
||||
if (!context.actions) {
|
||||
return res.badRequest({ body: 'RouteHandlerContext is not registered for actions' });
|
||||
}
|
||||
const actionsClient = (await context.actions).getActionsClient();
|
||||
const { id } = req.params;
|
||||
const { name, config, secrets } = req.body;
|
||||
trackLegacyRouteUsage('update', usageCounter);
|
||||
|
||||
try {
|
||||
return res.ok({
|
||||
body: await actionsClient.update({
|
||||
id,
|
||||
action: { name, config, secrets },
|
||||
}),
|
||||
});
|
||||
} catch (e) {
|
||||
if (isErrorThatHandlesItsOwnResponse(e)) {
|
||||
return e.sendResponse(res);
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
})
|
||||
);
|
||||
};
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
import { licenseStateMock } from '../lib/license_state.mock';
|
||||
import { verifyApiAccess, ActionTypeDisabledError } from '../lib';
|
||||
import { mockHandlerArguments } from './legacy/_mock_handler_arguments';
|
||||
import { mockHandlerArguments } from './_mock_handler_arguments';
|
||||
import { actionsClientMock } from '../actions_client/actions_client.mock';
|
||||
import { verifyAccessAndContext } from './verify_access_and_context';
|
||||
|
||||
|
|
|
@ -24,10 +24,10 @@ KIBANA_URL=https://elastic:changeme@localhost:5601
|
|||
|
||||
# create email action
|
||||
ACTION_ID_EMAIL=`curl -X POST --insecure --silent \
|
||||
$KIBANA_URL/api/actions/action \
|
||||
$KIBANA_URL/api/actions/connector \
|
||||
-H "kbn-xsrf: foo" -H "content-type: application/json" \
|
||||
-d '{
|
||||
"actionTypeId": ".email",
|
||||
"connector_type_id": ".email",
|
||||
"name": "email for action_param_templates test",
|
||||
"config": {
|
||||
"from": "team-alerting@example.com",
|
||||
|
@ -41,10 +41,10 @@ echo "email action id: $ACTION_ID_EMAIL"
|
|||
|
||||
# create slack action
|
||||
ACTION_ID_SLACK=`curl -X POST --insecure --silent \
|
||||
$KIBANA_URL/api/actions/action \
|
||||
$KIBANA_URL/api/actions/connector \
|
||||
-H "kbn-xsrf: foo" -H "content-type: application/json" \
|
||||
-d "{
|
||||
\"actionTypeId\": \".slack\",
|
||||
\"connector_type_id\": \".slack\",
|
||||
\"name\": \"slack for action_param_templates test\",
|
||||
\"config\": {
|
||||
},
|
||||
|
@ -56,10 +56,10 @@ echo "slack action id: $ACTION_ID_SLACK"
|
|||
|
||||
# create webhook action
|
||||
ACTION_ID_WEBHOOK=`curl -X POST --insecure --silent \
|
||||
$KIBANA_URL/api/actions/action \
|
||||
$KIBANA_URL/api/actions/connector \
|
||||
-H "kbn-xsrf: foo" -H "content-type: application/json" \
|
||||
-d "{
|
||||
\"actionTypeId\": \".webhook\",
|
||||
\"connector_type_id\": \".webhook\",
|
||||
\"name\": \"webhook for action_param_templates test\",
|
||||
\"config\": {
|
||||
\"url\": \"$SLACK_WEBHOOKURL\",
|
||||
|
@ -108,7 +108,7 @@ ALERT_ID=`curl -X POST --insecure --silent \
|
|||
}
|
||||
],
|
||||
\"params\": {
|
||||
\"index\": [\".kibana\"],
|
||||
\"index\": [\".kibana\"],
|
||||
\"timeField\": \"updated_at\",
|
||||
\"aggType\": \"count\",
|
||||
\"groupBy\": \"all\",
|
||||
|
|
|
@ -65,13 +65,13 @@ export default function casesWebhookTest({ getService }: FtrProviderContext) {
|
|||
);
|
||||
});
|
||||
|
||||
it('should return 403 when creating a cases webhook action', async () => {
|
||||
it('should return 403 when creating a cases webhook connector', async () => {
|
||||
await supertest
|
||||
.post('/api/actions/action')
|
||||
.post('/api/actions/connector')
|
||||
.set('kbn-xsrf', 'foo')
|
||||
.send({
|
||||
name: 'A cases webhook action',
|
||||
actionTypeId: '.cases-webhook',
|
||||
name: 'A cases webhook connector',
|
||||
connector_type_id: '.cases-webhook',
|
||||
config: {
|
||||
...config,
|
||||
createCommentUrl: `${casesWebhookSimulatorURL}/{{{external.system.id}}}/comments`,
|
||||
|
|
|
@ -11,14 +11,14 @@ import { FtrProviderContext } from '../../../../common/ftr_provider_context';
|
|||
export default function emailTest({ getService }: FtrProviderContext) {
|
||||
const supertest = getService('supertest');
|
||||
|
||||
describe('create email action', () => {
|
||||
it('should return 403 when creating an email action', async () => {
|
||||
describe('create email connector', () => {
|
||||
it('should return 403 when creating an email connector', async () => {
|
||||
await supertest
|
||||
.post('/api/actions/action')
|
||||
.post('/api/actions/connector')
|
||||
.set('kbn-xsrf', 'foo')
|
||||
.send({
|
||||
name: 'An email action',
|
||||
actionTypeId: '.email',
|
||||
name: 'An email connector',
|
||||
connector_type_id: '.email',
|
||||
config: {
|
||||
service: '__json',
|
||||
from: 'bob@example.com',
|
||||
|
|
|
@ -11,15 +11,15 @@ import { FtrProviderContext } from '../../../../common/ftr_provider_context';
|
|||
export default function indexTest({ getService }: FtrProviderContext) {
|
||||
const supertest = getService('supertest');
|
||||
|
||||
describe('index action', () => {
|
||||
it('should return 200 when creating an index action', async () => {
|
||||
// create action with no config
|
||||
describe('index connector', () => {
|
||||
it('should return 200 when creating an index connector', async () => {
|
||||
// create connector with no config
|
||||
await supertest
|
||||
.post('/api/actions/action')
|
||||
.post('/api/actions/connector')
|
||||
.set('kbn-xsrf', 'foo')
|
||||
.send({
|
||||
name: 'An index action',
|
||||
actionTypeId: '.index',
|
||||
name: 'An index connector',
|
||||
connector_type_id: '.index',
|
||||
config: {
|
||||
index: 'foo',
|
||||
},
|
||||
|
|
|
@ -50,13 +50,13 @@ export default function jiraTest({ getService }: FtrProviderContext) {
|
|||
);
|
||||
});
|
||||
|
||||
it('should return 403 when creating a jira action', async () => {
|
||||
it('should return 403 when creating a jira connector', async () => {
|
||||
await supertest
|
||||
.post('/api/actions/action')
|
||||
.post('/api/actions/connector')
|
||||
.set('kbn-xsrf', 'foo')
|
||||
.send({
|
||||
name: 'A jira action',
|
||||
actionTypeId: '.jira',
|
||||
name: 'A jira connector',
|
||||
connector_type_id: '.jira',
|
||||
config: {
|
||||
apiUrl: jiraSimulatorURL,
|
||||
projectKey: 'CK',
|
||||
|
|
|
@ -11,14 +11,14 @@ import { FtrProviderContext } from '../../../../common/ftr_provider_context';
|
|||
export default function pagerdutyTest({ getService }: FtrProviderContext) {
|
||||
const supertest = getService('supertest');
|
||||
|
||||
describe('pagerduty action', () => {
|
||||
it('should return 403 when creating a pagerduty action', async () => {
|
||||
describe('pagerduty connector', () => {
|
||||
it('should return 403 when creating a pagerduty connector', async () => {
|
||||
await supertest
|
||||
.post('/api/actions/action')
|
||||
.post('/api/actions/connector')
|
||||
.set('kbn-xsrf', 'foo')
|
||||
.send({
|
||||
name: 'A pagerduty action',
|
||||
actionTypeId: '.pagerduty',
|
||||
name: 'A pagerduty connector',
|
||||
connector_type_id: '.pagerduty',
|
||||
config: {
|
||||
apiUrl: 'http://localhost',
|
||||
},
|
||||
|
|
|
@ -49,12 +49,12 @@ export default function resilientTest({ getService }: FtrProviderContext) {
|
|||
);
|
||||
});
|
||||
|
||||
it('should return 403 when creating a resilient action', async () => {
|
||||
it('should return 403 when creating a resilient connector', async () => {
|
||||
await supertest
|
||||
.post('/api/actions/connector')
|
||||
.set('kbn-xsrf', 'foo')
|
||||
.send({
|
||||
name: 'A resilient action',
|
||||
name: 'A resilient connector',
|
||||
connector_type_id: '.resilient',
|
||||
config: {
|
||||
...mockResilient.config,
|
||||
|
|
|
@ -11,14 +11,14 @@ import { FtrProviderContext } from '../../../../common/ftr_provider_context';
|
|||
export default function serverLogTest({ getService }: FtrProviderContext) {
|
||||
const supertest = getService('supertest');
|
||||
|
||||
describe('server-log action', () => {
|
||||
it('should return 200 when creating a server-log action', async () => {
|
||||
describe('server-log connector', () => {
|
||||
it('should return 200 when creating a server-log connector', async () => {
|
||||
await supertest
|
||||
.post('/api/actions/action')
|
||||
.post('/api/actions/connector')
|
||||
.set('kbn-xsrf', 'foo')
|
||||
.send({
|
||||
name: 'A server.log action',
|
||||
actionTypeId: '.server-log',
|
||||
name: 'A server.log connector',
|
||||
connector_type_id: '.server-log',
|
||||
})
|
||||
.expect(200);
|
||||
});
|
||||
|
|
|
@ -49,13 +49,13 @@ export default function servicenowTest({ getService }: FtrProviderContext) {
|
|||
);
|
||||
});
|
||||
|
||||
it('should return 403 when creating a servicenow action', async () => {
|
||||
it('should return 403 when creating a servicenow connector', async () => {
|
||||
await supertest
|
||||
.post('/api/actions/action')
|
||||
.post('/api/actions/connector')
|
||||
.set('kbn-xsrf', 'foo')
|
||||
.send({
|
||||
name: 'A servicenow action',
|
||||
actionTypeId: '.servicenow',
|
||||
name: 'A servicenow connector',
|
||||
connector_type_id: '.servicenow',
|
||||
config: {
|
||||
apiUrl: servicenowSimulatorURL,
|
||||
},
|
||||
|
|
|
@ -14,7 +14,7 @@ import { FtrProviderContext } from '../../../../common/ftr_provider_context';
|
|||
export default function slackTest({ getService }: FtrProviderContext) {
|
||||
const supertest = getService('supertest');
|
||||
|
||||
describe('slack action', () => {
|
||||
describe('slack connector', () => {
|
||||
let slackSimulatorURL: string = '';
|
||||
let slackServer: http.Server;
|
||||
|
||||
|
@ -25,13 +25,13 @@ export default function slackTest({ getService }: FtrProviderContext) {
|
|||
slackSimulatorURL = `http://localhost:${availablePort}`;
|
||||
});
|
||||
|
||||
it('should return 403 when creating a slack action', async () => {
|
||||
it('should return 403 when creating a slack connector', async () => {
|
||||
await supertest
|
||||
.post('/api/actions/action')
|
||||
.post('/api/actions/connector')
|
||||
.set('kbn-xsrf', 'foo')
|
||||
.send({
|
||||
name: 'A slack action',
|
||||
actionTypeId: '.slack',
|
||||
name: 'A slack connector',
|
||||
connector_type_id: '.slack',
|
||||
secrets: {
|
||||
webhookUrl: slackSimulatorURL,
|
||||
},
|
||||
|
|
|
@ -16,8 +16,8 @@ export default function swimlaneTest({ getService }: FtrProviderContext) {
|
|||
const supertest = getService('supertest');
|
||||
const kibanaServer = getService('kibanaServer');
|
||||
const mockSwimlane = {
|
||||
name: 'A swimlane action',
|
||||
actionTypeId: '.swimlane',
|
||||
name: 'A swimlane connector',
|
||||
connector_type_id: '.swimlane',
|
||||
config: {
|
||||
apiUrl: 'http://swimlane.mynonexistent.co',
|
||||
appId: '123456asdf',
|
||||
|
@ -69,9 +69,9 @@ export default function swimlaneTest({ getService }: FtrProviderContext) {
|
|||
getExternalServiceSimulatorPath(ExternalServiceSimulator.SWIMLANE)
|
||||
);
|
||||
});
|
||||
it('should return 403 when creating a swimlane action', async () => {
|
||||
it('should return 403 when creating a swimlane connector', async () => {
|
||||
await supertest
|
||||
.post('/api/actions/action')
|
||||
.post('/api/actions/connector')
|
||||
.set('kbn-xsrf', 'foo')
|
||||
.send({
|
||||
...mockSwimlane,
|
||||
|
|
|
@ -14,7 +14,7 @@ import { FtrProviderContext } from '../../../../common/ftr_provider_context';
|
|||
export default function webhookTest({ getService }: FtrProviderContext) {
|
||||
const supertest = getService('supertest');
|
||||
|
||||
describe('webhook action', () => {
|
||||
describe('webhook connector', () => {
|
||||
let webhookSimulatorURL: string = '';
|
||||
let webhookServer: http.Server;
|
||||
// need to wait for kibanaServer to settle ...
|
||||
|
@ -25,13 +25,13 @@ export default function webhookTest({ getService }: FtrProviderContext) {
|
|||
webhookSimulatorURL = `http://localhost:${availablePort}`;
|
||||
});
|
||||
|
||||
it('should return 403 when creating a webhook action', async () => {
|
||||
it('should return 403 when creating a webhook connector', async () => {
|
||||
await supertest
|
||||
.post('/api/actions/action')
|
||||
.post('/api/actions/connector')
|
||||
.set('kbn-xsrf', 'test')
|
||||
.send({
|
||||
name: 'A generic Webhook action',
|
||||
actionTypeId: '.webhook',
|
||||
name: 'A generic Webhook connector',
|
||||
connector_type_id: '.webhook',
|
||||
secrets: {
|
||||
user: 'username',
|
||||
password: 'mypassphrase',
|
||||
|
|
|
@ -26,11 +26,11 @@ export default function retainAPIKeyTests({ getService }: FtrProviderContext) {
|
|||
|
||||
describe(scenario.id, () => {
|
||||
it('should retain the api key when a rule is disabled and then enabled', async () => {
|
||||
const { body: createdAction } = await supertest
|
||||
const { body: createdConnector } = await supertest
|
||||
.post(`${getUrlPrefix(space.id)}/api/actions/connector`)
|
||||
.set('kbn-xsrf', 'foo')
|
||||
.send({
|
||||
name: 'MY action',
|
||||
name: 'MY connector',
|
||||
connector_type_id: 'test.noop',
|
||||
config: {},
|
||||
secrets: {},
|
||||
|
@ -44,7 +44,7 @@ export default function retainAPIKeyTests({ getService }: FtrProviderContext) {
|
|||
getTestRuleData({
|
||||
actions: [
|
||||
{
|
||||
id: createdAction.id,
|
||||
id: createdConnector.id,
|
||||
group: 'default',
|
||||
params: {},
|
||||
},
|
||||
|
@ -53,7 +53,7 @@ export default function retainAPIKeyTests({ getService }: FtrProviderContext) {
|
|||
)
|
||||
.expect(200);
|
||||
objectRemover.add(space.id, createdRule.id, 'rule', 'alerting');
|
||||
objectRemover.add(space.id, createdAction.id, 'action', 'actions');
|
||||
objectRemover.add(space.id, createdConnector.id, 'connector', 'actions');
|
||||
const {
|
||||
body: { apiKey, apiKeyOwner },
|
||||
} = await alertUtils.getAPIKeyRequest(createdRule.id);
|
||||
|
|
|
@ -39,11 +39,11 @@ export default function ({ getService }: FtrProviderContext) {
|
|||
it(`should handle enqueue request appropriately: ${scenario.id}`, async () => {
|
||||
const startDate = new Date().toISOString();
|
||||
|
||||
const { body: createdAction } = await supertest
|
||||
const { body: createdConnector } = await supertest
|
||||
.post(`${getUrlPrefix(space.id)}/api/actions/connector`)
|
||||
.set('kbn-xsrf', 'foo')
|
||||
.send({
|
||||
name: 'My action',
|
||||
name: 'My Connector',
|
||||
connector_type_id: 'test.index-record',
|
||||
config: {
|
||||
unencrypted: `This value shouldn't get encrypted`,
|
||||
|
@ -54,10 +54,10 @@ export default function ({ getService }: FtrProviderContext) {
|
|||
})
|
||||
.expect(200);
|
||||
|
||||
objectRemover.add(space.id, createdAction.id, 'action', 'actions');
|
||||
objectRemover.add(space.id, createdConnector.id, 'connector', 'actions');
|
||||
|
||||
const connectorId = createdAction.id;
|
||||
const name = 'My action';
|
||||
const connectorId = createdConnector.id;
|
||||
const name = 'My Connector';
|
||||
const reference = `actions-enqueue-${scenario.id}:${space.id}:${connectorId}`;
|
||||
|
||||
const response = await supertestWithoutAuth
|
||||
|
|
|
@ -13,7 +13,7 @@ import { checkAAD, getUrlPrefix, ObjectRemover } from '../../../../common/lib';
|
|||
import { FtrProviderContext } from '../../../../common/ftr_provider_context';
|
||||
|
||||
// eslint-disable-next-line import/no-default-export
|
||||
export default function createActionTests({ getService }: FtrProviderContext) {
|
||||
export default function createConnectorTests({ getService }: FtrProviderContext) {
|
||||
const supertest = getService('supertest');
|
||||
const supertestWithoutAuth = getService('supertestWithoutAuth');
|
||||
const es = getService('es');
|
||||
|
@ -35,13 +35,13 @@ export default function createActionTests({ getService }: FtrProviderContext) {
|
|||
for (const scenario of UserAtSpaceScenarios) {
|
||||
const { user, space } = scenario;
|
||||
describe(scenario.id, () => {
|
||||
it('should handle create action request appropriately', async () => {
|
||||
it('should handle create connector request appropriately', async () => {
|
||||
const response = await supertestWithoutAuth
|
||||
.post(`${getUrlPrefix(space.id)}/api/actions/connector`)
|
||||
.auth(user.username, user.password)
|
||||
.set('kbn-xsrf', 'foo')
|
||||
.send({
|
||||
name: 'My action',
|
||||
name: 'My Connector',
|
||||
connector_type_id: 'test.index-record',
|
||||
config: {
|
||||
unencrypted: `This value shouldn't get encrypted`,
|
||||
|
@ -67,14 +67,14 @@ export default function createActionTests({ getService }: FtrProviderContext) {
|
|||
case 'space_1_all at space1':
|
||||
case 'space_1_all_with_restricted_fixture at space1':
|
||||
expect(response.statusCode).to.eql(200);
|
||||
objectRemover.add(space.id, response.body.id, 'action', 'actions');
|
||||
objectRemover.add(space.id, response.body.id, 'connector', 'actions');
|
||||
expect(response.body).to.eql({
|
||||
id: response.body.id,
|
||||
is_preconfigured: false,
|
||||
is_system_action: false,
|
||||
is_deprecated: false,
|
||||
is_missing_secrets: false,
|
||||
name: 'My action',
|
||||
name: 'My Connector',
|
||||
connector_type_id: 'test.index-record',
|
||||
config: {
|
||||
unencrypted: `This value shouldn't get encrypted`,
|
||||
|
@ -94,13 +94,13 @@ export default function createActionTests({ getService }: FtrProviderContext) {
|
|||
}
|
||||
});
|
||||
|
||||
it(`should handle create action request appropriately when action type isn't registered`, async () => {
|
||||
it(`should handle create connector request appropriately when connector type isn't registered`, async () => {
|
||||
const response = await supertestWithoutAuth
|
||||
.post(`${getUrlPrefix(space.id)}/api/actions/connector`)
|
||||
.set('kbn-xsrf', 'foo')
|
||||
.auth(user.username, user.password)
|
||||
.send({
|
||||
name: 'My action',
|
||||
name: 'My Connector',
|
||||
connector_type_id: 'test.unregistered-action-type',
|
||||
config: {},
|
||||
});
|
||||
|
@ -132,7 +132,7 @@ export default function createActionTests({ getService }: FtrProviderContext) {
|
|||
}
|
||||
});
|
||||
|
||||
it('should handle create action request appropriately when payload is empty and invalid', async () => {
|
||||
it('should handle create connector request appropriately when payload is empty and invalid', async () => {
|
||||
const response = await supertestWithoutAuth
|
||||
.post(`${getUrlPrefix(space.id)}/api/actions/connector`)
|
||||
.set('kbn-xsrf', 'foo')
|
||||
|
@ -159,7 +159,7 @@ export default function createActionTests({ getService }: FtrProviderContext) {
|
|||
}
|
||||
});
|
||||
|
||||
it(`should handle create action request appropriately when config isn't valid`, async () => {
|
||||
it(`should handle create connector request appropriately when config isn't valid`, async () => {
|
||||
const response = await supertestWithoutAuth
|
||||
.post(`${getUrlPrefix(space.id)}/api/actions/connector`)
|
||||
.set('kbn-xsrf', 'foo')
|
||||
|
@ -200,7 +200,7 @@ export default function createActionTests({ getService }: FtrProviderContext) {
|
|||
}
|
||||
});
|
||||
|
||||
it(`should handle create action requests for action types that are not enabled`, async () => {
|
||||
it(`should handle create connector requests for connector types that are not enabled`, async () => {
|
||||
const response = await supertestWithoutAuth
|
||||
.post(`${getUrlPrefix(space.id)}/api/actions/connector`)
|
||||
.set('kbn-xsrf', 'foo')
|
||||
|
@ -238,7 +238,7 @@ export default function createActionTests({ getService }: FtrProviderContext) {
|
|||
}
|
||||
});
|
||||
|
||||
it(`should handle create action request appropriately when empty strings are submitted`, async () => {
|
||||
it(`should handle create connector request appropriately when empty strings are submitted`, async () => {
|
||||
const response = await supertestWithoutAuth
|
||||
.post(`${getUrlPrefix(space.id)}/api/actions/connector`)
|
||||
.set('kbn-xsrf', 'foo')
|
||||
|
@ -271,14 +271,14 @@ export default function createActionTests({ getService }: FtrProviderContext) {
|
|||
}
|
||||
});
|
||||
|
||||
it('should handle create action request appropriately with a predefined id', async () => {
|
||||
it('should handle create connector request appropriately with a predefined id', async () => {
|
||||
const predefinedId = uuidv4();
|
||||
const response = await supertestWithoutAuth
|
||||
.post(`${getUrlPrefix(space.id)}/api/actions/connector/${predefinedId}`)
|
||||
.auth(user.username, user.password)
|
||||
.set('kbn-xsrf', 'foo')
|
||||
.send({
|
||||
name: 'My action',
|
||||
name: 'My Connector',
|
||||
connector_type_id: 'test.index-record',
|
||||
config: {
|
||||
unencrypted: `This value shouldn't get encrypted`,
|
||||
|
@ -304,14 +304,14 @@ export default function createActionTests({ getService }: FtrProviderContext) {
|
|||
case 'space_1_all at space1':
|
||||
case 'space_1_all_with_restricted_fixture at space1':
|
||||
expect(response.statusCode).to.eql(200);
|
||||
objectRemover.add(space.id, response.body.id, 'action', 'actions');
|
||||
objectRemover.add(space.id, response.body.id, 'connector', 'actions');
|
||||
expect(response.body).to.eql({
|
||||
id: predefinedId,
|
||||
is_preconfigured: false,
|
||||
is_system_action: false,
|
||||
is_deprecated: false,
|
||||
is_missing_secrets: false,
|
||||
name: 'My action',
|
||||
name: 'My Connector',
|
||||
connector_type_id: 'test.index-record',
|
||||
config: {
|
||||
unencrypted: `This value shouldn't get encrypted`,
|
||||
|
@ -331,13 +331,13 @@ export default function createActionTests({ getService }: FtrProviderContext) {
|
|||
}
|
||||
});
|
||||
|
||||
it(`shouldn't create a preconfigured action with the same id as an existing one`, async () => {
|
||||
it(`shouldn't create a preconfigured connector with the same id as an existing one`, async () => {
|
||||
const response = await supertestWithoutAuth
|
||||
.post(`${getUrlPrefix(space.id)}/api/actions/connector/custom-system-abc-connector`)
|
||||
.auth(user.username, user.password)
|
||||
.set('kbn-xsrf', 'foo')
|
||||
.send({
|
||||
name: 'My action',
|
||||
name: 'My Connector',
|
||||
connector_type_id: 'system-abc-action-type',
|
||||
config: {},
|
||||
secrets: {},
|
||||
|
@ -441,7 +441,7 @@ export default function createActionTests({ getService }: FtrProviderContext) {
|
|||
case 'space_1_all at space1':
|
||||
case 'space_1_all_with_restricted_fixture at space1':
|
||||
expect(response.statusCode).to.eql(200);
|
||||
objectRemover.add(space.id, response.body.id, 'action', 'actions');
|
||||
objectRemover.add(space.id, response.body.id, 'connector', 'actions');
|
||||
|
||||
const refs: string[] = [];
|
||||
for (const hit of searchResult.body.hits.hits) {
|
||||
|
|
|
@ -14,7 +14,7 @@ import { getUrlPrefix, ObjectRemover } from '../../../../common/lib';
|
|||
import { FtrProviderContext } from '../../../../common/ftr_provider_context';
|
||||
|
||||
// eslint-disable-next-line import/no-default-export
|
||||
export default function deleteActionTests({ getService }: FtrProviderContext) {
|
||||
export default function deleteConnectorTests({ getService }: FtrProviderContext) {
|
||||
const supertest = getService('supertest');
|
||||
const supertestWithoutAuth = getService('supertestWithoutAuth');
|
||||
const es = getService('es');
|
||||
|
@ -36,12 +36,12 @@ export default function deleteActionTests({ getService }: FtrProviderContext) {
|
|||
for (const scenario of UserAtSpaceScenarios) {
|
||||
const { user, space } = scenario;
|
||||
describe(scenario.id, () => {
|
||||
it('should handle delete action request appropriately', async () => {
|
||||
const { body: createdAction } = await supertest
|
||||
it('should handle delete connector request appropriately', async () => {
|
||||
const { body: createdConnector } = await supertest
|
||||
.post(`${getUrlPrefix(space.id)}/api/actions/connector`)
|
||||
.set('kbn-xsrf', 'foo')
|
||||
.send({
|
||||
name: 'My action',
|
||||
name: 'My Connector',
|
||||
connector_type_id: 'test.index-record',
|
||||
config: {
|
||||
unencrypted: `This value shouldn't get encrypted`,
|
||||
|
@ -53,7 +53,7 @@ export default function deleteActionTests({ getService }: FtrProviderContext) {
|
|||
.expect(200);
|
||||
|
||||
const response = await supertestWithoutAuth
|
||||
.delete(`${getUrlPrefix(space.id)}/api/actions/connector/${createdAction.id}`)
|
||||
.delete(`${getUrlPrefix(space.id)}/api/actions/connector/${createdConnector.id}`)
|
||||
.auth(user.username, user.password)
|
||||
.set('kbn-xsrf', 'foo');
|
||||
|
||||
|
@ -68,7 +68,7 @@ export default function deleteActionTests({ getService }: FtrProviderContext) {
|
|||
error: 'Forbidden',
|
||||
message: 'Unauthorized to delete actions',
|
||||
});
|
||||
objectRemover.add(space.id, createdAction.id, 'action', 'actions');
|
||||
objectRemover.add(space.id, createdConnector.id, 'connector', 'actions');
|
||||
break;
|
||||
case 'superuser at space1':
|
||||
case 'space_1_all at space1':
|
||||
|
@ -81,12 +81,12 @@ export default function deleteActionTests({ getService }: FtrProviderContext) {
|
|||
}
|
||||
});
|
||||
|
||||
it(`shouldn't delete action from another space`, async () => {
|
||||
const { body: createdAction } = await supertest
|
||||
it(`shouldn't delete connector from another space`, async () => {
|
||||
const { body: createdConnector } = await supertest
|
||||
.post(`${getUrlPrefix(space.id)}/api/actions/connector`)
|
||||
.set('kbn-xsrf', 'foo')
|
||||
.send({
|
||||
name: 'My action',
|
||||
name: 'My Connector',
|
||||
connector_type_id: 'test.index-record',
|
||||
config: {
|
||||
unencrypted: `This value shouldn't get encrypted`,
|
||||
|
@ -96,10 +96,10 @@ export default function deleteActionTests({ getService }: FtrProviderContext) {
|
|||
},
|
||||
})
|
||||
.expect(200);
|
||||
objectRemover.add(space.id, createdAction.id, 'action', 'actions');
|
||||
objectRemover.add(space.id, createdConnector.id, 'connector', 'actions');
|
||||
|
||||
const response = await supertestWithoutAuth
|
||||
.delete(`${getUrlPrefix('other')}/api/actions/connector/${createdAction.id}`)
|
||||
.delete(`${getUrlPrefix('other')}/api/actions/connector/${createdConnector.id}`)
|
||||
.auth(user.username, user.password)
|
||||
.set('kbn-xsrf', 'foo');
|
||||
|
||||
|
@ -122,7 +122,7 @@ export default function deleteActionTests({ getService }: FtrProviderContext) {
|
|||
expect(response.body).to.eql({
|
||||
statusCode: 404,
|
||||
error: 'Not Found',
|
||||
message: `Saved object [action/${createdAction.id}] not found`,
|
||||
message: `Saved object [action/${createdConnector.id}] not found`,
|
||||
});
|
||||
break;
|
||||
default:
|
||||
|
@ -130,7 +130,7 @@ export default function deleteActionTests({ getService }: FtrProviderContext) {
|
|||
}
|
||||
});
|
||||
|
||||
it(`should handle delete request appropriately when action doesn't exist`, async () => {
|
||||
it(`should handle delete request appropriately when connector doesn't exist`, async () => {
|
||||
const response = await supertestWithoutAuth
|
||||
.delete(`${getUrlPrefix(space.id)}/api/actions/connector/2`)
|
||||
.set('kbn-xsrf', 'foo')
|
||||
|
@ -158,7 +158,7 @@ export default function deleteActionTests({ getService }: FtrProviderContext) {
|
|||
}
|
||||
});
|
||||
|
||||
it(`shouldn't delete preconfigured action`, async () => {
|
||||
it(`shouldn't delete preconfigured connector`, async () => {
|
||||
const response = await supertestWithoutAuth
|
||||
.delete(`${getUrlPrefix(space.id)}/api/actions/connector/my-slack1`)
|
||||
.auth(user.username, user.password)
|
||||
|
@ -228,7 +228,7 @@ export default function deleteActionTests({ getService }: FtrProviderContext) {
|
|||
it('should handle delete hooks appropriately', async () => {
|
||||
const source = uuidv4();
|
||||
const encryptedValue = 'This value should be encrypted';
|
||||
const { body: createdAction } = await supertest
|
||||
const { body: createdConnector } = await supertest
|
||||
.post(`${getUrlPrefix(space.id)}/api/actions/connector`)
|
||||
.set('kbn-xsrf', 'foo')
|
||||
.send({
|
||||
|
@ -249,7 +249,7 @@ export default function deleteActionTests({ getService }: FtrProviderContext) {
|
|||
await esTestIndexTool.setup();
|
||||
|
||||
const response = await supertestWithoutAuth
|
||||
.delete(`${getUrlPrefix(space.id)}/api/actions/connector/${createdAction.id}`)
|
||||
.delete(`${getUrlPrefix(space.id)}/api/actions/connector/${createdConnector.id}`)
|
||||
.auth(user.username, user.password)
|
||||
.set('kbn-xsrf', 'foo');
|
||||
|
||||
|
@ -262,7 +262,7 @@ export default function deleteActionTests({ getService }: FtrProviderContext) {
|
|||
case 'space_1_all at space2':
|
||||
expect(response.statusCode).to.eql(403);
|
||||
expect(searchResult.body.hits.hits.length).to.eql(0);
|
||||
objectRemover.add(space.id, createdAction.id, 'action', 'actions');
|
||||
objectRemover.add(space.id, createdConnector.id, 'connector', 'actions');
|
||||
break;
|
||||
case 'superuser at space1':
|
||||
case 'space_1_all at space1':
|
||||
|
@ -279,7 +279,7 @@ export default function deleteActionTests({ getService }: FtrProviderContext) {
|
|||
|
||||
const expected = {
|
||||
state: {
|
||||
connectorId: createdAction.id,
|
||||
connectorId: createdConnector.id,
|
||||
config: { index: ES_TEST_INDEX_NAME, source },
|
||||
},
|
||||
source,
|
||||
|
@ -291,7 +291,7 @@ export default function deleteActionTests({ getService }: FtrProviderContext) {
|
|||
expect(refs).to.eql(['post-delete']);
|
||||
break;
|
||||
default:
|
||||
objectRemover.add(space.id, createdAction.id, 'action', 'actions');
|
||||
objectRemover.add(space.id, createdConnector.id, 'connector', 'actions');
|
||||
throw new Error(`Scenario untested: ${JSON.stringify(scenario)}`);
|
||||
}
|
||||
});
|
||||
|
|
|
@ -42,11 +42,11 @@ export default function ({ getService }: FtrProviderContext) {
|
|||
describe(scenario.id, () => {
|
||||
it('should handle execute request appropriately', async () => {
|
||||
const connectorTypeId = 'test.index-record';
|
||||
const { body: createdAction } = await supertest
|
||||
const { body: createdConnector } = await supertest
|
||||
.post(`${getUrlPrefix(space.id)}/api/actions/connector`)
|
||||
.set('kbn-xsrf', 'foo')
|
||||
.send({
|
||||
name: 'My action',
|
||||
name: 'My Connector',
|
||||
connector_type_id: connectorTypeId,
|
||||
config: {
|
||||
unencrypted: `This value shouldn't get encrypted`,
|
||||
|
@ -56,11 +56,11 @@ export default function ({ getService }: FtrProviderContext) {
|
|||
},
|
||||
})
|
||||
.expect(200);
|
||||
objectRemover.add(space.id, createdAction.id, 'action', 'actions');
|
||||
objectRemover.add(space.id, createdConnector.id, 'connector', 'actions');
|
||||
|
||||
const reference = `actions-execute-1:${user.username}`;
|
||||
const response = await supertestWithoutAuth
|
||||
.post(`${getUrlPrefix(space.id)}/api/actions/connector/${createdAction.id}/_execute`)
|
||||
.post(`${getUrlPrefix(space.id)}/api/actions/connector/${createdConnector.id}/_execute`)
|
||||
.auth(user.username, user.password)
|
||||
.set('kbn-xsrf', 'foo')
|
||||
.send({
|
||||
|
@ -114,10 +114,10 @@ export default function ({ getService }: FtrProviderContext) {
|
|||
|
||||
await validateEventLog({
|
||||
spaceId: space.id,
|
||||
connectorId: createdAction.id,
|
||||
connectorId: createdConnector.id,
|
||||
outcome: 'success',
|
||||
actionTypeId: 'test.index-record',
|
||||
message: `action executed: test.index-record:${createdAction.id}: My action`,
|
||||
message: `action executed: test.index-record:${createdConnector.id}: My Connector`,
|
||||
source: ActionExecutionSourceType.HTTP_REQUEST,
|
||||
});
|
||||
break;
|
||||
|
@ -126,12 +126,12 @@ export default function ({ getService }: FtrProviderContext) {
|
|||
}
|
||||
});
|
||||
|
||||
it(`shouldn't execute an action from another space`, async () => {
|
||||
const { body: createdAction } = await supertest
|
||||
it(`shouldn't execute an connector from another space`, async () => {
|
||||
const { body: createdConnector } = await supertest
|
||||
.post(`${getUrlPrefix(space.id)}/api/actions/connector`)
|
||||
.set('kbn-xsrf', 'foo')
|
||||
.send({
|
||||
name: 'My action',
|
||||
name: 'My Connector',
|
||||
connector_type_id: 'test.index-record',
|
||||
config: {
|
||||
unencrypted: `This value shouldn't get encrypted`,
|
||||
|
@ -141,11 +141,11 @@ export default function ({ getService }: FtrProviderContext) {
|
|||
},
|
||||
})
|
||||
.expect(200);
|
||||
objectRemover.add(space.id, createdAction.id, 'action', 'actions');
|
||||
objectRemover.add(space.id, createdConnector.id, 'connector', 'actions');
|
||||
|
||||
const reference = `actions-execute-4:${user.username}`;
|
||||
const response = await supertestWithoutAuth
|
||||
.post(`${getUrlPrefix('other')}/api/actions/connector/${createdAction.id}/_execute`)
|
||||
.post(`${getUrlPrefix('other')}/api/actions/connector/${createdConnector.id}/_execute`)
|
||||
.auth(user.username, user.password)
|
||||
.set('kbn-xsrf', 'foo')
|
||||
.send({
|
||||
|
@ -176,7 +176,7 @@ export default function ({ getService }: FtrProviderContext) {
|
|||
expect(response.body).to.eql({
|
||||
statusCode: 404,
|
||||
error: 'Not Found',
|
||||
message: `Saved object [action/${createdAction.id}] not found`,
|
||||
message: `Saved object [action/${createdConnector.id}] not found`,
|
||||
});
|
||||
break;
|
||||
default:
|
||||
|
@ -184,13 +184,13 @@ export default function ({ getService }: FtrProviderContext) {
|
|||
}
|
||||
});
|
||||
|
||||
it('should handle execute request appropriately after action is updated', async () => {
|
||||
it('should handle execute request appropriately after connector is updated', async () => {
|
||||
const connectorTypeId = 'test.index-record';
|
||||
const { body: createdAction } = await supertest
|
||||
const { body: createdConnector } = await supertest
|
||||
.post(`${getUrlPrefix(space.id)}/api/actions/connector`)
|
||||
.set('kbn-xsrf', 'foo')
|
||||
.send({
|
||||
name: 'My action',
|
||||
name: 'My Connector',
|
||||
connector_type_id: connectorTypeId,
|
||||
config: {
|
||||
unencrypted: `This value shouldn't get encrypted`,
|
||||
|
@ -200,13 +200,13 @@ export default function ({ getService }: FtrProviderContext) {
|
|||
},
|
||||
})
|
||||
.expect(200);
|
||||
objectRemover.add(space.id, createdAction.id, 'action', 'actions');
|
||||
objectRemover.add(space.id, createdConnector.id, 'connector', 'actions');
|
||||
|
||||
await supertest
|
||||
.put(`${getUrlPrefix(space.id)}/api/actions/connector/${createdAction.id}`)
|
||||
.put(`${getUrlPrefix(space.id)}/api/actions/connector/${createdConnector.id}`)
|
||||
.set('kbn-xsrf', 'foo')
|
||||
.send({
|
||||
name: 'My action updated',
|
||||
name: 'My Connector updated',
|
||||
config: {
|
||||
unencrypted: `This value shouldn't get encrypted`,
|
||||
},
|
||||
|
@ -218,7 +218,7 @@ export default function ({ getService }: FtrProviderContext) {
|
|||
|
||||
const reference = `actions-execute-2:${user.username}`;
|
||||
const response = await supertestWithoutAuth
|
||||
.post(`${getUrlPrefix(space.id)}/api/actions/connector/${createdAction.id}/_execute`)
|
||||
.post(`${getUrlPrefix(space.id)}/api/actions/connector/${createdConnector.id}/_execute`)
|
||||
.auth(user.username, user.password)
|
||||
.set('kbn-xsrf', 'foo')
|
||||
.send({
|
||||
|
@ -275,7 +275,7 @@ export default function ({ getService }: FtrProviderContext) {
|
|||
}
|
||||
});
|
||||
|
||||
it(`should handle execute request appropriately when action doesn't exist`, async () => {
|
||||
it(`should handle execute request appropriately when connector doesn't exist`, async () => {
|
||||
const response = await supertestWithoutAuth
|
||||
.post(`${getUrlPrefix(space.id)}/api/actions/connector/1/_execute`)
|
||||
.auth(user.username, user.password)
|
||||
|
@ -343,11 +343,11 @@ export default function ({ getService }: FtrProviderContext) {
|
|||
|
||||
it('should handle execute request appropriately after changing config properties', async () => {
|
||||
const connectorTypeId = '.email';
|
||||
const { body: createdAction } = await supertest
|
||||
const { body: createdConnector } = await supertest
|
||||
.post(`${getUrlPrefix(space.id)}/api/actions/connector`)
|
||||
.set('kbn-xsrf', 'foo')
|
||||
.send({
|
||||
name: 'test email action',
|
||||
name: 'test email connector',
|
||||
connector_type_id: connectorTypeId,
|
||||
config: {
|
||||
from: 'email-from-1@example.com',
|
||||
|
@ -362,13 +362,13 @@ export default function ({ getService }: FtrProviderContext) {
|
|||
},
|
||||
})
|
||||
.expect(200);
|
||||
objectRemover.add(space.id, createdAction.id, 'action', 'actions');
|
||||
objectRemover.add(space.id, createdConnector.id, 'connector', 'actions');
|
||||
|
||||
await supertest
|
||||
.put(`${getUrlPrefix(space.id)}/api/actions/connector/${createdAction.id}`)
|
||||
.put(`${getUrlPrefix(space.id)}/api/actions/connector/${createdConnector.id}`)
|
||||
.set('kbn-xsrf', 'foo')
|
||||
.send({
|
||||
name: 'a test email action 2',
|
||||
name: 'a test email connector 2',
|
||||
config: {
|
||||
from: 'email-from-2@example.com',
|
||||
service: '__json',
|
||||
|
@ -381,7 +381,7 @@ export default function ({ getService }: FtrProviderContext) {
|
|||
.expect(200);
|
||||
|
||||
const response = await supertestWithoutAuth
|
||||
.post(`${getUrlPrefix(space.id)}/api/actions/connector/${createdAction.id}/_execute`)
|
||||
.post(`${getUrlPrefix(space.id)}/api/actions/connector/${createdConnector.id}/_execute`)
|
||||
.auth(user.username, user.password)
|
||||
.set('kbn-xsrf', 'foo')
|
||||
.send({
|
||||
|
@ -420,18 +420,18 @@ export default function ({ getService }: FtrProviderContext) {
|
|||
let searchResult: any;
|
||||
const reference = `actions-execute-3:${user.username}`;
|
||||
const connectorTypeId = 'test.authorization';
|
||||
const { body: createdAction } = await supertest
|
||||
const { body: createdConnector } = await supertest
|
||||
.post(`${getUrlPrefix(space.id)}/api/actions/connector`)
|
||||
.set('kbn-xsrf', 'foo')
|
||||
.send({
|
||||
name: 'My action',
|
||||
name: 'My Connector',
|
||||
connector_type_id: connectorTypeId,
|
||||
})
|
||||
.expect(200);
|
||||
objectRemover.add(space.id, createdAction.id, 'action', 'actions');
|
||||
objectRemover.add(space.id, createdConnector.id, 'connector', 'actions');
|
||||
|
||||
const response = await supertestWithoutAuth
|
||||
.post(`${getUrlPrefix(space.id)}/api/actions/connector/${createdAction.id}/_execute`)
|
||||
.post(`${getUrlPrefix(space.id)}/api/actions/connector/${createdConnector.id}/_execute`)
|
||||
.auth(user.username, user.password)
|
||||
.set('kbn-xsrf', 'foo')
|
||||
.send({
|
||||
|
@ -528,9 +528,9 @@ export default function ({ getService }: FtrProviderContext) {
|
|||
switch (scenario.id) {
|
||||
/**
|
||||
* The users in these scenarios may have access
|
||||
* to Actions but do not have access to
|
||||
* to connectors but do not have access to
|
||||
* the system action. They should not be able to
|
||||
* to execute even if they have access to Actions.
|
||||
* to execute even if they have access to connectors.
|
||||
*/
|
||||
case 'no_kibana_privileges at space1':
|
||||
case 'space_1_all_alerts_none_actions at space1':
|
||||
|
@ -547,7 +547,7 @@ export default function ({ getService }: FtrProviderContext) {
|
|||
break;
|
||||
/**
|
||||
* The users in these scenarios have access
|
||||
* to Actions and to the system action. They should be able to
|
||||
* to connectors and to the system action. They should be able to
|
||||
* execute.
|
||||
*/
|
||||
case 'superuser at space1':
|
||||
|
|
|
@ -11,7 +11,7 @@ import { getUrlPrefix, ObjectRemover } from '../../../../common/lib';
|
|||
import { FtrProviderContext } from '../../../../common/ftr_provider_context';
|
||||
|
||||
// eslint-disable-next-line import/no-default-export
|
||||
export default function getActionTests({ getService }: FtrProviderContext) {
|
||||
export default function getConnectorTests({ getService }: FtrProviderContext) {
|
||||
const supertest = getService('supertest');
|
||||
const supertestWithoutAuth = getService('supertestWithoutAuth');
|
||||
|
||||
|
@ -23,12 +23,12 @@ export default function getActionTests({ getService }: FtrProviderContext) {
|
|||
for (const scenario of UserAtSpaceScenarios) {
|
||||
const { user, space } = scenario;
|
||||
describe(scenario.id, () => {
|
||||
it('should handle get action request appropriately', async () => {
|
||||
const { body: createdAction } = await supertest
|
||||
it('should handle get connector request appropriately', async () => {
|
||||
const { body: createdConnector } = await supertest
|
||||
.post(`${getUrlPrefix(space.id)}/api/actions/connector`)
|
||||
.set('kbn-xsrf', 'foo')
|
||||
.send({
|
||||
name: 'My action',
|
||||
name: 'My Connector',
|
||||
connector_type_id: 'test.index-record',
|
||||
config: {
|
||||
unencrypted: `This value shouldn't get encrypted`,
|
||||
|
@ -38,10 +38,10 @@ export default function getActionTests({ getService }: FtrProviderContext) {
|
|||
},
|
||||
})
|
||||
.expect(200);
|
||||
objectRemover.add(space.id, createdAction.id, 'action', 'actions');
|
||||
objectRemover.add(space.id, createdConnector.id, 'connector', 'actions');
|
||||
|
||||
const response = await supertestWithoutAuth
|
||||
.get(`${getUrlPrefix(space.id)}/api/actions/connector/${createdAction.id}`)
|
||||
.get(`${getUrlPrefix(space.id)}/api/actions/connector/${createdConnector.id}`)
|
||||
.auth(user.username, user.password);
|
||||
|
||||
switch (scenario.id) {
|
||||
|
@ -61,13 +61,13 @@ export default function getActionTests({ getService }: FtrProviderContext) {
|
|||
case 'space_1_all_with_restricted_fixture at space1':
|
||||
expect(response.statusCode).to.eql(200);
|
||||
expect(response.body).to.eql({
|
||||
id: createdAction.id,
|
||||
id: createdConnector.id,
|
||||
is_preconfigured: false,
|
||||
is_system_action: false,
|
||||
connector_type_id: 'test.index-record',
|
||||
is_deprecated: false,
|
||||
is_missing_secrets: false,
|
||||
name: 'My action',
|
||||
name: 'My Connector',
|
||||
config: {
|
||||
unencrypted: `This value shouldn't get encrypted`,
|
||||
},
|
||||
|
@ -78,12 +78,12 @@ export default function getActionTests({ getService }: FtrProviderContext) {
|
|||
}
|
||||
});
|
||||
|
||||
it(`action shouldn't be acessible from another space`, async () => {
|
||||
const { body: createdAction } = await supertest
|
||||
it(`connector shouldn't be acessible from another space`, async () => {
|
||||
const { body: createdConnector } = await supertest
|
||||
.post(`${getUrlPrefix(space.id)}/api/actions/connector`)
|
||||
.set('kbn-xsrf', 'foo')
|
||||
.send({
|
||||
name: 'My action',
|
||||
name: 'My Connector',
|
||||
connector_type_id: 'test.index-record',
|
||||
config: {
|
||||
unencrypted: `This value shouldn't get encrypted`,
|
||||
|
@ -93,10 +93,10 @@ export default function getActionTests({ getService }: FtrProviderContext) {
|
|||
},
|
||||
})
|
||||
.expect(200);
|
||||
objectRemover.add(space.id, createdAction.id, 'action', 'actions');
|
||||
objectRemover.add(space.id, createdConnector.id, 'connector', 'actions');
|
||||
|
||||
const response = await supertestWithoutAuth
|
||||
.get(`${getUrlPrefix('other')}/api/actions/connector/${createdAction.id}`)
|
||||
.get(`${getUrlPrefix('other')}/api/actions/connector/${createdConnector.id}`)
|
||||
.auth(user.username, user.password);
|
||||
|
||||
switch (scenario.id) {
|
||||
|
@ -118,7 +118,7 @@ export default function getActionTests({ getService }: FtrProviderContext) {
|
|||
expect(response.body).to.eql({
|
||||
statusCode: 404,
|
||||
error: 'Not Found',
|
||||
message: `Saved object [action/${createdAction.id}] not found`,
|
||||
message: `Saved object [action/${createdConnector.id}] not found`,
|
||||
});
|
||||
break;
|
||||
default:
|
||||
|
@ -126,7 +126,7 @@ export default function getActionTests({ getService }: FtrProviderContext) {
|
|||
}
|
||||
});
|
||||
|
||||
it('should handle get preconfigured action request appropriately', async () => {
|
||||
it('should handle get preconfigured connector request appropriately', async () => {
|
||||
const response = await supertestWithoutAuth
|
||||
.get(`${getUrlPrefix(space.id)}/api/actions/connector/my-slack1`)
|
||||
.auth(user.username, user.password);
|
||||
|
|
|
@ -12,7 +12,7 @@ import { getUrlPrefix, getTestRuleData, ObjectRemover } from '../../../../common
|
|||
import { FtrProviderContext } from '../../../../common/ftr_provider_context';
|
||||
|
||||
// eslint-disable-next-line import/no-default-export
|
||||
export default function getAllActionTests({ getService }: FtrProviderContext) {
|
||||
export default function getAllConnectorTests({ getService }: FtrProviderContext) {
|
||||
const supertest = getService('supertest');
|
||||
const supertestWithoutAuth = getService('supertestWithoutAuth');
|
||||
|
||||
|
@ -24,12 +24,12 @@ export default function getAllActionTests({ getService }: FtrProviderContext) {
|
|||
for (const scenario of UserAtSpaceScenarios) {
|
||||
const { user, space } = scenario;
|
||||
describe(scenario.id, () => {
|
||||
it('should handle get all action request appropriately', async () => {
|
||||
const { body: createdAction } = await supertest
|
||||
it('should handle get all connector request appropriately', async () => {
|
||||
const { body: createdConnector } = await supertest
|
||||
.post(`${getUrlPrefix(space.id)}/api/actions/connector`)
|
||||
.set('kbn-xsrf', 'foo')
|
||||
.send({
|
||||
name: 'My action',
|
||||
name: 'My Connector',
|
||||
connector_type_id: 'test.index-record',
|
||||
config: {
|
||||
unencrypted: `This value shouldn't get encrypted`,
|
||||
|
@ -39,7 +39,7 @@ export default function getAllActionTests({ getService }: FtrProviderContext) {
|
|||
},
|
||||
})
|
||||
.expect(200);
|
||||
objectRemover.add(space.id, createdAction.id, 'action', 'actions');
|
||||
objectRemover.add(space.id, createdConnector.id, 'connector', 'actions');
|
||||
|
||||
const response = await supertestWithoutAuth
|
||||
.get(`${getUrlPrefix(space.id)}/api/actions/connectors`)
|
||||
|
@ -69,11 +69,11 @@ export default function getAllActionTests({ getService }: FtrProviderContext) {
|
|||
);
|
||||
expect(nonCustomSslConnectors).to.eql([
|
||||
{
|
||||
id: createdAction.id,
|
||||
id: createdConnector.id,
|
||||
is_preconfigured: false,
|
||||
is_system_action: false,
|
||||
is_deprecated: false,
|
||||
name: 'My action',
|
||||
name: 'My Connector',
|
||||
connector_type_id: 'test.index-record',
|
||||
is_missing_secrets: false,
|
||||
config: {
|
||||
|
@ -161,11 +161,11 @@ export default function getAllActionTests({ getService }: FtrProviderContext) {
|
|||
});
|
||||
|
||||
it('should handle get all request appropriately with proper referenced_by_count', async () => {
|
||||
const { body: createdAction } = await supertest
|
||||
const { body: createdConnector } = await supertest
|
||||
.post(`${getUrlPrefix(space.id)}/api/actions/connector`)
|
||||
.set('kbn-xsrf', 'foo')
|
||||
.send({
|
||||
name: 'My action',
|
||||
name: 'My Connector',
|
||||
connector_type_id: 'test.index-record',
|
||||
config: {
|
||||
unencrypted: `This value shouldn't get encrypted`,
|
||||
|
@ -175,7 +175,7 @@ export default function getAllActionTests({ getService }: FtrProviderContext) {
|
|||
},
|
||||
})
|
||||
.expect(200);
|
||||
objectRemover.add(space.id, createdAction.id, 'action', 'actions');
|
||||
objectRemover.add(space.id, createdConnector.id, 'connector', 'actions');
|
||||
|
||||
const { body: createdAlert } = await supertest
|
||||
.post(`${getUrlPrefix(space.id)}/api/alerting/rule`)
|
||||
|
@ -185,7 +185,7 @@ export default function getAllActionTests({ getService }: FtrProviderContext) {
|
|||
actions: [
|
||||
{
|
||||
group: 'default',
|
||||
id: createdAction.id,
|
||||
id: createdConnector.id,
|
||||
params: {},
|
||||
},
|
||||
{
|
||||
|
@ -229,11 +229,11 @@ export default function getAllActionTests({ getService }: FtrProviderContext) {
|
|||
);
|
||||
expect(nonCustomSslConnectors).to.eql([
|
||||
{
|
||||
id: createdAction.id,
|
||||
id: createdConnector.id,
|
||||
is_preconfigured: false,
|
||||
is_system_action: false,
|
||||
is_deprecated: false,
|
||||
name: 'My action',
|
||||
name: 'My Connector',
|
||||
connector_type_id: 'test.index-record',
|
||||
is_missing_secrets: false,
|
||||
config: {
|
||||
|
@ -320,12 +320,12 @@ export default function getAllActionTests({ getService }: FtrProviderContext) {
|
|||
}
|
||||
});
|
||||
|
||||
it(`shouldn't get actions from another space`, async () => {
|
||||
const { body: createdAction } = await supertest
|
||||
it(`shouldn't get connectors from another space`, async () => {
|
||||
const { body: createdConnector } = await supertest
|
||||
.post(`${getUrlPrefix(space.id)}/api/actions/connector`)
|
||||
.set('kbn-xsrf', 'foo')
|
||||
.send({
|
||||
name: 'My action',
|
||||
name: 'My Connector',
|
||||
connector_type_id: 'test.index-record',
|
||||
config: {
|
||||
unencrypted: `This value shouldn't get encrypted`,
|
||||
|
@ -335,7 +335,7 @@ export default function getAllActionTests({ getService }: FtrProviderContext) {
|
|||
},
|
||||
})
|
||||
.expect(200);
|
||||
objectRemover.add(space.id, createdAction.id, 'action', 'actions');
|
||||
objectRemover.add(space.id, createdConnector.id, 'connector', 'actions');
|
||||
|
||||
const response = await supertestWithoutAuth
|
||||
.get(`${getUrlPrefix('other')}/api/actions/connectors`)
|
||||
|
|
|
@ -12,7 +12,7 @@ import { getUrlPrefix, getTestRuleData, ObjectRemover } from '../../../../common
|
|||
import { FtrProviderContext } from '../../../../common/ftr_provider_context';
|
||||
|
||||
// eslint-disable-next-line import/no-default-export
|
||||
export default function getAllActionTests({ getService }: FtrProviderContext) {
|
||||
export default function getAllConnectorTests({ getService }: FtrProviderContext) {
|
||||
const supertest = getService('supertest');
|
||||
const supertestWithoutAuth = getService('supertestWithoutAuth');
|
||||
|
||||
|
@ -24,12 +24,12 @@ export default function getAllActionTests({ getService }: FtrProviderContext) {
|
|||
for (const scenario of UserAtSpaceScenarios) {
|
||||
const { user, space } = scenario;
|
||||
describe(scenario.id, () => {
|
||||
it('should handle get all action request appropriately', async () => {
|
||||
const { body: createdAction } = await supertest
|
||||
it('should handle get all connector request appropriately', async () => {
|
||||
const { body: createdConnector } = await supertest
|
||||
.post(`${getUrlPrefix(space.id)}/api/actions/connector`)
|
||||
.set('kbn-xsrf', 'foo')
|
||||
.send({
|
||||
name: 'My action',
|
||||
name: 'My Connector',
|
||||
connector_type_id: 'test.index-record',
|
||||
config: {
|
||||
unencrypted: `This value shouldn't get encrypted`,
|
||||
|
@ -39,7 +39,7 @@ export default function getAllActionTests({ getService }: FtrProviderContext) {
|
|||
},
|
||||
})
|
||||
.expect(200);
|
||||
objectRemover.add(space.id, createdAction.id, 'action', 'actions');
|
||||
objectRemover.add(space.id, createdConnector.id, 'connector', 'actions');
|
||||
|
||||
const response = await supertestWithoutAuth
|
||||
.get(`${getUrlPrefix(space.id)}/internal/actions/connectors`)
|
||||
|
@ -78,11 +78,11 @@ export default function getAllActionTests({ getService }: FtrProviderContext) {
|
|||
referenced_by_count: 0,
|
||||
},
|
||||
{
|
||||
id: createdAction.id,
|
||||
id: createdConnector.id,
|
||||
is_preconfigured: false,
|
||||
is_system_action: false,
|
||||
is_deprecated: false,
|
||||
name: 'My action',
|
||||
name: 'My Connector',
|
||||
connector_type_id: 'test.index-record',
|
||||
is_missing_secrets: false,
|
||||
config: {
|
||||
|
@ -206,11 +206,11 @@ export default function getAllActionTests({ getService }: FtrProviderContext) {
|
|||
});
|
||||
|
||||
it('should handle get all request appropriately with proper referenced_by_count', async () => {
|
||||
const { body: createdAction } = await supertest
|
||||
const { body: createdConnector } = await supertest
|
||||
.post(`${getUrlPrefix(space.id)}/api/actions/connector`)
|
||||
.set('kbn-xsrf', 'foo')
|
||||
.send({
|
||||
name: 'My action',
|
||||
name: 'My Connector',
|
||||
connector_type_id: 'test.index-record',
|
||||
config: {
|
||||
unencrypted: `This value shouldn't get encrypted`,
|
||||
|
@ -220,7 +220,7 @@ export default function getAllActionTests({ getService }: FtrProviderContext) {
|
|||
},
|
||||
})
|
||||
.expect(200);
|
||||
objectRemover.add(space.id, createdAction.id, 'action', 'actions');
|
||||
objectRemover.add(space.id, createdConnector.id, 'connector', 'actions');
|
||||
|
||||
const { body: createdAlert } = await supertest
|
||||
.post(`${getUrlPrefix(space.id)}/api/alerting/rule`)
|
||||
|
@ -230,7 +230,7 @@ export default function getAllActionTests({ getService }: FtrProviderContext) {
|
|||
actions: [
|
||||
{
|
||||
group: 'default',
|
||||
id: createdAction.id,
|
||||
id: createdConnector.id,
|
||||
params: {},
|
||||
},
|
||||
{
|
||||
|
@ -283,11 +283,11 @@ export default function getAllActionTests({ getService }: FtrProviderContext) {
|
|||
referenced_by_count: 0,
|
||||
},
|
||||
{
|
||||
id: createdAction.id,
|
||||
id: createdConnector.id,
|
||||
is_preconfigured: false,
|
||||
is_system_action: false,
|
||||
is_deprecated: false,
|
||||
name: 'My action',
|
||||
name: 'My Connector',
|
||||
connector_type_id: 'test.index-record',
|
||||
is_missing_secrets: false,
|
||||
config: {
|
||||
|
@ -411,12 +411,12 @@ export default function getAllActionTests({ getService }: FtrProviderContext) {
|
|||
}
|
||||
});
|
||||
|
||||
it(`shouldn't get actions from another space`, async () => {
|
||||
const { body: createdAction } = await supertest
|
||||
it(`shouldn't get connectors from another space`, async () => {
|
||||
const { body: createdConnector } = await supertest
|
||||
.post(`${getUrlPrefix(space.id)}/api/actions/connector`)
|
||||
.set('kbn-xsrf', 'foo')
|
||||
.send({
|
||||
name: 'My action',
|
||||
name: 'My Connector',
|
||||
connector_type_id: 'test.index-record',
|
||||
config: {
|
||||
unencrypted: `This value shouldn't get encrypted`,
|
||||
|
@ -426,7 +426,7 @@ export default function getAllActionTests({ getService }: FtrProviderContext) {
|
|||
},
|
||||
})
|
||||
.expect(200);
|
||||
objectRemover.add(space.id, createdAction.id, 'action', 'actions');
|
||||
objectRemover.add(space.id, createdConnector.id, 'connector', 'actions');
|
||||
|
||||
const response = await supertestWithoutAuth
|
||||
.get(`${getUrlPrefix('other')}/internal/actions/connectors`)
|
||||
|
@ -590,12 +590,12 @@ export default function getAllActionTests({ getService }: FtrProviderContext) {
|
|||
it('calculates the references correctly', async () => {
|
||||
const { user, space } = SuperuserAtSpace1;
|
||||
|
||||
const { body: createdAction } = await supertest
|
||||
const { body: thisCreatedConnector } = await supertest
|
||||
.post(`${getUrlPrefix(space.id)}/api/actions/connector`)
|
||||
.set('kbn-xsrf', 'foo')
|
||||
.auth(user.username, user.password)
|
||||
.send({
|
||||
name: 'My action',
|
||||
name: 'My Connector',
|
||||
connector_type_id: 'test.index-record',
|
||||
config: {
|
||||
unencrypted: `This value shouldn't get encrypted`,
|
||||
|
@ -606,7 +606,7 @@ export default function getAllActionTests({ getService }: FtrProviderContext) {
|
|||
})
|
||||
.expect(200);
|
||||
|
||||
objectRemover.add(space.id, createdAction.id, 'action', 'actions');
|
||||
objectRemover.add(space.id, thisCreatedConnector.id, 'connector', 'actions');
|
||||
|
||||
const ruleRes = await supertest
|
||||
.post(`${getUrlPrefix(space.id)}/api/alerting/rule`)
|
||||
|
@ -616,7 +616,7 @@ export default function getAllActionTests({ getService }: FtrProviderContext) {
|
|||
actions: [
|
||||
systemAction,
|
||||
{
|
||||
id: createdAction.id,
|
||||
id: thisCreatedConnector.id,
|
||||
group: 'default',
|
||||
params: {},
|
||||
},
|
||||
|
@ -634,7 +634,9 @@ export default function getAllActionTests({ getService }: FtrProviderContext) {
|
|||
|
||||
const connectors = response.body as Array<{ id: string; referenced_by_count: number }>;
|
||||
|
||||
const createdConnector = connectors.find((connector) => connector.id === createdAction.id);
|
||||
const createdConnector = connectors.find(
|
||||
(connector) => connector.id === thisCreatedConnector.id
|
||||
);
|
||||
const systemConnector = connectors.find((connector) => connector.id === systemAction.id);
|
||||
|
||||
expect(createdConnector?.referenced_by_count).to.be(1);
|
||||
|
|
|
@ -89,7 +89,7 @@ export default function createActionTests({ getService }: FtrProviderContext) {
|
|||
describe('Create', () => {
|
||||
it('creates the sub action connector correctly', async () => {
|
||||
const res = await createSubActionConnector({ supertest });
|
||||
objectRemover.add('default', res.body.id, 'action', 'actions');
|
||||
objectRemover.add('default', res.body.id, 'connector', 'actions');
|
||||
|
||||
expect(res.body).to.eql({
|
||||
id: res.body.id,
|
||||
|
@ -140,7 +140,7 @@ export default function createActionTests({ getService }: FtrProviderContext) {
|
|||
describe('Sub actions', () => {
|
||||
it('executes a sub action with parameters correctly', async () => {
|
||||
const res = await createSubActionConnector({ supertest });
|
||||
objectRemover.add('default', res.body.id, 'action', 'actions');
|
||||
objectRemover.add('default', res.body.id, 'connector', 'actions');
|
||||
|
||||
const connectorId = res.body.id as string;
|
||||
const subActionParams = { id: 'test-id' };
|
||||
|
@ -180,7 +180,7 @@ export default function createActionTests({ getService }: FtrProviderContext) {
|
|||
|
||||
it('validates the subParams correctly', async () => {
|
||||
const res = await createSubActionConnector({ supertest });
|
||||
objectRemover.add('default', res.body.id, 'action', 'actions');
|
||||
objectRemover.add('default', res.body.id, 'connector', 'actions');
|
||||
|
||||
const execRes = await executeSubAction({
|
||||
supertest,
|
||||
|
@ -202,7 +202,7 @@ export default function createActionTests({ getService }: FtrProviderContext) {
|
|||
|
||||
it('validates correctly if the subActionParams is not an object', async () => {
|
||||
const res = await createSubActionConnector({ supertest });
|
||||
objectRemover.add('default', res.body.id, 'action', 'actions');
|
||||
objectRemover.add('default', res.body.id, 'connector', 'actions');
|
||||
|
||||
for (const subActionParams of ['foo', 1, true, null, ['bar']]) {
|
||||
const execRes = await executeSubAction({
|
||||
|
@ -225,7 +225,7 @@ export default function createActionTests({ getService }: FtrProviderContext) {
|
|||
|
||||
it('should execute correctly without schema validation', async () => {
|
||||
const res = await createSubActionConnector({ supertest });
|
||||
objectRemover.add('default', res.body.id, 'action', 'actions');
|
||||
objectRemover.add('default', res.body.id, 'connector', 'actions');
|
||||
|
||||
const execRes = await executeSubAction({
|
||||
supertest,
|
||||
|
@ -243,7 +243,7 @@ export default function createActionTests({ getService }: FtrProviderContext) {
|
|||
|
||||
it('should return an empty object if the func returns undefined', async () => {
|
||||
const res = await createSubActionConnector({ supertest });
|
||||
objectRemover.add('default', res.body.id, 'action', 'actions');
|
||||
objectRemover.add('default', res.body.id, 'connector', 'actions');
|
||||
|
||||
const execRes = await executeSubAction({
|
||||
supertest,
|
||||
|
@ -261,7 +261,7 @@ export default function createActionTests({ getService }: FtrProviderContext) {
|
|||
|
||||
it('should return an error if sub action is not registered', async () => {
|
||||
const res = await createSubActionConnector({ supertest });
|
||||
objectRemover.add('default', res.body.id, 'action', 'actions');
|
||||
objectRemover.add('default', res.body.id, 'connector', 'actions');
|
||||
|
||||
const execRes = await executeSubAction({
|
||||
supertest,
|
||||
|
@ -282,7 +282,7 @@ export default function createActionTests({ getService }: FtrProviderContext) {
|
|||
|
||||
it('should return an error if the registered method is not a function', async () => {
|
||||
const res = await createSubActionConnector({ supertest });
|
||||
objectRemover.add('default', res.body.id, 'action', 'actions');
|
||||
objectRemover.add('default', res.body.id, 'connector', 'actions');
|
||||
|
||||
const execRes = await executeSubAction({
|
||||
supertest,
|
||||
|
@ -303,7 +303,7 @@ export default function createActionTests({ getService }: FtrProviderContext) {
|
|||
|
||||
it('should return an error if the registered method does not exists', async () => {
|
||||
const res = await createSubActionConnector({ supertest });
|
||||
objectRemover.add('default', res.body.id, 'action', 'actions');
|
||||
objectRemover.add('default', res.body.id, 'connector', 'actions');
|
||||
|
||||
const execRes = await executeSubAction({
|
||||
supertest,
|
||||
|
@ -327,7 +327,7 @@ export default function createActionTests({ getService }: FtrProviderContext) {
|
|||
supertest,
|
||||
connectorTypeId: 'test.sub-action-connector-without-sub-actions',
|
||||
});
|
||||
objectRemover.add('default', res.body.id, 'action', 'actions');
|
||||
objectRemover.add('default', res.body.id, 'connector', 'actions');
|
||||
|
||||
const execRes = await executeSubAction({
|
||||
supertest,
|
||||
|
|
|
@ -14,7 +14,7 @@ import { checkAAD, getUrlPrefix, ObjectRemover } from '../../../../common/lib';
|
|||
import { FtrProviderContext } from '../../../../common/ftr_provider_context';
|
||||
|
||||
// eslint-disable-next-line import/no-default-export
|
||||
export default function updateActionTests({ getService }: FtrProviderContext) {
|
||||
export default function updateConnectorTests({ getService }: FtrProviderContext) {
|
||||
const supertest = getService('supertest');
|
||||
const supertestWithoutAuth = getService('supertestWithoutAuth');
|
||||
const es = getService('es');
|
||||
|
@ -36,12 +36,12 @@ export default function updateActionTests({ getService }: FtrProviderContext) {
|
|||
for (const scenario of UserAtSpaceScenarios) {
|
||||
const { user, space } = scenario;
|
||||
describe(scenario.id, () => {
|
||||
it('should handle update action request appropriately', async () => {
|
||||
const { body: createdAction } = await supertest
|
||||
it('should handle update connector request appropriately', async () => {
|
||||
const { body: createdConnector } = await supertest
|
||||
.post(`${getUrlPrefix(space.id)}/api/actions/connector`)
|
||||
.set('kbn-xsrf', 'foo')
|
||||
.send({
|
||||
name: 'My action',
|
||||
name: 'My Connector',
|
||||
connector_type_id: 'test.index-record',
|
||||
config: {
|
||||
unencrypted: `This value shouldn't get encrypted`,
|
||||
|
@ -51,14 +51,14 @@ export default function updateActionTests({ getService }: FtrProviderContext) {
|
|||
},
|
||||
})
|
||||
.expect(200);
|
||||
objectRemover.add(space.id, createdAction.id, 'action', 'actions');
|
||||
objectRemover.add(space.id, createdConnector.id, 'connector', 'actions');
|
||||
|
||||
const response = await supertestWithoutAuth
|
||||
.put(`${getUrlPrefix(space.id)}/api/actions/connector/${createdAction.id}`)
|
||||
.put(`${getUrlPrefix(space.id)}/api/actions/connector/${createdConnector.id}`)
|
||||
.auth(user.username, user.password)
|
||||
.set('kbn-xsrf', 'foo')
|
||||
.send({
|
||||
name: 'My action updated',
|
||||
name: 'My Connector updated',
|
||||
config: {
|
||||
unencrypted: `This value shouldn't get encrypted`,
|
||||
},
|
||||
|
@ -84,13 +84,13 @@ export default function updateActionTests({ getService }: FtrProviderContext) {
|
|||
case 'space_1_all_with_restricted_fixture at space1':
|
||||
expect(response.statusCode).to.eql(200);
|
||||
expect(response.body).to.eql({
|
||||
id: createdAction.id,
|
||||
id: createdConnector.id,
|
||||
is_preconfigured: false,
|
||||
is_system_action: false,
|
||||
is_deprecated: false,
|
||||
connector_type_id: 'test.index-record',
|
||||
is_missing_secrets: false,
|
||||
name: 'My action updated',
|
||||
name: 'My Connector updated',
|
||||
config: {
|
||||
unencrypted: `This value shouldn't get encrypted`,
|
||||
},
|
||||
|
@ -100,7 +100,7 @@ export default function updateActionTests({ getService }: FtrProviderContext) {
|
|||
supertest,
|
||||
spaceId: space.id,
|
||||
type: 'action',
|
||||
id: createdAction.id,
|
||||
id: createdConnector.id,
|
||||
});
|
||||
break;
|
||||
default:
|
||||
|
@ -108,12 +108,12 @@ export default function updateActionTests({ getService }: FtrProviderContext) {
|
|||
}
|
||||
});
|
||||
|
||||
it(`shouldn't update action from another space`, async () => {
|
||||
const { body: createdAction } = await supertest
|
||||
it(`shouldn't update connector from another space`, async () => {
|
||||
const { body: createdConnector } = await supertest
|
||||
.post(`${getUrlPrefix(space.id)}/api/actions/connector`)
|
||||
.set('kbn-xsrf', 'foo')
|
||||
.send({
|
||||
name: 'My action',
|
||||
name: 'My Connector',
|
||||
connector_type_id: 'test.index-record',
|
||||
config: {
|
||||
unencrypted: `This value shouldn't get encrypted`,
|
||||
|
@ -123,14 +123,14 @@ export default function updateActionTests({ getService }: FtrProviderContext) {
|
|||
},
|
||||
})
|
||||
.expect(200);
|
||||
objectRemover.add(space.id, createdAction.id, 'action', 'actions');
|
||||
objectRemover.add(space.id, createdConnector.id, 'connector', 'actions');
|
||||
|
||||
const response = await supertestWithoutAuth
|
||||
.put(`${getUrlPrefix('other')}/api/actions/connector/${createdAction.id}`)
|
||||
.put(`${getUrlPrefix('other')}/api/actions/connector/${createdConnector.id}`)
|
||||
.auth(user.username, user.password)
|
||||
.set('kbn-xsrf', 'foo')
|
||||
.send({
|
||||
name: 'My action updated',
|
||||
name: 'My Connector updated',
|
||||
config: {
|
||||
unencrypted: `This value shouldn't get encrypted`,
|
||||
},
|
||||
|
@ -158,7 +158,7 @@ export default function updateActionTests({ getService }: FtrProviderContext) {
|
|||
expect(response.body).to.eql({
|
||||
statusCode: 404,
|
||||
error: 'Not Found',
|
||||
message: `Saved object [action/${createdAction.id}] not found`,
|
||||
message: `Saved object [action/${createdConnector.id}] not found`,
|
||||
});
|
||||
break;
|
||||
default:
|
||||
|
@ -166,13 +166,13 @@ export default function updateActionTests({ getService }: FtrProviderContext) {
|
|||
}
|
||||
});
|
||||
|
||||
it('should handle update action request appropriately when passing a null config', async () => {
|
||||
it('should handle update connector request appropriately when passing a null config', async () => {
|
||||
const response = await supertestWithoutAuth
|
||||
.put(`${getUrlPrefix(space.id)}/api/actions/connector/1`)
|
||||
.set('kbn-xsrf', 'foo')
|
||||
.auth(user.username, user.password)
|
||||
.send({
|
||||
name: 'My action updated',
|
||||
name: 'My Connector updated',
|
||||
config: null,
|
||||
});
|
||||
|
||||
|
@ -196,13 +196,13 @@ export default function updateActionTests({ getService }: FtrProviderContext) {
|
|||
}
|
||||
});
|
||||
|
||||
it(`should handle update action request appropriately when action doesn't exist`, async () => {
|
||||
it(`should handle update connector request appropriately when connector doesn't exist`, async () => {
|
||||
const response = await supertestWithoutAuth
|
||||
.put(`${getUrlPrefix(space.id)}/api/actions/connector/1`)
|
||||
.set('kbn-xsrf', 'foo')
|
||||
.auth(user.username, user.password)
|
||||
.send({
|
||||
name: 'My action updated',
|
||||
name: 'My Connector updated',
|
||||
config: {
|
||||
unencrypted: `This value shouldn't get encrypted`,
|
||||
},
|
||||
|
@ -238,7 +238,7 @@ export default function updateActionTests({ getService }: FtrProviderContext) {
|
|||
}
|
||||
});
|
||||
|
||||
it('should handle update action request appropriately when payload is empty and invalid', async () => {
|
||||
it('should handle update connector request appropriately when payload is empty and invalid', async () => {
|
||||
const response = await supertestWithoutAuth
|
||||
.put(`${getUrlPrefix(space.id)}/api/actions/connector/1`)
|
||||
.set('kbn-xsrf', 'foo')
|
||||
|
@ -266,12 +266,12 @@ export default function updateActionTests({ getService }: FtrProviderContext) {
|
|||
}
|
||||
});
|
||||
|
||||
it('should handle update action request appropriately when secrets are not valid', async () => {
|
||||
const { body: createdAction } = await supertest
|
||||
it('should handle update connector request appropriately when secrets are not valid', async () => {
|
||||
const { body: createdConnector } = await supertest
|
||||
.post(`${getUrlPrefix(space.id)}/api/actions/connector`)
|
||||
.set('kbn-xsrf', 'foo')
|
||||
.send({
|
||||
name: 'My action',
|
||||
name: 'My Connector',
|
||||
connector_type_id: 'test.index-record',
|
||||
config: {
|
||||
unencrypted: `This value shouldn't get encrypted`,
|
||||
|
@ -281,14 +281,14 @@ export default function updateActionTests({ getService }: FtrProviderContext) {
|
|||
},
|
||||
})
|
||||
.expect(200);
|
||||
objectRemover.add(space.id, createdAction.id, 'action', 'actions');
|
||||
objectRemover.add(space.id, createdConnector.id, 'connector', 'actions');
|
||||
|
||||
const response = await supertestWithoutAuth
|
||||
.put(`${getUrlPrefix(space.id)}/api/actions/connector/${createdAction.id}`)
|
||||
.put(`${getUrlPrefix(space.id)}/api/actions/connector/${createdConnector.id}`)
|
||||
.set('kbn-xsrf', 'foo')
|
||||
.auth(user.username, user.password)
|
||||
.send({
|
||||
name: 'My action updated',
|
||||
name: 'My Connector updated',
|
||||
config: {
|
||||
unencrypted: `This value shouldn't get encrypted`,
|
||||
},
|
||||
|
@ -325,13 +325,13 @@ export default function updateActionTests({ getService }: FtrProviderContext) {
|
|||
}
|
||||
});
|
||||
|
||||
it(`shouldn't update a preconfigured action`, async () => {
|
||||
it(`shouldn't update a preconfigured connector`, async () => {
|
||||
const response = await supertestWithoutAuth
|
||||
.put(`${getUrlPrefix(space.id)}/api/actions/connector/custom-system-abc-connector`)
|
||||
.auth(user.username, user.password)
|
||||
.set('kbn-xsrf', 'foo')
|
||||
.send({
|
||||
name: 'My action updated',
|
||||
name: 'My Connector updated',
|
||||
config: {
|
||||
unencrypted: `This value shouldn't get encrypted`,
|
||||
},
|
||||
|
@ -366,13 +366,13 @@ export default function updateActionTests({ getService }: FtrProviderContext) {
|
|||
}
|
||||
});
|
||||
|
||||
it(`should handle update action request appropriately when empty strings are submitted`, async () => {
|
||||
it(`should handle update connector request appropriately when empty strings are submitted`, async () => {
|
||||
const response = await supertestWithoutAuth
|
||||
.put(`${getUrlPrefix(space.id)}/api/actions/connector/1`)
|
||||
.set('kbn-xsrf', 'foo')
|
||||
.auth(user.username, user.password)
|
||||
.send({
|
||||
name: 'My action updated',
|
||||
name: 'My Connector updated',
|
||||
config: {
|
||||
unencrypted: ' ',
|
||||
},
|
||||
|
@ -448,7 +448,7 @@ export default function updateActionTests({ getService }: FtrProviderContext) {
|
|||
const source = uuidv4();
|
||||
const encryptedValue = 'This value should be encrypted';
|
||||
|
||||
const { body: createdAction } = await supertest
|
||||
const { body: createdConnector } = await supertest
|
||||
.post(`${getUrlPrefix(space.id)}/api/actions/connector`)
|
||||
.set('kbn-xsrf', 'foo')
|
||||
.send({
|
||||
|
@ -463,14 +463,14 @@ export default function updateActionTests({ getService }: FtrProviderContext) {
|
|||
},
|
||||
})
|
||||
.expect(200);
|
||||
objectRemover.add(space.id, createdAction.id, 'action', 'actions');
|
||||
objectRemover.add(space.id, createdConnector.id, 'connector', 'actions');
|
||||
|
||||
// clear out docs from create
|
||||
await esTestIndexTool.destroy();
|
||||
await esTestIndexTool.setup();
|
||||
|
||||
const response = await supertestWithoutAuth
|
||||
.put(`${getUrlPrefix(space.id)}/api/actions/connector/${createdAction.id}`)
|
||||
.put(`${getUrlPrefix(space.id)}/api/actions/connector/${createdConnector.id}`)
|
||||
.auth(user.username, user.password)
|
||||
.set('kbn-xsrf', 'foo')
|
||||
.send({
|
||||
|
|
|
@ -54,7 +54,7 @@ export default function createGetActionErrorLogTests({ getService }: FtrProvider
|
|||
secrets: {},
|
||||
})
|
||||
.expect(200);
|
||||
objectRemover.add(space.id, createdConnector.id, 'action', 'actions');
|
||||
objectRemover.add(space.id, createdConnector.id, 'connector', 'actions');
|
||||
|
||||
const { body: createdRule } = await supertest
|
||||
.post(`${getUrlPrefix(space.id)}/api/alerting/rule`)
|
||||
|
@ -143,7 +143,7 @@ export default function createGetActionErrorLogTests({ getService }: FtrProvider
|
|||
secrets: {},
|
||||
})
|
||||
.expect(200);
|
||||
objectRemover.add(Spaces[1].id, createdConnector.id, 'action', 'actions');
|
||||
objectRemover.add(Spaces[1].id, createdConnector.id, 'connector', 'actions');
|
||||
|
||||
// Create 2 rules, and then only pull the logs for one of them
|
||||
let watchedRuleId;
|
||||
|
|
|
@ -31,11 +31,11 @@ export default function ({ getService }: FtrProviderContext) {
|
|||
});
|
||||
|
||||
it('should handle bulk_enqueue request appropriately', async () => {
|
||||
const { body: createdAction } = await supertest
|
||||
const { body: createdConnector } = await supertest
|
||||
.post(`${getUrlPrefix(Spaces.space1.id)}/api/actions/connector`)
|
||||
.set('kbn-xsrf', 'foo')
|
||||
.send({
|
||||
name: 'My action',
|
||||
name: 'My Connector',
|
||||
connector_type_id: 'test.index-record',
|
||||
config: {
|
||||
unencrypted: `This value shouldn't get encrypted`,
|
||||
|
@ -46,14 +46,14 @@ export default function ({ getService }: FtrProviderContext) {
|
|||
})
|
||||
.expect(200);
|
||||
|
||||
objectRemover.add(Spaces.space1.id, createdAction.id, 'action', 'actions');
|
||||
objectRemover.add(Spaces.space1.id, createdConnector.id, 'connector', 'actions');
|
||||
|
||||
const reference = `actions-enqueue-1:${Spaces.space1.id}:${createdAction.id}`;
|
||||
const reference = `actions-enqueue-1:${Spaces.space1.id}:${createdConnector.id}`;
|
||||
|
||||
const response = await supertest
|
||||
.post(
|
||||
`${getUrlPrefix(Spaces.space1.id)}/api/alerts_fixture/${
|
||||
createdAction.id
|
||||
createdConnector.id
|
||||
}/bulk_enqueue_actions`
|
||||
)
|
||||
.set('kbn-xsrf', 'foo')
|
||||
|
|
|
@ -11,7 +11,7 @@ import { getUrlPrefix } from '../../../common/lib/space_test_utils';
|
|||
import { FtrProviderContext } from '../../../common/ftr_provider_context';
|
||||
|
||||
// eslint-disable-next-line import/no-default-export
|
||||
export default function listActionTypesTests({ getService }: FtrProviderContext) {
|
||||
export default function listConnectorTypesTests({ getService }: FtrProviderContext) {
|
||||
const supertest = getService('supertest');
|
||||
|
||||
describe('connector_types', () => {
|
||||
|
@ -20,17 +20,17 @@ export default function listActionTypesTests({ getService }: FtrProviderContext)
|
|||
`${getUrlPrefix(Spaces.space1.id)}/api/actions/connector_types`
|
||||
);
|
||||
|
||||
function createActionTypeMatcher(id: string, name: string) {
|
||||
return (actionType: { id: string; name: string }) => {
|
||||
return actionType.id === id && actionType.name === name;
|
||||
function createConnectorTypeMatcher(id: string, name: string) {
|
||||
return (connectorType: { id: string; name: string }) => {
|
||||
return connectorType.id === id && connectorType.name === name;
|
||||
};
|
||||
}
|
||||
|
||||
expect(response.status).to.eql(200);
|
||||
// Check for values explicitly in order to avoid this test failing each time plugins register
|
||||
// a new action type
|
||||
// a new connector type
|
||||
expect(
|
||||
response.body.some(createActionTypeMatcher('test.index-record', 'Test: Index Record'))
|
||||
response.body.some(createConnectorTypeMatcher('test.index-record', 'Test: Index Record'))
|
||||
).to.be(true);
|
||||
});
|
||||
|
||||
|
@ -39,40 +39,11 @@ export default function listActionTypesTests({ getService }: FtrProviderContext)
|
|||
`${getUrlPrefix(Spaces.space1.id)}/api/actions/connector_types`
|
||||
);
|
||||
|
||||
const actionTypes = response.body as Array<{ is_system_action_type: boolean }>;
|
||||
const connectorTypes = response.body as Array<{ is_system_action_type: boolean }>;
|
||||
|
||||
expect(actionTypes.every((actionType) => !actionType.is_system_action_type)).to.be(true);
|
||||
});
|
||||
|
||||
describe('legacy', () => {
|
||||
it('should return 200 with list of action types containing defaults', async () => {
|
||||
const response = await supertest.get(
|
||||
`${getUrlPrefix(Spaces.space1.id)}/api/actions/list_action_types`
|
||||
);
|
||||
|
||||
function createActionTypeMatcher(id: string, name: string) {
|
||||
return (actionType: { id: string; name: string }) => {
|
||||
return actionType.id === id && actionType.name === name;
|
||||
};
|
||||
}
|
||||
|
||||
expect(response.status).to.eql(200);
|
||||
// Check for values explicitly in order to avoid this test failing each time plugins register
|
||||
// a new action type
|
||||
expect(
|
||||
response.body.some(createActionTypeMatcher('test.index-record', 'Test: Index Record'))
|
||||
).to.be(true);
|
||||
});
|
||||
|
||||
it('should filter out system action types', async () => {
|
||||
const response = await supertest.get(
|
||||
`${getUrlPrefix(Spaces.space1.id)}/api/actions/list_action_types`
|
||||
);
|
||||
|
||||
const actionTypes = response.body as Array<{ is_system_action_type: boolean }>;
|
||||
|
||||
expect(actionTypes.every((actionType) => !actionType.is_system_action_type)).to.be(true);
|
||||
});
|
||||
expect(connectorTypes.every((connectorType) => !connectorType.is_system_action_type)).to.be(
|
||||
true
|
||||
);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@ export default function webhookTest({ getService }: FtrProviderContext) {
|
|||
return parsedUrl.port;
|
||||
}
|
||||
|
||||
describe('webhook action', () => {
|
||||
describe('webhook connector', () => {
|
||||
describe('with http endpoint', () => {
|
||||
let webhookSimulatorURL: string = '';
|
||||
let webhookServer: http.Server;
|
||||
|
@ -47,9 +47,9 @@ export default function webhookTest({ getService }: FtrProviderContext) {
|
|||
});
|
||||
|
||||
it('webhook can be executed without username and password', async () => {
|
||||
const webhookActionId = await createWebhookAction(supertest, webhookSimulatorURL);
|
||||
const webhookConnectorId = await createWebhookConnector(supertest, webhookSimulatorURL);
|
||||
const { body: result } = await supertest
|
||||
.post(`/api/actions/action/${webhookActionId}/_execute`)
|
||||
.post(`/api/actions/connector/${webhookConnectorId}/_execute`)
|
||||
.set('kbn-xsrf', 'test')
|
||||
.send({
|
||||
params: {
|
||||
|
@ -78,11 +78,11 @@ export default function webhookTest({ getService }: FtrProviderContext) {
|
|||
});
|
||||
|
||||
it('should support the POST method against webhook target', async () => {
|
||||
const webhookActionId = await createWebhookAction(supertest, webhookSimulatorURL, {
|
||||
const webhookConnectorId = await createWebhookConnector(supertest, webhookSimulatorURL, {
|
||||
method: 'post',
|
||||
});
|
||||
const { body: result } = await supertest
|
||||
.post(`/api/actions/action/${webhookActionId}/_execute`)
|
||||
.post(`/api/actions/connector/${webhookConnectorId}/_execute`)
|
||||
.set('kbn-xsrf', 'test')
|
||||
.send({
|
||||
params: {
|
||||
|
@ -176,7 +176,7 @@ export default function webhookTest({ getService }: FtrProviderContext) {
|
|||
});
|
||||
}
|
||||
|
||||
export async function createWebhookAction(
|
||||
export async function createWebhookConnector(
|
||||
supertest: SuperTestAgent,
|
||||
webhookSimulatorURL: string,
|
||||
config: Record<string, string | Record<string, string>> = {}
|
||||
|
@ -190,16 +190,16 @@ export async function createWebhookAction(
|
|||
url,
|
||||
};
|
||||
|
||||
const { body: createdAction } = await supertest
|
||||
.post('/api/actions/action')
|
||||
const { body: createdConnector } = await supertest
|
||||
.post('/api/actions/connector')
|
||||
.set('kbn-xsrf', 'test')
|
||||
.send({
|
||||
name: 'A generic Webhook action',
|
||||
actionTypeId: '.webhook',
|
||||
name: 'A generic Webhook connector',
|
||||
connector_type_id: '.webhook',
|
||||
secrets: {},
|
||||
config: composedConfig,
|
||||
})
|
||||
.expect(200);
|
||||
|
||||
return createdAction.id;
|
||||
return createdConnector.id;
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ import { checkAAD, getUrlPrefix, ObjectRemover } from '../../../common/lib';
|
|||
import { FtrProviderContext } from '../../../common/ftr_provider_context';
|
||||
|
||||
// eslint-disable-next-line import/no-default-export
|
||||
export default function createActionTests({ getService }: FtrProviderContext) {
|
||||
export default function createConnectorTests({ getService }: FtrProviderContext) {
|
||||
const supertest = getService('supertest');
|
||||
|
||||
describe('create', () => {
|
||||
|
@ -24,7 +24,7 @@ export default function createActionTests({ getService }: FtrProviderContext) {
|
|||
.post(`${getUrlPrefix(Spaces.space1.id)}/api/actions/connector`)
|
||||
.set('kbn-xsrf', 'foo')
|
||||
.send({
|
||||
name: 'My action',
|
||||
name: 'My connector',
|
||||
connector_type_id: 'test.index-record',
|
||||
config: {
|
||||
unencrypted: `This value shouldn't get encrypted`,
|
||||
|
@ -35,12 +35,12 @@ export default function createActionTests({ getService }: FtrProviderContext) {
|
|||
});
|
||||
|
||||
expect(response.status).to.eql(200);
|
||||
objectRemover.add(Spaces.space1.id, response.body.id, 'action', 'actions');
|
||||
objectRemover.add(Spaces.space1.id, response.body.id, 'connector', 'actions');
|
||||
expect(response.body).to.eql({
|
||||
id: response.body.id,
|
||||
is_preconfigured: false,
|
||||
is_deprecated: false,
|
||||
name: 'My action',
|
||||
name: 'My connector',
|
||||
connector_type_id: 'test.index-record',
|
||||
is_missing_secrets: false,
|
||||
is_system_action: false,
|
||||
|
@ -59,12 +59,12 @@ export default function createActionTests({ getService }: FtrProviderContext) {
|
|||
});
|
||||
});
|
||||
|
||||
it('should handle create action request appropriately when empty strings are submitted', async () => {
|
||||
it('should handle create connector request appropriately when empty strings are submitted', async () => {
|
||||
await supertest
|
||||
.post(`${getUrlPrefix(Spaces.space1.id)}/api/actions/connector`)
|
||||
.set('kbn-xsrf', 'foo')
|
||||
.send({
|
||||
name: 'My action',
|
||||
name: 'My connector',
|
||||
connector_type_id: 'test.index-record',
|
||||
config: {
|
||||
unencrypted: ' ',
|
||||
|
@ -80,12 +80,12 @@ export default function createActionTests({ getService }: FtrProviderContext) {
|
|||
});
|
||||
});
|
||||
|
||||
it(`shouldn't create a preconfigured action with the same id as an existing one`, async () => {
|
||||
it(`shouldn't create a preconfigured connector with the same id as an existing one`, async () => {
|
||||
await supertest
|
||||
.post(`${getUrlPrefix(Spaces.space1.id)}/api/actions/connector/custom-system-abc-connector`)
|
||||
.set('kbn-xsrf', 'foo')
|
||||
.send({
|
||||
name: 'My action',
|
||||
name: 'My connector',
|
||||
connector_type_id: 'system-abc-action-type',
|
||||
config: {},
|
||||
secrets: {},
|
||||
|
@ -114,61 +114,19 @@ export default function createActionTests({ getService }: FtrProviderContext) {
|
|||
});
|
||||
});
|
||||
|
||||
describe('legacy', () => {
|
||||
it('should handle create action request appropriately', async () => {
|
||||
const response = await supertest
|
||||
.post(`${getUrlPrefix(Spaces.space1.id)}/api/actions/action`)
|
||||
.set('kbn-xsrf', 'foo')
|
||||
.send({
|
||||
name: 'My action',
|
||||
actionTypeId: 'test.index-record',
|
||||
config: {
|
||||
unencrypted: `This value shouldn't get encrypted`,
|
||||
},
|
||||
secrets: {
|
||||
encrypted: 'This value should be encrypted',
|
||||
},
|
||||
});
|
||||
|
||||
expect(response.status).to.eql(200);
|
||||
objectRemover.add(Spaces.space1.id, response.body.id, 'action', 'actions');
|
||||
expect(response.body).to.eql({
|
||||
id: response.body.id,
|
||||
isPreconfigured: false,
|
||||
isDeprecated: false,
|
||||
name: 'My action',
|
||||
actionTypeId: 'test.index-record',
|
||||
isMissingSecrets: false,
|
||||
isSystemAction: false,
|
||||
config: {
|
||||
unencrypted: `This value shouldn't get encrypted`,
|
||||
},
|
||||
});
|
||||
expect(typeof response.body.id).to.be('string');
|
||||
|
||||
// Ensure AAD isn't broken
|
||||
await checkAAD({
|
||||
supertest,
|
||||
spaceId: Spaces.space1.id,
|
||||
type: 'action',
|
||||
id: response.body.id,
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('should notify feature usage when creating a gold action type', async () => {
|
||||
it('should notify feature usage when creating a gold connector type', async () => {
|
||||
const testStart = new Date();
|
||||
const response = await supertest
|
||||
.post(`${getUrlPrefix(Spaces.space1.id)}/api/actions/action`)
|
||||
.post(`${getUrlPrefix(Spaces.space1.id)}/api/actions/connector`)
|
||||
.set('kbn-xsrf', 'foo')
|
||||
.send({
|
||||
name: 'Noop action type',
|
||||
actionTypeId: 'test.noop',
|
||||
name: 'Noop connector type',
|
||||
connector_type_id: 'test.noop',
|
||||
secrets: {},
|
||||
config: {},
|
||||
})
|
||||
.expect(200);
|
||||
objectRemover.add(Spaces.space1.id, response.body.id, 'action', 'actions');
|
||||
objectRemover.add(Spaces.space1.id, response.body.id, 'connector', 'actions');
|
||||
|
||||
const {
|
||||
body: { features },
|
||||
|
|
|
@ -10,7 +10,7 @@ import { getUrlPrefix, ObjectRemover } from '../../../common/lib';
|
|||
import { FtrProviderContext } from '../../../common/ftr_provider_context';
|
||||
|
||||
// eslint-disable-next-line import/no-default-export
|
||||
export default function deleteActionTests({ getService }: FtrProviderContext) {
|
||||
export default function deleteConnectorTests({ getService }: FtrProviderContext) {
|
||||
const supertest = getService('supertest');
|
||||
|
||||
describe('delete', () => {
|
||||
|
@ -18,12 +18,12 @@ export default function deleteActionTests({ getService }: FtrProviderContext) {
|
|||
|
||||
after(() => objectRemover.removeAll());
|
||||
|
||||
it('should handle delete action request appropriately', async () => {
|
||||
const { body: createdAction } = await supertest
|
||||
it('should handle delete connector request appropriately', async () => {
|
||||
const { body: createdConnector } = await supertest
|
||||
.post(`${getUrlPrefix(Spaces.space1.id)}/api/actions/connector`)
|
||||
.set('kbn-xsrf', 'foo')
|
||||
.send({
|
||||
name: 'My action',
|
||||
name: 'My connector',
|
||||
connector_type_id: 'test.index-record',
|
||||
config: {
|
||||
unencrypted: `This value shouldn't get encrypted`,
|
||||
|
@ -35,17 +35,17 @@ export default function deleteActionTests({ getService }: FtrProviderContext) {
|
|||
.expect(200);
|
||||
|
||||
await supertest
|
||||
.delete(`${getUrlPrefix(Spaces.space1.id)}/api/actions/connector/${createdAction.id}`)
|
||||
.delete(`${getUrlPrefix(Spaces.space1.id)}/api/actions/connector/${createdConnector.id}`)
|
||||
.set('kbn-xsrf', 'foo')
|
||||
.expect(204, '');
|
||||
});
|
||||
|
||||
it(`shouldn't delete action from another space`, async () => {
|
||||
const { body: createdAction } = await supertest
|
||||
it(`shouldn't delete connector from another space`, async () => {
|
||||
const { body: createdConnector } = await supertest
|
||||
.post(`${getUrlPrefix(Spaces.space1.id)}/api/actions/connector`)
|
||||
.set('kbn-xsrf', 'foo')
|
||||
.send({
|
||||
name: 'My action',
|
||||
name: 'My connector',
|
||||
connector_type_id: 'test.index-record',
|
||||
config: {
|
||||
unencrypted: `This value shouldn't get encrypted`,
|
||||
|
@ -55,19 +55,19 @@ export default function deleteActionTests({ getService }: FtrProviderContext) {
|
|||
},
|
||||
})
|
||||
.expect(200);
|
||||
objectRemover.add(Spaces.space1.id, createdAction.id, 'action', 'actions');
|
||||
objectRemover.add(Spaces.space1.id, createdConnector.id, 'connector', 'actions');
|
||||
|
||||
await supertest
|
||||
.delete(`${getUrlPrefix(Spaces.other.id)}/api/actions/connector/${createdAction.id}`)
|
||||
.delete(`${getUrlPrefix(Spaces.other.id)}/api/actions/connector/${createdConnector.id}`)
|
||||
.set('kbn-xsrf', 'foo')
|
||||
.expect(404, {
|
||||
statusCode: 404,
|
||||
error: 'Not Found',
|
||||
message: `Saved object [action/${createdAction.id}] not found`,
|
||||
message: `Saved object [action/${createdConnector.id}] not found`,
|
||||
});
|
||||
});
|
||||
|
||||
it(`should handle delete request appropriately when action doesn't exist`, async () => {
|
||||
it(`should handle delete request appropriately when connector doesn't exist`, async () => {
|
||||
await supertest
|
||||
.delete(`${getUrlPrefix(Spaces.space1.id)}/api/actions/connector/2`)
|
||||
.set('kbn-xsrf', 'foo')
|
||||
|
@ -78,7 +78,7 @@ export default function deleteActionTests({ getService }: FtrProviderContext) {
|
|||
});
|
||||
});
|
||||
|
||||
it(`shouldn't delete a preconfigured action`, async () => {
|
||||
it(`shouldn't delete a preconfigured connector`, async () => {
|
||||
await supertest
|
||||
.delete(`${getUrlPrefix(Spaces.space1.id)}/api/actions/connector/my-slack1`)
|
||||
.set('kbn-xsrf', 'foo')
|
||||
|
@ -103,93 +103,5 @@ export default function deleteActionTests({ getService }: FtrProviderContext) {
|
|||
message: 'System action system-connector-test.system-action is not allowed to delete.',
|
||||
});
|
||||
});
|
||||
|
||||
describe('legacy', () => {
|
||||
it('should handle delete action request appropriately', async () => {
|
||||
const { body: createdAction } = await supertest
|
||||
.post(`${getUrlPrefix(Spaces.space1.id)}/api/actions/action`)
|
||||
.set('kbn-xsrf', 'foo')
|
||||
.send({
|
||||
name: 'My action',
|
||||
actionTypeId: 'test.index-record',
|
||||
config: {
|
||||
unencrypted: `This value shouldn't get encrypted`,
|
||||
},
|
||||
secrets: {
|
||||
encrypted: 'This value should be encrypted',
|
||||
},
|
||||
})
|
||||
.expect(200);
|
||||
|
||||
await supertest
|
||||
.delete(`${getUrlPrefix(Spaces.space1.id)}/api/actions/action/${createdAction.id}`)
|
||||
.set('kbn-xsrf', 'foo')
|
||||
.expect(204, '');
|
||||
});
|
||||
|
||||
it(`shouldn't delete action from another space`, async () => {
|
||||
const { body: createdAction } = await supertest
|
||||
.post(`${getUrlPrefix(Spaces.space1.id)}/api/actions/action`)
|
||||
.set('kbn-xsrf', 'foo')
|
||||
.send({
|
||||
name: 'My action',
|
||||
actionTypeId: 'test.index-record',
|
||||
config: {
|
||||
unencrypted: `This value shouldn't get encrypted`,
|
||||
},
|
||||
secrets: {
|
||||
encrypted: 'This value should be encrypted',
|
||||
},
|
||||
})
|
||||
.expect(200);
|
||||
objectRemover.add(Spaces.space1.id, createdAction.id, 'action', 'actions');
|
||||
|
||||
await supertest
|
||||
.delete(`${getUrlPrefix(Spaces.other.id)}/api/actions/action/${createdAction.id}`)
|
||||
.set('kbn-xsrf', 'foo')
|
||||
.expect(404, {
|
||||
statusCode: 404,
|
||||
error: 'Not Found',
|
||||
message: `Saved object [action/${createdAction.id}] not found`,
|
||||
});
|
||||
});
|
||||
|
||||
it(`should handle delete request appropriately when action doesn't exist`, async () => {
|
||||
await supertest
|
||||
.delete(`${getUrlPrefix(Spaces.space1.id)}/api/actions/action/2`)
|
||||
.set('kbn-xsrf', 'foo')
|
||||
.expect(404, {
|
||||
statusCode: 404,
|
||||
error: 'Not Found',
|
||||
message: 'Saved object [action/2] not found',
|
||||
});
|
||||
});
|
||||
|
||||
it(`shouldn't delete a preconfigured action`, async () => {
|
||||
await supertest
|
||||
.delete(`${getUrlPrefix(Spaces.space1.id)}/api/actions/action/my-slack1`)
|
||||
.set('kbn-xsrf', 'foo')
|
||||
.expect(400, {
|
||||
statusCode: 400,
|
||||
error: 'Bad Request',
|
||||
message: `Preconfigured action my-slack1 is not allowed to delete.`,
|
||||
});
|
||||
});
|
||||
|
||||
it(`shouldn't delete a system action`, async () => {
|
||||
await supertest
|
||||
.delete(
|
||||
`${getUrlPrefix(
|
||||
Spaces.space1.id
|
||||
)}/api/actions/action/system-connector-test.system-action`
|
||||
)
|
||||
.set('kbn-xsrf', 'foo')
|
||||
.expect(400, {
|
||||
statusCode: 400,
|
||||
error: 'Bad Request',
|
||||
message: 'System action system-connector-test.system-action is not allowed to delete.',
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
@ -39,11 +39,11 @@ export default function ({ getService }: FtrProviderContext) {
|
|||
});
|
||||
|
||||
it('should handle execute request appropriately', async () => {
|
||||
const { body: createdAction } = await supertest
|
||||
const { body: createdConnector } = await supertest
|
||||
.post(`${getUrlPrefix(Spaces.space1.id)}/api/actions/connector`)
|
||||
.set('kbn-xsrf', 'foo')
|
||||
.send({
|
||||
name: 'My action',
|
||||
name: 'My connector',
|
||||
connector_type_id: 'test.index-record',
|
||||
config: {
|
||||
unencrypted: `This value shouldn't get encrypted`,
|
||||
|
@ -53,12 +53,12 @@ export default function ({ getService }: FtrProviderContext) {
|
|||
},
|
||||
})
|
||||
.expect(200);
|
||||
objectRemover.add(Spaces.space1.id, createdAction.id, 'action', 'actions');
|
||||
objectRemover.add(Spaces.space1.id, createdConnector.id, 'connector', 'actions');
|
||||
|
||||
const reference = `actions-execute-1:${Spaces.space1.id}:${createdAction.id}`;
|
||||
const reference = `actions-execute-1:${Spaces.space1.id}:${createdConnector.id}`;
|
||||
const response = await supertest
|
||||
.post(
|
||||
`${getUrlPrefix(Spaces.space1.id)}/api/actions/connector/${createdAction.id}/_execute`
|
||||
`${getUrlPrefix(Spaces.space1.id)}/api/actions/connector/${createdConnector.id}/_execute`
|
||||
)
|
||||
.set('kbn-xsrf', 'foo')
|
||||
.send({
|
||||
|
@ -93,30 +93,30 @@ export default function ({ getService }: FtrProviderContext) {
|
|||
|
||||
await validateEventLog({
|
||||
spaceId: Spaces.space1.id,
|
||||
actionId: createdAction.id,
|
||||
actionId: createdConnector.id,
|
||||
actionTypeId: 'test.index-record',
|
||||
outcome: 'success',
|
||||
message: `action executed: test.index-record:${createdAction.id}: My action`,
|
||||
startMessage: `action started: test.index-record:${createdAction.id}: My action`,
|
||||
message: `action executed: test.index-record:${createdConnector.id}: My connector`,
|
||||
startMessage: `action started: test.index-record:${createdConnector.id}: My connector`,
|
||||
source: ActionExecutionSourceType.HTTP_REQUEST,
|
||||
});
|
||||
});
|
||||
|
||||
it('should handle failed executions', async () => {
|
||||
const { body: createdAction } = await supertest
|
||||
const { body: createdConnector } = await supertest
|
||||
.post(`${getUrlPrefix(Spaces.space1.id)}/api/actions/connector`)
|
||||
.set('kbn-xsrf', 'foo')
|
||||
.send({
|
||||
name: 'failing action',
|
||||
name: 'failing connector',
|
||||
connector_type_id: 'test.failing',
|
||||
})
|
||||
.expect(200);
|
||||
objectRemover.add(Spaces.space1.id, createdAction.id, 'action', 'actions');
|
||||
objectRemover.add(Spaces.space1.id, createdConnector.id, 'connector', 'actions');
|
||||
|
||||
const reference = `actions-failure-1:${Spaces.space1.id}`;
|
||||
const response = await supertest
|
||||
.post(
|
||||
`${getUrlPrefix(Spaces.space1.id)}/api/actions/connector/${createdAction.id}/_execute`
|
||||
`${getUrlPrefix(Spaces.space1.id)}/api/actions/connector/${createdConnector.id}/_execute`
|
||||
)
|
||||
.set('kbn-xsrf', 'foo')
|
||||
.send({
|
||||
|
@ -128,7 +128,7 @@ export default function ({ getService }: FtrProviderContext) {
|
|||
|
||||
expect(response.status).to.eql(200);
|
||||
expect(response.body).to.eql({
|
||||
connector_id: createdAction.id,
|
||||
connector_id: createdConnector.id,
|
||||
status: 'error',
|
||||
message: 'an error occurred while running the action',
|
||||
service_message: `expected failure for ${ES_TEST_INDEX_NAME} ${reference}`,
|
||||
|
@ -138,21 +138,21 @@ export default function ({ getService }: FtrProviderContext) {
|
|||
|
||||
await validateEventLog({
|
||||
spaceId: Spaces.space1.id,
|
||||
actionId: createdAction.id,
|
||||
actionId: createdConnector.id,
|
||||
actionTypeId: 'test.failing',
|
||||
outcome: 'failure',
|
||||
message: `action execution failure: test.failing:${createdAction.id}: failing action`,
|
||||
message: `action execution failure: test.failing:${createdConnector.id}: failing connector`,
|
||||
errorMessage: `an error occurred while running the action: expected failure for .kibana-alerting-test-data actions-failure-1:space1; retry: true`,
|
||||
source: ActionExecutionSourceType.HTTP_REQUEST,
|
||||
});
|
||||
});
|
||||
|
||||
it(`shouldn't execute an action from another space`, async () => {
|
||||
const { body: createdAction } = await supertest
|
||||
it(`shouldn't execute a connector from another space`, async () => {
|
||||
const { body: createdConnector } = await supertest
|
||||
.post(`${getUrlPrefix(Spaces.space1.id)}/api/actions/connector`)
|
||||
.set('kbn-xsrf', 'foo')
|
||||
.send({
|
||||
name: 'My action',
|
||||
name: 'My connector',
|
||||
connector_type_id: 'test.index-record',
|
||||
config: {
|
||||
unencrypted: `This value shouldn't get encrypted`,
|
||||
|
@ -162,11 +162,13 @@ export default function ({ getService }: FtrProviderContext) {
|
|||
},
|
||||
})
|
||||
.expect(200);
|
||||
objectRemover.add(Spaces.space1.id, createdAction.id, 'action', 'actions');
|
||||
objectRemover.add(Spaces.space1.id, createdConnector.id, 'connector', 'actions');
|
||||
|
||||
const reference = `actions-execute-2:${Spaces.space1.id}`;
|
||||
await supertest
|
||||
.post(`${getUrlPrefix(Spaces.other.id)}/api/actions/action/${createdAction.id}/_execute`)
|
||||
.post(
|
||||
`${getUrlPrefix(Spaces.other.id)}/api/actions/connector/${createdConnector.id}/_execute`
|
||||
)
|
||||
.set('kbn-xsrf', 'foo')
|
||||
.send({
|
||||
params: {
|
||||
|
@ -178,25 +180,25 @@ export default function ({ getService }: FtrProviderContext) {
|
|||
.expect(404, {
|
||||
statusCode: 404,
|
||||
error: 'Not Found',
|
||||
message: `Saved object [action/${createdAction.id}] not found`,
|
||||
message: `Saved object [action/${createdConnector.id}] not found`,
|
||||
});
|
||||
});
|
||||
|
||||
it('should handle execute request appropriately and have proper callCluster and savedObjectsClient authorization', async () => {
|
||||
const reference = `actions-execute-3:${Spaces.space1.id}`;
|
||||
const { body: createdAction } = await supertest
|
||||
const { body: createdConnector } = await supertest
|
||||
.post(`${getUrlPrefix(Spaces.space1.id)}/api/actions/connector`)
|
||||
.set('kbn-xsrf', 'foo')
|
||||
.send({
|
||||
name: 'My action',
|
||||
name: 'My connector',
|
||||
connector_type_id: 'test.authorization',
|
||||
})
|
||||
.expect(200);
|
||||
objectRemover.add(Spaces.space1.id, createdAction.id, 'action', 'actions');
|
||||
objectRemover.add(Spaces.space1.id, createdConnector.id, 'connector', 'actions');
|
||||
|
||||
const response = await supertest
|
||||
.post(
|
||||
`${getUrlPrefix(Spaces.space1.id)}/api/actions/connector/${createdAction.id}/_execute`
|
||||
`${getUrlPrefix(Spaces.space1.id)}/api/actions/connector/${createdConnector.id}/_execute`
|
||||
)
|
||||
.set('kbn-xsrf', 'foo')
|
||||
.send({
|
||||
|
@ -231,23 +233,23 @@ export default function ({ getService }: FtrProviderContext) {
|
|||
});
|
||||
});
|
||||
|
||||
it('should notify feature usage when executing a gold action type', async () => {
|
||||
const { body: createdAction } = await supertest
|
||||
it('should notify feature usage when executing a gold connector type', async () => {
|
||||
const { body: createdConnector } = await supertest
|
||||
.post(`${getUrlPrefix(Spaces.space1.id)}/api/actions/connector`)
|
||||
.set('kbn-xsrf', 'foo')
|
||||
.send({
|
||||
name: 'Noop action type',
|
||||
name: 'Noop connector type',
|
||||
connector_type_id: 'test.noop',
|
||||
secrets: {},
|
||||
config: {},
|
||||
})
|
||||
.expect(200);
|
||||
objectRemover.add(Spaces.space1.id, createdAction.id, 'action', 'actions');
|
||||
objectRemover.add(Spaces.space1.id, createdConnector.id, 'connector', 'actions');
|
||||
|
||||
const executionStart = new Date();
|
||||
await supertest
|
||||
.post(
|
||||
`${getUrlPrefix(Spaces.space1.id)}/api/actions/connector/${createdAction.id}/_execute`
|
||||
`${getUrlPrefix(Spaces.space1.id)}/api/actions/connector/${createdConnector.id}/_execute`
|
||||
)
|
||||
.set('kbn-xsrf', 'foo')
|
||||
.send({
|
||||
|
@ -267,73 +269,6 @@ export default function ({ getService }: FtrProviderContext) {
|
|||
expect(new Date(noopFeature.last_used).getTime()).to.be.greaterThan(executionStart.getTime());
|
||||
});
|
||||
|
||||
describe('legacy', () => {
|
||||
it('should handle execute request appropriately', async () => {
|
||||
const { body: createdAction } = await supertest
|
||||
.post(`${getUrlPrefix(Spaces.space1.id)}/api/actions/action`)
|
||||
.set('kbn-xsrf', 'foo')
|
||||
.send({
|
||||
name: 'My action',
|
||||
actionTypeId: 'test.index-record',
|
||||
config: {
|
||||
unencrypted: `This value shouldn't get encrypted`,
|
||||
},
|
||||
secrets: {
|
||||
encrypted: 'This value should be encrypted',
|
||||
},
|
||||
})
|
||||
.expect(200);
|
||||
objectRemover.add(Spaces.space1.id, createdAction.id, 'action', 'actions');
|
||||
|
||||
const reference = `actions-execute-1:${Spaces.space1.id}:${createdAction.id}`;
|
||||
const response = await supertest
|
||||
.post(`${getUrlPrefix(Spaces.space1.id)}/api/actions/action/${createdAction.id}/_execute`)
|
||||
.set('kbn-xsrf', 'foo')
|
||||
.send({
|
||||
params: {
|
||||
reference,
|
||||
index: ES_TEST_INDEX_NAME,
|
||||
message: 'Testing 123',
|
||||
},
|
||||
});
|
||||
|
||||
expect(response.status).to.eql(200);
|
||||
});
|
||||
|
||||
it('should handle failed executions', async () => {
|
||||
const { body: createdAction } = await supertest
|
||||
.post(`${getUrlPrefix(Spaces.space1.id)}/api/actions/action`)
|
||||
.set('kbn-xsrf', 'foo')
|
||||
.send({
|
||||
name: 'failing action',
|
||||
actionTypeId: 'test.failing',
|
||||
})
|
||||
.expect(200);
|
||||
objectRemover.add(Spaces.space1.id, createdAction.id, 'action', 'actions');
|
||||
|
||||
const reference = `actions-failure-1:${Spaces.space1.id}:${createdAction.id}`;
|
||||
const response = await supertest
|
||||
.post(`${getUrlPrefix(Spaces.space1.id)}/api/actions/action/${createdAction.id}/_execute`)
|
||||
.set('kbn-xsrf', 'foo')
|
||||
.send({
|
||||
params: {
|
||||
reference,
|
||||
index: ES_TEST_INDEX_NAME,
|
||||
},
|
||||
});
|
||||
|
||||
expect(response.status).to.eql(200);
|
||||
expect(response.body).to.eql({
|
||||
actionId: createdAction.id,
|
||||
status: 'error',
|
||||
message: 'an error occurred while running the action',
|
||||
serviceMessage: `expected failure for ${ES_TEST_INDEX_NAME} ${reference}`,
|
||||
retry: true,
|
||||
errorSource: TaskErrorSource.FRAMEWORK,
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* The test are using a test endpoint that calls the actions client.
|
||||
* The route is defined here x-pack/test/alerting_api_integration/common/plugins/alerts/server/routes.ts.
|
||||
|
|
|
@ -12,7 +12,7 @@ import { getWebhookServer } from '@kbn/actions-simulators-plugin/server/plugin';
|
|||
import { FtrProviderContext } from '../../../../common/ftr_provider_context';
|
||||
import { ObjectRemover } from '../../../common/lib';
|
||||
import { Spaces } from '../../scenarios';
|
||||
import { createWebhookAction } from './connector_types/stack/webhook';
|
||||
import { createWebhookConnector } from './connector_types/stack/webhook';
|
||||
|
||||
// eslint-disable-next-line import/no-default-export
|
||||
export default function createUnsecuredActionTests({ getService }: FtrProviderContext) {
|
||||
|
@ -150,7 +150,7 @@ export default function createUnsecuredActionTests({ getService }: FtrProviderCo
|
|||
const webhookServer = await getWebhookServer();
|
||||
const availablePort = await getPort({ port: 9000 });
|
||||
webhookServer.listen(availablePort);
|
||||
const webhookActionId = await createWebhookAction(
|
||||
const webhookConnectorId = await createWebhookConnector(
|
||||
supertest,
|
||||
`http://localhost:${availablePort}`
|
||||
);
|
||||
|
@ -160,7 +160,7 @@ export default function createUnsecuredActionTests({ getService }: FtrProviderCo
|
|||
.set('kbn-xsrf', 'xxx')
|
||||
.send({
|
||||
requesterId: 'background_task',
|
||||
id: webhookActionId,
|
||||
id: webhookConnectorId,
|
||||
params: {
|
||||
body: 'success',
|
||||
},
|
||||
|
@ -175,10 +175,10 @@ export default function createUnsecuredActionTests({ getService }: FtrProviderCo
|
|||
})
|
||||
.expect(200);
|
||||
expect(response.body.status).to.eql('success');
|
||||
expect(response.body.result.actionId).to.eql(webhookActionId);
|
||||
expect(response.body.result.actionId).to.eql(webhookConnectorId);
|
||||
expect(response.body.result.status).to.eql('ok');
|
||||
|
||||
const query = getEventLogExecuteQuery(testStart, webhookActionId);
|
||||
const query = getEventLogExecuteQuery(testStart, webhookConnectorId);
|
||||
await retry.try(async () => {
|
||||
const searchResult = await es.search(query);
|
||||
expect((searchResult.hits.total as SearchTotalHits).value).to.eql(1);
|
||||
|
@ -188,7 +188,7 @@ export default function createUnsecuredActionTests({ getService }: FtrProviderCo
|
|||
expect(hit?._source?.event?.outcome).to.eql('success');
|
||||
// @ts-expect-error _source: unknown
|
||||
expect(hit?._source?.message).to.eql(
|
||||
`action executed: .webhook:${webhookActionId}: A generic Webhook action`
|
||||
`action executed: .webhook:${webhookConnectorId}: A generic Webhook connector`
|
||||
);
|
||||
// @ts-expect-error _source: unknown
|
||||
expect(hit?._source?.kibana?.action?.execution?.source).to.eql('background_task');
|
||||
|
|
|
@ -10,7 +10,7 @@ import { getUrlPrefix, ObjectRemover } from '../../../common/lib';
|
|||
import { FtrProviderContext } from '../../../common/ftr_provider_context';
|
||||
|
||||
// eslint-disable-next-line import/no-default-export
|
||||
export default function getActionTests({ getService }: FtrProviderContext) {
|
||||
export default function getConnectorTests({ getService }: FtrProviderContext) {
|
||||
const supertest = getService('supertest');
|
||||
|
||||
describe('get', () => {
|
||||
|
@ -18,12 +18,12 @@ export default function getActionTests({ getService }: FtrProviderContext) {
|
|||
|
||||
afterEach(() => objectRemover.removeAll());
|
||||
|
||||
it('should handle get action request appropriately', async () => {
|
||||
const { body: createdAction } = await supertest
|
||||
it('should handle get connector request appropriately', async () => {
|
||||
const { body: createdConnector } = await supertest
|
||||
.post(`${getUrlPrefix(Spaces.space1.id)}/api/actions/connector`)
|
||||
.set('kbn-xsrf', 'foo')
|
||||
.send({
|
||||
name: 'My action',
|
||||
name: 'My connector',
|
||||
connector_type_id: 'test.index-record',
|
||||
config: {
|
||||
unencrypted: `This value shouldn't get encrypted`,
|
||||
|
@ -33,30 +33,30 @@ export default function getActionTests({ getService }: FtrProviderContext) {
|
|||
},
|
||||
})
|
||||
.expect(200);
|
||||
objectRemover.add(Spaces.space1.id, createdAction.id, 'action', 'actions');
|
||||
objectRemover.add(Spaces.space1.id, createdConnector.id, 'connector', 'actions');
|
||||
|
||||
await supertest
|
||||
.get(`${getUrlPrefix(Spaces.space1.id)}/api/actions/connector/${createdAction.id}`)
|
||||
.get(`${getUrlPrefix(Spaces.space1.id)}/api/actions/connector/${createdConnector.id}`)
|
||||
.expect(200, {
|
||||
id: createdAction.id,
|
||||
id: createdConnector.id,
|
||||
is_preconfigured: false,
|
||||
is_deprecated: false,
|
||||
is_missing_secrets: false,
|
||||
is_system_action: false,
|
||||
connector_type_id: 'test.index-record',
|
||||
name: 'My action',
|
||||
name: 'My connector',
|
||||
config: {
|
||||
unencrypted: `This value shouldn't get encrypted`,
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
it(`action should't be acessible from another space`, async () => {
|
||||
const { body: createdAction } = await supertest
|
||||
it(`connector should't be acessible from another space`, async () => {
|
||||
const { body: createdConnector } = await supertest
|
||||
.post(`${getUrlPrefix(Spaces.space1.id)}/api/actions/connector`)
|
||||
.set('kbn-xsrf', 'foo')
|
||||
.send({
|
||||
name: 'My action',
|
||||
name: 'My connector',
|
||||
connector_type_id: 'test.index-record',
|
||||
config: {
|
||||
unencrypted: `This value shouldn't get encrypted`,
|
||||
|
@ -66,14 +66,14 @@ export default function getActionTests({ getService }: FtrProviderContext) {
|
|||
},
|
||||
})
|
||||
.expect(200);
|
||||
objectRemover.add(Spaces.space1.id, createdAction.id, 'action', 'actions');
|
||||
objectRemover.add(Spaces.space1.id, createdConnector.id, 'connector', 'actions');
|
||||
|
||||
await supertest
|
||||
.get(`${getUrlPrefix(Spaces.other.id)}/api/actions/connector/${createdAction.id}`)
|
||||
.get(`${getUrlPrefix(Spaces.other.id)}/api/actions/connector/${createdConnector.id}`)
|
||||
.expect(404, {
|
||||
statusCode: 404,
|
||||
error: 'Not Found',
|
||||
message: `Saved object [action/${createdAction.id}] not found`,
|
||||
message: `Saved object [action/${createdConnector.id}] not found`,
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -125,89 +125,5 @@ export default function getActionTests({ getService }: FtrProviderContext) {
|
|||
name: 'ServiceNow#xyz',
|
||||
});
|
||||
});
|
||||
|
||||
describe('legacy', () => {
|
||||
it('should handle get action request appropriately', async () => {
|
||||
const { body: createdAction } = await supertest
|
||||
.post(`${getUrlPrefix(Spaces.space1.id)}/api/actions/action`)
|
||||
.set('kbn-xsrf', 'foo')
|
||||
.send({
|
||||
name: 'My action',
|
||||
actionTypeId: 'test.index-record',
|
||||
config: {
|
||||
unencrypted: `This value shouldn't get encrypted`,
|
||||
},
|
||||
secrets: {
|
||||
encrypted: 'This value should be encrypted',
|
||||
},
|
||||
})
|
||||
.expect(200);
|
||||
objectRemover.add(Spaces.space1.id, createdAction.id, 'action', 'actions');
|
||||
|
||||
await supertest
|
||||
.get(`${getUrlPrefix(Spaces.space1.id)}/api/actions/action/${createdAction.id}`)
|
||||
.expect(200, {
|
||||
id: createdAction.id,
|
||||
isPreconfigured: false,
|
||||
isDeprecated: false,
|
||||
isSystemAction: false,
|
||||
actionTypeId: 'test.index-record',
|
||||
isMissingSecrets: false,
|
||||
name: 'My action',
|
||||
config: {
|
||||
unencrypted: `This value shouldn't get encrypted`,
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
it(`action should't be acessible from another space`, async () => {
|
||||
const { body: createdAction } = await supertest
|
||||
.post(`${getUrlPrefix(Spaces.space1.id)}/api/actions/action`)
|
||||
.set('kbn-xsrf', 'foo')
|
||||
.send({
|
||||
name: 'My action',
|
||||
actionTypeId: 'test.index-record',
|
||||
config: {
|
||||
unencrypted: `This value shouldn't get encrypted`,
|
||||
},
|
||||
secrets: {
|
||||
encrypted: 'This value should be encrypted',
|
||||
},
|
||||
})
|
||||
.expect(200);
|
||||
objectRemover.add(Spaces.space1.id, createdAction.id, 'action', 'actions');
|
||||
|
||||
await supertest
|
||||
.get(`${getUrlPrefix(Spaces.other.id)}/api/actions/action/${createdAction.id}`)
|
||||
.expect(404, {
|
||||
statusCode: 404,
|
||||
error: 'Not Found',
|
||||
message: `Saved object [action/${createdAction.id}] not found`,
|
||||
});
|
||||
});
|
||||
|
||||
it('should handle get a preconfigured connector', async () => {
|
||||
await supertest
|
||||
.get(`${getUrlPrefix(Spaces.space1.id)}/api/actions/action/my-slack1`)
|
||||
.expect(200, {
|
||||
id: 'my-slack1',
|
||||
isPreconfigured: true,
|
||||
isDeprecated: false,
|
||||
isSystemAction: false,
|
||||
actionTypeId: '.slack',
|
||||
name: 'Slack#xyz',
|
||||
});
|
||||
});
|
||||
|
||||
it('should return 404 when trying to get a system connector', async () => {
|
||||
await supertest
|
||||
.get(
|
||||
`${getUrlPrefix(
|
||||
Spaces.space1.id
|
||||
)}/api/actions/action/system-connector-test.system-action`
|
||||
)
|
||||
.expect(404);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ import { getUrlPrefix, ObjectRemover } from '../../../common/lib';
|
|||
import { FtrProviderContext } from '../../../common/ftr_provider_context';
|
||||
|
||||
// eslint-disable-next-line import/no-default-export
|
||||
export default function getAllActionTests({ getService }: FtrProviderContext) {
|
||||
export default function getAllConnectorsTests({ getService }: FtrProviderContext) {
|
||||
const supertest = getService('supertest');
|
||||
|
||||
describe('getAll', () => {
|
||||
|
@ -19,13 +19,13 @@ export default function getAllActionTests({ getService }: FtrProviderContext) {
|
|||
|
||||
afterEach(() => objectRemover.removeAll());
|
||||
|
||||
it('should handle get all action request appropriately', async () => {
|
||||
const { body: createdAction } = await supertest
|
||||
.post(`${getUrlPrefix(Spaces.space1.id)}/api/actions/action`)
|
||||
it('should handle get all connectors request appropriately', async () => {
|
||||
const { body: createdConnector } = await supertest
|
||||
.post(`${getUrlPrefix(Spaces.space1.id)}/api/actions/connector`)
|
||||
.set('kbn-xsrf', 'foo')
|
||||
.send({
|
||||
name: 'My action',
|
||||
actionTypeId: 'test.index-record',
|
||||
name: 'My connector',
|
||||
connector_type_id: 'test.index-record',
|
||||
config: {
|
||||
unencrypted: `This value shouldn't get encrypted`,
|
||||
},
|
||||
|
@ -34,7 +34,7 @@ export default function getAllActionTests({ getService }: FtrProviderContext) {
|
|||
},
|
||||
})
|
||||
.expect(200);
|
||||
objectRemover.add(Spaces.space1.id, createdAction.id, 'action', 'actions');
|
||||
objectRemover.add(Spaces.space1.id, createdConnector.id, 'connector', 'actions');
|
||||
|
||||
const { body: connectors } = await supertest
|
||||
.get(`${getUrlPrefix(Spaces.space1.id)}/api/actions/connectors`)
|
||||
|
@ -57,10 +57,10 @@ export default function getAllActionTests({ getService }: FtrProviderContext) {
|
|||
referenced_by_count: 0,
|
||||
},
|
||||
{
|
||||
id: createdAction.id,
|
||||
id: createdConnector.id,
|
||||
is_preconfigured: false,
|
||||
is_deprecated: false,
|
||||
name: 'My action',
|
||||
name: 'My connector',
|
||||
connector_type_id: 'test.index-record',
|
||||
is_missing_secrets: false,
|
||||
is_system_action: false,
|
||||
|
@ -144,13 +144,13 @@ export default function getAllActionTests({ getService }: FtrProviderContext) {
|
|||
]);
|
||||
});
|
||||
|
||||
it(`shouldn't get all action from another space`, async () => {
|
||||
const { body: createdAction } = await supertest
|
||||
.post(`${getUrlPrefix(Spaces.space1.id)}/api/actions/action`)
|
||||
it(`shouldn't get all connectors from another space`, async () => {
|
||||
const { body: createdConnector } = await supertest
|
||||
.post(`${getUrlPrefix(Spaces.space1.id)}/api/actions/connector`)
|
||||
.set('kbn-xsrf', 'foo')
|
||||
.send({
|
||||
name: 'My action',
|
||||
actionTypeId: 'test.index-record',
|
||||
name: 'My connector',
|
||||
connector_type_id: 'test.index-record',
|
||||
config: {
|
||||
unencrypted: `This value shouldn't get encrypted`,
|
||||
},
|
||||
|
@ -159,7 +159,7 @@ export default function getAllActionTests({ getService }: FtrProviderContext) {
|
|||
},
|
||||
})
|
||||
.expect(200);
|
||||
objectRemover.add(Spaces.space1.id, createdAction.id, 'action', 'actions');
|
||||
objectRemover.add(Spaces.space1.id, createdConnector.id, 'connector', 'actions');
|
||||
|
||||
const { body: connectors } = await supertest
|
||||
.get(`${getUrlPrefix(Spaces.other.id)}/api/actions/connectors`)
|
||||
|
@ -255,132 +255,5 @@ export default function getAllActionTests({ getService }: FtrProviderContext) {
|
|||
},
|
||||
]);
|
||||
});
|
||||
|
||||
describe('legacy', () => {
|
||||
it('should handle get all action request appropriately', async () => {
|
||||
const { body: createdAction } = await supertest
|
||||
.post(`${getUrlPrefix(Spaces.space1.id)}/api/actions/action`)
|
||||
.set('kbn-xsrf', 'foo')
|
||||
.send({
|
||||
name: 'My action',
|
||||
actionTypeId: 'test.index-record',
|
||||
config: {
|
||||
unencrypted: `This value shouldn't get encrypted`,
|
||||
},
|
||||
secrets: {
|
||||
encrypted: 'This value should be encrypted',
|
||||
},
|
||||
})
|
||||
.expect(200);
|
||||
objectRemover.add(Spaces.space1.id, createdAction.id, 'action', 'actions');
|
||||
|
||||
const { body: connectors } = await supertest
|
||||
.get(`${getUrlPrefix(Spaces.space1.id)}/api/actions`)
|
||||
.expect(200);
|
||||
|
||||
// the custom ssl connectors have dynamic ports, so remove them before
|
||||
// comparing to what we expect
|
||||
const nonCustomSslConnectors = connectors.filter(
|
||||
(conn: { id: string }) => !conn.id.startsWith('custom.ssl.')
|
||||
);
|
||||
|
||||
expect(nonCustomSslConnectors).to.eql([
|
||||
{
|
||||
id: 'preconfigured-alert-history-es-index',
|
||||
name: 'Alert history Elasticsearch index',
|
||||
actionTypeId: '.index',
|
||||
isPreconfigured: true,
|
||||
isSystemAction: false,
|
||||
isDeprecated: false,
|
||||
referencedByCount: 0,
|
||||
},
|
||||
{
|
||||
id: createdAction.id,
|
||||
isPreconfigured: false,
|
||||
isDeprecated: false,
|
||||
isSystemAction: false,
|
||||
name: 'My action',
|
||||
actionTypeId: 'test.index-record',
|
||||
isMissingSecrets: false,
|
||||
config: {
|
||||
unencrypted: `This value shouldn't get encrypted`,
|
||||
},
|
||||
referencedByCount: 0,
|
||||
},
|
||||
{
|
||||
actionTypeId: '.email',
|
||||
id: 'notification-email',
|
||||
isDeprecated: false,
|
||||
isPreconfigured: true,
|
||||
isSystemAction: false,
|
||||
name: 'Notification Email Connector',
|
||||
referencedByCount: 0,
|
||||
},
|
||||
{
|
||||
id: 'preconfigured-es-index-action',
|
||||
isPreconfigured: true,
|
||||
isDeprecated: false,
|
||||
actionTypeId: '.index',
|
||||
isSystemAction: false,
|
||||
name: 'preconfigured_es_index_action',
|
||||
referencedByCount: 0,
|
||||
},
|
||||
{
|
||||
actionTypeId: '.servicenow',
|
||||
id: 'my-deprecated-servicenow',
|
||||
isDeprecated: true,
|
||||
isPreconfigured: true,
|
||||
isSystemAction: false,
|
||||
name: 'ServiceNow#xyz',
|
||||
referencedByCount: 0,
|
||||
},
|
||||
{
|
||||
actionTypeId: '.servicenow',
|
||||
id: 'my-deprecated-servicenow-default',
|
||||
isPreconfigured: true,
|
||||
isDeprecated: true,
|
||||
isSystemAction: false,
|
||||
name: 'ServiceNow#xyz',
|
||||
referencedByCount: 0,
|
||||
},
|
||||
{
|
||||
id: 'my-slack1',
|
||||
isPreconfigured: true,
|
||||
isDeprecated: false,
|
||||
actionTypeId: '.slack',
|
||||
isSystemAction: false,
|
||||
name: 'Slack#xyz',
|
||||
referencedByCount: 0,
|
||||
},
|
||||
{
|
||||
id: 'custom-system-abc-connector',
|
||||
isPreconfigured: true,
|
||||
isDeprecated: false,
|
||||
actionTypeId: 'system-abc-action-type',
|
||||
isSystemAction: false,
|
||||
name: 'SystemABC',
|
||||
referencedByCount: 0,
|
||||
},
|
||||
{
|
||||
id: 'preconfigured.test.index-record',
|
||||
isPreconfigured: true,
|
||||
isDeprecated: false,
|
||||
actionTypeId: 'test.index-record',
|
||||
isSystemAction: false,
|
||||
name: 'Test:_Preconfigured_Index_Record',
|
||||
referencedByCount: 0,
|
||||
},
|
||||
{
|
||||
id: 'my-test-email',
|
||||
isPreconfigured: true,
|
||||
isDeprecated: false,
|
||||
actionTypeId: '.email',
|
||||
isSystemAction: false,
|
||||
name: 'TestEmail#xyz',
|
||||
referencedByCount: 0,
|
||||
},
|
||||
]);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ import { getUrlPrefix, ObjectRemover } from '../../../common/lib';
|
|||
import { FtrProviderContext } from '../../../common/ftr_provider_context';
|
||||
|
||||
// eslint-disable-next-line import/no-default-export
|
||||
export default function getAllActionTests({ getService }: FtrProviderContext) {
|
||||
export default function getAllConnectorsTests({ getService }: FtrProviderContext) {
|
||||
const supertest = getService('supertest');
|
||||
|
||||
describe('getAllSystem', () => {
|
||||
|
@ -19,13 +19,13 @@ export default function getAllActionTests({ getService }: FtrProviderContext) {
|
|||
|
||||
afterEach(() => objectRemover.removeAll());
|
||||
|
||||
it('should handle get all action request appropriately', async () => {
|
||||
const { body: createdAction } = await supertest
|
||||
.post(`${getUrlPrefix(Spaces.space1.id)}/api/actions/action`)
|
||||
it('should handle get all connector request appropriately', async () => {
|
||||
const { body: createdConnector } = await supertest
|
||||
.post(`${getUrlPrefix(Spaces.space1.id)}/api/actions/connector`)
|
||||
.set('kbn-xsrf', 'foo')
|
||||
.send({
|
||||
name: 'My action',
|
||||
actionTypeId: 'test.index-record',
|
||||
name: 'My connector',
|
||||
connector_type_id: 'test.index-record',
|
||||
config: {
|
||||
unencrypted: `This value shouldn't get encrypted`,
|
||||
},
|
||||
|
@ -34,7 +34,7 @@ export default function getAllActionTests({ getService }: FtrProviderContext) {
|
|||
},
|
||||
})
|
||||
.expect(200);
|
||||
objectRemover.add(Spaces.space1.id, createdAction.id, 'action', 'actions');
|
||||
objectRemover.add(Spaces.space1.id, createdConnector.id, 'connector', 'actions');
|
||||
|
||||
const { body: connectors } = await supertest
|
||||
.get(`${getUrlPrefix(Spaces.space1.id)}/internal/actions/connectors`)
|
||||
|
@ -66,10 +66,10 @@ export default function getAllActionTests({ getService }: FtrProviderContext) {
|
|||
referenced_by_count: 0,
|
||||
},
|
||||
{
|
||||
id: createdAction.id,
|
||||
id: createdConnector.id,
|
||||
is_preconfigured: false,
|
||||
is_deprecated: false,
|
||||
name: 'My action',
|
||||
name: 'My connector',
|
||||
connector_type_id: 'test.index-record',
|
||||
is_missing_secrets: false,
|
||||
is_system_action: false,
|
||||
|
@ -190,13 +190,13 @@ export default function getAllActionTests({ getService }: FtrProviderContext) {
|
|||
]);
|
||||
});
|
||||
|
||||
it(`shouldn't get all action from another space`, async () => {
|
||||
const { body: createdAction } = await supertest
|
||||
.post(`${getUrlPrefix(Spaces.space1.id)}/api/actions/action`)
|
||||
it(`shouldn't get all connectors from another space`, async () => {
|
||||
const { body: createdConnector } = await supertest
|
||||
.post(`${getUrlPrefix(Spaces.space1.id)}/api/actions/connector`)
|
||||
.set('kbn-xsrf', 'foo')
|
||||
.send({
|
||||
name: 'My action',
|
||||
actionTypeId: 'test.index-record',
|
||||
name: 'My connector',
|
||||
connector_type_id: 'test.index-record',
|
||||
config: {
|
||||
unencrypted: `This value shouldn't get encrypted`,
|
||||
},
|
||||
|
@ -205,7 +205,7 @@ export default function getAllActionTests({ getService }: FtrProviderContext) {
|
|||
},
|
||||
})
|
||||
.expect(200);
|
||||
objectRemover.add(Spaces.space1.id, createdAction.id, 'action', 'actions');
|
||||
objectRemover.add(Spaces.space1.id, createdConnector.id, 'connector', 'actions');
|
||||
|
||||
const { body: connectors } = await supertest
|
||||
.get(`${getUrlPrefix(Spaces.other.id)}/internal/actions/connectors`)
|
||||
|
|
|
@ -125,7 +125,7 @@ export default function createUnsecuredActionTests({ getService }: FtrProviderCo
|
|||
},
|
||||
})
|
||||
.expect(200);
|
||||
objectRemover.add(Spaces.space1.id, createdConnector1.id, 'action', 'actions');
|
||||
objectRemover.add(Spaces.space1.id, createdConnector1.id, 'connector', 'actions');
|
||||
|
||||
const { body: createdConnector2 } = await supertest
|
||||
.post(`${getUrlPrefix(Spaces.other.id)}/api/actions/connector`)
|
||||
|
@ -141,7 +141,7 @@ export default function createUnsecuredActionTests({ getService }: FtrProviderCo
|
|||
},
|
||||
})
|
||||
.expect(200);
|
||||
objectRemover.add(Spaces.other.id, createdConnector2.id, 'action', 'actions');
|
||||
objectRemover.add(Spaces.other.id, createdConnector2.id, 'connector', 'actions');
|
||||
|
||||
const space1SpaceResponse = await supertest
|
||||
.post(`/api/get_all_unsecured_actions`)
|
||||
|
|
|
@ -47,7 +47,7 @@ export default function createActionTests({ getService }: FtrProviderContext) {
|
|||
|
||||
expect(response.status).to.eql(200);
|
||||
const actionId = response.body.id;
|
||||
objectRemover.add('default', actionId, 'action', 'actions');
|
||||
objectRemover.add('default', actionId, 'connector', 'actions');
|
||||
|
||||
const actions = [];
|
||||
for (let i = 0; i < 510; i++) {
|
||||
|
|
|
@ -26,7 +26,7 @@ export default function createGetTests({ getService }: FtrProviderContext) {
|
|||
|
||||
it('7.10.0 migrates the `casesConfiguration` to be the `incidentConfiguration` in `config`, then 7.11.0 removes `incidentConfiguration`', async () => {
|
||||
const response = await supertest.get(
|
||||
`${getUrlPrefix(``)}/api/actions/action/791a2ab1-784a-46ea-aa68-04c837e5da2d`
|
||||
`${getUrlPrefix(``)}/api/actions/connector/791a2ab1-784a-46ea-aa68-04c837e5da2d`
|
||||
);
|
||||
|
||||
expect(response.status).to.eql(200);
|
||||
|
@ -42,7 +42,7 @@ export default function createGetTests({ getService }: FtrProviderContext) {
|
|||
|
||||
it('7.11.0 migrates webhook connector configurations to have `hasAuth` property', async () => {
|
||||
const responseWithAuth = await supertest.get(
|
||||
`${getUrlPrefix(``)}/api/actions/action/949f909b-20a0-46e3-aadb-6a4d117bb592`
|
||||
`${getUrlPrefix(``)}/api/actions/connector/949f909b-20a0-46e3-aadb-6a4d117bb592`
|
||||
);
|
||||
|
||||
expect(responseWithAuth.status).to.eql(200);
|
||||
|
@ -50,7 +50,7 @@ export default function createGetTests({ getService }: FtrProviderContext) {
|
|||
expect(responseWithAuth.body.config.hasAuth).to.eql(true);
|
||||
|
||||
const responseNoAuth = await supertest.get(
|
||||
`${getUrlPrefix(``)}/api/actions/action/7434121e-045a-47d6-a0a6-0b6da752397a`
|
||||
`${getUrlPrefix(``)}/api/actions/connector/7434121e-045a-47d6-a0a6-0b6da752397a`
|
||||
);
|
||||
expect(responseNoAuth.status).to.eql(200);
|
||||
expect(responseNoAuth.body.config).key('hasAuth');
|
||||
|
@ -59,16 +59,16 @@ export default function createGetTests({ getService }: FtrProviderContext) {
|
|||
|
||||
it('7.14.0 migrates connectors to have `isMissingSecrets` property', async () => {
|
||||
const responseWithisMissingSecrets = await supertest.get(
|
||||
`${getUrlPrefix(``)}/api/actions/action/7434121e-045a-47d6-a0a6-0b6da752397a`
|
||||
`${getUrlPrefix(``)}/api/actions/connector/7434121e-045a-47d6-a0a6-0b6da752397a`
|
||||
);
|
||||
|
||||
expect(responseWithisMissingSecrets.status).to.eql(200);
|
||||
expect(responseWithisMissingSecrets.body.isMissingSecrets).to.eql(false);
|
||||
expect(responseWithisMissingSecrets.body.is_missing_secrets).to.eql(false);
|
||||
});
|
||||
|
||||
it('7.16.0 migrates email connector configurations to set `service` property if not set', async () => {
|
||||
const connectorWithService = await supertest.get(
|
||||
`${getUrlPrefix(``)}/api/actions/action/0f8f2810-0a59-11ec-9a7c-fd0c2b83ff7c`
|
||||
`${getUrlPrefix(``)}/api/actions/connector/0f8f2810-0a59-11ec-9a7c-fd0c2b83ff7c`
|
||||
);
|
||||
|
||||
expect(connectorWithService.status).to.eql(200);
|
||||
|
@ -76,7 +76,7 @@ export default function createGetTests({ getService }: FtrProviderContext) {
|
|||
expect(connectorWithService.body.config.service).to.eql('someservice');
|
||||
|
||||
const connectorWithoutService = await supertest.get(
|
||||
`${getUrlPrefix(``)}/api/actions/action/1e0824a0-0a59-11ec-9a7c-fd0c2b83ff7c`
|
||||
`${getUrlPrefix(``)}/api/actions/connector/1e0824a0-0a59-11ec-9a7c-fd0c2b83ff7c`
|
||||
);
|
||||
|
||||
expect(connectorWithoutService.status).to.eql(200);
|
||||
|
@ -93,7 +93,7 @@ export default function createGetTests({ getService }: FtrProviderContext) {
|
|||
|
||||
await asyncForEach(serviceNowConnectorIds, async (serviceNowConnectorId) => {
|
||||
const connectorResponse = await supertest.get(
|
||||
`${getUrlPrefix(``)}/api/actions/action/${serviceNowConnectorId}`
|
||||
`${getUrlPrefix(``)}/api/actions/connector/${serviceNowConnectorId}`
|
||||
);
|
||||
|
||||
expect(connectorResponse.status).to.eql(200);
|
||||
|
|
|
@ -169,7 +169,7 @@ export default function createUnsecuredActionTests({ getService }: FtrProviderCo
|
|||
expect(response.status).to.eql(200);
|
||||
|
||||
const connectorId = response.body.id;
|
||||
objectRemover.add(Spaces.space1.id, connectorId, 'action', 'actions');
|
||||
objectRemover.add(Spaces.space1.id, connectorId, 'connector', 'actions');
|
||||
const { body: result } = await supertest
|
||||
.post(`/api/sample_unsecured_action`)
|
||||
.set('kbn-xsrf', 'xxx')
|
||||
|
|
|
@ -8,23 +8,23 @@
|
|||
import expect from '@kbn/expect';
|
||||
import { FtrProviderContext } from '../../../common/ftr_provider_context';
|
||||
|
||||
const PREWRITTEN_ACTION_ID = 'uuid-actionId';
|
||||
const DISABLED_ACTION_TYPE = 'test.not-enabled';
|
||||
const PREWRITTEN_CONNECTOR_ID = 'uuid-actionId';
|
||||
const DISABLED_CONNECTOR_TYPE = 'test.not-enabled';
|
||||
|
||||
// eslint-disable-next-line import/no-default-export
|
||||
export default function typeNotEnabledTests({ getService }: FtrProviderContext) {
|
||||
const supertest = getService('supertest');
|
||||
const esArchiver = getService('esArchiver');
|
||||
|
||||
describe('actionType not enabled', () => {
|
||||
// loads action PREWRITTEN_ACTION_ID with actionType DISABLED_ACTION_TYPE
|
||||
describe('connectorType not enabled', () => {
|
||||
// loads connector PREWRITTEN_CONNECTOR_ID with connectorType DISABLED_CONNECTOR_TYPE
|
||||
before(() => esArchiver.load('x-pack/test/functional/es_archives/actions'));
|
||||
after(() => esArchiver.unload('x-pack/test/functional/es_archives/actions'));
|
||||
|
||||
it('should handle create action with disabled actionType request appropriately', async () => {
|
||||
const response = await supertest.post(`/api/actions/action`).set('kbn-xsrf', 'foo').send({
|
||||
name: 'My action',
|
||||
actionTypeId: DISABLED_ACTION_TYPE,
|
||||
it('should handle create connector with disabled connector type request appropriately', async () => {
|
||||
const response = await supertest.post(`/api/actions/connector`).set('kbn-xsrf', 'foo').send({
|
||||
name: 'My connector',
|
||||
connector_type_id: DISABLED_CONNECTOR_TYPE,
|
||||
});
|
||||
|
||||
expect(response.status).to.eql(403);
|
||||
|
@ -36,9 +36,9 @@ export default function typeNotEnabledTests({ getService }: FtrProviderContext)
|
|||
});
|
||||
});
|
||||
|
||||
it(`should handle execute request with disabled actionType appropriately`, async () => {
|
||||
it(`should handle execute request with disabled connector type appropriately`, async () => {
|
||||
const response = await supertest
|
||||
.post(`/api/actions/action/${PREWRITTEN_ACTION_ID}/_execute`)
|
||||
.post(`/api/actions/connector/${PREWRITTEN_CONNECTOR_ID}/_execute`)
|
||||
.set('kbn-xsrf', 'foo')
|
||||
.send({
|
||||
params: {},
|
||||
|
@ -53,25 +53,25 @@ export default function typeNotEnabledTests({ getService }: FtrProviderContext)
|
|||
});
|
||||
});
|
||||
|
||||
it('should handle get action request with disabled actionType appropriately', async () => {
|
||||
const response = await supertest.get(`/api/actions/action/${PREWRITTEN_ACTION_ID}`);
|
||||
it('should handle get connector request with disabled connector type appropriately', async () => {
|
||||
const response = await supertest.get(`/api/actions/connector/${PREWRITTEN_CONNECTOR_ID}`);
|
||||
|
||||
expect(response.status).to.eql(200);
|
||||
expect(response.body).to.eql({
|
||||
actionTypeId: 'test.not-enabled',
|
||||
connector_type_id: 'test.not-enabled',
|
||||
config: {},
|
||||
id: 'uuid-actionId',
|
||||
isPreconfigured: false,
|
||||
isDeprecated: false,
|
||||
isSystemAction: false,
|
||||
isMissingSecrets: false,
|
||||
is_preconfigured: false,
|
||||
is_deprecated: false,
|
||||
is_system_action: false,
|
||||
is_missing_secrets: false,
|
||||
name: 'an action created before test.not-enabled was disabled',
|
||||
});
|
||||
});
|
||||
|
||||
it('should handle update action request with disabled actionType appropriately', async () => {
|
||||
it('should handle update connector request with disabled connector type appropriately', async () => {
|
||||
const responseUpdate = await supertest
|
||||
.put(`/api/actions/action/${PREWRITTEN_ACTION_ID}`)
|
||||
.put(`/api/actions/connector/${PREWRITTEN_CONNECTOR_ID}`)
|
||||
.set('kbn-xsrf', 'foo')
|
||||
.send({
|
||||
name: 'an action created before test.not-enabled was disabled (updated)',
|
||||
|
@ -85,29 +85,29 @@ export default function typeNotEnabledTests({ getService }: FtrProviderContext)
|
|||
'action type "test.not-enabled" is not enabled in the Kibana config xpack.actions.enabledActionTypes',
|
||||
});
|
||||
|
||||
const response = await supertest.get(`/api/actions/action/${PREWRITTEN_ACTION_ID}`);
|
||||
const response = await supertest.get(`/api/actions/connector/${PREWRITTEN_CONNECTOR_ID}`);
|
||||
expect(response.status).to.eql(200);
|
||||
expect(response.body).to.eql({
|
||||
actionTypeId: 'test.not-enabled',
|
||||
connector_type_id: 'test.not-enabled',
|
||||
config: {},
|
||||
id: 'uuid-actionId',
|
||||
isPreconfigured: false,
|
||||
isDeprecated: false,
|
||||
isMissingSecrets: false,
|
||||
isSystemAction: false,
|
||||
is_preconfigured: false,
|
||||
is_deprecated: false,
|
||||
is_missing_secrets: false,
|
||||
is_system_action: false,
|
||||
name: 'an action created before test.not-enabled was disabled',
|
||||
});
|
||||
});
|
||||
|
||||
it('should handle delete action request with disabled actionType appropriately', async () => {
|
||||
it('should handle delete connector request with disabled connector type appropriately', async () => {
|
||||
let response;
|
||||
|
||||
response = await supertest
|
||||
.delete(`/api/actions/action/${PREWRITTEN_ACTION_ID}`)
|
||||
.delete(`/api/actions/connector/${PREWRITTEN_CONNECTOR_ID}`)
|
||||
.set('kbn-xsrf', 'foo');
|
||||
expect(response.status).to.eql(204);
|
||||
|
||||
response = await supertest.get(`/api/actions/action/${PREWRITTEN_ACTION_ID}`);
|
||||
response = await supertest.get(`/api/actions/connector/${PREWRITTEN_CONNECTOR_ID}`);
|
||||
expect(response.status).to.eql(404);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -11,7 +11,7 @@ import { checkAAD, getUrlPrefix, ObjectRemover } from '../../../common/lib';
|
|||
import { FtrProviderContext } from '../../../common/ftr_provider_context';
|
||||
|
||||
// eslint-disable-next-line import/no-default-export
|
||||
export default function updateActionTests({ getService }: FtrProviderContext) {
|
||||
export default function updateConnectorTests({ getService }: FtrProviderContext) {
|
||||
const supertest = getService('supertest');
|
||||
|
||||
describe('update', () => {
|
||||
|
@ -19,12 +19,12 @@ export default function updateActionTests({ getService }: FtrProviderContext) {
|
|||
|
||||
after(() => objectRemover.removeAll());
|
||||
|
||||
it('should handle update action request appropriately', async () => {
|
||||
const { body: createdAction } = await supertest
|
||||
it('should handle update connector request appropriately', async () => {
|
||||
const { body: createdConnector } = await supertest
|
||||
.post(`${getUrlPrefix(Spaces.space1.id)}/api/actions/connector`)
|
||||
.set('kbn-xsrf', 'foo')
|
||||
.send({
|
||||
name: 'My action',
|
||||
name: 'My connector',
|
||||
connector_type_id: 'test.index-record',
|
||||
config: {
|
||||
unencrypted: `This value shouldn't get encrypted`,
|
||||
|
@ -34,13 +34,13 @@ export default function updateActionTests({ getService }: FtrProviderContext) {
|
|||
},
|
||||
})
|
||||
.expect(200);
|
||||
objectRemover.add(Spaces.space1.id, createdAction.id, 'action', 'actions');
|
||||
objectRemover.add(Spaces.space1.id, createdConnector.id, 'connector', 'actions');
|
||||
|
||||
await supertest
|
||||
.put(`${getUrlPrefix(Spaces.space1.id)}/api/actions/connector/${createdAction.id}`)
|
||||
.put(`${getUrlPrefix(Spaces.space1.id)}/api/actions/connector/${createdConnector.id}`)
|
||||
.set('kbn-xsrf', 'foo')
|
||||
.send({
|
||||
name: 'My action updated',
|
||||
name: 'My connector updated',
|
||||
config: {
|
||||
unencrypted: `This value shouldn't get encrypted`,
|
||||
},
|
||||
|
@ -49,13 +49,13 @@ export default function updateActionTests({ getService }: FtrProviderContext) {
|
|||
},
|
||||
})
|
||||
.expect(200, {
|
||||
id: createdAction.id,
|
||||
id: createdConnector.id,
|
||||
is_preconfigured: false,
|
||||
is_system_action: false,
|
||||
is_deprecated: false,
|
||||
connector_type_id: 'test.index-record',
|
||||
is_missing_secrets: false,
|
||||
name: 'My action updated',
|
||||
name: 'My connector updated',
|
||||
config: {
|
||||
unencrypted: `This value shouldn't get encrypted`,
|
||||
},
|
||||
|
@ -66,16 +66,16 @@ export default function updateActionTests({ getService }: FtrProviderContext) {
|
|||
supertest,
|
||||
spaceId: Spaces.space1.id,
|
||||
type: 'action',
|
||||
id: createdAction.id,
|
||||
id: createdConnector.id,
|
||||
});
|
||||
});
|
||||
|
||||
it(`shouldn't update action from another space`, async () => {
|
||||
const { body: createdAction } = await supertest
|
||||
it(`shouldn't update connector from another space`, async () => {
|
||||
const { body: createdConnector } = await supertest
|
||||
.post(`${getUrlPrefix(Spaces.space1.id)}/api/actions/connector`)
|
||||
.set('kbn-xsrf', 'foo')
|
||||
.send({
|
||||
name: 'My action',
|
||||
name: 'My connector',
|
||||
connector_type_id: 'test.index-record',
|
||||
config: {
|
||||
unencrypted: `This value shouldn't get encrypted`,
|
||||
|
@ -85,13 +85,13 @@ export default function updateActionTests({ getService }: FtrProviderContext) {
|
|||
},
|
||||
})
|
||||
.expect(200);
|
||||
objectRemover.add(Spaces.space1.id, createdAction.id, 'action', 'actions');
|
||||
objectRemover.add(Spaces.space1.id, createdConnector.id, 'connector', 'actions');
|
||||
|
||||
await supertest
|
||||
.put(`${getUrlPrefix(Spaces.other.id)}/api/actions/action/${createdAction.id}`)
|
||||
.put(`${getUrlPrefix(Spaces.other.id)}/api/actions/connector/${createdConnector.id}`)
|
||||
.set('kbn-xsrf', 'foo')
|
||||
.send({
|
||||
name: 'My action updated',
|
||||
name: 'My connector updated',
|
||||
config: {
|
||||
unencrypted: `This value shouldn't get encrypted`,
|
||||
},
|
||||
|
@ -102,7 +102,7 @@ export default function updateActionTests({ getService }: FtrProviderContext) {
|
|||
.expect(404, {
|
||||
statusCode: 404,
|
||||
error: 'Not Found',
|
||||
message: `Saved object [action/${createdAction.id}] not found`,
|
||||
message: `Saved object [action/${createdConnector.id}] not found`,
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -111,7 +111,7 @@ export default function updateActionTests({ getService }: FtrProviderContext) {
|
|||
.put(`${getUrlPrefix(Spaces.space1.id)}/api/actions/connector/custom-system-abc-connector`)
|
||||
.set('kbn-xsrf', 'foo')
|
||||
.send({
|
||||
name: 'My action updated',
|
||||
name: 'My connector updated',
|
||||
config: {
|
||||
unencrypted: `This value shouldn't get encrypted`,
|
||||
},
|
||||
|
@ -135,7 +135,7 @@ export default function updateActionTests({ getService }: FtrProviderContext) {
|
|||
)
|
||||
.set('kbn-xsrf', 'foo')
|
||||
.send({
|
||||
name: 'My action updated',
|
||||
name: 'My connector updated',
|
||||
config: {
|
||||
unencrypted: `This value shouldn't get encrypted`,
|
||||
},
|
||||
|
@ -150,25 +150,25 @@ export default function updateActionTests({ getService }: FtrProviderContext) {
|
|||
});
|
||||
});
|
||||
|
||||
it('should notify feature usage when editing a gold action type', async () => {
|
||||
const { body: createdAction } = await supertest
|
||||
it('should notify feature usage when editing a gold connector type', async () => {
|
||||
const { body: createdConnector } = await supertest
|
||||
.post(`${getUrlPrefix(Spaces.space1.id)}/api/actions/connector`)
|
||||
.set('kbn-xsrf', 'foo')
|
||||
.send({
|
||||
name: 'Noop action type',
|
||||
name: 'Noop connector type',
|
||||
connector_type_id: 'test.noop',
|
||||
secrets: {},
|
||||
config: {},
|
||||
})
|
||||
.expect(200);
|
||||
objectRemover.add(Spaces.space1.id, createdAction.id, 'action', 'actions');
|
||||
objectRemover.add(Spaces.space1.id, createdConnector.id, 'connector', 'actions');
|
||||
|
||||
const updateStart = new Date();
|
||||
await supertest
|
||||
.put(`${getUrlPrefix(Spaces.space1.id)}/api/actions/connector/${createdAction.id}`)
|
||||
.put(`${getUrlPrefix(Spaces.space1.id)}/api/actions/connector/${createdConnector.id}`)
|
||||
.set('kbn-xsrf', 'foo')
|
||||
.send({
|
||||
name: 'Noop action type updated',
|
||||
name: 'Noop connector type updated',
|
||||
secrets: {},
|
||||
config: {},
|
||||
})
|
||||
|
@ -186,7 +186,7 @@ export default function updateActionTests({ getService }: FtrProviderContext) {
|
|||
expect(new Date(noopFeature.last_used).getTime()).to.be.greaterThan(updateStart.getTime());
|
||||
});
|
||||
|
||||
it('should handle update action request appropriately when empty strings are submitted', async () => {
|
||||
it('should handle update connector request appropriately when empty strings are submitted', async () => {
|
||||
await supertest
|
||||
.put(`${getUrlPrefix(Spaces.space1.id)}/api/actions/connector/custom-system-abc-connector`)
|
||||
.set('kbn-xsrf', 'foo')
|
||||
|
@ -205,174 +205,5 @@ export default function updateActionTests({ getService }: FtrProviderContext) {
|
|||
message: `[request body.name]: value '' is not valid`,
|
||||
});
|
||||
});
|
||||
|
||||
describe('legacy', () => {
|
||||
it('should handle update action request appropriately', async () => {
|
||||
const { body: createdAction } = await supertest
|
||||
.post(`${getUrlPrefix(Spaces.space1.id)}/api/actions/action`)
|
||||
.set('kbn-xsrf', 'foo')
|
||||
.send({
|
||||
name: 'My action',
|
||||
actionTypeId: 'test.index-record',
|
||||
config: {
|
||||
unencrypted: `This value shouldn't get encrypted`,
|
||||
},
|
||||
secrets: {
|
||||
encrypted: 'This value should be encrypted',
|
||||
},
|
||||
})
|
||||
.expect(200);
|
||||
objectRemover.add(Spaces.space1.id, createdAction.id, 'action', 'actions');
|
||||
|
||||
await supertest
|
||||
.put(`${getUrlPrefix(Spaces.space1.id)}/api/actions/action/${createdAction.id}`)
|
||||
.set('kbn-xsrf', 'foo')
|
||||
.send({
|
||||
name: 'My action updated',
|
||||
config: {
|
||||
unencrypted: `This value shouldn't get encrypted`,
|
||||
},
|
||||
secrets: {
|
||||
encrypted: 'This value should be encrypted',
|
||||
},
|
||||
})
|
||||
.expect(200, {
|
||||
id: createdAction.id,
|
||||
isPreconfigured: false,
|
||||
isDeprecated: false,
|
||||
isSystemAction: false,
|
||||
actionTypeId: 'test.index-record',
|
||||
isMissingSecrets: false,
|
||||
name: 'My action updated',
|
||||
config: {
|
||||
unencrypted: `This value shouldn't get encrypted`,
|
||||
},
|
||||
});
|
||||
|
||||
// Ensure AAD isn't broken
|
||||
await checkAAD({
|
||||
supertest,
|
||||
spaceId: Spaces.space1.id,
|
||||
type: 'action',
|
||||
id: createdAction.id,
|
||||
});
|
||||
});
|
||||
|
||||
it(`shouldn't update action from another space`, async () => {
|
||||
const { body: createdAction } = await supertest
|
||||
.post(`${getUrlPrefix(Spaces.space1.id)}/api/actions/action`)
|
||||
.set('kbn-xsrf', 'foo')
|
||||
.send({
|
||||
name: 'My action',
|
||||
actionTypeId: 'test.index-record',
|
||||
config: {
|
||||
unencrypted: `This value shouldn't get encrypted`,
|
||||
},
|
||||
secrets: {
|
||||
encrypted: 'This value should be encrypted',
|
||||
},
|
||||
})
|
||||
.expect(200);
|
||||
objectRemover.add(Spaces.space1.id, createdAction.id, 'action', 'actions');
|
||||
|
||||
await supertest
|
||||
.put(`${getUrlPrefix(Spaces.other.id)}/api/actions/action/${createdAction.id}`)
|
||||
.set('kbn-xsrf', 'foo')
|
||||
.send({
|
||||
name: 'My action updated',
|
||||
config: {
|
||||
unencrypted: `This value shouldn't get encrypted`,
|
||||
},
|
||||
secrets: {
|
||||
encrypted: 'This value should be encrypted',
|
||||
},
|
||||
})
|
||||
.expect(404, {
|
||||
statusCode: 404,
|
||||
error: 'Not Found',
|
||||
message: `Saved object [action/${createdAction.id}] not found`,
|
||||
});
|
||||
});
|
||||
|
||||
it(`shouldn't update a preconfigured connector`, async () => {
|
||||
await supertest
|
||||
.put(`${getUrlPrefix(Spaces.space1.id)}/api/actions/action/custom-system-abc-connector`)
|
||||
.set('kbn-xsrf', 'foo')
|
||||
.send({
|
||||
name: 'My action updated',
|
||||
config: {
|
||||
unencrypted: `This value shouldn't get encrypted`,
|
||||
},
|
||||
secrets: {
|
||||
encrypted: 'This value should be encrypted',
|
||||
},
|
||||
})
|
||||
.expect(400, {
|
||||
statusCode: 400,
|
||||
error: 'Bad Request',
|
||||
message: `Preconfigured action custom-system-abc-connector can not be updated.`,
|
||||
});
|
||||
});
|
||||
|
||||
it(`shouldn't update a system connector`, async () => {
|
||||
await supertest
|
||||
.put(
|
||||
`${getUrlPrefix(
|
||||
Spaces.space1.id
|
||||
)}/api/actions/action/system-connector-test.system-action`
|
||||
)
|
||||
.set('kbn-xsrf', 'foo')
|
||||
.send({
|
||||
name: 'My action updated',
|
||||
config: {
|
||||
unencrypted: `This value shouldn't get encrypted`,
|
||||
},
|
||||
secrets: {
|
||||
encrypted: 'This value should be encrypted',
|
||||
},
|
||||
})
|
||||
.expect(400, {
|
||||
statusCode: 400,
|
||||
error: 'Bad Request',
|
||||
message: 'System action system-connector-test.system-action can not be updated.',
|
||||
});
|
||||
});
|
||||
|
||||
it('should notify feature usage when editing a gold action type', async () => {
|
||||
const { body: createdAction } = await supertest
|
||||
.post(`${getUrlPrefix(Spaces.space1.id)}/api/actions/action`)
|
||||
.set('kbn-xsrf', 'foo')
|
||||
.send({
|
||||
name: 'Noop action type',
|
||||
actionTypeId: 'test.noop',
|
||||
secrets: {},
|
||||
config: {},
|
||||
})
|
||||
.expect(200);
|
||||
objectRemover.add(Spaces.space1.id, createdAction.id, 'action', 'actions');
|
||||
|
||||
const updateStart = new Date();
|
||||
await supertest
|
||||
.put(`${getUrlPrefix(Spaces.space1.id)}/api/actions/action/${createdAction.id}`)
|
||||
.set('kbn-xsrf', 'foo')
|
||||
.send({
|
||||
name: 'Noop action type updated',
|
||||
secrets: {},
|
||||
config: {},
|
||||
})
|
||||
.expect(200);
|
||||
|
||||
const {
|
||||
body: { features },
|
||||
} = await supertest.get(`${getUrlPrefix(Spaces.space1.id)}/api/licensing/feature_usage`);
|
||||
expect(features).to.be.an(Array);
|
||||
const noopFeature = features.find(
|
||||
(feature: { name: string }) => feature.name === 'Connector: Test: Noop'
|
||||
);
|
||||
expect(noopFeature).to.be.ok();
|
||||
expect(noopFeature.last_used).to.be.a('string');
|
||||
expect(new Date(noopFeature.last_used).getTime()).to.be.greaterThan(updateStart.getTime());
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
@ -369,7 +369,7 @@ export default function eventLogTests({ getService }: FtrProviderContext) {
|
|||
secrets: {},
|
||||
})
|
||||
.expect(200);
|
||||
objectRemover.add(space.id, createdAction.id, 'action', 'actions');
|
||||
objectRemover.add(space.id, createdAction.id, 'connector', 'actions');
|
||||
|
||||
const response = await supertest
|
||||
.post(`${getUrlPrefix(space.id)}/api/alerting/rule`)
|
||||
|
@ -1837,7 +1837,7 @@ export default function eventLogTests({ getService }: FtrProviderContext) {
|
|||
secrets: {},
|
||||
})
|
||||
.expect(200);
|
||||
objectRemover.add(space.id, createdAction.id, 'action', 'actions');
|
||||
objectRemover.add(space.id, createdAction.id, 'connector', 'actions');
|
||||
|
||||
const { body: createdRule } = await supertest
|
||||
.post(`${getUrlPrefix(space.id)}/api/alerting/rule`)
|
||||
|
|
|
@ -75,7 +75,7 @@ export default function createGetActionErrorLogTests({ getService }: FtrProvider
|
|||
secrets: {},
|
||||
})
|
||||
.expect(200);
|
||||
objectRemover.add(Spaces.space1.id, createdConnector.id, 'action', 'actions');
|
||||
objectRemover.add(Spaces.space1.id, createdConnector.id, 'connector', 'actions');
|
||||
|
||||
const { body: createdRule } = await supertest
|
||||
.post(`${getUrlPrefix(Spaces.space1.id)}/api/alerting/rule`)
|
||||
|
@ -126,7 +126,7 @@ export default function createGetActionErrorLogTests({ getService }: FtrProvider
|
|||
secrets: {},
|
||||
})
|
||||
.expect(200);
|
||||
objectRemover.add(Spaces.space1.id, createdConnector1.id, 'action', 'actions');
|
||||
objectRemover.add(Spaces.space1.id, createdConnector1.id, 'connector', 'actions');
|
||||
|
||||
const { body: createdConnector2 } = await supertest
|
||||
.post(`${getUrlPrefix(Spaces.space1.id)}/api/actions/connector`)
|
||||
|
@ -138,7 +138,7 @@ export default function createGetActionErrorLogTests({ getService }: FtrProvider
|
|||
secrets: {},
|
||||
})
|
||||
.expect(200);
|
||||
objectRemover.add(Spaces.space1.id, createdConnector2.id, 'action', 'actions');
|
||||
objectRemover.add(Spaces.space1.id, createdConnector2.id, 'connector', 'actions');
|
||||
|
||||
const { body: createdRule } = await supertest
|
||||
.post(`${getUrlPrefix(Spaces.space1.id)}/api/alerting/rule`)
|
||||
|
|
|
@ -276,7 +276,7 @@ export default function createGetExecutionLogTests({ getService }: FtrProviderCo
|
|||
secrets: {},
|
||||
})
|
||||
.expect(200);
|
||||
objectRemover.add(Spaces.space1.id, createdConnector.id, 'action', 'actions');
|
||||
objectRemover.add(Spaces.space1.id, createdConnector.id, 'connector', 'actions');
|
||||
const { body: createdRule } = await supertest
|
||||
.post(`${getUrlPrefix(Spaces.space1.id)}/api/alerting/rule`)
|
||||
.set('kbn-xsrf', 'foo')
|
||||
|
@ -335,7 +335,7 @@ export default function createGetExecutionLogTests({ getService }: FtrProviderCo
|
|||
secrets: {},
|
||||
})
|
||||
.expect(200);
|
||||
objectRemover.add(Spaces.space1.id, createdConnector.id, 'action', 'actions');
|
||||
objectRemover.add(Spaces.space1.id, createdConnector.id, 'connector', 'actions');
|
||||
const { body: createdRule } = await supertest
|
||||
.post(`${getUrlPrefix(Spaces.space1.id)}/api/alerting/rule`)
|
||||
.set('kbn-xsrf', 'foo')
|
||||
|
|
|
@ -81,7 +81,7 @@ export const createAction = async ({
|
|||
})
|
||||
.expect(200);
|
||||
|
||||
objectRemover.add(Spaces.space1.id, createdAction.id, 'action', 'actions');
|
||||
objectRemover.add(Spaces.space1.id, createdAction.id, 'connector', 'actions');
|
||||
return createdAction;
|
||||
};
|
||||
|
||||
|
|
|
@ -76,11 +76,11 @@ export default function ruleTests({ getService }: FtrProviderContext) {
|
|||
}
|
||||
|
||||
async function createRule(params: CreateRuleParams) {
|
||||
const { body: createdAction } = await supertest
|
||||
const { body: createdConnector } = await supertest
|
||||
.post(`${getUrlPrefix(Spaces.space1.id)}/api/actions/connector`)
|
||||
.set('kbn-xsrf', 'foo')
|
||||
.send({
|
||||
name: 'My action',
|
||||
name: 'My Connector',
|
||||
connector_type_id: 'test.index-record',
|
||||
config: {
|
||||
unencrypted: `This value shouldn't get encrypted`,
|
||||
|
@ -90,7 +90,7 @@ export default function ruleTests({ getService }: FtrProviderContext) {
|
|||
},
|
||||
})
|
||||
.expect(200);
|
||||
objectRemover.add(Spaces.space1.id, createdAction.id, 'action', 'actions');
|
||||
objectRemover.add(Spaces.space1.id, createdConnector.id, 'connector', 'actions');
|
||||
|
||||
const { status, body: createdRule } = await supertest
|
||||
.post(`${getUrlPrefix(Spaces.space1.id)}/api/alerting/rule`)
|
||||
|
@ -104,7 +104,7 @@ export default function ruleTests({ getService }: FtrProviderContext) {
|
|||
actions: [
|
||||
{
|
||||
group: 'default',
|
||||
id: createdAction.id,
|
||||
id: createdConnector.id,
|
||||
params: {
|
||||
index: ES_TEST_INDEX_NAME,
|
||||
reference: '',
|
||||
|
@ -113,7 +113,7 @@ export default function ruleTests({ getService }: FtrProviderContext) {
|
|||
},
|
||||
{
|
||||
group: RecoveredActionGroup.id,
|
||||
id: createdAction.id,
|
||||
id: createdConnector.id,
|
||||
params: {
|
||||
index: ES_TEST_INDEX_NAME,
|
||||
reference: '',
|
||||
|
|
|
@ -15,46 +15,46 @@ export default function createCappedActionsTests({ getService }: FtrProviderCont
|
|||
const supertest = getService('supertest');
|
||||
const retry = getService('retry');
|
||||
|
||||
describe('Capped action type', () => {
|
||||
describe('Capped connector type', () => {
|
||||
const objectRemover = new ObjectRemover(supertest);
|
||||
|
||||
after(() => objectRemover.removeAll());
|
||||
|
||||
it('should not trigger actions more than connector types limit', async () => {
|
||||
const { body: createdAction01 } = await supertest
|
||||
const { body: createdConnector01 } = await supertest
|
||||
.post(`${getUrlPrefix(Spaces.space1.id)}/api/actions/connector`)
|
||||
.set('kbn-xsrf', 'foo')
|
||||
.send({
|
||||
name: 'MY action',
|
||||
name: 'MY Connector',
|
||||
connector_type_id: 'test.capped',
|
||||
config: {},
|
||||
secrets: {},
|
||||
})
|
||||
.expect(200);
|
||||
const { body: createdAction02 } = await supertest
|
||||
const { body: createdConnector02 } = await supertest
|
||||
.post(`${getUrlPrefix(Spaces.space1.id)}/api/actions/connector`)
|
||||
.set('kbn-xsrf', 'foo')
|
||||
.send({
|
||||
name: 'MY action',
|
||||
name: 'MY Connector',
|
||||
connector_type_id: 'test.capped',
|
||||
config: {},
|
||||
secrets: {},
|
||||
})
|
||||
.expect(200);
|
||||
const { body: createdAction03 } = await supertest
|
||||
const { body: createdConnector03 } = await supertest
|
||||
.post(`${getUrlPrefix(Spaces.space1.id)}/api/actions/connector`)
|
||||
.set('kbn-xsrf', 'foo')
|
||||
.send({
|
||||
name: 'MY action',
|
||||
name: 'MY Connector',
|
||||
connector_type_id: 'test.capped',
|
||||
config: {},
|
||||
secrets: {},
|
||||
})
|
||||
.expect(200);
|
||||
|
||||
objectRemover.add(Spaces.space1.id, createdAction01.id, 'action', 'actions');
|
||||
objectRemover.add(Spaces.space1.id, createdAction02.id, 'action', 'actions');
|
||||
objectRemover.add(Spaces.space1.id, createdAction03.id, 'action', 'actions');
|
||||
objectRemover.add(Spaces.space1.id, createdConnector01.id, 'connector', 'actions');
|
||||
objectRemover.add(Spaces.space1.id, createdConnector02.id, 'connector', 'actions');
|
||||
objectRemover.add(Spaces.space1.id, createdConnector03.id, 'connector', 'actions');
|
||||
|
||||
const { body: createdRule } = await supertest
|
||||
.post(`${getUrlPrefix(Spaces.space1.id)}/api/alerting/rule`)
|
||||
|
@ -71,17 +71,17 @@ export default function createCappedActionsTests({ getService }: FtrProviderCont
|
|||
},
|
||||
actions: [
|
||||
{
|
||||
id: createdAction01.id,
|
||||
id: createdConnector01.id,
|
||||
group: 'default',
|
||||
params: {},
|
||||
},
|
||||
{
|
||||
id: createdAction02.id,
|
||||
id: createdConnector02.id,
|
||||
group: 'default',
|
||||
params: {},
|
||||
},
|
||||
{
|
||||
id: createdAction03.id,
|
||||
id: createdConnector03.id,
|
||||
group: 'default',
|
||||
params: {},
|
||||
},
|
||||
|
|
|
@ -57,7 +57,7 @@ export default function createNotifyWhenTests({ getService }: FtrProviderContext
|
|||
}
|
||||
const createdActions = await Promise.all(actionPromises);
|
||||
createdActions.forEach((createdAction) =>
|
||||
objectRemover.add(Spaces.space1.id, createdAction.body.id, 'action', 'actions')
|
||||
objectRemover.add(Spaces.space1.id, createdAction.body.id, 'connector', 'actions')
|
||||
);
|
||||
|
||||
const pattern = {
|
||||
|
|
|
@ -46,17 +46,17 @@ export default function createSnoozeRuleTests({ getService }: FtrProviderContext
|
|||
describe('handle snooze rule request appropriately', function () {
|
||||
this.tags('skipFIPS');
|
||||
it('should handle snooze rule request appropriately', async () => {
|
||||
const { body: createdAction } = await supertest
|
||||
const { body: createdConnector } = await supertest
|
||||
.post(`${getUrlPrefix(Spaces.space1.id)}/api/actions/connector`)
|
||||
.set('kbn-xsrf', 'foo')
|
||||
.send({
|
||||
name: 'MY action',
|
||||
name: 'MY Connector',
|
||||
connector_type_id: 'test.noop',
|
||||
config: {},
|
||||
secrets: {},
|
||||
})
|
||||
.expect(200);
|
||||
objectRemover.add(Spaces.space1.id, createdAction.id, 'action', 'actions');
|
||||
objectRemover.add(Spaces.space1.id, createdConnector.id, 'connector', 'actions');
|
||||
|
||||
const { body: createdRule } = await supertest
|
||||
.post(`${getUrlPrefix(Spaces.space1.id)}/api/alerting/rule`)
|
||||
|
@ -66,7 +66,7 @@ export default function createSnoozeRuleTests({ getService }: FtrProviderContext
|
|||
enabled: false,
|
||||
actions: [
|
||||
{
|
||||
id: createdAction.id,
|
||||
id: createdConnector.id,
|
||||
group: 'default',
|
||||
params: {},
|
||||
},
|
||||
|
@ -104,17 +104,17 @@ export default function createSnoozeRuleTests({ getService }: FtrProviderContext
|
|||
describe('handle snooze rule request appropriately when duration is -1', function () {
|
||||
this.tags('skipFIPS');
|
||||
it('should handle snooze rule request appropriately when duration is -1', async () => {
|
||||
const { body: createdAction } = await supertest
|
||||
const { body: createdConnector } = await supertest
|
||||
.post(`${getUrlPrefix(Spaces.space1.id)}/api/actions/connector`)
|
||||
.set('kbn-xsrf', 'foo')
|
||||
.send({
|
||||
name: 'MY action',
|
||||
name: 'MY Connector',
|
||||
connector_type_id: 'test.noop',
|
||||
config: {},
|
||||
secrets: {},
|
||||
})
|
||||
.expect(200);
|
||||
objectRemover.add(Spaces.space1.id, createdAction.id, 'action', 'actions');
|
||||
objectRemover.add(Spaces.space1.id, createdConnector.id, 'connector', 'actions');
|
||||
|
||||
const { body: createdRule } = await supertest
|
||||
.post(`${getUrlPrefix(Spaces.space1.id)}/api/alerting/rule`)
|
||||
|
@ -124,7 +124,7 @@ export default function createSnoozeRuleTests({ getService }: FtrProviderContext
|
|||
enabled: false,
|
||||
actions: [
|
||||
{
|
||||
id: createdAction.id,
|
||||
id: createdConnector.id,
|
||||
group: 'default',
|
||||
params: {},
|
||||
},
|
||||
|
@ -160,17 +160,17 @@ export default function createSnoozeRuleTests({ getService }: FtrProviderContext
|
|||
});
|
||||
|
||||
it('should not trigger actions when snoozed', async () => {
|
||||
const { body: createdAction, status: connStatus } = await supertest
|
||||
const { body: createdConnector, status: connStatus } = await supertest
|
||||
.post(`${getUrlPrefix(Spaces.space1.id)}/api/actions/connector`)
|
||||
.set('kbn-xsrf', 'foo')
|
||||
.send({
|
||||
name: 'MY action',
|
||||
name: 'MY Connector',
|
||||
connector_type_id: 'test.noop',
|
||||
config: {},
|
||||
secrets: {},
|
||||
});
|
||||
expect(connStatus).to.be(200);
|
||||
objectRemover.add(Spaces.space1.id, createdAction.id, 'action', 'actions');
|
||||
objectRemover.add(Spaces.space1.id, createdConnector.id, 'connector', 'actions');
|
||||
|
||||
log.info('creating rule');
|
||||
const { body: createdRule, status: ruleStatus } = await supertest
|
||||
|
@ -188,7 +188,7 @@ export default function createSnoozeRuleTests({ getService }: FtrProviderContext
|
|||
},
|
||||
actions: [
|
||||
{
|
||||
id: createdAction.id,
|
||||
id: createdConnector.id,
|
||||
group: 'default',
|
||||
params: {},
|
||||
},
|
||||
|
@ -328,17 +328,17 @@ export default function createSnoozeRuleTests({ getService }: FtrProviderContext
|
|||
describe('clear the snooze after it expires', function () {
|
||||
this.tags('skipFIPS');
|
||||
it('should clear the snooze after it expires', async () => {
|
||||
const { body: createdAction } = await supertest
|
||||
const { body: createdConnector } = await supertest
|
||||
.post(`${getUrlPrefix(Spaces.space1.id)}/api/actions/connector`)
|
||||
.set('kbn-xsrf', 'foo')
|
||||
.send({
|
||||
name: 'MY action',
|
||||
name: 'MY Connector',
|
||||
connector_type_id: 'test.noop',
|
||||
config: {},
|
||||
secrets: {},
|
||||
})
|
||||
.expect(200);
|
||||
objectRemover.add(Spaces.space1.id, createdAction.id, 'action', 'actions');
|
||||
objectRemover.add(Spaces.space1.id, createdConnector.id, 'connector', 'actions');
|
||||
|
||||
const { body: createdRule } = await supertest
|
||||
.post(`${getUrlPrefix(Spaces.space1.id)}/api/alerting/rule`)
|
||||
|
@ -355,7 +355,7 @@ export default function createSnoozeRuleTests({ getService }: FtrProviderContext
|
|||
},
|
||||
actions: [
|
||||
{
|
||||
id: createdAction.id,
|
||||
id: createdConnector.id,
|
||||
group: 'default',
|
||||
params: {},
|
||||
},
|
||||
|
|
|
@ -21,7 +21,7 @@ import { createTlsWebhookServer } from '../../../../../common/lib/get_tls_webhoo
|
|||
export default function webhookTest({ getService }: FtrProviderContext) {
|
||||
const supertest = getService('supertest');
|
||||
|
||||
async function createWebhookAction(
|
||||
async function createWebhookConnector(
|
||||
webhookSimulatorURL: string,
|
||||
config: Record<string, string | Record<string, string>> = {}
|
||||
): Promise<string> {
|
||||
|
@ -34,18 +34,18 @@ export default function webhookTest({ getService }: FtrProviderContext) {
|
|||
url,
|
||||
};
|
||||
|
||||
const { body: createdAction } = await supertest
|
||||
.post('/api/actions/action')
|
||||
const { body: createdConnector } = await supertest
|
||||
.post('/api/actions/connector')
|
||||
.set('kbn-xsrf', 'test')
|
||||
.send({
|
||||
name: 'A generic Webhook action',
|
||||
actionTypeId: '.webhook',
|
||||
name: 'A generic Webhook connector',
|
||||
connector_type_id: '.webhook',
|
||||
secrets: {},
|
||||
config: composedConfig,
|
||||
})
|
||||
.expect(200);
|
||||
|
||||
return createdAction.id;
|
||||
return createdConnector.id;
|
||||
}
|
||||
|
||||
async function getPortOfConnector(connectorId: string): Promise<string> {
|
||||
|
@ -61,7 +61,7 @@ export default function webhookTest({ getService }: FtrProviderContext) {
|
|||
return parsedUrl.port;
|
||||
}
|
||||
|
||||
describe('webhook action', () => {
|
||||
describe('webhook connector', () => {
|
||||
describe('with http endpoint', () => {
|
||||
let webhookSimulatorURL: string = '';
|
||||
let webhookServer: http.Server;
|
||||
|
@ -73,9 +73,9 @@ export default function webhookTest({ getService }: FtrProviderContext) {
|
|||
});
|
||||
|
||||
it('webhook can be executed without username and password', async () => {
|
||||
const webhookActionId = await createWebhookAction(webhookSimulatorURL);
|
||||
const webhookConnectorId = await createWebhookConnector(webhookSimulatorURL);
|
||||
const { body: result } = await supertest
|
||||
.post(`/api/actions/action/${webhookActionId}/_execute`)
|
||||
.post(`/api/actions/connector/${webhookConnectorId}/_execute`)
|
||||
.set('kbn-xsrf', 'test')
|
||||
.send({
|
||||
params: {
|
||||
|
@ -104,9 +104,11 @@ export default function webhookTest({ getService }: FtrProviderContext) {
|
|||
});
|
||||
|
||||
it('should support the POST method against webhook target', async () => {
|
||||
const webhookActionId = await createWebhookAction(webhookSimulatorURL, { method: 'post' });
|
||||
const webhookConnectorId = await createWebhookConnector(webhookSimulatorURL, {
|
||||
method: 'post',
|
||||
});
|
||||
const { body: result } = await supertest
|
||||
.post(`/api/actions/action/${webhookActionId}/_execute`)
|
||||
.post(`/api/actions/connector/${webhookConnectorId}/_execute`)
|
||||
.set('kbn-xsrf', 'test')
|
||||
.send({
|
||||
params: {
|
||||
|
|
|
@ -236,7 +236,7 @@ export const createCaseWithConnector = async ({
|
|||
auth: auth ?? undefined,
|
||||
});
|
||||
|
||||
actionsRemover.add(auth?.space ?? 'default', connector.id, 'action', 'actions');
|
||||
actionsRemover.add(auth?.space ?? 'default', connector.id, 'connector', 'actions');
|
||||
|
||||
const [configuration, postedCase] = await Promise.all([
|
||||
createConfiguration(
|
||||
|
|
|
@ -144,7 +144,7 @@ export default ({ getService }: FtrProviderContext): void => {
|
|||
.set('kbn-xsrf', 'true')
|
||||
.expect(200);
|
||||
|
||||
actionsRemover.add('default', '51a4cbe0-5cea-11ec-a615-15461784e410', 'action', 'actions');
|
||||
actionsRemover.add('default', '51a4cbe0-5cea-11ec-a615-15461784e410', 'connector', 'actions');
|
||||
|
||||
await expectImportToHaveOneCase(supertestService);
|
||||
|
||||
|
|
|
@ -359,7 +359,7 @@ export default ({ getService }: FtrProviderContext): void => {
|
|||
},
|
||||
});
|
||||
|
||||
actionsRemover.add('default', newConnector.id, 'action', 'actions');
|
||||
actionsRemover.add('default', newConnector.id, 'connector', 'actions');
|
||||
await updateCase({
|
||||
supertest,
|
||||
params: {
|
||||
|
@ -399,7 +399,7 @@ export default ({ getService }: FtrProviderContext): void => {
|
|||
},
|
||||
});
|
||||
|
||||
actionsRemover.add('default', connector.id, 'action', 'actions');
|
||||
actionsRemover.add('default', connector.id, 'connector', 'actions');
|
||||
|
||||
const postedCase = await createCase(
|
||||
supertest,
|
||||
|
|
|
@ -53,7 +53,7 @@ export default ({ getService }: FtrProviderContext): void => {
|
|||
config: { apiUrl: serviceNowSimulatorURL },
|
||||
},
|
||||
});
|
||||
actionsRemover.add('default', connector.id, 'action', 'actions');
|
||||
actionsRemover.add('default', connector.id, 'connector', 'actions');
|
||||
|
||||
await createConfiguration(
|
||||
supertest,
|
||||
|
|
|
@ -48,13 +48,13 @@ export default ({ getService }: FtrProviderContext): void => {
|
|||
req: getCasesWebhookConnector(),
|
||||
});
|
||||
|
||||
actionsRemover.add('default', sir.id, 'action', 'actions');
|
||||
actionsRemover.add('default', snConnector.id, 'action', 'actions');
|
||||
actionsRemover.add('default', snOAuthConnector.id, 'action', 'actions');
|
||||
actionsRemover.add('default', emailConnector.id, 'action', 'actions');
|
||||
actionsRemover.add('default', jiraConnector.id, 'action', 'actions');
|
||||
actionsRemover.add('default', resilientConnector.id, 'action', 'actions');
|
||||
actionsRemover.add('default', casesWebhookConnector.id, 'action', 'actions');
|
||||
actionsRemover.add('default', sir.id, 'connector', 'actions');
|
||||
actionsRemover.add('default', snConnector.id, 'connector', 'actions');
|
||||
actionsRemover.add('default', snOAuthConnector.id, 'connector', 'actions');
|
||||
actionsRemover.add('default', emailConnector.id, 'connector', 'actions');
|
||||
actionsRemover.add('default', jiraConnector.id, 'connector', 'actions');
|
||||
actionsRemover.add('default', resilientConnector.id, 'connector', 'actions');
|
||||
actionsRemover.add('default', casesWebhookConnector.id, 'connector', 'actions');
|
||||
|
||||
const connectors = await getCaseConnectors({ supertest });
|
||||
const sortedConnectors = connectors.sort((a, b) => a.name.localeCompare(b.name));
|
||||
|
|
|
@ -57,7 +57,7 @@ export default ({ getService }: FtrProviderContext): void => {
|
|||
},
|
||||
});
|
||||
|
||||
actionsRemover.add('default', connector.id, 'action', 'actions');
|
||||
actionsRemover.add('default', connector.id, 'connector', 'actions');
|
||||
|
||||
// Configuration is created with no connector so the mappings are empty
|
||||
const configuration = await createConfiguration(supertest);
|
||||
|
@ -113,7 +113,7 @@ export default ({ getService }: FtrProviderContext): void => {
|
|||
},
|
||||
});
|
||||
|
||||
actionsRemover.add('default', connector.id, 'action', 'actions');
|
||||
actionsRemover.add('default', connector.id, 'connector', 'actions');
|
||||
|
||||
// Configuration is created with connector so the mappings are created
|
||||
const configuration = await createConfiguration(
|
||||
|
|
|
@ -56,7 +56,7 @@ export default ({ getService }: FtrProviderContext): void => {
|
|||
},
|
||||
});
|
||||
|
||||
actionsRemover.add('default', connector.id, 'action', 'actions');
|
||||
actionsRemover.add('default', connector.id, 'connector', 'actions');
|
||||
|
||||
const postRes = await createConfiguration(
|
||||
supertest,
|
||||
|
|
|
@ -90,7 +90,7 @@ export default ({ getService }: FtrProviderContext): void => {
|
|||
}),
|
||||
]);
|
||||
|
||||
actionsRemover.add('default', jiraConnector.id, 'action', 'actions');
|
||||
actionsRemover.add('default', jiraConnector.id, 'connector', 'actions');
|
||||
|
||||
const theCase = await pushCase({
|
||||
supertest,
|
||||
|
@ -163,7 +163,7 @@ export default ({ getService }: FtrProviderContext): void => {
|
|||
},
|
||||
});
|
||||
|
||||
actionsRemover.add('default', jiraConnector.id, 'action', 'actions');
|
||||
actionsRemover.add('default', jiraConnector.id, 'connector', 'actions');
|
||||
|
||||
await updateCase({
|
||||
supertest,
|
||||
|
@ -264,7 +264,7 @@ export default ({ getService }: FtrProviderContext): void => {
|
|||
},
|
||||
});
|
||||
|
||||
actionsRemover.add('default', serviceNow2.id, 'action', 'actions');
|
||||
actionsRemover.add('default', serviceNow2.id, 'connector', 'actions');
|
||||
|
||||
// change to serviceNow2 connector
|
||||
await updateCase({
|
||||
|
@ -566,7 +566,7 @@ export default ({ getService }: FtrProviderContext): void => {
|
|||
}),
|
||||
]);
|
||||
|
||||
actionsRemover.add('default', jiraConnector.id, 'action', 'actions');
|
||||
actionsRemover.add('default', jiraConnector.id, 'connector', 'actions');
|
||||
|
||||
await updateCase({
|
||||
supertest,
|
||||
|
@ -607,7 +607,7 @@ export default ({ getService }: FtrProviderContext): void => {
|
|||
},
|
||||
});
|
||||
|
||||
actionsRemover.add('default', serviceNowConnector.id, 'action', 'actions');
|
||||
actionsRemover.add('default', serviceNowConnector.id, 'connector', 'actions');
|
||||
|
||||
const updatedCasesServiceNow = await updateCase({
|
||||
supertest,
|
||||
|
|
|
@ -64,7 +64,7 @@ export default ({ getService }: FtrProviderContext): void => {
|
|||
}),
|
||||
]);
|
||||
|
||||
actionsRemover.add('default', jiraConnector.id, 'action', 'actions');
|
||||
actionsRemover.add('default', jiraConnector.id, 'connector', 'actions');
|
||||
|
||||
const theCase = await pushCase({
|
||||
supertest,
|
||||
|
|
|
@ -58,7 +58,7 @@ export default ({ getService }: FtrProviderContext): void => {
|
|||
},
|
||||
auth: authSpace1,
|
||||
});
|
||||
actionsRemover.add('space1', connector.id, 'action', 'actions');
|
||||
actionsRemover.add('space1', connector.id, 'connector', 'actions');
|
||||
|
||||
await createConfiguration(
|
||||
supertestWithoutAuth,
|
||||
|
@ -113,7 +113,7 @@ export default ({ getService }: FtrProviderContext): void => {
|
|||
},
|
||||
auth: authSpace1,
|
||||
});
|
||||
actionsRemover.add('space1', connector.id, 'action', 'actions');
|
||||
actionsRemover.add('space1', connector.id, 'connector', 'actions');
|
||||
|
||||
await createConfiguration(
|
||||
supertest,
|
||||
|
|
|
@ -77,13 +77,13 @@ export default ({ getService }: FtrProviderContext): void => {
|
|||
auth: authSpace1,
|
||||
});
|
||||
|
||||
actionsRemover.add(space, sir.id, 'action', 'actions');
|
||||
actionsRemover.add(space, snConnector.id, 'action', 'actions');
|
||||
actionsRemover.add(space, snOAuthConnector.id, 'action', 'actions');
|
||||
actionsRemover.add(space, emailConnector.id, 'action', 'actions');
|
||||
actionsRemover.add(space, jiraConnector.id, 'action', 'actions');
|
||||
actionsRemover.add(space, resilientConnector.id, 'action', 'actions');
|
||||
actionsRemover.add(space, casesWebhookConnector.id, 'action', 'actions');
|
||||
actionsRemover.add(space, sir.id, 'connector', 'actions');
|
||||
actionsRemover.add(space, snConnector.id, 'connector', 'actions');
|
||||
actionsRemover.add(space, snOAuthConnector.id, 'connector', 'actions');
|
||||
actionsRemover.add(space, emailConnector.id, 'connector', 'actions');
|
||||
actionsRemover.add(space, jiraConnector.id, 'connector', 'actions');
|
||||
actionsRemover.add(space, resilientConnector.id, 'connector', 'actions');
|
||||
actionsRemover.add(space, casesWebhookConnector.id, 'connector', 'actions');
|
||||
|
||||
const connectors = await getCaseConnectors({
|
||||
supertest: supertestWithoutAuth,
|
||||
|
@ -256,12 +256,12 @@ export default ({ getService }: FtrProviderContext): void => {
|
|||
auth: authSpace1,
|
||||
});
|
||||
|
||||
actionsRemover.add(space, sir.id, 'action', 'actions');
|
||||
actionsRemover.add(space, snConnector.id, 'action', 'actions');
|
||||
actionsRemover.add(space, snOAuthConnector.id, 'action', 'actions');
|
||||
actionsRemover.add(space, emailConnector.id, 'action', 'actions');
|
||||
actionsRemover.add(space, jiraConnector.id, 'action', 'actions');
|
||||
actionsRemover.add(space, resilientConnector.id, 'action', 'actions');
|
||||
actionsRemover.add(space, sir.id, 'connector', 'actions');
|
||||
actionsRemover.add(space, snConnector.id, 'connector', 'actions');
|
||||
actionsRemover.add(space, snOAuthConnector.id, 'connector', 'actions');
|
||||
actionsRemover.add(space, emailConnector.id, 'connector', 'actions');
|
||||
actionsRemover.add(space, jiraConnector.id, 'connector', 'actions');
|
||||
actionsRemover.add(space, resilientConnector.id, 'connector', 'actions');
|
||||
|
||||
const connectors = await getCaseConnectors({
|
||||
supertest: supertestWithoutAuth,
|
||||
|
|
|
@ -64,7 +64,7 @@ export default ({ getService }: FtrProviderContext): void => {
|
|||
auth: authSpace1,
|
||||
});
|
||||
|
||||
actionsRemover.add(space, connector.id, 'action', 'actions');
|
||||
actionsRemover.add(space, connector.id, 'connector', 'actions');
|
||||
|
||||
// Configuration is created with no connector so the mappings are empty
|
||||
const configuration = await createConfiguration(
|
||||
|
@ -134,7 +134,7 @@ export default ({ getService }: FtrProviderContext): void => {
|
|||
auth: authSpace1,
|
||||
});
|
||||
|
||||
actionsRemover.add(space, connector.id, 'action', 'actions');
|
||||
actionsRemover.add(space, connector.id, 'connector', 'actions');
|
||||
|
||||
// Configuration is created with no connector so the mappings are empty
|
||||
const configuration = await createConfiguration(
|
||||
|
|
|
@ -63,7 +63,7 @@ export default ({ getService }: FtrProviderContext): void => {
|
|||
auth: authSpace1,
|
||||
});
|
||||
|
||||
actionsRemover.add(space, connector.id, 'action', 'actions');
|
||||
actionsRemover.add(space, connector.id, 'connector', 'actions');
|
||||
|
||||
const postRes = await createConfiguration(
|
||||
supertestWithoutAuth,
|
||||
|
|
|
@ -75,17 +75,17 @@ export default ({ getPageObjects, getPageObject, getService }: FtrProviderContex
|
|||
},
|
||||
]);
|
||||
const connector = await getConnectorByName(connectorName, supertest);
|
||||
objectRemover.add(connector.id, 'action', 'actions');
|
||||
objectRemover.add(connector.id, 'connector', 'actions');
|
||||
});
|
||||
|
||||
it('should edit a connector', async () => {
|
||||
const connectorName = generateUniqueKey();
|
||||
const updatedConnectorName = `${connectorName}updated`;
|
||||
const createdAction = await createSlackConnector({
|
||||
const createdConnector = await createSlackConnector({
|
||||
name: connectorName,
|
||||
getService,
|
||||
});
|
||||
objectRemover.add(createdAction.id, 'action', 'actions');
|
||||
objectRemover.add(createdConnector.id, 'connector', 'actions');
|
||||
await browser.refresh();
|
||||
|
||||
await pageObjects.triggersActionsUI.searchConnectors(connectorName);
|
||||
|
@ -122,8 +122,8 @@ export default ({ getPageObjects, getPageObject, getService }: FtrProviderContex
|
|||
it('should test a connector and display a successful result', async () => {
|
||||
const connectorName = generateUniqueKey();
|
||||
const indexName = generateUniqueKey();
|
||||
const createdAction = await createIndexConnector(connectorName, indexName);
|
||||
objectRemover.add(createdAction.id, 'action', 'actions');
|
||||
const createdConnector = await createIndexConnector(connectorName, indexName);
|
||||
objectRemover.add(createdConnector.id, 'connector', 'actions');
|
||||
await browser.refresh();
|
||||
|
||||
await pageObjects.triggersActionsUI.searchConnectors(connectorName);
|
||||
|
@ -152,8 +152,8 @@ export default ({ getPageObjects, getPageObject, getService }: FtrProviderContex
|
|||
it('should test a connector and display a failure result', async () => {
|
||||
const connectorName = generateUniqueKey();
|
||||
const indexName = generateUniqueKey();
|
||||
const createdAction = await createIndexConnector(connectorName, indexName);
|
||||
objectRemover.add(createdAction.id, 'action', 'actions');
|
||||
const createdConnector = await createIndexConnector(connectorName, indexName);
|
||||
objectRemover.add(createdConnector.id, 'connector', 'actions');
|
||||
await browser.refresh();
|
||||
|
||||
await pageObjects.triggersActionsUI.searchConnectors(connectorName);
|
||||
|
@ -180,11 +180,11 @@ export default ({ getPageObjects, getPageObject, getService }: FtrProviderContex
|
|||
|
||||
it('should reset connector when canceling an edit', async () => {
|
||||
const connectorName = generateUniqueKey();
|
||||
const createdAction = await createSlackConnector({
|
||||
const createdConnector = await createSlackConnector({
|
||||
name: connectorName,
|
||||
getService,
|
||||
});
|
||||
objectRemover.add(createdAction.id, 'action', 'actions');
|
||||
objectRemover.add(createdConnector.id, 'connector', 'actions');
|
||||
await browser.refresh();
|
||||
|
||||
await pageObjects.triggersActionsUI.searchConnectors(connectorName);
|
||||
|
@ -212,11 +212,11 @@ export default ({ getPageObjects, getPageObject, getService }: FtrProviderContex
|
|||
it('should delete a connector', async () => {
|
||||
const connectorName = generateUniqueKey();
|
||||
await createSlackConnector({ name: connectorName, getService });
|
||||
const createdAction = await createSlackConnector({
|
||||
const createdConnector = await createSlackConnector({
|
||||
name: generateUniqueKey(),
|
||||
getService,
|
||||
});
|
||||
objectRemover.add(createdAction.id, 'action', 'actions');
|
||||
objectRemover.add(createdConnector.id, 'connector', 'actions');
|
||||
await browser.refresh();
|
||||
|
||||
await pageObjects.triggersActionsUI.searchConnectors(connectorName);
|
||||
|
@ -241,11 +241,11 @@ export default ({ getPageObjects, getPageObject, getService }: FtrProviderContex
|
|||
it('should bulk delete connectors', async () => {
|
||||
const connectorName = generateUniqueKey();
|
||||
await createSlackConnector({ name: connectorName, getService });
|
||||
const createdAction = await createSlackConnector({
|
||||
const createdConnector = await createSlackConnector({
|
||||
name: generateUniqueKey(),
|
||||
getService,
|
||||
});
|
||||
objectRemover.add(createdAction.id, 'action', 'actions');
|
||||
objectRemover.add(createdConnector.id, 'connector', 'actions');
|
||||
await browser.refresh();
|
||||
|
||||
await pageObjects.triggersActionsUI.searchConnectors(connectorName);
|
||||
|
@ -306,12 +306,12 @@ export default ({ getPageObjects, getPageObject, getService }: FtrProviderContex
|
|||
await pageObjects.common.navigateToApp('triggersActions');
|
||||
|
||||
const connectorName = generateUniqueKey();
|
||||
const createdAction = await createSlackConnector({ name: connectorName, getService });
|
||||
objectRemover.add(createdAction.id, 'action', 'actions');
|
||||
const createdConnector = await createSlackConnector({ name: connectorName, getService });
|
||||
objectRemover.add(createdConnector.id, 'connector', 'actions');
|
||||
|
||||
const alerts = [{ id: 'us-central' }];
|
||||
rule = await createRuleWithActionsAndParams(
|
||||
createdAction.id,
|
||||
createdConnector.id,
|
||||
testRunUuid,
|
||||
{
|
||||
instances: alerts,
|
||||
|
@ -401,7 +401,7 @@ export default ({ getPageObjects, getPageObject, getService }: FtrProviderContex
|
|||
});
|
||||
|
||||
async function createIndexConnector(connectorName: string, indexName: string) {
|
||||
const { body: createdAction } = await supertest
|
||||
const { body: createdConnector } = await supertest
|
||||
.post(`/api/actions/connector`)
|
||||
.set('kbn-xsrf', 'foo')
|
||||
.send({
|
||||
|
@ -414,6 +414,6 @@ export default ({ getPageObjects, getPageObject, getService }: FtrProviderContex
|
|||
secrets: {},
|
||||
})
|
||||
.expect(200);
|
||||
return createdAction;
|
||||
return createdConnector;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -50,7 +50,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
|
|||
it('should create the connector', async () => {
|
||||
const connectorName = generateUniqueKey();
|
||||
const createdAction = await createJiraConnector(connectorName);
|
||||
objectRemover.add(createdAction.id, 'action', 'actions');
|
||||
objectRemover.add(createdAction.id, 'connector', 'actions');
|
||||
await browser.refresh();
|
||||
|
||||
await pageObjects.triggersActionsUI.searchConnectors(connectorName);
|
||||
|
@ -72,7 +72,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
|
|||
const connectorName = generateUniqueKey();
|
||||
const createdAction = await createJiraConnector(connectorName);
|
||||
connectorId = createdAction.id;
|
||||
objectRemover.add(connectorId, 'action', 'actions');
|
||||
objectRemover.add(connectorId, 'connector', 'actions');
|
||||
});
|
||||
|
||||
beforeEach(async () => {
|
||||
|
|
|
@ -59,14 +59,14 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
|
|||
},
|
||||
]);
|
||||
const connector = await getConnectorByName(connectorName, supertest);
|
||||
objectRemover.add(connector.id, 'action', 'actions');
|
||||
objectRemover.add(connector.id, 'connector', 'actions');
|
||||
});
|
||||
|
||||
it('should edit the connector', async () => {
|
||||
const connectorName = generateUniqueKey();
|
||||
const updatedConnectorName = `${connectorName}updated`;
|
||||
const createdAction = await createOpsgenieConnector(connectorName);
|
||||
objectRemover.add(createdAction.id, 'action', 'actions');
|
||||
objectRemover.add(createdAction.id, 'connector', 'actions');
|
||||
await browser.refresh();
|
||||
|
||||
await pageObjects.triggersActionsUI.searchConnectors(connectorName);
|
||||
|
@ -99,7 +99,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
|
|||
it('should reset connector when canceling an edit', async () => {
|
||||
const connectorName = generateUniqueKey();
|
||||
const createdAction = await createOpsgenieConnector(connectorName);
|
||||
objectRemover.add(createdAction.id, 'action', 'actions');
|
||||
objectRemover.add(createdAction.id, 'connector', 'actions');
|
||||
await browser.refresh();
|
||||
|
||||
await pageObjects.triggersActionsUI.searchConnectors(connectorName);
|
||||
|
@ -127,7 +127,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
|
|||
it('should disable the run button when the message field is not filled', async () => {
|
||||
const connectorName = generateUniqueKey();
|
||||
const createdAction = await createOpsgenieConnector(connectorName);
|
||||
objectRemover.add(createdAction.id, 'action', 'actions');
|
||||
objectRemover.add(createdAction.id, 'connector', 'actions');
|
||||
await browser.refresh();
|
||||
|
||||
await pageObjects.triggersActionsUI.searchConnectors(connectorName);
|
||||
|
@ -149,7 +149,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
|
|||
const connectorName = generateUniqueKey();
|
||||
const createdAction = await createOpsgenieConnector(connectorName);
|
||||
connectorId = createdAction.id;
|
||||
objectRemover.add(createdAction.id, 'action', 'actions');
|
||||
objectRemover.add(createdAction.id, 'connector', 'actions');
|
||||
});
|
||||
|
||||
beforeEach(async () => {
|
||||
|
@ -292,7 +292,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
|
|||
|
||||
before(async () => {
|
||||
const createdAction = await createOpsgenieConnector(connectorName);
|
||||
objectRemover.add(createdAction.id, 'action', 'actions');
|
||||
objectRemover.add(createdAction.id, 'connector', 'actions');
|
||||
|
||||
await pageObjects.common.navigateToApp('triggersActions');
|
||||
});
|
||||
|
|
|
@ -66,7 +66,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
|
|||
},
|
||||
]);
|
||||
const connector = await getConnectorByName(connectorName, supertest);
|
||||
objectRemover.add(connector.id, 'action', 'actions');
|
||||
objectRemover.add(connector.id, 'connector', 'actions');
|
||||
});
|
||||
|
||||
/* FUTURE ENGINEER
|
||||
|
@ -94,7 +94,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
|
|||
},
|
||||
]);
|
||||
const connector = await getConnectorByName(connectorName, supertest);
|
||||
objectRemover.add(connector.id, 'action', 'actions');
|
||||
objectRemover.add(connector.id, 'connector', 'actions');
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -140,8 +140,8 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
|
|||
connectorTypeId: '.slack',
|
||||
});
|
||||
|
||||
objectRemover.add(webhookAction.id, 'action', 'actions');
|
||||
objectRemover.add(webApiAction.id, 'action', 'actions');
|
||||
objectRemover.add(webhookAction.id, 'connector', 'actions');
|
||||
objectRemover.add(webApiAction.id, 'connector', 'actions');
|
||||
await pageObjects.common.navigateToApp('triggersActions');
|
||||
});
|
||||
|
||||
|
|
|
@ -77,14 +77,14 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
|
|||
},
|
||||
]);
|
||||
const connector = await getConnectorByName(connectorName, supertest);
|
||||
objectRemover.add(connector.id, 'action', 'actions');
|
||||
objectRemover.add(connector.id, 'connector', 'actions');
|
||||
});
|
||||
|
||||
it('should edit the connector', async () => {
|
||||
const connectorName = generateUniqueKey();
|
||||
const updatedConnectorName = `${connectorName}updated`;
|
||||
const createdAction = await createTinesConnector(connectorName);
|
||||
objectRemover.add(createdAction.id, 'action', 'actions');
|
||||
objectRemover.add(createdAction.id, 'connector', 'actions');
|
||||
await browser.refresh();
|
||||
|
||||
await pageObjects.triggersActionsUI.searchConnectors(connectorName);
|
||||
|
@ -118,7 +118,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
|
|||
it('should reset connector when canceling an edit', async () => {
|
||||
const connectorName = generateUniqueKey();
|
||||
const createdAction = await createTinesConnector(connectorName);
|
||||
objectRemover.add(createdAction.id, 'action', 'actions');
|
||||
objectRemover.add(createdAction.id, 'connector', 'actions');
|
||||
await browser.refresh();
|
||||
|
||||
await pageObjects.triggersActionsUI.searchConnectors(connectorName);
|
||||
|
@ -146,7 +146,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
|
|||
it('should disable the run button when the fields are not filled', async () => {
|
||||
const connectorName = generateUniqueKey();
|
||||
const createdAction = await createTinesConnector(connectorName);
|
||||
objectRemover.add(createdAction.id, 'action', 'actions');
|
||||
objectRemover.add(createdAction.id, 'connector', 'actions');
|
||||
await browser.refresh();
|
||||
|
||||
await pageObjects.triggersActionsUI.searchConnectors(connectorName);
|
||||
|
@ -168,7 +168,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
|
|||
const connectorName = generateUniqueKey();
|
||||
const createdAction = await createTinesConnector(connectorName);
|
||||
connectorId = createdAction.id;
|
||||
objectRemover.add(createdAction.id, 'action', 'actions');
|
||||
objectRemover.add(createdAction.id, 'connector', 'actions');
|
||||
});
|
||||
|
||||
beforeEach(async () => {
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue