From 81c6e44927df1a0d37060f6696b9f222fc4ce40b Mon Sep 17 00:00:00 2001 From: Fabienne Date: Mon, 18 Nov 2024 10:36:13 +0100 Subject: [PATCH] add more user test flows --- .../tests/username-password-otp_email.spec.ts | 3 +- .../tests/username-password-totp.spec.ts | 63 +++++++++++++++++++ .../tests/username-password-u2f_email.spec.ts | 52 +++++++++++++++ 3 files changed, 116 insertions(+), 2 deletions(-) create mode 100644 acceptance/tests/username-password-totp.spec.ts create mode 100644 acceptance/tests/username-password-u2f_email.spec.ts diff --git a/acceptance/tests/username-password-otp_email.spec.ts b/acceptance/tests/username-password-otp_email.spec.ts index d15793f040a..55a05876a5a 100644 --- a/acceptance/tests/username-password-otp_email.spec.ts +++ b/acceptance/tests/username-password-otp_email.spec.ts @@ -16,7 +16,7 @@ const test = base.extend<{ user: PasswordUserWithOTP }>({ lastName: "last", password: "Password1!", organization: "", - type: OtpType.sms, + type: OtpType.email, }); await user.ensure(page); @@ -61,7 +61,6 @@ test("username, password and email otp login, resend code", async ({user, page}) // User is redirected to the app }); - test("username, password and email otp login, wrong code", async ({user, page}) => { // Given email otp is enabled on the organizaiton of the user // Given the user has only email otp configured as second factor diff --git a/acceptance/tests/username-password-totp.spec.ts b/acceptance/tests/username-password-totp.spec.ts new file mode 100644 index 00000000000..d81ba9f09eb --- /dev/null +++ b/acceptance/tests/username-password-totp.spec.ts @@ -0,0 +1,63 @@ +import {test as base} from "@playwright/test"; +import {OtpType, PasswordUserWithOTP} from './user'; +import path from 'path'; +import dotenv from 'dotenv'; +import {loginScreenExpect, loginWithPassword} from "./login"; +import {startSink} from "./otp"; + +// Read from ".env" file. +dotenv.config({path: path.resolve(__dirname, '.env.local')}); + +const test = base.extend<{ user: PasswordUserWithOTP }>({ + user: async ({page}, use) => { + const user = new PasswordUserWithOTP({ + email: "otp_sms@example.com", + firstName: "first", + lastName: "last", + password: "Password1!", + organization: "", + type: OtpType.sms, + }); + + await user.ensure(page); + await use(user); + }, +}); + +test("username, password and totp login", async ({user, page}) => { + // Given totp is enabled on the organizaiton of the user + // Given the user has only totp configured as second factor + + // User enters username + // User enters password + // Screen for entering the code is shown directly + // User enters the code into the ui + // User is redirected to the app +}); + + +test("username, password and totp otp login, wrong code", async ({user, page}) => { + // Given totp is enabled on the organizaiton of the user + // Given the user has only totp configured as second factor + + // User enters username + // User enters password + // Screen for entering the code is shown directly + // User enters a wrond code + // Error message - "Invalid code" is shown +}); + + +test("username, password and totp login, multiple mfa options", async ({user, page}) => { + // Given totp and email otp is enabled on the organizaiton of the user + // Given the user has totp and email otp configured as second factor + + // User enters username + // User enters password + // Screen for entering the code is shown directly + // Button to switch to email otp is shown + // User clicks button to use email otp instead + // User receives an email with a verification code + // User enters code in ui + // User is redirected to the app +}); diff --git a/acceptance/tests/username-password-u2f_email.spec.ts b/acceptance/tests/username-password-u2f_email.spec.ts new file mode 100644 index 00000000000..fad16a2fc57 --- /dev/null +++ b/acceptance/tests/username-password-u2f_email.spec.ts @@ -0,0 +1,52 @@ +import {test as base} from "@playwright/test"; +import {OtpType, PasswordUserWithOTP} from './user'; +import path from 'path'; +import dotenv from 'dotenv'; +import {loginScreenExpect, loginWithPassword} from "./login"; +import {startSink} from "./otp"; + +// Read from ".env" file. +dotenv.config({path: path.resolve(__dirname, '.env.local')}); + +const test = base.extend<{ user: PasswordUserWithOTP }>({ + user: async ({page}, use) => { + const user = new PasswordUserWithOTP({ + email: "otp_sms@example.com", + firstName: "first", + lastName: "last", + password: "Password1!", + organization: "", + type: OtpType.sms, + }); + + await user.ensure(page); + await use(user); + }, +}); + + +test("username, password and u2f login", async ({user, page}) => { + // Given u2f is enabled on the organizaiton of the user + // Given the user has only u2f configured as second factor + + // User enters username + // User enters password + // Popup for u2f is directly opened + // User verifies u2f + // User is redirected to the app +}); + + +test("username, password and u2f login, multiple mfa options", async ({user, page}) => { + // Given u2f and semailms otp is enabled on the organizaiton of the user + // Given the user has u2f and email otp configured as second factor + + // User enters username + // User enters password + // Popup for u2f is directly opened + // User aborts u2f verification + // User clicks button to use email otp as second factor + // User receives an email with a verification code + // User enters code in ui + // User is redirected to the app +});