Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for creating and removing virtual authenticators (#7760)
This patch adds support for the Virtual Authenticators WebDriver API, allowing developers to write E2E tests that exercise the WebAuthn API. At the moment, the API is only supported on Chrome 79 onwards. Fixes #7753 [1] https://w3c.github.io/webauthn#sctn-automation
- Loading branch information
Showing
10 changed files
with
350 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
java/client/src/org/openqa/selenium/virtualauthenticator/HasVirtualAuthenticator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// Licensed to the Software Freedom Conservancy (SFC) under one | ||
// or more contributor license agreements. See the NOTICE file | ||
// distributed with this work for additional information | ||
// regarding copyright ownership. The SFC licenses this file | ||
// to you under the Apache License, Version 2.0 (the | ||
// "License"); you may not use this file except in compliance | ||
// with the License. You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, | ||
// software distributed under the License is distributed on an | ||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
// KIND, either express or implied. See the License for the | ||
// specific language governing permissions and limitations | ||
// under the License. | ||
|
||
package org.openqa.selenium.virtualauthenticator; | ||
|
||
import org.openqa.selenium.virtualauthenticator.VirtualAuthenticator; | ||
import org.openqa.selenium.virtualauthenticator.VirtualAuthenticatorOptions; | ||
|
||
/** | ||
* Interface implemented by each driver that allows access to the virtual authenticator API. | ||
*/ | ||
public interface HasVirtualAuthenticator { | ||
public VirtualAuthenticator addVirtualAuthenticator(VirtualAuthenticatorOptions options); | ||
|
||
public void removeVirtualAuthenticator(VirtualAuthenticator authenticator); | ||
} |
36 changes: 36 additions & 0 deletions
36
java/client/src/org/openqa/selenium/virtualauthenticator/VirtualAuthenticator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// Licensed to the Software Freedom Conservancy (SFC) under one | ||
// or more contributor license agreements. See the NOTICE file | ||
// distributed with this work for additional information | ||
// regarding copyright ownership. The SFC licenses this file | ||
// to you under the Apache License, Version 2.0 (the | ||
// "License"); you may not use this file except in compliance | ||
// with the License. You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, | ||
// software distributed under the License is distributed on an | ||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
// KIND, either express or implied. See the License for the | ||
// specific language governing permissions and limitations | ||
// under the License. | ||
|
||
package org.openqa.selenium.virtualauthenticator; | ||
|
||
import java.util.Objects; | ||
|
||
/** | ||
* Represents a virtual authenticator. | ||
*/ | ||
public class VirtualAuthenticator { | ||
|
||
private final String id; | ||
|
||
public VirtualAuthenticator(final String id) { | ||
this.id = Objects.requireNonNull(id); | ||
} | ||
|
||
public String getId() { | ||
return id; | ||
} | ||
} |
102 changes: 102 additions & 0 deletions
102
java/client/src/org/openqa/selenium/virtualauthenticator/VirtualAuthenticatorOptions.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
// Licensed to the Software Freedom Conservancy (SFC) under one | ||
// or more contributor license agreements. See the NOTICE file | ||
// distributed with this work for additional information | ||
// regarding copyright ownership. The SFC licenses this file | ||
// to you under the Apache License, Version 2.0 (the | ||
// "License"); you may not use this file except in compliance | ||
// with the License. You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, | ||
// software distributed under the License is distributed on an | ||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
// KIND, either express or implied. See the License for the | ||
// specific language governing permissions and limitations | ||
// under the License. | ||
|
||
package org.openqa.selenium.virtualauthenticator; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
/** | ||
* Options for the creation of virtual authenticators. | ||
* @see http://w3c.github.io/webauthn/#sctn-automation | ||
*/ | ||
public class VirtualAuthenticatorOptions { | ||
|
||
enum Protocol { | ||
CTAP2("ctap2"), | ||
U2F("ctap1/u2f"); | ||
|
||
public final String id; | ||
|
||
private Protocol(String id) { | ||
this.id = id; | ||
} | ||
} | ||
|
||
enum Transport { | ||
BLE("ble"), | ||
INTERNAL("internal"), | ||
NFC("nfc"), | ||
USB("usb"); | ||
|
||
public final String id; | ||
|
||
private Transport(String id) { | ||
this.id = id; | ||
} | ||
} | ||
|
||
private Protocol protocol = Protocol.CTAP2; | ||
private Transport transport = Transport.USB; | ||
private boolean hasResidentKey = false; | ||
private boolean hasUserVerification = false; | ||
private boolean isUserConsenting = true; | ||
private boolean isUserVerified = false; | ||
|
||
public VirtualAuthenticatorOptions() { } | ||
|
||
public VirtualAuthenticatorOptions setProtocol(Protocol protocol) { | ||
this.protocol = protocol; | ||
return this; | ||
} | ||
|
||
public VirtualAuthenticatorOptions setTransport(Transport transport) { | ||
this.transport = transport; | ||
return this; | ||
} | ||
|
||
public VirtualAuthenticatorOptions setHasResidentKey(boolean hasResidentKey) { | ||
this.hasResidentKey = hasResidentKey; | ||
return this; | ||
} | ||
|
||
public VirtualAuthenticatorOptions setHasUserVerification(boolean hasUserVerification) { | ||
this.hasUserVerification = hasUserVerification; | ||
return this; | ||
} | ||
|
||
public VirtualAuthenticatorOptions setIsUserConsenting(boolean isUserConsenting) { | ||
this.isUserConsenting = isUserConsenting; | ||
return this; | ||
} | ||
|
||
public VirtualAuthenticatorOptions setIsUserVerified(boolean isUserVerified) { | ||
this.isUserVerified = isUserVerified; | ||
return this; | ||
} | ||
|
||
public Map<String, Object> toMap() { | ||
HashMap<String, Object> map = new HashMap(); | ||
map.put("protocol", protocol.id); | ||
map.put("transport", transport.id); | ||
map.put("hasResidentKey", hasResidentKey); | ||
map.put("hasUserVerification", hasUserVerification); | ||
map.put("isUserConsenting", isUserConsenting); | ||
map.put("isUserVerified", isUserVerified); | ||
return map; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
java/client/test/org/openqa/selenium/virtualauthenticator/BUILD.bazel
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
load("@rules_jvm_external//:defs.bzl", "artifact") | ||
load("//java:defs.bzl", "java_selenium_test_suite") | ||
|
||
java_selenium_test_suite( | ||
name = "LargeTests", | ||
size = "large", | ||
srcs = glob(["*.java"]), | ||
browsers = ["chrome", "edge", "ie", "safari"], | ||
deps = [ | ||
"//java/client/src/org/openqa/selenium:core", | ||
"//java/client/src/org/openqa/selenium/remote", | ||
"//java/client/test/org/openqa/selenium/environment", | ||
"//java/client/test/org/openqa/selenium/testing:annotations", | ||
"//java/client/test/org/openqa/selenium/testing:test-base", | ||
"//java/client/test/org/openqa/selenium/testing/drivers", | ||
artifact("junit:junit"), | ||
artifact("org.assertj:assertj-core"), | ||
], | ||
) |
Oops, something went wrong.