use of aQute.bnd.connection.settings.ProxyDTO in project bnd by bndtools.
the class HttpClientProxyTest method assertSocks5Proxy.
@SuppressWarnings("resource")
void assertSocks5Proxy(String password, boolean authenticationCalled) throws MalformedURLException, Exception {
Processor p = new Processor();
p.setProperty("-connectionsettings", "" + false);
HttpClient hc = new HttpClient();
ConnectionSettings cs = new ConnectionSettings(p, hc);
if (socks5Proxy != null) {
ProxyDTO proxy = new ProxyDTO();
proxy.active = true;
proxy.host = "localhost";
proxy.port = socksProxyPort;
proxy.protocol = Type.SOCKS;
if (password != null) {
proxy.username = "proxyuser";
proxy.password = password;
}
hc.addProxyHandler(ConnectionSettings.createProxyHandler(proxy));
}
ServerDTO server = new ServerDTO();
server.id = httpTestServer.getBaseURI().toString();
server.verify = false;
server.trust = Strings.join(httpTestServer.getTrustedCertificateFiles(IO.getFile("generated")));
cs.add(server);
URL url = new URL(httpTestServer.getBaseURI() + "/get-tag/ABCDEFGH");
TaggedData tag = hc.connectTagged(url);
assertNotNull(tag);
assertEquals("ABCDEFGH", tag.getTag());
String s = IO.collect(tag.getInputStream());
assertNotNull(s);
assertTrue(s.trim().startsWith("{"));
// assertTrue(this.authenticationCalled.get() == authenticationCalled);
}
use of aQute.bnd.connection.settings.ProxyDTO in project bnd by bndtools.
the class HttpClientProxyTest method assertHttpProxy.
@SuppressWarnings("resource")
void assertHttpProxy(String password, boolean authenticationCalled) throws MalformedURLException, Exception {
Processor p = new Processor();
p.setProperty("-connectionsettings", "" + false);
HttpClient hc = new HttpClient();
ConnectionSettings cs = new ConnectionSettings(p, hc);
if (httpProxy != null) {
ProxyDTO proxy = new ProxyDTO();
proxy.active = true;
proxy.host = "localhost";
proxy.port = httpProxyPort;
proxy.protocol = Type.HTTP;
if (password != null) {
proxy.username = "proxyuser";
proxy.password = password;
}
hc.addProxyHandler(ConnectionSettings.createProxyHandler(proxy));
}
ServerDTO server = new ServerDTO();
server.id = httpTestServer.getBaseURI().toString();
server.verify = false;
server.trust = Strings.join(httpTestServer.getTrustedCertificateFiles(IO.getFile("generated")));
cs.add(server);
URL url = new URL(httpTestServer.getBaseURI() + "/get-tag/ABCDEFGH");
TaggedData tag = hc.connectTagged(url);
assertNotNull(tag);
if (tag.getState() != State.OTHER)
assertEquals("ABCDEFGH", tag.getTag());
String s = IO.collect(tag.getInputStream());
assertNotNull(s);
assertTrue(s.trim().startsWith("{"));
assertTrue(this.authenticationCalled.get() == authenticationCalled);
}
use of aQute.bnd.connection.settings.ProxyDTO in project bnd by bndtools.
the class SettingsParserTest method testSocksAuth.
public void testSocksAuth() throws Exception {
SettingsDTO settings = getSettings("socks-auth.xml");
assertEquals(1, settings.proxies.size());
ProxyDTO p = settings.proxies.get(0);
assertEquals("myproxy", p.id);
assertEquals(true, p.active);
assertEquals(Type.SOCKS, p.protocol);
assertEquals(1080, p.port);
assertEquals(null, p.nonProxyHosts);
assertEquals("proxyuser", p.username);
assertEquals("somepassword", p.password);
}
use of aQute.bnd.connection.settings.ProxyDTO in project bnd by bndtools.
the class SettingsParserTest method testSocksNoAuth.
public void testSocksNoAuth() throws Exception {
SettingsDTO settings = getSettings("socks-noauth.xml");
assertEquals(1, settings.proxies.size());
ProxyDTO p = settings.proxies.get(0);
assertEquals("myproxy", p.id);
assertEquals(true, p.active);
assertEquals(Type.SOCKS, p.protocol);
assertEquals(1080, p.port);
assertEquals(null, p.nonProxyHosts);
assertEquals(null, p.username);
assertEquals(null, p.password);
}
use of aQute.bnd.connection.settings.ProxyDTO in project bnd by bndtools.
the class SettingsParserTest method testNonProxyHost.
public void testNonProxyHost() throws Exception {
SettingsDTO settings = getSettings("socks-auth-nonproxyhosts.xml");
assertEquals(1, settings.proxies.size());
ProxyDTO p = settings.proxies.get(0);
assertEquals("myproxy", p.id);
assertEquals(true, p.active);
assertEquals(Type.SOCKS, p.protocol);
assertEquals(1080, p.port);
assertEquals("*.google.com|ibiblio.org", p.nonProxyHosts);
assertEquals(null, p.username);
assertEquals(null, p.password);
}
Aggregations