summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorMatthew Miller <matthew@millerti.me>2021-02-04 09:56:54 -0800
committerMatthew Miller <matthew@millerti.me>2021-02-04 09:56:54 -0800
commit4abc8169c55ea3d91ffdae5ef123b83376e446c4 (patch)
tree36dea30f9348838186058f7a75e24ac51579ff2f
parentfa377a92d9f30909e9a81b134253bd0798df8319 (diff)
Revert generateAttestationOptions tests
-rw-r--r--packages/server/src/attestation/generateAttestationOptions.test.ts48
1 files changed, 11 insertions, 37 deletions
diff --git a/packages/server/src/attestation/generateAttestationOptions.test.ts b/packages/server/src/attestation/generateAttestationOptions.test.ts
index 814d300..eb7dcd7 100644
--- a/packages/server/src/attestation/generateAttestationOptions.test.ts
+++ b/packages/server/src/attestation/generateAttestationOptions.test.ts
@@ -1,28 +1,12 @@
jest.mock('../helpers/generateChallenge');
-import base64url from 'base64url';
-
import generateAttestationOptions from './generateAttestationOptions';
-import * as generateUserHandle from '../helpers/generateUserHandle';
-
-let mockGenerateUserHandle: jest.SpyInstance;
-const mockUserHandle = Buffer.from([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]);
-
-beforeEach(() => {
- mockGenerateUserHandle = jest
- .spyOn(generateUserHandle, 'default')
- .mockReturnValue(mockUserHandle);
-});
-
-afterEach(() => {
- mockGenerateUserHandle.mockRestore();
-});
-
test('should generate credential request options suitable for sending via JSON', () => {
const rpName = 'SimpleWebAuthn';
const rpID = 'not.real';
const challenge = 'totallyrandomvalue';
+ const userID = '1234';
const userName = 'usernameHere';
const timeout = 1;
const attestationType = 'indirect';
@@ -31,6 +15,7 @@ test('should generate credential request options suitable for sending via JSON',
rpName,
rpID,
challenge,
+ userID,
userName,
timeout,
attestationType,
@@ -44,7 +29,7 @@ test('should generate credential request options suitable for sending via JSON',
id: rpID,
},
user: {
- id: 'AQIDBAUGBwgJCgsMDQ4PEA',
+ id: userID,
name: userName,
displayName: userName,
},
@@ -74,10 +59,11 @@ test('should map excluded credential IDs if specified', () => {
rpName: 'SimpleWebAuthn',
rpID: 'not.real',
challenge: 'totallyrandomvalue',
+ userID: '1234',
userName: 'usernameHere',
excludeCredentials: [
{
- id: base64url.toBuffer('c29tZUlEaGVyZQ'),
+ id: Buffer.from('someIDhere', 'ascii'),
type: 'public-key',
transports: ['usb', 'ble', 'nfc', 'internal'],
},
@@ -98,6 +84,7 @@ test('defaults to 60 seconds if no timeout is specified', () => {
rpName: 'SimpleWebAuthn',
rpID: 'not.real',
challenge: 'totallyrandomvalue',
+ userID: '1234',
userName: 'usernameHere',
});
@@ -109,6 +96,7 @@ test('defaults to none attestation if no attestation type is specified', () => {
rpName: 'SimpleWebAuthn',
rpID: 'not.real',
challenge: 'totallyrandomvalue',
+ userID: '1234',
userName: 'usernameHere',
});
@@ -120,6 +108,7 @@ test('should set authenticatorSelection if specified', () => {
rpName: 'SimpleWebAuthn',
rpID: 'not.real',
challenge: 'totallyrandomvalue',
+ userID: '1234',
userName: 'usernameHere',
authenticatorSelection: {
authenticatorAttachment: 'cross-platform',
@@ -140,6 +129,7 @@ test('should set extensions if specified', () => {
rpName: 'SimpleWebAuthn',
rpID: 'not.real',
challenge: 'totallyrandomvalue',
+ userID: '1234',
userName: 'usernameHere',
extensions: { appid: 'simplewebauthn' },
});
@@ -153,6 +143,7 @@ test('should generate a challenge if one is not provided', () => {
const options = generateAttestationOptions({
rpID: 'not.real',
rpName: 'SimpleWebAuthn',
+ userID: '1234',
userName: 'usernameHere',
});
@@ -164,6 +155,7 @@ test('should use custom supported algorithm IDs as-is when provided', () => {
const options = generateAttestationOptions({
rpID: 'not.real',
rpName: 'SimpleWebAuthn',
+ userID: '1234',
userName: 'usernameHere',
supportedAlgorithmIDs: [-7, -8, -65535],
});
@@ -174,21 +166,3 @@ test('should use custom supported algorithm IDs as-is when provided', () => {
{ alg: -65535, type: 'public-key' },
]);
});
-
-test('should generate a new userHandle each time', () => {
- mockGenerateUserHandle.mockRestore();
-
- const opts1 = generateAttestationOptions({
- rpID: 'not.real',
- rpName: 'SimpleWebAuthn',
- userName: 'usernamehere',
- });
-
- const opts2 = generateAttestationOptions({
- rpID: 'not.real',
- rpName: 'SimpleWebAuthn',
- userName: 'usernamehere',
- });
-
- expect(opts1.user.id).not.toEqual(opts2.user.id);
-});