use of com.blackducksoftware.integration.hub.alert.TestGlobalProperties in project hub-alert by blackducksoftware.
the class AccumulatorProcessorTestIT method init.
@Before
public void init() throws Exception {
globalProperties = new TestGlobalProperties();
final HubServicesFactory hubServicesFactory = globalProperties.createHubServicesFactoryWithCredential(new PrintStreamIntLogger(System.out, LogLevel.TRACE));
projectService = hubServicesFactory.createProjectService();
notificationDataService = hubServicesFactory.createNotificationService();
codeLocationService = hubServicesFactory.createCodeLocationService();
hubService = hubServicesFactory.createHubService();
}
use of com.blackducksoftware.integration.hub.alert.TestGlobalProperties 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);
}
use of com.blackducksoftware.integration.hub.alert.TestGlobalProperties in project hub-alert by blackducksoftware.
the class CommonConfigTest method init.
@Before
public void init() throws IOException {
outputLogger = new OutputLogger();
globalProperties = new TestGlobalProperties();
}
use of com.blackducksoftware.integration.hub.alert.TestGlobalProperties in project hub-alert by blackducksoftware.
the class EmailChannelTestIT method sendEmailTest.
@Test
@Category(ExternalConnectionTest.class)
public void sendEmailTest() throws Exception {
final AuditEntryRepositoryWrapper auditEntryRepository = Mockito.mock(AuditEntryRepositoryWrapper.class);
final GlobalHubRepositoryWrapper globalRepository = Mockito.mock(GlobalHubRepositoryWrapper.class);
final GlobalHubConfigEntity globalConfig = new GlobalHubConfigEntity(300, properties.getProperty(TestPropertyKey.TEST_HUB_API_KEY));
Mockito.when(globalRepository.findAll()).thenReturn(Arrays.asList(globalConfig));
final TestGlobalProperties globalProperties = new TestGlobalProperties(globalRepository);
globalProperties.setHubUrl(properties.getProperty(TestPropertyKey.TEST_HUB_SERVER_URL));
final String trustCert = properties.getProperty(TestPropertyKey.TEST_TRUST_HTTPS_CERT);
if (trustCert != null) {
globalProperties.setHubTrustCertificate(Boolean.valueOf(trustCert));
}
EmailGroupChannel emailChannel = new EmailGroupChannel(globalProperties, gson, auditEntryRepository, null, null, null);
final ProjectData projectData = createProjectData("Manual test project");
final EmailGroupEvent event = new EmailGroupEvent(projectData, 1L);
final String smtpHost = properties.getProperty(TestPropertyKey.TEST_EMAIL_SMTP_HOST);
final String smtpFrom = properties.getProperty(TestPropertyKey.TEST_EMAIL_SMTP_FROM);
final GlobalEmailConfigEntity emailGlobalConfigEntity = new GlobalEmailConfigEntity(smtpHost, null, null, null, null, null, smtpFrom, null, null, null, null, null, null, null);
emailChannel = Mockito.spy(emailChannel);
Mockito.doReturn(emailGlobalConfigEntity).when(emailChannel).getGlobalConfigEntity();
final MockEmailEntity mockEmailEntity = new MockEmailEntity();
mockEmailEntity.setGroupName("IntegrationTest");
emailChannel.sendAuditedMessage(event, mockEmailEntity.createEntity());
}
use of com.blackducksoftware.integration.hub.alert.TestGlobalProperties in project hub-alert by blackducksoftware.
the class LoginActionsTestIT method testAuthenticateUserRoleFailIT.
@Test
public void testAuthenticateUserRoleFailIT() throws IntegrationException, IOException {
mockLoginRestModel.setHubUsername(properties.getProperty(TestPropertyKey.TEST_ACTIVE_USER));
final LoginActions loginActions = new LoginActions(new TestGlobalProperties());
final boolean userAuthenticated = loginActions.authenticateUser(mockLoginRestModel.createRestModel(), new Slf4jIntLogger(logger));
assertFalse(userAuthenticated);
assertTrue(outputLogger.isLineContainingText("User role not authenticated"));
}
Aggregations