From cd625d2a5886eb07fdd584551433561eff7427ba Mon Sep 17 00:00:00 2001 From: Chris Roberson Date: Mon, 18 Nov 2019 13:02:25 -0500 Subject: [PATCH] [Monitoring] Use a basic monitoring user for tests (#47865) (#50930) * Use a basic monitoring user for tests * Rework this a little to fix the issue that the tests aren't working properly * I think this is what we need to fix the tests * Switch this order, since these tests cause a weird login loop in the current order --- .../apps/monitoring/_get_lifecycle_methods.js | 7 +++++-- .../monitoring/enable_monitoring/index.js | 2 +- .../feature_controls/monitoring_security.ts | 2 +- .../feature_controls/monitoring_spaces.ts | 6 ++++++ .../test/functional/apps/monitoring/index.js | 2 +- .../page_objects/monitoring_page.js | 19 +++++++++++++++++-- 6 files changed, 31 insertions(+), 7 deletions(-) diff --git a/x-pack/test/functional/apps/monitoring/_get_lifecycle_methods.js b/x-pack/test/functional/apps/monitoring/_get_lifecycle_methods.js index 6e2f0e2f00bccf..c1faa25ed9c70a 100644 --- a/x-pack/test/functional/apps/monitoring/_get_lifecycle_methods.js +++ b/x-pack/test/functional/apps/monitoring/_get_lifecycle_methods.js @@ -6,7 +6,8 @@ export const getLifecycleMethods = (getService, getPageObjects) => { const esArchiver = getService('esArchiver'); - const PageObjects = getPageObjects(['monitoring', 'timePicker']); + const security = getService('security'); + const PageObjects = getPageObjects(['monitoring', 'timePicker', 'security']); const noData = getService('monitoringNoData'); let _archive; @@ -33,7 +34,9 @@ export const getLifecycleMethods = (getService, getPageObjects) => { await PageObjects.timePicker.setAbsoluteRange(from, to); }, - tearDown() { + async tearDown() { + await PageObjects.security.logout(); + await security.user.delete('basic_monitoring_user'); return esArchiver.unload(_archive); } }; diff --git a/x-pack/test/functional/apps/monitoring/enable_monitoring/index.js b/x-pack/test/functional/apps/monitoring/enable_monitoring/index.js index 2cdecc58266a6a..aa96d712287990 100644 --- a/x-pack/test/functional/apps/monitoring/enable_monitoring/index.js +++ b/x-pack/test/functional/apps/monitoring/enable_monitoring/index.js @@ -17,7 +17,7 @@ export default function ({ getService, getPageObjects }) { before(async () => { const browser = getService('browser'); await browser.setWindowSize(1600, 1000); - await PageObjects.monitoring.navigateTo(); + await PageObjects.monitoring.navigateTo(true); await noData.isOnNoDataPage(); }); diff --git a/x-pack/test/functional/apps/monitoring/feature_controls/monitoring_security.ts b/x-pack/test/functional/apps/monitoring/feature_controls/monitoring_security.ts index 2d645d161c134a..84a4a2697a278b 100644 --- a/x-pack/test/functional/apps/monitoring/feature_controls/monitoring_security.ts +++ b/x-pack/test/functional/apps/monitoring/feature_controls/monitoring_security.ts @@ -13,7 +13,7 @@ export default function({ getPageObjects, getService }: FtrProviderContext) { const appsMenu = getService('appsMenu'); const PageObjects = getPageObjects(['common', 'security']); - describe('securty', () => { + describe('security', () => { before(async () => { await esArchiver.load('empty_kibana'); diff --git a/x-pack/test/functional/apps/monitoring/feature_controls/monitoring_spaces.ts b/x-pack/test/functional/apps/monitoring/feature_controls/monitoring_spaces.ts index 94714f7b0ca348..4508d6a8e5a189 100644 --- a/x-pack/test/functional/apps/monitoring/feature_controls/monitoring_spaces.ts +++ b/x-pack/test/functional/apps/monitoring/feature_controls/monitoring_spaces.ts @@ -19,6 +19,12 @@ export default function({ getPageObjects, getService }: FtrProviderContext) { await esArchiver.load('empty_kibana'); }); + after(async () => { + await esArchiver.unload('empty_kibana'); + await PageObjects.common.navigateToApp('home'); + await PageObjects.security.logout(); + }); + describe('space with no features disabled', () => { before(async () => { await spacesService.create({ diff --git a/x-pack/test/functional/apps/monitoring/index.js b/x-pack/test/functional/apps/monitoring/index.js index 06c8dc292869e2..77ca4087da13a9 100644 --- a/x-pack/test/functional/apps/monitoring/index.js +++ b/x-pack/test/functional/apps/monitoring/index.js @@ -13,7 +13,6 @@ export default function ({ loadTestFile }) { loadTestFile(require.resolve('./cluster/list')); loadTestFile(require.resolve('./cluster/overview')); loadTestFile(require.resolve('./cluster/alerts')); - loadTestFile(require.resolve('./enable_monitoring')); // loadTestFile(require.resolve('./cluster/license')); loadTestFile(require.resolve('./elasticsearch/overview')); @@ -40,5 +39,6 @@ export default function ({ loadTestFile }) { loadTestFile(require.resolve('./beats/beat_detail')); loadTestFile(require.resolve('./time_filter')); + loadTestFile(require.resolve('./enable_monitoring')); }); } diff --git a/x-pack/test/functional/page_objects/monitoring_page.js b/x-pack/test/functional/page_objects/monitoring_page.js index 933962c160bc9f..58214f17f4ff00 100644 --- a/x-pack/test/functional/page_objects/monitoring_page.js +++ b/x-pack/test/functional/page_objects/monitoring_page.js @@ -5,11 +5,26 @@ */ export function MonitoringPageProvider({ getPageObjects, getService }) { - const PageObjects = getPageObjects(['common', 'header']); + const PageObjects = getPageObjects(['common', 'header', 'shield', 'spaceSelector']); const testSubjects = getService('testSubjects'); + const security = getService('security'); return new class MonitoringPage { - async navigateTo() { + async navigateTo(useSuperUser = false) { + // always create this because our tear down tries to delete it + await security.user.create('basic_monitoring_user', { + password: 'monitoring_user_password', + roles: ['monitoring_user', 'kibana_user'], + full_name: 'basic monitoring', + }); + + if (!useSuperUser) { + await PageObjects.common.navigateToApp('login'); + await PageObjects.shield.login( + 'basic_monitoring_user', + 'monitoring_user_password' + ); + } await PageObjects.common.navigateToApp('monitoring'); }