use of com.synopsys.integration.alert.common.rest.model.SettingsProxyModel in project hub-alert by blackducksoftware.
the class SettingsProxyCrudActionsTest method deleteTest.
@Test
public void deleteTest() {
UUID uuid = UUID.randomUUID();
SettingsProxyConfigurationRepository settingsProxyConfigurationRepository = Mockito.mock(SettingsProxyConfigurationRepository.class);
NonProxyHostsConfigurationRepository nonProxyHostsConfigurationRepository = Mockito.mock(NonProxyHostsConfigurationRepository.class);
Mockito.when(settingsProxyConfigurationRepository.existsByName(AlertRestConstants.DEFAULT_CONFIGURATION_NAME)).thenReturn(true);
SettingsProxyConfigAccessor settingsProxyConfigAccessor = new SettingsProxyConfigAccessor(encryptionUtility, settingsProxyConfigurationRepository, nonProxyHostsConfigurationRepository);
SettingsProxyCrudActions configActions = new SettingsProxyCrudActions(authorizationManager, settingsProxyConfigAccessor, settingsProxyValidator, settingsDescriptorKey);
ActionResponse<SettingsProxyModel> actionResponse = configActions.delete();
Mockito.verify(settingsProxyConfigurationRepository).deleteByName(AlertRestConstants.DEFAULT_CONFIGURATION_NAME);
assertTrue(actionResponse.isSuccessful());
assertFalse(actionResponse.hasContent());
assertEquals(HttpStatus.NO_CONTENT, actionResponse.getHttpStatus());
}
use of com.synopsys.integration.alert.common.rest.model.SettingsProxyModel in project hub-alert by blackducksoftware.
the class SettingsProxyCrudActionsTest method createTest.
@Test
public void createTest() {
UUID uuid = UUID.randomUUID();
SettingsProxyConfigurationRepository settingsProxyConfigurationRepository = Mockito.mock(SettingsProxyConfigurationRepository.class);
NonProxyHostsConfigurationRepository nonProxyHostsConfigurationRepository = Mockito.mock(NonProxyHostsConfigurationRepository.class);
SettingsProxyConfigurationEntity entity = createSettingsProxyConfigurationEntity(uuid);
Mockito.when(settingsProxyConfigurationRepository.existsByName(AlertRestConstants.DEFAULT_CONFIGURATION_NAME)).thenReturn(false);
Mockito.when(settingsProxyConfigurationRepository.save(Mockito.any())).thenReturn(entity);
Mockito.when(settingsProxyConfigurationRepository.getOne(uuid)).thenReturn(entity);
SettingsProxyConfigAccessor settingsProxyConfigAccessor = new SettingsProxyConfigAccessor(encryptionUtility, settingsProxyConfigurationRepository, nonProxyHostsConfigurationRepository);
SettingsProxyCrudActions configActions = new SettingsProxyCrudActions(authorizationManager, settingsProxyConfigAccessor, settingsProxyValidator, settingsDescriptorKey);
ActionResponse<SettingsProxyModel> actionResponse = configActions.create(createSettingsProxyModel());
Mockito.verify(nonProxyHostsConfigurationRepository).saveAll(Mockito.any());
assertTrue(actionResponse.isSuccessful());
assertTrue(actionResponse.hasContent());
assertEquals(HttpStatus.OK, actionResponse.getHttpStatus());
assertModelObfuscated(actionResponse);
}
use of com.synopsys.integration.alert.common.rest.model.SettingsProxyModel in project hub-alert by blackducksoftware.
the class SettingsProxyValidatorTest method validateHostWithoutPortTest.
@Test
void validateHostWithoutPortTest() {
SettingsProxyModel settingsProxyModel = new SettingsProxyModel();
settingsProxyModel.setName(AlertRestConstants.DEFAULT_CONFIGURATION_NAME);
settingsProxyModel.setProxyHost(HOST);
ValidationResponseModel validationResponseModel = settingsProxyValidator.validate(settingsProxyModel);
assertTrue(validationResponseModel.hasErrors());
assertEquals(1, validationResponseModel.getErrors().size());
assertTrue(validationResponseModel.getErrors().containsKey(SettingsProxyValidator.PROXY_PORT_FIELD_NAME));
}
use of com.synopsys.integration.alert.common.rest.model.SettingsProxyModel in project hub-alert by blackducksoftware.
the class SettingsProxyValidatorTest method validatePortWithoutHostTest.
@Test
void validatePortWithoutHostTest() {
SettingsProxyModel settingsProxyModel = new SettingsProxyModel();
settingsProxyModel.setName(AlertRestConstants.DEFAULT_CONFIGURATION_NAME);
settingsProxyModel.setProxyPort(PORT);
ValidationResponseModel validationResponseModel = settingsProxyValidator.validate(settingsProxyModel);
assertTrue(validationResponseModel.hasErrors());
assertEquals(1, validationResponseModel.getErrors().size());
assertTrue(validationResponseModel.getErrors().containsKey(SettingsProxyValidator.PROXY_HOST_FIELD_NAME));
}
use of com.synopsys.integration.alert.common.rest.model.SettingsProxyModel in project hub-alert by blackducksoftware.
the class SettingsProxyValidatorTest method validateUsernameWithoutPasswordTest.
@Test
void validateUsernameWithoutPasswordTest() {
SettingsProxyModel settingsProxyModel = new SettingsProxyModel();
settingsProxyModel.setName(AlertRestConstants.DEFAULT_CONFIGURATION_NAME);
settingsProxyModel.setProxyHost(HOST);
settingsProxyModel.setProxyPort(PORT);
settingsProxyModel.setProxyUsername(USERNAME);
ValidationResponseModel validationResponseModel = settingsProxyValidator.validate(settingsProxyModel);
assertTrue(validationResponseModel.hasErrors());
assertEquals(1, validationResponseModel.getErrors().size());
assertTrue(validationResponseModel.getErrors().containsKey(SettingsProxyValidator.PROXY_PASSWORD_FIELD_NAME));
}
Aggregations