use of com.synopsys.integration.alert.component.settings.encryption.model.SettingsEncryptionModel in project hub-alert by blackducksoftware.
the class SettingsEncryptionCrudActions method createMaskedSettingsEncryptionModel.
private SettingsEncryptionModel createMaskedSettingsEncryptionModel() {
// EncryptionUtility does not return a model. A SettingsEncryptionModel with values must be created in order to obfuscate in the ConfigurationCrudHelper later.
SettingsEncryptionModel settingsEncryptionModel = new SettingsEncryptionModel();
settingsEncryptionModel.setIsEncryptionPasswordSet(encryptionUtility.isPasswordSet());
settingsEncryptionModel.setIsEncryptionGlobalSaltSet(encryptionUtility.isGlobalSaltSet());
settingsEncryptionModel.setReadOnly(encryptionUtility.isEncryptionFromEnvironment());
return settingsEncryptionModel;
}
use of com.synopsys.integration.alert.component.settings.encryption.model.SettingsEncryptionModel in project hub-alert by blackducksoftware.
the class SettingsEncryptionControllerTestIT method testValidate.
@Test
@WithMockUser(roles = AlertIntegrationTestConstants.ROLE_ALERT_ADMIN)
public void testValidate() throws Exception {
SettingsEncryptionModel settingsEncryptionModel = new SettingsEncryptionModel();
settingsEncryptionModel.setEncryptionPassword("password");
settingsEncryptionModel.setEncryptionGlobalSalt("globalSalt");
String url = AlertRestConstants.SETTINGS_ENCRYPTION_PATH + "/validate";
MockHttpServletRequestBuilder request = MockMvcRequestBuilders.post(new URI(url)).with(SecurityMockMvcRequestPostProcessors.user("admin").roles(AlertIntegrationTestConstants.ROLE_ALERT_ADMIN)).with(SecurityMockMvcRequestPostProcessors.csrf()).content(gson.toJson(settingsEncryptionModel)).contentType(contentType);
mockMvc.perform(request).andExpect(MockMvcResultMatchers.status().isOk());
}
use of com.synopsys.integration.alert.component.settings.encryption.model.SettingsEncryptionModel in project hub-alert by blackducksoftware.
the class SettingsEncryptionValidatorTest method validateNotInitializedTest.
@Test
public void validateNotInitializedTest() {
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");
settingsEncryptionModel.setEncryptionGlobalSalt("globalSalt");
SettingsEncryptionValidator validator = new SettingsEncryptionValidator(encryptionUtilityWithoutProperties, systemMessageAccessor);
ValidationResponseModel validationResponseModel = validator.validate(settingsEncryptionModel);
assertFalse(validationResponseModel.hasErrors());
}
use of com.synopsys.integration.alert.component.settings.encryption.model.SettingsEncryptionModel in project hub-alert by blackducksoftware.
the class SettingsEncryptionValidatorTest method fieldNameTooShortTest.
@Test
public void fieldNameTooShortTest() {
SettingsEncryptionValidator validator = new SettingsEncryptionValidator(encryptionUtility, systemMessageAccessor);
SettingsEncryptionModel settingsEncryptionModel = new SettingsEncryptionModel();
settingsEncryptionModel.setEncryptionPassword("too");
settingsEncryptionModel.setEncryptionGlobalSalt("short");
ValidationResponseModel validationResponseModel = validator.validate(settingsEncryptionModel);
assertTrue(validationResponseModel.hasErrors());
assertEquals(2, validationResponseModel.getErrors().size());
}
use of com.synopsys.integration.alert.component.settings.encryption.model.SettingsEncryptionModel in project hub-alert by blackducksoftware.
the class SettingsEncryptionCrudActionsTest method assertModelObfuscated.
private void assertModelObfuscated(ActionResponse<SettingsEncryptionModel> actionResponse) {
Optional<SettingsEncryptionModel> optionalSettingsEncryptionModel = actionResponse.getContent();
assertTrue(optionalSettingsEncryptionModel.isPresent());
SettingsEncryptionModel settingsEncryptionModel = optionalSettingsEncryptionModel.get();
assertTrue(settingsEncryptionModel.getEncryptionPassword().isEmpty());
assertTrue(settingsEncryptionModel.getEncryptionGlobalSalt().isEmpty());
assertTrue(settingsEncryptionModel.getIsEncryptionPasswordSet());
assertTrue(settingsEncryptionModel.getIsEncryptionGlobalSaltSet());
assertTrue(settingsEncryptionModel.isReadOnly());
}
Aggregations