-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #376 from Web3Auth/harry/revamp-auth-service-e2e
E2E - Revamp e2e script for Auth service
- Loading branch information
Showing
14 changed files
with
741 additions
and
245 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
name: AuthService - E2ETests - No MFA case | ||
|
||
on: | ||
workflow_dispatch: | ||
push: | ||
branches: | ||
- master | ||
schedule: | ||
- cron: "*/30 * * * *" | ||
|
||
env: | ||
NODE_VERSION: 20 | ||
|
||
jobs: | ||
build: | ||
name: AuthService - E2ETests | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check out code | ||
uses: actions/checkout@v4 | ||
- name: Trigger tests | ||
env: | ||
CI: true | ||
CI_MODE: ${{ secrets.CI_MODE }} | ||
SMS_MOBILE_NUMBER: ${{ secrets.SMS_MOBILE_NUMBER }} | ||
LOGIN_MOBILE_NUMBER: ${{ secrets.LOGIN_MOBILE_NUMBER }} | ||
BACKUP_PHRASE_PROD: ${{ secrets.BACKUP_PHRASE_PROD }} | ||
BACKUP_PHRASE_CYAN: ${{ secrets.BACKUP_PHRASE_CYAN }} | ||
BACKUP_PHRASE_AQUA: ${{ secrets.BACKUP_PHRASE_AQUA }} | ||
TESTMAIL_APP_APIKEY: ${{ secrets.TESTMAIL_APP_APIKEY }} | ||
MAIL_APP: ${{ secrets.MAIL_APP }} | ||
run: | | ||
npm install && npx playwright install && npm run test:authservice:case1 | ||
- name: Get current timestamp | ||
id: get-time | ||
run: echo "::set-output name=timestamp::$(date +%Y%m%d%H%M%S)" | ||
|
||
- name: Upload test results | ||
if: always() | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: artifact-${{ github.run_id }}-${{ github.job }}-${{ steps.get-time.outputs.timestamp }} | ||
path: test-results/* | ||
if-no-files-found: ignore | ||
- name: Update Discord | ||
uses: sarisia/actions-status-discord@v1 | ||
if: always() | ||
with: | ||
webhook: ${{ secrets.DISCORD_WEBHOOK }} | ||
title: ${{ github.workflow}} - ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} | ||
status: ${{ job.status }} | ||
nocontext: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
name: AuthService - E2ETests - None than mandatory MFA case | ||
|
||
on: | ||
workflow_dispatch: | ||
push: | ||
branches: | ||
- master | ||
schedule: | ||
- cron: "10 */2 * * *" | ||
|
||
env: | ||
NODE_VERSION: 20 | ||
|
||
jobs: | ||
build: | ||
name: AuthService - E2ETests | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check out code | ||
uses: actions/checkout@v4 | ||
- name: Trigger tests | ||
env: | ||
CI: true | ||
CI_MODE: ${{ secrets.CI_MODE }} | ||
SMS_MOBILE_NUMBER: ${{ secrets.SMS_MOBILE_NUMBER }} | ||
LOGIN_MOBILE_NUMBER: ${{ secrets.LOGIN_MOBILE_NUMBER }} | ||
BACKUP_PHRASE_PROD: ${{ secrets.BACKUP_PHRASE_PROD }} | ||
BACKUP_PHRASE_CYAN: ${{ secrets.BACKUP_PHRASE_CYAN }} | ||
BACKUP_PHRASE_AQUA: ${{ secrets.BACKUP_PHRASE_AQUA }} | ||
TESTMAIL_APP_APIKEY: ${{ secrets.TESTMAIL_APP_APIKEY }} | ||
MAIL_APP: ${{ secrets.MAIL_APP }} | ||
run: | | ||
npm install && npx playwright install && npm run test:authservice:case2 | ||
- name: Get current timestamp | ||
id: get-time | ||
run: echo "::set-output name=timestamp::$(date +%Y%m%d%H%M%S)" | ||
|
||
- name: Upload test results | ||
if: always() | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: artifact-${{ github.run_id }}-${{ github.job }}-${{ steps.get-time.outputs.timestamp }} | ||
path: test-results/* | ||
if-no-files-found: ignore | ||
- name: Update Discord | ||
uses: sarisia/actions-status-discord@v1 | ||
if: always() | ||
with: | ||
webhook: ${{ secrets.DISCORD_WEBHOOK }} | ||
title: ${{ github.workflow}} - ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} | ||
status: ${{ job.status }} | ||
nocontext: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
name: AuthService - E2ETests - Mandatory MFA case | ||
|
||
on: | ||
workflow_dispatch: | ||
push: | ||
branches: | ||
- master | ||
schedule: | ||
- cron: "30 */2 * * *" | ||
|
||
env: | ||
NODE_VERSION: 20 | ||
|
||
jobs: | ||
build: | ||
name: AuthService - E2ETests | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check out code | ||
uses: actions/checkout@v4 | ||
- name: Trigger tests | ||
env: | ||
CI: true | ||
CI_MODE: ${{ secrets.CI_MODE }} | ||
SMS_MOBILE_NUMBER: ${{ secrets.SMS_MOBILE_NUMBER }} | ||
LOGIN_MOBILE_NUMBER: ${{ secrets.LOGIN_MOBILE_NUMBER }} | ||
BACKUP_PHRASE_PROD: ${{ secrets.BACKUP_PHRASE_PROD }} | ||
BACKUP_PHRASE_CYAN: ${{ secrets.BACKUP_PHRASE_CYAN }} | ||
BACKUP_PHRASE_AQUA: ${{ secrets.BACKUP_PHRASE_AQUA }} | ||
TESTMAIL_APP_APIKEY: ${{ secrets.TESTMAIL_APP_APIKEY }} | ||
MAIL_APP: ${{ secrets.MAIL_APP }} | ||
run: | | ||
npm install && npx playwright install && npm run test:authservice:case3 | ||
- name: Get current timestamp | ||
id: get-time | ||
run: echo "::set-output name=timestamp::$(date +%Y%m%d%H%M%S)" | ||
|
||
- name: Upload test results | ||
if: always() | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: artifact-${{ github.run_id }}-${{ github.job }}-${{ steps.get-time.outputs.timestamp }} | ||
path: test-results/* | ||
if-no-files-found: ignore | ||
- name: Update Discord | ||
uses: sarisia/actions-status-discord@v1 | ||
if: always() | ||
with: | ||
webhook: ${{ secrets.DISCORD_WEBHOOK }} | ||
title: ${{ github.workflow}} - ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} | ||
status: ${{ job.status }} | ||
nocontext: true |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
// playwright-dev-page.ts | ||
import { Page } from "@playwright/test"; | ||
// eslint-disable-next-line import/no-extraneous-dependencies | ||
import * as speakeasy from "speakeasy"; | ||
|
||
import { delay } from "../utils"; | ||
|
||
export class AuthServicePage { | ||
readonly page: Page; | ||
|
||
constructor(page: Page) { | ||
this.page = page; | ||
} | ||
|
||
async clickSetup2FA() { | ||
await this.page.click(`[data-testid="start-mfa-setup"]`); | ||
} | ||
|
||
async saveTheDevice() { | ||
await this.page.click(`input[type="checkbox"]`); | ||
await this.page.click(`[data-testid="add-device-factor"]`); | ||
} | ||
|
||
async skipTheFactorSetup() { | ||
await this.page.click(`[data-testid="skip"]`); | ||
} | ||
|
||
async skipPasskeySetup() { | ||
await this.page.click(`[data-testid="skipPasskey"]`); | ||
} | ||
|
||
async inputPasswordFactor(password: string) { | ||
await this.page.fill(`#openlogin-password`, password); | ||
await this.page.fill(`#openlogin-confirm-password`, password); | ||
await this.page.click(`[data-testid="confirmPassword"]`); | ||
} | ||
|
||
async confirmDone2FASetup() { | ||
await this.page.click(`[data-testid="done"]`); | ||
} | ||
|
||
async donotSaveDevice() { | ||
await this.page.click('text="Do not save"'); | ||
} | ||
|
||
async verifyAuthenticatorFactor(secret: string) { | ||
await this.page.click(`[data-testid="authenticator"]`); | ||
await delay(30000); | ||
|
||
const token = speakeasy.totp({ | ||
secret, | ||
encoding: "base32", | ||
step: 30, | ||
}); | ||
|
||
await this.page.locator(`xpath=.//input[@data-test='single-input']`).first().type(token); | ||
} | ||
|
||
async setupAuthenticator() { | ||
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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// playwright-dev-page.ts | ||
import { Page } from "@playwright/test"; | ||
|
||
export class DashboardPage { | ||
readonly page: Page; | ||
|
||
constructor(page: Page) { | ||
this.page = page; | ||
} | ||
|
||
async clickEnableMFA() { | ||
await this.page.click(`button[data-testid="btnEnableMFA"]`); | ||
} | ||
|
||
async getOpenLoginPrivateKey() { | ||
return (await this.page.locator("text=Openlogin Private key").textContent()).split(" : ")[1]; | ||
} | ||
|
||
async getUserInfoObject() { | ||
await this.page.locator('[data-testid="btnGetUserInfo"]').click(); | ||
const content = await this.page.locator(".card-container pre").textContent(); | ||
return JSON.parse(content); | ||
} | ||
|
||
async getOpenloginStateObject() { | ||
await this.page.locator('[data-testid="btnGetOpenloginState"]').click(); | ||
const content = await this.page.locator(".card-container pre").textContent(); | ||
return JSON.parse(content); | ||
} | ||
} |
Oops, something went wrong.