Skip to content

Commit

Permalink
fixes MKI tests
Browse files Browse the repository at this point in the history
  • Loading branch information
MadameSheema committed Jun 12, 2024
1 parent 74738c0 commit 85dc576
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,21 @@ import {
fillCasesMandatoryfields,
filterStatusOpen,
} from '../../../tasks/create_new_case';
import { login } from '../../../tasks/login';
import { visit, visitWithTimeRange } from '../../../tasks/navigation';

import { CASES_URL, OVERVIEW_URL } from '../../../urls/navigation';
import { ELASTICSEARCH_USERNAME, IS_SERVERLESS } from '../../../env_var_names_constants';
import { deleteCases } from '../../../tasks/api_calls/cases';
import { login } from '../../../tasks/login';

// https://github.com/elastic/kibana/issues/179231
const isServerless = Cypress.env(IS_SERVERLESS);
const username = isServerless ? 'platform_engineer' : Cypress.env(ELASTICSEARCH_USERNAME);
const getUsername = () => {
if (isServerless) {
return cy.task('getFullname');
} else {
return cy.wrap(Cypress.env(ELASTICSEARCH_USERNAME));
}
};

// Tracked by https://github.com/elastic/security-team/issues/7696
describe('Cases', { tags: ['@ess', '@serverless'] }, () => {
Expand Down Expand Up @@ -109,12 +114,17 @@ describe('Cases', { tags: ['@ess', '@serverless'] }, () => {
cy.get(CASE_DETAILS_PAGE_TITLE).should('have.text', this.mycase.name);
cy.get(CASE_DETAILS_STATUS).should('have.text', 'Open');
cy.get(CASE_DETAILS_USER_ACTION_DESCRIPTION_EVENT).should('have.text', 'Description');

cy.get(CASE_DETAILS_DESCRIPTION).should(
'have.text',
`${this.mycase.description} ${this.mycase.timeline.title}`
);
cy.get(CASE_DETAILS_USERNAMES).eq(REPORTER).should('contain', username);
cy.get(CASE_DETAILS_USERNAMES).eq(PARTICIPANTS).should('contain', username);

getUsername().then((username) => {
cy.get(CASE_DETAILS_USERNAMES).eq(REPORTER).should('contain', username);
cy.get(CASE_DETAILS_USERNAMES).eq(PARTICIPANTS).should('contain', username);
});

cy.get(CASE_DETAILS_TAGS).should('have.text', expectedTags);

EXPECTED_METRICS.forEach((metric) => {
Expand Down
17 changes: 15 additions & 2 deletions x-pack/test/security_solution_cypress/cypress/support/saml_auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,11 @@ export const samlAuthentication = async (
password: config.env.ELASTICSEARCH_PASSWORD,
};

// If config.env.PROXY_ORG is set, it means that proxy service is used to create projects. Define the proxy org filename to override the roles.
const rolesFilename = config.env.PROXY_ORG ? `${config.env.PROXY_ORG}.json` : undefined;

on('task', {
getSessionCookie: async (role: string | SecurityRoleName): Promise<string> => {
// If config.env.PROXY_ORG is set, it means that proxy service is used to create projects. Define the proxy org filename to override the roles.
const rolesFilename = config.env.PROXY_ORG ? `${config.env.PROXY_ORG}.json` : undefined;
const sessionManager = new SamlSessionManager(
{
hostOptions,
Expand All @@ -42,5 +43,17 @@ export const samlAuthentication = async (
);
return sessionManager.getSessionCookieForRole(role);
},
getFullname: async (role: string | SecurityRoleName = 'platform_engineer'): Promise<string> => {
const sessionManager = new SamlSessionManager(
{
hostOptions,
log,
isCloud: config.env.CLOUD_SERVERLESS,
},
rolesFilename
);
const { fullname } = await sessionManager.getUserData(role);
return fullname;
},
});
};

0 comments on commit 85dc576

Please sign in to comment.