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

[webauthn] WPT - adding port to RP ID should fail

Relying party IDs are defined as "a registrable domain suffix of or
equal to the caller’s origin's effective domain". RP IDs do not include
a port.

This patch changes the host + port subtests to expect a failure instead
of success.

Bug: 875444
Change-Id: I0067ebd883612d534df13a555284fe1cdec7424d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2088002
Commit-Queue: Nina Satragno <nsatragno@chromium.org>
Reviewed-by: default avatarKen Buchanan <kenrb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#747289}
parent 53e97bc2
...@@ -27,6 +27,12 @@ standardSetup(function() { ...@@ -27,6 +27,12 @@ standardSetup(function() {
new CreateCredentialsTest("options.publicKey.rp.id", "-invaliddomain.com").runTest("Bad rp: id is invalid domain (starts with dash)", "SecurityError"); new CreateCredentialsTest("options.publicKey.rp.id", "-invaliddomain.com").runTest("Bad rp: id is invalid domain (starts with dash)", "SecurityError");
new CreateCredentialsTest("options.publicKey.rp.id", "0invaliddomain.com").runTest("Bad rp: id is invalid domain (starts with number)", "SecurityError"); new CreateCredentialsTest("options.publicKey.rp.id", "0invaliddomain.com").runTest("Bad rp: id is invalid domain (starts with number)", "SecurityError");
let hostAndPort = window.location.host;
if (!hostAndPort.match(/:\d+$/)) {
hostAndPort += ":443";
}
new CreateCredentialsTest("options.publicKey.rp.id", hostAndPort).runTest("Bad rp id: id is host + port", "SecurityError");
// // rp.name // // rp.name
new CreateCredentialsTest({path: "options.publicKey.rp.name", value: undefined}).runTest("rp missing name", TypeError); new CreateCredentialsTest({path: "options.publicKey.rp.name", value: undefined}).runTest("rp missing name", TypeError);
......
This is a testharness.js-based test. This is a testharness.js-based test.
PASS passing credentials.create() with default arguments PASS passing credentials.create() with default arguments
FAIL passing credentials.create() with rpId (host and port) promise_test: Unhandled rejection with value: object "SecurityError: The relying party ID is not a registrable domain suffix of, nor equal to the current domain."
PASS passing credentials.create() with rpId (hostname) PASS passing credentials.create() with rpId (hostname)
PASS passing credentials.create() without rp.icon PASS passing credentials.create() without rp.icon
PASS very short user id PASS very short user id
......
...@@ -20,7 +20,6 @@ standardSetup(function() { ...@@ -20,7 +20,6 @@ standardSetup(function() {
new CreateCredentialsTest().runTest("passing credentials.create() with default arguments"); new CreateCredentialsTest().runTest("passing credentials.create() with default arguments");
// rp // rp
new CreateCredentialsTest({path: "options.publicKey.rp.id", value: window.location.host}).runTest("passing credentials.create() with rpId (host and port)");
new CreateCredentialsTest({path: "options.publicKey.rp.id", value: window.location.hostname}).runTest("passing credentials.create() with rpId (hostname)"); new CreateCredentialsTest({path: "options.publicKey.rp.id", value: window.location.hostname}).runTest("passing credentials.create() with rpId (hostname)");
new CreateCredentialsTest({path: "options.publicKey.rp.icon", value: undefined}).runTest("passing credentials.create() without rp.icon"); new CreateCredentialsTest({path: "options.publicKey.rp.icon", value: undefined}).runTest("passing credentials.create() without rp.icon");
......
...@@ -31,6 +31,14 @@ standardSetup(function() { ...@@ -31,6 +31,14 @@ standardSetup(function() {
new GetCredentialsTest("options.publicKey.rpId", "0invaliddomain.com") new GetCredentialsTest("options.publicKey.rpId", "0invaliddomain.com")
.addCredential(credPromise) .addCredential(credPromise)
.runTest("Bad rpId: invalid domain (starts with number)", "SecurityError"); .runTest("Bad rpId: invalid domain (starts with number)", "SecurityError");
let hostAndPort = window.location.host;
if (!hostAndPort.match(/:\d+$/)) {
hostAndPort += ":443";
}
new GetCredentialsTest({path: "options.publicKey.rpId", value: hostAndPort})
.addCredential(credPromise)
.runTest("Bad rpId: host + port", "SecurityError");
}); });
/* JSHINT */ /* JSHINT */
......
...@@ -2,7 +2,6 @@ This is a testharness.js-based test. ...@@ -2,7 +2,6 @@ This is a testharness.js-based test.
PASS passing credentials.get() with default args PASS passing credentials.get() with default args
PASS passing credentials.create() with no timeout PASS passing credentials.create() with no timeout
PASS rpId undefined PASS rpId undefined
FAIL passing credentials.get() with rpId (host and port) promise_test: Unhandled rejection with value: object "SecurityError: The relying party ID is not a registrable domain suffix of, nor equal to the current domain."
PASS passing credentials.get() with rpId (hostname) PASS passing credentials.get() with rpId (hostname)
FAIL no credential specified promise_test: Unhandled rejection with value: object "Error: Attempting list without defining credential to test" FAIL no credential specified promise_test: Unhandled rejection with value: object "Error: Attempting list without defining credential to test"
PASS authenticatorSelection userVerification undefined PASS authenticatorSelection userVerification undefined
......
...@@ -30,9 +30,6 @@ standardSetup(function() { ...@@ -30,9 +30,6 @@ standardSetup(function() {
new GetCredentialsTest({path: "options.publicKey.rpId", value: undefined}) new GetCredentialsTest({path: "options.publicKey.rpId", value: undefined})
.addCredential(credPromise) .addCredential(credPromise)
.runTest("rpId undefined"); .runTest("rpId undefined");
new GetCredentialsTest({path: "options.publicKey.rpId", value: window.location.host})
.addCredential(credPromise)
.runTest("passing credentials.get() with rpId (host and port)");
new GetCredentialsTest({path: "options.publicKey.rpId", value: window.location.hostname}) new GetCredentialsTest({path: "options.publicKey.rpId", value: window.location.hostname})
.addCredential(credPromise) .addCredential(credPromise)
.runTest("passing credentials.get() with rpId (hostname)"); .runTest("passing credentials.get() with rpId (hostname)");
......
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