mirror of
https://github.com/zitadel/zitadel.git
synced 2025-12-11 22:42:18 +00:00
Merge branch 'main' into acceptance-test-suite
This commit is contained in:
62
.github/workflows/test.yml
vendored
62
.github/workflows/test.yml
vendored
@@ -1,8 +1,39 @@
|
|||||||
name: Quality
|
name: Quality
|
||||||
|
|
||||||
on: pull_request
|
on:
|
||||||
|
pull_request:
|
||||||
|
schedule:
|
||||||
|
# Every morning at 6:00 AM CET
|
||||||
|
- cron: '0 4 * * *'
|
||||||
|
workflow_dispatch:
|
||||||
|
inputs:
|
||||||
|
target-env:
|
||||||
|
description: 'Zitadel target environment to run the acceptance tests against.'
|
||||||
|
required: true
|
||||||
|
type: choice
|
||||||
|
options:
|
||||||
|
- 'qa'
|
||||||
|
- 'prod'
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
matrix:
|
||||||
|
# If the workflow is triggered by a schedule event, only the acceptance tests run against QA and Prod.
|
||||||
|
name: Matrix
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
outputs:
|
||||||
|
matrix: ${{ steps.matrix.outputs.matrix }}
|
||||||
|
steps:
|
||||||
|
- name: Matrix
|
||||||
|
id: matrix
|
||||||
|
run: |
|
||||||
|
if [ -n "${{ github.event.schedule }}" ]; then
|
||||||
|
echo 'matrix=["test:acceptance:qa", "test:acceptance:prod"]' >> $GITHUB_OUTPUT
|
||||||
|
elif [ -n "${{ github.event.inputs.target-env }}" ]; then
|
||||||
|
echo 'matrix=["test:acceptance:${{ github.event.inputs.target-env }}"]' >> $GITHUB_OUTPUT
|
||||||
|
else
|
||||||
|
echo 'matrix=["format --check", "lint", "test:unit", "test:integration", "test:acceptance"]' >> $GITHUB_OUTPUT
|
||||||
|
fi
|
||||||
|
|
||||||
quality:
|
quality:
|
||||||
name: Ensure Quality
|
name: Ensure Quality
|
||||||
|
|
||||||
@@ -13,15 +44,13 @@ jobs:
|
|||||||
permissions:
|
permissions:
|
||||||
contents: "read"
|
contents: "read"
|
||||||
|
|
||||||
|
needs:
|
||||||
|
- matrix
|
||||||
|
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
command:
|
command: ${{ fromJson( needs.matrix.outputs.matrix ) }}
|
||||||
- format --check
|
|
||||||
- lint
|
|
||||||
- test:unit
|
|
||||||
- test:integration
|
|
||||||
- test:acceptance
|
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout Repo
|
- name: Checkout Repo
|
||||||
@@ -55,7 +84,7 @@ jobs:
|
|||||||
# We can cache the Playwright binary independently from the pnpm cache, because we install it separately.
|
# We can cache the Playwright binary independently from the pnpm cache, because we install it separately.
|
||||||
# After pnpm install --frozen-lockfile, we can get the version so we only have to download the binary once per version.
|
# After pnpm install --frozen-lockfile, we can get the version so we only have to download the binary once per version.
|
||||||
- run: echo "PLAYWRIGHT_VERSION=$(npx playwright --version | cut -d ' ' -f 2)" >> $GITHUB_ENV
|
- run: echo "PLAYWRIGHT_VERSION=$(npx playwright --version | cut -d ' ' -f 2)" >> $GITHUB_ENV
|
||||||
if: ${{ matrix.command == 'test:acceptance' }}
|
if: ${{ startsWith(matrix.command, 'test:acceptance') }}
|
||||||
|
|
||||||
- uses: actions/cache@v4.0.2
|
- uses: actions/cache@v4.0.2
|
||||||
name: Setup Playwright binary cache
|
name: Setup Playwright binary cache
|
||||||
@@ -65,11 +94,11 @@ jobs:
|
|||||||
key: ${{ runner.os }}-playwright-binary-${{ env.PLAYWRIGHT_VERSION }}
|
key: ${{ runner.os }}-playwright-binary-${{ env.PLAYWRIGHT_VERSION }}
|
||||||
restore-keys: |
|
restore-keys: |
|
||||||
${{ runner.os }}-playwright-binary-
|
${{ runner.os }}-playwright-binary-
|
||||||
if: ${{ matrix.command == 'test:acceptance' }}
|
if: ${{ startsWith(matrix.command, 'test:acceptance') }}
|
||||||
|
|
||||||
- name: Install Playwright Browsers
|
- name: Install Playwright Browsers
|
||||||
run: pnpm exec playwright install --with-deps
|
run: pnpm exec playwright install --with-deps
|
||||||
if: ${{ matrix.command == 'test:acceptance' && steps.playwright-cache.outputs.cache-hit != 'true' }}
|
if: ${{ startsWith(matrix.command, 'test:acceptance') && steps.playwright-cache.outputs.cache-hit != 'true' }}
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
- name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v3
|
uses: docker/setup-buildx-action@v3
|
||||||
@@ -79,10 +108,19 @@ jobs:
|
|||||||
run: ZITADEL_DEV_UID=root pnpm run-sink
|
run: ZITADEL_DEV_UID=root pnpm run-sink
|
||||||
if: ${{ matrix.command == 'test:acceptance' }}
|
if: ${{ matrix.command == 'test:acceptance' }}
|
||||||
|
|
||||||
|
- name: Create Cloud Env File
|
||||||
|
run: |
|
||||||
|
if [ "${{ matrix.command }}" == "test:acceptance:prod" ]; then
|
||||||
|
echo "${{ secrets.ENV_FILE_CONTENT_ACCEPTANCE_PROD }}" | tee apps/login/.env.local acceptance/tests/.env.local > /dev/null
|
||||||
|
else
|
||||||
|
echo "${{ secrets.ENV_FILE_CONTENT_ACCEPTANCE_QA }}" | tee apps/login/.env.local acceptance/tests/.env.local > /dev/null
|
||||||
|
fi
|
||||||
|
if: ${{ matrix.command == 'test:acceptance:qa' || matrix.command == 'test:acceptance:prod' }}
|
||||||
|
|
||||||
- name: Create Production Build
|
- name: Create Production Build
|
||||||
run: pnpm build
|
run: pnpm build
|
||||||
if: ${{ matrix.command == 'test:acceptance' }}
|
if: ${{ startsWith(matrix.command, 'test:acceptance') }}
|
||||||
|
|
||||||
- name: Check
|
- name: Check
|
||||||
id: check
|
id: check
|
||||||
run: pnpm ${{ matrix.command }}
|
run: pnpm ${{ contains(matrix.command, 'test:acceptance') && 'test:acceptance' || matrix.command }}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
services:
|
services:
|
||||||
zitadel:
|
zitadel:
|
||||||
user: "${ZITADEL_DEV_UID}"
|
user: "${ZITADEL_DEV_UID}"
|
||||||
image: ghcr.io/zitadel/zitadel:v2.65.0
|
image: "${ZITADEL_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"
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ export function LoginOTP({
|
|||||||
value: host
|
value: host
|
||||||
? {
|
? {
|
||||||
urlTemplate:
|
urlTemplate:
|
||||||
`${host.includes("localhost") ? "http://" : "https://"}${host}/otp/method=${method}?code={{.Code}}&userId={{.UserID}}&sessionId={{.SessionID}}&organization={{.OrgID}}` +
|
`${host.includes("localhost") ? "http://" : "https://"}${host}/otp/method=${method}?code={{.Code}}&userId={{.UserID}}&sessionId={{.SessionID}}` +
|
||||||
(authRequestId ? `&authRequestId=${authRequestId}` : ""),
|
(authRequestId ? `&authRequestId=${authRequestId}` : ""),
|
||||||
}
|
}
|
||||||
: {},
|
: {},
|
||||||
@@ -107,14 +107,19 @@ export function LoginOTP({
|
|||||||
challenges,
|
challenges,
|
||||||
authRequestId,
|
authRequestId,
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch(() => {
|
||||||
setError(error.message ?? "Could not request OTP challenge");
|
setError("Could not request OTP challenge");
|
||||||
return;
|
return;
|
||||||
})
|
})
|
||||||
.finally(() => {
|
.finally(() => {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (response && "error" in response && response.error) {
|
||||||
|
setError(response.error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -167,6 +172,11 @@ export function LoginOTP({
|
|||||||
setLoading(false);
|
setLoading(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (response && "error" in response && response.error) {
|
||||||
|
setError(response.error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -110,6 +110,11 @@ export function LoginPasskey({
|
|||||||
setLoading(false);
|
setLoading(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (session && "error" in session && session.error) {
|
||||||
|
setError(session.error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
return session;
|
return session;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -132,6 +137,11 @@ export function LoginPasskey({
|
|||||||
setLoading(false);
|
setLoading(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (response && "error" in response && response.error) {
|
||||||
|
setError(response.error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -142,7 +142,7 @@ export async function removeSessionFromCookie<T>(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getMostRecentSessionCookie<T>(): Promise<any> {
|
export async function getMostRecentSessionCookie<T>(): Promise<Cookie> {
|
||||||
const cookiesList = await cookies();
|
const cookiesList = await cookies();
|
||||||
const stringifiedCookie = cookiesList.get("sessions");
|
const stringifiedCookie = cookiesList.get("sessions");
|
||||||
|
|
||||||
|
|||||||
@@ -132,21 +132,23 @@ export async function updateSession(options: UpdateSessionCommand) {
|
|||||||
challenges,
|
challenges,
|
||||||
} = options;
|
} = options;
|
||||||
const recentSession = sessionId
|
const recentSession = sessionId
|
||||||
? await getSessionCookieById({ sessionId }).catch((error) => {
|
? await getSessionCookieById({ sessionId })
|
||||||
return Promise.reject(error);
|
|
||||||
})
|
|
||||||
: loginName
|
: loginName
|
||||||
? await getSessionCookieByLoginName({ loginName, organization }).catch(
|
? await getSessionCookieByLoginName({ loginName, organization })
|
||||||
(error) => {
|
: await getMostRecentSessionCookie();
|
||||||
return Promise.reject(error);
|
|
||||||
},
|
if (!recentSession) {
|
||||||
)
|
return {
|
||||||
: await getMostRecentSessionCookie().catch((error) => {
|
error: "Could not find session",
|
||||||
return Promise.reject(error);
|
};
|
||||||
});
|
}
|
||||||
|
|
||||||
const host = (await headers()).get("host");
|
const host = (await headers()).get("host");
|
||||||
|
|
||||||
|
if (!host) {
|
||||||
|
return { error: "Could not get host" };
|
||||||
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
host &&
|
host &&
|
||||||
challenges &&
|
challenges &&
|
||||||
@@ -174,6 +176,10 @@ export async function updateSession(options: UpdateSessionCommand) {
|
|||||||
lifetime,
|
lifetime,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (!session) {
|
||||||
|
return { error: "Could not update session" };
|
||||||
|
}
|
||||||
|
|
||||||
// if password, check if user has MFA methods
|
// if password, check if user has MFA methods
|
||||||
let authMethods;
|
let authMethods;
|
||||||
if (checks && checks.password && session.factors?.user?.id) {
|
if (checks && checks.password && session.factors?.user?.id) {
|
||||||
|
|||||||
@@ -72,6 +72,7 @@ export default defineConfig({
|
|||||||
],
|
],
|
||||||
|
|
||||||
/* 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",
|
||||||
|
|||||||
Reference in New Issue
Block a user