summaryrefslogtreecommitdiffhomepage
path: root/packages/server/src/authentication/verifyAuthenticationResponse.test.ts
diff options
context:
space:
mode:
authorFabian Cook <hello@fabiancook.dev>2023-09-13 14:26:10 +1200
committerFabian Cook <hello@fabiancook.dev>2023-09-13 14:26:10 +1200
commitbf6c633aaea16235ef8c16f3d85ccbb0b2b03227 (patch)
tree510820e0340545df5d80319670a6c067ad0a578e /packages/server/src/authentication/verifyAuthenticationResponse.test.ts
parent24fe104eba8ed6d1d694abf8a0b81224aa796941 (diff)
Add tests for expectedType
Diffstat (limited to 'packages/server/src/authentication/verifyAuthenticationResponse.test.ts')
-rw-r--r--packages/server/src/authentication/verifyAuthenticationResponse.test.ts34
1 files changed, 34 insertions, 0 deletions
diff --git a/packages/server/src/authentication/verifyAuthenticationResponse.test.ts b/packages/server/src/authentication/verifyAuthenticationResponse.test.ts
index 822bdd9..b150aff 100644
--- a/packages/server/src/authentication/verifyAuthenticationResponse.test.ts
+++ b/packages/server/src/authentication/verifyAuthenticationResponse.test.ts
@@ -335,6 +335,40 @@ Deno.test('should throw an error if RP ID not in list of possible RP IDs', async
);
});
+Deno.test('should throw an error if type not the expected type', async () => {
+ await assertRejects(
+ () =>
+ verifyAuthenticationResponse({
+ response: assertionResponse,
+ expectedChallenge: assertionChallenge,
+ expectedOrigin: assertionOrigin,
+ // assertionResponse contains webauthn.get, this should produce an error
+ expectedType: 'payment.get',
+ expectedRPID: 'localhost',
+ authenticator: authenticator,
+ }),
+ Error,
+ 'Unexpected authentication response type',
+ );
+});
+
+Deno.test('should throw an error if type not in list of expected types', async () => {
+ await assertRejects(
+ () =>
+ verifyAuthenticationResponse({
+ response: assertionResponse,
+ expectedChallenge: assertionChallenge,
+ expectedOrigin: assertionOrigin,
+ // assertionResponse contains webauthn.get, this should produce an error
+ expectedType: ['payment.get', 'something.get'],
+ expectedRPID: 'localhost',
+ authenticator: authenticator,
+ }),
+ Error,
+ 'Unexpected authentication response type',
+ );
+});
+
Deno.test('should pass verification if custom challenge verifier returns true', async () => {
const verification = await verifyAuthenticationResponse({
response: {