use of com.spotify.sshagentproxy.Identity in project helios by spotify.
the class AuthenticatingHttpConnectorTest method testOneIdentity_ResponseIsOk.
@Test
public void testOneIdentity_ResponseIsOk() throws Exception {
final AgentProxy proxy = mock(AgentProxy.class);
final Identity identity = mockIdentity();
final AuthenticatingHttpConnector authConnector = createAuthenticatingConnector(Optional.of(proxy), ImmutableList.of(identity));
final String path = "/another/one";
final HttpsURLConnection connection = mock(HttpsURLConnection.class);
when(connector.connect(argThat(matchesAnyEndpoint(path)), eq(method), eq(entity), eq(headers))).thenReturn(connection);
when(connection.getResponseCode()).thenReturn(200);
final URI uri = new URI("https://helios" + path);
authConnector.connect(uri, method, entity, headers);
verify(connector).setExtraHttpsHandler(sshAgentHttpsHandlerWithArgs(USER, proxy, identity));
}
use of com.spotify.sshagentproxy.Identity in project helios by spotify.
the class AuthenticatingHttpConnectorTest method testOneIdentity_ServerReturns502BadGateway.
@Test
public void testOneIdentity_ServerReturns502BadGateway() throws Exception {
final AgentProxy proxy = mock(AgentProxy.class);
final Identity identity = mockIdentity();
final AuthenticatingHttpConnector authConnector = createAuthenticatingConnector(Optional.of(proxy), ImmutableList.of(identity));
final String path = "/foobar";
final HttpsURLConnection connection = mock(HttpsURLConnection.class);
when(connector.connect(argThat(matchesAnyEndpoint(path)), eq(method), eq(entity), eq(headers))).thenReturn(connection);
when(connection.getResponseCode()).thenReturn(502);
final URI uri = new URI("https://helios" + path);
final HttpURLConnection returnedConnection = authConnector.connect(uri, method, entity, headers);
assertSame("If there is only one identity do not expect any additional endpoints to " + "be called after the first returns Unauthorized", returnedConnection, connection);
}
Aggregations