Closed occupant23 closed 4 years ago
Implementation proposal (PoC level):
<dependency>
<groupId>com.browserup</groupId>
<artifactId>browserup-proxy-core</artifactId>
<version>2.0.1</version>
</dependency>
package com.xceptance.neodymium.tests;
import java.io.File;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.openqa.selenium.Proxy;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import com.browserup.bup.BrowserUpProxy;
import com.browserup.bup.BrowserUpProxyServer;
import com.browserup.bup.client.ClientUtil;
import com.browserup.bup.mitm.KeyStoreFileCertificateSource;
import com.browserup.bup.mitm.manager.ImpersonatingMitmManager;
import com.xceptance.neodymium.NeodymiumRunner;
@RunWith(NeodymiumRunner.class)
public class DevTest
{
@Test
public void testSomething() throws Exception
{
KeyStoreFileCertificateSource fileCertificateSource = new KeyStoreFileCertificateSource("PKCS12", new File("./config/Certificates.p12"), "MitmProxy", "xceptance");
ImpersonatingMitmManager mitmManager = ImpersonatingMitmManager.builder().rootCertificateSource(fileCertificateSource).build();
BrowserUpProxy proxy = new BrowserUpProxyServer();
proxy.setMitmManager(mitmManager);
proxy.start();
// get the Selenium proxy object
Proxy seleniumProxy = ClientUtil.createSeleniumProxy(proxy);
// configure it as a desired capability
ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.setAcceptInsecureCerts(true);
chromeOptions.addArguments("-ignore-certificate-errors");
chromeOptions.setProxy(seleniumProxy);
// start the browser up
WebDriver driver = new ChromeDriver(chromeOptions);
proxy.autoAuthorization(domain, user, password, AuthType.BASIC);
driver.get("http://" + domain);
try
{
Thread.sleep(5000);
}
catch (InterruptedException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
driver.quit();
Assert.assertTrue(true);
}
}
Created follow up ticket to conclude this topic with the next version #117
Some modern browsers deprecate the usage of a Basic Authentication via URL. On the other side prevents/lacks the WebDriver spec any other method of passing the authentication credentials.
Recheck: https://github.com/w3c/webdriver/issues/385