diff options
author | Matthew Miller <matthew@millerti.me> | 2022-12-10 22:40:45 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-12-10 22:40:45 -0800 |
commit | 461b67c0c6fadfb55c1da6c9c8ab2693ba4c9a03 (patch) | |
tree | ae713d608966ac977390e7bbfbeab5ea79a191bc /packages/server/src/authentication/generateAuthenticationOptions.test.ts | |
parent | 33528afe001d4aca62052dce204c0398c3127ffd (diff) | |
parent | 90dd7f247182329987a8e23f476d9280d8d5c265 (diff) |
Merge pull request #299 from MasterKale/feat/isomorphic
feat/isomorphic
Diffstat (limited to 'packages/server/src/authentication/generateAuthenticationOptions.test.ts')
-rw-r--r-- | packages/server/src/authentication/generateAuthenticationOptions.test.ts | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/packages/server/src/authentication/generateAuthenticationOptions.test.ts b/packages/server/src/authentication/generateAuthenticationOptions.test.ts index 78c6473..9048cf5 100644 --- a/packages/server/src/authentication/generateAuthenticationOptions.test.ts +++ b/packages/server/src/authentication/generateAuthenticationOptions.test.ts @@ -1,10 +1,13 @@ jest.mock('../helpers/generateChallenge'); +import { isoBase64URL } from '../helpers/iso'; + import { generateAuthenticationOptions } from './generateAuthenticationOptions'; -test('should generate credential request options suitable for sending via JSON', () => { - const challenge = 'totallyrandomvalue'; +const challengeString = 'dG90YWxseXJhbmRvbXZhbHVl'; +const challengeBuffer = isoBase64URL.toBuffer(challengeString); +test('should generate credential request options suitable for sending via JSON', () => { const options = generateAuthenticationOptions({ allowCredentials: [ { @@ -19,12 +22,12 @@ test('should generate credential request options suitable for sending via JSON', }, ], timeout: 1, - challenge, + challenge: challengeBuffer, }); expect(options).toEqual({ // base64url-encoded - challenge: 'dG90YWxseXJhbmRvbXZhbHVl', + challenge: challengeString, allowCredentials: [ { id: 'MTIzNA', @@ -43,7 +46,7 @@ test('should generate credential request options suitable for sending via JSON', test('defaults to 60 seconds if no timeout is specified', () => { const options = generateAuthenticationOptions({ - challenge: 'totallyrandomvalue', + challenge: challengeBuffer, allowCredentials: [ { id: Buffer.from('1234', 'ascii'), type: 'public-key' }, { id: Buffer.from('5678', 'ascii'), type: 'public-key' }, @@ -55,7 +58,7 @@ test('defaults to 60 seconds if no timeout is specified', () => { test('should not set userVerification if not specified', () => { const options = generateAuthenticationOptions({ - challenge: 'totallyrandomvalue', + challenge: challengeBuffer, allowCredentials: [ { id: Buffer.from('1234', 'ascii'), type: 'public-key' }, { id: Buffer.from('5678', 'ascii'), type: 'public-key' }, @@ -86,7 +89,7 @@ test('should generate without params', () => { test('should set userVerification if specified', () => { const options = generateAuthenticationOptions({ - challenge: 'totallyrandomvalue', + challenge: challengeBuffer, allowCredentials: [ { id: Buffer.from('1234', 'ascii'), type: 'public-key' }, { id: Buffer.from('5678', 'ascii'), type: 'public-key' }, @@ -99,7 +102,7 @@ test('should set userVerification if specified', () => { test('should set extensions if specified', () => { const options = generateAuthenticationOptions({ - challenge: 'totallyrandomvalue', + challenge: challengeBuffer, allowCredentials: [ { id: Buffer.from('1234', 'ascii'), type: 'public-key' }, { id: Buffer.from('5678', 'ascii'), type: 'public-key' }, |