From b7eb07f6bc382817bbc10e5f8b7db8b83b0a2688 Mon Sep 17 00:00:00 2001 From: Pranav C Date: Wed, 7 Feb 2024 12:26:49 +0000 Subject: [PATCH] test: playwright - SAML auth flow test - WIP --- .../pages/SsoIdpPage/SAMLLoginPage.ts | 34 +++++++++++++++++++ tests/playwright/setup/index.ts | 12 +++++++ 2 files changed, 46 insertions(+) create mode 100644 tests/playwright/pages/SsoIdpPage/SAMLLoginPage.ts diff --git a/tests/playwright/pages/SsoIdpPage/SAMLLoginPage.ts b/tests/playwright/pages/SsoIdpPage/SAMLLoginPage.ts new file mode 100644 index 0000000000..0f9d95c473 --- /dev/null +++ b/tests/playwright/pages/SsoIdpPage/SAMLLoginPage.ts @@ -0,0 +1,34 @@ +import { Page } from '@playwright/test'; +import BasePage from '../Base'; +import { ProjectsPage } from '../ProjectsPage'; +import { expect } from '@playwright/test'; + +export class SAMLLoginPage extends BasePage { + readonly projectsPage: ProjectsPage; + + constructor(rootPage: Page) { + super(rootPage); + this.projectsPage = new ProjectsPage(rootPage); + } + + async goto(title = 'test') { + // reload page to get latest app info + await this.rootPage.reload(); + await this.rootPage.goto('/#/signin/'); + // click sign in with SAML + await this.rootPage.locator(`button:has-text("Sign in with ${title}")`).click(); + } + + get() { + return this.rootPage.locator('html'); + } + + async signIn({ email }: { email: string }) { + const signIn = this.get(); + await signIn.locator('#userName').waitFor(); + + await signIn.locator(`#userName`).fill(email); + await signIn.locator(`#email`).fill(email); + await signIn.locator(`#btn-sign-in`).click(); + } +} diff --git a/tests/playwright/setup/index.ts b/tests/playwright/setup/index.ts index 8ff99934d8..0d9aeb95ab 100644 --- a/tests/playwright/setup/index.ts +++ b/tests/playwright/setup/index.ts @@ -209,6 +209,18 @@ async function localInit({ // console.log(process.env.TEST_WORKER_INDEX, process.env.TEST_PARALLEL_INDEX); + // delete sso-clients + if (isEE() && api['ssoClient']) { + const clients = await api.ssoClient.list(); + for (const client of clients.list) { + try { + await api.ssoClient.delete(client.id); + } catch (e) { + console.log(`Error deleting sso-client: ${client.id}`); + } + } + } + if (isEE() && api['workspace']) { // Delete associated workspace // Note that: on worker error, entire thread is reset & worker ID numbering is reset too