use of com.synopsys.integration.alert.common.persistence.model.ConfigurationFieldModel in project hub-alert by blackducksoftware.
the class LdapManagerTest method testAuthenticationTypeSimple.
@Test
public void testAuthenticationTypeSimple() throws Exception {
final String authenticationType = "simple";
ConfigurationModel configurationModel = createConfigurationModel();
configurationModel.getField(AuthenticationDescriptor.KEY_LDAP_AUTHENTICATION_TYPE).get().setFieldValue(authenticationType);
DefaultConfigurationModelConfigurationAccessor configurationModelConfigurationAccessor = Mockito.mock(DefaultConfigurationModelConfigurationAccessor.class);
Mockito.when(configurationModelConfigurationAccessor.getConfigurationsByDescriptorKey(Mockito.any(DescriptorKey.class))).thenReturn(List.of(configurationModel));
UserManagementAuthoritiesPopulator authoritiesPopulator = Mockito.mock(UserManagementAuthoritiesPopulator.class);
LdapManager ldapManager = new LdapManager(AUTHENTICATION_DESCRIPTOR_KEY, configurationModelConfigurationAccessor, authoritiesPopulator, LDAP_USER_CONTEXT_MAPPER);
ldapManager.getAuthenticationProvider();
FieldUtility updatedProperties = ldapManager.getCurrentConfiguration();
assertEquals(authenticationType, updatedProperties.getField(AuthenticationDescriptor.KEY_LDAP_AUTHENTICATION_TYPE).flatMap(ConfigurationFieldModel::getFieldValue).orElse(null));
}
use of com.synopsys.integration.alert.common.persistence.model.ConfigurationFieldModel in project hub-alert by blackducksoftware.
the class PurgeTaskTest method cronExpressionNotDefault.
@Test
public void cronExpressionNotDefault() {
final String notDefaultValue = "44";
ConfigurationModelConfigurationAccessor configurationModelConfigurationAccessor = Mockito.mock(ConfigurationModelConfigurationAccessor.class);
ConfigurationModelMutable configurationModel = new ConfigurationModelMutable(1L, 1L, null, null, ConfigContextEnum.GLOBAL);
ConfigurationFieldModel configurationFieldModel = ConfigurationFieldModel.create(SchedulingDescriptor.KEY_PURGE_DATA_FREQUENCY_DAYS);
configurationFieldModel.setFieldValue(notDefaultValue);
configurationModel.put(configurationFieldModel);
Mockito.when(configurationModelConfigurationAccessor.getConfigurationsByDescriptorKey(Mockito.any(DescriptorKey.class))).thenReturn(List.of(configurationModel));
PurgeTask task = new PurgeTask(new SchedulingDescriptorKey(), null, null, null, null, configurationModelConfigurationAccessor);
String cronWithNotDefault = task.scheduleCronExpression();
String expectedCron = String.format(PurgeTask.CRON_FORMAT, notDefaultValue);
assertEquals(expectedCron, cronWithNotDefault);
}
use of com.synopsys.integration.alert.common.persistence.model.ConfigurationFieldModel in project hub-alert by blackducksoftware.
the class LdapManagerTest method createConfigurationModel.
private ConfigurationModel createConfigurationModel() {
ConfigurationModelMutable configurationModel = new ConfigurationModelMutable(1L, 1L, null, null, ConfigContextEnum.GLOBAL);
ConfigurationFieldModel enabledField = ConfigurationFieldModel.create(AuthenticationDescriptor.KEY_LDAP_ENABLED);
ConfigurationFieldModel serverField = ConfigurationFieldModel.create(AuthenticationDescriptor.KEY_LDAP_SERVER);
ConfigurationFieldModel managerDNField = ConfigurationFieldModel.create(AuthenticationDescriptor.KEY_LDAP_MANAGER_DN);
ConfigurationFieldModel managerPasswordField = ConfigurationFieldModel.createSensitive(AuthenticationDescriptor.KEY_LDAP_MANAGER_PWD);
ConfigurationFieldModel authenticationTypeField = ConfigurationFieldModel.create(AuthenticationDescriptor.KEY_LDAP_AUTHENTICATION_TYPE);
ConfigurationFieldModel referralField = ConfigurationFieldModel.create(AuthenticationDescriptor.KEY_LDAP_REFERRAL);
ConfigurationFieldModel userSearchBaseField = ConfigurationFieldModel.create(AuthenticationDescriptor.KEY_LDAP_USER_SEARCH_BASE);
ConfigurationFieldModel userSearchFilterField = ConfigurationFieldModel.create(AuthenticationDescriptor.KEY_LDAP_USER_SEARCH_FILTER);
ConfigurationFieldModel userDNPatternsField = ConfigurationFieldModel.create(AuthenticationDescriptor.KEY_LDAP_USER_DN_PATTERNS);
ConfigurationFieldModel userAttributesField = ConfigurationFieldModel.create(AuthenticationDescriptor.KEY_LDAP_USER_ATTRIBUTES);
ConfigurationFieldModel groupSearchBaseField = ConfigurationFieldModel.create(AuthenticationDescriptor.KEY_LDAP_GROUP_SEARCH_BASE);
ConfigurationFieldModel groupSearchFilterField = ConfigurationFieldModel.create(AuthenticationDescriptor.KEY_LDAP_GROUP_SEARCH_FILTER);
ConfigurationFieldModel groupRoleAttributeField = ConfigurationFieldModel.create(AuthenticationDescriptor.KEY_LDAP_GROUP_ROLE_ATTRIBUTE);
enabledField.setFieldValue(DEFAULT_ENABLED);
serverField.setFieldValue(DEFAULT_SERVER);
managerDNField.setFieldValue(DEFAULT_MANAGER_DN);
managerPasswordField.setFieldValue(DEFAULT_MANAGER_PASSWORD);
authenticationTypeField.setFieldValue(DEFAULT_AUTHENTICATION_TYPE);
referralField.setFieldValue(DEFAULT_REFERRAL);
userSearchBaseField.setFieldValue(DEFAULT_USER_SEARCH_BASE);
userSearchFilterField.setFieldValue(DEFAULT_USER_SEARCH_FILTER);
userDNPatternsField.setFieldValue(DEFAULT_USER_DN_PATTERNS);
userAttributesField.setFieldValue(DEFAULT_USER_ATTRIBUTES);
groupSearchBaseField.setFieldValue(DEFAULT_GROUP_SEARCH_BASE);
groupSearchFilterField.setFieldValue(DEFAULT_GROUP_SEARCH_FILTER);
groupRoleAttributeField.setFieldValue(DEFAULT_GROUP_ROLE_ATTRIBUTE);
configurationModel.put(enabledField);
configurationModel.put(serverField);
configurationModel.put(managerDNField);
configurationModel.put(managerPasswordField);
configurationModel.put(authenticationTypeField);
configurationModel.put(referralField);
configurationModel.put(userSearchBaseField);
configurationModel.put(userSearchFilterField);
configurationModel.put(userDNPatternsField);
configurationModel.put(userAttributesField);
configurationModel.put(groupSearchBaseField);
configurationModel.put(groupSearchFilterField);
configurationModel.put(groupRoleAttributeField);
return configurationModel;
}
use of com.synopsys.integration.alert.common.persistence.model.ConfigurationFieldModel in project hub-alert by blackducksoftware.
the class ProxyConfigurationModelConverterTest method createDefaultConfigurationModel.
private ConfigurationModel createDefaultConfigurationModel() {
Map<String, ConfigurationFieldModel> fieldValuesMap = new HashMap<>();
ConfigurationFieldModel hostField = ConfigurationFieldModel.create(ProxyConfigurationModelConverter.FIELD_KEY_HOST);
ConfigurationFieldModel portField = ConfigurationFieldModel.create(ProxyConfigurationModelConverter.FIELD_KEY_PORT);
ConfigurationFieldModel passwordField = ConfigurationFieldModel.create(ProxyConfigurationModelConverter.FIELD_KEY_PASSWORD);
ConfigurationFieldModel userField = ConfigurationFieldModel.create(ProxyConfigurationModelConverter.FIELD_KEY_USERNAME);
ConfigurationFieldModel nonProxyHostField = ConfigurationFieldModel.create(ProxyConfigurationModelConverter.FIELD_KEY_NON_PROXY_HOSTS);
hostField.setFieldValue(TEST_SMTP_HOST);
portField.setFieldValue(TEST_SMTP_PORT);
passwordField.setFieldValue(TEST_AUTH_PASSWORD);
userField.setFieldValue(TEST_AUTH_USER);
nonProxyHostField.setFieldValues(TEST_NON_PROXY_HOSTS);
fieldValuesMap.put(ProxyConfigurationModelConverter.FIELD_KEY_HOST, hostField);
fieldValuesMap.put(ProxyConfigurationModelConverter.FIELD_KEY_PORT, portField);
fieldValuesMap.put(ProxyConfigurationModelConverter.FIELD_KEY_PASSWORD, passwordField);
fieldValuesMap.put(ProxyConfigurationModelConverter.FIELD_KEY_USERNAME, userField);
fieldValuesMap.put(ProxyConfigurationModelConverter.FIELD_KEY_NON_PROXY_HOSTS, nonProxyHostField);
return new ConfigurationModel(1L, 1L, "", "", ConfigContextEnum.GLOBAL, fieldValuesMap);
}
use of com.synopsys.integration.alert.common.persistence.model.ConfigurationFieldModel in project hub-alert by blackducksoftware.
the class EmailGlobalConfigurationModelConverterTest method createDefaultConfigurationModel.
private ConfigurationModel createDefaultConfigurationModel() {
Map<String, ConfigurationFieldModel> fieldValuesMap = new HashMap<>();
ConfigurationFieldModel fromField = ConfigurationFieldModel.create(EmailPropertyKeys.JAVAMAIL_FROM_KEY.getPropertyKey());
ConfigurationFieldModel hostField = ConfigurationFieldModel.create(EmailPropertyKeys.JAVAMAIL_HOST_KEY.getPropertyKey());
ConfigurationFieldModel portField = ConfigurationFieldModel.create(EmailPropertyKeys.JAVAMAIL_PORT_KEY.getPropertyKey());
ConfigurationFieldModel authField = ConfigurationFieldModel.create(EmailPropertyKeys.JAVAMAIL_AUTH_KEY.getPropertyKey());
ConfigurationFieldModel passwordField = ConfigurationFieldModel.create(EmailPropertyKeys.JAVAMAIL_PASSWORD_KEY.getPropertyKey());
ConfigurationFieldModel userField = ConfigurationFieldModel.create(EmailPropertyKeys.JAVAMAIL_USER_KEY.getPropertyKey());
ConfigurationFieldModel ehloField = ConfigurationFieldModel.create(EmailPropertyKeys.JAVAMAIL_EHLO_KEY.getPropertyKey());
fromField.setFieldValue(TEST_FROM);
hostField.setFieldValue(TEST_SMTP_HOST);
portField.setFieldValue(TEST_SMTP_PORT);
authField.setFieldValue(TEST_AUTH_REQUIRED);
passwordField.setFieldValue(TEST_AUTH_PASSWORD);
userField.setFieldValue(TEST_AUTH_USER);
ehloField.setFieldValue("true");
fieldValuesMap.put(EmailPropertyKeys.JAVAMAIL_FROM_KEY.getPropertyKey(), fromField);
fieldValuesMap.put(EmailPropertyKeys.JAVAMAIL_HOST_KEY.getPropertyKey(), hostField);
fieldValuesMap.put(EmailPropertyKeys.JAVAMAIL_PORT_KEY.getPropertyKey(), portField);
fieldValuesMap.put(EmailPropertyKeys.JAVAMAIL_AUTH_KEY.getPropertyKey(), authField);
fieldValuesMap.put(EmailPropertyKeys.JAVAMAIL_PASSWORD_KEY.getPropertyKey(), passwordField);
fieldValuesMap.put(EmailPropertyKeys.JAVAMAIL_USER_KEY.getPropertyKey(), userField);
fieldValuesMap.put(EmailPropertyKeys.JAVAMAIL_EHLO_KEY.getPropertyKey(), ehloField);
return new ConfigurationModel(1L, 1L, "", "", ConfigContextEnum.GLOBAL, fieldValuesMap);
}
Aggregations