Skip to content

test(auth): pin onComplete and factor refresh on successful MFA enrollment - #2462

Merged
demolaf merged 3 commits into
version-10.0.0-beta05from
feat/mfa-enrollment-test
Sep 2, 2026
Merged

test(auth): pin onComplete and factor refresh on successful MFA enrollment#2462
demolaf merged 3 commits into
version-10.0.0-beta05from
feat/mfa-enrollment-test

Conversation

@demolaf

@demolaf demolaf commented Sep 1, 2026

Copy link
Copy Markdown
Member

Nothing asserted that onComplete fires when MFA enrollment succeeds. #2457 removed the recovery-codes step, which moved onComplete one user interaction earlier for every default-configured integrator — the suite would have passed equally well had it been deleted rather than hoisted. The SMS route was unpinned end to end: deleting its enrollWithVerificationCode call left all 633 tests green.

MfaEnrollmentScreen built its handlers inside the composable, so there was nothing to stub. An internal MfaEnrollmentScreenInternal now takes them as parameters and the public composable constructs the real ones and delegates to it; the public signature is unchanged.

Added nine tests across both enrollment routes — TOTP (onComplete fires exactly once with the entered code, the enrolled-factors refresh, the failure path) and SMS (dial-code prefix and session storage, exact enroll arguments, the missing-session guard, send and enroll failures, resend session replacement and its rate-limit gate). Each was verified to fail when the line it pins is removed.


Maintainer note: Fixes internal CPRN-383

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors MfaEnrollmentScreen by extracting an internal composable MfaEnrollmentScreenInternal to allow injecting stubbed enrollment handlers for unit testing. It also adds several unit tests to verify successful and failed TOTP enrollment scenarios. The review feedback correctly identifies that the tests incorrectly use the whenever { ... } syntax to stub suspend functions, which will result in a NotAMockException at runtime. These stubbing calls should be wrapped in runBlocking to function properly.

@demolaf
demolaf force-pushed the version-10.0.0-beta05 branch from 444543d to 059bba8 Compare September 1, 2026 16:17
@demolaf
demolaf force-pushed the feat/mfa-enrollment-test branch from bcb4a97 to 5a7ea86 Compare September 1, 2026 16:17

@russellwheatley russellwheatley left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

The Internal seam keeps the public API clean, and the success tests actually pin onComplete with exact enroll arguments. SMS coverage is more than the issue asked for and I think that's the right call.

A few non-blocking nits if you feel like it: the resend test could assert errors after the final verify, and there's no TOTP twin of the missing-session test. Not worth holding this.

@demolaf
demolaf merged commit 1306c0e into version-10.0.0-beta05 Sep 2, 2026
9 checks passed
@github-project-automation github-project-automation Bot moved this from Backlog to Done in studio-2394994192-60a69 Sep 2, 2026
@demolaf
demolaf deleted the feat/mfa-enrollment-test branch September 2, 2026 12:08
demolaf added a commit that referenced this pull request Sep 6, 2026
…lment (#2462)

* test(auth): pin onComplete and factor refresh on successful MFA enrollment

* test(auth): pin the SMS MFA enrollment route through send, verify and resend

* test(auth): pin the missing TOTP secret guard and the resend's clean enroll
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