Skip to content

Commit

Permalink
Adjust user management functional tests to work in Cloud. (elastic#11…
Browse files Browse the repository at this point in the history
  • Loading branch information
azasypkin authored and kibanamachine committed Nov 17, 2021
1 parent d9bea38 commit 49f1118
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions x-pack/test/functional/apps/security/users.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
const toasts = getService('toasts');
const browser = getService('browser');

function isCloudEnvironment() {
return config.get('servers.elasticsearch.hostname') !== 'localhost';
}

describe('users', function () {
const optionalUser: UserFormValues = {
username: 'OptionalUser',
Expand All @@ -37,7 +41,11 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
const users = keyBy(await PageObjects.security.getElasticsearchUsers(), 'username');
log.info('actualUsers = %j', users);
log.info('config = %j', config.get('servers.elasticsearch.hostname'));
if (config.get('servers.elasticsearch.hostname') === 'localhost') {

// In Cloud default users are defined in file realm, such users aren't exposed through the Users API.
if (isCloudEnvironment()) {
expect(Object.keys(users)).to.eql(['test_user']);
} else {
expect(users.elastic.roles).to.eql(['superuser']);
expect(users.elastic.reserved).to.be(true);
expect(users.elastic.deprecated).to.be(false);
Expand All @@ -49,9 +57,6 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
expect(users.kibana.roles).to.eql(['kibana_system']);
expect(users.kibana.reserved).to.be(true);
expect(users.kibana.deprecated).to.be(true);
} else {
expect(users.anonymous.roles).to.eql(['anonymous']);
expect(users.anonymous.reserved).to.be(true);
}
});

Expand Down

0 comments on commit 49f1118

Please sign in to comment.