Skip to content

Commit

Permalink
[ftr] remove svlCommonPage.forceLogout(); for tests using SAML auth (e…
Browse files Browse the repository at this point in the history
…lastic#187140)

## Summary

**tl; dr;** PR removes `svlCommonPage.forceLogout();` for test suites,
that use _SAML auth_ to Kibana with
`svlCommonPage.loginWithRole(<role>)` as this call is not needed.


More details:
`svlCommonPage.forceLogout();` was introduced together with
`svlCommonPage.login()` when FTR allowed only basic authentication with
`/login` route and operator user. Mixing basic auth with Cloud SAML auth
caused flakiness, probably some of you noticed inconsistent redirects to
Cloud UI in before/after hooks. Calling `/logout` route and handling
what happens next was important to reset Kibana state.

However with `svlCommonPage.loginWithRole(<role>)` it is no longer
needed, it works this way:
1. use Cloud SAML auth (mock IDP to replicate SAML locally) to generate
session based on provided project role
2. clear browser state: delete all cookies, clear session & local
storage, verify it succeeded
3. set cookie in browser, validate role/user is applied properly by
validating user profile in browser

Since we generate only 1 session per unique role within each FTR config
run, it is not possible to have 2 different sessions for the same user.
When your next test is calling `svlCommonPage.loginWithRole(<role>)`,
the cookie in browser and browser state overall will be reset
completely.
  • Loading branch information
dmlemeshko authored Jul 1, 2024
1 parent 53aa772 commit ccfc5d3
Show file tree
Hide file tree
Showing 28 changed files with 1 addition and 62 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {
await pageObjects.svlCommonPage.loginWithRole(VIEWER_ROLE);
});

after(async () => {
await pageObjects.svlCommonPage.forceLogout();
});

describe('User details', async () => {
it('should display correct user details', async () => {
await pageObjects.common.navigateToApp('security_account');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,6 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
await pageObjects.common.navigateToApp('settings');
});

after(async () => {
await pageObjects.svlCommonPage.forceLogout();
});

it('renders the page', async () => {
await retry.waitFor('title to be visible', async () => {
return await testSubjects.exists('managementSettingsTitle');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ export default ({ getPageObject, getService }: FtrProviderContext) => {
);

await kibanaServer.savedObjects.cleanStandardList();
await svlCommonPage.forceLogout();
});

it('adds lens visualization to a new case', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ export default ({ getPageObject, getService }: FtrProviderContext) => {

after(async () => {
await svlCases.api.deleteAllCaseItems();
await svlCommonPage.forceLogout();
});

describe('Closure options', function () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ export default ({ getService, getPageObject }: FtrProviderContext) => {

after(async () => {
await svlCases.api.deleteAllCaseItems();
await svlCommonPage.forceLogout();
});

it('creates a case', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ export default ({ getPageObject, getService }: FtrProviderContext) => {
after(async () => {
await svlCases.api.deleteAllCaseItems();
await cases.casesTable.waitForCasesToBeDeleted();
await svlCommonPage.forceLogout();
});

describe('empty state', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ export default ({ getPageObject, getService }: FtrProviderContext) => {

after(async () => {
await svlCases.api.deleteAllCaseItems();
await svlCommonPage.forceLogout();
});

describe('page', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {

after(async () => {
await esArchiver.unload('x-pack/test/functional/es_archives/infra/metrics_and_logs');
await pageObjects.svlCommonPage.forceLogout();
});

describe('Alerts dropdown', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
await Promise.all([
esArchiver.unload('x-pack/test/functional/es_archives/infra/metrics_and_logs'),
]);
await pageObjects.svlCommonPage.forceLogout();
});

describe('#Single Host Flyout', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,6 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
await pageObjects.svlCommonPage.loginWithRole('viewer');
});

after(async () => {
await pageObjects.svlCommonPage.forceLogout();
});

describe('Inventory page', function () {
this.tags('includeFirefox');
before(async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,6 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
await svlObltNavigation.navigateToLandingPage();
});

after(async () => {
await pageObjects.svlCommonPage.forceLogout();
});

describe('when Hosts settings is on', () => {
before(async () => {
await setHostsSetting(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {

after(async () => {
await esArchiver.unload('x-pack/test/functional/es_archives/infra/metrics_and_logs');
await pageObjects.svlCommonPage.forceLogout();
});

describe('Osquery Tab', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
});

after(async () => {
await PageObjects.svlCommonPage.forceLogout();
await ml.api.cleanMlIndices();
await ml.testResources.cleanMLSavedObjects();
await esArchiver.unload('x-pack/test/functional/es_archives/logstash_functional');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,6 @@ export default function ({ getPageObjects }: FtrProviderContext) {
await PageObjects.svlCommonPage.loginWithRole(role);
});

after(async () => {
await PageObjects.svlCommonPage.forceLogout();
});

describe('list features', () => {
it('has the correct features enabled', async () => {
await PageObjects.header.waitUntilLoadingHasFinished();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {

after(async () => {
await synthtrace.clean();
await PageObjects.svlCommonPage.forceLogout();
});

describe('columns selection initialization and update', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {

after(async () => {
await synthtrace.clean();
await PageObjects.svlCommonPage.forceLogout();
});

describe('should render custom control columns properly', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,6 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
await PageObjects.svlCommonPage.loginWithRole('viewer');
});

after(async () => {
await PageObjects.svlCommonPage.forceLogout();
});

describe('when no dataSourceSelection is given', () => {
it('should initialize the "All logs" selection', async () => {
await PageObjects.observabilityLogsExplorer.navigateTo();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,6 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
await PageObjects.observabilityLogsExplorer.removeInstalledPackages();
});

after(async () => {
await PageObjects.svlCommonPage.forceLogout();
});

describe('as consistent behavior', () => {
before(async () => {
await PageObjects.observabilityLogsExplorer.navigateTo();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {

after(async () => {
await synthtrace.clean();
await PageObjects.svlCommonPage.forceLogout();
});

describe('field list initialisation', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
});

after('clean up archives', async () => {
await PageObjects.svlCommonPage.forceLogout();
await kibanaServer.importExport.unload('test/functional/fixtures/kbn_archiver/discover');
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
});

after('clean up archives', async () => {
await PageObjects.svlCommonPage.forceLogout();
if (cleanupDataStreamSetup) {
cleanupDataStreamSetup();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
});

after(async () => {
await PageObjects.svlCommonPage.forceLogout();
await kibanaServer.importExport.unload('test/functional/fixtures/kbn_archiver/discover');
await esArchiver.unload(
'x-pack/test/functional/es_archives/observability_logs_explorer/data_streams'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ export default ({ getPageObject, getService }: FtrProviderContext) => {
});

after(async () => {
await svlCommonPage.forceLogout();
await svlUserManager.invalidateApiKeyForRole(roleAuthc);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,11 @@ export default function ({ getPageObject, getPageObjects, getService }: FtrProvi
roleAuthc
);
caseIdMonitoring = caseMonitoring.id;
await pageObjects.svlCommonPage.loginWithRole('admin');
});

after(async () => {
await svlCases.api.deleteAllCaseItems();
await pageObjects.svlCommonPage.forceLogout();
});

beforeEach(async () => {
await pageObjects.svlCommonPage.loginWithRole('admin');
});

it('cases list screenshot', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,6 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
await pageObjects.svlCommonPage.loginWithRole('admin');
});

after(async () => {
await pageObjects.svlCommonPage.forceLogout();
});

it('server log connector screenshots', async () => {
await pageObjects.common.navigateToApp('connectors');
await pageObjects.header.waitUntilLoadingHasFinished();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {
await pageObjects.svlCommonPage.loginWithRole('admin');
});

after(async () => {
await pageObjects.svlCommonPage.forceLogout();
});

it('create maintenance window screenshot', async () => {
await pageObjects.common.navigateToApp('maintenanceWindows');
await pageObjects.header.waitUntilLoadingHasFinished();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,6 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
await pageObjects.common.navigateToApp('settings');
});

after(async () => {
await pageObjects.svlCommonPage.forceLogout();
});

it('renders the page', async () => {
await retry.waitFor('title to be visible', async () => {
return await testSubjects.exists('managementSettingsTitle');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {

after(async () => {
await cspDashboard.index.remove();
await pageObjects.svlCommonPage.forceLogout();
});

describe('Kubernetes Dashboard', () => {
Expand Down

0 comments on commit ccfc5d3

Please sign in to comment.