Skip to content

Feat/fe testing infrastructure#144

Open
romanetar wants to merge 7 commits into
feat/mfa---login-ui-flowfrom
feat/fe-testing-infrastructure
Open

Feat/fe testing infrastructure#144
romanetar wants to merge 7 commits into
feat/mfa---login-ui-flowfrom
feat/fe-testing-infrastructure

Conversation

@romanetar

Copy link
Copy Markdown
Contributor

@coderabbitai

coderabbitai Bot commented Jun 30, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 5085df8f-d38a-41b4-ac2a-f4b849c1e1ef

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/fe-testing-infrastructure

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

Copy link
Copy Markdown

📘 OpenAPI / Swagger preview

➡️ https://OpenStackweb.github.io/openstackid/openapi/pr-144/

This page is automatically updated on each push to this PR.

@romanetar
romanetar force-pushed the feat/fe-testing-infrastructure branch from 7acd03d to deb8d3c Compare June 30, 2026 16:29
@github-actions

Copy link
Copy Markdown

📘 OpenAPI / Swagger preview

➡️ https://OpenStackweb.github.io/openstackid/openapi/pr-144/

This page is automatically updated on each push to this PR.

@romanetar
romanetar force-pushed the feat/fe-testing-infrastructure branch from deb8d3c to 94943cf Compare June 30, 2026 17:48
@github-actions

Copy link
Copy Markdown

📘 OpenAPI / Swagger preview

➡️ https://OpenStackweb.github.io/openstackid/openapi/pr-144/

This page is automatically updated on each push to this PR.

@romanetar
romanetar force-pushed the feat/fe-testing-infrastructure branch from 94943cf to 3b111f5 Compare June 30, 2026 17:54
@github-actions

Copy link
Copy Markdown

📘 OpenAPI / Swagger preview

➡️ https://OpenStackweb.github.io/openstackid/openapi/pr-144/

This page is automatically updated on each push to this PR.

@romanetar
romanetar requested a review from smarcet June 30, 2026 18:00
@github-actions

Copy link
Copy Markdown

📘 OpenAPI / Swagger preview

➡️ https://OpenStackweb.github.io/openstackid/openapi/pr-144/

This page is automatically updated on each push to this PR.

Comment thread .github/workflows/push.yml Outdated
@romanetar
romanetar force-pushed the feat/fe-testing-infrastructure branch from 567eaf8 to b434b4e Compare June 30, 2026 18:19
Comment thread .github/workflows/pull_request_unit_tests.yml Outdated
@github-actions

Copy link
Copy Markdown

📘 OpenAPI / Swagger preview

➡️ https://OpenStackweb.github.io/openstackid/openapi/pr-144/

This page is automatically updated on each push to this PR.

@romanetar
romanetar force-pushed the feat/fe-testing-infrastructure branch from b434b4e to b02637e Compare June 30, 2026 18:24
@github-actions

Copy link
Copy Markdown

📘 OpenAPI / Swagger preview

➡️ https://OpenStackweb.github.io/openstackid/openapi/pr-144/

This page is automatically updated on each push to this PR.

@romanetar
romanetar force-pushed the feat/fe-testing-infrastructure branch from b02637e to ece0a61 Compare June 30, 2026 18:31
@github-actions

Copy link
Copy Markdown

📘 OpenAPI / Swagger preview

➡️ https://OpenStackweb.github.io/openstackid/openapi/pr-144/

This page is automatically updated on each push to this PR.

@romanetar
romanetar force-pushed the feat/fe-testing-infrastructure branch from ece0a61 to 88d296e Compare June 30, 2026 18:45
@github-actions

Copy link
Copy Markdown

📘 OpenAPI / Swagger preview

➡️ https://OpenStackweb.github.io/openstackid/openapi/pr-144/

This page is automatically updated on each push to this PR.

@romanetar
romanetar force-pushed the feat/fe-testing-infrastructure branch from 88d296e to f7b8536 Compare June 30, 2026 19:04
@github-actions

Copy link
Copy Markdown

📘 OpenAPI / Swagger preview

➡️ https://OpenStackweb.github.io/openstackid/openapi/pr-144/

This page is automatically updated on each push to this PR.

@romanetar
romanetar force-pushed the feat/fe-testing-infrastructure branch from f7b8536 to 127ce7a Compare July 1, 2026 13:52
@github-actions

github-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown

📘 OpenAPI / Swagger preview

➡️ https://OpenStackweb.github.io/openstackid/openapi/pr-144/

This page is automatically updated on each push to this PR.

@romanetar
romanetar force-pushed the feat/fe-testing-infrastructure branch from 127ce7a to 6248346 Compare July 1, 2026 14:10
@github-actions

github-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown

📘 OpenAPI / Swagger preview

➡️ https://OpenStackweb.github.io/openstackid/openapi/pr-144/

This page is automatically updated on each push to this PR.

2 similar comments
@github-actions

github-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown

📘 OpenAPI / Swagger preview

➡️ https://OpenStackweb.github.io/openstackid/openapi/pr-144/

This page is automatically updated on each push to this PR.

@github-actions

github-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown

📘 OpenAPI / Swagger preview

➡️ https://OpenStackweb.github.io/openstackid/openapi/pr-144/

This page is automatically updated on each push to this PR.

@romanetar
romanetar force-pushed the feat/fe-testing-infrastructure branch from e995647 to 1b6f66d Compare July 1, 2026 14:59
@github-actions

github-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown

📘 OpenAPI / Swagger preview

➡️ https://OpenStackweb.github.io/openstackid/openapi/pr-144/

This page is automatically updated on each push to this PR.

@romanetar
romanetar requested a review from smarcet July 1, 2026 15:36
@smarcet
smarcet force-pushed the feat/mfa---login-ui-flow branch from e0b8519 to 1f2e9b6 Compare July 23, 2026 16:33
romanetar and others added 7 commits July 25, 2026 01:15
Signed-off-by: romanetar <roman_ag@hotmail.com>
Signed-off-by: romanetar <roman_ag@hotmail.com>
Signed-off-by: romanetar <roman_ag@hotmail.com>
Comment out login-mfa-flow.spec.ts and register.spec.ts so CI runs
login.spec.ts alone to verify it now passes without account lockout
interference. Also fix the MFA beforeEach mock: fulfill() must run
before unroute(), otherwise Playwright auto-resolves the in-flight
route on unroute and the later fulfill() throws "Route is already
handled" - which was letting the real POST through with a wrong
password and locking out test@test.com.
login.spec.ts verified green in isolation; re-enable the MFA flow
suite (route-ordering fix already applied) and the registration
suite now that the account-lockout cascade is gone.

Signed-off-by: romanetar <roman_ag@hotmail.com>
PR #142 reverted the password login step from AJAX back to a native
form POST + server redirect/session flow (commit 0eca371), removing
handleAuthenticatePasswordFlow/Ok/Error, authenticateWithPassword, and
the MFA_CHALLENGE_REQUIRED constant. The tests added by this branch
were written against the old AJAX contract and needed to be realigned.

- tests/js/login/login.mfa.test.js: remove the handleAuthenticatePasswordOk
  describe block - it tested a client-side AJAX handler that no longer
  exists in login.js.

- tests/e2e/tests/auth/login-mfa-flow.spec.ts:
  - beforeEach no longer mocks the password POST as JSON; it performs a
    real native login against a real MFA-enforced account, matching how
    postLogin() actually issues a challenge (redirect + session state).
  - Each TS-* test now uses its own seeded MFA user (mfa-ts-NNN@test.com)
    instead of sharing one fixed account - a real challenge issuance
    counts against two_factor.rate_limit.max_otp_requests, so 8 tests
    sharing one account exhausted the limit before the suite finished.
  - Fixed VERIFY_URL/RESEND_URL/RECOVERY_URL/CANCEL_URL glob patterns to
    end with '**': postRawRequest() appends every param as a query string
    in addition to the body, so the exact-suffix glob never matched and
    silently left every route mock inert (requests were hitting the real
    backend instead).
  - TS-004/TS-007: resetToPasswordFlow() keeps the verified identity and
    returns to the password step (authFlow: FLOW.PASSWORD) - it does not
    clear user_name/user_verified. Both tests asserted the email step was
    shown instead, contradicting their own titles and the function's name.
  - TS-002: widened the post-verify assertion timeout - onVerify2FA()
    always assigns window.location.href on success, so even a same-URL
    mock response occasionally triggers a real navigation that raced the
    original 1s timeout.

- .github/workflows/{pull_request,push}_frontend_tests.yml: seed the 8
  mfa-ts-NNN@test.com accounts alongside the existing test@test.com /
  e2e@test.com fixtures.

- .gitignore: add /test-results/ (Playwright's screenshot/video/trace
  output directory) - only /tests/e2e/report/ was previously ignored.

Verified: 40/40 PHP (TwoFactorLoginFlowTest), 23/23 Jest, 13/13 Playwright
e2e, stable across repeated runs via `docker compose --profile e2e run
--rm playwright npx playwright test`.
Adds tests/e2e/tests/oauth2/auth-code-flow.spec.ts, exercising the full
authorization code grant end to end - including the memento (pending
OAuth2 request) surviving a real MFA detour, consent-bypass for a
returning user, and MFA-skip for a trusted device:

- unauthenticated /oauth2/auth redirects to login (memento serialized).
- full flow: real login -> real MFA challenge -> real OTP -> consent
  screen for the correct client -> Accept -> authorization code ->
  code exchanged at the token endpoint for a real access_token.
- returning user with prior consent: a second /oauth2/auth for the same
  client+scope skips the consent screen entirely and redirects straight
  to redirect_uri (InteractiveGrantType::handle()'s has_former_consent +
  auto_approval branch).
- trusted device: checking "Trust this device" during MFA sets the
  Secure device_trust_token cookie; logging out and logging back in
  then skips the MFA challenge entirely.

Infrastructure needed to drive this for real (no mocks):

- app/Console/Commands/GetLatestOtp.php (idp:get-latest-otp {email}):
  prints the newest not-yet-redeemed OTP for a user, since the mailer
  queues via Redis and there is no catchable local mailbox to read the
  code from. Registered in app/Console/Kernel.php.

- tests/e2e/utils/otp.ts: reads that OTP from the test runner - directly
  via `php artisan` when reachable in-process (CI, host dev), or via
  `docker exec idp-app php artisan ...` when running against the
  dockerized stack (APP_URL points at nginx).

- docker-compose/playwright/Dockerfile + docker-compose.yml: the
  playwright service now builds this image (adds the Docker CLI on top
  of the stock Playwright image) and mounts /var/run/docker.sock so the
  above `docker exec` path works from inside that container. Scoped to
  the e2e profile only.

- The suite works around two config('app.url')-vs-actual-origin
  mismatches (e.g. app.url=http://localhost but this suite runs against
  http://nginx in the docker-compose e2e profile - cookies are
  domain-scoped, so following the server's literal absolute redirect/
  form-action URLs client-side would drop the session): verify2FA's
  redirect_url, the consent form's action, and the password step's
  postLogin() redirect are all replayed via page.request (shares the
  page's cookies) instead of trusting the browser/client-side JS to
  follow them unassisted.

- .github/workflows/{pull_request,push}_frontend_tests.yml: seed
  mfa-oauth2-consent@test.com and mfa-oauth2-trust@test.com alongside
  the existing mfa-oauth2@test.com fixture.

Known environment limitation (not a bug): the trusted-device assertion
requires a "potentially trustworthy origin" for the Secure cookie to
persist - true for http://localhost (host dev, and CI, which already
uses APP_URL=http://localhost:8001) but not for the docker-compose e2e
profile's http://nginx, where browsers silently drop the cookie.

Verified: 16/17 e2e via `docker compose --profile e2e run --rm
playwright npx playwright test` (the trusted-device test is the one
expected miss, per the above), 4/4 in tests/e2e/tests/oauth2/ via host
(`npx playwright test`), 40/40 PHP (TwoFactorLoginFlowTest), 23/23 Jest.
@smarcet
smarcet force-pushed the feat/fe-testing-infrastructure branch from 1b6f66d to 052220a Compare July 26, 2026 04:06
@github-actions

Copy link
Copy Markdown

📘 OpenAPI / Swagger preview

➡️ https://OpenStackweb.github.io/openstackid/openapi/pr-144/

This page is automatically updated on each push to this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants