use of com.synopsys.integration.alert.test.common.TestProperties in project hub-alert by blackducksoftware.
the class EmailGlobalTestActionTest method testPermissionConfigValidTest.
@Test
public void testPermissionConfigValidTest() throws AlertException {
TestProperties testProperties = new TestProperties();
AuthorizationManager authorizationManager = createAuthorizationManager(AuthenticationTestUtils.FULL_PERMISSIONS);
EmailGlobalConfigurationValidator validator = new EmailGlobalConfigurationValidator();
EmailChannelMessagingService emailChannelMessagingService = Mockito.mock(EmailChannelMessagingService.class);
Mockito.when(emailChannelMessagingService.sendMessage(Mockito.any(), Mockito.any())).thenReturn(new MessageResult("PASS"));
JavamailPropertiesFactory javamailPropertiesFactory = new JavamailPropertiesFactory();
EmailGlobalTestAction emailGlobalTestAction = new EmailGlobalTestAction(authorizationManager, validator, emailChannelMessagingService, javamailPropertiesFactory, configurationAccessor);
EmailGlobalConfigModel globalConfigModel = createValidEmailGlobalConfigModel(testProperties);
ActionResponse<ValidationResponseModel> response = emailGlobalTestAction.testWithPermissionCheck("noreply@synopsys.com", globalConfigModel);
assertEquals(HttpStatus.OK, response.getHttpStatus());
assertTrue(response.isSuccessful());
assertTrue(response.hasContent());
assertFalse(response.getContent().get().hasErrors(), "Expected the message result to not have errors");
}
use of com.synopsys.integration.alert.test.common.TestProperties in project hub-alert by blackducksoftware.
the class EmailGlobalTestActionTest method testConfigITTest.
@Test
@Tags(value = { @Tag(TestTags.DEFAULT_INTEGRATION), @Tag(TestTags.CUSTOM_EXTERNAL_CONNECTION) })
public void testConfigITTest() {
AuthorizationManager authorizationManager = createAuthorizationManager(AuthenticationTestUtils.FULL_PERMISSIONS);
EmailGlobalConfigurationValidator validator = new EmailGlobalConfigurationValidator();
TestProperties testProperties = new TestProperties();
String emailAddress = testProperties.getProperty(TestPropertyKey.TEST_EMAIL_RECIPIENT);
JavamailPropertiesFactory javamailPropertiesFactory = new JavamailPropertiesFactory();
EmailChannelMessagingService validEmailChannelMessagingService = createValidEmailChannelMessagingService(emailAddress);
EmailGlobalTestAction emailGlobalTestAction = new EmailGlobalTestAction(authorizationManager, validator, validEmailChannelMessagingService, javamailPropertiesFactory, configurationAccessor);
EmailGlobalConfigModel globalConfigModel = createValidEmailGlobalConfigModel(testProperties);
ConfigurationTestResult testResult = emailGlobalTestAction.testConfigModelContent(emailAddress, globalConfigModel);
assertTrue(testResult.isSuccess(), "Expected the message result to not have errors");
}
use of com.synopsys.integration.alert.test.common.TestProperties in project hub-alert by blackducksoftware.
the class SlackChannelTestIT method init.
@BeforeEach
public void init() {
gson = new Gson();
properties = new TestProperties();
}
use of com.synopsys.integration.alert.test.common.TestProperties in project hub-alert by blackducksoftware.
the class BlackDuckSSOConfigRetrieverTest method createBlackDuckProperties.
private BlackDuckProperties createBlackDuckProperties() {
TestProperties testProperties = new TestProperties();
String blackDuckUrl = testProperties.getBlackDuckURL();
String blackDuckApiKey = testProperties.getBlackDuckAPIToken();
String blackDuckTimeout = testProperties.getOptionalProperty(TestPropertyKey.TEST_BLACKDUCK_PROVIDER_TIMEOUT).orElse("300");
MockAlertProperties mockAlertProperties = new MockAlertProperties();
ProxyManager mockProxyManager = Mockito.mock(ProxyManager.class);
Mockito.when(mockProxyManager.createProxyInfoForHost(Mockito.anyString())).thenReturn(ProxyInfo.NO_PROXY_INFO);
ConfigurationModelMutable configurationModel = new ConfigurationModelMutable(0L, 0L, null, null, ConfigContextEnum.GLOBAL);
configurationModel.put(createConfigFieldModel(ProviderDescriptor.KEY_PROVIDER_CONFIG_ENABLED, Boolean.TRUE.toString()));
configurationModel.put(createConfigFieldModel(ProviderDescriptor.KEY_PROVIDER_CONFIG_NAME, BlackDuckSSOConfigRetrieverTest.class.getSimpleName()));
configurationModel.put(createConfigFieldModel(BlackDuckDescriptor.KEY_BLACKDUCK_URL, blackDuckUrl));
configurationModel.put(createConfigFieldModel(BlackDuckDescriptor.KEY_BLACKDUCK_API_KEY, blackDuckApiKey));
configurationModel.put(createConfigFieldModel(BlackDuckDescriptor.KEY_BLACKDUCK_TIMEOUT, blackDuckTimeout));
return new BlackDuckProperties(0L, new Gson(), BlackDuckServicesFactory.createDefaultObjectMapper(), mockAlertProperties, mockProxyManager, configurationModel);
}
use of com.synopsys.integration.alert.test.common.TestProperties in project hub-alert by blackducksoftware.
the class EmailMessagingServiceTest method sendAuthenticatedMessage.
@Test
public void sendAuthenticatedMessage() throws MessagingException, AlertException {
TestProperties testProperties = new TestProperties();
FreemarkerTemplatingService freemarkerTemplatingService = new FreemarkerTemplatingService();
EmailMessagingService emailMessagingService = new EmailMessagingService(freemarkerTemplatingService);
Session mockSession = Mockito.mock(Session.class);
Transport mockTransport = Mockito.mock(Transport.class);
Mockito.doNothing().when(mockTransport).connect();
Mockito.doNothing().when(mockTransport).close();
Mockito.when(mockSession.getTransport()).thenReturn(mockTransport);
Mockito.when(mockSession.getProperties()).thenReturn(testProperties.getProperties());
Message message = new MimeMessage(mockSession);
Mockito.doNothing().when(mockTransport).sendMessage(Mockito.eq(message), Mockito.any());
emailMessagingService.sendMessages(true, null, -1, null, null, mockSession, List.of(message));
}
Aggregations