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);
}
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());
}
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();
}
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());
}
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());
}
Aggregations