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

Fix flaky user activation/deactivation tests #132465

Merged
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
3 changes: 1 addition & 2 deletions x-pack/test/functional/apps/security/users.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
});
});

// FLAKY: https://github.com/elastic/kibana/issues/118728
describe.skip('Deactivate/Activate user', () => {
describe('Deactivate/Activate user', () => {
it('deactivates user when confirming', async () => {
await PageObjects.security.deactivatesUser(optionalUser);
const users = keyBy(await PageObjects.security.getElasticsearchUsers(), 'username');
Expand Down
22 changes: 15 additions & 7 deletions x-pack/test/functional/page_objects/security_page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export class SecurityPageObject extends FtrService {
private readonly common = this.ctx.getPageObject('common');
private readonly header = this.ctx.getPageObject('header');
private readonly monacoEditor = this.ctx.getService('monacoEditor');
private readonly es = this.ctx.getService('es');

public loginPage = Object.freeze({
login: async (username?: string, password?: string, options: LoginOptions = {}) => {
Expand Down Expand Up @@ -350,13 +351,6 @@ export class SecurityPageObject extends FtrService {

const btn = await this.find.byButtonText(privilege);
await btn.click();

// const options = await this.find.byCssSelector(`.euiFilterSelectItem`);
// Object.entries(options).forEach(([key, prop]) => {
// console.log({ key, proto: prop.__proto__ });
// });

// await options.click();
}

async assignRoleToUser(role: string) {
Expand Down Expand Up @@ -516,13 +510,27 @@ export class SecurityPageObject extends FtrService {
await this.clickUserByUserName(user.username ?? '');
await this.testSubjects.click('editUserDisableUserButton');
await this.testSubjects.click('confirmModalConfirmButton');
await this.testSubjects.missingOrFail('confirmModalConfirmButton');
if (user.username) {
await this.retry.waitForWithTimeout('ES to acknowledge deactivation', 15000, async () => {
const userResponse = await this.es.security.getUser({ username: user.username });
return userResponse[user.username!].enabled === false;
});
}
await this.submitUpdateUserForm();
}

async activatesUser(user: UserFormValues) {
await this.clickUserByUserName(user.username ?? '');
await this.testSubjects.click('editUserEnableUserButton');
await this.testSubjects.click('confirmModalConfirmButton');
await this.testSubjects.missingOrFail('confirmModalConfirmButton');
if (user.username) {
await this.retry.waitForWithTimeout('ES to acknowledge activation', 15000, async () => {
const userResponse = await this.es.security.getUser({ username: user.username });
return userResponse[user.username!].enabled === true;
});
}
await this.submitUpdateUserForm();
}

Expand Down