Commit c751fecd authored by Nina Satragno's avatar Nina Satragno Committed by Commit Bot

[webauthn] Fix getcredential-extensions WPTs

WPTs testing navigator.credentials.get() webauthn extensions were
expecting errors incorrectly:

* Unrecognized extensions are ignored instead of failing the request
  https://w3c.github.io/webauthn/#sctn-extensions
* null, empty array, and non sensical objects evaluate to dictionaries
  with undefined key values, which means they should also be ignored
  https://heycam.github.io/webidl/#es-dictionary

Fixed: 875444
Change-Id: I5b2cd3d421dc3cddc7010ff3f365314e25cf2a06
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2133159Reviewed-by: default avatarKen Buchanan <kenrb@chromium.org>
Commit-Queue: Nina Satragno <nsatragno@chromium.org>
Cr-Commit-Position: refs/heads/master@{#755874}
parent 17442564
This is a testharness.js-based test.
PASS Bad extensions: extensions is string
FAIL Bad extensions: extensions is null assert_unreached: Should have rejected: Expected bad parameters to fail Reached unreachable code
FAIL Bad extensions: extensions is empty Array assert_unreached: Should have rejected: Expected bad parameters to fail Reached unreachable code
FAIL Bad extensions: extensions is empty ArrayBuffer assert_unreached: Should have rejected: Expected bad parameters to fail Reached unreachable code
FAIL Bad extensions: malformatted JSON assert_unreached: Should have rejected: Expected bad parameters to fail Reached unreachable code
FAIL Bad extensions: JavaScript object assert_unreached: Should have rejected: Expected bad parameters to fail Reached unreachable code
FAIL Bad extensions: extension ID too long assert_unreached: Should have rejected: Expected bad parameters to fail Reached unreachable code
PASS extensions is a nonsensical JSON string
PASS Clean up the test environment
Harness: the test ran to completion.
...@@ -14,46 +14,37 @@ ...@@ -14,46 +14,37 @@
standardSetup(function() { standardSetup(function() {
"use strict"; "use strict";
var credPromise = createCredential();
var dummyExtension = { var dummyExtension = {
foo: true, foo: true,
bar: "yup" bar: "yup"
}; };
var credPromise = createCredential(); var badExtId = {};
badExtId[createRandomString(65)] = dummyExtension;
// bad extension values // bad extension values
new GetCredentialsTest("options.publicKey.extensions", "hi mom") new GetCredentialsTest("options.publicKey.extensions", "hi mom")
.addCredential(credPromise) .addCredential(credPromise)
.runTest("Bad extensions: extensions is string", TypeError); .runTest("Bad extensions: extensions is string", TypeError);
// empty extensions
new GetCredentialsTest("options.publicKey.extensions", null) new GetCredentialsTest("options.publicKey.extensions", null)
.addCredential(credPromise) .addCredential(credPromise)
.runTest("Bad extensions: extensions is null", TypeError); .runTest("extensions is null");
new GetCredentialsTest("options.publicKey.extensions", []) new GetCredentialsTest("options.publicKey.extensions", [])
.addCredential(credPromise) .addCredential(credPromise)
.runTest("Bad extensions: extensions is empty Array", TypeError); .runTest("extensions is empty Array");
new GetCredentialsTest("options.publicKey.extensions", new ArrayBuffer(0)) new GetCredentialsTest("options.publicKey.extensions", new ArrayBuffer(0))
.addCredential(credPromise) .addCredential(credPromise)
.runTest("Bad extensions: extensions is empty ArrayBuffer", TypeError); .runTest("extensions is empty ArrayBuffer");
var badJson = '{"foo": true, "bar: "yup"}'; // missing quote after "bar"
new GetCredentialsTest("options.publicKey.extensions", {foo: badJson}) // unknown extensions should be ignored
.addCredential(credPromise)
.runTest("Bad extensions: malformatted JSON", TypeError);
new GetCredentialsTest("options.publicKey.extensions", {foo: dummyExtension}) new GetCredentialsTest("options.publicKey.extensions", {foo: dummyExtension})
.addCredential(credPromise) .addCredential(credPromise)
.runTest("Bad extensions: JavaScript object", TypeError); .runTest("ignored extension");
var badExtId = {};
badExtId[createRandomString(65)] = dummyExtension;
new GetCredentialsTest("options.publicKey.extensions", {badExtId: dummyExtension}) new GetCredentialsTest("options.publicKey.extensions", {badExtId: dummyExtension})
.addCredential(credPromise) .addCredential(credPromise)
.runTest("Bad extensions: extension ID too long", TypeError); .runTest("extension ID too long");
// 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 GetCredentialsTest("options.publicKey.extensions", {foo: JSON.stringify(randomExtId)})
.addCredential(credPromise)
.runTest("extensions is a nonsensical JSON string");
// TODO // TODO
// defined extensions: // defined extensions:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment