diff --git a/server/tests/unit/nest/webauthn-config.service.test.ts b/server/tests/unit/nest/webauthn-config.service.test.ts index 3b67349ed..6ce16c68e 100644 --- a/server/tests/unit/nest/webauthn-config.service.test.ts +++ b/server/tests/unit/nest/webauthn-config.service.test.ts @@ -6,7 +6,7 @@ import { } from '../../../src/nest/auth/webauthn-config.service'; import { Logger } from '@nestjs/common'; -import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest'; +import { assert, describe, it, expect, beforeEach, afterEach, vi } from 'vitest'; /** * webauthn-config.service.test.ts @@ -190,7 +190,8 @@ describe('passkeyVerificationOrigins', () => { it('WAC-019: keeps the application origin when the relying party ID is shared', async () => { appUrlRef.value = 'https://trek.example.org'; settingsStore.set('webauthn_rp_id', 'example.org'); - const config = (await svc.resolve())!; + const config = await svc.resolve(); + assert(config); expect(passkeyVerificationOrigins(config, 'https://example.org')).toEqual(['https://trek.example.org']); expect(passkeyVerificationOrigins(config, 'https://trek.example.org')).toEqual(['https://trek.example.org']); @@ -198,19 +199,23 @@ describe('passkeyVerificationOrigins', () => { it('WAC-020: tolerates a proxy scheme and port on the configured RP host', async () => { appUrlRef.value = 'http://trek.example.org:3001'; - const config = (await svc.resolve())!; + const config = await svc.resolve(); + assert(config); expect(passkeyVerificationOrigins(config, 'https://trek.example.org:8443')).toEqual([ 'http://trek.example.org:3001', 'https://trek.example.org:8443', ]); expect(passkeyVerificationOrigins(config, 'https://other.trek.example.org')).toEqual(config.origins); + expect(passkeyVerificationOrigins(config, 'https://unrelated.example.net')).toEqual(config.origins); + expect(passkeyVerificationOrigins(config, null)).toEqual(config.origins); }); it('WAC-021: applies an explicit list exactly, including its ports', async () => { settingsStore.set('webauthn_rp_id', 'example.org'); settingsStore.set('webauthn_origins', 'https://example.org, https://trek.example.org'); - const config = (await svc.resolve())!; + const config = await svc.resolve(); + assert(config); expect(passkeyVerificationOrigins(config, 'https://example.org:8443')).toEqual([ 'https://example.org',