use of com.synopsys.integration.alert.component.settings.encryption.model.SettingsEncryptionModel in project hub-alert by blackducksoftware.
the class SettingsEncryptionCrudActionsTest method getOneTest.
@Test
void getOneTest() {
SettingsEncryptionCrudActions configActions = new SettingsEncryptionCrudActions(authorizationManager, encryptionUtility, validator, settingsDescriptorKey);
ActionResponse<SettingsEncryptionModel> actionResponse = configActions.getOne();
assertTrue(actionResponse.isSuccessful());
assertTrue(actionResponse.hasContent());
assertEquals(HttpStatus.OK, actionResponse.getHttpStatus());
assertModelObfuscated(actionResponse);
}
use of com.synopsys.integration.alert.component.settings.encryption.model.SettingsEncryptionModel in project hub-alert by blackducksoftware.
the class SettingsEncryptionCrudActionsTest method updateTest.
@Test
void updateTest() {
SettingsEncryptionModel settingsEncryptionModel = new SettingsEncryptionModel();
settingsEncryptionModel.setEncryptionPassword("password");
settingsEncryptionModel.setEncryptionGlobalSalt("globalSalt");
SettingsEncryptionCrudActions configActions = new SettingsEncryptionCrudActions(authorizationManager, encryptionUtility, validator, settingsDescriptorKey);
ActionResponse<SettingsEncryptionModel> actionResponse = configActions.update(settingsEncryptionModel);
assertTrue(actionResponse.isSuccessful());
assertTrue(actionResponse.hasContent());
assertEquals(HttpStatus.OK, actionResponse.getHttpStatus());
assertModelObfuscated(actionResponse);
}
use of com.synopsys.integration.alert.component.settings.encryption.model.SettingsEncryptionModel in project hub-alert by blackducksoftware.
the class SettingsEncryptionControllerTestIT method testUpdate.
@Test
@WithMockUser(roles = AlertIntegrationTestConstants.ROLE_ALERT_ADMIN)
public void testUpdate() throws Exception {
SettingsEncryptionModel settingsEncryptionModel = new SettingsEncryptionModel();
settingsEncryptionModel.setEncryptionPassword("password");
settingsEncryptionModel.setEncryptionGlobalSalt("globalSalt");
String url = AlertRestConstants.SETTINGS_ENCRYPTION_PATH;
MockHttpServletRequestBuilder request = MockMvcRequestBuilders.put(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().isNoContent());
}
use of com.synopsys.integration.alert.component.settings.encryption.model.SettingsEncryptionModel 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.component.settings.encryption.model.SettingsEncryptionModel in project hub-alert by blackducksoftware.
the class SettingsEncryptionValidatorTest method validateTest.
@Test
public void validateTest() {
SettingsEncryptionValidator validator = new SettingsEncryptionValidator(encryptionUtility, systemMessageAccessor);
SettingsEncryptionModel settingsEncryptionModel = new SettingsEncryptionModel();
settingsEncryptionModel.setEncryptionPassword("password");
settingsEncryptionModel.setEncryptionGlobalSalt("globalSalt");
ValidationResponseModel validationResponseModel = validator.validate(settingsEncryptionModel);
assertFalse(validationResponseModel.hasErrors());
}
Aggregations