Skip to content

Commit

Permalink
Add handling 'two-step-verification' in E2E tests when Bitbucket.org …
Browse files Browse the repository at this point in the history
…OAuth setup (#23223)

* Add handling 'two-step-verification' of Bitbucket provider
  • Loading branch information
artaleks9 authored Oct 31, 2024
1 parent e469487 commit 51a833a
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions tests/e2e/pageobjects/git-providers/OauthPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ export class OauthPage {
private static APPROVE_BUTTON: By;
private static DENY_ACCESS_BUTTON: By;
private static DENY_SAVE_CREDENTIALS_BUTTON: By;
private static ENABLE_TWO_STEP_VERIFICATION_FORM: By;
private static DENY_TWO_STEP_VERIFICATION: By;

constructor(
@inject(CLASSES.DriverHelper)
Expand Down Expand Up @@ -55,6 +57,8 @@ export class OauthPage {
OauthPage.SUBMIT_BUTTON = By.id('login-submit');
OauthPage.APPROVE_BUTTON = By.xpath('//button[@value="approve"]');
OauthPage.DENY_ACCESS_BUTTON = By.xpath('//button[@value="deny"]');
OauthPage.ENABLE_TWO_STEP_VERIFICATION_FORM = By.id('ProductHeading');
OauthPage.DENY_TWO_STEP_VERIFICATION = By.id('mfa-promote-dismiss');
}
break;
case GitProviderType.GITLAB:
Expand Down Expand Up @@ -153,6 +157,24 @@ export class OauthPage {
await this.driverHelper.waitDisappearance(OauthPage.APPROVE_BUTTON);
}

async waitVisibilityTwoStepVerificationForm(): Promise<boolean> {
Logger.debug();

return this.driverHelper.waitVisibilityBoolean(OauthPage.ENABLE_TWO_STEP_VERIFICATION_FORM);
}

async clickOnDenyTwoStepVerification(): Promise<void> {
Logger.debug();

await this.driverHelper.waitAndClick(OauthPage.DENY_TWO_STEP_VERIFICATION);
}

async waitDisappearanceTwoStepVerificationForm(): Promise<void> {
Logger.debug();

await this.driverHelper.waitDisappearance(OauthPage.ENABLE_TWO_STEP_VERIFICATION_FORM);
}

async login(): Promise<void> {
Logger.debug();

Expand All @@ -170,6 +192,13 @@ export class OauthPage {
await this.clickOnNotRememberCredentialsButton();
}
await this.waitClosingLoginPage();

if (FACTORY_TEST_CONSTANTS.TS_SELENIUM_FACTORY_GIT_PROVIDER === GitProviderType.BITBUCKET_CLOUD_OAUTH2) {
if (await this.waitVisibilityTwoStepVerificationForm()) {
await this.clickOnDenyTwoStepVerification();
await this.waitDisappearanceTwoStepVerificationForm();
}
}
}

async confirmAccess(): Promise<void> {
Expand Down

0 comments on commit 51a833a

Please sign in to comment.