Skip to content

Commit

Permalink
Add correct roles to test user for functional tests in dashboard (#11…
Browse files Browse the repository at this point in the history
…0880) (#111048)

* Add animals role to test user for functional tests in dashboard

* Fix two more dashboard tests by applying proper roles

* Restore test user defaults

* Fix one last dashboard test

* forgot security service

* Cleanup

Co-authored-by: Poff Poffenberger <[email protected]>
  • Loading branch information
kibanamachine and poffdeluxe authored Sep 2, 2021
1 parent 4fe13b3 commit 7135609
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 2 deletions.
6 changes: 6 additions & 0 deletions test/functional/apps/dashboard/dashboard_back_button.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,25 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
const kibanaServer = getService('kibanaServer');
const PageObjects = getPageObjects(['dashboard', 'header', 'common', 'visualize', 'timePicker']);
const browser = getService('browser');
const security = getService('security');

describe('dashboard back button', () => {
before(async () => {
await esArchiver.loadIfNeeded(
'test/functional/fixtures/es_archiver/dashboard/current/kibana'
);
await security.testUser.setRoles(['kibana_admin', 'animals', 'test_logstash_reader']);
await kibanaServer.uiSettings.replace({
defaultIndex: '0bf35f60-3dc9-11e8-8660-4d65aa086b3c',
});
await PageObjects.common.navigateToApp('dashboard');
await PageObjects.dashboard.preserveCrossAppState();
});

after(async () => {
await security.testUser.restoreDefaults();
});

it('after navigation from listing page to dashboard back button works', async () => {
await PageObjects.dashboard.gotoDashboardLandingPage();
await PageObjects.dashboard.loadSavedDashboard('dashboard with everything');
Expand Down
8 changes: 7 additions & 1 deletion test/functional/apps/dashboard/dashboard_filter_bar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
const esArchiver = getService('esArchiver');
const kibanaServer = getService('kibanaServer');
const browser = getService('browser');
const security = getService('security');
const PageObjects = getPageObjects([
'common',
'dashboard',
Expand All @@ -32,12 +33,17 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
describe('dashboard filter bar', () => {
before(async () => {
await esArchiver.load('test/functional/fixtures/es_archiver/dashboard/current/kibana');
await security.testUser.setRoles(['kibana_admin', 'test_logstash_reader', 'animals']);
await kibanaServer.uiSettings.replace({
defaultIndex: '0bf35f60-3dc9-11e8-8660-4d65aa086b3c',
});
await PageObjects.common.navigateToApp('dashboard');
});

after(async () => {
await security.testUser.restoreDefaults();
});

describe('Add a filter bar', function () {
before(async () => {
await PageObjects.dashboard.gotoDashboardLandingPage();
Expand Down Expand Up @@ -181,7 +187,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
it('are added when a cell magnifying glass is clicked', async function () {
await dashboardAddPanel.addSavedSearch('Rendering-Test:-saved-search');
await PageObjects.dashboard.waitForRenderComplete();
const isLegacyDefault = PageObjects.discover.useLegacyTable();
const isLegacyDefault = await PageObjects.discover.useLegacyTable();
if (isLegacyDefault) {
await testSubjects.click('docTableCellFilter');
} else {
Expand Down
6 changes: 6 additions & 0 deletions test/functional/apps/dashboard/data_shared_attributes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
const esArchiver = getService('esArchiver');
const kibanaServer = getService('kibanaServer');
const dashboardPanelActions = getService('dashboardPanelActions');
const security = getService('security');
const PageObjects = getPageObjects(['common', 'dashboard', 'timePicker']);

describe('dashboard data-shared attributes', function describeIndexTests() {
let originalPanelTitles: string[];

before(async () => {
await esArchiver.load('test/functional/fixtures/es_archiver/dashboard/current/kibana');
await security.testUser.setRoles(['kibana_admin', 'test_logstash_reader', 'animals']);
await kibanaServer.uiSettings.replace({
defaultIndex: '0bf35f60-3dc9-11e8-8660-4d65aa086b3c',
});
Expand All @@ -31,6 +33,10 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
await PageObjects.dashboard.waitForRenderComplete();
});

after(async () => {
await security.testUser.restoreDefaults();
});

it('should have time picker with data-shared-timefilter-duration', async () => {
await retry.try(async () => {
const sharedData = await PageObjects.timePicker.getTimeDurationForSharing();
Expand Down
2 changes: 1 addition & 1 deletion test/functional/apps/dashboard/legacy_urls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {

describe('legacy urls', function describeIndexTests() {
before(async function () {
await security.testUser.setRoles(['kibana_admin', 'animals']);
await security.testUser.setRoles(['kibana_admin', 'test_logstash_reader', 'animals']);
await esArchiver.load('test/functional/fixtures/es_archiver/dashboard/current/kibana');
await PageObjects.common.navigateToApp('dashboard');
await PageObjects.dashboard.clickNewDashboard();
Expand Down
6 changes: 6 additions & 0 deletions test/functional/apps/dashboard/view_edit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,23 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
const PageObjects = getPageObjects(['dashboard', 'header', 'common', 'visualize', 'timePicker']);
const dashboardName = 'dashboard with filter';
const filterBar = getService('filterBar');
const security = getService('security');

describe('dashboard view edit mode', function viewEditModeTests() {
before(async () => {
await esArchiver.load('test/functional/fixtures/es_archiver/dashboard/current/kibana');
await security.testUser.setRoles(['kibana_admin', 'test_logstash_reader', 'animals']);
await kibanaServer.uiSettings.replace({
defaultIndex: '0bf35f60-3dc9-11e8-8660-4d65aa086b3c',
});
await PageObjects.common.navigateToApp('dashboard');
await PageObjects.dashboard.preserveCrossAppState();
});

after(async () => {
await security.testUser.restoreDefaults();
});

it('create new dashboard opens in edit mode', async function () {
await PageObjects.dashboard.gotoDashboardLandingPage();
await PageObjects.dashboard.clickNewDashboard();
Expand Down

0 comments on commit 7135609

Please sign in to comment.