Skip to content

Commit

Permalink
[Monitoring] Use a basic monitoring user for tests (#47865) (#50930)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
chrisronline authored Nov 18, 2019
1 parent a7c6635 commit cd625d2
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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);
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down
2 changes: 1 addition & 1 deletion x-pack/test/functional/apps/monitoring/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
Expand All @@ -40,5 +39,6 @@ export default function ({ loadTestFile }) {
loadTestFile(require.resolve('./beats/beat_detail'));

loadTestFile(require.resolve('./time_filter'));
loadTestFile(require.resolve('./enable_monitoring'));
});
}
19 changes: 17 additions & 2 deletions x-pack/test/functional/page_objects/monitoring_page.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}

Expand Down

0 comments on commit cd625d2

Please sign in to comment.