use of com.synopsys.integration.alert.test.common.MockAlertProperties in project hub-alert by blackducksoftware.
the class AuthenticationConfigurationValidatorTest method createValidatorAsserter.
private GlobalConfigurationValidatorAsserter createValidatorAsserter(Map<String, FieldValueModel> keyToValues) {
AlertProperties mockAlertProperties = new MockAlertProperties();
FilePersistenceUtil filePersistenceUtil = new FilePersistenceUtil(mockAlertProperties, new Gson());
return new GlobalConfigurationValidatorAsserter(new AuthenticationDescriptorKey().getUniversalKey(), new AuthenticationConfigurationFieldModelValidator(filePersistenceUtil), keyToValues);
}
use of com.synopsys.integration.alert.test.common.MockAlertProperties 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());
}
use of com.synopsys.integration.alert.test.common.MockAlertProperties in project hub-alert by blackducksoftware.
the class EmailChannelTestIT method sendEmailTest.
@Test
@Tag(TestTags.CUSTOM_EXTERNAL_CONNECTION)
public void sendEmailTest() {
MockAlertProperties testAlertProperties = new MockAlertProperties();
String testEmailRecipient = testProperties.getProperty(TestPropertyKey.TEST_EMAIL_RECIPIENT);
EmailAttachmentFileCreator emailAttachmentFileCreator = new EmailAttachmentFileCreator(testAlertProperties, new MessageContentGroupCsvCreator(), gson);
FreemarkerTemplatingService freemarkerTemplatingService = new FreemarkerTemplatingService();
EmailMessagingService emailMessagingService = new EmailMessagingService(freemarkerTemplatingService);
JavamailPropertiesFactory javamailPropertiesFactory = new JavamailPropertiesFactory();
EmailChannelMessagingService emailChannelMessagingService = new EmailChannelMessagingService(testAlertProperties, emailMessagingService, emailAttachmentFileCreator);
EmailGlobalConfigModel emailGlobalConfig = createEmailGlobalConfig();
EmailGlobalConfigAccessor emailConfigurationAccessor = Mockito.mock(EmailGlobalConfigAccessor.class);
Mockito.when(emailConfigurationAccessor.getConfiguration()).thenReturn(Optional.of(emailGlobalConfig));
JobEmailAddressValidator emailAddressValidator = Mockito.mock(JobEmailAddressValidator.class);
Mockito.when(emailAddressValidator.validate(Mockito.any(), Mockito.anyCollection())).thenReturn(new ValidatedEmailAddresses(Set.of(testEmailRecipient), Set.of()));
EmailAddressGatherer emailAddressGatherer = new EmailAddressGatherer(null, null);
EmailChannelMessageConverter emailChannelMessageConverter = new EmailChannelMessageConverter(new EmailChannelMessageFormatter());
EmailChannelMessageSender emailChannelMessageSender = new EmailChannelMessageSender(emailConfigurationAccessor, emailAddressGatherer, emailChannelMessagingService, emailAddressValidator, javamailPropertiesFactory);
EmailChannel emailChannel = new EmailChannel(emailChannelMessageConverter, emailChannelMessageSender);
List<String> emailAddresses = List.of(testEmailRecipient);
EmailJobDetailsModel emailJobDetails = new EmailJobDetailsModel(null, EmailChannelTestIT.class.getSimpleName(), false, true, EmailAttachmentFormat.NONE.name(), emailAddresses);
EmailITTestAssertions.assertSendSimpleMessageSuccess(emailChannel, emailJobDetails);
}
use of com.synopsys.integration.alert.test.common.MockAlertProperties in project hub-alert by blackducksoftware.
the class EmailGlobalFieldModelTestActionTest method createValidEmailChannelMessagingService.
private EmailChannelMessagingService createValidEmailChannelMessagingService(String emailAddress) {
MockAlertProperties testAlertProperties = new MockAlertProperties();
JobEmailAddressValidator emailAddressValidator = Mockito.mock(JobEmailAddressValidator.class);
Mockito.when(emailAddressValidator.validate(Mockito.any(), Mockito.anyCollection())).thenReturn(new ValidatedEmailAddresses(Set.of(emailAddress), Set.of()));
Gson gson = new Gson();
MessageContentGroupCsvCreator messageContentGroupCsvCreator = new MessageContentGroupCsvCreator();
EmailAttachmentFileCreator emailAttachmentFileCreator = new EmailAttachmentFileCreator(testAlertProperties, messageContentGroupCsvCreator, gson);
FreemarkerTemplatingService freemarkerTemplatingService = new FreemarkerTemplatingService();
EmailMessagingService emailMessagingService = new EmailMessagingService(freemarkerTemplatingService);
return new EmailChannelMessagingService(testAlertProperties, emailMessagingService, emailAttachmentFileCreator);
}
use of com.synopsys.integration.alert.test.common.MockAlertProperties in project hub-alert by blackducksoftware.
the class SettingsEncryptionCrudActionsTest method getOneNotInitializedTest.
@Test
void getOneNotInitializedTest() {
MockAlertProperties alertPropertiesNoEncryption = new MockAlertProperties();
alertPropertiesNoEncryption.setEncryptionPassword("");
alertPropertiesNoEncryption.setEncryptionSalt("");
FilePersistenceUtil filePersistenceUtilWithoutProperties = new FilePersistenceUtil(alertPropertiesNoEncryption, gson);
EncryptionUtility encryptionUtilityWithoutProperties = new EncryptionUtility(alertPropertiesNoEncryption, filePersistenceUtilWithoutProperties);
SettingsEncryptionCrudActions configActions = new SettingsEncryptionCrudActions(authorizationManager, encryptionUtilityWithoutProperties, validator, settingsDescriptorKey);
ActionResponse<SettingsEncryptionModel> actionResponse = configActions.getOne();
assertTrue(actionResponse.isError());
assertFalse(actionResponse.hasContent());
assertEquals(HttpStatus.NOT_FOUND, actionResponse.getHttpStatus());
}
Aggregations