Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Maps] fix users without access to Maps should not have the option to create them #88830

Merged
merged 4 commits into from
Jan 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion x-pack/plugins/maps/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,11 +160,19 @@ export class MapsPlugin

public start(core: CoreStart, plugins: MapsPluginStartDependencies): MapsStartApi {
setLicensingPluginStart(plugins.licensing);
plugins.uiActions.addTriggerAction(VISUALIZE_GEO_FIELD_TRIGGER, visualizeGeoFieldAction);
setStartServices(core, plugins);

// unregisters the OSS alias
plugins.visualizations.unRegisterAlias(PLUGIN_ID_OSS);

if (core.application.capabilities.maps.show) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

plugins.uiActions.addTriggerAction(VISUALIZE_GEO_FIELD_TRIGGER, visualizeGeoFieldAction);
}

if (!core.application.capabilities.maps.save) {
plugins.visualizations.unRegisterAlias(APP_ID);
}

return {
createLayerDescriptors,
registerLayerWizard,
Expand Down
82 changes: 53 additions & 29 deletions x-pack/test/functional/apps/maps/visualize_create_menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,42 +12,66 @@ export default function ({ getService, getPageObjects }) {
const security = getService('security');

describe('visualize create menu', () => {
before(async () => {
await security.testUser.setRoles(
['test_logstash_reader', 'global_maps_all', 'geoshape_data_reader', 'global_visualize_all'],
false
);
describe('maps visualize alias', () => {
describe('with write permission', () => {
before(async () => {
await security.testUser.setRoles(['global_maps_all', 'global_visualize_all'], false);

await PageObjects.visualize.navigateToNewVisualization();
});
await PageObjects.visualize.navigateToNewVisualization();
});

after(async () => {
await security.testUser.restoreDefaults();
});
it('should show maps application in create menu', async () => {
const hasMapsApp = await PageObjects.visualize.hasMapsApp();
expect(hasMapsApp).to.equal(true);
});

it('should show maps application in create menu', async () => {
const hasMapsApp = await PageObjects.visualize.hasMapsApp();
expect(hasMapsApp).to.equal(true);
});
it('should take users to Maps application when Maps is clicked', async () => {
await PageObjects.visualize.clickMapsApp();
await PageObjects.header.waitUntilLoadingHasFinished();
await PageObjects.maps.waitForLayersToLoad();
const doesLayerExist = await PageObjects.maps.doesLayerExist('Road map');
expect(doesLayerExist).to.equal(true);
});
});

it('should not show legacy region map visualizion in create menu', async () => {
await PageObjects.visualize.clickAggBasedVisualizations();
const hasLegecyViz = await PageObjects.visualize.hasRegionMap();
expect(hasLegecyViz).to.equal(false);
});
describe('without write permission', () => {
before(async () => {
await security.testUser.setRoles(['global_maps_read', 'global_visualize_all'], false);

await PageObjects.visualize.navigateToNewVisualization();
});

it('should not show legacy tilemap map visualizion in create menu', async () => {
const hasLegecyViz = await PageObjects.visualize.hasTileMap();
expect(hasLegecyViz).to.equal(false);
after(async () => {
await security.testUser.restoreDefaults();
});

it('should not show maps application in create menu', async () => {
const hasMapsApp = await PageObjects.visualize.hasMapsApp();
expect(hasMapsApp).to.equal(false);
});
});
});

it('should take users to Maps application when Maps is clicked', async () => {
await PageObjects.visualize.goBackToGroups();
await PageObjects.visualize.clickMapsApp();
await PageObjects.header.waitUntilLoadingHasFinished();
await PageObjects.maps.waitForLayersToLoad();
const doesLayerExist = await PageObjects.maps.doesLayerExist('Road map');
expect(doesLayerExist).to.equal(true);
describe('aggregion based visualizations', () => {
before(async () => {
await security.testUser.setRoles(['global_visualize_all'], false);

await PageObjects.visualize.navigateToNewAggBasedVisualization();
});

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

it('should not show legacy region map visualizion in create menu', async () => {
const hasLegecyViz = await PageObjects.visualize.hasRegionMap();
expect(hasLegecyViz).to.equal(false);
});

it('should not show legacy tilemap map visualizion in create menu', async () => {
const hasLegecyViz = await PageObjects.visualize.hasTileMap();
expect(hasLegecyViz).to.equal(false);
});
});
});
}