Exemplo n.º 1
0
        public void ThrowWhenRemovingAdminRoleFromAdmin()
        {
            var admin = AuthUserTestHelper.User(Username.ADMIN).WithRoles(RegisteredRole, AdminRole).Build();

            Action removing = () => _userRoleService.RemoveRole(admin, AdminRole);

            removing.Should().Throw <ManualValidationException>();
        }
Exemplo n.º 2
0
        public void SwapOutRolesWhenAllIsWell()
        {
            var authUser = AuthUserTestHelper.User().WithRoles(PendingRole).Build();

            _userRegistrationService.Register(authUser, RegisteredRole, PendingRole);

            authUser.RoleIds.Should().BeEquivalentTo(RegisteredRole.Id);
        }
Exemplo n.º 3
0
        public void RemoveRoleWhenAllIsWell()
        {
            var authUser = AuthUserTestHelper.User().WithRoles(RegisteredRole, AdminRole).Build();

            _userRoleService.RemoveRole(authUser, AdminRole);

            authUser.RoleIds.Should().BeEquivalentTo(RegisteredRole.Id);
        }
Exemplo n.º 4
0
        public void ValidationErrorWhenUserHasNoRoles()
        {
            var authUser = AuthUserTestHelper.User().WithRoles().Build();

            Action registration = () => _userRegistrationService.Register(authUser, RegisteredRole, PendingRole);

            registration.Should().Throw <ManualValidationException>();
        }
Exemplo n.º 5
0
        public void ThrowWhenRemovingNonAssignedRole()
        {
            var authUser        = AuthUserTestHelper.User().WithRoles(RegisteredRole).Build();
            var nonAssignedRole = AdminRole;

            Action removing = () => _userRoleService.RemoveRole(authUser, nonAssignedRole);

            removing.Should().Throw <ManualValidationException>();
        }
Exemplo n.º 6
0
        public void ThrowWhenAssigningDuplicateRoles()
        {
            var authUser      = AuthUserTestHelper.User().WithRoles(RegisteredRole).Build();
            var duplicateRole = RegisteredRole;

            Action assigning = () => _userRoleService.AssignRole(authUser, duplicateRole);

            assigning.Should().Throw <ManualValidationException>();
        }
Exemplo n.º 7
0
        public void ThrowWhenNotPassingPendingRole()
        {
            var authUser  = AuthUserTestHelper.User().WithRoles(PendingRole).Build();
            var wrongRole = RegisteredRole;

            Action registration = () => _userRegistrationService.Register(authUser, RegisteredRole, wrongRole);

            registration.Should().Throw <ArgumentException>();
        }
Exemplo n.º 8
0
 private static AuthUser BuildAuthUser(long id, string name, params Role[] roles)
 {
     return(AuthUserTestHelper.User(name).WithId(id).WithRoles(roles).Build());
 }