Skip to content

Commit fce7a8a

Browse files
committed
fix: address PR review findings for MFA challenge UI
- Check for 404 specifically in updateMfaStatusUI() instead of hiding on any non-OK response; log a warning for other error statuses - Update JSDoc to document both 404 and non-OK handling behaviors - Make MFA status test assertion deterministic (expect 404 when MFA is disabled in playwright-test profile, not [200, 404])
1 parent e36a82c commit fce7a8a

2 files changed

Lines changed: 11 additions & 10 deletions

File tree

playwright/tests/mfa/mfa-challenge.spec.ts

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -57,15 +57,9 @@ test.describe('MFA', () => {
5757
// Call the MFA status endpoint
5858
const response = await page.request.get('/user/mfa/status');
5959

60-
// With MFA disabled in playwright-test profile, expect 404
61-
// With MFA enabled, expect 200 with proper response shape
62-
expect([200, 404]).toContain(response.status());
63-
64-
if (response.status() === 200) {
65-
const body = await response.json();
66-
expect(typeof body.mfaEnabled).toBe('boolean');
67-
expect(typeof body.fullyAuthenticated).toBe('boolean');
68-
}
60+
// MFA is disabled in playwright-test profile, so endpoint returns 404.
61+
// A separate MFA-enabled test profile would be needed to test the 200 case.
62+
expect(response.status()).toBe(404);
6963
});
7064

7165
test('should require authentication for MFA status endpoint', async ({ page }) => {

src/main/resources/static/js/user/webauthn-manage.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,8 @@ async function handleRegisterPasskey() {
262262

263263
/**
264264
* Update the MFA Status section in the auth-methods card.
265-
* Silently hides the container if the MFA status endpoint returns 404 (MFA disabled).
265+
* Hides the container if the MFA status endpoint returns 404 (MFA disabled).
266+
* Logs a warning for other non-OK responses.
266267
*/
267268
async function updateMfaStatusUI() {
268269
const container = document.getElementById('mfaStatusContainer');
@@ -274,7 +275,13 @@ async function updateMfaStatusUI() {
274275
headers: { [csrfHeader]: csrfToken }
275276
});
276277

278+
if (response.status === 404) {
279+
// MFA feature disabled — silently hide
280+
container.classList.add('d-none');
281+
return;
282+
}
277283
if (!response.ok) {
284+
console.warn('MFA status endpoint returned', response.status);
278285
container.classList.add('d-none');
279286
return;
280287
}

0 commit comments

Comments
 (0)