diff options
author | Matthew Miller <matthew@millerti.me> | 2020-07-10 11:20:19 -0700 |
---|---|---|
committer | Matthew Miller <matthew@millerti.me> | 2020-07-10 11:20:19 -0700 |
commit | 29ff29421297c4e329cd8ee209f936dcac06506e (patch) | |
tree | a346db2dafdb8cf0f2c00329b9cc37658fbf8874 | |
parent | 6a54ebeb40e3820497c09668e078979419e6df65 (diff) |
Fix Android SafetyNet tests
-rw-r--r-- | packages/server/src/attestation/verifications/verifyAndroidSafetyNet.test.ts | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/packages/server/src/attestation/verifications/verifyAndroidSafetyNet.test.ts b/packages/server/src/attestation/verifications/verifyAndroidSafetyNet.test.ts index 001eb35..d6536b9 100644 --- a/packages/server/src/attestation/verifications/verifyAndroidSafetyNet.test.ts +++ b/packages/server/src/attestation/verifications/verifyAndroidSafetyNet.test.ts @@ -5,11 +5,13 @@ import verifyAndroidSafetyNet from './verifyAndroidSafetyNet'; import decodeAttestationObject, { AttestationStatement, } from '../../helpers/decodeAttestationObject'; +import parseAuthenticatorData from '../../helpers/parseAuthenticatorData'; import toHash from '../../helpers/toHash'; let authData: Buffer; let attStmt: AttestationStatement; let clientDataHash: Buffer; +let aaguid: Buffer; beforeEach(() => { const { attestationObject, clientDataJSON } = attestationAndroidSafetyNet.response; @@ -18,31 +20,36 @@ beforeEach(() => { authData = decodedAttestationObject.authData; attStmt = decodedAttestationObject.attStmt; clientDataHash = toHash(base64url.toBuffer(clientDataJSON)); + + const parsedAuthData = parseAuthenticatorData(authData); + aaguid = parsedAuthData.aaguid!; }); /** * We need to use the `verifyTimestampMS` escape hatch until I can figure out how to generate a * signature after modifying the payload with a `timestampMs` we can dynamically set */ -test('should verify Android SafetyNet attestation', () => { - const verified = verifyAndroidSafetyNet({ +test('should verify Android SafetyNet attestation', async () => { + const verified = await verifyAndroidSafetyNet({ attStmt, authData, clientDataHash, verifyTimestampMS: false, + aaguid, }); expect(verified).toEqual(true); }); -test('should throw error when timestamp is not within one minute of now', () => { - expect(() => { +test('should throw error when timestamp is not within one minute of now', async () => { + await expect( verifyAndroidSafetyNet({ attStmt, authData, clientDataHash, - }); - }).toThrow(/has expired/i); + aaguid, + }), + ).rejects.toThrow(/has expired/i); }); const attestationAndroidSafetyNet = { |