diff --git a/.github/workflows/playwright-on-push.yml b/.github/workflows/playwright-on-push.yml index b43a4f19..2f6de864 100644 --- a/.github/workflows/playwright-on-push.yml +++ b/.github/workflows/playwright-on-push.yml @@ -20,10 +20,6 @@ concurrency: env: BASE_URL: https://localhost:8080 - # Master password seeded into configuration.json for the deSEC test. Seeding the config - # makes AIO consider itself already installed, so /setup no longer generates/shows a - # password; the seed helper writes this one and the test logs in with it directly. - AIO_TEST_PASSWORD: correct horse battery staple aircraft jobs: test: @@ -42,67 +38,14 @@ jobs: - name: Run Playwright tests for backup restore run: ./php/tests/run.sh ./php/tests/tests/restore-instance.spec.js - - name: Start deSEC mock and fresh development server - run: | - # The deSEC flow must not touch the real deSEC API, so point it at a local mock. - node php/tests/desec-mock.mjs 8090 > desec-mock.log 2>&1 & - echo $! > desec-mock.pid - docker rm --force nextcloud-aio-{mastercontainer,apache,notify-push,nextcloud,redis,database,domaincheck,whiteboard,imaginary,talk,collabora,borgbackup,caddy,dnsmasq} || true - docker volume rm nextcloud_aio_{mastercontainer,apache,database,database_dump,nextcloud,nextcloud_data,redis,backup_cache,elasticsearch} || true - # The deSEC registration entry point renders regardless of SKIP_DOMAIN_VALIDATION, - # and the deSEC flow sets the domain with validation skipped internally, so no - # SKIP_DOMAIN_VALIDATION override is needed here. - docker run \ - -d \ - --init \ - --name nextcloud-aio-mastercontainer \ - --restart always \ - --publish 8080:8080 \ - --add-host host.docker.internal:host-gateway \ - --volume nextcloud_aio_mastercontainer:/mnt/docker-aio-config \ - --volume ./php:/var/www/docker-aio/php \ - --volume ./community-containers:/var/www/docker-aio/community-containers \ - --volume ./Containers/mastercontainer/internal.Caddyfile:/internal.Caddyfile \ - --volume ./Containers/mastercontainer/headers.Caddyfile:/headers.Caddyfile \ - --volume ./Containers/mastercontainer/start.sh:/start.sh \ - --volume /var/run/docker.sock:/var/run/docker.sock:ro \ - --env APACHE_PORT=11000 \ - ghcr.io/nextcloud-releases/all-in-one:develop - echo Waiting for 10 seconds for the development container to start ... - sleep 10 - # Point the running interface at the deSEC mock via configuration.json (config-only, - # no env override). The container runs PHP and has ./php mounted, so use the helper. - # AIO_TEST_PASSWORD is forwarded so the helper can seed the master password too. - docker exec --env AIO_TEST_PASSWORD="$AIO_TEST_PASSWORD" nextcloud-aio-mastercontainer \ - php /var/www/docker-aio/php/tests/seed-desec-mock-config.php \ - http://host.docker.internal:8090/api/v1 http://host.docker.internal:8090/update + - name: Run Playwright tests for desec registration + run: ./php/tests/run.sh ./php/tests/tests/desec-register.spec.js - - name: Run Playwright tests for deSEC domain registration - run: | - export DEBUG=pw:api - export DESEC_MOCK_URL=http://localhost:8090 + - name: Run Playwright tests for desec with existing account + run: ./php/tests/run.sh ./php/tests/tests/desec-existing.spec.js - # Each deSEC scenario ends by registering a domain, which persists in - # configuration.json and would hide the registration UI for the next scenario. - # Run each spec as its own step and re-seed (reset the deSEC state) in between. - reseed() { - docker exec --env AIO_TEST_PASSWORD="$AIO_TEST_PASSWORD" nextcloud-aio-mastercontainer \ - php /var/www/docker-aio/php/tests/seed-desec-mock-config.php \ - http://host.docker.internal:8090/api/v1 http://host.docker.internal:8090/update - } - dump_logs() { - docker logs nextcloud-aio-mastercontainer - echo "--- deSEC mock log ---" - cat "$GITHUB_WORKSPACE/desec-mock.log" || true - } - - cd php/tests - if ! npx playwright test tests/desec-register.spec.js; then dump_logs; exit 1; fi - reseed - if ! npx playwright test tests/desec-existing.spec.js; then dump_logs; exit 1; fi - reseed - if ! npx playwright test tests/desec-existing-slug.spec.js; then dump_logs; exit 1; fi - kill "$(cat "$GITHUB_WORKSPACE/desec-mock.pid")" || true + - name: Run Playwright tests for desec with existing slug + run: ./php/tests/run.sh ./php/tests/tests/desec-existing-slug.spec.js - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 if: ${{ !cancelled() }} diff --git a/.github/workflows/playwright-on-workflow-dispatch.yml b/.github/workflows/playwright-on-workflow-dispatch.yml index a9419889..e6e48c7f 100644 --- a/.github/workflows/playwright-on-workflow-dispatch.yml +++ b/.github/workflows/playwright-on-workflow-dispatch.yml @@ -29,64 +29,20 @@ jobs: TEST_CODE_FROM_IMAGE: yes run: ./php/tests/run.sh ./php/tests/tests/restore-instance.spec.js - - name: Start deSEC mock and fresh development server - run: | - # The deSEC flow must not touch the real deSEC API, so point it at a local mock. - node php/tests/desec-mock.mjs 8090 > desec-mock.log 2>&1 & - echo $! > desec-mock.pid - docker rm --force nextcloud-aio-{mastercontainer,apache,notify-push,nextcloud,redis,database,domaincheck,whiteboard,imaginary,talk,collabora,borgbackup,caddy,dnsmasq} || true - docker volume rm nextcloud_aio_{mastercontainer,apache,database,database_dump,nextcloud,nextcloud_data,redis,backup_cache,elasticsearch} || true - # The deSEC registration entry point renders regardless of SKIP_DOMAIN_VALIDATION, - # and the deSEC flow sets the domain with validation skipped internally, so no - # SKIP_DOMAIN_VALIDATION override is needed here. - # Mount ./php/tests so the locally-checked-out DesecManager is exercised. - docker run \ - -d \ - --init \ - --name nextcloud-aio-mastercontainer \ - --restart always \ - --publish 8080:8080 \ - --add-host host.docker.internal:host-gateway \ - --volume nextcloud_aio_mastercontainer:/mnt/docker-aio-config \ - --volume ./php/tests:/var/www/docker-aio/php/tests \ - --volume /var/run/docker.sock:/var/run/docker.sock:ro \ - --env APACHE_PORT=11000 \ - ghcr.io/nextcloud-releases/all-in-one:develop - echo Waiting for 10 seconds for the development container to start ... - sleep 10 - # Point the running interface at the deSEC mock via configuration.json (config-only, - # no env override). The container runs PHP and has ./php mounted, so use the helper. - # AIO_TEST_PASSWORD is forwarded so the helper can seed the master password too. - docker exec --env AIO_TEST_PASSWORD="$AIO_TEST_PASSWORD" nextcloud-aio-mastercontainer \ - php /var/www/docker-aio/php/tests/seed-desec-mock-config.php \ - http://host.docker.internal:8090/api/v1 http://host.docker.internal:8090/update + - name: Run Playwright tests for desec registration + env: + TEST_CODE_FROM_IMAGE: yes + run: ./php/tests/run.sh ./php/tests/tests/desec-register.spec.js - - name: Run Playwright tests for deSEC domain registration - run: | - export DEBUG=pw:api - export DESEC_MOCK_URL=http://localhost:8090 + - name: Run Playwright tests for desec with existing account + env: + TEST_CODE_FROM_IMAGE: yes + run: ./php/tests/run.sh ./php/tests/tests/desec-existing.spec.js - # Each deSEC scenario ends by registering a domain, which persists in - # configuration.json and would hide the registration UI for the next scenario. - # Run each spec as its own step and re-seed (reset the deSEC state) in between. - reseed() { - docker exec --env AIO_TEST_PASSWORD="$AIO_TEST_PASSWORD" nextcloud-aio-mastercontainer \ - php /var/www/docker-aio/php/tests/seed-desec-mock-config.php \ - http://host.docker.internal:8090/api/v1 http://host.docker.internal:8090/update - } - dump_logs() { - docker logs nextcloud-aio-mastercontainer - echo "--- deSEC mock log ---" - cat "$GITHUB_WORKSPACE/desec-mock.log" || true - } - - cd php/tests - if ! npx playwright test tests/desec-register.spec.js; then dump_logs; exit 1; fi - reseed - if ! npx playwright test tests/desec-existing.spec.js; then dump_logs; exit 1; fi - reseed - if ! npx playwright test tests/desec-existing-slug.spec.js; then dump_logs; exit 1; fi - kill "$(cat "$GITHUB_WORKSPACE/desec-mock.pid")" || true + - name: Run Playwright tests for desec with existing slug + env: + TEST_CODE_FROM_IMAGE: yes + run: ./php/tests/run.sh ./php/tests/tests/desec-existing-slug.spec.js - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 if: ${{ !cancelled() }} diff --git a/php/tests/compose.yaml b/php/tests/compose.yaml index 4844bb0c..73de8e0f 100644 --- a/php/tests/compose.yaml +++ b/php/tests/compose.yaml @@ -34,6 +34,8 @@ services: environment: SKIP_DOMAIN_VALIDATION: ${SKIP_DOMAIN_VALIDATION-true} APACHE_PORT: 11000 + TESTING___DESEC_API_BASE: http://desec-mock:8090/api/v1 + TESTING___DESEC_UPDATE_URL: http://desec-mock:8090/update entrypoint: bash /start.sh app-code-from-image: @@ -56,6 +58,13 @@ services: profiles: - local-code + desec-mock: + image: docker.io/library/node:latest + volumes: + - ..:/app/php + working_dir: /app + command: node php/tests/desec-mock.mjs 8090 2>&1 + test-runner-base: image: mcr.microsoft.com/playwright:v1.56.1 volumes: @@ -65,10 +74,14 @@ services: - '9323:9323' # to view test reports profiles: - none + depends_on: + desec-mock: + condition: service_started environment: BASE_URL: "https://nextcloud-aio-mastercontainer:8080" DEBUG: "pw:api" CI: "true" + DESEC_MOCK_URL: "http://desec-mock:8090" command: |- bash -c " cd tests diff --git a/php/tests/run.sh b/php/tests/run.sh index 152e7d46..2481ce1f 100755 --- a/php/tests/run.sh +++ b/php/tests/run.sh @@ -68,4 +68,10 @@ else sleep 1 SKIP_DOMAIN_VALIDATION=false run_tests tests/restore-instance.spec.js + sleep 1 + run_tests tests/desec-register.spec.js + sleep 1 + run_tests tests/desec-existing.spec.js + sleep 1 + run_tests tests/desec-existing-slug.spec.js fi