public JsonResult AddAuthenticablePrincipal(AuthenticablePrincipal entity) { try { AddAuthenticablePrincipalEntity result = userManagement.NewUser(entity, User); return(http.RespondSuccess(result)); } catch { return(http.RespondServerError()); } }
public void UserManagementLogic_NewUser_Unauthorized_ThrowsUnauthorizedAccessException() { ClaimsPrincipal user = new ClaimsPrincipal(); AuthenticablePrincipal newUser = GetAuthenticablePrincipalValid(); Mock <IAuthorizationLogic> authorizationLogic = new Mock <IAuthorizationLogic>(); authorizationLogic.Setup(x => x.IsAuthorizedThrowsException(AuthorizationScopes.ManageUsers, user, It.IsAny <ILoggableEntity>(), It.IsAny <EventCategory>())).Throws(new UnauthorizedAccessException()); Mock <IConfigurationRepository> configurationRepository = new Mock <IConfigurationRepository>(); UserManagementLogic userManagementLogic = new UserManagementLogic(configurationRepository.Object, authorizationLogic.Object); userManagementLogic.NewUser(newUser, user); }