Search in sources :

Example 6 with ProxyInfo

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);
}
Also used : ProxyInfo(com.synopsys.integration.rest.proxy.ProxyInfo)

Example 7 with ProxyInfo

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));
}
Also used : BlackDuckProperties(com.synopsys.integration.alert.provider.blackduck.BlackDuckProperties) ProxyManager(com.synopsys.integration.alert.common.rest.proxy.ProxyManager) IntLogger(com.synopsys.integration.log.IntLogger) BlackDuckSystemValidator(com.synopsys.integration.alert.provider.blackduck.validator.BlackDuckSystemValidator) BlackDuckServerConfig(com.synopsys.integration.blackduck.configuration.BlackDuckServerConfig) ProxyInfo(com.synopsys.integration.rest.proxy.ProxyInfo) CredentialsBuilder(com.synopsys.integration.rest.credentials.CredentialsBuilder) SystemMessageSeverity(com.synopsys.integration.alert.common.enumeration.SystemMessageSeverity) SystemMessageType(com.synopsys.integration.alert.common.enumeration.SystemMessageType) DefaultSystemMessageAccessor(com.synopsys.integration.alert.database.system.DefaultSystemMessageAccessor) BlackDuckProvider(com.synopsys.integration.alert.provider.blackduck.BlackDuckProvider) Credentials(com.synopsys.integration.rest.credentials.Credentials) ProxyInfoBuilder(com.synopsys.integration.rest.proxy.ProxyInfoBuilder) StatefulProvider(com.synopsys.integration.alert.api.provider.state.StatefulProvider) Test(org.junit.jupiter.api.Test)

Example 8 with ProxyInfo

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;
}
Also used : ProxyInfo(com.synopsys.integration.rest.proxy.ProxyInfo) ProxyManager(com.synopsys.integration.alert.common.rest.proxy.ProxyManager)

Example 9 with ProxyInfo

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());
}
Also used : ProxyInfo(com.synopsys.integration.rest.proxy.ProxyInfo) Test(org.junit.jupiter.api.Test)

Example 10 with ProxyInfo

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());
}
Also used : ProxyInfo(com.synopsys.integration.rest.proxy.ProxyInfo) Test(org.junit.jupiter.api.Test)

Aggregations

ProxyInfo (com.synopsys.integration.rest.proxy.ProxyInfo)22 Test (org.junit.jupiter.api.Test)9 IntHttpClient (com.synopsys.integration.rest.client.IntHttpClient)5 AzureBoardsProperties (com.synopsys.integration.alert.channel.azure.boards.AzureBoardsProperties)3 ProxyManager (com.synopsys.integration.alert.common.rest.proxy.ProxyManager)3 ConfigurationModel (com.synopsys.integration.alert.common.persistence.model.ConfigurationModel)2 AzureApiVersionAppender (com.synopsys.integration.azure.boards.common.http.AzureApiVersionAppender)2 AzureHttpRequestCreator (com.synopsys.integration.azure.boards.common.http.AzureHttpRequestCreator)2 AzureHttpService (com.synopsys.integration.azure.boards.common.http.AzureHttpService)2 AzureWorkItemCommentService (com.synopsys.integration.azure.boards.common.service.comment.AzureWorkItemCommentService)2 AzureWorkItemTypeStateService (com.synopsys.integration.azure.boards.common.service.state.AzureWorkItemTypeStateService)2 AzureWorkItemService (com.synopsys.integration.azure.boards.common.service.workitem.AzureWorkItemService)2 BlackDuckServicesFactory (com.synopsys.integration.blackduck.service.BlackDuckServicesFactory)2 IntLogger (com.synopsys.integration.log.IntLogger)2 Credentials (com.synopsys.integration.rest.credentials.Credentials)2 CredentialsBuilder (com.synopsys.integration.rest.credentials.CredentialsBuilder)2 ProxyInfoBuilder (com.synopsys.integration.rest.proxy.ProxyInfoBuilder)2 IssueTrackerModelExtractor (com.synopsys.integration.alert.api.channel.issue.IssueTrackerModelExtractor)1 IssueTrackerProcessor (com.synopsys.integration.alert.api.channel.issue.IssueTrackerProcessor)1 IssueTrackerSearcher (com.synopsys.integration.alert.api.channel.issue.search.IssueTrackerSearcher)1