diff --git a/x-pack/test/security_functional/screenshots/baseline/reset_session_page.png b/x-pack/test/security_functional/screenshots/baseline/reset_session_page.png new file mode 100644 index 0000000000000..8ef70d4bf357a Binary files /dev/null and b/x-pack/test/security_functional/screenshots/baseline/reset_session_page.png differ diff --git a/x-pack/test/security_functional/tests/login_selector/index.ts b/x-pack/test/security_functional/tests/login_selector/index.ts index bf3cc557f0bd7..ae81b307987cc 100644 --- a/x-pack/test/security_functional/tests/login_selector/index.ts +++ b/x-pack/test/security_functional/tests/login_selector/index.ts @@ -11,5 +11,6 @@ export default function ({ loadTestFile }: FtrProviderContext) { describe('security app - login selector', function () { loadTestFile(require.resolve('./basic_functionality')); loadTestFile(require.resolve('./auth_provider_hint')); + loadTestFile(require.resolve('./reset_session_page')); }); } diff --git a/x-pack/test/security_functional/tests/login_selector/reset_session_page.ts b/x-pack/test/security_functional/tests/login_selector/reset_session_page.ts new file mode 100644 index 0000000000000..e4a9321b4b6f7 --- /dev/null +++ b/x-pack/test/security_functional/tests/login_selector/reset_session_page.ts @@ -0,0 +1,55 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import expect from '@kbn/expect'; +import { FtrProviderContext } from '../../ftr_provider_context'; + +export default function ({ getService, getPageObjects, updateBaselines }: FtrProviderContext) { + const screenshots = getService('screenshots'); + const browser = getService('browser'); + const security = getService('security'); + const PageObjects = getPageObjects(['security', 'common']); + + describe('reset session page', function () { + const userWithoutPermissions = { username: 'user_without_permissions', password: 'changeme' }; + + before(async () => { + // We use a really small window to minimize differences across os's and browsers. + await browser.setScreenshotSize(1000, 500); + + await security.user.create(userWithoutPermissions.username, { + password: userWithoutPermissions.password, + roles: [], + }); + }); + + beforeEach(async () => { + // Logout needs to happen before anything else to avoid flaky behavior + await PageObjects.security.forceLogout(); + }); + + after(async () => { + // Clean up after ourselves + await security.user.delete(userWithoutPermissions.username); + await PageObjects.security.forceLogout(); + }); + + it('compare screenshot', async () => { + await PageObjects.security.loginSelector.login('basic', 'basic1', { + username: userWithoutPermissions.username, + password: userWithoutPermissions.password, + expectedLoginResult: 'error', + }); + + const percentDifference = await screenshots.compareAgainstBaseline( + 'reset_session_page', + updateBaselines + ); + expect(percentDifference).to.be.lessThan(0.022); + }); + }); +}