use of com.oracle.bedrock.runtime.remote.http.HttpBasedAuthentication in project oracle-bedrock by coherence-community.
the class SoapConnectionTest method shouldOpenAuthenticatedConnection.
@Test
public void shouldOpenAuthenticatedConnection() throws Exception {
URL url = new URL("http://oracle.com:80/foo");
Envelope envelope = mock(Envelope.class);
String useName = "dummy";
HttpBasedAuthentication authentication = mock(HttpBasedAuthentication.class);
HttpURLConnection httpConnection = mock(HttpURLConnection.class);
when(authentication.openConnection(any(URL.class), anyString(), any(OptionsByType.class))).thenReturn(httpConnection);
SoapConnection realConnection = new SoapConnection("oracle.com", 80, "/foo", useName, authentication) {
@Override
public List<Object> send(Envelope envelope, HttpURLConnection httpConnection) throws IOException {
return Collections.emptyList();
}
};
SoapConnection connection = spy(realConnection);
connection.send(envelope);
verify(authentication).openConnection(eq(url), eq(useName), any(OptionsByType.class));
verify(connection).send(same(envelope), same(httpConnection));
}
use of com.oracle.bedrock.runtime.remote.http.HttpBasedAuthentication in project oracle-bedrock by coherence-community.
the class WindowsRemoteTerminalTest method shouldCreateWindowsSession.
@Test
public void shouldCreateWindowsSession() throws Exception {
String userName = "Bob";
HttpBasedAuthentication authentication = new Password("secret");
String hostName = "foo.com";
int port = 1234;
RemotePlatform platform = mock(RemotePlatform.class);
when(platform.getUserName()).thenReturn(userName);
when(platform.getAuthentication()).thenReturn(authentication);
when(platform.getAddress()).thenReturn(InetAddress.getByName(hostName));
when(platform.getPort()).thenReturn(port);
WindowsRemoteTerminal shell = new WindowsRemoteTerminal(platform);
WindowsSession session = shell.createSession();
assertThat(session, is(notNullValue()));
SoapConnection soapConnection = session.getSoapConnection();
assertThat(soapConnection.getUrl().getHost(), is("foo.com"));
assertThat(soapConnection.getUrl().getPort(), is(1234));
assertThat(soapConnection.getUserName(), is("Bob"));
assertThat(soapConnection.getAuthentication(), is(sameInstance(authentication)));
}
Aggregations