Skip to content

Commit

Permalink
Enable security plugin in OSS tests
Browse files Browse the repository at this point in the history
This is a partial backport of #111681, so the Kibana security
plugin is enabled but Elasticsearch security is still disabled.
  • Loading branch information
Joe Portner committed Apr 11, 2022
1 parent ef3aa64 commit 4ab0c09
Show file tree
Hide file tree
Showing 15 changed files with 58 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export default function ({ getService }: FtrProviderContext) {

expect(resp.body).to.be.an('array');

expect(resp.body.length).to.be(13);
expect(resp.body.length).to.be(34);

// Test for sample data card
expect(resp.body.findIndex((c: { id: string }) => c.id === 'sample_data_all')).to.be.above(
Expand Down
11 changes: 5 additions & 6 deletions test/common/services/security/test_user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,12 @@ export class TestUser extends FtrService {
export async function createTestUserService(ctx: FtrProviderContext, role: Role, user: User) {
const log = ctx.getService('log');
const config = ctx.getService('config');
const kibanaServer = ctx.getService('kibanaServer');

const enabledPlugins = config.get('security.disableTestUser')
? []
: await kibanaServer.plugins.getEnabledIds();

const enabled = enabledPlugins.includes('security') && !config.get('security.disableTestUser');
const enabled =
!config
.get('esTestCluster.serverArgs')
.some((arg: string) => arg === 'xpack.security.enabled=false') &&
!config.get('security.disableTestUser');

if (enabled) {
log.debug('===============creating roles and users===============');
Expand Down
3 changes: 0 additions & 3 deletions test/functional/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,7 @@ export default async function ({ readConfigFile }) {
'--xpack.maps.showMapVisualizationTypes=true',

// to be re-enabled once kibana/issues/102552 is completed
'--xpack.security.enabled=false',
'--monitoring.enabled=false',
'--xpack.reporting.enabled=false',
'--enterpriseSearch.enabled=false',
],
},

Expand Down
4 changes: 3 additions & 1 deletion x-pack/test/alerting_api_integration/common/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,9 @@ export function createTestConfig(name: string, options: CreateTestConfigOptions)
},
},
})}`,
...disabledPlugins.map((key) => `--xpack.${key}.enabled=false`),
...disabledPlugins
.filter((k) => k !== 'security')
.map((key) => `--xpack.${key}.enabled=false`),
...plugins.map(
(pluginDir) =>
`--plugin-path=${path.resolve(__dirname, 'fixtures', 'plugins', pluginDir)}`
Expand Down
4 changes: 3 additions & 1 deletion x-pack/test/case_api_integration/common/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,9 @@ export function createTestConfig(name: string, options: CreateTestConfigOptions)
`--xpack.actions.allowedHosts=${JSON.stringify(['localhost', 'some.non.existent.com'])}`,
`--xpack.actions.enabledActionTypes=${JSON.stringify(enabledActionTypes)}`,
'--xpack.eventLog.logEntries=true',
...disabledPlugins.map((key) => `--xpack.${key}.enabled=false`),
...disabledPlugins
.filter((k) => k !== 'security')
.map((key) => `--xpack.${key}.enabled=false`),
// Actions simulators plugin. Needed for testing push to external services.
...alertingPlugins.map(
(pluginDir) =>
Expand Down
4 changes: 3 additions & 1 deletion x-pack/test/lists_api_integration/common/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ export function createTestConfig(name: string, options: CreateTestConfigOptions)
...xPackApiIntegrationTestsConfig.get('kbnTestServer'),
serverArgs: [
...xPackApiIntegrationTestsConfig.get('kbnTestServer.serverArgs'),
...disabledPlugins.map((key) => `--xpack.${key}.enabled=false`),
...disabledPlugins
.filter((k) => k !== 'security')
.map((key) => `--xpack.${key}.enabled=false`),
`--plugin-path=${path.join(__dirname, 'fixtures', 'plugins', 'alerts')}`,
`--plugin-path=${path.join(__dirname, 'fixtures', 'plugins', 'actions')}`,
`--plugin-path=${path.join(__dirname, 'fixtures', 'plugins', 'task_manager')}`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export default async function ({ readConfigFile }: FtrConfigProviderContext) {
},
kbnTestServer: {
...apiConfig.get('kbnTestServer'),
serverArgs: [...apiConfig.get('kbnTestServer.serverArgs'), `--xpack.security.enabled=false`],
serverArgs: [...apiConfig.get('kbnTestServer.serverArgs')],
},
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,7 @@ export default async function ({ readConfigFile }: FtrConfigProviderContext) {
testFiles: [resolve(__dirname, './reporting_without_security')],
kbnTestServer: {
...reportingConfig.get('kbnTestServer'),
serverArgs: [
...reportingConfig.get('kbnTestServer.serverArgs'),
`--xpack.security.enabled=false`,
],
serverArgs: [...reportingConfig.get('kbnTestServer.serverArgs')],
},
esTestCluster: {
...reportingConfig.get('esTestCluster'),
Expand Down
4 changes: 3 additions & 1 deletion x-pack/test/rule_registry/common/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,9 @@ export function createTestConfig(name: string, options: CreateTestConfigOptions)
`--xpack.actions.allowedHosts=${JSON.stringify(['localhost', 'some.non.existent.com'])}`,
`--xpack.actions.enabledActionTypes=${JSON.stringify(enabledActionTypes)}`,
'--xpack.eventLog.logEntries=true',
...disabledPlugins.map((key) => `--xpack.${key}.enabled=false`),
...disabledPlugins
.filter((k) => k !== 'security')
.map((key) => `--xpack.${key}.enabled=false`),
// TO DO: Remove feature flags once we're good to go
'--xpack.securitySolution.enableExperimental=["ruleRegistryEnabled"]',
'--xpack.ruleRegistry.write.enabled=true',
Expand Down
4 changes: 3 additions & 1 deletion x-pack/test/saved_object_api_integration/common/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ export function createTestConfig(name: string, options: CreateTestConfigOptions)
...config.xpack.api.get('kbnTestServer.serverArgs'),
'--server.xsrf.disableProtection=true',
`--plugin-path=${path.join(__dirname, 'fixtures', 'saved_object_test_plugin')}`,
...disabledPlugins.map((key) => `--xpack.${key}.enabled=false`),
...disabledPlugins
.filter((k) => k !== 'security')
.map((key) => `--xpack.${key}.enabled=false`),
],
},
};
Expand Down
4 changes: 3 additions & 1 deletion x-pack/test/spaces_api_integration/common/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@ export function createTestConfig(name: string, options: CreateTestConfigOptions)
'--status.allowAnonymous=false',
'--server.xsrf.disableProtection=true',
`--plugin-path=${path.join(__dirname, 'fixtures', 'spaces_test_plugin')}`,
...disabledPlugins.map((key) => `--xpack.${key}.enabled=false`),
...disabledPlugins
.filter((k) => k !== 'security')
.map((key) => `--xpack.${key}.enabled=false`),
],
},
};
Expand Down
4 changes: 3 additions & 1 deletion x-pack/test/timeline/common/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,9 @@ export function createTestConfig(name: string, options: CreateTestConfigOptions)
`--xpack.actions.allowedHosts=${JSON.stringify(['localhost', 'some.non.existent.com'])}`,
`--xpack.actions.enabledActionTypes=${JSON.stringify(enabledActionTypes)}`,
'--xpack.eventLog.logEntries=true',
...disabledPlugins.map((key) => `--xpack.${key}.enabled=false`),
...disabledPlugins
.filter((k) => k !== 'security')
.map((key) => `--xpack.${key}.enabled=false`),
// TO DO: Remove feature flags once we're good to go
'--xpack.securitySolution.enableExperimental=["ruleRegistryEnabled"]',
'--xpack.ruleRegistry.write.enabled=true',
Expand Down
4 changes: 3 additions & 1 deletion x-pack/test/ui_capabilities/common/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ export function createTestConfig(name: string, options: CreateTestConfigOptions)
...xPackFunctionalTestsConfig.get('kbnTestServer'),
serverArgs: [
...xPackFunctionalTestsConfig.get('kbnTestServer.serverArgs'),
...disabledPlugins.map((key) => `--xpack.${key}.enabled=false`),
...disabledPlugins
.filter((k) => k !== 'security')
.map((key) => `--xpack.${key}.enabled=false`),
`--plugin-path=${path.join(__dirname, 'fixtures', 'plugins', 'foo_plugin')}`,
],
},
Expand Down
15 changes: 13 additions & 2 deletions x-pack/test/ui_capabilities/spaces_only/tests/catalogue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@ export default function catalogueTests({ getService }: FtrProviderContext) {
'watcher',
];

const uiCapabilitiesExceptions = [
// enterprise_search plugin is loaded but disabled because security isn't enabled in ES. That means the following 3 capabilities are disabled
'enterpriseSearch',
'appSearch',
'workplaceSearch',
];

describe('catalogue', () => {
SpaceScenarios.forEach((scenario) => {
it(`${scenario.name}`, async () => {
Expand All @@ -33,7 +40,10 @@ export default function catalogueTests({ getService }: FtrProviderContext) {
expect(uiCapabilities.success).to.be(true);
expect(uiCapabilities.value).to.have.property('catalogue');
// everything is enabled
const expected = mapValues(uiCapabilities.value!.catalogue, () => true);
const expected = mapValues(
uiCapabilities.value!.catalogue,
(enabled, catalogueId) => !uiCapabilitiesExceptions.includes(catalogueId)
);
expect(uiCapabilities.value!.catalogue).to.eql(expected);
break;
}
Expand All @@ -55,7 +65,8 @@ export default function catalogueTests({ getService }: FtrProviderContext) {
// only foo is disabled
const expected = mapValues(
uiCapabilities.value!.catalogue,
(value, catalogueId) => catalogueId !== 'foo'
(enabled, catalogueId) =>
!uiCapabilitiesExceptions.includes(catalogueId) && catalogueId !== 'foo'
);
expect(uiCapabilities.value!.catalogue).to.eql(expected);
break;
Expand Down
15 changes: 13 additions & 2 deletions x-pack/test/ui_capabilities/spaces_only/tests/nav_links.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@ export default function navLinksTests({ getService }: FtrProviderContext) {
const uiCapabilitiesService: UICapabilitiesService = getService('uiCapabilities');
const featuresService: FeaturesService = getService('features');

const uiCapabilitiesExceptions = [
// enterprise_search plugin is loaded but disabled because security isn't enabled in ES. That means the following 3 capabilities are disabled
'enterpriseSearch',
'appSearch',
'workplaceSearch',
];

describe('navLinks', () => {
let navLinksBuilder: NavLinksBuilder;
before(async () => {
Expand All @@ -30,7 +37,9 @@ export default function navLinksTests({ getService }: FtrProviderContext) {
case 'everything_space':
expect(uiCapabilities.success).to.be(true);
expect(uiCapabilities.value).to.have.property('navLinks');
expect(uiCapabilities.value!.navLinks).to.eql(navLinksBuilder.all());
expect(uiCapabilities.value!.navLinks).to.eql(
navLinksBuilder.except(...uiCapabilitiesExceptions)
);
break;
case 'nothing_space':
expect(uiCapabilities.success).to.be(true);
Expand All @@ -40,7 +49,9 @@ export default function navLinksTests({ getService }: FtrProviderContext) {
case 'foo_disabled_space':
expect(uiCapabilities.success).to.be(true);
expect(uiCapabilities.value).to.have.property('navLinks');
expect(uiCapabilities.value!.navLinks).to.eql(navLinksBuilder.except('foo'));
expect(uiCapabilities.value!.navLinks).to.eql(
navLinksBuilder.except('foo', ...uiCapabilitiesExceptions)
);
break;
default:
throw new UnreachableError(scenario);
Expand Down

0 comments on commit 4ab0c09

Please sign in to comment.