mirror of
https://github.com/microsoft/playwright-java.git
synced 2025-12-28 02:15:15 +00:00
fix: add pfxBase64 to jsonCert instead of params (#1746)
This commit is contained in:
parent
87152ecc71
commit
995cf902fb
@ -434,7 +434,7 @@ public class Utils {
|
||||
}
|
||||
String pfxBase64 = base64Buffer(cert.pfx, cert.pfxPath);
|
||||
if (pfxBase64 != null) {
|
||||
params.addProperty("pfx", pfxBase64);
|
||||
jsonCert.addProperty("pfx", pfxBase64);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new PlaywrightException("Failed to read from file", e);
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
package com.microsoft.playwright;
|
||||
|
||||
import com.microsoft.playwright.options.ClientCertificate;
|
||||
import com.microsoft.playwright.options.Proxy;
|
||||
import org.junit.jupiter.api.AfterAll;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
@ -120,6 +119,25 @@ public class TestClientCertificates extends TestBase {
|
||||
request.dispose();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void passWithTrustedClientCertificatesPfx() {
|
||||
APIRequest.NewContextOptions requestOptions = new APIRequest.NewContextOptions()
|
||||
.setIgnoreHTTPSErrors(true) // TODO: remove once we can pass a custom CA.
|
||||
.setClientCertificates(asList(
|
||||
new ClientCertificate(customServer.origin)
|
||||
.setPfxPath(asset("client-certificates/client/trusted/client_keystore.p12"))
|
||||
.setPassphrase("passphrase")));
|
||||
|
||||
APIRequestContext request = playwright.request().newContext(requestOptions);
|
||||
APIResponse response = request.get(customServer.url);
|
||||
|
||||
assertEquals(customServer.url, response.url());
|
||||
assertEquals(200, response.status());
|
||||
assertTrue(response.text().contains("Hello CN=Alice, your certificate was issued by O=Client Certificate Demo,CN=localhost!"), response.text());
|
||||
|
||||
request.dispose();
|
||||
}
|
||||
|
||||
static boolean isWebKitMacOS() {
|
||||
return isWebKit() && isMac;
|
||||
}
|
||||
|
||||
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user