Search in sources :

Example 46 with DescriptorKey

use of com.synopsys.integration.alert.descriptor.api.model.DescriptorKey in project hub-alert by blackducksoftware.

the class JiraServerGlobalConfigurationModelSaveActionsTest method createAuthorizationManager.

private AuthorizationManager createAuthorizationManager() {
    AuthenticationTestUtils authenticationTestUtils = new AuthenticationTestUtils();
    DescriptorKey descriptorKey = ChannelKeys.JIRA_SERVER;
    PermissionKey permissionKey = new PermissionKey(ConfigContextEnum.GLOBAL.name(), descriptorKey.getUniversalKey());
    Map<PermissionKey, Integer> permissions = Map.of(permissionKey, AuthenticationTestUtils.FULL_PERMISSIONS);
    return authenticationTestUtils.createAuthorizationManagerWithCurrentUserSet("admin", "admin", () -> new PermissionMatrixModel(permissions));
}
Also used : PermissionMatrixModel(com.synopsys.integration.alert.common.persistence.model.PermissionMatrixModel) PermissionKey(com.synopsys.integration.alert.common.persistence.model.PermissionKey) AuthenticationTestUtils(com.synopsys.integration.alert.test.common.AuthenticationTestUtils) DescriptorKey(com.synopsys.integration.alert.descriptor.api.model.DescriptorKey)

Example 47 with DescriptorKey

use of com.synopsys.integration.alert.descriptor.api.model.DescriptorKey in project hub-alert by blackducksoftware.

the class ConfigurationModelConfigurationAccessorTestIT method deleteConfigurationTest.

@Test
public void deleteConfigurationTest() {
    DescriptorKey descriptorKey = createDescriptorKey(DESCRIPTOR_NAME);
    ConfigurationModel createdModel1 = configurationModelConfigurationAccessor.createConfiguration(descriptorKey, ConfigContextEnum.DISTRIBUTION, List.of());
    ConfigurationModel createdModel2 = configurationModelConfigurationAccessor.createConfiguration(descriptorKey, ConfigContextEnum.DISTRIBUTION, List.of());
    List<ConfigurationModel> foundModels = configurationModelConfigurationAccessor.getConfigurationsByDescriptorKey(descriptorKey);
    assertEquals(2, foundModels.size());
    configurationModelConfigurationAccessor.deleteConfiguration(createdModel1);
    List<ConfigurationModel> afterFirstDeletion = configurationModelConfigurationAccessor.getConfigurationsByDescriptorKey(descriptorKey);
    assertEquals(foundModels.size() - 1, afterFirstDeletion.size());
    configurationModelConfigurationAccessor.deleteConfiguration(createdModel2);
    List<ConfigurationModel> afterSecondDeletion = configurationModelConfigurationAccessor.getConfigurationsByDescriptorKey(descriptorKey);
    assertEquals(foundModels.size() - 2, afterSecondDeletion.size());
}
Also used : ConfigurationModel(com.synopsys.integration.alert.common.persistence.model.ConfigurationModel) DescriptorKey(com.synopsys.integration.alert.descriptor.api.model.DescriptorKey) AlertIntegrationTest(com.synopsys.integration.alert.util.AlertIntegrationTest) Test(org.junit.jupiter.api.Test)

Example 48 with DescriptorKey

use of com.synopsys.integration.alert.descriptor.api.model.DescriptorKey in project hub-alert by blackducksoftware.

the class ConfigurationModelConfigurationAccessorTestIT method updateConfigurationReplaceValueTest.

@Test
public void updateConfigurationReplaceValueTest() throws AlertConfigurationException {
    final String initialValue = "initial value";
    ConfigurationFieldModel originalField = ConfigurationFieldModel.create(FIELD_KEY_INSENSITIVE);
    originalField.setFieldValue(initialValue);
    DescriptorKey descriptorKey = createDescriptorKey(DESCRIPTOR_NAME);
    ConfigurationModel createdModel = configurationModelConfigurationAccessor.createConfiguration(descriptorKey, ConfigContextEnum.DISTRIBUTION, Arrays.asList(originalField));
    List<ConfigurationFieldModel> copyOfFieldList = createdModel.getCopyOfFieldList();
    assertEquals(1, copyOfFieldList.size());
    Optional<String> optionalValue = copyOfFieldList.get(0).getFieldValue();
    assertTrue(optionalValue.isPresent());
    assertEquals(initialValue, optionalValue.get());
    final String additionalValue = "additional value";
    ConfigurationFieldModel newFieldWithSameKey = ConfigurationFieldModel.create(FIELD_KEY_INSENSITIVE);
    newFieldWithSameKey.setFieldValue(additionalValue);
    ConfigurationModel updatedModel = configurationModelConfigurationAccessor.updateConfiguration(createdModel.getConfigurationId(), Arrays.asList(newFieldWithSameKey));
    List<ConfigurationFieldModel> configuredFields = updatedModel.getCopyOfFieldList();
    assertEquals(1, configuredFields.size());
    ConfigurationFieldModel configuredField = configuredFields.get(0);
    assertEquals(originalField, configuredField);
    assertTrue(configuredField.getFieldValues().contains(additionalValue));
    List<FieldValueEntity> databaseFieldValues = fieldValueRepository.findByConfigId(updatedModel.getConfigurationId());
    assertNotNull(databaseFieldValues);
    assertEquals(1, databaseFieldValues.size());
}
Also used : ConfigurationModel(com.synopsys.integration.alert.common.persistence.model.ConfigurationModel) ConfigurationFieldModel(com.synopsys.integration.alert.common.persistence.model.ConfigurationFieldModel) DescriptorKey(com.synopsys.integration.alert.descriptor.api.model.DescriptorKey) FieldValueEntity(com.synopsys.integration.alert.database.configuration.FieldValueEntity) AlertIntegrationTest(com.synopsys.integration.alert.util.AlertIntegrationTest) Test(org.junit.jupiter.api.Test)

Example 49 with DescriptorKey

use of com.synopsys.integration.alert.descriptor.api.model.DescriptorKey in project hub-alert by blackducksoftware.

the class ConfigurationModelConfigurationAccessorTestIT method createConfigTest.

@Test
public void createConfigTest() {
    ConfigurationFieldModel configField1 = ConfigurationFieldModel.create(FIELD_KEY_INSENSITIVE);
    ConfigurationFieldModel configField2 = ConfigurationFieldModel.createSensitive(FIELD_KEY_SENSITIVE);
    DescriptorKey descriptorKey = createDescriptorKey(DESCRIPTOR_NAME);
    ConfigurationModel createdConfig = configurationModelConfigurationAccessor.createConfiguration(descriptorKey, ConfigContextEnum.DISTRIBUTION, List.of(configField1, configField2));
    assertTrue(createdConfig.getCopyOfFieldList().contains(configField1));
    assertTrue(createdConfig.getCopyOfFieldList().contains(configField2));
    Optional<DescriptorConfigEntity> configEntityOptional = descriptorConfigsRepository.findById(createdConfig.getConfigurationId());
    assertTrue(configEntityOptional.isPresent());
}
Also used : ConfigurationModel(com.synopsys.integration.alert.common.persistence.model.ConfigurationModel) ConfigurationFieldModel(com.synopsys.integration.alert.common.persistence.model.ConfigurationFieldModel) DescriptorConfigEntity(com.synopsys.integration.alert.database.configuration.DescriptorConfigEntity) DescriptorKey(com.synopsys.integration.alert.descriptor.api.model.DescriptorKey) AlertIntegrationTest(com.synopsys.integration.alert.util.AlertIntegrationTest) Test(org.junit.jupiter.api.Test)

Example 50 with DescriptorKey

use of com.synopsys.integration.alert.descriptor.api.model.DescriptorKey in project hub-alert by blackducksoftware.

the class ConfigurationModelConfigurationAccessorTestIT method updateConfigurationMultipleValueTest.

@Test
public void updateConfigurationMultipleValueTest() throws AlertConfigurationException {
    final String initialValue = "initial value";
    ConfigurationFieldModel originalField = ConfigurationFieldModel.create(FIELD_KEY_INSENSITIVE);
    originalField.setFieldValue(initialValue);
    DescriptorKey descriptorKey = createDescriptorKey(DESCRIPTOR_NAME);
    ConfigurationModel createdModel = configurationModelConfigurationAccessor.createConfiguration(descriptorKey, ConfigContextEnum.DISTRIBUTION, Arrays.asList(originalField));
    List<ConfigurationFieldModel> copyOfFieldList = createdModel.getCopyOfFieldList();
    assertEquals(1, copyOfFieldList.size());
    Optional<String> optionalValue = copyOfFieldList.get(0).getFieldValue();
    assertTrue(optionalValue.isPresent());
    assertEquals(initialValue, optionalValue.get());
    final String additionalValue = "additional value";
    ConfigurationFieldModel newFieldWithSameKey = ConfigurationFieldModel.create(FIELD_KEY_INSENSITIVE);
    newFieldWithSameKey.setFieldValue(additionalValue);
    ConfigurationModel updatedModel = configurationModelConfigurationAccessor.updateConfiguration(createdModel.getConfigurationId(), Arrays.asList(originalField, newFieldWithSameKey));
    List<ConfigurationFieldModel> configuredFields = updatedModel.getCopyOfFieldList();
    assertEquals(1, configuredFields.size());
    ConfigurationFieldModel configuredField = configuredFields.get(0);
    assertEquals(originalField, configuredField);
    assertTrue(configuredField.getFieldValues().contains(initialValue));
    assertTrue(configuredField.getFieldValues().contains(additionalValue));
    List<FieldValueEntity> databaseFieldValues = fieldValueRepository.findByConfigId(updatedModel.getConfigurationId());
    assertNotNull(databaseFieldValues);
    assertEquals(2, databaseFieldValues.size());
    assertEquals(configuredField.getFieldValues().size(), databaseFieldValues.size());
}
Also used : ConfigurationModel(com.synopsys.integration.alert.common.persistence.model.ConfigurationModel) ConfigurationFieldModel(com.synopsys.integration.alert.common.persistence.model.ConfigurationFieldModel) DescriptorKey(com.synopsys.integration.alert.descriptor.api.model.DescriptorKey) FieldValueEntity(com.synopsys.integration.alert.database.configuration.FieldValueEntity) AlertIntegrationTest(com.synopsys.integration.alert.util.AlertIntegrationTest) Test(org.junit.jupiter.api.Test)

Aggregations

DescriptorKey (com.synopsys.integration.alert.descriptor.api.model.DescriptorKey)91 Test (org.junit.jupiter.api.Test)72 PermissionKey (com.synopsys.integration.alert.common.persistence.model.PermissionKey)42 PermissionMatrixModel (com.synopsys.integration.alert.common.persistence.model.PermissionMatrixModel)42 AuthenticationTestUtils (com.synopsys.integration.alert.test.common.AuthenticationTestUtils)41 AuthorizationManager (com.synopsys.integration.alert.common.security.authorization.AuthorizationManager)39 ConfigurationFieldModel (com.synopsys.integration.alert.common.persistence.model.ConfigurationFieldModel)29 ConfigurationModel (com.synopsys.integration.alert.common.persistence.model.ConfigurationModel)28 ConfigContextEnum (com.synopsys.integration.alert.common.enumeration.ConfigContextEnum)23 ConfigurationFieldModelConverter (com.synopsys.integration.alert.common.persistence.util.ConfigurationFieldModelConverter)23 ChannelKey (com.synopsys.integration.alert.descriptor.api.model.ChannelKey)23 ActionResponse (com.synopsys.integration.alert.common.action.ActionResponse)21 ConfigurationModelConfigurationAccessor (com.synopsys.integration.alert.common.persistence.accessor.ConfigurationModelConfigurationAccessor)18 DescriptorAccessor (com.synopsys.integration.alert.common.persistence.accessor.DescriptorAccessor)17 FieldModel (com.synopsys.integration.alert.common.rest.model.FieldModel)17 ValidationActionResponse (com.synopsys.integration.alert.common.action.ValidationActionResponse)13 EmailGlobalConfigurationValidator (com.synopsys.integration.alert.channel.email.validator.EmailGlobalConfigurationValidator)12 DefinedFieldModel (com.synopsys.integration.alert.common.persistence.model.DefinedFieldModel)12 EncryptionUtility (com.synopsys.integration.alert.common.security.EncryptionUtility)12 EmailGlobalConfigModel (com.synopsys.integration.alert.service.email.model.EmailGlobalConfigModel)12