use of com.blackducksoftware.integration.hub.alert.channel.rest.ChannelRestConnectionFactory in project hub-alert by blackducksoftware.
the class ChannelRestConnectionFactoryTest method testConnectionFields.
@Test
public void testConnectionFields() throws EncryptionException {
final String host = "host";
final int port = 1;
final Credentials credentials = new Credentials("username", "password");
final TestGlobalProperties globalProperties = new TestGlobalProperties();
globalProperties.setHubProxyHost(host);
globalProperties.setHubProxyUsername(credentials.getUsername());
globalProperties.setHubProxyPassword(credentials.getDecryptedPassword());
globalProperties.setHubProxyPort(String.valueOf(port));
globalProperties.setHubTrustCertificate(true);
final ChannelRestConnectionFactory channelRestConnectionFactory = new ChannelRestConnectionFactory(globalProperties);
final RestConnection restConnection = channelRestConnectionFactory.createUnauthenticatedRestConnection("https:url");
final ProxyInfo expectedProxyInfo = new ProxyInfo(host, port, credentials, null, null, null);
assertNotNull(restConnection);
assertEquals(expectedProxyInfo, restConnection.getProxyInfo());
}
use of com.blackducksoftware.integration.hub.alert.channel.rest.ChannelRestConnectionFactory in project hub-alert by blackducksoftware.
the class HipChatChannelTest method testGlobalConfigValidApiKeyTest.
@Test
public void testGlobalConfigValidApiKeyTest() throws Exception {
final TestGlobalProperties globalProperties = new TestGlobalProperties();
globalProperties.setHubTrustCertificate(Boolean.TRUE);
final ChannelRestConnectionFactory restFactory = new ChannelRestConnectionFactory(globalProperties);
final HipChatChannel hipChatChannel = new HipChatChannel(null, null, null, null, null, restFactory);
hipChatMockUtil.setApiKey(properties.getProperty(TestPropertyKey.TEST_HIPCHAT_API_KEY));
final GlobalHipChatConfigEntity entity = hipChatMockUtil.createGlobalEntity();
final String validMessage = hipChatChannel.testGlobalConfig(entity);
assertEquals("API key is valid.", validMessage);
}
use of com.blackducksoftware.integration.hub.alert.channel.rest.ChannelRestConnectionFactory in project hub-alert by blackducksoftware.
the class HipChatChannelTest method testGlobalConfigInvalidApiKeyTest.
@Test
public void testGlobalConfigInvalidApiKeyTest() {
final TestGlobalProperties globalProperties = new TestGlobalProperties();
globalProperties.setHubTrustCertificate(Boolean.TRUE);
final ChannelRestConnectionFactory restFactory = new ChannelRestConnectionFactory(globalProperties);
final HipChatChannel hipChatChannel = new HipChatChannel(null, null, null, null, null, restFactory);
hipChatMockUtil.setApiKey("garbage");
try {
final GlobalHipChatConfigEntity entity = hipChatMockUtil.createGlobalEntity();
hipChatChannel.testGlobalConfig(entity);
} catch (final IntegrationException ex) {
assertTrue(ex.getMessage().contains("Invalid API key: "));
}
}
use of com.blackducksoftware.integration.hub.alert.channel.rest.ChannelRestConnectionFactory in project hub-alert by blackducksoftware.
the class SlackChannelTestIT method sendMessageTestIT.
@Test
@Category(ExternalConnectionTest.class)
public void sendMessageTestIT() throws IOException, IntegrationException {
final AuditEntryRepositoryWrapper auditEntryRepository = Mockito.mock(AuditEntryRepositoryWrapper.class);
final GlobalHubRepositoryWrapper mockedGlobalRepository = Mockito.mock(GlobalHubRepositoryWrapper.class);
final TestGlobalProperties globalProperties = new TestGlobalProperties(mockedGlobalRepository, null);
final ChannelRestConnectionFactory channelRestConnectionFactory = new ChannelRestConnectionFactory(globalProperties);
final SlackChannel slackChannel = new SlackChannel(gson, auditEntryRepository, null, null, channelRestConnectionFactory);
final String roomName = properties.getProperty(TestPropertyKey.TEST_SLACK_CHANNEL_NAME);
final String username = properties.getProperty(TestPropertyKey.TEST_SLACK_USERNAME);
final String webHook = properties.getProperty(TestPropertyKey.TEST_SLACK_WEBHOOK);
final SlackDistributionConfigEntity config = new SlackDistributionConfigEntity(webHook, username, roomName);
final ProjectData projectData = createProjectData("Slack test project");
final SlackEvent event = new SlackEvent(projectData, new Long(0));
slackChannel.sendAuditedMessage(event, config);
final boolean actual = outputLogger.isLineContainingText("Successfully sent a slack_channel message!");
assertTrue(actual);
}
Aggregations