Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(acceptance): username password #227

Merged
merged 43 commits into from
Oct 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
4772861
use postgres
eliobischof Oct 16, 2024
73a385c
setup playwright
eliobischof Oct 16, 2024
8c6d957
pipeline
eliobischof Oct 16, 2024
fe289e3
build and test
eliobischof Oct 16, 2024
ac7cbe5
test on pr
eliobischof Oct 16, 2024
5be0ed4
rename pipeline workflows
eliobischof Oct 16, 2024
2fa16d5
generate
eliobischof Oct 16, 2024
653b499
timeout
eliobischof Oct 16, 2024
f1b756b
submit username and password
eliobischof Oct 16, 2024
c5620e6
concurrent setup
eliobischof Oct 16, 2024
576cdcc
fail earlier
eliobischof Oct 16, 2024
ca0e551
kill -0
eliobischof Oct 16, 2024
be84e94
build with env
eliobischof Oct 16, 2024
17e516a
compose to background
eliobischof Oct 16, 2024
3ff49c3
wait individually
eliobischof Oct 16, 2024
c413805
await setup
eliobischof Oct 16, 2024
b058b75
default uid
eliobischof Oct 16, 2024
77fb366
use current user
eliobischof Oct 16, 2024
76430e1
use root
eliobischof Oct 16, 2024
5969b14
runneradmin
eliobischof Oct 16, 2024
4cb1795
root
eliobischof Oct 16, 2024
cb8f071
simplify setup
eliobischof Oct 16, 2024
f7796e3
Merge branch 'main' into acceptance-test-suite
peintnermax Oct 17, 2024
1134b9c
develop against local zitadel
eliobischof Oct 17, 2024
6883497
Merge branch 'acceptance-test-suite' of github.com:zitadel/typescript…
eliobischof Oct 18, 2024
1ca16f9
run acceptance
eliobischof Oct 18, 2024
7b43cac
remove gh workflow
eliobischof Oct 18, 2024
e58e8c5
generate before build
eliobischof Oct 18, 2024
087e815
fix conditions
eliobischof Oct 18, 2024
90f13b2
build before start
eliobischof Oct 18, 2024
46fb2ea
remove workspace packages
eliobischof Oct 18, 2024
a45c841
Merge branch 'qa' into acceptance-test-suite
eliobischof Oct 18, 2024
083bf5a
clean dependencies
eliobischof Oct 18, 2024
8290a6b
no sudo
eliobischof Oct 18, 2024
3fc6118
keep dir
eliobischof Oct 18, 2024
7cde73f
fmt
eliobischof Oct 18, 2024
614bb5d
debug path
eliobischof Oct 18, 2024
edffb99
run zitadel as root
eliobischof Oct 18, 2024
0459bea
build
eliobischof Oct 18, 2024
bdfbd94
no prestart
eliobischof Oct 18, 2024
3ce1703
start already built
eliobischof Oct 18, 2024
cc53c44
update test
eliobischof Oct 18, 2024
bfd8a7c
fmt
eliobischof Oct 18, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 43 additions & 9 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ on: pull_request

jobs:
quality:
env:
ZITADEL_IMAGE: ghcr.io/zitadel/zitadel:v2.63.4
POSTGRES_IMAGE: postgres:17.0-alpine3.19

name: Ensure Quality

runs-on: ubuntu-latest
Expand All @@ -21,6 +25,7 @@ jobs:
- lint
- test:unit
- test:integration
- test:acceptance

steps:
- name: Checkout Repo
Expand All @@ -34,12 +39,6 @@ jobs:
- name: Setup pnpm
uses: pnpm/[email protected]

- uses: pnpm/[email protected]
name: Install pnpm
id: pnpm-install
with:
run_install: false

- name: Get pnpm store directory
id: pnpm-cache
shell: bash
Expand All @@ -54,17 +53,52 @@ jobs:
restore-keys: |
${{ runner.os }}-pnpm-store-

- name: Install Dependencies
run: CYPRESS_INSTALL_BINARY=0 pnpm install

- run: echo "CYPRESS_VERSION=$(pnpm list -r | grep cypress | cut -d ' ' -f 2)" >> $GITHUB_ENV
if: ${{ matrix.command == 'test:integration' }}

- uses: actions/[email protected]
name: Setup Cypress binary cache
with:
path: ~/.cache/Cypress
key: ${{ runner.os }}-cypress-binary-${{ hashFiles('**/pnpm-lock.yaml') }}
key: ${{ runner.os }}-cypress-binary-${{ env.CYPRESS_VERSION }}
restore-keys: |
${{ runner.os }}-cypress-binary-
if: ${{ matrix.command }} == "test:integration"
if: ${{ matrix.command == 'test:integration' }}

- name: Install Dependencies
- name: Install Cypress Browsers
run: pnpm install
if: ${{ matrix.command == 'test:integration' }}

- run: echo "PLAYWRIGHT_VERSION=$(npx playwright --version | cut -d ' ' -f 2)" >> $GITHUB_ENV
if: ${{ matrix.command == 'test:acceptance' }}

- uses: actions/[email protected]
name: Setup Playwright binary cache
with:
path: ~/.cache/ms-playwright
key: ${{ runner.os }}-playwright-binary-${{ env.PLAYWRIGHT_VERSION }}
restore-keys: |
${{ runner.os }}-playwright-binary-
if: ${{ matrix.command == 'test:acceptance' }}

- name: Install Playwright Browsers
run: pnpm exec playwright install --with-deps
if: ${{ matrix.command == 'test:acceptance' }}

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
if: ${{ matrix.command == 'test:acceptance' }}

- name: Run ZITADEL
run: ZITADEL_DEV_UID=root pnpm run-zitadel
if: ${{ matrix.command == 'test:acceptance' }}

- name: Install Playwright Browsers
run: pnpm build
if: ${{ matrix.command == 'test:acceptance' }}

- name: Check
id: check
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,7 @@ packages/zitadel-server/src/app/proto
.idea
.vercel
.env*.local
/test-results/
/playwright-report/
/blob-report/
/playwright/.cache/
51 changes: 38 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -178,32 +178,57 @@ To run the application make sure to install the dependencies with
pnpm install
```

then setup the environment for the login application which needs a `.env.local` in `/apps/login`.
Go to your instance and create a service user for the application having the `IAM_OWNER` manager role.
This user is required to have access to create users on your primary organization and reading policy data so it can be
restricted to your personal use case but we'll stick with `IAM_OWNER` for convenience. Create a PAT and copy the value to
paste it under the `ZITADEL_SERVICE_USER_TOKEN` key.
The file should look as follows:
then generate the GRPC stubs with

```
ZITADEL_API_URL=[yourinstanceurl]
ZITADEL_ORG_ID=[yourprimaryorg]
ZITADEL_SERVICE_USER_TOKEN=[yourserviceuserpersonalaccesstoken]
```sh
pnpm generate
```

then generate the GRPC stubs with
To run the application against a local ZITADEL instance, run the following command:

```sh
pnpm generate
pnpm run-zitadel
```

This sets up ZITADEL using docker compose and writes the configuration to the file `apps/login/.env.local`.

<details>
<summary>Alternatively, use another environment</summary>
You can develop against any ZITADEL instance in which you have sufficient rights to execute the following steps.
Just create or overwrite the file `apps/login/.env.local` yourself.
Add your instances base URL to the file at the key `ZITADEL_API_URL`.
Go to your instance and create a service user for the login application.
The login application creates users on your primary organization and reads policy data.
For the sake of simplicity, just make the service user an instance member with the role `IAM_OWNER`.
Create a PAT and copy it to the file `apps/login/.env.local` using the key `ZITADEL_SERVICE_USER_TOKEN`.
Also add the users ID to the file using the key `ZITADEL_SERVICE_USER_ID`.

The file should look similar to this:

```
ZITADEL_API_URL=https://zitadel-tlx3du.us1.zitadel.cloud
ZITADEL_SERVICE_USER_ID=289106423158521850
ZITADEL_SERVICE_USER_TOKEN=1S6w48thfWFI2klgfwkCnhXJLf9FQ457E-_3H74ePQxfO3Af0Tm4V5Xi-ji7urIl_xbn-Rk
```

and then run it with
</details>

Start the login application in dev mode:

```sh
pnpm dev
```

Open the login application with your favorite browser at `localhost:3000`.
Change the source code and see the changes live in your browser.

Make sure the application still behaves as expected by running all tests

```sh
pnpm test
```

To satisfy your unique workflow requirements, check out the package.json in the root directory for more detailed scripts.

### Deploy to Vercel

Expand Down
1 change: 0 additions & 1 deletion acceptance/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
FROM golang:1.19-alpine
RUN apk add curl jq
RUN go install github.com/zitadel/[email protected]
COPY setup.sh /setup.sh
RUN chmod +x /setup.sh
ENTRYPOINT [ "/setup.sh" ]
35 changes: 19 additions & 16 deletions acceptance/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
version: "3.8"

services:
zitadel:
user: "${ZITADEL_DEV_UID}"
Expand All @@ -8,32 +6,37 @@ services:
ports:
- "8080:8080"
volumes:
- ./machinekey:/machinekey
- ./pat:/pat
- ./zitadel.yaml:/zitadel.yaml
depends_on:
db:
condition: "service_healthy"

db:
image: "cockroachdb/cockroach:v22.2.2"
command: "start-single-node --insecure --http-addr :9090"
restart: 'always'
image: "${POSTGRES_IMAGE:-postgres:latest}"
environment:
- POSTGRES_USER=zitadel
- PGUSER=zitadel
- POSTGRES_DB=zitadel
- POSTGRES_HOST_AUTH_METHOD=trust
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:
test: ["CMD", "curl", "-f", "http://localhost:9090/health?ready=1"]
interval: "10s"
timeout: "30s"
test: ["CMD-SHELL", "pg_isready"]
interval: '10s'
timeout: '30s'
retries: 5
start_period: "20s"
start_period: '20s'
ports:
- "26257:26257"
- "9090:9090"
- 5432:5432

wait_for_zitadel:
image: curlimages/curl:8.00.1
command:
[
"/bin/sh",
"-c",
"i=0; while ! curl http://zitadel:8080/debug/ready && [ $$i -lt 30 ]; do sleep 1; i=$$((i+1)); done; [ $$i -eq 30 ] && exit 1 || exit 0",
"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:
- zitadel
Expand All @@ -43,11 +46,11 @@ services:
container_name: setup
build: .
environment:
KEY: /key/zitadel-admin-sa.json
SERVICE: http://zitadel:8080
WRITE_ENVIRONMENT_FILE: /apps/login/.env.acceptance
PAT_FILE: /pat/zitadel-admin-sa.pat
ZITADEL_API_INTERNAL_URL: http://zitadel:8080
WRITE_ENVIRONMENT_FILE: /apps/login/.env.local
volumes:
- "./machinekey:/key"
- "./pat:/pat"
- "../apps/login:/apps/login"
depends_on:
wait_for_zitadel:
Expand Down
1 change: 0 additions & 1 deletion acceptance/machinekey/.gitignore

This file was deleted.

Empty file removed acceptance/machinekey/.kitkeep
Empty file.
2 changes: 2 additions & 0 deletions acceptance/pat/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*
!.gitkeep
File renamed without changes.
Loading