Commit 65619dbb authored by Nina Satragno's avatar Nina Satragno Committed by Commit Bot

[chromedriver] Alias ctap1/u2f to u2f on AddVirtualAuthenticator

The spec says the protocol identifier is the string "ctap1/u2f" [1], but
the devtools protocol definition does not support slashes on enums.

[1] https://w3c.github.io/webauthn/#authenticator-configuration

Bug: 922572
Change-Id: Ide12cac53eadbac4260924c86bf0ad1d612b4c1e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1842172
Auto-Submit: Nina Satragno <nsatragno@chromium.org>
Commit-Queue: John Chen <johnchen@chromium.org>
Reviewed-by: default avatarJohn Chen <johnchen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#702990}
parent 3482de63
......@@ -2445,7 +2445,7 @@ class ChromeDriverSecureContextTest(ChromeDriverBaseTestWithWebServer):
self._driver.Load(self.GetHttpsUrlForFile(
'/chromedriver/webauthn_test.html', 'chromedriver.test'))
self._driver.AddVirtualAuthenticator(
protocol = 'ctap2',
protocol = 'ctap1/u2f',
transport = 'usb',
)
result = self._driver.ExecuteAsyncScript(script)
......
......@@ -102,19 +102,25 @@ Status ExecuteWebAuthnCommand(const WebAuthnCommand& command,
Status ExecuteAddVirtualAuthenticator(WebView* web_view,
const base::Value& params,
std::unique_ptr<base::Value>* value) {
return web_view->SendCommandAndGetResult(
"WebAuthn.addVirtualAuthenticator",
MapParams(
{
{"options.protocol", "protocol"},
{"options.transport", "transport"},
{"options.hasResidentKey", "hasResidentKey"},
{"options.hasUserVerification", "hasUserVerification"},
{"options.automaticPresenceSimulation", "isUserConsenting"},
{"options.isUserVerified", "isUserVerified"},
},
params),
value);
base::DictionaryValue mapped_params = MapParams(
{
{"options.protocol", "protocol"},
{"options.transport", "transport"},
{"options.hasResidentKey", "hasResidentKey"},
{"options.hasUserVerification", "hasUserVerification"},
{"options.automaticPresenceSimulation", "isUserConsenting"},
{"options.isUserVerified", "isUserVerified"},
},
params);
// The spec calls u2f "ctap1/u2f", convert the value here since devtools does
// not support slashes on enums.
std::string* protocol = mapped_params.FindStringPath("options.protocol");
if (protocol && *protocol == "ctap1/u2f")
*protocol = "u2f";
return web_view->SendCommandAndGetResult("WebAuthn.addVirtualAuthenticator",
std::move(mapped_params), value);
}
Status ExecuteRemoveVirtualAuthenticator(WebView* web_view,
......
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