summaryrefslogtreecommitdiffhomepage
path: root/packages/browser/src
diff options
context:
space:
mode:
authorMatthew Miller <matthew@millerti.me>2021-02-03 15:35:46 -0800
committerMatthew Miller <matthew@millerti.me>2021-02-03 15:35:46 -0800
commit8b5bcf25d4cb987dbad430b5b629b05b56108d95 (patch)
tree9b7a20fa8a6546765409584e8460f22a9267a755 /packages/browser/src
parent1b6c2832ca5e1fbcc5a1f5e5c0acf257c81599f3 (diff)
Fix Browser unit tests
Diffstat (limited to 'packages/browser/src')
-rw-r--r--packages/browser/src/methods/startAssertion.test.ts9
-rw-r--r--packages/browser/src/methods/startAttestation.test.ts7
2 files changed, 7 insertions, 9 deletions
diff --git a/packages/browser/src/methods/startAssertion.test.ts b/packages/browser/src/methods/startAssertion.test.ts
index c74b88f..f763391 100644
--- a/packages/browser/src/methods/startAssertion.test.ts
+++ b/packages/browser/src/methods/startAssertion.test.ts
@@ -4,7 +4,6 @@ import {
} from '@simplewebauthn/typescript-types';
import supportsWebauthn from '../helpers/supportsWebauthn';
-import toUint8Array from '../helpers/toUint8Array';
import bufferToBase64URLString from '../helpers/bufferToBase64URLString';
import startAssertion from './startAssertion';
@@ -21,7 +20,7 @@ const mockUserHandle = 'mockUserHandle';
// With ASCII challenge
const goodOpts1: PublicKeyCredentialRequestOptionsJSON = {
- challenge: bufferToBase64URLString(toUint8Array('fizz')),
+ challenge: bufferToBase64URLString(Buffer.from('fizz', 'ascii')),
allowCredentials: [
{
id: 'C0VGlvYFratUdAV1iCw-ULpUW8E-exHPXQChBfyVeJZCMfjMFcwDmOFgoMUz39LoMtCJUBW8WPlLkGT6q8qTCg',
@@ -34,7 +33,7 @@ const goodOpts1: PublicKeyCredentialRequestOptionsJSON = {
// With UTF-8 challenge
const goodOpts2UTF8: PublicKeyCredentialRequestOptionsJSON = {
- challenge: bufferToBase64URLString(toUint8Array('やれやれだぜ')),
+ challenge: bufferToBase64URLString(Buffer.from('やれやれだぜ', 'utf-8')),
allowCredentials: [],
timeout: 1,
};
@@ -88,7 +87,7 @@ test('should support optional allowCredential', async () => {
);
await startAssertion({
- challenge: bufferToBase64URLString(toUint8Array('fizz')),
+ challenge: bufferToBase64URLString(Buffer.from('fizz', 'ascii')),
timeout: 1,
});
@@ -111,7 +110,7 @@ test('should convert allow allowCredential to undefined when empty', async () =>
);
await startAssertion({
- challenge: bufferToBase64URLString(toUint8Array('fizz')),
+ challenge: bufferToBase64URLString(Buffer.from('fizz', 'ascii')),
timeout: 1,
allowCredentials: [],
});
diff --git a/packages/browser/src/methods/startAttestation.test.ts b/packages/browser/src/methods/startAttestation.test.ts
index 0723213..ad71488 100644
--- a/packages/browser/src/methods/startAttestation.test.ts
+++ b/packages/browser/src/methods/startAttestation.test.ts
@@ -3,7 +3,6 @@ import {
PublicKeyCredentialCreationOptionsJSON,
} from '@simplewebauthn/typescript-types';
-import toUint8Array from '../helpers/toUint8Array';
import supportsWebauthn from '../helpers/supportsWebauthn';
import bufferToBase64URLString from '../helpers/bufferToBase64URLString';
@@ -18,7 +17,7 @@ const mockAttestationObject = 'mockAtte';
const mockClientDataJSON = 'mockClie';
const goodOpts1: PublicKeyCredentialCreationOptionsJSON = {
- challenge: bufferToBase64URLString(toUint8Array('fizz')),
+ challenge: bufferToBase64URLString(Buffer.from('fizz', 'ascii')),
attestation: 'direct',
pubKeyCredParams: [
{
@@ -69,7 +68,7 @@ test('should convert options before passing to navigator.credentials.create(...)
// Make sure challenge and user.id are converted to Buffers
expect(new Uint8Array(argsPublicKey.challenge)).toEqual(new Uint8Array([102, 105, 122, 122]));
- expect(new Uint8Array(argsPublicKey.user.id)).toEqual(new Uint8Array([53, 54, 55, 56]));
+ expect(new Uint8Array(argsPublicKey.user.id)).toEqual(new Uint8Array([231, 174, 252]));
// Confirm construction of excludeCredentials array
expect(credId instanceof ArrayBuffer).toEqual(true);
@@ -88,7 +87,7 @@ test('should return base64url-encoded response values', async done => {
return new Promise(resolve => {
resolve({
id: 'foobar',
- rawId: toUint8Array('foobar'),
+ rawId: Buffer.from('foobar', 'ascii'),
response: {
attestationObject: Buffer.from(mockAttestationObject, 'ascii'),
clientDataJSON: Buffer.from(mockClientDataJSON, 'ascii'),