Skip to content

Commit

Permalink
test: update new mfa flow
Browse files Browse the repository at this point in the history
  • Loading branch information
LeVinhGithub committed Sep 3, 2024
1 parent f3195c3 commit 00fce25
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 16 deletions.
28 changes: 28 additions & 0 deletions authservice/login-with-passwordless/AuthServicePage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,18 @@ export class AuthServicePage {
await this.page.click(`[data-testid="confirmPassword"]`);
}

async inputPasswordFactorNewMFAFlow(password: string) {
await this.page.click(`[data-testid="passwordFactor"]`);

await this.page.fill(`input[data-testid="auth-password"]`, password);
await this.page.fill(`input[data-testid="auth-confirm-password"]`, password);
await this.page.click(`[data-testid="confirmPassword"]`);
}

async finishSetupNewMFAList() {
await this.page.click(`[data-testid="finish-setup"]`);
}

async confirmDone2FASetup() {
await this.page.click(`[data-testid="done"]`);
}
Expand Down Expand Up @@ -88,4 +100,20 @@ export class AuthServicePage {
await this.page.locator(`xpath=.//input[@data-test='single-input']`).first().type(token);
return secret;
}

async setupAuthenticatorNewMFAFlow() {
await this.page.locator('[data-testid="authenticatorFactor"]').click();
await this.page.locator('text="Enter code manually"').click();

const secret = await this.page.locator(`div>span`).textContent();
await this.page.click(`button[aria-label="Next"]`);

// Generate TOTP token
const token = speakeasy.totp({
secret,
encoding: "base32",
});
await this.page.locator(`xpath=.//input[@data-test='single-input']`).first().type(token);
return secret;
}
}
20 changes: 4 additions & 16 deletions authservice/login-with-passwordless/auth-case-2.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ test.describe.serial("Passwordless Login scenarios", () => {

await loginPage.gotoLoginPage(authServiceURL);
await loginPage.selectBuildEnv("testing");
await loginPage.selectAllMFAFactor();
await loginPage.selectMFAFactor(["DEVICE", "PASSWORD", "AUTHENTICATOR"]);
await loginPage.selectMFALevel("none");
await loginPage.selectMFAMandantory(["DEVICE", "PASSWORD", "AUTHENTICATOR"]);
await loginPage.selectOpenloginNetwork("sapphire_devnet");
Expand Down Expand Up @@ -74,29 +74,17 @@ test.describe.serial("Passwordless Login scenarios", () => {

await authServicePage.clickSetup2FA();

// SETUP DEVICE FACTOR

await authServicePage.saveTheDevice();

// SKIP SOCIAL FACTOR

await authServicePage.skipTheFactorSetup();

// SETUP AUTHENTICATOR FACTOR

await authServicePage.setupAuthenticator();

// SKIP RECOVERY FACTOR

await authServicePage.skipTheFactorSetup();
await authServicePage.setupAuthenticatorNewMFAFlow();

// SETUP PASSWORD

await authServicePage.inputPasswordFactor(passwordTestingFactor);
await authServicePage.inputPasswordFactorNewMFAFlow(passwordTestingFactor);

// SKIP PASSKEY

await authServicePage.skipPasskeySetup();
await authServicePage.finishSetupNewMFAList();
await authServicePage.confirmDone2FASetup();

// GET INFO KEY AFTER 2FA SETUP AND VERIFY
Expand Down

0 comments on commit 00fce25

Please sign in to comment.