Skip to content

Commit f2c7a1f

Browse files
committed
test(plugin-auth): the unset grace-period case configures none (WIP)
Claude-Session: https://claude.ai/code/session_01Utp6Cai3TgWyncLtR5EwF7 Co-authored-by: Claude <noreply@anthropic.com>
1 parent 859a042 commit f2c7a1f

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

‎packages/plugins/plugin-auth/src/organization-mfa-enrollment-guard.test.ts‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -583,15 +583,16 @@ const post = (manager: AuthManager, path: string, body: unknown, headers: Record
583583
* A member of an organization that requires MFA, unenrolled, whose grace clock
584584
* started 30 days ago, in a session whose active organization is that one —
585585
* the card's measured state, on a deployment with two-factor on or off, and a
586-
* grace period of `graceDays` (7 unless a case says otherwise).
586+
* grace period of `graceDays` (7 unless a case says otherwise; `null` configures
587+
* none, so the manager's own default applies).
587588
*/
588-
async function arrangeHeldMember(twoFactor: boolean, graceDays: number | undefined = 7) {
589+
async function arrangeHeldMember(twoFactor: boolean, graceDays: number | null = 7) {
589590
const engine: any = createMemoryEngine();
590591
const manager = new AuthManager({
591592
secret: SECRET,
592593
baseUrl: 'http://localhost:3000',
593594
dataEngine: engine,
594-
...(graceDays === undefined ? {} : { mfaGracePeriodDays: graceDays }),
595+
...(graceDays === null ? {} : { mfaGracePeriodDays: graceDays }),
595596
...(twoFactor ? { plugins: { twoFactor: true } } : {}),
596597
} as any);
597598
const signedUp = await post(manager, '/sign-up/email', { email: EMAIL, password: PASSWORD, name: 'Member' });
@@ -653,8 +654,8 @@ describe('#30411 the grace period the notice names is the one the gate holds to'
653654
});
654655

655656
it.each([
656-
[40, false], [20, true], [undefined, true],
657-
] as const)('grace %j days, clock started 30 days ago: held = %j, and the manager answers the same number', async (graceDays, held) => {
657+
[40, false], [20, true], [null, true],
658+
] as const)('grace %j days (null: unset), clock started 30 days ago: held = %j, and the manager answers the same number', async (graceDays, held) => {
658659
const { manager, userId } = await arrangeHeldMember(true, graceDays);
659660
expect(manager.getMfaGracePeriodDays()).toBe(graceDays ?? 7);
660661
const gates = await manager.resolveUserAuthGates(userId, { organizationId: ORG });

0 commit comments

Comments
 (0)