Search in sources :

Example 21 with EmailGlobalConfigurationValidator

use of com.synopsys.integration.alert.channel.email.validator.EmailGlobalConfigurationValidator 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");
}
Also used : TestProperties(com.synopsys.integration.alert.test.common.TestProperties) EmailGlobalConfigModel(com.synopsys.integration.alert.service.email.model.EmailGlobalConfigModel) ValidationResponseModel(com.synopsys.integration.alert.common.rest.model.ValidationResponseModel) EmailGlobalConfigurationValidator(com.synopsys.integration.alert.channel.email.validator.EmailGlobalConfigurationValidator) AuthorizationManager(com.synopsys.integration.alert.common.security.authorization.AuthorizationManager) MessageResult(com.synopsys.integration.alert.common.message.model.MessageResult) EmailChannelMessagingService(com.synopsys.integration.alert.channel.email.distribution.EmailChannelMessagingService) JavamailPropertiesFactory(com.synopsys.integration.alert.service.email.JavamailPropertiesFactory) Test(org.junit.jupiter.api.Test)

Example 22 with EmailGlobalConfigurationValidator

use of com.synopsys.integration.alert.channel.email.validator.EmailGlobalConfigurationValidator in project hub-alert by blackducksoftware.

the class EmailGlobalTestActionTest method testPermissionForbiddenTest.

@Test
public void testPermissionForbiddenTest() throws AlertException {
    AuthorizationManager authorizationManager = createAuthorizationManager(0);
    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);
    ActionResponse<ValidationResponseModel> response = emailGlobalTestAction.testWithPermissionCheck("noreply@synopsys.com", new EmailGlobalConfigModel());
    assertEquals(HttpStatus.FORBIDDEN, response.getHttpStatus());
}
Also used : ValidationResponseModel(com.synopsys.integration.alert.common.rest.model.ValidationResponseModel) EmailGlobalConfigModel(com.synopsys.integration.alert.service.email.model.EmailGlobalConfigModel) EmailGlobalConfigurationValidator(com.synopsys.integration.alert.channel.email.validator.EmailGlobalConfigurationValidator) AuthorizationManager(com.synopsys.integration.alert.common.security.authorization.AuthorizationManager) MessageResult(com.synopsys.integration.alert.common.message.model.MessageResult) EmailChannelMessagingService(com.synopsys.integration.alert.channel.email.distribution.EmailChannelMessagingService) JavamailPropertiesFactory(com.synopsys.integration.alert.service.email.JavamailPropertiesFactory) Test(org.junit.jupiter.api.Test)

Example 23 with EmailGlobalConfigurationValidator

use of com.synopsys.integration.alert.channel.email.validator.EmailGlobalConfigurationValidator 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");
}
Also used : TestProperties(com.synopsys.integration.alert.test.common.TestProperties) EmailGlobalConfigModel(com.synopsys.integration.alert.service.email.model.EmailGlobalConfigModel) EmailGlobalConfigurationValidator(com.synopsys.integration.alert.channel.email.validator.EmailGlobalConfigurationValidator) AuthorizationManager(com.synopsys.integration.alert.common.security.authorization.AuthorizationManager) JavamailPropertiesFactory(com.synopsys.integration.alert.service.email.JavamailPropertiesFactory) EmailChannelMessagingService(com.synopsys.integration.alert.channel.email.distribution.EmailChannelMessagingService) ConfigurationTestResult(com.synopsys.integration.alert.common.message.model.ConfigurationTestResult) Test(org.junit.jupiter.api.Test) TestTags(com.synopsys.integration.alert.test.common.TestTags) Tags(org.junit.jupiter.api.Tags)

Aggregations

EmailGlobalConfigurationValidator (com.synopsys.integration.alert.channel.email.validator.EmailGlobalConfigurationValidator)23 AuthorizationManager (com.synopsys.integration.alert.common.security.authorization.AuthorizationManager)23 EmailGlobalConfigModel (com.synopsys.integration.alert.service.email.model.EmailGlobalConfigModel)23 Test (org.junit.jupiter.api.Test)23 PermissionKey (com.synopsys.integration.alert.common.persistence.model.PermissionKey)12 PermissionMatrixModel (com.synopsys.integration.alert.common.persistence.model.PermissionMatrixModel)12 DescriptorKey (com.synopsys.integration.alert.descriptor.api.model.DescriptorKey)12 AuthenticationTestUtils (com.synopsys.integration.alert.test.common.AuthenticationTestUtils)12 EmailGlobalConfigAccessor (com.synopsys.integration.alert.channel.email.database.accessor.EmailGlobalConfigAccessor)10 EmailChannelMessagingService (com.synopsys.integration.alert.channel.email.distribution.EmailChannelMessagingService)9 JavamailPropertiesFactory (com.synopsys.integration.alert.service.email.JavamailPropertiesFactory)9 ValidationResponseModel (com.synopsys.integration.alert.common.rest.model.ValidationResponseModel)7 ConfigurationTestResult (com.synopsys.integration.alert.common.message.model.ConfigurationTestResult)6 MessageResult (com.synopsys.integration.alert.common.message.model.MessageResult)4 TestProperties (com.synopsys.integration.alert.test.common.TestProperties)4 TestTags (com.synopsys.integration.alert.test.common.TestTags)3 UUID (java.util.UUID)3 Tags (org.junit.jupiter.api.Tags)3 Gson (com.google.gson.Gson)2 EmailAttachmentFileCreator (com.synopsys.integration.alert.channel.email.attachment.EmailAttachmentFileCreator)2