tor-browser

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

createcredential-pubkeycredparams.https.html (3957B)


      1 <!DOCTYPE html>
      2 <meta charset="utf-8">
      3 <title>WebAuthn navigator.credentials.create() pubKeyCredParams 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    var badType = {
     18        type: "something-else",
     19        alg: cose_alg_ECDSA_w_SHA512
     20    };
     21    var badTypeEmptyString = cloneObject(badType);
     22    badTypeEmptyString.type = "";
     23    var badTypeNull = cloneObject(badType);
     24    badTypeNull.type = null;
     25    var badTypeEmptyObj = cloneObject(badType);
     26    badTypeEmptyObj.type = {};
     27 
     28    var badAlg = {
     29        type: "public-key",
     30        alg: 42
     31    };
     32    var badAlgZero = cloneObject(badAlg);
     33    badAlgZero.alg = 0;
     34 
     35    // bad pubKeyCredParams values
     36    new CreateCredentialsTest({path: "options.publicKey.pubKeyCredParams", value: undefined}).runTest("Bad pubKeyCredParams: pubKeyCredParams is undefined", TypeError);
     37    new CreateCredentialsTest("options.publicKey.pubKeyCredParams", "hi mom").runTest("Bad pubKeyCredParams: pubKeyCredParams is string", TypeError);
     38    new CreateCredentialsTest("options.publicKey.pubKeyCredParams", null).runTest("Bad pubKeyCredParams: pubKeyCredParams is null", TypeError);
     39    new CreateCredentialsTest("options.publicKey.pubKeyCredParams", [badType]).runTest("Bad pubKeyCredParams: first param has bad type (\"something-else\")", "NotSupportedError");
     40    new CreateCredentialsTest("options.publicKey.pubKeyCredParams", [badTypeEmptyString]).runTest("Bad pubKeyCredParams: first param has bad type (\"\")", "NotSupportedError");
     41    new CreateCredentialsTest("options.publicKey.pubKeyCredParams", [badTypeNull]).runTest("Bad pubKeyCredParams: first param has bad type (null)", "NotSupportedError");
     42    new CreateCredentialsTest("options.publicKey.pubKeyCredParams", [badTypeEmptyObj]).runTest("Bad pubKeyCredParams: first param has bad type (empty object)", "NotSupportedError");
     43    new CreateCredentialsTest("options.publicKey.pubKeyCredParams", [badAlg])
     44      .modify("options.publicKey.timeout", 300)
     45      .runTest("Bad pubKeyCredParams: first param has bad alg (42)", "NotAllowedError");
     46    new CreateCredentialsTest("options.publicKey.pubKeyCredParams", [badAlgZero])
     47      .modify("options.publicKey.timeout", 300)
     48      .runTest("Bad pubKeyCredParams: first param has bad alg (0)", "NotAllowedError");
     49 
     50    // TODO: come back to this when mock authenticators support multiple cryptos so that we can test the preference ranking
     51    // function verifyEC256(res) {
     52    //     debug ("verifyEC256 got", res);
     53    //     debug ("client data JSON", ab2str(res.response.clientDataJSON));
     54    //     parseAuthenticatorData(res.response.attestationObject);
     55    // }
     56    // new CreateCredentialsTest("options.publicKey.pubKeyCredParams", [pkParamEC256, pkParamEC512])
     57    //     .afterTest(verifyEC256)
     58    //     .runTest("EC256, EC512 pubKeyCredParams");
     59    // function verifyEC512(res) {
     60    //     debug ("verifyEC512 got", res);
     61    //     debug ("client data JSON", ab2str(res.response.clientDataJSON));
     62    //     // parseAuthenticatorData(res.response.attestationObject);
     63    //     printHex ("clientDataJSON", res.response.clientDataJSON);
     64    //     printHex ("attestationObject", res.response.attestationObject);
     65    // }
     66    // new CreateCredentialsTest("options.publicKey.pubKeyCredParams", [pkParamEC512, pkParamEC256])
     67    //     .afterTest(verifyEC512)
     68    //     .runTest("EC512, EC256 pubKeyCredParams");
     69 });
     70 
     71 /* JSHINT */
     72 /* globals standardSetup, CreateCredentialsTest, cose_alg_ECDSA_w_SHA512, cloneObject */
     73 </script>