Skip to content

Commit

Permalink
Fix flaky tests
Browse files Browse the repository at this point in the history
  • Loading branch information
e40pud committed Jan 31, 2024
1 parent b4d93fc commit b6f3ad4
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
} from '../../../../../tasks/alerts';
import { createRule } from '../../../../../tasks/api_calls/rules';
import { deleteAlertsAndRules } from '../../../../../tasks/api_calls/common';
import { login } from '../../../../../tasks/login';
import { activateUser, login } from '../../../../../tasks/login';
import { ALERTS_URL } from '../../../../../urls/navigation';
import { waitForAlertsToPopulate } from '../../../../../tasks/create_new_rule';
import {
Expand All @@ -43,17 +43,19 @@ import {
import { ALERTS_COUNT } from '../../../../../screens/alerts';

// Failing: See https://github.com/elastic/kibana/issues/173429
describe.skip('Alert user assignment - ESS & Serverless', { tags: ['@ess', '@serverless'] }, () => {
describe('Alert user assignment - ESS & Serverless', { tags: ['@ess', '@serverless'] }, () => {
before(() => {
cy.task('esArchiverLoad', { archiveName: 'auditbeat_multiple' });

// Login into accounts so that they got activated and visible in user profiles list
login(ROLES.t1_analyst);
login(ROLES.t2_analyst);
login(ROLES.t3_analyst);
login(ROLES.soc_manager);
login(ROLES.detections_admin);
login(ROLES.platform_engineer);
login();

// Activate accounts so that they got visible in user profiles list
activateUser(ROLES.t1_analyst);
activateUser(ROLES.t2_analyst);
activateUser(ROLES.t3_analyst);
activateUser(ROLES.soc_manager);
activateUser(ROLES.detections_admin);
activateUser(ROLES.platform_engineer);
});

after(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { getNewRule } from '../../../../../objects/rule';
import { refreshAlertPageFilter, selectFirstPageAlerts } from '../../../../../tasks/alerts';
import { createRule } from '../../../../../tasks/api_calls/rules';
import { deleteAlertsAndRules } from '../../../../../tasks/api_calls/common';
import { login } from '../../../../../tasks/login';
import { activateUser, login } from '../../../../../tasks/login';
import { ALERTS_URL } from '../../../../../urls/navigation';
import { waitForAlertsToPopulate } from '../../../../../tasks/create_new_rule';
import {
Expand All @@ -21,7 +21,7 @@ import {
} from '../../../../../tasks/alert_assignments';

// FLAKY: https://github.com/elastic/kibana/issues/172557
describe.skip(
describe(
'Alert user assignment - Serverless Complete',
{
tags: ['@serverless'],
Expand All @@ -38,13 +38,15 @@ describe.skip(
before(() => {
cy.task('esArchiverLoad', { archiveName: 'auditbeat_multiple' });

// Login into accounts so that they got activated and visible in user profiles list
login(ROLES.t1_analyst);
login(ROLES.t2_analyst);
login(ROLES.t3_analyst);
login(ROLES.soc_manager);
login(ROLES.detections_admin);
login(ROLES.platform_engineer);
login();

// Activate accounts so that they got visible in user profiles list
activateUser(ROLES.t1_analyst);
activateUser(ROLES.t2_analyst);
activateUser(ROLES.t3_analyst);
activateUser(ROLES.soc_manager);
activateUser(ROLES.detections_admin);
activateUser(ROLES.platform_engineer);
});

after(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { getNewRule } from '../../../../../objects/rule';
import { refreshAlertPageFilter, selectFirstPageAlerts } from '../../../../../tasks/alerts';
import { createRule } from '../../../../../tasks/api_calls/rules';
import { deleteAlertsAndRules } from '../../../../../tasks/api_calls/common';
import { login } from '../../../../../tasks/login';
import { activateUser, login } from '../../../../../tasks/login';
import { ALERTS_URL } from '../../../../../urls/navigation';
import { waitForAlertsToPopulate } from '../../../../../tasks/create_new_rule';
import {
Expand All @@ -21,7 +21,7 @@ import {
} from '../../../../../tasks/alert_assignments';

// FLAKY: https://github.com/elastic/kibana/issues/172520
describe.skip(
describe(
'Alert user assignment - Serverless Essentials',
{
tags: ['@serverless'],
Expand All @@ -38,13 +38,15 @@ describe.skip(
before(() => {
cy.task('esArchiverLoad', { archiveName: 'auditbeat_multiple' });

// Login into accounts so that they got activated and visible in user profiles list
login(ROLES.t1_analyst);
login(ROLES.t2_analyst);
login(ROLES.t3_analyst);
login(ROLES.soc_manager);
login(ROLES.detections_admin);
login(ROLES.platform_engineer);
login();

// Activate accounts so that they got visible in user profiles list
activateUser(ROLES.t1_analyst);
activateUser(ROLES.t2_analyst);
activateUser(ROLES.t3_analyst);
activateUser(ROLES.soc_manager);
activateUser(ROLES.detections_admin);
activateUser(ROLES.platform_engineer);
});

after(() => {
Expand Down
20 changes: 20 additions & 0 deletions x-pack/test/security_solution_cypress/cypress/tasks/login.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,23 @@ export const loginWithUser = (user: User): void => {
export const logout = (): void => {
cy.visit(LOGOUT_URL);
};

export const activateUser = (role?: SecurityRoleName): void => {
const user = role
? {
username: role,
password: 'changeme',
}
: defaultUser;

cy.request({
url: `${Cypress.env('ELASTICSEARCH_URL')}/_security/profile/_activate`,
method: 'POST',
body: {
grant_type: 'password',
username: user.username,
password: user.password,
},
headers: API_HEADERS,
});
};

0 comments on commit b6f3ad4

Please sign in to comment.