Commit 50d5488e authored by Findit's avatar Findit

Revert "webauthn: move create credential tests for residentKey/credProps to WPT"

This reverts commit ee2f8113.

Reason for revert:

Findit (https://goo.gl/kROfz5) identified CL at revision 825930 as the
culprit for flakes in the build cycles as shown on:
https://analysis.chromium.org/p/chromium/flake-portal/analysis/culprit?key=ag9zfmZpbmRpdC1mb3ItbWVyQwsSDEZsYWtlQ3VscHJpdCIxY2hyb21pdW0vZWUyZjgxMTM1MTFjZTRiNzE5YzAwNTA4OTFjMzJjNGZiMWJlMzM2ZAw

Sample Failed Build: https://ci.chromium.org/b/8863960967178909888

Sample Failed Step: blink_web_tests on Mac-10.15

Sample Flaky Test: external/wpt/webauthn/createcredential-resident-key.https.html

Original change's description:
> webauthn: move create credential tests for residentKey/credProps to WPT
> 
> Bug: 1117630
> Change-Id: I2fa4d73b7a4cfe5e7f19fd835cb32e1bb4926d2f
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2508878
> Reviewed-by: Nina Satragno <nsatragno@chromium.org>
> Commit-Queue: Martin Kreichgauer <martinkr@google.com>
> Cr-Commit-Position: refs/heads/master@{#825930}


Change-Id: I54688bd7288995c66a1a361f361e6c1694e1378d
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 1117630
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2531219
Cr-Commit-Position: refs/heads/master@{#826142}
parent 4913c2fe
...@@ -550,56 +550,31 @@ function validateAuthenticatorAssertionResponse(assert) { ...@@ -550,56 +550,31 @@ function validateAuthenticatorAssertionResponse(assert) {
// TODO: parseAuthenticatorData() and make sure flags are correct // TODO: parseAuthenticatorData() and make sure flags are correct
} }
function defaultAuthenticatorArgs() {
return {
protocol: 'ctap1/u2f',
transport: 'usb',
hasResidentKey: false,
hasUserVerification: false,
isUserVerified: false,
};
}
function standardSetup(cb, options = {}) { function standardSetup(cb, options = {}) {
// Setup an automated testing environment if available. // Setup an automated testing environment if available.
let authenticatorArgs = Object.assign(defaultAuthenticatorArgs(), options); let authenticatorArgs = {
window.test_driver.add_virtual_authenticator(authenticatorArgs) protocol: "ctap1/u2f",
.then(authenticator => { transport: "usb",
hasResidentKey: false,
hasUserVerification: false,
isUserVerified: false,
};
extendObject(authenticatorArgs, options);
window.test_driver.add_virtual_authenticator(authenticatorArgs).then(authenticator => {
cb(); cb();
// XXX add a subtest to clean up the virtual authenticator since // XXX add a subtest to clean up the virtual authenticator since
// testharness does not support waiting for promises on cleanup. // testharness does not support waiting for promises on cleanup.
promise_test( promise_test(() => window.test_driver.remove_virtual_authenticator(authenticator),
() => "Clean up the test environment");
window.test_driver.remove_virtual_authenticator(authenticator), }).catch(error => {
'Clean up the test environment'); if (error !== "error: Action add_virtual_authenticator not implemented") {
}) throw error;
.catch(error => {
if (error !==
'error: Action add_virtual_authenticator not implemented') {
throw error;
} }
// The protocol is not available. Continue manually. // The protocol is not available. Continue manually.
cb(); cb();
}); });
} }
// virtualAuthenticatorTest runs |testCb| in a promise_test with a virtual /* JSHINT */
// authenticator set up before and destroyed after the test, if the virtual /* globals promise_rejects_dom, promise_rejects_js, assert_class_string, assert_equals, assert_idl_attribute, assert_readonly, promise_test */
// testing API is available. In manual tests, setup and teardown is skipped. /* exported standardSetup, CreateCredentialsTest, GetCredentialsTest */
function virtualAuthenticatorTest(
testCb, options = {}, name = 'Virtual Authenticator Test') {
let authenticatorArgs = Object.assign(defaultAuthenticatorArgs(), options);
promise_test(async t => {
try {
let authenticator =
await window.test_driver.add_virtual_authenticator(authenticatorArgs);
t.add_cleanup(
() => window.test_driver.remove_virtual_authenticator(authenticator));
} catch (error) {
if (error !== 'error: Action add_virtual_authenticator not implemented') {
throw error;
}
}
testCb(t);
}, name);
}
<!DOCTYPE html> <!DOCTYPE html>
<html> <title>Credential Manager: End-to-end tests for create(), exercising creation of resident keys on virtual authenticators.</title>
<head> <script src="../resources/testharness.js"></script>
<meta charset="utf-8"> <script src="../resources/testharnessreport.js"></script>
<title>navigator.credentials.create() test with residentKey and credProps</title> <script src="/gen/layout_test_data/mojo/public/js/mojo_bindings_lite.js"></script>
<meta name="timeout" content="long"> <script src="/gen/mojo/public/mojom/base/time.mojom-lite.js"></script>
<script src="/resources/testharness.js"></script> <script src="/gen/url/mojom/url.mojom-lite.js"></script>
<script src="/resources/testharnessreport.js"></script> <script src="/gen/third_party/blink/public/mojom/webauthn/authenticator.mojom-lite.js"></script>
<script src="/resources/testdriver.js"></script> <script src="/gen/third_party/blink/public/mojom/webauthn/virtual_authenticator.mojom-lite.js"></script>
<script src="/resources/testdriver-vendor.js"></script> <script src="resources/test-inputs.js"></script>
<script src=helpers.js></script> <script src="resources/virtual-navigator-credentials.js"></script>
<body>
<script> <script>
"use strict"; if (document.location.host != "subdomain.example.test:8443") {
document.location = "https://subdomain.example.test:8443/credentialmanager/credentialscontainer-create-with-resident-keys.html";
promise_test(_ => new Promise(_ => {}), "Stall tests on the wrong host.");
}
const credPropsTests = [ const credPropsTests = [
{ {
name: "U2F", name: "U2F",
authenticatorArgs: { authenticatorArgs: {
protocol: "ctap1/u2f", protocol: blink.test.mojom.ClientToAuthenticatorProtocol.U2F,
}, },
expected: { expected: {
discouraged: { discouraged: {
...@@ -37,10 +42,9 @@ const credPropsTests = [ ...@@ -37,10 +42,9 @@ const credPropsTests = [
{ {
name: "CTAP 2.0 without resident key support", name: "CTAP 2.0 without resident key support",
authenticatorArgs: { authenticatorArgs: {
protocol: "ctap2", protocol: blink.test.mojom.ClientToAuthenticatorProtocol.CTAP2,
ctap2Version: blink.test.mojom.Ctap2Version.CTAP2_0,
hasResidentKey: false, hasResidentKey: false,
hasUserVerification: true,
isUserVerified: true,
}, },
expected: { expected: {
discouraged: { discouraged: {
...@@ -61,16 +65,14 @@ const credPropsTests = [ ...@@ -61,16 +65,14 @@ const credPropsTests = [
{ {
name: "CTAP 2.0 with resident key support", name: "CTAP 2.0 with resident key support",
authenticatorArgs: { authenticatorArgs: {
protocol: "ctap2", protocol: blink.test.mojom.ClientToAuthenticatorProtocol.CTAP2,
ctap2Version: blink.test.mojom.Ctap2Version.CTAP2_0,
hasResidentKey: true, hasResidentKey: true,
hasUserVerification: true,
isUserVerified: true,
}, },
expected: { expected: {
discouraged: { discouraged: {
success: true, success: true,
// CTAP2.0 authenticators may treat all credentials as discoverable, // CTAP2.0 authenticators may treat all credentials as discoverable, thus Chrome omits 'rk' in this case.
// thus Chrome omits 'rk' in this case.
hasRk: false, hasRk: false,
}, },
preferred: { preferred: {
...@@ -88,10 +90,9 @@ const credPropsTests = [ ...@@ -88,10 +90,9 @@ const credPropsTests = [
{ {
name: "CTAP 2.1 without resident key support", name: "CTAP 2.1 without resident key support",
authenticatorArgs: { authenticatorArgs: {
protocol: "ctap2_1", protocol: blink.test.mojom.ClientToAuthenticatorProtocol.CTAP2,
ctap2Version: blink.test.mojom.Ctap2Version.CTAP2_1,
hasResidentKey: false, hasResidentKey: false,
hasUserVerification: true,
isUserVerified: true,
}, },
expected: { expected: {
discouraged: { discouraged: {
...@@ -112,10 +113,9 @@ const credPropsTests = [ ...@@ -112,10 +113,9 @@ const credPropsTests = [
{ {
name: "CTAP 2.1 with resident key support", name: "CTAP 2.1 with resident key support",
authenticatorArgs: { authenticatorArgs: {
protocol: "ctap2_1", protocol: blink.test.mojom.ClientToAuthenticatorProtocol.CTAP2,
ctap2Version: blink.test.mojom.Ctap2Version.CTAP2_1,
hasResidentKey: true, hasResidentKey: true,
hasUserVerification: true,
isUserVerified: true,
}, },
expected: { expected: {
discouraged: { discouraged: {
...@@ -138,41 +138,32 @@ const credPropsTests = [ ...@@ -138,41 +138,32 @@ const credPropsTests = [
]; ];
for (const fixture of credPropsTests) { for (const fixture of credPropsTests) {
for (const rkRequirement of ["discouraged", "preferred", "required"]) { authenticatorSetup(fixture.name, () => {
virtualAuthenticatorTest(async t => { for (const rkRequirement of ["discouraged", "preferred", "required"]) {
const promise = createCredential({ promise_test(async t => {
options: { var customMakeCredOptions = deepCopy(MAKE_CREDENTIAL_OPTIONS);
publicKey: { customMakeCredOptions.extensions = {credProps: true};
authenticatorSelection: {
residentKey: rkRequirement,
},
extensions: {
credProps: true,
},
},
},
});
assert_true(rkRequirement in fixture.expected); customMakeCredOptions.authenticatorSelection.residentKey = rkRequirement;
const expected = fixture.expected[rkRequirement]; const promise = navigator.credentials.create({publicKey: customMakeCredOptions});
assert_true('success' in expected);
if (!expected.success) {
return promise_rejects_dom(t, "NotAllowedError", promise);
}
const cred = await promise; assert_true(rkRequirement in fixture.expected);
assert_true('credProps' in cred.getClientExtensionResults()); const expected = fixture.expected[rkRequirement];
const credProps = cred.getClientExtensionResults().credProps; assert_true('success' in expected);
assert_equals('rk' in credProps, expected.hasRk, "hasRk"); if (!expected.success) {
if (expected.hasRk) { return promise_rejects_dom(t, "NotAllowedError", promise);
assert_equals(credProps.rk, expected.rk, "rk"); }
}
}, fixture.authenticatorArgs, fixture.name const cred = await promise;
+ ": navigator.credentials.create() with credProps extension, rk=" assert_true('credProps' in cred.getClientExtensionResults());
+ rkRequirement); const credProps = cred.getClientExtensionResults().credProps;
} assert_equals('rk' in credProps, expected.hasRk, "hasRk");
if (expected.hasRk) {
assert_equals(credProps.rk, expected.rk, "rk");
}
}, fixture.name + ": navigator.credentials.create() with credProps extension, rk=" + rkRequirement);
}
}, fixture.authenticatorArgs);
} }
</script> </script>
</head>
<body></body>
</html>
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