mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-01 00:43:15 +00:00
test(auth): check resolved passkey configuration before use
The Server lint warning ratchet rejected three non-null assertions. Check that the configuration exists before using it, and cover missing and out-of-scope origins.
This commit is contained in:
@@ -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',
|
||||
|
||||
Reference in New Issue
Block a user