Search in sources :

Example 11 with ProxyInfo

use of com.synopsys.integration.rest.proxy.ProxyInfo in project hub-alert by blackducksoftware.

the class ProxyManagerTest method testCreateProxyInfoForHost.

@Test
public void testCreateProxyInfoForHost() {
    Mockito.when(settingsUtility.getConfiguration()).thenReturn(Optional.of(createSettingsProxyModelWithNonProxyHosts()));
    ProxyInfo proxyInfo = proxyManager.createProxyInfoForHost(HOST);
    performAssertions(proxyInfo);
}
Also used : ProxyInfo(com.synopsys.integration.rest.proxy.ProxyInfo) Test(org.junit.jupiter.api.Test)

Example 12 with ProxyInfo

use of com.synopsys.integration.rest.proxy.ProxyInfo in project hub-alert by blackducksoftware.

the class ProxyManagerTest method testCreateProxyInfoForHostNoProxy.

@Test
public void testCreateProxyInfoForHostNoProxy() {
    Mockito.when(settingsUtility.getConfiguration()).thenReturn(Optional.empty());
    ProxyInfo proxyInfo = proxyManager.createProxyInfoForHost(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 13 with ProxyInfo

use of com.synopsys.integration.rest.proxy.ProxyInfo in project hub-alert by blackducksoftware.

the class AzureBoardsMessageSenderFactory method createMessageSender.

@Override
public IssueTrackerMessageSender<Integer> createMessageSender(AzureBoardsJobDetailsModel distributionDetails) throws AlertException {
    AzureBoardsProperties azureBoardsProperties = azureBoardsPropertiesFactory.createAzureBoardsProperties();
    azureBoardsProperties.validateProperties();
    // Initialize Http Service
    ProxyInfo proxy = proxyManager.createProxyInfoForHost(AzureHttpRequestCreatorFactory.DEFAULT_BASE_URL);
    AzureHttpRequestCreator azureHttpRequestCreator = azureBoardsProperties.createAzureHttpRequestCreator(proxy, gson);
    AzureHttpService azureHttpService = new AzureHttpService(gson, azureHttpRequestCreator);
    // Azure Boards Services
    AzureApiVersionAppender apiVersionAppender = new AzureApiVersionAppender();
    AzureWorkItemService workItemService = new AzureWorkItemService(azureHttpService, azureHttpRequestCreator);
    AzureWorkItemTypeStateService workItemTypeStateService = new AzureWorkItemTypeStateService(azureHttpService, apiVersionAppender);
    AzureWorkItemCommentService workItemCommentService = new AzureWorkItemCommentService(azureHttpService, apiVersionAppender);
    return createMessageSender(workItemService, workItemTypeStateService, workItemCommentService, azureBoardsProperties.getOrganizationName(), distributionDetails);
}
Also used : ProxyInfo(com.synopsys.integration.rest.proxy.ProxyInfo) AzureApiVersionAppender(com.synopsys.integration.azure.boards.common.http.AzureApiVersionAppender) AzureWorkItemCommentService(com.synopsys.integration.azure.boards.common.service.comment.AzureWorkItemCommentService) AzureWorkItemService(com.synopsys.integration.azure.boards.common.service.workitem.AzureWorkItemService) AzureWorkItemTypeStateService(com.synopsys.integration.azure.boards.common.service.state.AzureWorkItemTypeStateService) AzureHttpRequestCreator(com.synopsys.integration.azure.boards.common.http.AzureHttpRequestCreator) AzureHttpService(com.synopsys.integration.azure.boards.common.http.AzureHttpService) AzureBoardsProperties(com.synopsys.integration.alert.channel.azure.boards.AzureBoardsProperties)

Example 14 with ProxyInfo

use of com.synopsys.integration.rest.proxy.ProxyInfo in project hub-alert by blackducksoftware.

the class AzureBoardsCustomFunctionAction method isAuthenticated.

private boolean isAuthenticated(FieldUtility fieldUtility) {
    AzureBoardsProperties properties = AzureBoardsProperties.fromFieldAccessor(azureBoardsCredentialDataStoreFactory, azureRedirectUrlCreator.createOAuthRedirectUri(), fieldUtility);
    ProxyInfo proxy = proxyManager.createProxyInfoForHost(AzureHttpRequestCreatorFactory.DEFAULT_BASE_URL);
    return properties.hasOAuthCredentials(proxy);
}
Also used : ProxyInfo(com.synopsys.integration.rest.proxy.ProxyInfo) AzureBoardsProperties(com.synopsys.integration.alert.channel.azure.boards.AzureBoardsProperties)

Example 15 with ProxyInfo

use of com.synopsys.integration.rest.proxy.ProxyInfo in project hub-alert by blackducksoftware.

the class AzureOAuthCallbackController method testOAuthConnection.

private void testOAuthConnection(AzureBoardsProperties azureBoardsProperties, String authorizationCode, String oAuthRequestId) {
    try {
        ProxyInfo proxyInfo = proxyManager.createProxyInfoForHost(AzureHttpRequestCreatorFactory.DEFAULT_BASE_URL);
        String organizationName = azureBoardsProperties.getOrganizationName();
        // save initiate token requests with the authorization code.
        logger.info("OAuth request with id {}: Testing with authorization code to save tokens.", oAuthRequestId);
        testGetProjects(azureBoardsProperties.createAzureHttpService(proxyInfo, gson, authorizationCode), organizationName, oAuthRequestId);
        // load the oauth credentials from the store.
        logger.info("OAuth request with id {}: Testing with store to read tokens.", oAuthRequestId);
        testGetProjects(azureBoardsProperties.createAzureHttpService(proxyInfo, gson), organizationName, oAuthRequestId);
    } catch (AlertException ex) {
        logger.error("OAuth request with id {}: Error in azure oauth validation test ", oAuthRequestId, ex);
        logger.error("Caused by: ", ex);
    }
}
Also used : ProxyInfo(com.synopsys.integration.rest.proxy.ProxyInfo) AlertException(com.synopsys.integration.alert.api.common.model.exception.AlertException)

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