MavenSettings { public static Proxy selectProxy(final Settings settings, final String serverUrl) throws MalformedURLException { return selectProxy(settings, serverUrl, false); } private  MavenSettings(); static Server selectServer(final Settings settings, final String serverId); static Proxy selectProxy(final Settings settings, final String serverUrl); static Proxy selectProxy(final Settings settings, final String serverUrl, final boolean strict); static Server decrypt(final SecDispatcher secDispatcher, final Server server); static Proxy decrypt(final SecDispatcher secDispatcher, final Proxy server);  }
@Test public void proxySelectionNonStrict() throws Exception { final Settings settings = new Settings(); { Proxy httpProxy = new Proxy(); httpProxy.setId("http"); httpProxy.setActive(true); httpProxy.setProtocol("http"); httpProxy.setHost("somehost"); httpProxy.setPort(8080); httpProxy.setNonProxyHosts("localhost"); settings.addProxy(httpProxy); } { Proxy httpProxy = new Proxy(); httpProxy.setId("https"); httpProxy.setActive(true); httpProxy.setProtocol("https"); httpProxy.setHost("somehost"); httpProxy.setPort(8081); httpProxy.setNonProxyHosts("localhost"); settings.addProxy(httpProxy); } { final Proxy proxy = MavenSettings.selectProxy(settings, "http: assertThat(proxy, nullValue()); } { final Proxy proxy = MavenSettings.selectProxy(settings, "http: assertThat(proxy, notNullValue()); assertThat(proxy.getId(), is("http")); } { final Proxy proxy = MavenSettings.selectProxy(settings, "https: assertThat(proxy, notNullValue()); assertThat(proxy.getId(), is("https")); } }
@Test public void proxySelectionNonStrictHttpOnly() throws Exception { final Settings settings = new Settings(); { Proxy httpProxy = new Proxy(); httpProxy.setId("http"); httpProxy.setActive(true); httpProxy.setProtocol("http"); httpProxy.setHost("somehost"); httpProxy.setPort(8080); httpProxy.setNonProxyHosts("localhost"); settings.addProxy(httpProxy); } { final Proxy proxy = MavenSettings.selectProxy(settings, "http: assertThat(proxy, nullValue()); } { final Proxy proxy = MavenSettings.selectProxy(settings, "http: assertThat(proxy, notNullValue()); assertThat(proxy.getId(), is("http")); } { final Proxy proxy = MavenSettings.selectProxy(settings, "https: assertThat(proxy, notNullValue()); assertThat(proxy.getId(), is("http")); } }
@Test public void proxySelectionNonStrictHttpsOnly() throws Exception { final Settings settings = new Settings(); { Proxy httpProxy = new Proxy(); httpProxy.setId("https"); httpProxy.setActive(true); httpProxy.setProtocol("https"); httpProxy.setHost("somehost"); httpProxy.setPort(8081); httpProxy.setNonProxyHosts("localhost"); settings.addProxy(httpProxy); } { final Proxy proxy = MavenSettings.selectProxy(settings, "http: assertThat(proxy, nullValue()); } { final Proxy proxy = MavenSettings.selectProxy(settings, "http: assertThat(proxy, nullValue()); } { final Proxy proxy = MavenSettings.selectProxy(settings, "https: assertThat(proxy, notNullValue()); assertThat(proxy.getId(), is("https")); } }
@Test public void proxySelectionStrict() throws Exception { final Settings settings = new Settings(); { Proxy httpProxy = new Proxy(); httpProxy.setId("http"); httpProxy.setActive(true); httpProxy.setProtocol("http"); httpProxy.setHost("somehost"); httpProxy.setPort(8080); httpProxy.setNonProxyHosts("localhost"); settings.addProxy(httpProxy); } { Proxy httpProxy = new Proxy(); httpProxy.setId("https"); httpProxy.setActive(true); httpProxy.setProtocol("https"); httpProxy.setHost("somehost"); httpProxy.setPort(8081); httpProxy.setNonProxyHosts("localhost"); settings.addProxy(httpProxy); } { final Proxy proxy = MavenSettings.selectProxy(settings, "http: assertThat(proxy, nullValue()); } { final Proxy proxy = MavenSettings.selectProxy(settings, "http: assertThat(proxy, notNullValue()); assertThat(proxy.getId(), is("http")); } { final Proxy proxy = MavenSettings.selectProxy(settings, "https: assertThat(proxy, notNullValue()); assertThat(proxy.getId(), is("https")); } }
@Test public void proxySelectionStrictHttpOnly() throws Exception { final Settings settings = new Settings(); { Proxy httpProxy = new Proxy(); httpProxy.setId("http"); httpProxy.setActive(true); httpProxy.setProtocol("http"); httpProxy.setHost("somehost"); httpProxy.setPort(8080); httpProxy.setNonProxyHosts("localhost"); settings.addProxy(httpProxy); } { final Proxy proxy = MavenSettings.selectProxy(settings, "http: assertThat(proxy, nullValue()); } { final Proxy proxy = MavenSettings.selectProxy(settings, "http: assertThat(proxy, notNullValue()); assertThat(proxy.getId(), is("http")); } { final Proxy proxy = MavenSettings.selectProxy(settings, "https: assertThat(proxy, nullValue()); } }
@Test public void proxySelectionStrictHttpsOnly() throws Exception { final Settings settings = new Settings(); { Proxy httpProxy = new Proxy(); httpProxy.setId("https"); httpProxy.setActive(true); httpProxy.setProtocol("https"); httpProxy.setHost("somehost"); httpProxy.setPort(8081); httpProxy.setNonProxyHosts("localhost"); settings.addProxy(httpProxy); } { final Proxy proxy = MavenSettings.selectProxy(settings, "http: assertThat(proxy, nullValue()); } { final Proxy proxy = MavenSettings.selectProxy(settings, "http: assertThat(proxy, nullValue()); } { final Proxy proxy = MavenSettings.selectProxy(settings, "https: assertThat(proxy, notNullValue()); assertThat(proxy.getId(), is("https")); } }