Skip to content

Commit

Permalink
Test user for maps test verifying sample data maps (#96109)
Browse files Browse the repository at this point in the history
 test user for sample maps test & removing geoall_writer_role from add layer
  • Loading branch information
bhavyarm committed Apr 14, 2021
1 parent 87f2c10 commit fc62886
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 35 deletions.
15 changes: 15 additions & 0 deletions test/functional/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,21 @@ export default async function ({ readConfigFile }) {
kibana: [],
},

kibana_sample_read: {
elasticsearch: {
cluster: [],
indices: [
{
names: ['kibana_sample*'],
privileges: ['read', 'view_index_metadata'],
field_security: { grant: ['*'], except: [] },
},
],
run_as: [],
},
kibana: [],
},

kibana_date_nanos: {
elasticsearch: {
cluster: [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,7 @@ export default function ({ getPageObjects, getService }) {

describe('GeoJSON import layer panel', () => {
before(async () => {
await security.testUser.setRoles([
'global_maps_all',
'geoall_data_writer',
'global_index_pattern_management_all',
]);
await security.testUser.setRoles(['global_maps_all', 'global_index_pattern_management_all']);
await PageObjects.maps.openNewMap();
});

Expand Down
53 changes: 23 additions & 30 deletions x-pack/test/functional/apps/maps/sample_data.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,22 @@ export default function ({ getPageObjects, getService, updateBaselines }) {
const screenshot = getService('screenshots');
const testSubjects = getService('testSubjects');
const kibanaServer = getService('kibanaServer');
const security = getService('security');

// Only update the baseline images from Jenkins session images after comparing them
// These tests might fail locally because of scaling factors and resolution.

describe('maps loaded from sample data', () => {
before(async () => {
//installing the sample data with test user with super user role and then switching roles with limited privileges
await security.testUser.setRoles(['superuser'], false);
await PageObjects.common.navigateToUrl('home', '/tutorial_directory/sampleData', {
useActualUrl: true,
});
await PageObjects.header.waitUntilLoadingHasFinished();
await PageObjects.home.addSampleDataSet('ecommerce');
await PageObjects.home.addSampleDataSet('flights');
await PageObjects.home.addSampleDataSet('logs');
const SAMPLE_DATA_RANGE = `[
{
"from": "now-30d",
Expand Down Expand Up @@ -80,15 +90,23 @@ export default function ({ getPageObjects, getService, updateBaselines }) {
await kibanaServer.uiSettings.update({
[UI_SETTINGS.TIMEPICKER_QUICK_RANGES]: SAMPLE_DATA_RANGE,
});
//running the rest of the tests with limited roles
await security.testUser.setRoles(['global_maps_all', 'kibana_sample_read'], false);
});

after(async () => {
await security.testUser.restoreDefaults();
await PageObjects.common.navigateToUrl('home', '/tutorial_directory/sampleData', {
useActualUrl: true,
});
await PageObjects.header.waitUntilLoadingHasFinished();
await PageObjects.home.removeSampleDataSet('ecommerce');
await PageObjects.home.removeSampleDataSet('flights');
await PageObjects.home.removeSampleDataSet('logs');
});

describe('ecommerce', () => {
before(async () => {
await PageObjects.common.navigateToUrl('home', '/tutorial_directory/sampleData', {
useActualUrl: true,
});
await PageObjects.header.waitUntilLoadingHasFinished();
await PageObjects.home.addSampleDataSet('ecommerce');
await PageObjects.maps.loadSavedMap('[eCommerce] Orders by Country');
await PageObjects.maps.toggleLayerVisibility('Road map');
await PageObjects.maps.toggleLayerVisibility('United Kingdom');
Expand All @@ -104,11 +122,6 @@ export default function ({ getPageObjects, getService, updateBaselines }) {

after(async () => {
await PageObjects.maps.existFullScreen();
await PageObjects.common.navigateToUrl('home', '/tutorial_directory/sampleData', {
useActualUrl: true,
});
await PageObjects.header.waitUntilLoadingHasFinished();
await PageObjects.home.removeSampleDataSet('ecommerce');
});

it('should load layers', async () => {
Expand All @@ -122,11 +135,6 @@ export default function ({ getPageObjects, getService, updateBaselines }) {

describe('flights', () => {
before(async () => {
await PageObjects.common.navigateToUrl('home', '/tutorial_directory/sampleData', {
useActualUrl: true,
});
await PageObjects.header.waitUntilLoadingHasFinished();
await PageObjects.home.addSampleDataSet('flights');
await PageObjects.maps.loadSavedMap('[Flights] Origin and Destination Flight Time');
await PageObjects.maps.toggleLayerVisibility('Road map');
await PageObjects.timePicker.setCommonlyUsedTime('sample_data range');
Expand All @@ -138,11 +146,6 @@ export default function ({ getPageObjects, getService, updateBaselines }) {

after(async () => {
await PageObjects.maps.existFullScreen();
await PageObjects.common.navigateToUrl('home', '/tutorial_directory/sampleData', {
useActualUrl: true,
});
await PageObjects.header.waitUntilLoadingHasFinished();
await PageObjects.home.removeSampleDataSet('flights');
});

it('should load saved object and display layers', async () => {
Expand All @@ -156,11 +159,6 @@ export default function ({ getPageObjects, getService, updateBaselines }) {

describe('web logs', () => {
before(async () => {
await PageObjects.common.navigateToUrl('home', '/tutorial_directory/sampleData', {
useActualUrl: true,
});
await PageObjects.header.waitUntilLoadingHasFinished();
await PageObjects.home.addSampleDataSet('logs');
await PageObjects.maps.loadSavedMap('[Logs] Total Requests and Bytes');
await PageObjects.maps.toggleLayerVisibility('Road map');
await PageObjects.maps.toggleLayerVisibility('Total Requests by Country');
Expand All @@ -173,11 +171,6 @@ export default function ({ getPageObjects, getService, updateBaselines }) {

after(async () => {
await PageObjects.maps.existFullScreen();
await PageObjects.common.navigateToUrl('home', '/tutorial_directory/sampleData', {
useActualUrl: true,
});
await PageObjects.header.waitUntilLoadingHasFinished();
await PageObjects.home.removeSampleDataSet('logs');
});

it('should load saved object and display layers', async () => {
Expand Down

0 comments on commit fc62886

Please sign in to comment.