public void UserManagementLogic_SetUser_Unauthorized_ThrowsUnauthorizedAccessException()
        {
            ClaimsPrincipal user = new ClaimsPrincipal();
            UpdateUserModel authenticablePrincipal = GetUpdateUserModelValid();

            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.SetUser(authenticablePrincipal, user);
        }
        public void UserManagementLogic_SetUser_InvalidUser_ThrowsReferencedObjectDoesNotExistException()
        {
            ClaimsPrincipal user            = new ClaimsPrincipal();
            UpdateUserModel updateUserModel = new UpdateUserModel()
            {
                Id = Guid.NewGuid()
            };

            Mock <IConfigurationRepository> configurationRepository = new Mock <IConfigurationRepository>();

            configurationRepository.Setup(x => x.Get <AuthenticablePrincipal>(It.IsAny <Guid>())).Returns((AuthenticablePrincipal)null);

            UserManagementLogic userManagementLogic = new UserManagementLogic(configurationRepository.Object, new AuthorizeInitialSetup(configurationRepository.Object));

            userManagementLogic.SetUser(updateUserModel, user);
        }
        public void UserManagementLogic_SetUser_UpdateModelHasNullUpn_ThrowsInsufficientDataException()
        {
            ClaimsPrincipal user            = new ClaimsPrincipal();
            UpdateUserModel updateUserModel = new UpdateUserModel()
            {
                Id = Guid.NewGuid(), Name = null
            };
            AuthenticablePrincipal validUser = new AuthenticablePrincipal();

            Mock <IConfigurationRepository> configurationRepository = new Mock <IConfigurationRepository>();

            configurationRepository.Setup(x => x.Get <AuthenticablePrincipal>(It.IsAny <Guid>())).Returns(validUser);

            UserManagementLogic userManagementLogic = new UserManagementLogic(configurationRepository.Object, new AuthorizeInitialSetup(configurationRepository.Object));

            userManagementLogic.SetUser(updateUserModel, user);
        }
 public JsonResult UpdateAuthenticablePrincipal(UpdateUserModel entity)
 {
     return(http.RespondSuccess(userManagement.SetUser(entity, User)));
 }