@Test public void intercept_portInAuthority() throws Exception { when(chain.request()).thenReturn(new Request.Builder() .url("https://foo.com:123/foo/bar?baz=norf") .method("GET", null) .build()); interceptor.intercept(chain); verify(chain).proceed(request.capture()); assertThat(request.getValue().url()).isEqualTo(HttpUrl.parse("https://localhost:456/foo/bar?baz=norf")); assertThat(request.getValue().header(HttpHeaders.HOST)).isEqualTo("foo.com:123"); }
@Before public void before() throws Exception { MockitoAnnotations.initMocks(this); interceptor = new MeshProxyInterceptor(HostAndPort.fromString("localhost:456")); }
if (config.meshProxy().isPresent()) { client.addInterceptor(new MeshProxyInterceptor(config.meshProxy().get())); } else { switch (config.nodeSelectionStrategy()) {
if (config.meshProxy().isPresent()) { client.addInterceptor(new MeshProxyInterceptor(config.meshProxy().get())); } else { switch (config.nodeSelectionStrategy()) {
@Test public void intercept_portNotInAuthority() throws Exception { when(chain.request()).thenReturn(new Request.Builder() .url("https://foo.com/foo/bar?baz=norf") .method("GET", null) .build()); interceptor.intercept(chain); verify(chain).proceed(request.capture()); assertThat(request.getValue().url()).isEqualTo(HttpUrl.parse("https://localhost:456/foo/bar?baz=norf")); assertThat(request.getValue().header(HttpHeaders.HOST)).isEqualTo("foo.com"); }
@Test public void intercept_stripsUserinfoFromAuthority() throws Exception { when(chain.request()).thenReturn(new Request.Builder() .url("https://user:pass@foo.com/foo/bar?baz=norf") .method("GET", null) .build()); interceptor.intercept(chain); verify(chain).proceed(request.capture()); assertThat(request.getValue().url()).isEqualTo(HttpUrl.parse("https://user:pass@localhost:456/foo/bar?baz=norf")); assertThat(request.getValue().header(HttpHeaders.HOST)).isEqualTo("foo.com"); } }