use of com.blackducksoftware.integration.hub.configuration.HubServerConfig in project hub-alert by blackducksoftware.
the class TestGlobalProperties method createHubServicesFactoryWithCredential.
public HubServicesFactory createHubServicesFactoryWithCredential(final IntLogger logger) throws Exception {
setHubUrl(testProperties.getProperty(TestPropertyKey.TEST_HUB_SERVER_URL));
setHubTrustCertificate(true);
final HubServerConfig hubServerConfig = createHubServerConfigWithCredentials(logger);
final RestConnection restConnection = hubServerConfig.createCredentialsRestConnection(logger);
return new HubServicesFactory(restConnection);
}
use of com.blackducksoftware.integration.hub.configuration.HubServerConfig 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