use of com.synopsys.integration.alert.component.certificates.web.PKIXErrorResponseFactory in project hub-alert by blackducksoftware.
the class EmailConfigActionTestIT method updatePasswordEmailGlobalConfigTest.
@Test
void updatePasswordEmailGlobalConfigTest() throws AlertConfigurationException {
AuthorizationManager authorizationManager = createEmailAuthorizationManager();
EmailGlobalCrudActions emailGlobalCrudActions = createEmailCrudActions(authorizationManager);
GlobalConfigurationModelToConcreteConversionService globalConfigurationModelToConcreteConversionService = createConversionService(emailGlobalCrudActions);
ConfigActions configActions = new ConfigActions(authorizationManager, descriptorAccessor, configurationModelConfigurationAccessor, fieldModelProcessor, descriptorProcessor, configurationFieldModelConverter, descriptorMap, pkixErrorResponseFactory, encryptionUtility, settingsDescriptorKey, globalConfigurationModelToConcreteConversionService);
FieldModel fieldModel = createEmailFieldModel();
fieldModel = configActions.create(fieldModel).getContent().orElseThrow(() -> new AlertConfigurationException("Couldn't create configuration"));
String updatedHost = "updated." + TEST_SMTP_HOST;
String updatedPassword = "updatedPassword";
fieldModel.putField(EmailPropertyKeys.JAVAMAIL_HOST_KEY.getPropertyKey(), new FieldValueModel(List.of(updatedHost), false));
fieldModel.putField(EmailPropertyKeys.JAVAMAIL_PASSWORD_KEY.getPropertyKey(), new FieldValueModel(List.of(updatedPassword), false));
configActions.update(Long.valueOf(fieldModel.getId()), fieldModel);
Optional<EmailGlobalConfigModel> staticEmailConfig = emailGlobalConfigAccessor.getConfiguration();
assertTrue(staticEmailConfig.isPresent());
EmailGlobalConfigModel staticModel = staticEmailConfig.get();
assertEquals(Boolean.TRUE, staticModel.getSmtpAuth().orElse(null));
assertEquals(TEST_AUTH_USER, staticModel.getSmtpUsername().orElse(null));
assertEquals(updatedPassword, staticModel.getSmtpPassword().orElse(null));
assertEquals(updatedHost, staticModel.getSmtpHost().orElse(null));
assertEquals(Integer.valueOf(TEST_SMTP_PORT), staticModel.getSmtpPort().orElse(null));
assertEquals(TEST_FROM, staticModel.getSmtpFrom().orElse(null));
String propertyValue = staticModel.getAdditionalJavaMailProperties().map(map -> map.get(EmailPropertyKeys.JAVAMAIL_EHLO_KEY.getPropertyKey())).orElse(null);
assertEquals("true", propertyValue);
}
use of com.synopsys.integration.alert.component.certificates.web.PKIXErrorResponseFactory in project hub-alert by blackducksoftware.
the class EmailConfigActionTestIT method updateReadExistingPasswordEmailGlobalConfigTest.
@Test
void updateReadExistingPasswordEmailGlobalConfigTest() throws AlertConfigurationException {
AuthorizationManager authorizationManager = createEmailAuthorizationManager();
EmailGlobalCrudActions emailGlobalCrudActions = createEmailCrudActions(authorizationManager);
GlobalConfigurationModelToConcreteConversionService globalConfigurationModelToConcreteConversionService = createConversionService(emailGlobalCrudActions);
ConfigActions configActions = new ConfigActions(authorizationManager, descriptorAccessor, configurationModelConfigurationAccessor, fieldModelProcessor, descriptorProcessor, configurationFieldModelConverter, descriptorMap, pkixErrorResponseFactory, encryptionUtility, settingsDescriptorKey, globalConfigurationModelToConcreteConversionService);
FieldModel fieldModel = createEmailFieldModel();
fieldModel = configActions.create(fieldModel).getContent().orElseThrow(() -> new AlertConfigurationException("Couldn't create configuration"));
String updatedHost = "updated." + TEST_SMTP_HOST;
fieldModel.putField(EmailPropertyKeys.JAVAMAIL_HOST_KEY.getPropertyKey(), new FieldValueModel(List.of(updatedHost), false));
configActions.update(Long.valueOf(fieldModel.getId()), fieldModel);
Optional<EmailGlobalConfigModel> staticEmailConfig = emailGlobalConfigAccessor.getConfiguration();
assertTrue(staticEmailConfig.isPresent());
EmailGlobalConfigModel staticModel = staticEmailConfig.get();
assertEquals(Boolean.TRUE, staticModel.getSmtpAuth().orElse(null));
assertEquals(TEST_AUTH_USER, staticModel.getSmtpUsername().orElse(null));
assertEquals(TEST_AUTH_PASSWORD, staticModel.getSmtpPassword().orElse(null));
assertEquals(updatedHost, staticModel.getSmtpHost().orElse(null));
assertEquals(Integer.valueOf(TEST_SMTP_PORT), staticModel.getSmtpPort().orElse(null));
assertEquals(TEST_FROM, staticModel.getSmtpFrom().orElse(null));
String propertyValue = staticModel.getAdditionalJavaMailProperties().map(map -> map.get(EmailPropertyKeys.JAVAMAIL_EHLO_KEY.getPropertyKey())).orElse(null);
assertEquals("true", propertyValue);
}
use of com.synopsys.integration.alert.component.certificates.web.PKIXErrorResponseFactory in project hub-alert by blackducksoftware.
the class EmailConfigActionTestIT method createEmailGlobalConfigTest.
@Test
void createEmailGlobalConfigTest() {
AuthorizationManager authorizationManager = createEmailAuthorizationManager();
EmailGlobalCrudActions emailGlobalCrudActions = createEmailCrudActions(authorizationManager);
GlobalConfigurationModelToConcreteConversionService globalConfigurationModelToConcreteConversionService = createConversionService(emailGlobalCrudActions);
ConfigActions configActions = new ConfigActions(authorizationManager, descriptorAccessor, configurationModelConfigurationAccessor, fieldModelProcessor, descriptorProcessor, configurationFieldModelConverter, descriptorMap, pkixErrorResponseFactory, encryptionUtility, settingsDescriptorKey, globalConfigurationModelToConcreteConversionService);
FieldModel fieldModel = createEmailFieldModel();
configActions.create(fieldModel);
Optional<EmailGlobalConfigModel> staticEmailConfig = emailGlobalConfigAccessor.getConfiguration();
assertTrue(staticEmailConfig.isPresent());
EmailGlobalConfigModel staticModel = staticEmailConfig.get();
assertEquals(Boolean.TRUE, staticModel.getSmtpAuth().orElse(null));
assertEquals(TEST_AUTH_USER, staticModel.getSmtpUsername().orElse(null));
assertEquals(TEST_AUTH_PASSWORD, staticModel.getSmtpPassword().orElse(null));
assertEquals(TEST_SMTP_HOST, staticModel.getSmtpHost().orElse(null));
assertEquals(Integer.valueOf(TEST_SMTP_PORT), staticModel.getSmtpPort().orElse(null));
assertEquals(TEST_FROM, staticModel.getSmtpFrom().orElse(null));
String propertyValue = staticModel.getAdditionalJavaMailProperties().map(map -> map.get(EmailPropertyKeys.JAVAMAIL_EHLO_KEY.getPropertyKey())).orElse(null);
assertEquals("true", propertyValue);
}
Aggregations