From 10c9d64977b8382771689f8db25f25eb782f743a Mon Sep 17 00:00:00 2001 From: Fabienne Date: Mon, 18 Nov 2024 09:30:23 +0100 Subject: [PATCH] add test flows for login ui --- acceptance/tests/username-passkey.spec.ts | 22 +++++ .../tests/username-password-otp_email.spec.ts | 87 +++++++++++++++++++ .../tests/username-password-otp_sms.spec.ts | 35 ++++++++ acceptance/tests/username-password.spec.ts | 50 +++++++++++ 4 files changed, 194 insertions(+) create mode 100644 acceptance/tests/username-password-otp_email.spec.ts diff --git a/acceptance/tests/username-passkey.spec.ts b/acceptance/tests/username-passkey.spec.ts index 43c3cec7149..b3f6b131dde 100644 --- a/acceptance/tests/username-passkey.spec.ts +++ b/acceptance/tests/username-passkey.spec.ts @@ -24,3 +24,25 @@ test("username and passkey login", async ({user, page}) => { await loginWithPasskey(page, user.getAuthenticatorId(), user.getUsername()) await loginScreenExpect(page, user.getFullName()); }); + +test("username and passkey login, if passkey enabled", async ({user, page}) => { + // Given passkey is enabled on the organization of the user + // Given the user has only passkey enabled as authentication + + // enter username + // passkey popup is directly shown + // user verifies passkey + // user is redirected to app +}); + +test("username and passkey login, multiple auth methods", async ({user, page}) => { + // Given passkey and password is enabled on the organization of the user + // Given the user has password and passkey registered + + // enter username + // passkey popup is directly shown + // user aborts passkey authentication + // user switches to password authentication + // user enters password + // user is redirected to app +}); diff --git a/acceptance/tests/username-password-otp_email.spec.ts b/acceptance/tests/username-password-otp_email.spec.ts new file mode 100644 index 00000000000..d15793f040a --- /dev/null +++ b/acceptance/tests/username-password-otp_email.spec.ts @@ -0,0 +1,87 @@ +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 email otp login, enter code manually", 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 + + // User enters username + // User enters password + // User receives an email with a verification code + // User enters the code into the ui + // User is redirected to the app +}); + + +test("username, password and email otp login, click link in email", 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 + + // User enters username + // User enters password + // User receives an email with a verification code + // User clicks link in the email + // User is redirected to the app +}); + +test("username, password and email otp login, resend 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 + + // User enters username + // User enters password + // User receives an email with a verification code + // User clicks resend code + // User receives a new email with a verification code + // User enters the new code in the ui + // 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 + + // User enters username + // User enters password + // User receives an email with a verification code + // User enters a wrond code + // Error message - "Invalid code" is shown +}); + +test("username, password and email otp login, multiple mfa options", async ({user, page}) => { + // Given email otp and sms otp is enabled on the organizaiton of the user + // Given the user has email and sms otp configured as second factor + + // User enters username + // User enters password + // User receives an email with a verification code + // User clicks button to use sms otp as second factor + // User receives an sms with a verification code + // User enters code in ui + // User is redirected to the app +}); diff --git a/acceptance/tests/username-password-otp_sms.spec.ts b/acceptance/tests/username-password-otp_sms.spec.ts index 9caf8bd5ceb..d80e03fac8d 100644 --- a/acceptance/tests/username-password-otp_sms.spec.ts +++ b/acceptance/tests/username-password-otp_sms.spec.ts @@ -34,3 +34,38 @@ test("username, password and otp login", async ({user, page}) => { }); +test("username, password and sms otp login", async ({user, page}) => { + // Given sms otp is enabled on the organizaiton of the user + // Given the user has only sms otp configured as second factor + + // User enters username + // User enters password + // User receives an sms with a verification code + // User enters the code into the ui + // User is redirected to the app +}); + + +test("username, password and sms otp login, resend code", async ({user, page}) => { + // Given sms otp is enabled on the organizaiton of the user + // Given the user has only sms otp configured as second factor + + // User enters username + // User enters password + // User receives an sms with a verification code + // User clicks resend code + // User receives a new sms with a verification code + // User is redirected to the app +}); + + +test("username, password and sms otp login, wrong code", async ({user, page}) => { + // Given sms otp is enabled on the organizaiton of the user + // Given the user has only sms otp configured as second factor + + // User enters username + // User enters password + // User receives an sms with a verification code + // User enters a wrond code + // Error message - "Invalid code" is shown +}); diff --git a/acceptance/tests/username-password.spec.ts b/acceptance/tests/username-password.spec.ts index e9ab31d998c..ee97f21bc64 100644 --- a/acceptance/tests/username-password.spec.ts +++ b/acceptance/tests/username-password.spec.ts @@ -43,3 +43,53 @@ test("username and password login, wrong password", async ({user, page}) => { await password(page, "wrong") await passwordScreenExpect(page, "wrong") }); + +test("username and password login, wrong username, ignore unknown usernames", async ({user, page}) => { + // Given user doesn't exist but ignore unknown usernames setting is set to true + // Given username password login is enabled on the users organization + + // enter login name + // enter password + // redirect to loginname page --> error message username or password wrong +}); + +test("username and password login, initial password change", async ({user, page}) => { + // Given user is created and has changePassword set to true + // Given username password login is enabled on the users organization + + // enter login name + // enter password + // create new password +}); + +test("username and password login, reset password - enter code manually", async ({user, page}) => { + // Given user has forgotten password and clicks the forgot password button + // Given username password login is enabled on the users organization + + // enter login name + // click password forgotten + // enter code from email + // user is redirected to app +}); + +test("username and password login, reset password - click link", async ({user, page}) => { + // Given user has forgotten password and clicks the forgot password button, and then the link in the email + // Given username password login is enabled on the users organization + + // enter login name + // click password forgotten + // click link in email + // set new password + // redirect to app +}); + +test("username and password login, reset password, resend code", async ({user, page}) => { + // Given user has forgotten password and clicks the forgot password button and then resend code + // Given username password login is enabled on the users organization + + // enter login name + // click password forgotten + // click resend code + // enter code from second email + // user is authenticated +}); \ No newline at end of file