Closed kroegr closed 4 years ago
Good Morning!
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?