|
30 | 30 | import org.junit.Test; |
31 | 31 | import org.openqa.selenium.InvalidArgumentException; |
32 | 32 | import org.openqa.selenium.JavascriptExecutor; |
33 | | -import org.openqa.selenium.environment.webserver.Page; |
34 | 33 | import org.openqa.selenium.testing.JUnit4TestBase; |
35 | 34 | import org.openqa.selenium.virtualauthenticator.VirtualAuthenticatorOptions.Protocol; |
36 | 35 |
|
@@ -66,73 +65,14 @@ public class VirtualAuthenticatorTest extends JUnit4TestBase { |
66 | 65 | private final static PKCS8EncodedKeySpec privateKey = |
67 | 66 | new PKCS8EncodedKeySpec(Base64.getMimeDecoder().decode(base64EncodedPK)); |
68 | 67 |
|
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 | | - |
126 | 68 | private JavascriptExecutor jsAwareDriver; |
127 | 69 | private VirtualAuthenticator authenticator; |
128 | 70 |
|
129 | 71 | @Before |
130 | 72 | public void setup() { |
131 | 73 | assumeThat(driver).isInstanceOf(HasVirtualAuthenticator.class); |
132 | 74 | 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")); |
136 | 76 | } |
137 | 77 |
|
138 | 78 | private void createRKEnabledU2FAuthenticator() { |
|
0 commit comments