use of com.synopsys.integration.alert.api.common.model.ValidationResponseModel in project blackduck-alert by blackducksoftware.
the class SettingsProxyValidatorTest method validateUsernameWithoutPasswordIsProxyPasswordSetTest.
@Test
void validateUsernameWithoutPasswordIsProxyPasswordSetTest() {
SettingsProxyModel settingsProxyModel = new SettingsProxyModel(ID, AlertRestConstants.DEFAULT_CONFIGURATION_NAME, CREATED_AT, LAST_UPDATED, HOST, PORT, USERNAME, null, Boolean.TRUE, NON_PROXY_HOSTS);
ValidationResponseModel validationResponseModel = settingsProxyValidator.validate(settingsProxyModel);
assertFalse(validationResponseModel.hasErrors());
}
use of com.synopsys.integration.alert.api.common.model.ValidationResponseModel in project blackduck-alert by blackducksoftware.
the class UserActionsTest method testExternalUserNoEmailValidation.
@Test
public void testExternalUserNoEmailValidation() throws Exception {
AuthenticationType authenticationTypeLDAP = AuthenticationType.LDAP;
UserModel userModel = UserModel.existingUser(id, name, password, null, authenticationTypeLDAP, roles, true);
Mockito.when(authorizationManager.hasExecutePermission(Mockito.any(ConfigContextEnum.class), Mockito.any(DescriptorKey.class))).thenReturn(true);
Mockito.when(userAccessor.getUser(Mockito.anyLong())).thenReturn(Optional.of(userModel));
Set<String> roleNames = roles.stream().map(UserRoleModel::getName).collect(Collectors.toSet());
roleNames.add(DefaultUserRole.ALERT_ADMIN.name());
UserConfig userConfig = new UserConfig(id.toString(), name, "newPassword", null, roleNames, false, false, false, true, false, authenticationTypeLDAP.name(), true);
UserActions userActions = new UserActions(userManagementDescriptorKey, userAccessor, roleAccessor, authorizationManager, authenticationTypeAccessor, userSystemValidator);
ValidationActionResponse validationActionResponse = userActions.validate(userConfig);
assertFalse(validationActionResponse.isError());
assertTrue(validationActionResponse.hasContent());
ValidationResponseModel validationResponseModel = validationActionResponse.getContent().get();
assertFalse(validationResponseModel.hasErrors());
assertEquals("The user is valid", validationActionResponse.getMessage().get());
}
use of com.synopsys.integration.alert.api.common.model.ValidationResponseModel in project blackduck-alert by blackducksoftware.
the class SettingsProxyTestActionTestIT method testUrlWithBadResponseTest.
@Test
void testUrlWithBadResponseTest() {
SettingsProxyModel settingsProxyModel = createSettingsProxyModel(testProperties);
AuthorizationManager authorizationManager = createAuthorizationManager(AuthenticationTestUtils.FULL_PERMISSIONS);
settingsProxyTestAction = new SettingsProxyTestAction(authorizationManager, settingsProxyValidator, settingsDescriptorKey, proxyTestService, settingsProxyConfigAccessor);
ActionResponse<ValidationResponseModel> testResult = settingsProxyTestAction.testWithPermissionCheck("http://thisUrlWillReturnFailures", settingsProxyModel);
assertTrue(testResult.isSuccessful());
assertTrue(testResult.getContent().isPresent());
ValidationResponseModel validationResponseModel = testResult.getContent().get();
assertTrue(validationResponseModel.hasErrors());
}
use of com.synopsys.integration.alert.api.common.model.ValidationResponseModel in project blackduck-alert by blackducksoftware.
the class SettingsProxyTestActionTestIT method testWithPermissionCheckTest.
@Test
void testWithPermissionCheckTest() {
SettingsProxyModel settingsProxyModel = createSettingsProxyModel(testProperties);
AuthorizationManager authorizationManager = createAuthorizationManager(AuthenticationTestUtils.FULL_PERMISSIONS);
settingsProxyTestAction = new SettingsProxyTestAction(authorizationManager, settingsProxyValidator, settingsDescriptorKey, proxyTestService, settingsProxyConfigAccessor);
ActionResponse<ValidationResponseModel> testResult = settingsProxyTestAction.testWithPermissionCheck(validTargetUrl, settingsProxyModel);
assertTrue(testResult.isSuccessful());
assertTrue(testResult.getContent().isPresent());
ValidationResponseModel validationResponseModel = testResult.getContent().get();
assertFalse(validationResponseModel.hasErrors());
}
use of com.synopsys.integration.alert.api.common.model.ValidationResponseModel in project blackduck-alert by blackducksoftware.
the class SettingsProxyTestActionTestIT method testWithoutPermissionsCheckTest.
@Test
void testWithoutPermissionsCheckTest() {
SettingsProxyModel settingsProxyModel = createSettingsProxyModel(testProperties);
AuthorizationManager authorizationManager = createAuthorizationManager(AuthenticationTestUtils.NO_PERMISSIONS);
settingsProxyTestAction = new SettingsProxyTestAction(authorizationManager, settingsProxyValidator, settingsDescriptorKey, proxyTestService, settingsProxyConfigAccessor);
ActionResponse<ValidationResponseModel> testResult = settingsProxyTestAction.testWithPermissionCheck(validTargetUrl, settingsProxyModel);
assertTrue(testResult.isError());
assertTrue(testResult.getContent().isPresent());
ValidationResponseModel validationResponseModel = testResult.getContent().get();
assertTrue(validationResponseModel.hasErrors());
}
Aggregations