use of java.net.Proxy in project bazel by bazelbuild.
the class ProxyHelperTest method testProxyAuth.
@Test
public void testProxyAuth() throws Exception {
Proxy proxy = ProxyHelper.createProxy("http://foo:barbaz@my.example.com");
assertEquals(Proxy.Type.HTTP, proxy.type());
assertThat(proxy.toString()).endsWith(":80");
assertEquals(System.getProperty("http.proxyHost"), "my.example.com");
assertEquals(System.getProperty("http.proxyPort"), "80");
assertEquals(System.getProperty("http.proxyUser"), "foo");
assertEquals(System.getProperty("http.proxyPassword"), "barbaz");
proxy = ProxyHelper.createProxy("https://biz:bat@my.example.com");
assertThat(proxy.toString()).endsWith(":443");
assertEquals(System.getProperty("https.proxyHost"), "my.example.com");
assertEquals(System.getProperty("https.proxyPort"), "443");
assertEquals(System.getProperty("https.proxyUser"), "biz");
assertEquals(System.getProperty("https.proxyPassword"), "bat");
}
use of java.net.Proxy in project bazel by bazelbuild.
the class ProxyHelperTest method testProxyDefaultPort.
@Test
public void testProxyDefaultPort() throws Exception {
Proxy proxy = ProxyHelper.createProxy("http://my.example.com");
assertEquals(Proxy.Type.HTTP, proxy.type());
assertThat(proxy.toString()).endsWith(":80");
assertEquals(System.getProperty("http.proxyHost"), "my.example.com");
assertEquals(System.getProperty("http.proxyPort"), "80");
proxy = ProxyHelper.createProxy("https://my.example.com");
assertThat(proxy.toString()).endsWith(":443");
assertEquals(System.getProperty("https.proxyHost"), "my.example.com");
assertEquals(System.getProperty("https.proxyPort"), "443");
}
use of java.net.Proxy in project bazel by bazelbuild.
the class ProxyHelperTest method testCreateIfNeededHttpsUpperCase.
@Test
public void testCreateIfNeededHttpsUpperCase() throws Exception {
ProxyHelper helper = new ProxyHelper(ImmutableMap.of("HTTPS_PROXY", "https://my.example.com"));
Proxy proxy = helper.createProxyIfNeeded(new URL("https://www.something.com"));
assertThat(proxy.toString()).endsWith("my.example.com:443");
}
use of java.net.Proxy in project bazel by bazelbuild.
the class ProxyHelperTest method testCreateIfNeededHttpLowerCase.
@Test
public void testCreateIfNeededHttpLowerCase() throws Exception {
ProxyHelper helper = new ProxyHelper(ImmutableMap.of("http_proxy", "http://my.example.com"));
Proxy proxy = helper.createProxyIfNeeded(new URL("http://www.something.com"));
assertThat(proxy.toString()).endsWith("my.example.com:80");
}
use of java.net.Proxy in project bazel by bazelbuild.
the class ProxyHelperTest method testEncodedProxyAuth.
@Test
public void testEncodedProxyAuth() throws Exception {
Proxy proxy = ProxyHelper.createProxy("http://foo:b%40rb%40z@my.example.com");
assertEquals(Proxy.Type.HTTP, proxy.type());
assertThat(proxy.toString()).endsWith(":80");
assertEquals(System.getProperty("http.proxyHost"), "my.example.com");
assertEquals(System.getProperty("http.proxyPort"), "80");
assertEquals(System.getProperty("http.proxyUser"), "foo");
assertEquals(System.getProperty("http.proxyPassword"), "b@rb@z");
}
Aggregations