mirror of
https://github.com/zitadel/zitadel.git
synced 2025-12-12 01:43:08 +00:00
Merge branch 'acceptance-test-suite' into test_definitions
This commit is contained in:
4
.github/workflows/test.yml
vendored
4
.github/workflows/test.yml
vendored
@@ -4,10 +4,6 @@ on: pull_request
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
quality:
|
quality:
|
||||||
env:
|
|
||||||
ZITADEL_IMAGE: ghcr.io/zitadel/zitadel:v2.63.4
|
|
||||||
POSTGRES_IMAGE: postgres:17.0-alpine3.19
|
|
||||||
|
|
||||||
name: Ensure Quality
|
name: Ensure Quality
|
||||||
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
services:
|
services:
|
||||||
zitadel:
|
zitadel:
|
||||||
user: "${ZITADEL_DEV_UID}"
|
user: "${ZITADEL_DEV_UID}"
|
||||||
image: "${ZITADEL_IMAGE:-ghcr.io/zitadel/zitadel:latest}"
|
image: ghcr.io/zitadel/zitadel:v2.65.0
|
||||||
command: 'start-from-init --masterkey "MasterkeyNeedsToHave32Characters" --tlsMode disabled --config /zitadel.yaml --steps /zitadel.yaml'
|
command: 'start-from-init --masterkey "MasterkeyNeedsToHave32Characters" --tlsMode disabled --config /zitadel.yaml --steps /zitadel.yaml'
|
||||||
ports:
|
ports:
|
||||||
- "8080:8080"
|
- "8080:8080"
|
||||||
@@ -13,8 +13,8 @@ services:
|
|||||||
condition: "service_healthy"
|
condition: "service_healthy"
|
||||||
|
|
||||||
db:
|
db:
|
||||||
restart: 'always'
|
restart: "always"
|
||||||
image: "${POSTGRES_IMAGE:-postgres:latest}"
|
image: postgres:17.0-alpine3.19
|
||||||
environment:
|
environment:
|
||||||
- POSTGRES_USER=zitadel
|
- POSTGRES_USER=zitadel
|
||||||
- PGUSER=zitadel
|
- PGUSER=zitadel
|
||||||
@@ -23,21 +23,16 @@ services:
|
|||||||
command: postgres -c shared_preload_libraries=pg_stat_statements -c pg_stat_statements.track=all -c shared_buffers=1GB -c work_mem=16MB -c effective_io_concurrency=100 -c wal_level=minimal -c archive_mode=off -c max_wal_senders=0
|
command: postgres -c shared_preload_libraries=pg_stat_statements -c pg_stat_statements.track=all -c shared_buffers=1GB -c work_mem=16MB -c effective_io_concurrency=100 -c wal_level=minimal -c archive_mode=off -c max_wal_senders=0
|
||||||
healthcheck:
|
healthcheck:
|
||||||
test: ["CMD-SHELL", "pg_isready"]
|
test: ["CMD-SHELL", "pg_isready"]
|
||||||
interval: '10s'
|
interval: "10s"
|
||||||
timeout: '30s'
|
timeout: "30s"
|
||||||
retries: 5
|
retries: 5
|
||||||
start_period: '20s'
|
start_period: "20s"
|
||||||
ports:
|
ports:
|
||||||
- 5432:5432
|
- 5432:5432
|
||||||
|
|
||||||
wait_for_zitadel:
|
wait_for_zitadel:
|
||||||
image: curlimages/curl:8.00.1
|
image: curlimages/curl:8.00.1
|
||||||
command:
|
command: /bin/sh -c "until curl -s -o /dev/null -i -f http://zitadel:8080/debug/ready; do echo 'waiting' && sleep 1; done; echo 'ready' && sleep 5;" || false
|
||||||
[
|
|
||||||
"/bin/sh",
|
|
||||||
"-c",
|
|
||||||
"i=0; while ! curl http://zitadel:8080/debug/ready && [ $$i -lt 30 ]; do sleep 1; i=$$((i+1)); done; [ $$i -eq 120 ] && exit 1 || exit 0",
|
|
||||||
]
|
|
||||||
depends_on:
|
depends_on:
|
||||||
- zitadel
|
- zitadel
|
||||||
|
|
||||||
@@ -49,9 +44,11 @@ services:
|
|||||||
PAT_FILE: /pat/zitadel-admin-sa.pat
|
PAT_FILE: /pat/zitadel-admin-sa.pat
|
||||||
ZITADEL_API_INTERNAL_URL: http://zitadel:8080
|
ZITADEL_API_INTERNAL_URL: http://zitadel:8080
|
||||||
WRITE_ENVIRONMENT_FILE: /apps/login/.env.local
|
WRITE_ENVIRONMENT_FILE: /apps/login/.env.local
|
||||||
|
WRITE_TEST_ENVIRONMENT_FILE: /acceptance/tests/.env.local
|
||||||
volumes:
|
volumes:
|
||||||
- "./pat:/pat"
|
- "./pat:/pat"
|
||||||
- "../apps/login:/apps/login"
|
- "../apps/login:/apps/login"
|
||||||
|
- "../acceptance/tests:/acceptance/tests"
|
||||||
depends_on:
|
depends_on:
|
||||||
wait_for_zitadel:
|
wait_for_zitadel:
|
||||||
condition: "service_completed_successfully"
|
condition: "service_completed_successfully"
|
||||||
|
|||||||
@@ -26,9 +26,30 @@ fi
|
|||||||
|
|
||||||
WRITE_ENVIRONMENT_FILE=${WRITE_ENVIRONMENT_FILE:-$(dirname "$0")/../apps/login/.env.local}
|
WRITE_ENVIRONMENT_FILE=${WRITE_ENVIRONMENT_FILE:-$(dirname "$0")/../apps/login/.env.local}
|
||||||
echo "Writing environment file to ${WRITE_ENVIRONMENT_FILE} when done."
|
echo "Writing environment file to ${WRITE_ENVIRONMENT_FILE} when done."
|
||||||
|
WRITE_TEST_ENVIRONMENT_FILE=${WRITE_TEST_ENVIRONMENT_FILE:-$(dirname "$0")/../acceptance/tests/.env.local}
|
||||||
|
echo "Writing environment file to ${WRITE_TEST_ENVIRONMENT_FILE} when done."
|
||||||
|
|
||||||
echo "ZITADEL_API_URL=${ZITADEL_API_URL}
|
echo "ZITADEL_API_URL=${ZITADEL_API_URL}
|
||||||
ZITADEL_SERVICE_USER_ID=${ZITADEL_SERVICE_USER_ID}
|
ZITADEL_SERVICE_USER_ID=${ZITADEL_SERVICE_USER_ID}
|
||||||
ZITADEL_SERVICE_USER_TOKEN=${PAT}" > ${WRITE_ENVIRONMENT_FILE}
|
ZITADEL_SERVICE_USER_TOKEN=${PAT}
|
||||||
|
DEBUG=true"| tee "${WRITE_ENVIRONMENT_FILE}" "${WRITE_TEST_ENVIRONMENT_FILE}" > /dev/null
|
||||||
echo "Wrote environment file ${WRITE_ENVIRONMENT_FILE}"
|
echo "Wrote environment file ${WRITE_ENVIRONMENT_FILE}"
|
||||||
cat ${WRITE_ENVIRONMENT_FILE}
|
cat ${WRITE_ENVIRONMENT_FILE}
|
||||||
|
|
||||||
|
echo "Wrote environment file ${WRITE_TEST_ENVIRONMENT_FILE}"
|
||||||
|
cat ${WRITE_TEST_ENVIRONMENT_FILE}
|
||||||
|
|
||||||
|
DEFAULTORG_RESPONSE_RESULTS=0
|
||||||
|
# waiting for default organization
|
||||||
|
until [ ${DEFAULTORG_RESPONSE_RESULTS} -eq 1 ]
|
||||||
|
do
|
||||||
|
DEFAULTORG_RESPONSE=$(curl -s --request POST \
|
||||||
|
--url "${ZITADEL_API_INTERNAL_URL}/v2/organizations/_search" \
|
||||||
|
--header "Authorization: Bearer ${PAT}" \
|
||||||
|
--header "Host: ${ZITADEL_API_DOMAIN}" \
|
||||||
|
--header "Content-Type: application/json" \
|
||||||
|
-d "{\"queries\": [{\"defaultQuery\":{}}]}" )
|
||||||
|
echo "Received default organization response: ${DEFAULTORG_RESPONSE}"
|
||||||
|
DEFAULTORG_RESPONSE_RESULTS=$(echo $DEFAULTORG_RESPONSE | jq -r '.result | length')
|
||||||
|
echo "Received default organization response result: ${DEFAULTORG_RESPONSE_RESULTS}"
|
||||||
|
done
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import {test} from "@playwright/test";
|
import { test } from "@playwright/test";
|
||||||
import {loginScreenExpect, loginWithPassword} from "./login";
|
import { loginScreenExpect, loginWithPassword } from "./login";
|
||||||
|
|
||||||
test("admin login", async ({page}) => {
|
test("admin login", async ({ page }) => {
|
||||||
await loginWithPassword(page, "zitadel-admin@zitadel.localhost", "Password1.")
|
await loginWithPassword(page, "zitadel-admin@zitadel.localhost", "Password1!");
|
||||||
await loginScreenExpect(page, "ZITADEL Admin");
|
await loginScreenExpect(page, "ZITADEL Admin");
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,29 +1,28 @@
|
|||||||
import {expect, Page} from "@playwright/test";
|
import { expect, Page } from "@playwright/test";
|
||||||
import {loginname} from "./loginname";
|
import { loginname } from "./loginname";
|
||||||
import {password} from "./password";
|
import { password } from "./password";
|
||||||
|
|
||||||
export async function startLogin(page: Page) {
|
export async function startLogin(page: Page) {
|
||||||
await page.goto("/loginname");
|
await page.goto("/loginname");
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function loginWithPassword(page: Page, username: string, pw: string) {
|
export async function loginWithPassword(page: Page, username: string, pw: string) {
|
||||||
await startLogin(page);
|
await startLogin(page);
|
||||||
await loginname(page, username);
|
await loginname(page, username);
|
||||||
await password(page, pw);
|
await password(page, pw);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function loginWithPasskey(page: Page, authenticatorId: string, username: string) {
|
export async function loginWithPasskey(page: Page, authenticatorId: string, username: string) {
|
||||||
await startLogin(page);
|
await startLogin(page);
|
||||||
await loginname(page, username);
|
await loginname(page, username);
|
||||||
// await passkey(page, authenticatorId);
|
// await passkey(page, authenticatorId);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function loginScreenExpect(page: Page, fullName: string) {
|
export async function loginScreenExpect(page: Page, fullName: string) {
|
||||||
await expect(page.getByRole('heading')).toContainText(fullName);
|
await expect(page).toHaveURL(/signedin.*/);
|
||||||
|
await expect(page.getByRole("heading")).toContainText(fullName);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function loginWithOTP(page: Page, username: string, password: string) {
|
export async function loginWithOTP(page: Page, username: string, password: string) {
|
||||||
await loginWithPassword(page, username, password);
|
await loginWithPassword(page, username, password);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
import {expect, Page} from "@playwright/test";
|
import { expect, Page } from "@playwright/test";
|
||||||
|
|
||||||
const usernameUserInput = "username-text-input"
|
const usernameUserInput = "username-text-input";
|
||||||
|
|
||||||
export async function loginnameScreen(page: Page, username: string) {
|
export async function loginnameScreen(page: Page, username: string) {
|
||||||
await page.getByTestId(usernameUserInput).pressSequentially(username);
|
await page.getByTestId(usernameUserInput).pressSequentially(username);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function loginnameScreenExpect(page: Page, username: string) {
|
export async function loginnameScreenExpect(page: Page, username: string) {
|
||||||
await expect(page.getByTestId(usernameUserInput)).toHaveValue(username);
|
await expect(page.getByTestId(usernameUserInput)).toHaveValue(username);
|
||||||
await expect(page.getByTestId('error').locator('div')).toContainText("Could not find user")
|
await expect(page.getByTestId("error").locator("div")).toContainText("Could not find user");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import {Page} from "@playwright/test";
|
import { Page } from "@playwright/test";
|
||||||
import {loginnameScreen} from "./loginname-screen";
|
import { loginnameScreen } from "./loginname-screen";
|
||||||
|
|
||||||
export async function loginname(page: Page, username: string) {
|
export async function loginname(page: Page, username: string) {
|
||||||
await loginnameScreen(page, username)
|
await loginnameScreen(page, username);
|
||||||
await page.getByTestId("submit-button").click()
|
await page.getByTestId("submit-button").click();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,29 +3,29 @@ import * as http from "node:http";
|
|||||||
let messages = new Map<string, any>();
|
let messages = new Map<string, any>();
|
||||||
|
|
||||||
export function startSink() {
|
export function startSink() {
|
||||||
const hostname = "127.0.0.1"
|
const hostname = "127.0.0.1";
|
||||||
const port = 3030
|
const port = 3030;
|
||||||
|
|
||||||
const server = http.createServer((req, res) => {
|
const server = http.createServer((req, res) => {
|
||||||
console.log("Sink received message: ")
|
console.log("Sink received message: ");
|
||||||
let body = '';
|
let body = "";
|
||||||
req.on('data', (chunk) => {
|
req.on("data", (chunk) => {
|
||||||
body += chunk;
|
body += chunk;
|
||||||
});
|
|
||||||
|
|
||||||
req.on('end', () => {
|
|
||||||
console.log(body);
|
|
||||||
const data = JSON.parse(body)
|
|
||||||
messages.set(data.contextInfo.recipientEmailAddress, data.args.code)
|
|
||||||
res.statusCode = 200;
|
|
||||||
res.setHeader('Content-Type', 'text/plain');
|
|
||||||
res.write('OK');
|
|
||||||
res.end();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
server.listen(port, hostname, () => {
|
req.on("end", () => {
|
||||||
console.log(`Sink running at http://${hostname}:${port}/`);
|
console.log(body);
|
||||||
|
const data = JSON.parse(body);
|
||||||
|
messages.set(data.contextInfo.recipientEmailAddress, data.args.code);
|
||||||
|
res.statusCode = 200;
|
||||||
|
res.setHeader("Content-Type", "text/plain");
|
||||||
|
res.write("OK");
|
||||||
|
res.end();
|
||||||
});
|
});
|
||||||
return server
|
});
|
||||||
|
|
||||||
|
server.listen(port, hostname, () => {
|
||||||
|
console.log(`Sink running at http://${hostname}:${port}/`);
|
||||||
|
});
|
||||||
|
return server;
|
||||||
}
|
}
|
||||||
@@ -1,110 +1,109 @@
|
|||||||
import {expect, Page} from "@playwright/test";
|
import { expect, Page } from "@playwright/test";
|
||||||
import {CDPSession} from "playwright-core";
|
import { CDPSession } from "playwright-core";
|
||||||
|
|
||||||
interface session {
|
interface session {
|
||||||
client: CDPSession
|
client: CDPSession;
|
||||||
authenticatorId: string
|
authenticatorId: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function client(page: Page): Promise<session> {
|
async function client(page: Page): Promise<session> {
|
||||||
const cdpSession = await page.context().newCDPSession(page);
|
const cdpSession = await page.context().newCDPSession(page);
|
||||||
await cdpSession.send('WebAuthn.enable', {enableUI: false});
|
await cdpSession.send("WebAuthn.enable", { enableUI: false });
|
||||||
const result = await cdpSession.send('WebAuthn.addVirtualAuthenticator', {
|
const result = await cdpSession.send("WebAuthn.addVirtualAuthenticator", {
|
||||||
options: {
|
options: {
|
||||||
protocol: 'ctap2',
|
protocol: "ctap2",
|
||||||
transport: 'internal',
|
transport: "internal",
|
||||||
hasResidentKey: true,
|
hasResidentKey: true,
|
||||||
hasUserVerification: true,
|
hasUserVerification: true,
|
||||||
isUserVerified: true,
|
isUserVerified: true,
|
||||||
automaticPresenceSimulation: true,
|
automaticPresenceSimulation: true,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
return {client: cdpSession, authenticatorId: result.authenticatorId};
|
return { client: cdpSession, authenticatorId: result.authenticatorId };
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function passkeyRegister(page: Page): Promise<string> {
|
export async function passkeyRegister(page: Page): Promise<string> {
|
||||||
const session = await client(page)
|
const session = await client(page);
|
||||||
|
|
||||||
await passkeyNotExisting(session.client, session.authenticatorId);
|
await passkeyNotExisting(session.client, session.authenticatorId);
|
||||||
await simulateSuccessfulPasskeyRegister(
|
await simulateSuccessfulPasskeyRegister(session.client, session.authenticatorId, () =>
|
||||||
session.client,
|
page.getByTestId("submit-button").click(),
|
||||||
session.authenticatorId,
|
);
|
||||||
() =>
|
await passkeyRegistered(session.client, session.authenticatorId);
|
||||||
page.getByTestId("submit-button").click()
|
|
||||||
);
|
|
||||||
await passkeyRegistered(session.client, session.authenticatorId);
|
|
||||||
|
|
||||||
return session.authenticatorId
|
return session.authenticatorId;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function passkey(page: Page, authenticatorId: string) {
|
export async function passkey(page: Page, authenticatorId: string) {
|
||||||
const cdpSession = await page.context().newCDPSession(page);
|
const cdpSession = await page.context().newCDPSession(page);
|
||||||
await cdpSession.send('WebAuthn.enable', {enableUI: false});
|
await cdpSession.send("WebAuthn.enable", { enableUI: false });
|
||||||
|
|
||||||
const signCount = await passkeyExisting(cdpSession, authenticatorId);
|
const signCount = await passkeyExisting(cdpSession, authenticatorId);
|
||||||
|
|
||||||
await simulateSuccessfulPasskeyInput(
|
await simulateSuccessfulPasskeyInput(cdpSession, authenticatorId, () => page.getByTestId("submit-button").click());
|
||||||
cdpSession,
|
|
||||||
authenticatorId,
|
|
||||||
() =>
|
|
||||||
page.getByTestId("submit-button").click()
|
|
||||||
);
|
|
||||||
|
|
||||||
await passkeyUsed(cdpSession, authenticatorId, signCount);
|
await passkeyUsed(cdpSession, authenticatorId, signCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function passkeyNotExisting(client: CDPSession, authenticatorId: string) {
|
async function passkeyNotExisting(client: CDPSession, authenticatorId: string) {
|
||||||
const result = await client.send('WebAuthn.getCredentials', {authenticatorId});
|
const result = await client.send("WebAuthn.getCredentials", { authenticatorId });
|
||||||
expect(result.credentials).toHaveLength(0);
|
expect(result.credentials).toHaveLength(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function passkeyRegistered(client: CDPSession, authenticatorId: string) {
|
async function passkeyRegistered(client: CDPSession, authenticatorId: string) {
|
||||||
const result = await client.send('WebAuthn.getCredentials', {authenticatorId});
|
const result = await client.send("WebAuthn.getCredentials", { authenticatorId });
|
||||||
expect(result.credentials).toHaveLength(1);
|
expect(result.credentials).toHaveLength(1);
|
||||||
await passkeyUsed(client, authenticatorId, 0);
|
await passkeyUsed(client, authenticatorId, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function passkeyExisting(client: CDPSession, authenticatorId: string): Promise<number> {
|
async function passkeyExisting(client: CDPSession, authenticatorId: string): Promise<number> {
|
||||||
const result = await client.send('WebAuthn.getCredentials', {authenticatorId});
|
const result = await client.send("WebAuthn.getCredentials", { authenticatorId });
|
||||||
expect(result.credentials).toHaveLength(1);
|
expect(result.credentials).toHaveLength(1);
|
||||||
return result.credentials[0].signCount
|
return result.credentials[0].signCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function passkeyUsed(client: CDPSession, authenticatorId: string, signCount: number) {
|
async function passkeyUsed(client: CDPSession, authenticatorId: string, signCount: number) {
|
||||||
const result = await client.send('WebAuthn.getCredentials', {authenticatorId});
|
const result = await client.send("WebAuthn.getCredentials", { authenticatorId });
|
||||||
expect(result.credentials).toHaveLength(1);
|
expect(result.credentials).toHaveLength(1);
|
||||||
expect(result.credentials[0].signCount).toBeGreaterThan(signCount);
|
expect(result.credentials[0].signCount).toBeGreaterThan(signCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function simulateSuccessfulPasskeyRegister(client: CDPSession, authenticatorId: string, operationTrigger: () => Promise<void>) {
|
async function simulateSuccessfulPasskeyRegister(
|
||||||
// initialize event listeners to wait for a successful passkey input event
|
client: CDPSession,
|
||||||
const operationCompleted = new Promise<void>(resolve => {
|
authenticatorId: string,
|
||||||
client.on('WebAuthn.credentialAdded', () => {
|
operationTrigger: () => Promise<void>,
|
||||||
console.log('Credential Added!');
|
) {
|
||||||
resolve()
|
// initialize event listeners to wait for a successful passkey input event
|
||||||
});
|
const operationCompleted = new Promise<void>((resolve) => {
|
||||||
|
client.on("WebAuthn.credentialAdded", () => {
|
||||||
|
console.log("Credential Added!");
|
||||||
|
resolve();
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
|
||||||
// perform a user action that triggers passkey prompt
|
// perform a user action that triggers passkey prompt
|
||||||
await operationTrigger();
|
await operationTrigger();
|
||||||
|
|
||||||
// wait to receive the event that the passkey was successfully registered or verified
|
// wait to receive the event that the passkey was successfully registered or verified
|
||||||
await operationCompleted;
|
await operationCompleted;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function simulateSuccessfulPasskeyInput(client: CDPSession, authenticatorId: string, operationTrigger: () => Promise<void>) {
|
async function simulateSuccessfulPasskeyInput(
|
||||||
// initialize event listeners to wait for a successful passkey input event
|
client: CDPSession,
|
||||||
const operationCompleted = new Promise<void>(resolve => {
|
authenticatorId: string,
|
||||||
client.on('WebAuthn.credentialAsserted', () => {
|
operationTrigger: () => Promise<void>,
|
||||||
console.log('Credential Asserted!');
|
) {
|
||||||
resolve()
|
// initialize event listeners to wait for a successful passkey input event
|
||||||
});
|
const operationCompleted = new Promise<void>((resolve) => {
|
||||||
|
client.on("WebAuthn.credentialAsserted", () => {
|
||||||
|
console.log("Credential Asserted!");
|
||||||
|
resolve();
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
|
||||||
// perform a user action that triggers passkey prompt
|
// perform a user action that triggers passkey prompt
|
||||||
await operationTrigger();
|
await operationTrigger();
|
||||||
|
|
||||||
// wait to receive the event that the passkey was successfully registered or verified
|
// wait to receive the event that the passkey was successfully registered or verified
|
||||||
await operationCompleted;
|
await operationCompleted;
|
||||||
}
|
}
|
||||||
s
|
|
||||||
@@ -1,47 +1,57 @@
|
|||||||
import {expect, Page} from "@playwright/test";
|
import { expect, Page } from "@playwright/test";
|
||||||
|
|
||||||
const passwordField = 'password-text-input'
|
const passwordField = "password-text-input";
|
||||||
const passwordConfirmField = 'password-confirm-text-input'
|
const passwordConfirmField = "password-confirm-text-input";
|
||||||
const lengthCheck = "length-check"
|
const lengthCheck = "length-check";
|
||||||
const symbolCheck = "symbol-check"
|
const symbolCheck = "symbol-check";
|
||||||
const numberCheck = "number-check"
|
const numberCheck = "number-check";
|
||||||
const uppercaseCheck = "uppercase-check"
|
const uppercaseCheck = "uppercase-check";
|
||||||
const lowercaseCheck = "lowercase-check"
|
const lowercaseCheck = "lowercase-check";
|
||||||
const equalCheck = "equal-check"
|
const equalCheck = "equal-check";
|
||||||
|
|
||||||
const matchText = "Matches"
|
const matchText = "Matches";
|
||||||
const noMatchText = "Doesn\'t match"
|
const noMatchText = "Doesn't match";
|
||||||
|
|
||||||
export async function changePasswordScreen(page: Page, password1: string, password2: string) {
|
export async function changePasswordScreen(page: Page, password1: string, password2: string) {
|
||||||
await page.getByTestId(passwordField).pressSequentially(password1);
|
await page.getByTestId(passwordField).pressSequentially(password1);
|
||||||
await page.getByTestId(passwordConfirmField).pressSequentially(password2);
|
await page.getByTestId(passwordConfirmField).pressSequentially(password2);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function passwordScreen(page: Page, password: string) {
|
export async function passwordScreen(page: Page, password: string) {
|
||||||
await page.getByTestId(passwordField).pressSequentially(password);
|
await page.getByTestId(passwordField).pressSequentially(password);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function passwordScreenExpect(page: Page, password: string) {
|
export async function passwordScreenExpect(page: Page, password: string) {
|
||||||
await expect(page.getByTestId(passwordField)).toHaveValue(password);
|
await expect(page.getByTestId(passwordField)).toHaveValue(password);
|
||||||
await expect(page.getByTestId('error').locator('div')).toContainText("Could not verify password");
|
await expect(page.getByTestId("error").locator("div")).toContainText("Could not verify password");
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function changePasswordScreenExpect(page: Page, password1: string, password2: string, length: boolean, symbol: boolean, number: boolean, uppercase: boolean, lowercase: boolean, equals: boolean) {
|
export async function changePasswordScreenExpect(
|
||||||
await expect(page.getByTestId(passwordField)).toHaveValue(password1);
|
page: Page,
|
||||||
await expect(page.getByTestId(passwordConfirmField)).toHaveValue(password2);
|
password1: string,
|
||||||
|
password2: string,
|
||||||
|
length: boolean,
|
||||||
|
symbol: boolean,
|
||||||
|
number: boolean,
|
||||||
|
uppercase: boolean,
|
||||||
|
lowercase: boolean,
|
||||||
|
equals: boolean,
|
||||||
|
) {
|
||||||
|
await expect(page.getByTestId(passwordField)).toHaveValue(password1);
|
||||||
|
await expect(page.getByTestId(passwordConfirmField)).toHaveValue(password2);
|
||||||
|
|
||||||
await checkContent(page, lengthCheck, length);
|
await checkContent(page, lengthCheck, length);
|
||||||
await checkContent(page, symbolCheck, symbol);
|
await checkContent(page, symbolCheck, symbol);
|
||||||
await checkContent(page, numberCheck, number);
|
await checkContent(page, numberCheck, number);
|
||||||
await checkContent(page, uppercaseCheck, uppercase);
|
await checkContent(page, uppercaseCheck, uppercase);
|
||||||
await checkContent(page, lowercaseCheck, lowercase);
|
await checkContent(page, lowercaseCheck, lowercase);
|
||||||
await checkContent(page, equalCheck, equals);
|
await checkContent(page, equalCheck, equals);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function checkContent(page: Page, testid: string, match: boolean) {
|
async function checkContent(page: Page, testid: string, match: boolean) {
|
||||||
if (match) {
|
if (match) {
|
||||||
await expect(page.getByTestId(testid)).toContainText(matchText);
|
await expect(page.getByTestId(testid)).toContainText(matchText);
|
||||||
} else {
|
} else {
|
||||||
await expect(page.getByTestId(testid)).toContainText(noMatchText);
|
await expect(page.getByTestId(testid)).toContainText(noMatchText);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,20 +1,19 @@
|
|||||||
import {Page} from "@playwright/test";
|
import { Page } from "@playwright/test";
|
||||||
import {changePasswordScreen, passwordScreen} from "./password-screen";
|
import { changePasswordScreen, passwordScreen } from "./password-screen";
|
||||||
|
|
||||||
const passwordSubmitButton = "submit-button"
|
|
||||||
|
|
||||||
|
const passwordSubmitButton = "submit-button";
|
||||||
|
|
||||||
export async function startChangePassword(page: Page, loginname: string) {
|
export async function startChangePassword(page: Page, loginname: string) {
|
||||||
await page.goto('password/change?' + new URLSearchParams({loginName: loginname}));
|
await page.goto("/password/change?" + new URLSearchParams({ loginName: loginname }));
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function changePassword(page: Page, loginname: string, password: string) {
|
export async function changePassword(page: Page, loginname: string, password: string) {
|
||||||
await startChangePassword(page, loginname);
|
await startChangePassword(page, loginname);
|
||||||
await changePasswordScreen(page, password, password)
|
await changePasswordScreen(page, password, password);
|
||||||
await page.getByTestId(passwordSubmitButton).click();
|
await page.getByTestId(passwordSubmitButton).click();
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function password(page: Page, password: string) {
|
export async function password(page: Page, password: string) {
|
||||||
await passwordScreen(page, password)
|
await passwordScreen(page, password);
|
||||||
await page.getByTestId(passwordSubmitButton).click()
|
await page.getByTestId(passwordSubmitButton).click();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,27 +1,27 @@
|
|||||||
import {Page} from "@playwright/test";
|
import { Page } from "@playwright/test";
|
||||||
|
|
||||||
const passwordField = 'password-text-input'
|
const passwordField = "password-text-input";
|
||||||
const passwordConfirmField = 'password-confirm-text-input'
|
const passwordConfirmField = "password-confirm-text-input";
|
||||||
|
|
||||||
export async function registerUserScreenPassword(page: Page, firstname: string, lastname: string, email: string) {
|
export async function registerUserScreenPassword(page: Page, firstname: string, lastname: string, email: string) {
|
||||||
await registerUserScreen(page, firstname, lastname, email)
|
await registerUserScreen(page, firstname, lastname, email);
|
||||||
await page.getByTestId('Password-radio').click();
|
await page.getByTestId("Password-radio").click();
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function registerUserScreenPasskey(page: Page, firstname: string, lastname: string, email: string) {
|
export async function registerUserScreenPasskey(page: Page, firstname: string, lastname: string, email: string) {
|
||||||
await registerUserScreen(page, firstname, lastname, email)
|
await registerUserScreen(page, firstname, lastname, email);
|
||||||
await page.getByTestId('Passkeys-radio').click();
|
await page.getByTestId("Passkeys-radio").click();
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function registerPasswordScreen(page: Page, password1: string, password2: string) {
|
export async function registerPasswordScreen(page: Page, password1: string, password2: string) {
|
||||||
await page.getByTestId(passwordField).pressSequentially(password1);
|
await page.getByTestId(passwordField).pressSequentially(password1);
|
||||||
await page.getByTestId(passwordConfirmField).pressSequentially(password2);
|
await page.getByTestId(passwordConfirmField).pressSequentially(password2);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function registerUserScreen(page: Page, firstname: string, lastname: string, email: string) {
|
export async function registerUserScreen(page: Page, firstname: string, lastname: string, email: string) {
|
||||||
await page.getByTestId('firstname-text-input').pressSequentially(firstname);
|
await page.getByTestId("firstname-text-input").pressSequentially(firstname);
|
||||||
await page.getByTestId('lastname-text-input').pressSequentially(lastname);
|
await page.getByTestId("lastname-text-input").pressSequentially(lastname);
|
||||||
await page.getByTestId('email-text-input').pressSequentially(email);
|
await page.getByTestId("email-text-input").pressSequentially(email);
|
||||||
await page.getByTestId('privacy-policy-checkbox').check();
|
await page.getByTestId("privacy-policy-checkbox").check();
|
||||||
await page.getByTestId('tos-checkbox').check();
|
await page.getByTestId("tos-checkbox").check();
|
||||||
}
|
}
|
||||||
@@ -1,32 +1,32 @@
|
|||||||
import {test} from "@playwright/test";
|
import { test } from "@playwright/test";
|
||||||
import {registerWithPasskey, registerWithPassword} from './register';
|
import dotenv from "dotenv";
|
||||||
import {loginScreenExpect} from "./login";
|
import path from "path";
|
||||||
import {removeUserByUsername} from './zitadel';
|
import { loginScreenExpect } from "./login";
|
||||||
import path from 'path';
|
import { registerWithPasskey, registerWithPassword } from "./register";
|
||||||
import dotenv from 'dotenv';
|
import { removeUserByUsername } from "./zitadel";
|
||||||
|
|
||||||
// Read from ".env" file.
|
// Read from ".env" file.
|
||||||
dotenv.config({path: path.resolve(__dirname, '.env.local')});
|
dotenv.config({ path: path.resolve(__dirname, ".env.local") });
|
||||||
|
|
||||||
test("register with password", async ({page}) => {
|
test("register with password", async ({ page }) => {
|
||||||
const username = "register-password@example.com"
|
const username = "register-password@example.com";
|
||||||
const password = "Password1!"
|
const password = "Password1!";
|
||||||
const firstname = "firstname"
|
const firstname = "firstname";
|
||||||
const lastname = "lastname"
|
const lastname = "lastname";
|
||||||
|
|
||||||
await removeUserByUsername(username)
|
await removeUserByUsername(username);
|
||||||
await registerWithPassword(page, firstname, lastname, username, password, password)
|
await registerWithPassword(page, firstname, lastname, username, password, password);
|
||||||
await loginScreenExpect(page, firstname + " " + lastname);
|
await loginScreenExpect(page, firstname + " " + lastname);
|
||||||
});
|
});
|
||||||
|
|
||||||
test("register with passkey", async ({page}) => {
|
test("register with passkey", async ({ page }) => {
|
||||||
const username = "register-passkey@example.com"
|
const username = "register-passkey@example.com";
|
||||||
const firstname = "firstname"
|
const firstname = "firstname";
|
||||||
const lastname = "lastname"
|
const lastname = "lastname";
|
||||||
|
|
||||||
await removeUserByUsername(username)
|
await removeUserByUsername(username);
|
||||||
await registerWithPasskey(page, firstname, lastname, username)
|
await registerWithPasskey(page, firstname, lastname, username);
|
||||||
await loginScreenExpect(page, firstname + " " + lastname);
|
await loginScreenExpect(page, firstname + " " + lastname);
|
||||||
});
|
});
|
||||||
|
|
||||||
test("register with username and password - only password enabled", async ({user, page}) => {
|
test("register with username and password - only password enabled", async ({user, page}) => {
|
||||||
|
|||||||
@@ -1,18 +1,25 @@
|
|||||||
import {Page} from "@playwright/test";
|
import { Page } from "@playwright/test";
|
||||||
import {passkeyRegister} from './passkey';
|
import { passkeyRegister } from "./passkey";
|
||||||
import {registerPasswordScreen, registerUserScreenPasskey, registerUserScreenPassword} from './register-screen';
|
import { registerPasswordScreen, registerUserScreenPasskey, registerUserScreenPassword } from "./register-screen";
|
||||||
|
|
||||||
export async function registerWithPassword(page: Page, firstname: string, lastname: string, email: string, password1: string, password2: string) {
|
export async function registerWithPassword(
|
||||||
await page.goto('/register');
|
page: Page,
|
||||||
await registerUserScreenPassword(page, firstname, lastname, email)
|
firstname: string,
|
||||||
await page.getByTestId('submit-button').click();
|
lastname: string,
|
||||||
await registerPasswordScreen(page, password1, password2)
|
email: string,
|
||||||
await page.getByTestId('submit-button').click();
|
password1: string,
|
||||||
|
password2: string,
|
||||||
|
) {
|
||||||
|
await page.goto("/register");
|
||||||
|
await registerUserScreenPassword(page, firstname, lastname, email);
|
||||||
|
await page.getByTestId("submit-button").click();
|
||||||
|
await registerPasswordScreen(page, password1, password2);
|
||||||
|
await page.getByTestId("submit-button").click();
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function registerWithPasskey(page: Page, firstname: string, lastname: string, email: string): Promise<string> {
|
export async function registerWithPasskey(page: Page, firstname: string, lastname: string, email: string): Promise<string> {
|
||||||
await page.goto('/register');
|
await page.goto("/register");
|
||||||
await registerUserScreenPasskey(page, firstname, lastname, email)
|
await registerUserScreenPasskey(page, firstname, lastname, email);
|
||||||
await page.getByTestId('submit-button').click();
|
await page.getByTestId("submit-button").click();
|
||||||
return await passkeyRegister(page)
|
return await passkeyRegister(page);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,205 +1,216 @@
|
|||||||
import fetch from "node-fetch";
|
import { Page } from "@playwright/test";
|
||||||
import {Page} from "@playwright/test";
|
import axios from "axios";
|
||||||
import {registerWithPasskey} from "./register";
|
import { registerWithPasskey } from "./register";
|
||||||
import {loginWithPassword} from "./login";
|
import { getUserByUsername, removeUser } from "./zitadel";
|
||||||
import {changePassword} from "./password";
|
|
||||||
import {getUserByUsername, removeUser} from './zitadel';
|
|
||||||
|
|
||||||
export interface userProps {
|
export interface userProps {
|
||||||
email: string;
|
email: string;
|
||||||
firstName: string;
|
firstName: string;
|
||||||
lastName: string;
|
lastName: string;
|
||||||
organization: string;
|
organization: string;
|
||||||
password: string;
|
password: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
class User {
|
class User {
|
||||||
private readonly props: userProps;
|
private readonly props: userProps;
|
||||||
private user: string;
|
private user: string;
|
||||||
|
|
||||||
constructor(userProps: userProps) {
|
constructor(userProps: userProps) {
|
||||||
this.props = userProps;
|
this.props = userProps;
|
||||||
|
}
|
||||||
|
|
||||||
|
async ensure(page: Page) {
|
||||||
|
await this.remove();
|
||||||
|
|
||||||
|
const body = {
|
||||||
|
username: this.props.email,
|
||||||
|
organization: {
|
||||||
|
orgId: this.props.organization,
|
||||||
|
},
|
||||||
|
profile: {
|
||||||
|
givenName: this.props.firstName,
|
||||||
|
familyName: this.props.lastName,
|
||||||
|
},
|
||||||
|
email: {
|
||||||
|
email: this.props.email,
|
||||||
|
isVerified: true,
|
||||||
|
},
|
||||||
|
password: {
|
||||||
|
password: this.props.password!,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
try {
|
||||||
|
const response = await axios.post(`${process.env.ZITADEL_API_URL}/v2/users/human`, body, {
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
Authorization: `Bearer ${process.env.ZITADEL_SERVICE_USER_TOKEN}`,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
if (response.status >= 400 && response.status !== 409) {
|
||||||
|
const error = `HTTP Error: ${response.status} - ${response.statusText}`;
|
||||||
|
console.error(error);
|
||||||
|
throw new Error(error);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error making request:", error);
|
||||||
|
throw error;
|
||||||
}
|
}
|
||||||
|
|
||||||
async ensure(page: Page) {
|
// wait for projection of user
|
||||||
await this.remove()
|
await page.waitForTimeout(3000);
|
||||||
|
}
|
||||||
|
|
||||||
const body = {
|
async remove() {
|
||||||
username: this.props.email,
|
const resp: any = await getUserByUsername(this.getUsername());
|
||||||
organization: {
|
if (!resp || !resp.result || !resp.result[0]) {
|
||||||
orgId: this.props.organization
|
return;
|
||||||
},
|
|
||||||
profile: {
|
|
||||||
givenName: this.props.firstName,
|
|
||||||
familyName: this.props.lastName,
|
|
||||||
},
|
|
||||||
email: {
|
|
||||||
email: this.props.email,
|
|
||||||
isVerified: true,
|
|
||||||
},
|
|
||||||
password: {
|
|
||||||
password: this.props.password!,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const response = await fetch(process.env.ZITADEL_API_URL! + "/v2/users/human", {
|
|
||||||
method: 'POST',
|
|
||||||
body: JSON.stringify(body),
|
|
||||||
headers: {
|
|
||||||
'Content-Type': 'application/json',
|
|
||||||
'Authorization': "Bearer " + process.env.ZITADEL_SERVICE_USER_TOKEN!
|
|
||||||
}
|
|
||||||
});
|
|
||||||
if (response.statusCode >= 400 && response.statusCode != 409) {
|
|
||||||
const error = 'HTTP Error: ' + response.statusCode + ' - ' + response.statusMessage;
|
|
||||||
console.error(error);
|
|
||||||
throw new Error(error);
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
await removeUser(resp.result[0].userId);
|
||||||
|
}
|
||||||
|
|
||||||
async remove() {
|
public setUserId(userId: string) {
|
||||||
await removeUser(this.getUserId())
|
this.user = userId;
|
||||||
return
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public setUserId(userId: string) {
|
public getUserId() {
|
||||||
this.user = userId
|
return this.user;
|
||||||
}
|
}
|
||||||
|
|
||||||
public getUserId() {
|
public getUsername() {
|
||||||
return this.user;
|
return this.props.email;
|
||||||
}
|
}
|
||||||
|
|
||||||
public getUsername() {
|
public getPassword() {
|
||||||
return this.props.email;
|
return this.props.password;
|
||||||
}
|
}
|
||||||
|
|
||||||
public getPassword() {
|
public getFirstname() {
|
||||||
return this.props.password;
|
return this.props.firstName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public getFirstname() {
|
public getLastname() {
|
||||||
return this.props.firstName
|
return this.props.lastName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public getLastname() {
|
public getFullName() {
|
||||||
return this.props.lastName
|
return `${this.props.firstName} ${this.props.lastName}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
public getFullName() {
|
|
||||||
return this.props.firstName + " " + this.props.lastName
|
|
||||||
}
|
|
||||||
|
|
||||||
public async doPasswordChange(page: Page, password: string) {
|
|
||||||
await loginWithPassword(page, this.getUsername(), this.getPassword())
|
|
||||||
await changePassword(page, this.getUsername(), password)
|
|
||||||
this.props.password = password
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export class PasswordUser extends User {
|
export class PasswordUser extends User {}
|
||||||
}
|
|
||||||
|
|
||||||
export enum OtpType {
|
export enum OtpType {
|
||||||
sms = "sms",
|
sms = "sms",
|
||||||
email = "email",
|
email = "email",
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface otpUserProps {
|
export interface otpUserProps {
|
||||||
email: string;
|
email: string;
|
||||||
firstName: string;
|
firstName: string;
|
||||||
lastName: string;
|
lastName: string;
|
||||||
organization: string;
|
organization: string;
|
||||||
password: string,
|
password: string;
|
||||||
type: OtpType,
|
type: OtpType;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class PasswordUserWithOTP extends User {
|
export class PasswordUserWithOTP extends User {
|
||||||
private type: OtpType
|
private type: OtpType;
|
||||||
private code: string
|
private code: string;
|
||||||
|
|
||||||
constructor(props: otpUserProps) {
|
constructor(props: otpUserProps) {
|
||||||
super({
|
super({
|
||||||
email: props.email,
|
email: props.email,
|
||||||
firstName: props.firstName,
|
firstName: props.firstName,
|
||||||
lastName: props.lastName,
|
lastName: props.lastName,
|
||||||
organization: props.organization,
|
organization: props.organization,
|
||||||
password: props.password,
|
password: props.password,
|
||||||
})
|
});
|
||||||
this.type = props.type
|
this.type = props.type;
|
||||||
|
}
|
||||||
|
|
||||||
|
async ensure(page: Page) {
|
||||||
|
await super.ensure(page);
|
||||||
|
|
||||||
|
let url = "otp_";
|
||||||
|
switch (this.type) {
|
||||||
|
case OtpType.sms:
|
||||||
|
url = url + "sms";
|
||||||
|
break;
|
||||||
|
case OtpType.email:
|
||||||
|
url = url + "email";
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
async ensure(page: Page) {
|
try {
|
||||||
await super.ensure(page)
|
const response = await axios.post(
|
||||||
|
`${process.env.ZITADEL_API_URL}/v2/users/${this.getUserId()}/${url}`,
|
||||||
|
{},
|
||||||
|
{
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
Authorization: `Bearer ${process.env.ZITADEL_SERVICE_USER_TOKEN}`,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
let url = "otp_"
|
if (response.status >= 400 && response.status !== 409) {
|
||||||
switch (this.type) {
|
const error = `HTTP Error: ${response.status} - ${response.statusText}`;
|
||||||
case OtpType.sms:
|
console.error(error);
|
||||||
url = url + "sms"
|
throw new Error(error);
|
||||||
case OtpType.email:
|
}
|
||||||
url = url + "email"
|
|
||||||
}
|
|
||||||
|
|
||||||
const response = await fetch(process.env.ZITADEL_API_URL! + "/v2/users/" + this.getUserId() + "/" + url, {
|
// TODO: get code from SMS or Email provider
|
||||||
method: 'POST',
|
this.code = "";
|
||||||
headers: {
|
} catch (error) {
|
||||||
'Content-Type': 'application/json',
|
console.error("Error making request:", error);
|
||||||
'Authorization': "Bearer " + process.env.ZITADEL_SERVICE_USER_TOKEN!
|
throw error;
|
||||||
}
|
|
||||||
});
|
|
||||||
if (response.statusCode >= 400 && response.statusCode != 409) {
|
|
||||||
const error = 'HTTP Error: ' + response.statusCode + ' - ' + response.statusMessage;
|
|
||||||
console.error(error);
|
|
||||||
throw new Error(error);
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: get code from SMS or Email provider
|
|
||||||
this.code = ""
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public getCode() {
|
// wait for projection of user
|
||||||
return this.code
|
await page.waitForTimeout(2000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public getCode() {
|
||||||
|
return this.code;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface passkeyUserProps {
|
export interface passkeyUserProps {
|
||||||
email: string;
|
email: string;
|
||||||
firstName: string;
|
firstName: string;
|
||||||
lastName: string;
|
lastName: string;
|
||||||
organization: string;
|
organization: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class PasskeyUser extends User {
|
export class PasskeyUser extends User {
|
||||||
private authenticatorId: string
|
private authenticatorId: string;
|
||||||
|
|
||||||
constructor(props: passkeyUserProps) {
|
constructor(props: passkeyUserProps) {
|
||||||
super({
|
super({
|
||||||
email: props.email,
|
email: props.email,
|
||||||
firstName: props.firstName,
|
firstName: props.firstName,
|
||||||
lastName: props.lastName,
|
lastName: props.lastName,
|
||||||
organization: props.organization,
|
organization: props.organization,
|
||||||
password: ""
|
password: "",
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public async ensure(page: Page) {
|
public async ensure(page: Page) {
|
||||||
await this.remove()
|
await this.remove();
|
||||||
const authId = await registerWithPasskey(page, this.getFirstname(), this.getLastname(), this.getUsername())
|
const authId = await registerWithPasskey(page, this.getFirstname(), this.getLastname(), this.getUsername());
|
||||||
this.authenticatorId = authId
|
this.authenticatorId = authId;
|
||||||
}
|
|
||||||
|
|
||||||
public async remove() {
|
// wait for projection of user
|
||||||
const resp = await getUserByUsername(this.getUsername())
|
await page.waitForTimeout(2000);
|
||||||
if (!resp || !resp.result || !resp.result[0]) {
|
}
|
||||||
return
|
|
||||||
}
|
|
||||||
this.setUserId(resp.result[0].userId)
|
|
||||||
await super.remove()
|
|
||||||
}
|
|
||||||
|
|
||||||
public getAuthenticatorId(): string {
|
public async remove() {
|
||||||
return this.authenticatorId
|
await super.remove();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public getAuthenticatorId(): string {
|
||||||
|
return this.authenticatorId;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,28 +1,28 @@
|
|||||||
import {test as base} from "@playwright/test";
|
import { test as base } from "@playwright/test";
|
||||||
import path from 'path';
|
import dotenv from "dotenv";
|
||||||
import dotenv from 'dotenv';
|
import path from "path";
|
||||||
import {PasskeyUser} from "./user";
|
import { loginScreenExpect, loginWithPasskey } from "./login";
|
||||||
import {loginScreenExpect, loginWithPasskey} from "./login";
|
import { PasskeyUser } from "./user";
|
||||||
|
|
||||||
// Read from ".env" file.
|
// Read from ".env" file.
|
||||||
dotenv.config({path: path.resolve(__dirname, '.env.local')});
|
dotenv.config({ path: path.resolve(__dirname, ".env.local") });
|
||||||
|
|
||||||
const test = base.extend<{ user: PasskeyUser }>({
|
const test = base.extend<{ user: PasskeyUser }>({
|
||||||
user: async ({page}, use) => {
|
user: async ({ page }, use) => {
|
||||||
const user = new PasskeyUser({
|
const user = new PasskeyUser({
|
||||||
email: "passkey@example.com",
|
email: "passkey@example.com",
|
||||||
firstName: "first",
|
firstName: "first",
|
||||||
lastName: "last",
|
lastName: "last",
|
||||||
organization: "",
|
organization: "",
|
||||||
});
|
});
|
||||||
await user.ensure(page);
|
await user.ensure(page);
|
||||||
await use(user);
|
await use(user);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
test("username and passkey login", async ({user, page}) => {
|
test("username and passkey login", async ({ user, page }) => {
|
||||||
await loginWithPasskey(page, user.getAuthenticatorId(), user.getUsername())
|
await loginWithPasskey(page, user.getAuthenticatorId(), user.getUsername());
|
||||||
await loginScreenExpect(page, user.getFullName());
|
await loginScreenExpect(page, user.getFullName());
|
||||||
});
|
});
|
||||||
|
|
||||||
test("username and passkey login, if passkey enabled", async ({user, page}) => {
|
test("username and passkey login, if passkey enabled", async ({user, page}) => {
|
||||||
|
|||||||
@@ -1,41 +1,47 @@
|
|||||||
import {test as base} from "@playwright/test";
|
import { test as base } from "@playwright/test";
|
||||||
import {PasswordUser} from './user';
|
import dotenv from "dotenv";
|
||||||
import path from 'path';
|
import path from "path";
|
||||||
import dotenv from 'dotenv';
|
import { loginScreenExpect, loginWithPassword } from "./login";
|
||||||
import {loginScreenExpect, loginWithPassword} from "./login";
|
import { changePassword, startChangePassword } from "./password";
|
||||||
import {changePassword, startChangePassword} from "./password";
|
import { changePasswordScreen, changePasswordScreenExpect } from "./password-screen";
|
||||||
import {changePasswordScreen, changePasswordScreenExpect} from "./password-screen";
|
import { PasswordUser } from "./user";
|
||||||
|
|
||||||
// Read from ".env" file.
|
// Read from ".env" file.
|
||||||
dotenv.config({path: path.resolve(__dirname, '.env.local')});
|
dotenv.config({ path: path.resolve(__dirname, ".env.local") });
|
||||||
|
|
||||||
const test = base.extend<{ user: PasswordUser }>({
|
const test = base.extend<{ user: PasswordUser }>({
|
||||||
user: async ({page}, use) => {
|
user: async ({ page }, use) => {
|
||||||
const user = new PasswordUser({
|
const user = new PasswordUser({
|
||||||
email: "password-changed@example.com",
|
email: "password-changed@example.com",
|
||||||
firstName: "first",
|
firstName: "first",
|
||||||
lastName: "last",
|
lastName: "last",
|
||||||
password: "Password1!",
|
password: "Password1!",
|
||||||
organization: "",
|
organization: "",
|
||||||
});
|
});
|
||||||
await user.ensure(page);
|
await user.ensure(page);
|
||||||
await use(user);
|
await use(user);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
test("username and password changed login", async ({user, page}) => {
|
test("username and password changed login", async ({ user, page }) => {
|
||||||
const changedPw = "ChangedPw1!"
|
const changedPw = "ChangedPw1!";
|
||||||
await loginWithPassword(page, user.getUsername(), user.getPassword())
|
await loginWithPassword(page, user.getUsername(), user.getPassword());
|
||||||
await changePassword(page, user.getUsername(), changedPw)
|
|
||||||
await loginWithPassword(page, user.getUsername(), changedPw)
|
// wait for projection of token
|
||||||
await loginScreenExpect(page, user.getFullName());
|
await page.waitForTimeout(2000);
|
||||||
|
|
||||||
|
await changePassword(page, user.getUsername(), changedPw);
|
||||||
|
await loginScreenExpect(page, user.getFullName());
|
||||||
|
|
||||||
|
await loginWithPassword(page, user.getUsername(), changedPw);
|
||||||
|
await loginScreenExpect(page, user.getFullName());
|
||||||
});
|
});
|
||||||
|
|
||||||
test("password not with desired complexity", async ({user, page}) => {
|
test("password not with desired complexity", async ({ user, page }) => {
|
||||||
const changedPw1 = "change"
|
const changedPw1 = "change";
|
||||||
const changedPw2 = "chang"
|
const changedPw2 = "chang";
|
||||||
await loginWithPassword(page, user.getUsername(), user.getPassword())
|
await loginWithPassword(page, user.getUsername(), user.getPassword());
|
||||||
await startChangePassword(page, user.getUsername());
|
await startChangePassword(page, user.getUsername());
|
||||||
await changePasswordScreen(page, changedPw1, changedPw2)
|
await changePasswordScreen(page, changedPw1, changedPw2);
|
||||||
await changePasswordScreenExpect(page, changedPw1, changedPw2, false, false, false, false, true, false)
|
await changePasswordScreenExpect(page, changedPw1, changedPw2, false, false, false, false, true, false);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,39 +1,36 @@
|
|||||||
import {test as base} from "@playwright/test";
|
import { test as base } from "@playwright/test";
|
||||||
import {OtpType, PasswordUserWithOTP} from './user';
|
import dotenv from "dotenv";
|
||||||
import path from 'path';
|
import path from "path";
|
||||||
import dotenv from 'dotenv';
|
import { OtpType, PasswordUserWithOTP } from "./user";
|
||||||
import {loginScreenExpect, loginWithPassword} from "./login";
|
|
||||||
import {startSink} from "./otp";
|
|
||||||
|
|
||||||
// Read from ".env" file.
|
// Read from ".env" file.
|
||||||
dotenv.config({path: path.resolve(__dirname, '.env.local')});
|
dotenv.config({ path: path.resolve(__dirname, ".env.local") });
|
||||||
|
|
||||||
const test = base.extend<{ user: PasswordUserWithOTP }>({
|
const test = base.extend<{ user: PasswordUserWithOTP }>({
|
||||||
user: async ({page}, use) => {
|
user: async ({ page }, use) => {
|
||||||
const user = new PasswordUserWithOTP({
|
const user = new PasswordUserWithOTP({
|
||||||
email: "otp_sms@example.com",
|
email: "otp_sms@example.com",
|
||||||
firstName: "first",
|
firstName: "first",
|
||||||
lastName: "last",
|
lastName: "last",
|
||||||
password: "Password1!",
|
password: "Password1!",
|
||||||
organization: "",
|
organization: "",
|
||||||
type: OtpType.sms,
|
type: OtpType.sms,
|
||||||
});
|
});
|
||||||
|
|
||||||
await user.ensure(page);
|
await user.ensure(page);
|
||||||
await use(user);
|
await use(user);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
test("username, password and otp login", async ({user, page}) => {
|
/*
|
||||||
const server = startSink()
|
test("username, password and otp login", async ({ user, page }) => {
|
||||||
await loginWithPassword(page, user.getUsername(), user.getPassword())
|
//const server = startSink()
|
||||||
|
await loginWithPassword(page, user.getUsername(), user.getPassword());
|
||||||
|
|
||||||
|
await loginScreenExpect(page, user.getFullName());
|
||||||
await loginScreenExpect(page, user.getFullName());
|
//server.close()
|
||||||
server.close()
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
test("username, password and sms 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 sms otp is enabled on the organizaiton of the user
|
||||||
// Given the user has only sms otp configured as second factor
|
// Given the user has only sms otp configured as second factor
|
||||||
@@ -45,7 +42,6 @@ test("username, password and sms otp login", async ({user, page}) => {
|
|||||||
// User is redirected to the app (default redirect url)
|
// User is redirected to the app (default redirect url)
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
test("username, password and sms otp login, resend code", async ({user, page}) => {
|
test("username, password and sms otp login, resend code", async ({user, page}) => {
|
||||||
// Given sms otp is enabled on the organizaiton of the user
|
// Given sms otp is enabled on the organizaiton of the user
|
||||||
// Given the user has only sms otp configured as second factor
|
// Given the user has only sms otp configured as second factor
|
||||||
@@ -58,7 +54,6 @@ test("username, password and sms otp login, resend code", async ({user, page}) =
|
|||||||
// User is redirected to the app (default redirect url)
|
// User is redirected to the app (default redirect url)
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
test("username, password and sms otp login, wrong code", async ({user, page}) => {
|
test("username, password and sms otp login, wrong code", async ({user, page}) => {
|
||||||
// Given sms otp is enabled on the organizaiton of the user
|
// Given sms otp is enabled on the organizaiton of the user
|
||||||
// Given the user has only sms otp configured as second factor
|
// Given the user has only sms otp configured as second factor
|
||||||
@@ -69,3 +64,4 @@ test("username, password and sms otp login, wrong code", async ({user, page}) =>
|
|||||||
// User enters a wrond code
|
// User enters a wrond code
|
||||||
// Error message - "Invalid code" is shown
|
// Error message - "Invalid code" is shown
|
||||||
});
|
});
|
||||||
|
*/
|
||||||
|
|||||||
@@ -1,47 +1,47 @@
|
|||||||
import {test as base} from "@playwright/test";
|
import { test as base } from "@playwright/test";
|
||||||
import {PasswordUser} from './user';
|
import dotenv from "dotenv";
|
||||||
import path from 'path';
|
import path from "path";
|
||||||
import dotenv from 'dotenv';
|
import { loginScreenExpect, loginWithPassword, startLogin } from "./login";
|
||||||
import {loginScreenExpect, loginWithPassword, startLogin} from "./login";
|
import { loginname } from "./loginname";
|
||||||
import {loginnameScreenExpect} from "./loginname-screen";
|
import { loginnameScreenExpect } from "./loginname-screen";
|
||||||
import {passwordScreenExpect} from "./password-screen";
|
import { password } from "./password";
|
||||||
import {loginname} from "./loginname";
|
import { passwordScreenExpect } from "./password-screen";
|
||||||
import {password} from "./password";
|
import { PasswordUser } from "./user";
|
||||||
|
|
||||||
// Read from ".env" file.
|
// Read from ".env" file.
|
||||||
dotenv.config({path: path.resolve(__dirname, '.env.local')});
|
dotenv.config({ path: path.resolve(__dirname, ".env.local") });
|
||||||
|
|
||||||
const test = base.extend<{ user: PasswordUser }>({
|
const test = base.extend<{ user: PasswordUser }>({
|
||||||
user: async ({page}, use) => {
|
user: async ({ page }, use) => {
|
||||||
const user = new PasswordUser({
|
const user = new PasswordUser({
|
||||||
email: "password@example.com",
|
email: "password@example.com",
|
||||||
firstName: "first",
|
firstName: "first",
|
||||||
lastName: "last",
|
lastName: "last",
|
||||||
password: "Password1!",
|
password: "Password1!",
|
||||||
organization: "",
|
organization: "",
|
||||||
});
|
});
|
||||||
await user.ensure(page);
|
await user.ensure(page);
|
||||||
await use(user);
|
await use(user);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
test("username and password login", async ({user, page}) => {
|
test("username and password login", async ({ user, page }) => {
|
||||||
await loginWithPassword(page, user.getUsername(), user.getPassword())
|
await loginWithPassword(page, user.getUsername(), user.getPassword());
|
||||||
await loginScreenExpect(page, user.getFullName());
|
await loginScreenExpect(page, user.getFullName());
|
||||||
});
|
});
|
||||||
|
|
||||||
test("username and password login, unknown username", async ({page}) => {
|
test("username and password login, unknown username", async ({ page }) => {
|
||||||
const username = "unknown"
|
const username = "unknown";
|
||||||
await startLogin(page);
|
await startLogin(page);
|
||||||
await loginname(page, username)
|
await loginname(page, username);
|
||||||
await loginnameScreenExpect(page, username)
|
await loginnameScreenExpect(page, username);
|
||||||
});
|
});
|
||||||
|
|
||||||
test("username and password login, wrong password", async ({user, page}) => {
|
test("username and password login, wrong password", async ({ user, page }) => {
|
||||||
await startLogin(page);
|
await startLogin(page);
|
||||||
await loginname(page, user.getUsername())
|
await loginname(page, user.getUsername());
|
||||||
await password(page, "wrong")
|
await password(page, "wrong");
|
||||||
await passwordScreenExpect(page, "wrong")
|
await passwordScreenExpect(page, "wrong");
|
||||||
});
|
});
|
||||||
|
|
||||||
test("username and password login, wrong username, ignore unknown usernames", async ({user, page}) => {
|
test("username and password login, wrong username, ignore unknown usernames", async ({user, page}) => {
|
||||||
|
|||||||
@@ -1,50 +1,60 @@
|
|||||||
import fetch from "node-fetch";
|
import axios from "axios";
|
||||||
|
|
||||||
export async function removeUserByUsername(username: string) {
|
export async function removeUserByUsername(username: string) {
|
||||||
const resp = await getUserByUsername(username)
|
const resp = await getUserByUsername(username);
|
||||||
if (!resp || !resp.result || !resp.result[0]) {
|
if (!resp || !resp.result || !resp.result[0]) {
|
||||||
return
|
return;
|
||||||
}
|
}
|
||||||
await removeUser(resp.result[0].userId)
|
await removeUser(resp.result[0].userId);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function removeUser(id: string) {
|
export async function removeUser(id: string) {
|
||||||
const response = await fetch(process.env.ZITADEL_API_URL! + "/v2/users/" + id, {
|
try {
|
||||||
method: 'DELETE',
|
const response = await axios.delete(`${process.env.ZITADEL_API_URL}/v2/users/${id}`, {
|
||||||
headers: {
|
headers: {
|
||||||
'Authorization': "Bearer " + process.env.ZITADEL_SERVICE_USER_TOKEN!
|
Authorization: `Bearer ${process.env.ZITADEL_SERVICE_USER_TOKEN}`,
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
if (response.statusCode >= 400 && response.statusCode != 404) {
|
|
||||||
const error = 'HTTP Error: ' + response.statusCode + ' - ' + response.statusMessage;
|
if (response.status >= 400 && response.status !== 404) {
|
||||||
console.error(error);
|
const error = `HTTP Error: ${response.status} - ${response.statusText}`;
|
||||||
throw new Error(error);
|
console.error(error);
|
||||||
|
throw new Error(error);
|
||||||
}
|
}
|
||||||
return
|
} catch (error) {
|
||||||
|
console.error("Error making request:", error);
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getUserByUsername(username: string) {
|
export async function getUserByUsername(username: string) {
|
||||||
const listUsersBody = {
|
const listUsersBody = {
|
||||||
queries: [{
|
queries: [
|
||||||
userNameQuery: {
|
{
|
||||||
userName: username,
|
userNameQuery: {
|
||||||
}
|
userName: username,
|
||||||
}]
|
},
|
||||||
}
|
},
|
||||||
const jsonBody = JSON.stringify(listUsersBody)
|
],
|
||||||
const registerResponse = await fetch(process.env.ZITADEL_API_URL! + "/v2/users", {
|
};
|
||||||
method: 'POST',
|
|
||||||
body: jsonBody,
|
try {
|
||||||
headers: {
|
const response = await axios.post(`${process.env.ZITADEL_API_URL}/v2/users`, listUsersBody, {
|
||||||
'Content-Type': 'application/json',
|
headers: {
|
||||||
'Authorization': "Bearer " + process.env.ZITADEL_SERVICE_USER_TOKEN!
|
"Content-Type": "application/json",
|
||||||
}
|
Authorization: `Bearer ${process.env.ZITADEL_SERVICE_USER_TOKEN}`,
|
||||||
|
},
|
||||||
});
|
});
|
||||||
if (registerResponse.statusCode >= 400) {
|
|
||||||
const error = 'HTTP Error: ' + registerResponse.statusCode + ' - ' + registerResponse.statusMessage;
|
if (response.status >= 400) {
|
||||||
console.error(error);
|
const error = `HTTP Error: ${response.status} - ${response.statusText}`;
|
||||||
throw new Error(error);
|
console.error(error);
|
||||||
|
throw new Error(error);
|
||||||
}
|
}
|
||||||
const respJson = await registerResponse.json()
|
|
||||||
return respJson
|
return response.data;
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error making request:", error);
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,11 @@
|
|||||||
FirstInstance:
|
FirstInstance:
|
||||||
PatPath: /pat/zitadel-admin-sa.pat
|
PatPath: /pat/zitadel-admin-sa.pat
|
||||||
|
PrivacyPolicy:
|
||||||
|
TOSLink: "https://zitadel.com/docs/legal/terms-of-service"
|
||||||
|
PrivacyLink: "https://zitadel.com/docs/legal/policies/privacy-policy"
|
||||||
|
HelpLink: "https://zitadel.com/docs"
|
||||||
|
SupportEmail: "support@zitadel.com"
|
||||||
|
DocsLink: "https://zitadel.com/docs"
|
||||||
Org:
|
Org:
|
||||||
Human:
|
Human:
|
||||||
UserName: zitadel-admin
|
UserName: zitadel-admin
|
||||||
|
|||||||
@@ -2,6 +2,14 @@ import { stub } from "../support/mock";
|
|||||||
|
|
||||||
describe("login", () => {
|
describe("login", () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
|
stub("zitadel.org.v2.OrganizationService", "ListOrganizations", {
|
||||||
|
data: {
|
||||||
|
details: {
|
||||||
|
totalResult: 1,
|
||||||
|
},
|
||||||
|
result: [{ id: "256088834543534543" }],
|
||||||
|
},
|
||||||
|
});
|
||||||
stub("zitadel.session.v2.SessionService", "CreateSession", {
|
stub("zitadel.session.v2.SessionService", "CreateSession", {
|
||||||
data: {
|
data: {
|
||||||
details: {
|
details: {
|
||||||
|
|||||||
@@ -3,11 +3,12 @@ import { SignInWithIdp } from "@/components/sign-in-with-idp";
|
|||||||
import { UsernameForm } from "@/components/username-form";
|
import { UsernameForm } from "@/components/username-form";
|
||||||
import {
|
import {
|
||||||
getBrandingSettings,
|
getBrandingSettings,
|
||||||
getLegalAndSupportSettings,
|
getDefaultOrg,
|
||||||
getLoginSettings,
|
getLoginSettings,
|
||||||
settingsService,
|
settingsService,
|
||||||
} from "@/lib/zitadel";
|
} from "@/lib/zitadel";
|
||||||
import { makeReqCtx } from "@zitadel/client/v2";
|
import { makeReqCtx } from "@zitadel/client/v2";
|
||||||
|
import { Organization } from "@zitadel/proto/zitadel/org/v2/org_pb";
|
||||||
import { getLocale, getTranslations } from "next-intl/server";
|
import { getLocale, getTranslations } from "next-intl/server";
|
||||||
|
|
||||||
function getIdentityProviders(orgId?: string) {
|
function getIdentityProviders(orgId?: string) {
|
||||||
@@ -31,16 +32,29 @@ export default async function Page({
|
|||||||
const organization = searchParams?.organization;
|
const organization = searchParams?.organization;
|
||||||
const submit: boolean = searchParams?.submit === "true";
|
const submit: boolean = searchParams?.submit === "true";
|
||||||
|
|
||||||
const loginSettings = await getLoginSettings(organization);
|
let defaultOrganization;
|
||||||
const legal = await getLegalAndSupportSettings();
|
if (!organization) {
|
||||||
|
const org: Organization | null = await getDefaultOrg();
|
||||||
const identityProviders = await getIdentityProviders(organization);
|
if (org) {
|
||||||
|
defaultOrganization = org.id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const host = process.env.VERCEL_URL
|
const host = process.env.VERCEL_URL
|
||||||
? `https://${process.env.VERCEL_URL}`
|
? `https://${process.env.VERCEL_URL}`
|
||||||
: "http://localhost:3000";
|
: "http://localhost:3000";
|
||||||
|
|
||||||
const branding = await getBrandingSettings(organization);
|
const loginSettings = await getLoginSettings(
|
||||||
|
organization ?? defaultOrganization,
|
||||||
|
);
|
||||||
|
|
||||||
|
const identityProviders = await getIdentityProviders(
|
||||||
|
organization ?? defaultOrganization,
|
||||||
|
);
|
||||||
|
|
||||||
|
const branding = await getBrandingSettings(
|
||||||
|
organization ?? defaultOrganization,
|
||||||
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<DynamicTheme branding={branding}>
|
<DynamicTheme branding={branding}>
|
||||||
@@ -51,16 +65,16 @@ export default async function Page({
|
|||||||
<UsernameForm
|
<UsernameForm
|
||||||
loginName={loginName}
|
loginName={loginName}
|
||||||
authRequestId={authRequestId}
|
authRequestId={authRequestId}
|
||||||
organization={organization}
|
organization={organization} // stick to "organization" as we still want to do user discovery based on the searchParams not the default organization, later the organization is determined by the found user
|
||||||
submit={submit}
|
submit={submit}
|
||||||
allowRegister={!!loginSettings?.allowRegister}
|
allowRegister={!!loginSettings?.allowRegister}
|
||||||
>
|
>
|
||||||
{legal && identityProviders && process.env.ZITADEL_API_URL && (
|
{identityProviders && process.env.ZITADEL_API_URL && (
|
||||||
<SignInWithIdp
|
<SignInWithIdp
|
||||||
host={host}
|
host={host}
|
||||||
identityProviders={identityProviders}
|
identityProviders={identityProviders}
|
||||||
authRequestId={authRequestId}
|
authRequestId={authRequestId}
|
||||||
organization={organization}
|
organization={organization ?? defaultOrganization} // use the organization from the searchParams here otherwise fallback to the default organization
|
||||||
></SignInWithIdp>
|
></SignInWithIdp>
|
||||||
)}
|
)}
|
||||||
</UsernameForm>
|
</UsernameForm>
|
||||||
|
|||||||
@@ -3,7 +3,12 @@ import { DynamicTheme } from "@/components/dynamic-theme";
|
|||||||
import { PasswordForm } from "@/components/password-form";
|
import { PasswordForm } from "@/components/password-form";
|
||||||
import { UserAvatar } from "@/components/user-avatar";
|
import { UserAvatar } from "@/components/user-avatar";
|
||||||
import { loadMostRecentSession } from "@/lib/session";
|
import { loadMostRecentSession } from "@/lib/session";
|
||||||
import { getBrandingSettings, getLoginSettings } from "@/lib/zitadel";
|
import {
|
||||||
|
getBrandingSettings,
|
||||||
|
getDefaultOrg,
|
||||||
|
getLoginSettings,
|
||||||
|
} from "@/lib/zitadel";
|
||||||
|
import { Organization } from "@zitadel/proto/zitadel/org/v2/org_pb";
|
||||||
import { PasskeysType } from "@zitadel/proto/zitadel/settings/v2/login_settings_pb";
|
import { PasskeysType } from "@zitadel/proto/zitadel/settings/v2/login_settings_pb";
|
||||||
import { getLocale, getTranslations } from "next-intl/server";
|
import { getLocale, getTranslations } from "next-intl/server";
|
||||||
|
|
||||||
@@ -16,7 +21,16 @@ export default async function Page({
|
|||||||
const t = await getTranslations({ locale, namespace: "password" });
|
const t = await getTranslations({ locale, namespace: "password" });
|
||||||
const tError = await getTranslations({ locale, namespace: "error" });
|
const tError = await getTranslations({ locale, namespace: "error" });
|
||||||
|
|
||||||
const { loginName, organization, authRequestId, alt } = searchParams;
|
let { loginName, organization, authRequestId, alt } = searchParams;
|
||||||
|
|
||||||
|
let defaultOrganization;
|
||||||
|
if (!organization) {
|
||||||
|
const org: Organization | null = await getDefaultOrg();
|
||||||
|
|
||||||
|
if (org) {
|
||||||
|
defaultOrganization = org.id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// also allow no session to be found (ignoreUnkownUsername)
|
// also allow no session to be found (ignoreUnkownUsername)
|
||||||
let sessionFactors;
|
let sessionFactors;
|
||||||
@@ -30,8 +44,12 @@ export default async function Page({
|
|||||||
console.warn(error);
|
console.warn(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
const branding = await getBrandingSettings(organization);
|
const branding = await getBrandingSettings(
|
||||||
const loginSettings = await getLoginSettings(organization);
|
organization ?? defaultOrganization,
|
||||||
|
);
|
||||||
|
const loginSettings = await getLoginSettings(
|
||||||
|
organization ?? defaultOrganization,
|
||||||
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<DynamicTheme branding={branding}>
|
<DynamicTheme branding={branding}>
|
||||||
@@ -62,7 +80,7 @@ export default async function Page({
|
|||||||
<PasswordForm
|
<PasswordForm
|
||||||
loginName={loginName}
|
loginName={loginName}
|
||||||
authRequestId={authRequestId}
|
authRequestId={authRequestId}
|
||||||
organization={organization}
|
organization={organization} // stick to "organization" as we still want to do user discovery based on the searchParams not the default organization, later the organization is determined by the found user
|
||||||
loginSettings={loginSettings}
|
loginSettings={loginSettings}
|
||||||
promptPasswordless={
|
promptPasswordless={
|
||||||
loginSettings?.passkeysType === PasskeysType.ALLOWED
|
loginSettings?.passkeysType === PasskeysType.ALLOWED
|
||||||
|
|||||||
@@ -22,13 +22,8 @@ export default async function Page({
|
|||||||
searchParams;
|
searchParams;
|
||||||
|
|
||||||
if (!organization) {
|
if (!organization) {
|
||||||
const org: Organization | null = await getDefaultOrg().catch((error) => {
|
const org: Organization | null = await getDefaultOrg();
|
||||||
console.warn(error);
|
if (org) {
|
||||||
return null;
|
|
||||||
});
|
|
||||||
if (!org) {
|
|
||||||
console.warn("No default organization found");
|
|
||||||
} else {
|
|
||||||
organization = org.id;
|
organization = org.id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ export function AuthenticationMethodRadio({
|
|||||||
<RadioGroup.Option
|
<RadioGroup.Option
|
||||||
key={method.name}
|
key={method.name}
|
||||||
value={method}
|
value={method}
|
||||||
data-testid={method.name+"-radio"}
|
data-testid={method.name + "-radio"}
|
||||||
className={({ active, checked }) =>
|
className={({ active, checked }) =>
|
||||||
`${
|
`${
|
||||||
active
|
active
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import { create } from "@zitadel/client";
|
|||||||
import { ChecksSchema } from "@zitadel/proto/zitadel/session/v2/session_service_pb";
|
import { ChecksSchema } from "@zitadel/proto/zitadel/session/v2/session_service_pb";
|
||||||
import { PasswordComplexitySettings } from "@zitadel/proto/zitadel/settings/v2/password_settings_pb";
|
import { PasswordComplexitySettings } from "@zitadel/proto/zitadel/settings/v2/password_settings_pb";
|
||||||
import { useTranslations } from "next-intl";
|
import { useTranslations } from "next-intl";
|
||||||
|
import { redirect } from "next/navigation";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import { FieldValues, useForm } from "react-hook-form";
|
import { FieldValues, useForm } from "react-hook-form";
|
||||||
import { Alert } from "./alert";
|
import { Alert } from "./alert";
|
||||||
@@ -103,6 +104,11 @@ export function ChangePasswordForm({
|
|||||||
passwordResponse.error
|
passwordResponse.error
|
||||||
) {
|
) {
|
||||||
setError(passwordResponse.error);
|
setError(passwordResponse.error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (passwordResponse && passwordResponse.nextStep) {
|
||||||
|
return redirect(passwordResponse.nextStep);
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -1,71 +0,0 @@
|
|||||||
"use client";
|
|
||||||
|
|
||||||
import { Bars3Icon, XMarkIcon } from "@heroicons/react/24/solid";
|
|
||||||
import { clsx } from "clsx";
|
|
||||||
import {
|
|
||||||
createContext,
|
|
||||||
Dispatch,
|
|
||||||
ReactNode,
|
|
||||||
SetStateAction,
|
|
||||||
useContext,
|
|
||||||
useState,
|
|
||||||
} from "react";
|
|
||||||
|
|
||||||
const MobileNavContext = createContext<
|
|
||||||
[boolean, Dispatch<SetStateAction<boolean>>] | undefined
|
|
||||||
>(undefined);
|
|
||||||
|
|
||||||
export function MobileNavContextProvider({
|
|
||||||
children,
|
|
||||||
}: {
|
|
||||||
children: ReactNode;
|
|
||||||
}) {
|
|
||||||
const [isOpen, setIsOpen] = useState(false);
|
|
||||||
return (
|
|
||||||
<MobileNavContext.Provider value={[isOpen, setIsOpen]}>
|
|
||||||
{children}
|
|
||||||
</MobileNavContext.Provider>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
export function useMobileNavToggle() {
|
|
||||||
const context = useContext(MobileNavContext);
|
|
||||||
if (context === undefined) {
|
|
||||||
throw new Error(
|
|
||||||
"useMobileNavToggle must be used within a MobileNavContextProvider",
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return context;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function MobileNavToggle({ children }: { children: ReactNode }) {
|
|
||||||
const [isOpen, setIsOpen] = useMobileNavToggle();
|
|
||||||
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
className="group absolute right-0 top-0 flex h-14 items-center space-x-2 px-4 lg:hidden"
|
|
||||||
onClick={() => setIsOpen(!isOpen)}
|
|
||||||
>
|
|
||||||
<div className="font-medium text-text-light-secondary-500 dark:text-text-dark-secondary-500 group-hover:text-text-light-500 dark:group-hover:text-text-dark-500">
|
|
||||||
Menu
|
|
||||||
</div>
|
|
||||||
{isOpen ? (
|
|
||||||
<XMarkIcon className="block w-6" />
|
|
||||||
) : (
|
|
||||||
<Bars3Icon className="block w-6" />
|
|
||||||
)}
|
|
||||||
</button>
|
|
||||||
|
|
||||||
<div
|
|
||||||
className={clsx("overflow-y-auto lg:static lg:block", {
|
|
||||||
"fixed inset-x-0 bottom-0 top-14 bg-gray-900": isOpen,
|
|
||||||
hidden: !isOpen,
|
|
||||||
})}
|
|
||||||
>
|
|
||||||
{children}
|
|
||||||
</div>
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@@ -71,9 +71,12 @@ export function PasswordForm({
|
|||||||
|
|
||||||
if (response && "error" in response && response.error) {
|
if (response && "error" in response && response.error) {
|
||||||
setError(response.error);
|
setError(response.error);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
return response;
|
if (response && response.nextStep) {
|
||||||
|
return router.push(response.nextStep);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function resetPasswordAndContinue() {
|
async function resetPasswordAndContinue() {
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import { create } from "@zitadel/client";
|
|||||||
import { ChecksSchema } from "@zitadel/proto/zitadel/session/v2/session_service_pb";
|
import { ChecksSchema } from "@zitadel/proto/zitadel/session/v2/session_service_pb";
|
||||||
import { PasswordComplexitySettings } from "@zitadel/proto/zitadel/settings/v2/password_settings_pb";
|
import { PasswordComplexitySettings } from "@zitadel/proto/zitadel/settings/v2/password_settings_pb";
|
||||||
import { useTranslations } from "next-intl";
|
import { useTranslations } from "next-intl";
|
||||||
|
import { redirect } from "next/navigation";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import { FieldValues, useForm } from "react-hook-form";
|
import { FieldValues, useForm } from "react-hook-form";
|
||||||
import { Alert } from "./alert";
|
import { Alert } from "./alert";
|
||||||
@@ -123,7 +124,14 @@ export function SetPasswordForm({
|
|||||||
passwordResponse.error
|
passwordResponse.error
|
||||||
) {
|
) {
|
||||||
setError(passwordResponse.error);
|
setError(passwordResponse.error);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (passwordResponse && passwordResponse.nextStep) {
|
||||||
|
return redirect(passwordResponse.nextStep);
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const { errors } = formState;
|
const { errors } = formState;
|
||||||
|
|||||||
@@ -124,23 +124,11 @@ export async function sendPassword(command: UpdateSessionCommand) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const submitted = {
|
if (!authMethods || !session.factors?.user?.loginName) {
|
||||||
sessionId: session.id,
|
|
||||||
factors: session.factors,
|
|
||||||
challenges: session.challenges,
|
|
||||||
authMethods,
|
|
||||||
userState: user.state,
|
|
||||||
};
|
|
||||||
|
|
||||||
if (
|
|
||||||
!submitted ||
|
|
||||||
!submitted.authMethods ||
|
|
||||||
!submitted.factors?.user?.loginName
|
|
||||||
) {
|
|
||||||
return { error: "Could not verify password!" };
|
return { error: "Could not verify password!" };
|
||||||
}
|
}
|
||||||
|
|
||||||
const availableSecondFactors = submitted?.authMethods?.filter(
|
const availableSecondFactors = authMethods?.filter(
|
||||||
(m: AuthenticationMethodType) =>
|
(m: AuthenticationMethodType) =>
|
||||||
m !== AuthenticationMethodType.PASSWORD &&
|
m !== AuthenticationMethodType.PASSWORD &&
|
||||||
m !== AuthenticationMethodType.PASSKEY,
|
m !== AuthenticationMethodType.PASSKEY,
|
||||||
@@ -148,15 +136,18 @@ export async function sendPassword(command: UpdateSessionCommand) {
|
|||||||
|
|
||||||
if (availableSecondFactors?.length == 1) {
|
if (availableSecondFactors?.length == 1) {
|
||||||
const params = new URLSearchParams({
|
const params = new URLSearchParams({
|
||||||
loginName: submitted.factors?.user.loginName,
|
loginName: session.factors?.user.loginName,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (command.authRequestId) {
|
if (command.authRequestId) {
|
||||||
params.append("authRequestId", command.authRequestId);
|
params.append("authRequestId", command.authRequestId);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (command.organization) {
|
if (command.organization || session.factors?.user?.organizationId) {
|
||||||
params.append("organization", command.organization);
|
params.append(
|
||||||
|
"organization",
|
||||||
|
command.organization ?? session.factors?.user?.organizationId,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const factor = availableSecondFactors[0];
|
const factor = availableSecondFactors[0];
|
||||||
@@ -172,35 +163,41 @@ export async function sendPassword(command: UpdateSessionCommand) {
|
|||||||
}
|
}
|
||||||
} else if (availableSecondFactors?.length >= 1) {
|
} else if (availableSecondFactors?.length >= 1) {
|
||||||
const params = new URLSearchParams({
|
const params = new URLSearchParams({
|
||||||
loginName: submitted.factors.user.loginName,
|
loginName: session.factors.user.loginName,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (command.authRequestId) {
|
if (command.authRequestId) {
|
||||||
params.append("authRequestId", command.authRequestId);
|
params.append("authRequestId", command.authRequestId);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (command.organization) {
|
if (command.organization || session.factors?.user?.organizationId) {
|
||||||
params.append("organization", command.organization);
|
params.append(
|
||||||
|
"organization",
|
||||||
|
command.organization ?? session.factors?.user?.organizationId,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return redirect(`/mfa?` + params);
|
return redirect(`/mfa?` + params);
|
||||||
} else if (submitted.userState === UserState.INITIAL) {
|
} else if (user.state === UserState.INITIAL) {
|
||||||
const params = new URLSearchParams({
|
const params = new URLSearchParams({
|
||||||
loginName: submitted.factors.user.loginName,
|
loginName: session.factors.user.loginName,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (command.authRequestId) {
|
if (command.authRequestId) {
|
||||||
params.append("authRequestId", command.authRequestId);
|
params.append("authRequestId", command.authRequestId);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (command.organization) {
|
if (command.organization || session.factors?.user?.organizationId) {
|
||||||
params.append("organization", command.organization);
|
params.append(
|
||||||
|
"organization",
|
||||||
|
command.organization ?? session.factors?.user?.organizationId,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return redirect(`/password/change?` + params);
|
return redirect(`/password/change?` + params);
|
||||||
} else if (command.forceMfa && !availableSecondFactors.length) {
|
} else if (command.forceMfa && !availableSecondFactors.length) {
|
||||||
const params = new URLSearchParams({
|
const params = new URLSearchParams({
|
||||||
loginName: submitted.factors.user.loginName,
|
loginName: session.factors.user.loginName,
|
||||||
force: "true", // this defines if the mfa is forced in the settings
|
force: "true", // this defines if the mfa is forced in the settings
|
||||||
checkAfter: "true", // this defines if the check is directly made after the setup
|
checkAfter: "true", // this defines if the check is directly made after the setup
|
||||||
});
|
});
|
||||||
@@ -209,8 +206,11 @@ export async function sendPassword(command: UpdateSessionCommand) {
|
|||||||
params.append("authRequestId", command.authRequestId);
|
params.append("authRequestId", command.authRequestId);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (command.organization) {
|
if (command.organization || session.factors?.user?.organizationId) {
|
||||||
params.append("organization", command.organization);
|
params.append(
|
||||||
|
"organization",
|
||||||
|
command.organization ?? session.factors?.user?.organizationId,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: provide a way to setup passkeys on mfa page?
|
// TODO: provide a way to setup passkeys on mfa page?
|
||||||
@@ -239,33 +239,39 @@ export async function sendPassword(command: UpdateSessionCommand) {
|
|||||||
|
|
||||||
// return router.push(`/passkey/set?` + params);
|
// return router.push(`/passkey/set?` + params);
|
||||||
// }
|
// }
|
||||||
else if (command.authRequestId && submitted.sessionId) {
|
else if (command.authRequestId && session.id) {
|
||||||
const params = new URLSearchParams({
|
const params = new URLSearchParams({
|
||||||
sessionId: submitted.sessionId,
|
sessionId: session.id,
|
||||||
authRequest: command.authRequestId,
|
authRequest: command.authRequestId,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (command.organization) {
|
if (command.organization || session.factors?.user?.organizationId) {
|
||||||
params.append("organization", command.organization);
|
params.append(
|
||||||
|
"organization",
|
||||||
|
command.organization ?? session.factors?.user?.organizationId,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return redirect(`/login?` + params);
|
return { nextStep: `/login?${params}` };
|
||||||
}
|
}
|
||||||
|
|
||||||
// without OIDC flow
|
// without OIDC flow
|
||||||
const params = new URLSearchParams(
|
const params = new URLSearchParams(
|
||||||
command.authRequestId
|
command.authRequestId
|
||||||
? {
|
? {
|
||||||
loginName: submitted.factors.user.loginName,
|
loginName: session.factors.user.loginName,
|
||||||
authRequestId: command.authRequestId,
|
authRequestId: command.authRequestId,
|
||||||
}
|
}
|
||||||
: {
|
: {
|
||||||
loginName: submitted.factors.user.loginName,
|
loginName: session.factors.user.loginName,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
if (command.organization) {
|
if (command.organization || session.factors?.user?.organizationId) {
|
||||||
params.append("organization", command.organization);
|
params.append(
|
||||||
|
"organization",
|
||||||
|
command.organization ?? session.factors?.user?.organizationId,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return redirect(`/signedin?` + params);
|
return redirect(`/signedin?` + params);
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ import {
|
|||||||
import { deleteSession, listAuthenticationMethodTypes } from "@/lib/zitadel";
|
import { deleteSession, listAuthenticationMethodTypes } from "@/lib/zitadel";
|
||||||
import { RequestChallenges } from "@zitadel/proto/zitadel/session/v2/challenge_pb";
|
import { RequestChallenges } from "@zitadel/proto/zitadel/session/v2/challenge_pb";
|
||||||
import { Checks } from "@zitadel/proto/zitadel/session/v2/session_service_pb";
|
import { Checks } from "@zitadel/proto/zitadel/session/v2/session_service_pb";
|
||||||
import { headers } from "next/headers";
|
|
||||||
import {
|
import {
|
||||||
getMostRecentSessionCookie,
|
getMostRecentSessionCookie,
|
||||||
getSessionCookieById,
|
getSessionCookieById,
|
||||||
@@ -68,7 +67,7 @@ export async function updateSession(options: UpdateSessionCommand) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// TODO remove ports from host header for URL with port
|
// TODO remove ports from host header for URL with port
|
||||||
const host = "localhost"
|
const host = "localhost";
|
||||||
|
|
||||||
if (
|
if (
|
||||||
host &&
|
host &&
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
"build": "turbo run build",
|
"build": "turbo run build",
|
||||||
"test": "turbo run test",
|
"test": "turbo run test",
|
||||||
"start": "turbo run start",
|
"start": "turbo run start",
|
||||||
"start:built": "turbo run start:built",
|
"start:built": "turbo run start:built",
|
||||||
"test:unit": "turbo run test:unit -- --passWithNoTests",
|
"test:unit": "turbo run test:unit -- --passWithNoTests",
|
||||||
"test:integration": "turbo run test:integration",
|
"test:integration": "turbo run test:integration",
|
||||||
"test:acceptance": "pnpm exec playwright test",
|
"test:acceptance": "pnpm exec playwright test",
|
||||||
@@ -34,6 +34,8 @@
|
|||||||
"@types/node": "^22.9.0",
|
"@types/node": "^22.9.0",
|
||||||
"@vitejs/plugin-react": "^4.3.3",
|
"@vitejs/plugin-react": "^4.3.3",
|
||||||
"@zitadel/prettier-config": "workspace:*",
|
"@zitadel/prettier-config": "workspace:*",
|
||||||
|
"axios": "^1.7.7",
|
||||||
|
"dotenv": "^16.4.5",
|
||||||
"eslint": "8.57.1",
|
"eslint": "8.57.1",
|
||||||
"eslint-config-zitadel": "workspace:*",
|
"eslint-config-zitadel": "workspace:*",
|
||||||
"prettier": "^3.2.5",
|
"prettier": "^3.2.5",
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import {defineConfig, devices} from "@playwright/test";
|
import { defineConfig, devices } from "@playwright/test";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Read environment variables from file.
|
* Read environment variables from file.
|
||||||
@@ -12,33 +12,33 @@ import {defineConfig, devices} from "@playwright/test";
|
|||||||
* See https://playwright.dev/docs/test-configuration.
|
* See https://playwright.dev/docs/test-configuration.
|
||||||
*/
|
*/
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
testDir: "./acceptance/tests",
|
testDir: "./acceptance/tests",
|
||||||
/* Run tests in files in parallel */
|
/* Run tests in files in parallel */
|
||||||
fullyParallel: true,
|
fullyParallel: true,
|
||||||
/* Fail the build on CI if you accidentally left test.only in the source code. */
|
/* Fail the build on CI if you accidentally left test.only in the source code. */
|
||||||
forbidOnly: !!process.env.CI,
|
forbidOnly: !!process.env.CI,
|
||||||
/* Retry on CI only */
|
/* Retry on CI only */
|
||||||
retries: process.env.CI ? 2 : 0,
|
retries: process.env.CI ? 2 : 0,
|
||||||
/* Opt out of parallel tests on CI. */
|
/* Opt out of parallel tests on CI. */
|
||||||
workers: process.env.CI ? 1 : undefined,
|
workers: process.env.CI ? 1 : undefined,
|
||||||
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
|
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
|
||||||
reporter: "html",
|
reporter: "html",
|
||||||
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
|
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
|
||||||
use: {
|
use: {
|
||||||
/* Base URL to use in actions like `await page.goto('/')`. */
|
/* Base URL to use in actions like `await page.goto('/')`. */
|
||||||
baseURL: "http://localhost:3000",
|
baseURL: "http://localhost:3000",
|
||||||
|
|
||||||
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
|
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
|
||||||
trace: "on-first-retry",
|
trace: "on-first-retry",
|
||||||
|
},
|
||||||
|
|
||||||
|
/* Configure projects for major browsers */
|
||||||
|
projects: [
|
||||||
|
{
|
||||||
|
name: "chromium",
|
||||||
|
use: { ...devices["Desktop Chrome"] },
|
||||||
},
|
},
|
||||||
|
/*
|
||||||
/* Configure projects for major browsers */
|
|
||||||
projects: [
|
|
||||||
{
|
|
||||||
name: "chromium",
|
|
||||||
use: {...devices["Desktop Chrome"]},
|
|
||||||
},
|
|
||||||
/*
|
|
||||||
{
|
{
|
||||||
name: "firefox",
|
name: "firefox",
|
||||||
use: { ...devices["Desktop Firefox"] },
|
use: { ...devices["Desktop Firefox"] },
|
||||||
@@ -50,32 +50,32 @@ export default defineConfig({
|
|||||||
},
|
},
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* Test against mobile viewports. */
|
/* Test against mobile viewports. */
|
||||||
// {
|
// {
|
||||||
// name: 'Mobile Chrome',
|
// name: 'Mobile Chrome',
|
||||||
// use: { ...devices['Pixel 5'] },
|
// use: { ...devices['Pixel 5'] },
|
||||||
// },
|
// },
|
||||||
// {
|
// {
|
||||||
// name: 'Mobile Safari',
|
// name: 'Mobile Safari',
|
||||||
// use: { ...devices['iPhone 12'] },
|
// use: { ...devices['iPhone 12'] },
|
||||||
// },
|
// },
|
||||||
|
|
||||||
/* Test against branded browsers. */
|
/* Test against branded browsers. */
|
||||||
// {
|
// {
|
||||||
// name: 'Microsoft Edge',
|
// name: 'Microsoft Edge',
|
||||||
// use: { ...devices['Desktop Edge'], channel: 'msedge' },
|
// use: { ...devices['Desktop Edge'], channel: 'msedge' },
|
||||||
// },
|
// },
|
||||||
// {
|
// {
|
||||||
// name: 'Google Chrome',
|
// name: 'Google Chrome',
|
||||||
// use: { ...devices['Desktop Chrome'], channel: 'chrome' },
|
// use: { ...devices['Desktop Chrome'], channel: 'chrome' },
|
||||||
// },
|
// },
|
||||||
],
|
],
|
||||||
|
|
||||||
/* Run local dev server before starting the tests */
|
/* Run local dev server before starting the tests */
|
||||||
webServer: {
|
webServer: {
|
||||||
command: "pnpm start:built",
|
command: "pnpm start:built",
|
||||||
url: "http://127.0.0.1:3000",
|
url: "http://127.0.0.1:3000",
|
||||||
reuseExistingServer: !process.env.CI,
|
reuseExistingServer: !process.env.CI,
|
||||||
timeout: 5 * 60_000,
|
timeout: 5 * 60_000,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
56
pnpm-lock.yaml
generated
56
pnpm-lock.yaml
generated
@@ -26,6 +26,12 @@ importers:
|
|||||||
'@zitadel/prettier-config':
|
'@zitadel/prettier-config':
|
||||||
specifier: workspace:*
|
specifier: workspace:*
|
||||||
version: link:packages/zitadel-prettier-config
|
version: link:packages/zitadel-prettier-config
|
||||||
|
axios:
|
||||||
|
specifier: ^1.7.7
|
||||||
|
version: 1.7.7
|
||||||
|
dotenv:
|
||||||
|
specifier: ^16.4.5
|
||||||
|
version: 16.4.5
|
||||||
eslint:
|
eslint:
|
||||||
specifier: 8.57.1
|
specifier: 8.57.1
|
||||||
version: 8.57.1
|
version: 8.57.1
|
||||||
@@ -2071,6 +2077,10 @@ packages:
|
|||||||
resolution: {integrity: sha512-7GO6HghkA5fYG9TYnNxi14/7K9f5occMlp3zXAuSxn7CKCxt9xbNWG7yF8hTCSUchlfWSe3uLmlPfigevRItzQ==}
|
resolution: {integrity: sha512-7GO6HghkA5fYG9TYnNxi14/7K9f5occMlp3zXAuSxn7CKCxt9xbNWG7yF8hTCSUchlfWSe3uLmlPfigevRItzQ==}
|
||||||
engines: {node: '>=12'}
|
engines: {node: '>=12'}
|
||||||
|
|
||||||
|
dotenv@16.4.5:
|
||||||
|
resolution: {integrity: sha512-ZmdL2rui+eB2YwhsWzjInR8LldtZHGDoQ1ugH85ppHKwpUHL7j7rN0Ti9NCnGiQbhaZ11FpR+7ao1dNsmduNUg==}
|
||||||
|
engines: {node: '>=12'}
|
||||||
|
|
||||||
dprint-node@1.0.8:
|
dprint-node@1.0.8:
|
||||||
resolution: {integrity: sha512-iVKnUtYfGrYcW1ZAlfR/F59cUVL8QIhWoBJoSjkkdua/dkWIgjZfiLMeTjiB06X0ZLkQ0M2C1VbUj/CxkIf1zg==}
|
resolution: {integrity: sha512-iVKnUtYfGrYcW1ZAlfR/F59cUVL8QIhWoBJoSjkkdua/dkWIgjZfiLMeTjiB06X0ZLkQ0M2C1VbUj/CxkIf1zg==}
|
||||||
|
|
||||||
@@ -4623,7 +4633,7 @@ snapshots:
|
|||||||
'@babel/traverse': 7.25.9
|
'@babel/traverse': 7.25.9
|
||||||
'@babel/types': 7.26.0
|
'@babel/types': 7.26.0
|
||||||
convert-source-map: 2.0.0
|
convert-source-map: 2.0.0
|
||||||
debug: 4.3.7(supports-color@5.5.0)
|
debug: 4.3.7
|
||||||
gensync: 1.0.0-beta.2
|
gensync: 1.0.0-beta.2
|
||||||
json5: 2.2.3
|
json5: 2.2.3
|
||||||
semver: 6.3.1
|
semver: 6.3.1
|
||||||
@@ -4710,7 +4720,7 @@ snapshots:
|
|||||||
'@babel/parser': 7.26.2
|
'@babel/parser': 7.26.2
|
||||||
'@babel/template': 7.25.9
|
'@babel/template': 7.25.9
|
||||||
'@babel/types': 7.26.0
|
'@babel/types': 7.26.0
|
||||||
debug: 4.3.7(supports-color@5.5.0)
|
debug: 4.3.7
|
||||||
globals: 11.12.0
|
globals: 11.12.0
|
||||||
transitivePeerDependencies:
|
transitivePeerDependencies:
|
||||||
- supports-color
|
- supports-color
|
||||||
@@ -5100,7 +5110,7 @@ snapshots:
|
|||||||
'@eslint/eslintrc@2.1.4':
|
'@eslint/eslintrc@2.1.4':
|
||||||
dependencies:
|
dependencies:
|
||||||
ajv: 6.12.6
|
ajv: 6.12.6
|
||||||
debug: 4.3.7(supports-color@5.5.0)
|
debug: 4.3.7
|
||||||
espree: 9.6.1
|
espree: 9.6.1
|
||||||
globals: 13.24.0
|
globals: 13.24.0
|
||||||
ignore: 5.3.2
|
ignore: 5.3.2
|
||||||
@@ -5199,7 +5209,7 @@ snapshots:
|
|||||||
'@humanwhocodes/config-array@0.13.0':
|
'@humanwhocodes/config-array@0.13.0':
|
||||||
dependencies:
|
dependencies:
|
||||||
'@humanwhocodes/object-schema': 2.0.3
|
'@humanwhocodes/object-schema': 2.0.3
|
||||||
debug: 4.3.7(supports-color@5.5.0)
|
debug: 4.3.7
|
||||||
minimatch: 3.1.2
|
minimatch: 3.1.2
|
||||||
transitivePeerDependencies:
|
transitivePeerDependencies:
|
||||||
- supports-color
|
- supports-color
|
||||||
@@ -5746,7 +5756,7 @@ snapshots:
|
|||||||
|
|
||||||
agent-base@7.1.1:
|
agent-base@7.1.1:
|
||||||
dependencies:
|
dependencies:
|
||||||
debug: 4.3.7(supports-color@5.5.0)
|
debug: 4.3.7
|
||||||
transitivePeerDependencies:
|
transitivePeerDependencies:
|
||||||
- supports-color
|
- supports-color
|
||||||
|
|
||||||
@@ -5921,6 +5931,14 @@ snapshots:
|
|||||||
|
|
||||||
axe-core@4.10.0: {}
|
axe-core@4.10.0: {}
|
||||||
|
|
||||||
|
axios@1.7.7:
|
||||||
|
dependencies:
|
||||||
|
follow-redirects: 1.15.6
|
||||||
|
form-data: 4.0.0
|
||||||
|
proxy-from-env: 1.1.0
|
||||||
|
transitivePeerDependencies:
|
||||||
|
- debug
|
||||||
|
|
||||||
axios@1.7.7(debug@4.3.7):
|
axios@1.7.7(debug@4.3.7):
|
||||||
dependencies:
|
dependencies:
|
||||||
follow-redirects: 1.15.6(debug@4.3.7)
|
follow-redirects: 1.15.6(debug@4.3.7)
|
||||||
@@ -6267,6 +6285,10 @@ snapshots:
|
|||||||
dependencies:
|
dependencies:
|
||||||
ms: 2.1.2
|
ms: 2.1.2
|
||||||
|
|
||||||
|
debug@4.3.7:
|
||||||
|
dependencies:
|
||||||
|
ms: 2.1.3
|
||||||
|
|
||||||
debug@4.3.7(supports-color@5.5.0):
|
debug@4.3.7(supports-color@5.5.0):
|
||||||
dependencies:
|
dependencies:
|
||||||
ms: 2.1.3
|
ms: 2.1.3
|
||||||
@@ -6368,6 +6390,8 @@ snapshots:
|
|||||||
|
|
||||||
dotenv@16.0.3: {}
|
dotenv@16.0.3: {}
|
||||||
|
|
||||||
|
dotenv@16.4.5: {}
|
||||||
|
|
||||||
dprint-node@1.0.8:
|
dprint-node@1.0.8:
|
||||||
dependencies:
|
dependencies:
|
||||||
detect-libc: 1.0.3
|
detect-libc: 1.0.3
|
||||||
@@ -6619,7 +6643,7 @@ snapshots:
|
|||||||
debug: 4.3.7(supports-color@5.5.0)
|
debug: 4.3.7(supports-color@5.5.0)
|
||||||
enhanced-resolve: 5.17.1
|
enhanced-resolve: 5.17.1
|
||||||
eslint: 8.57.1
|
eslint: 8.57.1
|
||||||
eslint-module-utils: 2.8.2(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.6.3))(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.6.3(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.6.3))(eslint-import-resolver-node@0.3.9)(eslint-plugin-import@2.29.1)(eslint@8.57.1))(eslint@8.57.1)
|
eslint-module-utils: 2.8.2(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.6.3))(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.6.3)(eslint@8.57.1)
|
||||||
fast-glob: 3.3.2
|
fast-glob: 3.3.2
|
||||||
get-tsconfig: 4.8.0
|
get-tsconfig: 4.8.0
|
||||||
is-bun-module: 1.1.0
|
is-bun-module: 1.1.0
|
||||||
@@ -6632,7 +6656,7 @@ snapshots:
|
|||||||
- eslint-import-resolver-webpack
|
- eslint-import-resolver-webpack
|
||||||
- supports-color
|
- supports-color
|
||||||
|
|
||||||
eslint-module-utils@2.8.2(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.6.3))(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.6.3(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.6.3))(eslint-import-resolver-node@0.3.9)(eslint-plugin-import@2.29.1)(eslint@8.57.1))(eslint@8.57.1):
|
eslint-module-utils@2.8.2(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.6.3))(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.6.3)(eslint@8.57.1):
|
||||||
dependencies:
|
dependencies:
|
||||||
debug: 3.2.7(supports-color@8.1.1)
|
debug: 3.2.7(supports-color@8.1.1)
|
||||||
optionalDependencies:
|
optionalDependencies:
|
||||||
@@ -6653,7 +6677,7 @@ snapshots:
|
|||||||
doctrine: 2.1.0
|
doctrine: 2.1.0
|
||||||
eslint: 8.57.1
|
eslint: 8.57.1
|
||||||
eslint-import-resolver-node: 0.3.9
|
eslint-import-resolver-node: 0.3.9
|
||||||
eslint-module-utils: 2.8.2(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.6.3))(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.6.3(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.6.3))(eslint-import-resolver-node@0.3.9)(eslint-plugin-import@2.29.1)(eslint@8.57.1))(eslint@8.57.1)
|
eslint-module-utils: 2.8.2(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.6.3))(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.6.3)(eslint@8.57.1)
|
||||||
hasown: 2.0.2
|
hasown: 2.0.2
|
||||||
is-core-module: 2.15.1
|
is-core-module: 2.15.1
|
||||||
is-glob: 4.0.3
|
is-glob: 4.0.3
|
||||||
@@ -6741,7 +6765,7 @@ snapshots:
|
|||||||
ajv: 6.12.6
|
ajv: 6.12.6
|
||||||
chalk: 4.1.2
|
chalk: 4.1.2
|
||||||
cross-spawn: 7.0.3
|
cross-spawn: 7.0.3
|
||||||
debug: 4.3.7(supports-color@5.5.0)
|
debug: 4.3.7
|
||||||
doctrine: 3.0.0
|
doctrine: 3.0.0
|
||||||
escape-string-regexp: 4.0.0
|
escape-string-regexp: 4.0.0
|
||||||
eslint-scope: 7.2.2
|
eslint-scope: 7.2.2
|
||||||
@@ -6931,6 +6955,8 @@ snapshots:
|
|||||||
|
|
||||||
flatted@3.3.1: {}
|
flatted@3.3.1: {}
|
||||||
|
|
||||||
|
follow-redirects@1.15.6: {}
|
||||||
|
|
||||||
follow-redirects@1.15.6(debug@4.3.7):
|
follow-redirects@1.15.6(debug@4.3.7):
|
||||||
optionalDependencies:
|
optionalDependencies:
|
||||||
debug: 4.3.7(supports-color@5.5.0)
|
debug: 4.3.7(supports-color@5.5.0)
|
||||||
@@ -7165,7 +7191,7 @@ snapshots:
|
|||||||
http-proxy-agent@7.0.2:
|
http-proxy-agent@7.0.2:
|
||||||
dependencies:
|
dependencies:
|
||||||
agent-base: 7.1.1
|
agent-base: 7.1.1
|
||||||
debug: 4.3.7(supports-color@5.5.0)
|
debug: 4.3.7
|
||||||
transitivePeerDependencies:
|
transitivePeerDependencies:
|
||||||
- supports-color
|
- supports-color
|
||||||
|
|
||||||
@@ -7185,7 +7211,7 @@ snapshots:
|
|||||||
https-proxy-agent@7.0.5:
|
https-proxy-agent@7.0.5:
|
||||||
dependencies:
|
dependencies:
|
||||||
agent-base: 7.1.1
|
agent-base: 7.1.1
|
||||||
debug: 4.3.7(supports-color@5.5.0)
|
debug: 4.3.7
|
||||||
transitivePeerDependencies:
|
transitivePeerDependencies:
|
||||||
- supports-color
|
- supports-color
|
||||||
|
|
||||||
@@ -8709,7 +8735,7 @@ snapshots:
|
|||||||
cac: 6.7.14
|
cac: 6.7.14
|
||||||
chokidar: 4.0.1
|
chokidar: 4.0.1
|
||||||
consola: 3.2.3
|
consola: 3.2.3
|
||||||
debug: 4.3.7(supports-color@5.5.0)
|
debug: 4.3.7
|
||||||
esbuild: 0.24.0
|
esbuild: 0.24.0
|
||||||
joycon: 3.1.1
|
joycon: 3.1.1
|
||||||
picocolors: 1.1.1
|
picocolors: 1.1.1
|
||||||
@@ -8867,7 +8893,7 @@ snapshots:
|
|||||||
vite-node@2.1.4(@types/node@22.9.0)(sass@1.80.7):
|
vite-node@2.1.4(@types/node@22.9.0)(sass@1.80.7):
|
||||||
dependencies:
|
dependencies:
|
||||||
cac: 6.7.14
|
cac: 6.7.14
|
||||||
debug: 4.3.7(supports-color@5.5.0)
|
debug: 4.3.7
|
||||||
pathe: 1.1.2
|
pathe: 1.1.2
|
||||||
vite: 5.4.11(@types/node@22.9.0)(sass@1.80.7)
|
vite: 5.4.11(@types/node@22.9.0)(sass@1.80.7)
|
||||||
transitivePeerDependencies:
|
transitivePeerDependencies:
|
||||||
@@ -8883,7 +8909,7 @@ snapshots:
|
|||||||
|
|
||||||
vite-tsconfig-paths@5.1.2(typescript@5.6.3)(vite@5.4.11(@types/node@22.9.0)(sass@1.80.7)):
|
vite-tsconfig-paths@5.1.2(typescript@5.6.3)(vite@5.4.11(@types/node@22.9.0)(sass@1.80.7)):
|
||||||
dependencies:
|
dependencies:
|
||||||
debug: 4.3.7(supports-color@5.5.0)
|
debug: 4.3.7
|
||||||
globrex: 0.1.2
|
globrex: 0.1.2
|
||||||
tsconfck: 3.1.4(typescript@5.6.3)
|
tsconfck: 3.1.4(typescript@5.6.3)
|
||||||
optionalDependencies:
|
optionalDependencies:
|
||||||
@@ -8912,7 +8938,7 @@ snapshots:
|
|||||||
'@vitest/spy': 2.1.4
|
'@vitest/spy': 2.1.4
|
||||||
'@vitest/utils': 2.1.4
|
'@vitest/utils': 2.1.4
|
||||||
chai: 5.1.2
|
chai: 5.1.2
|
||||||
debug: 4.3.7(supports-color@5.5.0)
|
debug: 4.3.7
|
||||||
expect-type: 1.1.0
|
expect-type: 1.1.0
|
||||||
magic-string: 0.30.12
|
magic-string: 0.30.12
|
||||||
pathe: 1.1.2
|
pathe: 1.1.2
|
||||||
|
|||||||
Reference in New Issue
Block a user