tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

createcredential-passing.https.html (10218B)


      1 <!DOCTYPE html>
      2 <meta charset="utf-8">
      3 <title>WebAuthn credential.create() Passing Tests</title>
      4 <meta name="timeout" content="long">
      5 <link rel="author" title="Adam Powers" href="mailto:adam@fidoalliance.org">
      6 <link rel="help" href="https://w3c.github.io/webauthn/#iface-credential">
      7 <script src="/resources/testharness.js"></script>
      8 <script src="/resources/testharnessreport.js"></script>
      9 <script src="/resources/testdriver.js"></script>
     10 <script src="/resources/testdriver-vendor.js"></script>
     11 <script src=helpers.js></script>
     12 <body></body>
     13 <script>
     14 standardSetup(function() {
     15    "use strict";
     16 
     17    // CreateCredentialTest passing tests
     18 
     19    // default arguments
     20    new CreateCredentialsTest().runTest("passing credentials.create() with default arguments");
     21 
     22    // rp
     23    new CreateCredentialsTest({path: "options.publicKey.rp.id", value: window.location.hostname}).runTest("passing credentials.create() with rpId (hostname)");
     24 
     25    // user
     26    new CreateCredentialsTest("options.publicKey.user.id", new ArrayBuffer(1)).runTest("very short user id");
     27    new CreateCredentialsTest("options.publicKey.user.id", new ArrayBuffer(64)).runTest("max length user id");
     28    new CreateCredentialsTest("options.publicKey.user.id", new Uint8Array(64)).runTest("Uint8Array user id");
     29    new CreateCredentialsTest("options.publicKey.user.id", new Int8Array(64)).runTest("Int8Array user id");
     30    new CreateCredentialsTest("options.publicKey.user.id", new Int16Array(32)).runTest("Int16Array user id");
     31    new CreateCredentialsTest("options.publicKey.user.id", new Int32Array(16)).runTest("Int32Array user id");
     32    new CreateCredentialsTest("options.publicKey.user.id", new Float32Array(16)).runTest("Float32Array user id");
     33    var dvBuf1 = new ArrayBuffer(16);
     34    new CreateCredentialsTest("options.publicKey.user.id", new DataView(dvBuf1)).runTest("DataView user id");
     35 
     36    // good challenge values
     37    // all these challenges are zero-filled buffers... think anyone will complain?
     38    new CreateCredentialsTest("options.publicKey.challenge", new Int16Array(33)).runTest("Int16Array challenge");
     39    new CreateCredentialsTest("options.publicKey.challenge", new Int32Array(17)).runTest("Int32Array challenge");
     40    new CreateCredentialsTest("options.publicKey.challenge", new Float32Array(17)).runTest("Float32Array challenge");
     41    new CreateCredentialsTest("options.publicKey.challenge", new Float64Array(9)).runTest("Float64Array challenge");
     42    var dvBuf2 = new ArrayBuffer(65);
     43    new CreateCredentialsTest("options.publicKey.challenge", new DataView(dvBuf2)).runTest("DataView challenge");
     44    new CreateCredentialsTest("options.publicKey.challenge", new ArrayBuffer(8192)).runTest("Absurdly large challenge");
     45 
     46    // good pubKeyCredParams values
     47    // empty pubKeyCredParams should default to EC256 and RS256
     48    new CreateCredentialsTest("options.publicKey.pubKeyCredParams", []).runTest("pubKeyCredParams is empty Array");
     49    const pkParamEC256 = {
     50        type: "public-key",
     51        alg: cose_alg_ECDSA_w_SHA256
     52    };
     53    const pkParamEC512 = {
     54        type: "public-key",
     55        alg: cose_alg_ECDSA_w_SHA512
     56    };
     57    new CreateCredentialsTest("options.publicKey.pubKeyCredParams", [pkParamEC256]).runTest("EC256 pubKeyCredParams");
     58    new CreateCredentialsTest("options.publicKey.pubKeyCredParams", [pkParamEC512, pkParamEC256])
     59        .runTest("SelectEC256 pubKeyCredParams from a list");
     60 
     61    // pubKeyCredParams with unknown value
     62    new CreateCredentialsTest("options.publicKey.pubKeyCredParams", [{ "type": "unknown", alg: -7, }, { "type": "public-key", alg: -7, }])
     63        .runTest("pubKeyCredParams with unknown value");
     64 
     65    // timeout
     66    new CreateCredentialsTest({path: "options.publicKey.timeout", value: undefined}).runTest("passing credentials.create() with no timeout");
     67 
     68    // valid authenticatorSelection values
     69    var defaultAuthnrSel = {
     70        authenticatorAttachment: "cross-platform",
     71        requireResidentKey: false,
     72        userVerification: "preferred"
     73    };
     74    // attachment
     75    var authnrSelAttachUndef = cloneObject(defaultAuthnrSel);
     76    authnrSelAttachUndef.authenticatorAttachment = undefined;
     77    var authnrSelAttachEmptyStr = cloneObject(defaultAuthnrSel);
     78    authnrSelAttachEmptyStr.authenticatorAttachment = "";
     79    var authnrSelAttachEmptyObj = cloneObject(defaultAuthnrSel);
     80    authnrSelAttachEmptyObj.authenticatorAttachment = {};
     81    var authnrSelAttachNull = cloneObject(defaultAuthnrSel);
     82    authnrSelAttachNull.authenticatorAttachment = null;
     83    var authnrSelAttachUnknownValue = cloneObject(defaultAuthnrSel);
     84    authnrSelAttachUnknownValue.authenticatorAttachment = "unknown-value";
     85    // resident key
     86    var authnrSelRkUndef = cloneObject(defaultAuthnrSel);
     87    authnrSelRkUndef.requireResidentKey = undefined;
     88    var authnrSelRkFalse = cloneObject(defaultAuthnrSel);
     89    authnrSelRkFalse.requireResidentKey = false;
     90    // user verification
     91    var authnrSelUvUndef = cloneObject(defaultAuthnrSel);
     92    authnrSelUvUndef.userVerification = undefined;
     93    var authnrSelUvDiscouraged = cloneObject(defaultAuthnrSel);
     94    authnrSelUvDiscouraged.userVerification = "discouraged";
     95    var authnrSelUvEmptyStr = cloneObject(defaultAuthnrSel);
     96    authnrSelUvEmptyStr.userVerification = "";
     97    var authnrSelUvEmptyObj = cloneObject(defaultAuthnrSel);
     98    authnrSelUvEmptyObj.userVerification = {};
     99    var authnrSelUvStr = cloneObject(defaultAuthnrSel);
    100    authnrSelUvStr.userVerification = "requiredshirtshoestshirt";
    101    var authnrSelUvNull = cloneObject(defaultAuthnrSel);
    102    authnrSelUvNull.userVerification = null;
    103 
    104    new CreateCredentialsTest({path: "options.publicKey.authenticatorSelection", value: undefined}).runTest("authenticatorSelection is undefined");
    105    new CreateCredentialsTest("options.publicKey.authenticatorSelection", {}).runTest("authenticatorSelection is empty object");
    106    new CreateCredentialsTest("options.publicKey.authenticatorSelection", cloneObject(defaultAuthnrSel)).runTest("authenticatorSelection default values");
    107 
    108    // authnr selection attachment
    109    new CreateCredentialsTest("options.publicKey.authenticatorSelection", authnrSelAttachUndef).runTest("authenticatorSelection attachment undefined");
    110    new CreateCredentialsTest("options.publicKey.authenticatorSelection", authnrSelAttachEmptyStr).runTest("authenticatorSelection attachment empty string");
    111    new CreateCredentialsTest("options.publicKey.authenticatorSelection", authnrSelAttachEmptyObj).runTest("authenticatorSelection attachment empty object");
    112    new CreateCredentialsTest("options.publicKey.authenticatorSelection", authnrSelAttachNull).runTest("authenticatorSelection attachment null");
    113    new CreateCredentialsTest("options.publicKey.authenticatorSelection", authnrSelAttachUnknownValue).runTest("authenticatorSelection attachment unknown value");
    114 
    115    // authnr selection resident key
    116    new CreateCredentialsTest("options.publicKey.authenticatorSelection", authnrSelRkUndef).runTest("authenticatorSelection residentKey undefined");
    117    // XXX: assumes authnr is behaving like most U2F authnrs; really depends on the authnr or mock configuration
    118    new CreateCredentialsTest("options.publicKey.authenticatorSelection", authnrSelRkFalse).runTest("authenticatorSelection residentKey false");
    119 
    120    // authnr selection user verification
    121    new CreateCredentialsTest("options.publicKey.authenticatorSelection", authnrSelUvUndef).runTest("authenticatorSelection userVerification undefined");
    122    new CreateCredentialsTest("options.publicKey.authenticatorSelection", authnrSelUvDiscouraged).runTest("authenticatorSelection userVerification discouraged");
    123    new CreateCredentialsTest("options.publicKey.authenticatorSelection", authnrSelUvEmptyStr).runTest("authenticatorSelection userVerification empty string");
    124    new CreateCredentialsTest("options.publicKey.authenticatorSelection", authnrSelUvEmptyObj).runTest("authenticatorSelection userVerification empty object");
    125    new CreateCredentialsTest("options.publicKey.authenticatorSelection", authnrSelUvStr).runTest("authenticatorSelection userVerification unknown value");
    126    new CreateCredentialsTest("options.publicKey.authenticatorSelection", authnrSelUvNull).runTest("authenticatorSelection userVerification null");
    127 
    128    // good attestation values
    129    new CreateCredentialsTest("options.publicKey.attestation", "none").runTest("attestation parameter: attestation is \"none\"");
    130    new CreateCredentialsTest("options.publicKey.attestation", "indirect").runTest("attestation parameter: attestation is \"indirect\"");
    131    new CreateCredentialsTest("options.publicKey.attestation", "direct").runTest("attestation parameter: attestation is \"direct\"");
    132    new CreateCredentialsTest({path: "options.publicKey.attestation", value: undefined}).runTest("attestation parameter: attestation is undefined");
    133    // attestation unknown values
    134    new CreateCredentialsTest("options.publicKey.attestation", {}).runTest("attestation parameter: attestation is empty object");
    135    new CreateCredentialsTest("options.publicKey.attestation", []).runTest("attestation parameter: attestation is empty array");
    136    new CreateCredentialsTest("options.publicKey.attestation", null).runTest("attestation parameter: attestation is null");
    137    new CreateCredentialsTest("options.publicKey.attestation", "noneofyourbusiness").runTest("attestation parameter: attestation is \"noneofyourbusiness\"");
    138    new CreateCredentialsTest("options.publicKey.attestation", "").runTest("attestation parameter: attestation is empty string");
    139    // TODO: test this with multiple mock authenticators to make sure that the right options are chosen when available?
    140 
    141    // good extension values
    142    new CreateCredentialsTest({path: "options.publicKey.extensions", value: undefined}).runTest("extensions undefined");
    143    new CreateCredentialsTest("options.publicKey.extensions", {}).runTest("extensions are empty object");
    144    new CreateCredentialsTest("options.publicKey.extensions", {foo: "", bar: "", bat: ""}).runTest("extensions are dict of empty strings");
    145 });
    146 
    147 /* JSHINT */
    148 /* globals standardSetup, CreateCredentialsTest, cose_alg_ECDSA_w_SHA256, cose_alg_ECDSA_w_SHA512, cloneObject */
    149 </script>