Search in sources :

Example 1 with ProxyInfo

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

the class ProxyManagerTest method testCreate.

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

Example 2 with ProxyInfo

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

the class AzureBoardsProcessorFactory method createProcessor.

@Override
public IssueTrackerProcessor<Integer> createProcessor(AzureBoardsJobDetailsModel distributionDetails) throws AlertException {
    AzureBoardsProperties azureBoardsProperties = azureBoardsPropertiesFactory.createAzureBoardsProperties();
    String organizationName = azureBoardsProperties.getOrganizationName();
    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);
    // Common Azure Boards Services
    AzureApiVersionAppender apiVersionAppender = new AzureApiVersionAppender();
    AzureProjectService projectService = new AzureProjectService(azureHttpService, apiVersionAppender);
    AzureWorkItemService workItemService = new AzureWorkItemService(azureHttpService, azureHttpRequestCreator);
    AzureWorkItemQueryService workItemQueryService = new AzureWorkItemQueryService(azureHttpService, apiVersionAppender);
    String projectNameOrId = distributionDetails.getProjectNameOrId();
    String teamProjectName = retrieveProjectNameIfNecessary(projectService, organizationName, projectNameOrId);
    installCustomFieldsIfNecessary(organizationName, teamProjectName, distributionDetails.getWorkItemType(), projectService, new AzureProcessService(azureHttpService, apiVersionAppender));
    // Searcher Requirements
    AzureBoardsIssueStatusResolver azureBoardsIssueStatusResolver = new AzureBoardsIssueStatusResolver(distributionDetails.getWorkItemCompletedState(), distributionDetails.getWorkItemReopenState());
    AzureBoardsIssueTrackerQueryManager queryManager = new AzureBoardsIssueTrackerQueryManager(organizationName, distributionDetails, workItemService, workItemQueryService);
    // Extractor Requirements
    AzureBoardsExistingIssueDetailsCreator issueDetailsCreator = new AzureBoardsExistingIssueDetailsCreator(organizationName, issueCategoryRetriever, azureBoardsIssueStatusResolver);
    AzureBoardsWorkItemFinder workItemFinder = new AzureBoardsWorkItemFinder(queryManager, teamProjectName);
    AzureBoardsProjectAndVersionIssueFinder projectAndVersionIssueFinder = new AzureBoardsProjectAndVersionIssueFinder(gson, issueDetailsCreator, workItemFinder);
    AzureBoardsComponentIssueFinder componentIssueFinder = new AzureBoardsComponentIssueFinder(gson, workItemFinder, issueDetailsCreator);
    IssueTrackerSearcher<Integer> azureBoardsSearcher = new IssueTrackerSearcher<>(projectAndVersionIssueFinder, projectAndVersionIssueFinder, componentIssueFinder, componentIssueFinder, modelTransformer);
    IssueTrackerModelExtractor<Integer> extractor = new IssueTrackerModelExtractor<>(formatter, azureBoardsSearcher);
    // Message Sender Requirements
    AzureWorkItemTypeStateService workItemTypeStateService = new AzureWorkItemTypeStateService(azureHttpService, apiVersionAppender);
    AzureWorkItemCommentService workItemCommentService = new AzureWorkItemCommentService(azureHttpService, apiVersionAppender);
    IssueTrackerMessageSender<Integer> messageSender = azureBoardsMessageSenderFactory.createMessageSender(workItemService, workItemTypeStateService, workItemCommentService, organizationName, distributionDetails);
    return new IssueTrackerProcessor<>(extractor, messageSender);
}
Also used : AzureBoardsProjectAndVersionIssueFinder(com.synopsys.integration.alert.channel.azure.boards.distribution.search.AzureBoardsProjectAndVersionIssueFinder) AzureBoardsWorkItemFinder(com.synopsys.integration.alert.channel.azure.boards.distribution.search.AzureBoardsWorkItemFinder) AzureWorkItemTypeStateService(com.synopsys.integration.azure.boards.common.service.state.AzureWorkItemTypeStateService) AzureWorkItemQueryService(com.synopsys.integration.azure.boards.common.service.query.AzureWorkItemQueryService) ProxyInfo(com.synopsys.integration.rest.proxy.ProxyInfo) IssueTrackerModelExtractor(com.synopsys.integration.alert.api.channel.issue.IssueTrackerModelExtractor) AzureWorkItemCommentService(com.synopsys.integration.azure.boards.common.service.comment.AzureWorkItemCommentService) AzureHttpRequestCreator(com.synopsys.integration.azure.boards.common.http.AzureHttpRequestCreator) AzureHttpService(com.synopsys.integration.azure.boards.common.http.AzureHttpService) AzureBoardsExistingIssueDetailsCreator(com.synopsys.integration.alert.channel.azure.boards.distribution.search.AzureBoardsExistingIssueDetailsCreator) AzureBoardsProperties(com.synopsys.integration.alert.channel.azure.boards.AzureBoardsProperties) IssueTrackerProcessor(com.synopsys.integration.alert.api.channel.issue.IssueTrackerProcessor) IssueTrackerSearcher(com.synopsys.integration.alert.api.channel.issue.search.IssueTrackerSearcher) AzureProjectService(com.synopsys.integration.azure.boards.common.service.project.AzureProjectService) AzureApiVersionAppender(com.synopsys.integration.azure.boards.common.http.AzureApiVersionAppender) AzureBoardsComponentIssueFinder(com.synopsys.integration.alert.channel.azure.boards.distribution.search.AzureBoardsComponentIssueFinder) AzureBoardsIssueStatusResolver(com.synopsys.integration.alert.channel.azure.boards.distribution.search.AzureBoardsIssueStatusResolver) AzureWorkItemService(com.synopsys.integration.azure.boards.common.service.workitem.AzureWorkItemService) AzureProcessService(com.synopsys.integration.azure.boards.common.service.process.AzureProcessService)

Example 3 with ProxyInfo

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

the class ConfigurationLogger method initialize.

@Override
protected void initialize() {
    ProxyInfo proxyInfo = proxyManager.createProxyInfo();
    Optional<String> proxyHost = proxyInfo.getHost();
    Optional<String> proxyPort = Optional.of(proxyInfo.getPort()).map(Object::toString);
    Optional<String> proxyUsername = proxyInfo.getUsername();
    Optional<String> proxyPassword = proxyInfo.getMaskedPassword();
    boolean authenticatedProxy = StringUtils.isNotBlank(proxyPassword.orElse(""));
    logger.info("----------------------------------------");
    logger.info("Alert Configuration: ");
    logger.info("Alert Server URL:          {}", alertProperties.getServerURL());
    logger.info("Logging level:             {}", alertProperties.getLoggingLevel().orElse(""));
    logger.info("Alert Proxy Host:          {}", proxyHost.orElse(""));
    logger.info("Alert Proxy Port:          {}", proxyPort.orElse(""));
    logger.info("Alert Proxy Authenticated: {}", authenticatedProxy);
    logger.info("Alert Proxy User:          {}", proxyUsername.orElse(""));
    logger.info("");
    logger.info("----------------------------------------");
}
Also used : ProxyInfo(com.synopsys.integration.rest.proxy.ProxyInfo)

Example 4 with ProxyInfo

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

the class BlackDuckProperties method createBlackDuckProperties.

private Map<String, String> createBlackDuckProperties(String blackDuckUrl) {
    Map<String, String> properties = new HashMap<>();
    properties.put(BlackDuckServerConfigBuilder.TRUST_CERT_KEY.getKey(), String.valueOf(alertProperties.getAlertTrustCertificate().orElse(false)));
    ProxyInfo proxyInfo = proxyManager.createProxyInfoForHost(blackDuckUrl);
    properties.put(BlackDuckServerConfigBuilder.PROXY_HOST_KEY.getKey(), proxyInfo.getHost().orElse(""));
    properties.put(BlackDuckServerConfigBuilder.PROXY_PORT_KEY.getKey(), String.valueOf(proxyInfo.getPort()));
    properties.put(BlackDuckServerConfigBuilder.PROXY_USERNAME_KEY.getKey(), proxyInfo.getUsername().orElse(""));
    properties.put(BlackDuckServerConfigBuilder.PROXY_PASSWORD_KEY.getKey(), proxyInfo.getPassword().orElse(""));
    return properties;
}
Also used : ProxyInfo(com.synopsys.integration.rest.proxy.ProxyInfo) HashMap(java.util.HashMap)

Example 5 with ProxyInfo

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

the class ChannelRestConnectionFactoryTest method testConnectionFields.

@Test
void testConnectionFields() {
    String baseUrl = "https://example-base-url";
    final String host = "host";
    final int port = 1;
    CredentialsBuilder builder = Credentials.newBuilder();
    builder.setUsername("username");
    builder.setPassword("password");
    Credentials credentials = builder.build();
    ProxyInfoBuilder proxyBuilder = ProxyInfo.newBuilder();
    proxyBuilder.setHost(host);
    proxyBuilder.setPort(port);
    proxyBuilder.setCredentials(credentials);
    proxyBuilder.setNtlmDomain(null);
    proxyBuilder.setNtlmWorkstation(null);
    ProxyInfo expectedProxyInfo = proxyBuilder.build();
    MockAlertProperties testAlertProperties = new MockAlertProperties();
    testAlertProperties.setAlertTrustCertificate(true);
    ProxyManager proxyManager = Mockito.mock(ProxyManager.class);
    Mockito.when(proxyManager.createProxyInfoForHost(baseUrl)).thenReturn(expectedProxyInfo);
    ChannelRestConnectionFactory channelRestConnectionFactory = new ChannelRestConnectionFactory(testAlertProperties, proxyManager, gson);
    IntHttpClient intHttpClient = channelRestConnectionFactory.createIntHttpClient(baseUrl);
    assertNotNull(intHttpClient);
    assertEquals(expectedProxyInfo, intHttpClient.getProxyInfo());
}
Also used : ProxyInfo(com.synopsys.integration.rest.proxy.ProxyInfo) IntHttpClient(com.synopsys.integration.rest.client.IntHttpClient) MockAlertProperties(com.synopsys.integration.alert.test.common.MockAlertProperties) ProxyManager(com.synopsys.integration.alert.common.rest.proxy.ProxyManager) CredentialsBuilder(com.synopsys.integration.rest.credentials.CredentialsBuilder) Credentials(com.synopsys.integration.rest.credentials.Credentials) ProxyInfoBuilder(com.synopsys.integration.rest.proxy.ProxyInfoBuilder) 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