Skip to content

Commit

Permalink
Review#1: make sure we are preserving original URL, remove legacy stu…
Browse files Browse the repository at this point in the history
…ff and properly detect that chrome is visible.
  • Loading branch information
azasypkin committed May 14, 2020
1 parent 892fbba commit e8766ee
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import { FtrProviderContext } from '../../../ftr_provider_context';

export default function({ loadTestFile }: FtrProviderContext) {
describe('security app - login selector - trial license', function() {
describe('security app - trial license', function() {
this.tags('ciGroup4');

loadTestFile(require.resolve('./login_selector'));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
*/

import expect from '@kbn/expect';
import { parse } from 'url';
import { USERS_PATH } from '../../../../../plugins/security/public/management/management_urls';
import { FtrProviderContext } from '../../../ftr_provider_context';

export default function({ getService, getPageObjects }: FtrProviderContext) {
Expand Down Expand Up @@ -39,12 +41,34 @@ export default function({ getService, getPageObjects }: FtrProviderContext) {
await PageObjects.security.forceLogout();
});

it('can login with Login Form', async () => {
it('can login with Login Form preserving original URL', async () => {
await PageObjects.common.navigateToActualUrl('kibana', USERS_PATH, {
ensureCurrentUrl: false,
shouldLoginIfPrompted: false,
});
await PageObjects.common.waitUntilUrlIncludes('next=');

await PageObjects.security.loginSelector.login('basic', 'basic1');

// We need to make sure that both path and hash are respected.
const currentURL = parse(await browser.getCurrentUrl());
expect(currentURL.pathname).to.eql('/app/kibana');
expect(currentURL.hash).to.eql(`#${USERS_PATH}`);
});

it('can login with SSO', async () => {
it('can login with SSO preserving original URL', async () => {
await PageObjects.common.navigateToActualUrl('kibana', USERS_PATH, {
ensureCurrentUrl: false,
shouldLoginIfPrompted: false,
});
await PageObjects.common.waitUntilUrlIncludes('next=');

await PageObjects.security.loginSelector.login('saml', 'saml1');

// We need to make sure that both path and hash are respected.
const currentURL = parse(await browser.getCurrentUrl());
expect(currentURL.pathname).to.eql('/app/kibana');
expect(currentURL.hash).to.eql(`#${USERS_PATH}`);
});

it('should show toast with error if SSO fails', async () => {
Expand Down
15 changes: 5 additions & 10 deletions x-pack/test/functional/page_objects/security_page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,23 +27,15 @@ export function SecurityPageProvider({ getService, getPageObjects }: FtrProvider
type LoginExpectedResult = 'spaceSelector' | 'error' | 'chrome';

async function waitForLoginPage() {
log.debug('Waiting for Login Page to appear.');
await retry.waitForWithTimeout('login page', config.get('timeouts.waitFor') * 5, async () => {
const alert = await browser.getAlert();
if (alert && alert.accept) {
await alert.accept();
}
return await find.existsByDisplayedByCssSelector('.login-form');
});
}

async function waitForLoginForm() {
log.debug('Waiting for Login Form to appear.');
await retry.waitForWithTimeout('login form', config.get('timeouts.waitFor') * 5, async () => {
const alert = await browser.getAlert();
if (alert && alert.accept) {
await alert.accept();
}

return await testSubjects.exists('loginForm');
});
}
Expand Down Expand Up @@ -97,7 +89,10 @@ export function SecurityPageProvider({ getService, getPageObjects }: FtrProvider
}

if (expectedResult === 'chrome') {
await find.byCssSelector('[data-test-subj="kibanaChrome"] nav:not(.ng-hide) ', 20000);
await find.byCssSelector(
'[data-test-subj="kibanaChrome"] .app-wrapper:not(.hidden-chrome)',
20000
);
log.debug(`Finished login process currentUrl = ${await browser.getCurrentUrl()}`);
}
}
Expand Down

0 comments on commit e8766ee

Please sign in to comment.