use of com.synopsys.integration.alert.common.persistence.model.ConfigurationModel in project hub-alert by blackducksoftware.
the class DefaultDescriptorGlobalConfigUtilityTest method testGetFieldModelActionNull.
@Test
public void testGetFieldModelActionNull() throws Exception {
DescriptorKey descriptorKey = createDescriptorKey();
FieldModel fieldModel = new FieldModel(descriptorKey.getUniversalKey(), ConfigContextEnum.GLOBAL.name(), Map.of());
ConfigurationModelConfigurationAccessor configurationModelConfigurationAccessor = Mockito.mock(ConfigurationModelConfigurationAccessor.class);
ConfigurationFieldModelConverter converter = Mockito.mock(ConfigurationFieldModelConverter.class);
ConfigurationModel configurationModel = Mockito.mock(ConfigurationModel.class);
ApiAction apiAction = Mockito.mock(ApiAction.class);
Mockito.when(configurationModelConfigurationAccessor.getConfigurationsByDescriptorKeyAndContext(Mockito.any(DescriptorKey.class), Mockito.any(ConfigContextEnum.class))).thenReturn(List.of(configurationModel));
Mockito.when(converter.convertToFieldModel(Mockito.any())).thenReturn(fieldModel);
Mockito.when(apiAction.afterGetAction(Mockito.eq(fieldModel))).thenReturn(null);
DefaultDescriptorGlobalConfigUtility configUtility = new DefaultDescriptorGlobalConfigUtility(descriptorKey, configurationModelConfigurationAccessor, apiAction, converter);
Optional<FieldModel> actualFieldModel = configUtility.getFieldModel();
assertFalse(actualFieldModel.isPresent());
}
use of com.synopsys.integration.alert.common.persistence.model.ConfigurationModel in project hub-alert by blackducksoftware.
the class DefaultDescriptorGlobalConfigUtilityTest method testGetConfiguration.
@Test
public void testGetConfiguration() throws Exception {
DescriptorKey descriptorKey = createDescriptorKey();
ConfigurationModelConfigurationAccessor configurationModelConfigurationAccessor = Mockito.mock(ConfigurationModelConfigurationAccessor.class);
DefaultDescriptorGlobalConfigUtility configUtility = new DefaultDescriptorGlobalConfigUtility(descriptorKey, configurationModelConfigurationAccessor, null, null);
assertFalse(configUtility.getConfiguration().isPresent());
ConfigurationModel configurationModel = Mockito.mock(ConfigurationModel.class);
Mockito.when(configurationModelConfigurationAccessor.getConfigurationsByDescriptorKeyAndContext(Mockito.any(DescriptorKey.class), Mockito.any(ConfigContextEnum.class))).thenReturn(List.of(configurationModel));
assertTrue(configUtility.getConfiguration().isPresent());
}
use of com.synopsys.integration.alert.common.persistence.model.ConfigurationModel in project hub-alert by blackducksoftware.
the class SAMLContext method disableSAML.
public void disableSAML() {
try {
ConfigurationModel configurationModel = getCurrentConfiguration();
Map<String, ConfigurationFieldModel> fields = configurationModel.getCopyOfKeyToFieldMap();
ConfigurationFieldModel enabledField = fields.get(AuthenticationDescriptor.KEY_SAML_ENABLED);
if (null == enabledField) {
enabledField = ConfigurationFieldModel.create(AuthenticationDescriptor.KEY_SAML_ENABLED);
fields.put(AuthenticationDescriptor.KEY_SAML_ENABLED, enabledField);
}
enabledField.setFieldValue(String.valueOf(false));
configurationModelConfigurationAccessor.updateConfiguration(configurationModel.getConfigurationId(), fields.values());
} catch (AlertException ex) {
logger.error("Error disabling SAML configuration.");
}
}
use of com.synopsys.integration.alert.common.persistence.model.ConfigurationModel in project hub-alert by blackducksoftware.
the class ConfigurationModelConfigurationAccessorTestIT method getConfigurationByIdTest.
@Test
public void getConfigurationByIdTest() {
ConfigurationFieldModel configField1 = ConfigurationFieldModel.create(FIELD_KEY_INSENSITIVE);
ConfigurationFieldModel configField2 = ConfigurationFieldModel.createSensitive(FIELD_KEY_SENSITIVE);
DescriptorKey descriptorKey = createDescriptorKey(DESCRIPTOR_NAME);
ConfigurationModel configurationModel1 = configurationModelConfigurationAccessor.createConfiguration(descriptorKey, ConfigContextEnum.DISTRIBUTION, Arrays.asList(configField1));
ConfigurationModel configurationModel2 = configurationModelConfigurationAccessor.createConfiguration(descriptorKey, ConfigContextEnum.DISTRIBUTION, Arrays.asList(configField2));
Optional<ConfigurationModel> optionalFoundConfig1 = configurationModelConfigurationAccessor.getConfigurationById(configurationModel1.getConfigurationId());
assertTrue(optionalFoundConfig1.isPresent());
ConfigurationModel foundConfig1 = optionalFoundConfig1.get();
assertEquals(configurationModel1.getDescriptorId(), foundConfig1.getDescriptorId());
assertEquals(configurationModel1.getConfigurationId(), foundConfig1.getConfigurationId());
Optional<ConfigurationModel> optionalFoundConfig2 = configurationModelConfigurationAccessor.getConfigurationById(configurationModel2.getConfigurationId());
assertTrue(optionalFoundConfig2.isPresent());
ConfigurationModel foundConfig2 = optionalFoundConfig2.get();
assertEquals(configurationModel2.getDescriptorId(), foundConfig2.getDescriptorId());
assertEquals(configurationModel2.getConfigurationId(), foundConfig2.getConfigurationId());
}
use of com.synopsys.integration.alert.common.persistence.model.ConfigurationModel in project hub-alert by blackducksoftware.
the class ConfigurationModelConfigurationAccessorTestIT method configurationModelTest.
@Test
public void configurationModelTest() {
DescriptorKey descriptorKey = createDescriptorKey(DESCRIPTOR_NAME);
ConfigurationModel configurationModel = configurationModelConfigurationAccessor.createConfiguration(descriptorKey, ConfigContextEnum.DISTRIBUTION, List.of());
assertNotNull(configurationModel.getConfigurationId());
assertNotNull(configurationModel.getDescriptorId());
assertNotNull(configurationModel.getCopyOfFieldList());
assertNotNull(configurationModel.getCopyOfKeyToFieldMap());
}
Aggregations