-
Notifications
You must be signed in to change notification settings - Fork 21
Relay the Java networking system properties to sub-processes to support proxy servers #17
Conversation
This will make available to the sub-processes the same properties that were defined in the parent process.
|
||
Assert.assertEquals(1, commands.size()); | ||
Assert.assertEquals("-Dhttp.proxyHost=192.0.2.42", commands.get(0)); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps it's worth adding a test for all supported properties to catch any changes to the supported set.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure I understand the suggestion. Do you mean we add a copy of the contents of NETWORKING_PROPERTY_NAMES
in a unit test that asserts that NETWORKING_PROPERTY_NAMES
is equal to the copy?
I think I'd rather craft an integration test that uses org.littleshoot:littleproxy:1.1.0-beta1
like the test I added in tfs-plugin that sets up a proxy server, connects to a remote host and then asserts that the proxy server was used. What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
craft an integration test that uses org.littleshoot:littleproxy:1.1.0-beta1 like the test I added in tfs-plugin that sets up a proxy server, connects to a remote host and then asserts that the proxy server was used
I'll be implementing this; please hold off on merging until I follow up.
Thanks!
- Oli
This avoids the chance of conflict if a workstation already had 8089 or 9443 bound to something else (which I did).
I originally wrote this class for jenkinsci/tfs-plugin and I need it pretty much as-is for this project, as well.
The browser pop-up should connect through littleproxy to reach WireMock, which is verified via proxyWasUsed().
54477cd
to
9a3098f
Compare
I was able to add two positive tests (they assert that the proxy server was indeed used) and I couldn't get a negative test going (configures the proxy, but turns it off, which should cause requests to fail), maybe because the JavaFX browser decides to try connecting directly if the proxy server isn't responding. |
Add support for unauthenticated proxy servers This is done by relaying the Java networking system properties to sub-processes created for launching the web browsers.
Summary
Without these changes, a program using this component would open a web browser that would not follow the same proxy server configuration as the program and thus would be unable to complete the OAuth 2.0 Authorization Code Flow when access to the authorization endpoint needed to be performed through a proxy server. This is because oauth2-useragent uses sub-processes to launch web browsers and the network-related configuration of the parent process was not propagated to the child processes.
This pull request propagates the values of networking-related system properties to the sub-processes such that if the main program can reach resources through a proxy server, so will the web browsers used for OAuth 2.0 flows.
Manual testing
192.168.0.117
. It's listening on all interfaces at port8123
.Copy the SNAPSHOT build of GCM4ML containing these oauth2-useragent changes and configure Git to point to that version, enabling debug mode by setting
-Ddebug=true
.Configure the networking to prevent being able to reach web servers without going through a proxy server.
003 Router
option and then renewing the lease.wget
yieldsNetwork is unreachable
orNo route to host
.Clear or invalidate the saved credentials (if any) for the VSTS account, to force authentication.
insecureStore.xml
toinsecureStore.xml.old
.Run a
git clone
against a Git repo in the VSTS account.Configure Git to use our proxy server by running:
Try the
git clone
again.The GCM4ML emits the following:
...which means it's unable to reach VSTS and so Git falls back to prompting for credentials.
Update the
credential.helper
configuration to include the following:Try the
git clone
again.server has reponded
and the web browser is popped up to complete the authentication. ✅Complete the authentication and notice the
git clone
succeeding.Windows & Linux (Oracle documents this setting as only being available "[on] recent Windows systems and on Gnome 2.x systems")
Update the
credential.helper
configuration to replace the twohttps.proxy*
properties with the following:Configure the proxy server for the operating system.
Clear or invalidate the saved credentials for the VSTS account, to force authentication.
Run
git fetch
inside the local copy of the Git repository.Clear the proxy server configuration for the operating system.
Undo the Git
http.proxy
configuration.Undo the networking configuration, so as to restore direct access to web servers.
Mission accomplished!