Skip to content

Commit 26b7f59

Browse files
committed
[java] Update virtual authenticator test to use html test page
1 parent e360535 commit 26b7f59

1 file changed

Lines changed: 1 addition & 61 deletions

File tree

java/test/org/openqa/selenium/virtualauthenticator/VirtualAuthenticatorTest.java

Lines changed: 1 addition & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
import org.junit.Test;
3131
import org.openqa.selenium.InvalidArgumentException;
3232
import org.openqa.selenium.JavascriptExecutor;
33-
import org.openqa.selenium.environment.webserver.Page;
3433
import org.openqa.selenium.testing.JUnit4TestBase;
3534
import org.openqa.selenium.virtualauthenticator.VirtualAuthenticatorOptions.Protocol;
3635

@@ -66,73 +65,14 @@ public class VirtualAuthenticatorTest extends JUnit4TestBase {
6665
private final static PKCS8EncodedKeySpec privateKey =
6766
new PKCS8EncodedKeySpec(Base64.getMimeDecoder().decode(base64EncodedPK));
6867

69-
private final static String script =
70-
"async function registerCredential(options = {}) {"
71-
+ " options = Object.assign({"
72-
+ " authenticatorSelection: {"
73-
+ " requireResidentKey: false,"
74-
+ " },"
75-
+ " rp: {"
76-
+ " id: \"localhost\","
77-
+ " name: \"Selenium WebDriver Test\","
78-
+ " },"
79-
+ " challenge: Int8Array.from(\"challenge\"),"
80-
+ " pubKeyCredParams: ["
81-
+ " {type: \"public-key\", alg: -7},"
82-
+ " ],"
83-
+ " user: {"
84-
+ " name: \"name\","
85-
+ " displayName: \"displayName\","
86-
+ " id: Int8Array.from([1]),"
87-
+ " },"
88-
+ " }, options);"
89-
90-
+ " try {"
91-
+ " const credential = await navigator.credentials.create({publicKey: options});"
92-
+ " return {"
93-
+ " status: \"OK\","
94-
+ " credential: {"
95-
+ " id: credential.id,"
96-
+ " rawId: Array.from(new Int8Array(credential.rawId)),"
97-
+ " transports: credential.response.getTransports(),"
98-
+ " }"
99-
+ " };"
100-
+ " } catch (error) {"
101-
+ " return {status: error.toString()};"
102-
+ " }"
103-
+ "}"
104-
105-
+ "async function getCredential(credentials, options = {}) {"
106-
+ " options = Object.assign({"
107-
+ " challenge: Int8Array.from(\"Winter is Coming\"),"
108-
+ " rpId: \"localhost\","
109-
+ " allowCredentials: credentials,"
110-
+ " userVerification: \"preferred\","
111-
+ " }, options);"
112-
113-
+ " try {"
114-
+ " const attestation = await navigator.credentials.get({publicKey: options});"
115-
+ " return {"
116-
+ " status: \"OK\","
117-
+ " attestation: {"
118-
+ " userHandle: new Int8Array(attestation.response.userHandle),"
119-
+ " },"
120-
+ " };"
121-
+ " } catch (error) {"
122-
+ " return {status: error.toString()};"
123-
+ " }"
124-
+ "}";
125-
12668
private JavascriptExecutor jsAwareDriver;
12769
private VirtualAuthenticator authenticator;
12870

12971
@Before
13072
public void setup() {
13173
assumeThat(driver).isInstanceOf(HasVirtualAuthenticator.class);
13274
jsAwareDriver = (JavascriptExecutor) driver;
133-
driver.get(appServer.create(new Page()
134-
.withTitle("Virtual Authenticator Test")
135-
.withScripts(script)));
75+
driver.get(appServer.whereIs("virtual-authenticator.html"));
13676
}
13777

13878
private void createRKEnabledU2FAuthenticator() {

0 commit comments

Comments
 (0)