blob: 6d0e3e3beed265573715937e3bcf1a2ae18e94a2 [file] [log] [blame]
<!DOCTYPE html>
<meta charset="utf-8">
<title>WebAuthn navigator.credentials.create() extensions Tests</title>
<link rel="author" title="Adam Powers" href="mailto:adam@fidoalliance.org">
<link rel="help" href="https://w3c.github.io/webauthn/#iface-credential">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src=helpers.js></script>
<body></body>
<script>
standardSetup(function() {
"use strict";
var dummyExtension = {
foo: true,
bar: "yup"
};
// bad extension values
new CreateCredentialsTest("options.publicKey.extensions", "hi mom").runTest("Bad extensions: extensions is string", new TypeError());
new CreateCredentialsTest("options.publicKey.extensions", null).runTest("Bad extensions: extensions is null", new TypeError());
new CreateCredentialsTest("options.publicKey.extensions", []).runTest("Bad extensions: extensions is empty Array", new TypeError());
new CreateCredentialsTest("options.publicKey.extensions", new ArrayBuffer(0)).runTest("Bad extensions: extensions is empty ArrayBuffer", new TypeError());
var badJson = '{"foo": true, "bar: "yup"}'; // missing quote after "bar"
new CreateCredentialsTest("options.publicKey.extensions", {foo: badJson}).runTest("Bad extensions: malformatted JSON", new TypeError());
new CreateCredentialsTest("options.publicKey.extensions", {foo: dummyExtension}).runTest("Bad extensions: JavaScript object", new TypeError());
var badExtId = {};
badExtId[createRandomString(65)] = dummyExtension;
new CreateCredentialsTest("options.publicKey.extensions", {badExtId: dummyExtension}).runTest("Bad extensions: extension ID too long", new TypeError());
// phony extensions
// TODO: not sure if this should pass or fail
// should be clarified as part of https://github.com/w3c/webauthn/pull/765
var randomExtId = {};
randomExtId[createRandomString(64)] = dummyExtension;
new CreateCredentialsTest("options.publicKey.extensions", {foo: JSON.stringify(randomExtId)}).runTest("extensions is a nonsensical JSON string");
// Defined extensions.
// appid
new CreateCredentialsTest("options.publicKey.extensions", {appid: ""}).runTest("empty appid in create request", "NotSupportedError");
new CreateCredentialsTest("options.publicKey.extensions", {appid: null}).runTest("null appid in create request", "NotSupportedError");
new CreateCredentialsTest("options.publicKey.extensions", {appid: "anything"}).runTest("appid in create request", "NotSupportedError");
// TODO
// defined extensions:
// * txAuthSimple
// * txAuthGeneric
// * authnSel
// * exts
// * uvi
// * loc
// * uvm
});
/* JSHINT */
/* globals standardSetup, CreateCredentialsTest, createRandomString */
</script>