summaryrefslogtreecommitdiffhomepage
path: root/packages/server/src/authentication/verifyAuthenticationResponse.test.ts
diff options
context:
space:
mode:
authorMatthew Miller <matthew@millerti.me>2023-09-27 22:51:38 -0700
committerGitHub <noreply@github.com>2023-09-27 22:51:38 -0700
commitd9f85dbbffda27f27fbf8fa2341fb67aca93e201 (patch)
tree5ac4de6ef7fe0613e55ea7f40356f1518645f26e /packages/server/src/authentication/verifyAuthenticationResponse.test.ts
parent75fb63dc3de2cb9dede7e31c88f5ec29d3db1a29 (diff)
parentbf6c633aaea16235ef8c16f3d85ccbb0b2b03227 (diff)
Merge pull request #436 from opennetwork/expected-type
Add `expectedType` for verifyAuthenticationResponse and verifyRegistrationResponse
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: {