summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorMatthew Miller <matthew@millerti.me>2020-06-06 17:18:10 -0700
committerMatthew Miller <matthew@millerti.me>2020-06-06 17:18:10 -0700
commitbf0ba9fe32520a1badde7648e26e9a9f6da8dc4b (patch)
tree63886fc78d0f008116e070916233c1cdf1ff54dd
parent4dbd0851c04179a53b45eb41b4258fd5b549bac3 (diff)
Add assertion verification test for RP ID check
-rw-r--r--packages/server/src/assertion/verifyAssertionResponse.test.ts17
1 files changed, 17 insertions, 0 deletions
diff --git a/packages/server/src/assertion/verifyAssertionResponse.test.ts b/packages/server/src/assertion/verifyAssertionResponse.test.ts
index 888afc1..9066f53 100644
--- a/packages/server/src/assertion/verifyAssertionResponse.test.ts
+++ b/packages/server/src/assertion/verifyAssertionResponse.test.ts
@@ -121,6 +121,23 @@ test('should throw error if previous counter value is not less than in response'
}).toThrow(/counter value/i);
});
+test('should throw error if assertion RP ID is unexpected value', () => {
+ mockParseAuthData.mockReturnValue({
+ rpIdHash: toHash(Buffer.from('bad.url', 'ascii')),
+ flags: 0,
+ });
+
+ expect(() => {
+ verifyAssertionResponse({
+ credential: assertionResponse,
+ expectedChallenge: assertionChallenge,
+ expectedOrigin: assertionOrigin,
+ expectedRPID: 'dev.dontneeda.pw',
+ authenticator: authenticator,
+ });
+ }).toThrow(/rp id/i);
+});
+
test('should not compare counters if both are 0', () => {
const verification = verifyAssertionResponse({
credential: assertionFirstTimeUsedResponse,