diff --git a/cypress/integration/plugins/security-dashboards-plugin/aggregation_view.js b/cypress/integration/plugins/security-dashboards-plugin/aggregation_view.js index d7fb02219..7ffc17509 100644 --- a/cypress/integration/plugins/security-dashboards-plugin/aggregation_view.js +++ b/cypress/integration/plugins/security-dashboards-plugin/aggregation_view.js @@ -5,7 +5,7 @@ import { SAVED_OBJECTS_PATH, -} from '../../../utils/constants'; +} from '../../../utils/dashboards/constants'; import { ADMIN_AUTH, @@ -51,12 +51,13 @@ if (Cypress.env('SECURITY_ENABLED') && Cypress.env('AGGREGATION_VIEW')) { title: 's*', timeFieldName: 'timestamp', }); - cy.createIndexPatternWithTenantHeader('index-pattern2', { + cy.createIndexPattern('index-pattern2', { title: 'se*', timeFieldName: 'timestamp', }, indexPatternTenantHeaderSetUp ); + cy.wait(30000); }); it('should check the saved objects as global tenant', () => { diff --git a/cypress/utils/commands.js b/cypress/utils/commands.js index b1c09133f..c9d9003cb 100644 --- a/cypress/utils/commands.js +++ b/cypress/utils/commands.js @@ -198,26 +198,7 @@ Cypress.Commands.add('bulkUploadDocs', (fixturePath, index) => { }); }); -Cypress.Commands.add('createIndexPattern', (id, attributes) => { - const url = `${ - Cypress.config().baseUrl - }/api/saved_objects/index-pattern/${id}`; - - cy.request({ - method: 'POST', - url, - headers: { - 'content-type': 'application/json;charset=UTF-8', - 'osd-xsrf': true, - }, - body: JSON.stringify({ - attributes, - references: [], - }), - }); -}); - -Cypress.Commands.add('createIndexPatternWithTenantHeader', (id, attributes, header = {}) => { +Cypress.Commands.add('createIndexPattern', (id, attributes, header = {}) => { const url = `${ Cypress.config().baseUrl }/api/saved_objects/index-pattern/${id}`; diff --git a/cypress/utils/dashboards/constants.js b/cypress/utils/dashboards/constants.js index a850c1690..9b2450cdd 100644 --- a/cypress/utils/dashboards/constants.js +++ b/cypress/utils/dashboards/constants.js @@ -2,3 +2,11 @@ * Copyright OpenSearch Contributors * SPDX-License-Identifier: Apache-2.0 */ + +import { BASE_PATH } from '../base_constants'; + +// STACK MANAGEMENT PATH +export const STACK_MANAGEMENT_PATH = BASE_PATH + '/app/management'; + +export const INDEX_PATTERN_PATH = STACK_MANAGEMENT_PATH + '/opensearch-dashboards/indexPatterns'; +export const SAVED_OBJECTS_PATH = STACK_MANAGEMENT_PATH + '/opensearch-dashboards/objects'; diff --git a/cypress/utils/index.d.ts b/cypress/utils/index.d.ts index 6ad99c329..b4f8a3660 100644 --- a/cypress/utils/index.d.ts +++ b/cypress/utils/index.d.ts @@ -46,18 +46,9 @@ declare namespace Cypress { /** * Adds an index pattern * @example - * cy.createIndexPattern('patterId', 'patt*', 'timestamp') + * cy.createIndexPattern('patterId', {'patt*', 'timestamp'}) */ createIndexPattern( - id: string, - attributes: { - title: string; - timeFieldName?: string; - [key: string]: any; - } - ): Chainable; - - createIndexPatternWithTenantHeader( id: string, attributes: { title: string; diff --git a/cypress/utils/plugins/security-dashboards-plugin/index.d.ts b/cypress/utils/plugins/security-dashboards-plugin/index.d.ts new file mode 100644 index 000000000..6a520c8ec --- /dev/null +++ b/cypress/utils/plugins/security-dashboards-plugin/index.d.ts @@ -0,0 +1,52 @@ +// type definitions for custom commands like "createDefaultTodos" +/// + +declare namespace Cypress { + interface Chainable { + /** + * Create a test tenant by calling REST API + * @example + * cy.createTenant('test_tenant', tenantJsonFixture ) + */ + createTenant( + tenantID: string, + tenantJson: string + ): Chainable; + } + + interface Chainable { + /** + * Create an internal user by calling REST API + * @example + * cy.createInternalUser('test_user', userJsonFixture ) + */ + createInternalUser( + userID: string, + userJson: string + ): Chainable; + } + + interface Chainable { + /** + * Create a role by calling REST API + * @example + * cy.createRole('role_name', roleJsonFixture ) + */ + createRole( + roleID: string, + roleJson: string + ): Chainable; + } + + interface Chainable { + /** + * Create a role mapping by calling REST API + * @example + * cy.createRoleMapping('role_name', rolemappingJsonFixture ) + */ + createRoleMapping( + roleID: string, + rolemappingJson: string + ): Chainable; + } +} \ No newline at end of file diff --git a/cypress/utils/plugins/security/constants.js b/cypress/utils/plugins/security/constants.js index 7b31285d4..1f8009ba0 100644 --- a/cypress/utils/plugins/security/constants.js +++ b/cypress/utils/plugins/security/constants.js @@ -65,9 +65,3 @@ export const SEC_API_CACHE_PURGE_PATH = BASE_SEC_API_PATH + '/cache'; export const SEC_API_AUTHINFO_PATH = BASE_PATH + '/api/v1/auth/authinfo'; export const SEC_API_TENANT_PATH = BASE_PATH + '/api/v1/multitenancy/tenant'; - -// STACK MANAGEMENT PATH -export const STACK_MANAGEMENT_PATH = BASE_PATH + '/app/management'; - -export const INDEX_PATTERN_PATH = STACK_MANAGEMENT_PATH + '/opensearch-dashboards/indexPatterns'; -export const SAVED_OBJECTS_PATH = STACK_MANAGEMENT_PATH + '/opensearch-dashboards/objects';