You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I want to start the automated tests on localhost against my local system to check that the tests still green/functional after working on it.
The Webapplication is a Single-Page-Application and for security-reasons are HTTP-Header injected by a thirdparty-proxy for authentication. For the automated tests I use browserup-proxy to emulate that thirdparty-proxy and inject the HTTP-Header with the needed values for testing.
When I run the test locally against the DEV- or TEST-Stage, the proxy on localhost is working as expected - the header wil be injected.
When I run the test locally against my local environment, the proxy on localhost is not working as expected - there will be no headers set.
Here is the code for the configuration of the proxy:
BrowserUpProxy proxy = new BrowserUpProxyServer();
proxy.start();
Proxy seleniumProxy = ClientUtil.createSeleniumProxy(proxy);
// put our custom header to each request
proxy.addRequestFilter((request, contents, messageInfo) -> {
if (Host.isApiUrl(messageInfo.getUrl())) {
request.headers().add("x-protect-authorization-user", "any_user");
}
System.err.println(messageInfo.getUrl());
System.out.println(request.headers().entries().toString());
return null;
});
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(CapabilityType.PROXY, seleniumProxy);
String proxyOption = "--proxy-server=" + seleniumProxy.getHttpProxy();
options.addArguments(proxyOption);
options.setCapability(CapabilityType.PROXY, seleniumProxy);
On localhost against localhost the method proxy.addRequestFilter is not called, only on urls != localhost.
Versions that I am using:
com.browserup.browserup-proxy-core 2.1.0
org.seleniumhq.selenium.selenium-java 3.141.59
geckodriver 0.26.0
If more informations are needed or missing, please let me know.
What I have asked me: Is it even possible to run a proxy and the application under test on the same host or is this conflicting with the behavior of a proxy?
The text was updated successfully, but these errors were encountered:
I have found the solution, it's not a problem or bug with the proxy or anything else.
Firefox/geckodriver is per default configured to not allow any proxy hijack anything on localhost. It's possible to allow that.
FirefoxOptions options = new FirefoxOptions();
options.setHeadless(true);
FirefoxProfile p = new FirefoxProfile();
p.setPreference("network.proxy.allow_hijacking_localhost", true);
options.setProfile(p);
options.setLogLevel(FirefoxDriverLogLevel.INFO);
driver = new FirefoxDriver(options);
I want to start the automated tests on localhost against my local system to check that the tests still green/functional after working on it.
The Webapplication is a Single-Page-Application and for security-reasons are HTTP-Header injected by a thirdparty-proxy for authentication. For the automated tests I use browserup-proxy to emulate that thirdparty-proxy and inject the HTTP-Header with the needed values for testing.
When I run the test locally against the DEV- or TEST-Stage, the proxy on localhost is working as expected - the header wil be injected.
When I run the test locally against my local environment, the proxy on localhost is not working as expected - there will be no headers set.
Here is the code for the configuration of the proxy:
On localhost against localhost the method proxy.addRequestFilter is not called, only on urls != localhost.
Versions that I am using:
com.browserup.browserup-proxy-core 2.1.0
org.seleniumhq.selenium.selenium-java 3.141.59
geckodriver 0.26.0
If more informations are needed or missing, please let me know.
What I have asked me: Is it even possible to run a proxy and the application under test on the same host or is this conflicting with the behavior of a proxy?
The text was updated successfully, but these errors were encountered: