Search in sources :

Example 6 with FilePersistenceUtil

use of com.synopsys.integration.alert.common.persistence.util.FilePersistenceUtil in project hub-alert by blackducksoftware.

the class DefaultConfigurationModelConfigurationAccessorTest method createEncryptionUtility.

private EncryptionUtility createEncryptionUtility() {
    alertProperties = Mockito.mock(AlertProperties.class);
    Mockito.when(alertProperties.getAlertEncryptionPassword()).thenReturn(Optional.of(TEST_PASSWORD));
    Mockito.when(alertProperties.getAlertEncryptionGlobalSalt()).thenReturn(Optional.of(TEST_SALT));
    Mockito.when(alertProperties.getAlertConfigHome()).thenReturn(TEST_DIRECTORY);
    Mockito.when(alertProperties.getAlertSecretsDir()).thenReturn(TEST_SECRETS_DIRECTORY);
    filePersistenceUtil = new FilePersistenceUtil(alertProperties, new Gson());
    return new EncryptionUtility(alertProperties, filePersistenceUtil);
}
Also used : FilePersistenceUtil(com.synopsys.integration.alert.common.persistence.util.FilePersistenceUtil) Gson(com.google.gson.Gson) AlertProperties(com.synopsys.integration.alert.common.AlertProperties) EncryptionUtility(com.synopsys.integration.alert.common.security.EncryptionUtility)

Example 7 with FilePersistenceUtil

use of com.synopsys.integration.alert.common.persistence.util.FilePersistenceUtil 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());
}
Also used : SettingsEncryptionCrudActions(com.synopsys.integration.alert.component.settings.encryption.action.SettingsEncryptionCrudActions) FilePersistenceUtil(com.synopsys.integration.alert.common.persistence.util.FilePersistenceUtil) SettingsEncryptionModel(com.synopsys.integration.alert.component.settings.encryption.model.SettingsEncryptionModel) MockAlertProperties(com.synopsys.integration.alert.test.common.MockAlertProperties) EncryptionUtility(com.synopsys.integration.alert.common.security.EncryptionUtility) Test(org.junit.jupiter.api.Test)

Example 8 with FilePersistenceUtil

use of com.synopsys.integration.alert.common.persistence.util.FilePersistenceUtil in project hub-alert by blackducksoftware.

the class EncryptionUtilityTest method initializeTest.

@BeforeEach
public void initializeTest() {
    alertProperties = Mockito.mock(AlertProperties.class);
    Mockito.when(alertProperties.getAlertEncryptionPassword()).thenReturn(Optional.of(TEST_PASSWORD));
    Mockito.when(alertProperties.getAlertEncryptionGlobalSalt()).thenReturn(Optional.of(TEST_SALT));
    Mockito.when(alertProperties.getAlertConfigHome()).thenReturn(TEST_DIRECTORY);
    Mockito.when(alertProperties.getAlertSecretsDir()).thenReturn(TEST_SECRETS_DIRECTORY);
    filePersistenceUtil = new FilePersistenceUtil(alertProperties, new Gson());
    encryptionUtility = new EncryptionUtility(alertProperties, filePersistenceUtil);
    File file = new File(TEST_DIRECTORY, "data");
    file.mkdirs();
}
Also used : FilePersistenceUtil(com.synopsys.integration.alert.common.persistence.util.FilePersistenceUtil) Gson(com.google.gson.Gson) AlertProperties(com.synopsys.integration.alert.common.AlertProperties) File(java.io.File) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 9 with FilePersistenceUtil

use of com.synopsys.integration.alert.common.persistence.util.FilePersistenceUtil in project hub-alert by blackducksoftware.

the class SettingsEncryptionValidatorTest method validateNotInitializedNoPasswordTest.

@Test
public void validateNotInitializedNoPasswordTest() {
    MockAlertProperties alertPropertiesNoEncryption = new MockAlertProperties();
    alertPropertiesNoEncryption.setEncryptionPassword("");
    alertPropertiesNoEncryption.setEncryptionSalt("");
    FilePersistenceUtil filePersistenceUtilWithoutProperties = new FilePersistenceUtil(alertPropertiesNoEncryption, gson);
    EncryptionUtility encryptionUtilityWithoutProperties = new EncryptionUtility(alertPropertiesNoEncryption, filePersistenceUtilWithoutProperties);
    SettingsEncryptionModel settingsEncryptionModel = new SettingsEncryptionModel();
    settingsEncryptionModel.setEncryptionGlobalSalt("globalSalt");
    SettingsEncryptionValidator validator = new SettingsEncryptionValidator(encryptionUtilityWithoutProperties, systemMessageAccessor);
    ValidationResponseModel validationResponseModel = validator.validate(settingsEncryptionModel);
    assertTrue(validationResponseModel.hasErrors());
    assertEquals(1, validationResponseModel.getErrors().size());
}
Also used : ValidationResponseModel(com.synopsys.integration.alert.common.rest.model.ValidationResponseModel) FilePersistenceUtil(com.synopsys.integration.alert.common.persistence.util.FilePersistenceUtil) SettingsEncryptionModel(com.synopsys.integration.alert.component.settings.encryption.model.SettingsEncryptionModel) MockAlertProperties(com.synopsys.integration.alert.test.common.MockAlertProperties) EncryptionUtility(com.synopsys.integration.alert.common.security.EncryptionUtility) Test(org.junit.jupiter.api.Test)

Example 10 with FilePersistenceUtil

use of com.synopsys.integration.alert.common.persistence.util.FilePersistenceUtil in project hub-alert by blackducksoftware.

the class SettingsEncryptionValidatorTest method validateNotInitializedNoGlobalSaltTest.

@Test
public void validateNotInitializedNoGlobalSaltTest() {
    MockAlertProperties alertPropertiesNoEncryption = new MockAlertProperties();
    alertPropertiesNoEncryption.setEncryptionPassword("");
    alertPropertiesNoEncryption.setEncryptionSalt("");
    FilePersistenceUtil filePersistenceUtilWithoutProperties = new FilePersistenceUtil(alertPropertiesNoEncryption, gson);
    EncryptionUtility encryptionUtilityWithoutProperties = new EncryptionUtility(alertPropertiesNoEncryption, filePersistenceUtilWithoutProperties);
    SettingsEncryptionModel settingsEncryptionModel = new SettingsEncryptionModel();
    settingsEncryptionModel.setEncryptionPassword("password");
    SettingsEncryptionValidator validator = new SettingsEncryptionValidator(encryptionUtilityWithoutProperties, systemMessageAccessor);
    ValidationResponseModel validationResponseModel = validator.validate(settingsEncryptionModel);
    assertTrue(validationResponseModel.hasErrors());
    assertEquals(1, validationResponseModel.getErrors().size());
}
Also used : ValidationResponseModel(com.synopsys.integration.alert.common.rest.model.ValidationResponseModel) FilePersistenceUtil(com.synopsys.integration.alert.common.persistence.util.FilePersistenceUtil) SettingsEncryptionModel(com.synopsys.integration.alert.component.settings.encryption.model.SettingsEncryptionModel) MockAlertProperties(com.synopsys.integration.alert.test.common.MockAlertProperties) EncryptionUtility(com.synopsys.integration.alert.common.security.EncryptionUtility) Test(org.junit.jupiter.api.Test)

Aggregations

FilePersistenceUtil (com.synopsys.integration.alert.common.persistence.util.FilePersistenceUtil)11 Test (org.junit.jupiter.api.Test)7 EncryptionUtility (com.synopsys.integration.alert.common.security.EncryptionUtility)5 MockAlertProperties (com.synopsys.integration.alert.test.common.MockAlertProperties)5 Gson (com.google.gson.Gson)4 AlertProperties (com.synopsys.integration.alert.common.AlertProperties)4 SettingsEncryptionModel (com.synopsys.integration.alert.component.settings.encryption.model.SettingsEncryptionModel)4 ValidationResponseModel (com.synopsys.integration.alert.common.rest.model.ValidationResponseModel)3 ParserPool (org.opensaml.xml.parse.ParserPool)3 ExtendedMetadata (org.springframework.security.saml.metadata.ExtendedMetadata)3 MetadataGenerator (org.springframework.security.saml.metadata.MetadataGenerator)3 ConfigurationModel (com.synopsys.integration.alert.common.persistence.model.ConfigurationModel)2 AuthenticationDescriptorKey (com.synopsys.integration.alert.component.authentication.descriptor.AuthenticationDescriptorKey)2 SAMLContext (com.synopsys.integration.alert.component.authentication.security.saml.SAMLContext)2 SAMLManager (com.synopsys.integration.alert.component.authentication.security.saml.SAMLManager)2 BeforeEach (org.junit.jupiter.api.BeforeEach)2 MetadataManager (org.springframework.security.saml.metadata.MetadataManager)2 AlertConfigurationException (com.synopsys.integration.alert.api.common.model.exception.AlertConfigurationException)1 AlertFieldStatus (com.synopsys.integration.alert.common.descriptor.config.field.errors.AlertFieldStatus)1 FieldModel (com.synopsys.integration.alert.common.rest.model.FieldModel)1