kibana/x-pack/test/api_integration/apis/features/features/features.ts
Brandon Kobel 21841f6ff8
Removing the lens feature, using visualize instead (#48041)
* Removing the lens feature, using visualize instead

* Updating /api/features test because lens isn't a feature anymore

* Updating capability from lens to visualize in test

* Fixing api integration test
2019-10-15 12:03:12 -07:00

124 lines
3.5 KiB
TypeScript

/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
import expect from '@kbn/expect';
import { SecurityService } from '../../../../common/services';
import { Feature } from '../../../../../plugins/features/server';
import { FtrProviderContext } from '../../../ftr_provider_context';
export default function({ getService }: FtrProviderContext) {
const supertest = getService('supertest');
const supertestWithoutAuth = getService('supertestWithoutAuth');
const security: SecurityService = getService('security');
describe('/api/features', () => {
describe('with the "global all" privilege', () => {
it('should return a 200', async () => {
const username = 'global_all';
const roleName = 'global_all';
const password = `${username}-password`;
try {
await security.role.create(roleName, {
elasticsearch: {},
kibana: [
{
base: ['all'],
spaces: ['*'],
},
],
});
await security.user.create(username, {
password,
roles: [roleName],
full_name: 'a kibana user',
});
await supertestWithoutAuth
.get('/api/features')
.auth(username, password)
.set('kbn-xsrf', 'foo')
.expect(200);
} finally {
await security.role.delete(roleName);
await security.user.delete(username);
}
});
});
describe('without the "global all" privilege', () => {
it('should return a 404', async () => {
const username = 'dashboard_all';
const roleName = 'dashboard_all';
const password = `${username}-password`;
try {
await security.role.create(roleName, {
elasticsearch: {},
kibana: [
{
feature: {
dashboard: ['all'],
},
spaces: ['*'],
},
],
});
await security.user.create(username, {
password,
roles: [roleName],
full_name: 'a kibana user',
});
await supertestWithoutAuth
.get('/api/features')
.auth(username, password)
.set('kbn-xsrf', 'foo')
.expect(404);
} finally {
await security.role.delete(roleName);
await security.user.delete(username);
}
});
});
describe('with trial license', () => {
it('should return a full feature set', async () => {
const { body } = await supertest
.get('/api/features')
.set('kbn-xsrf', 'xxx')
.expect(200);
expect(body).to.be.an(Array);
const featureIds = body.map((b: Feature) => b.id);
expect(featureIds.sort()).to.eql(
[
'discover',
'visualize',
'dashboard',
'dev_tools',
'advancedSettings',
'indexPatterns',
'timelion',
'graph',
'monitoring',
'savedObjectsManagement',
'ml',
'apm',
'canvas',
'code',
'infrastructure',
'logs',
'maps',
'uptime',
'siem',
].sort()
);
});
});
});
}