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);
}
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);
}
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("----------------------------------------");
}
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;
}
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());
}
Aggregations