From c5193b371abba75ff0c1f4cea9c5ebe92d88da5c Mon Sep 17 00:00:00 2001 From: Brad White Date: Thu, 28 Sep 2023 16:54:36 -0600 Subject: [PATCH] [8.10] Fix `x-pack/test_serverless` TS Error (#167568) ## Summary Partially fixes #167373 for: `./x-pack/test_serverless/tsconfig.json` --- .../endpoint_management/feature_access/complete.cy.ts | 3 ++- .../feature_access/complete_with_endpoint.cy.ts | 3 ++- .../feature_access/essentials.cy.ts | 3 ++- .../feature_access/essentials_with_endpoint.cy.ts | 3 ++- .../roles/complete_with_endpoint_roles.cy.ts | 10 +++++----- .../roles/essentials_with_endpoint.roles.cy.ts | 8 ++++---- .../test_suites/security/cypress/tasks/login.ts | 3 ++- 7 files changed, 19 insertions(+), 14 deletions(-) diff --git a/x-pack/test_serverless/functional/test_suites/security/cypress/e2e/endpoint_management/feature_access/complete.cy.ts b/x-pack/test_serverless/functional/test_suites/security/cypress/e2e/endpoint_management/feature_access/complete.cy.ts index c76bbe5150e3e..44b3f9c37d70e 100644 --- a/x-pack/test_serverless/functional/test_suites/security/cypress/e2e/endpoint_management/feature_access/complete.cy.ts +++ b/x-pack/test_serverless/functional/test_suites/security/cypress/e2e/endpoint_management/feature_access/complete.cy.ts @@ -6,6 +6,7 @@ */ import { RESPONSE_ACTION_API_COMMANDS_NAMES } from '@kbn/security-solution-plugin/common/endpoint/service/response_actions/constants'; +import { ServerlessRoleName } from '../../../../../../../shared/lib'; import { login } from '../../../tasks/login'; import { getNoPrivilegesPage } from '../../../screens/endpoint_management/common'; import { getEndpointManagementPageList } from '../../../screens/endpoint_management'; @@ -30,7 +31,7 @@ describe( let password: string; beforeEach(() => { - login('endpoint_operations_analyst').then((response) => { + login(ServerlessRoleName.ENDPOINT_OPERATIONS_ANALYST).then((response) => { username = response.username; password = response.password; }); diff --git a/x-pack/test_serverless/functional/test_suites/security/cypress/e2e/endpoint_management/feature_access/complete_with_endpoint.cy.ts b/x-pack/test_serverless/functional/test_suites/security/cypress/e2e/endpoint_management/feature_access/complete_with_endpoint.cy.ts index fc8a1e1a690fb..85ae5a8b3aed9 100644 --- a/x-pack/test_serverless/functional/test_suites/security/cypress/e2e/endpoint_management/feature_access/complete_with_endpoint.cy.ts +++ b/x-pack/test_serverless/functional/test_suites/security/cypress/e2e/endpoint_management/feature_access/complete_with_endpoint.cy.ts @@ -6,6 +6,7 @@ */ import { RESPONSE_ACTION_API_COMMANDS_NAMES } from '@kbn/security-solution-plugin/common/endpoint/service/response_actions/constants'; +import { ServerlessRoleName } from '../../../../../../../shared/lib'; import { login } from '../../../tasks/login'; import { getAgentListTable, visitFleetAgentList } from '../../../screens'; import { getEndpointManagementPageList } from '../../../screens/endpoint_management'; @@ -29,7 +30,7 @@ describe( let password: string; beforeEach(() => { - login('endpoint_operations_analyst').then((response) => { + login(ServerlessRoleName.ENDPOINT_OPERATIONS_ANALYST).then((response) => { username = response.username; password = response.password; }); diff --git a/x-pack/test_serverless/functional/test_suites/security/cypress/e2e/endpoint_management/feature_access/essentials.cy.ts b/x-pack/test_serverless/functional/test_suites/security/cypress/e2e/endpoint_management/feature_access/essentials.cy.ts index da5da7a4fa5f9..5297440a3f558 100644 --- a/x-pack/test_serverless/functional/test_suites/security/cypress/e2e/endpoint_management/feature_access/essentials.cy.ts +++ b/x-pack/test_serverless/functional/test_suites/security/cypress/e2e/endpoint_management/feature_access/essentials.cy.ts @@ -6,6 +6,7 @@ */ import { RESPONSE_ACTION_API_COMMANDS_NAMES } from '@kbn/security-solution-plugin/common/endpoint/service/response_actions/constants'; +import { ServerlessRoleName } from '../../../../../../../shared/lib'; import { login } from '../../../tasks/login'; import { getNoPrivilegesPage } from '../../../screens/endpoint_management/common'; import { ensureResponseActionAuthzAccess } from '../../../tasks/endpoint_management'; @@ -32,7 +33,7 @@ describe( let password: string; beforeEach(() => { - login('endpoint_operations_analyst').then((response) => { + login(ServerlessRoleName.ENDPOINT_OPERATIONS_ANALYST).then((response) => { username = response.username; password = response.password; }); diff --git a/x-pack/test_serverless/functional/test_suites/security/cypress/e2e/endpoint_management/feature_access/essentials_with_endpoint.cy.ts b/x-pack/test_serverless/functional/test_suites/security/cypress/e2e/endpoint_management/feature_access/essentials_with_endpoint.cy.ts index 86295ef1d28c0..8d81d0860bd05 100644 --- a/x-pack/test_serverless/functional/test_suites/security/cypress/e2e/endpoint_management/feature_access/essentials_with_endpoint.cy.ts +++ b/x-pack/test_serverless/functional/test_suites/security/cypress/e2e/endpoint_management/feature_access/essentials_with_endpoint.cy.ts @@ -6,6 +6,7 @@ */ import { RESPONSE_ACTION_API_COMMANDS_NAMES } from '@kbn/security-solution-plugin/common/endpoint/service/response_actions/constants'; +import { ServerlessRoleName } from '../../../../../../../shared/lib'; import { login } from '../../../tasks/login'; import { getAgentListTable, visitFleetAgentList } from '../../../screens'; import { getEndpointManagementPageMap } from '../../../screens/endpoint_management'; @@ -37,7 +38,7 @@ describe( let password: string; beforeEach(() => { - login('endpoint_operations_analyst').then((response) => { + login(ServerlessRoleName.ENDPOINT_OPERATIONS_ANALYST).then((response) => { username = response.username; password = response.password; }); diff --git a/x-pack/test_serverless/functional/test_suites/security/cypress/e2e/endpoint_management/roles/complete_with_endpoint_roles.cy.ts b/x-pack/test_serverless/functional/test_suites/security/cypress/e2e/endpoint_management/roles/complete_with_endpoint_roles.cy.ts index 2311a803043f2..dc1c8565c17ae 100644 --- a/x-pack/test_serverless/functional/test_suites/security/cypress/e2e/endpoint_management/roles/complete_with_endpoint_roles.cy.ts +++ b/x-pack/test_serverless/functional/test_suites/security/cypress/e2e/endpoint_management/roles/complete_with_endpoint_roles.cy.ts @@ -130,7 +130,7 @@ describe( const deniedResponseActions = pick(consoleHelpPanelResponseActionsTestSubj, 'execute'); beforeEach(() => { - login('t3_analyst'); + login(ServerlessRoleName.T3_ANALYST); }); it('should have access to Endpoint list page', () => { @@ -182,7 +182,7 @@ describe( const deniedPages = allPages.filter(({ id }) => id !== 'blocklist' && id !== 'endpointList'); beforeEach(() => { - login('threat_intelligence_analyst'); + login(ServerlessRoleName.THREAT_INTELLIGENCE_ANALYST); }); it('should have access to Endpoint list page', () => { @@ -227,7 +227,7 @@ describe( ]; beforeEach(() => { - login('rule_author'); + login(ServerlessRoleName.RULE_AUTHOR); }); for (const { id, title } of artifactPagesFullAccess) { @@ -278,7 +278,7 @@ describe( const grantedAccessPages = [pageById.endpointList, pageById.policyList]; beforeEach(() => { - login('soc_manager'); + login(ServerlessRoleName.SOC_MANAGER); }); for (const { id, title } of artifactPagesFullAccess) { @@ -325,7 +325,7 @@ describe( const grantedAccessPages = [pageById.endpointList, pageById.policyList]; beforeEach(() => { - login('endpoint_operations_analyst'); + login(ServerlessRoleName.ENDPOINT_OPERATIONS_ANALYST); }); for (const { id, title } of artifactPagesFullAccess) { diff --git a/x-pack/test_serverless/functional/test_suites/security/cypress/e2e/endpoint_management/roles/essentials_with_endpoint.roles.cy.ts b/x-pack/test_serverless/functional/test_suites/security/cypress/e2e/endpoint_management/roles/essentials_with_endpoint.roles.cy.ts index c60095aa23c06..235b21023d8a2 100644 --- a/x-pack/test_serverless/functional/test_suites/security/cypress/e2e/endpoint_management/roles/essentials_with_endpoint.roles.cy.ts +++ b/x-pack/test_serverless/functional/test_suites/security/cypress/e2e/endpoint_management/roles/essentials_with_endpoint.roles.cy.ts @@ -93,7 +93,7 @@ describe( ]; beforeEach(() => { - login('t3_analyst'); + login(ServerlessRoleName.T3_ANALYST); }); it('should have access to Endpoint list page', () => { @@ -132,7 +132,7 @@ describe( const deniedPages = allPages.filter(({ id }) => id !== 'blocklist' && id !== 'endpointList'); beforeEach(() => { - login('threat_intelligence_analyst'); + login(ServerlessRoleName.THREAT_INTELLIGENCE_ANALYST); }); it('should have access to Endpoint list page', () => { @@ -167,7 +167,7 @@ describe( ]; beforeEach(() => { - login('rule_author'); + login(ServerlessRoleName.RULE_AUTHOR); }); for (const { id, title } of artifactPagesFullAccess) { @@ -211,7 +211,7 @@ describe( const grantedAccessPages = [pageById.endpointList, pageById.policyList]; beforeEach(() => { - login('soc_manager'); + login(ServerlessRoleName.SOC_MANAGER); }); for (const { id, title } of artifactPagesFullAccess) { diff --git a/x-pack/test_serverless/functional/test_suites/security/cypress/tasks/login.ts b/x-pack/test_serverless/functional/test_suites/security/cypress/tasks/login.ts index 7b9d571d8c7c9..d8963783ef23d 100644 --- a/x-pack/test_serverless/functional/test_suites/security/cypress/tasks/login.ts +++ b/x-pack/test_serverless/functional/test_suites/security/cypress/tasks/login.ts @@ -8,6 +8,7 @@ import { request } from '@kbn/security-solution-plugin/public/management/cypress/tasks/common'; import { isLocalhost } from '@kbn/security-solution-plugin/scripts/endpoint/common/is_localhost'; import type { ServerlessRoleName } from '../../../../../shared/lib'; +import { ServerlessRoleName as RoleName } from '../../../../../shared/lib/security/types'; import { STANDARD_HTTP_HEADERS } from '../../../../../shared/lib/security/default_http_headers'; /** @@ -65,7 +66,7 @@ interface CyLoginTask { * @param user Defaults to `soc_manager` */ export const login: CyLoginTask = ( - user: ServerlessRoleName | 'elastic' = 'soc_manager' + user: ServerlessRoleName | 'elastic' = RoleName.SOC_MANAGER ): ReturnType => { let username = Cypress.env('KIBANA_USERNAME'); let password = Cypress.env('KIBANA_PASSWORD');