use of com.blackducksoftware.integration.hub.proxy.ProxyInfo in project hub-alert by blackducksoftware.
the class ChannelRestConnectionFactoryTest method testConnectionFields.
@Test
public void testConnectionFields() throws EncryptionException {
final String host = "host";
final int port = 1;
final Credentials credentials = new Credentials("username", "password");
final TestGlobalProperties globalProperties = new TestGlobalProperties();
globalProperties.setHubProxyHost(host);
globalProperties.setHubProxyUsername(credentials.getUsername());
globalProperties.setHubProxyPassword(credentials.getDecryptedPassword());
globalProperties.setHubProxyPort(String.valueOf(port));
globalProperties.setHubTrustCertificate(true);
final ChannelRestConnectionFactory channelRestConnectionFactory = new ChannelRestConnectionFactory(globalProperties);
final RestConnection restConnection = channelRestConnectionFactory.createUnauthenticatedRestConnection("https:url");
final ProxyInfo expectedProxyInfo = new ProxyInfo(host, port, credentials, null, null, null);
assertNotNull(restConnection);
assertEquals(expectedProxyInfo, restConnection.getProxyInfo());
}
use of com.blackducksoftware.integration.hub.proxy.ProxyInfo in project hub-alert by blackducksoftware.
the class GlobalHubConfigActionsTest method testCreateRestConnection.
@Test
public void testCreateRestConnection() throws Exception {
final GlobalHubConfigActions configActions = new GlobalHubConfigActions(null, null, null);
final String url = "https://www.google.com/";
final String apiToken = "User";
HubServerConfigBuilder serverConfigBuilder = new HubServerConfigBuilder();
serverConfigBuilder.setHubUrl(url);
serverConfigBuilder.setApiToken(apiToken);
// we create this spy to skip the server validation that happens in the build method
serverConfigBuilder = Mockito.spy(serverConfigBuilder);
Mockito.doAnswer(new Answer<HubServerConfig>() {
@Override
public HubServerConfig answer(final InvocationOnMock invocation) throws Throwable {
final HubServerConfig hubServerConfig = new HubServerConfig(new URL(url), 0, apiToken, new ProxyInfo(null, 0, null, null, null, null), false, new UriCombiner());
return hubServerConfig;
}
}).when(serverConfigBuilder).build();
final RestConnection restConnection = configActions.createRestConnection(serverConfigBuilder);
assertNotNull(restConnection);
}
Aggregations