diff options
author | Matthew Miller <matthew@millerti.me> | 2023-08-17 13:04:50 -0700 |
---|---|---|
committer | Matthew Miller <matthew@millerti.me> | 2023-08-17 13:04:50 -0700 |
commit | ea9526b88dbf8242af2efc63bfaa3236ead668f9 (patch) | |
tree | 4840260fc60866d763e4a8ba42021238dbed765f /packages/server/src/helpers/parseAuthenticatorData.test.ts | |
parent | 10cdf6f8ec17cd99ec55c0e996e37bca0488aba4 (diff) |
Update parseAuthenticatorData tests
Diffstat (limited to 'packages/server/src/helpers/parseAuthenticatorData.test.ts')
-rw-r--r-- | packages/server/src/helpers/parseAuthenticatorData.test.ts | 49 |
1 files changed, 28 insertions, 21 deletions
diff --git a/packages/server/src/helpers/parseAuthenticatorData.test.ts b/packages/server/src/helpers/parseAuthenticatorData.test.ts index 5115cc3..30b898f 100644 --- a/packages/server/src/helpers/parseAuthenticatorData.test.ts +++ b/packages/server/src/helpers/parseAuthenticatorData.test.ts @@ -1,4 +1,7 @@ +import { assertEquals } from "https://deno.land/std@0.198.0/assert/mod.ts"; + import { parseAuthenticatorData } from "./parseAuthenticatorData.ts"; +import { AuthenticationExtensionsAuthenticatorOutputs } from "./decodeAuthenticatorExtensions.ts"; import { isoBase64URL } from "./iso/index.ts"; // Grabbed this from a Conformance test, contains attestation data @@ -8,52 +11,56 @@ const authDataWithAT = isoBase64URL.toBuffer( ); // Grabbed this from a Conformance test, contains extension data -const authDataWithED = Buffer.from( +const authDataWithED = isoBase64URL.toBuffer( "SZYN5YgOjGh0NBcPZHZgW4/krrmihjLHmVzzuoMdl2OBAAAAjaFxZXhhbXBsZS5leHRlbnNpb254dlRoaXMgaXMgYW4gZXhhbXBsZSBleHRlbnNpb24hIElmIHlvdSByZWFkIHRoaXMgbWVzc2FnZSwgeW91IHByb2JhYmx5IHN1Y2Nlc3NmdWxseSBwYXNzaW5nIGNvbmZvcm1hbmNlIHRlc3RzLiBHb29kIGpvYiE=", "base64", ); -test("should parse flags", () => { +Deno.test("should parse flags", () => { const parsed = parseAuthenticatorData(authDataWithED); const { flags } = parsed; - expect(flags.up).toEqual(true); - expect(flags.uv).toEqual(false); - expect(flags.be).toEqual(false); - expect(flags.bs).toEqual(false); - expect(flags.at).toEqual(false); - expect(flags.ed).toEqual(true); + assertEquals(flags.up, true); + assertEquals(flags.uv, false); + assertEquals(flags.be, false); + assertEquals(flags.bs, false); + assertEquals(flags.at, false); + assertEquals(flags.ed, true); }); -test("should parse attestation data", () => { +Deno.test("should parse attestation data", () => { const parsed = parseAuthenticatorData(authDataWithAT); const { credentialID, credentialPublicKey, aaguid, counter } = parsed; - expect(isoBase64URL.fromBuffer(credentialID!)).toEqual( + assertEquals( + isoBase64URL.fromBuffer(credentialID!), "drsqybluveECHdSPE_37iuq7wESwP7tJnbFZ7X_Ie_o", ); - expect(isoBase64URL.fromBuffer(credentialPublicKey!, "base64")).toEqual( + assertEquals( + isoBase64URL.fromBuffer(credentialPublicKey!, "base64"), "pAEDAzkBACBZAQDcxA7Ehs9goWB2Hbl6e9v+aUub9rvy2M7Hkvf+iCzMGE63e3sCEW5Ru33KNy4um46s9jalcBHtZgtEnyeRoQvszis+ws5o4Da0vQfuzlpBmjWT1dV6LuP+vs9wrfObW4jlA5bKEIhv63+jAxOtdXGVzo75PxBlqxrmrr5IR9n8Fw7clwRsDkjgRHaNcQVbwq/qdNwU5H3hZKu9szTwBS5NGRq01EaDF2014YSTFjwtAmZ3PU1tcO/QD2U2zg6eB5grfWDeAJtRE8cbndDWc8aLL0aeC37Q36+TVsGe6AhBgHEw6eO3I3NW5r9v/26CqMPBDwmEundeq1iGyKfMloobIUMBAAE=", ); - expect(isoBase64URL.fromBuffer(aaguid!, "base64")).toEqual( + assertEquals( + isoBase64URL.fromBuffer(aaguid!, "base64"), "yHzdl1bBSbieJMs2NlTzUA==", ); - expect(counter).toEqual(37); + assertEquals( + counter, + 37, + ); }); -test("should parse extension data", () => { - expect.assertions(1); - +Deno.test("should parse extension data", () => { const parsed = parseAuthenticatorData(authDataWithED); const { extensionsData } = parsed; - - if (extensionsData) { - expect(extensionsData).toEqual({ + assertEquals( + extensionsData, + { "example.extension": "This is an example extension! If you read this message, you probably successfully passing conformance tests. Good job!", - }); - } + } as AuthenticationExtensionsAuthenticatorOutputs, + ); }); |