Skip to content

Commit

Permalink
Merge pull request #376 from Web3Auth/harry/revamp-auth-service-e2e
Browse files Browse the repository at this point in the history
E2E - Revamp e2e script for Auth service
  • Loading branch information
chaitanyapotti authored Aug 15, 2024
2 parents 9ffb111 + b498015 commit 3eed4c1
Show file tree
Hide file tree
Showing 14 changed files with 741 additions and 245 deletions.
53 changes: 53 additions & 0 deletions .github/workflows/authservice-case1.yml
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
53 changes: 53 additions & 0 deletions .github/workflows/authservice-case2.yml
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
53 changes: 53 additions & 0 deletions .github/workflows/authservice-case3.yml
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
84 changes: 0 additions & 84 deletions .github/workflows/authservice.yml

This file was deleted.

73 changes: 73 additions & 0 deletions authservice/login-with-passwordless/AuthServicePage.ts
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;
}
}
30 changes: 30 additions & 0 deletions authservice/login-with-passwordless/DashboardPage.ts
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);
}
}
Loading

0 comments on commit 3eed4c1

Please sign in to comment.