use of com.synopsys.integration.rest.proxy.ProxyInfo in project hub-alert by blackducksoftware.
the class JiraCloudPropertiesFactory method createJiraProperties.
public JiraCloudProperties createJiraProperties(FieldUtility fieldUtility) {
String url = fieldUtility.getStringOrNull(JiraCloudDescriptor.KEY_JIRA_URL);
String username = fieldUtility.getStringOrNull(JiraCloudDescriptor.KEY_JIRA_ADMIN_EMAIL_ADDRESS);
String accessToken = fieldUtility.getStringOrNull(JiraCloudDescriptor.KEY_JIRA_ADMIN_API_TOKEN);
boolean pluginCheckDisabled = fieldUtility.getBooleanOrFalse(JiraCloudDescriptor.KEY_JIRA_DISABLE_PLUGIN_CHECK);
ProxyInfo proxy = proxyManager.createProxyInfoForHost(url);
return new JiraCloudProperties(url, accessToken, username, pluginCheckDisabled, proxy);
}
use of com.synopsys.integration.rest.proxy.ProxyInfo in project hub-alert by blackducksoftware.
the class SystemValidatorTest method testValidateHubValidProviderWithProxy.
@Test
public void testValidateHubValidProviderWithProxy() throws Exception {
ProxyManager proxyManager = Mockito.mock(ProxyManager.class);
CredentialsBuilder builder = Credentials.newBuilder();
builder.setUsername("AUser");
builder.setPassword("aPassword");
Credentials credentials = builder.build();
ProxyInfoBuilder proxyBuilder = ProxyInfo.newBuilder();
proxyBuilder.setHost("google.com");
proxyBuilder.setPort(3218);
proxyBuilder.setCredentials(credentials);
proxyBuilder.setNtlmDomain(null);
proxyBuilder.setNtlmWorkstation(null);
ProxyInfo expectedProxyInfo = proxyBuilder.build();
Mockito.when(proxyManager.createProxyInfoForHost(Mockito.anyString())).thenReturn(expectedProxyInfo);
BlackDuckProperties blackDuckProperties = Mockito.mock(BlackDuckProperties.class);
Mockito.when(blackDuckProperties.getBlackDuckUrl()).thenReturn(Optional.of("Black Duck URL"));
Mockito.when(blackDuckProperties.getApiToken()).thenReturn("Black Duck API Token");
Mockito.when(blackDuckProperties.getBlackDuckTimeout()).thenReturn(BlackDuckProperties.DEFAULT_TIMEOUT);
BlackDuckServerConfig serverConfig = Mockito.mock(BlackDuckServerConfig.class);
Mockito.when(serverConfig.canConnect(Mockito.any(IntLogger.class))).thenReturn(false);
DefaultSystemMessageAccessor defaultSystemMessageUtility = Mockito.mock(DefaultSystemMessageAccessor.class);
StatefulProvider statefulProvider = Mockito.mock(StatefulProvider.class);
BlackDuckProvider provider = Mockito.mock(BlackDuckProvider.class);
Mockito.when(provider.createStatefulProvider(Mockito.any())).thenReturn(statefulProvider);
Mockito.when(statefulProvider.getProperties()).thenReturn(blackDuckProperties);
BlackDuckSystemValidator blackDuckSystemValidator = new BlackDuckSystemValidator(defaultSystemMessageUtility);
blackDuckSystemValidator.validate(blackDuckProperties);
Mockito.verify(defaultSystemMessageUtility, Mockito.times(0)).addSystemMessage(Mockito.anyString(), Mockito.any(SystemMessageSeverity.class), Mockito.any(SystemMessageType.class));
}
use of com.synopsys.integration.rest.proxy.ProxyInfo in project hub-alert by blackducksoftware.
the class TestBlackDuckProperties method createMockedProxyManger.
public static ProxyManager createMockedProxyManger() {
ProxyManager proxyManager = Mockito.mock(ProxyManager.class);
ProxyInfo proxyInfo = Mockito.mock(ProxyInfo.class);
Mockito.when(proxyInfo.getHost()).thenReturn(Optional.empty());
Mockito.when(proxyInfo.getPort()).thenReturn(-1);
Mockito.when(proxyInfo.getUsername()).thenReturn(Optional.empty());
Mockito.when(proxyInfo.getPassword()).thenReturn(Optional.empty());
Mockito.when(proxyManager.createProxyInfoForHost(Mockito.anyString())).thenReturn(proxyInfo);
return proxyManager;
}
use of com.synopsys.integration.rest.proxy.ProxyInfo in project hub-alert by blackducksoftware.
the class ProxyManagerTest method testCreateProxyInfoForHostNonProxyHost.
@Test
public void testCreateProxyInfoForHostNonProxyHost() {
Mockito.when(settingsUtility.getConfiguration()).thenReturn(Optional.of(createSettingsProxyModelWithNonProxyHosts()));
ProxyInfo proxyInfo = proxyManager.createProxyInfoForHost(NON_PROXY_HOST);
assertTrue(proxyInfo.getHost().isEmpty());
assertEquals(0, proxyInfo.getPort());
assertTrue(proxyInfo.getUsername().isEmpty());
assertTrue(proxyInfo.getPassword().isEmpty());
}
use of com.synopsys.integration.rest.proxy.ProxyInfo in project hub-alert by blackducksoftware.
the class ProxyManagerTest method testCreateNoProxy.
@Test
public void testCreateNoProxy() {
Mockito.when(settingsUtility.getConfiguration()).thenReturn(Optional.empty());
ProxyInfo proxyInfo = proxyManager.createProxyInfo();
assertTrue(proxyInfo.getHost().isEmpty());
assertEquals(0, proxyInfo.getPort());
assertTrue(proxyInfo.getUsername().isEmpty());
assertTrue(proxyInfo.getPassword().isEmpty());
}
Aggregations