Beispiel #1
0
        public void ThenUserHasNoAssignedActiveDirectoryAccount(string userName)
        {
            Guid userId = MockDatabase.GetUser(userName).Id;
            IEnumerable <IAccount> accounts = IdentityManagementService.GetUserAccounts(userId);

            Assert.IsFalse(accounts.Any(o => o.Type == AccountType.Federated));
        }
Beispiel #2
0
        public void WhenTheExternalGroupNameOfTheGroupIsCleared(string groupName)
        {
            Guid   groupId = nameIdentifierPairs[groupName];
            IGroup group   = IdentityManagementService.GetGroup(groupId);

            Try(() => IdentityManagementService.UpdateGroup(groupId, groupName, group.Description, group.IsDisabled, null));
        }
Beispiel #3
0
        public void ThenUserHasAFederatedAccountWithName(string userName, string accountName)
        {
            Guid userId = MockDatabase.GetUser(userName).Id;
            IEnumerable <IAccount> accounts = IdentityManagementService.GetUserAccounts(userId);

            Assert.AreEqual(1, accounts.Count(a => a.Type == AccountType.Federated && a.Name == accountName));
        }
Beispiel #4
0
        public void WhenActiveDirectoryAccountNameIsChangedToForUser(string accountName, string userName)
        {
            Guid  userId = nameIdentifierPairs[userName];
            IUser user   = IdentityManagementService.GetUser(userId);

            Try(() => IdentityManagementService.UpdateExternalUserAccount(user.Id, AccountType.ActiveDirectory, accountName));
        }
Beispiel #5
0
        public void WhenPermissionIsRemovedFromRole(string permissionName, string roleName)
        {
            Permission permission = MockDatabase.GetOrCreatePermission(permissionName);
            Role       role       = MockDatabase.GetRole(roleName);

            Try(() => IdentityManagementService.RemoveRolePermission(role.Id, permission.Id));
        }
Beispiel #6
0
        public void ThenRoleHasNoPermissions(string roleName)
        {
            Guid  roleId = MockDatabase.GetRole(roleName).Id;
            IRole role   = IdentityManagementService.GetRole(roleId);

            Assert.AreEqual(0, role.Permissions.Count);
        }
Beispiel #7
0
        public void ThenUserHasCustomPropertyWithTheValue(string userName, string customPropertyName, string customPropertyValue)
        {
            Guid  userId = MockDatabase.GetUser(userName).Id;
            IUser user   = IdentityManagementService.GetUser(userId);

            Assert.IsTrue(user.CustomProperties.Any(p => p.Name.Equals(customPropertyName) && p.Value.Equals(customPropertyValue)));
        }
Beispiel #8
0
        public void WhenTheExternalGroupNameOfTheGroupIsChangedTo(string groupName, string externalGroup)
        {
            Guid   groupId = MockDatabase.GetGroup(groupName).Id;
            IGroup group   = IdentityManagementService.GetGroup(groupId);

            Try(() => IdentityManagementService.UpdateGroup(groupId, groupName, group.Description, group.IsDisabled, externalGroup));
        }
Beispiel #9
0
 public void WhenExternalActiveDirectoryUsersAreSearchedByCustomPropertyNameAndValue(string customPropertyName, string customPropertyValue)
 {
     Try(() =>
     {
         returnedUsers = IdentityManagementService.GetUsers(customPropertyName, customPropertyValue, AccountType.ActiveDirectory).ToList();
     });
 }
 public AccessManagement(
     IIdentityService identityService,
     IdentityManagementService managementService)
 {
     _identityService   = identityService;
     _managementService = managementService;
 }
Beispiel #11
0
 public void WhenUsersAreSearchedByCustomPropertyNameAndValue(string customPropertyName, string customPropertyValue)
 {
     Try(() =>
     {
         returnedUsers = IdentityManagementService.GetUsers(customPropertyName, customPropertyValue).ToList();
     });
 }
Beispiel #12
0
        public void WhenTheUserIsRemovedFromTheOrganization(string user, string organization)
        {
            Guid organizationId = MockDatabase.GetOrganization(organization).Id;
            Guid userId         = nameIdentifierPairs[user];

            Try(() => IdentityManagementService.RemoveUserOrganization(userId, organizationId));
        }
Beispiel #13
0
 public void WhenAUserIsAdded(string userName)
 {
     Try(() =>
     {
         IUserListItem userListItem = IdentityManagementService.CreateUser(userName);
         nameIdentifierPairs.Add(userName, userListItem.Id);
     });
 }
Beispiel #14
0
        public void ThenAllUsersAreEnabled()
        {
            IEnumerable <IUserListItem> users = IdentityManagementService.GetUsers();

            foreach (IUserListItem user in users)
            {
                Assert.IsFalse(user.IsDisabled, user.Name);
            }
        }
Beispiel #15
0
 public void WhenRemovingActiveDirectoryAccountFromUser(string user)
 {
     Try(() =>
     {
         Guid userId = nameIdentifierPairs[user];
         var name    = MockDatabase.GetUser(user).Accounts.Single(o => o.Type == Store.Model.AccountType.ActiveDirectory).Name;
         IdentityManagementService.RemoveUserAccount(userId, AccountType.ActiveDirectory, name);
     });
 }
Beispiel #16
0
        public void ThenAllGroupsAreEnabled()
        {
            IEnumerable <IGroup> groups = IdentityManagementService.GetGroups();

            foreach (IGroup group in groups)
            {
                Assert.IsFalse(group.IsDisabled, group.Name);
            }
        }
Beispiel #17
0
        public void ThenTheGroupHasTheFollowingMembers(string group, Table expectedMembers)
        {
            List <IUserListItem> members = IdentityManagementService.GetGroupMembers(nameIdentifierPairs[group]).ToList();

            Assert.AreEqual(expectedMembers.RowCount, members.Count);
            foreach (TableRow expectedMember in expectedMembers.Rows)
            {
                Assert.IsTrue(members.Any(m => m.Name.Equals(expectedMember["User"])), expectedMember.ToTableString());
            }
        }
Beispiel #18
0
        public void ThenUserHasAnAccountWithNameAndPassword(string userName, string accountName, string password)
        {
            Guid userId = MockDatabase.GetUser(userName).Id;
            IEnumerable <IAccount> accounts = IdentityManagementService.GetUserAccounts(userId);

            IAccount account = accounts.SingleOrDefault(a => a.Type == AccountType.Password && a.Name == accountName);

            Assert.IsNotNull(account);
            Assert.IsTrue(UserService.IsMatchingPassword(accountName, password));
        }
Beispiel #19
0
        private void UpdateUser(string userName, Table customPropertiesTable, string newUserName)
        {
            List <KeyValuePair <string, string> > customProperties = customPropertiesTable.Rows
                                                                     .Select(row => new KeyValuePair <string, string>(row["Name"], row["Value"]))
                                                                     .ToList();

            Guid userId = nameIdentifierPairs[userName];

            IdentityManagementService.UpdateUser(userId, newUserName, false, customProperties);
        }
Beispiel #20
0
        private void CreateUser(string userName, Table customPropertiesTable)
        {
            List <KeyValuePair <string, string> > customProperties = customPropertiesTable.Rows
                                                                     .Select(row => new KeyValuePair <string, string>(row["Name"], row["Value"]))
                                                                     .ToList();

            IUserListItem userListItem = IdentityManagementService.CreateUser(userName, customProperties);

            nameIdentifierPairs.Add(userName, userListItem.Id);
        }
Beispiel #21
0
        public void ThenTheUserIsInTheFollowingOrganizations(string userName, Table expectedOrganizations)
        {
            IUser user = IdentityManagementService.GetUser(nameIdentifierPairs[userName]);

            Assert.AreEqual(expectedOrganizations.RowCount, user.Organizations.Count);
            foreach (TableRow row in expectedOrganizations.Rows)
            {
                Assert.IsNotNull(user.Organizations.SingleOrDefault(o => o.Name == row["Organization"]));
            }
        }
Beispiel #22
0
        public void ThenTheFollowingUsersExist(Table expectedUsers)
        {
            List <IUserListItem> users = IdentityManagementService.GetUsers().ToList();

            Assert.AreEqual(expectedUsers.RowCount, users.Count);

            foreach (TableRow expectedUser in expectedUsers.Rows)
            {
                Assert.IsTrue(users.Any(u => u.Name.Equals(expectedUser["Name"])), expectedUser.ToTableString());
            }
        }
Beispiel #23
0
        public void ThenTheFollowingGroupsExist(Table expectedGroups)
        {
            List <IGroup> groups = IdentityManagementService.GetGroups().ToList();

            Assert.AreEqual(expectedGroups.RowCount, groups.Count);
            foreach (TableRow expectedGroup in expectedGroups.Rows)
            {
                Assert.IsTrue(groups.Any(g => g.Name.Equals(expectedGroup["Name"]) && Equals(g.Description, expectedGroup["Description"]) &&
                                         Equals(g.ExternalGroupName, expectedGroup["External group"])), expectedGroup.ToTableString());
            }
        }
Beispiel #24
0
        public void ThenTheUserHasTheFollowingRoles(string userName, Table expectedRoles)
        {
            Guid userId = MockDatabase.GetUser(userName).Id;
            IReadOnlyCollection <IRole> roles = IdentityManagementService.GetUser(userId).Roles;

            Assert.AreEqual(expectedRoles.RowCount, roles.Count);

            foreach (TableRow expectedRole in expectedRoles.Rows)
            {
                Assert.IsTrue(roles.Any(r => r.Name.Equals(expectedRole["Role"])));
            }
        }
Beispiel #25
0
        public void ThenTheUserHasTheFollowingCustomProperties(string userName, Table expectedCustomProperties)
        {
            Guid userId = MockDatabase.GetUser(userName).Id;
            IReadOnlyCollection <ICustomProperty> customProperties = IdentityManagementService.GetUser(userId).CustomProperties;

            Assert.AreEqual(expectedCustomProperties.RowCount, customProperties.Count);

            foreach (TableRow expectedCustomProperty in expectedCustomProperties.Rows)
            {
                Assert.IsTrue(customProperties.Any(c => c.Name == expectedCustomProperty["Name"] && c.Value == expectedCustomProperty["Value"]));
            }
        }
Beispiel #26
0
        public void ThenTheUserHasIsAMemberOfTheFollowingGroups(string user, Table table)
        {
            Guid          userId = MockDatabase.GetUser(user).Id;
            List <IGroup> groups = IdentityManagementService.GetUserGroups(userId).ToList();

            Assert.AreEqual(table.Rows.Count, groups.Count);

            foreach (var row in table.Rows)
            {
                Assert.IsNotNull(groups.FirstOrDefault(o => o.Name == row["Group"]), row.ToTableString());
            }
        }
Beispiel #27
0
 public void ThenTheFollowingOrganizationsExist(Table expectedOrganizations)
 {
     organizations = IdentityManagementService.GetOrganizations().ToList();
     Assert.AreEqual(expectedOrganizations.RowCount, organizations.Count);
     foreach (TableRow expectedOrganization in expectedOrganizations.Rows)
     {
         Assert.IsTrue(organizations.Any(o => o.Name.Equals(expectedOrganization["Name"]) &&
                                         o.Description.Equals(expectedOrganization["Description"]) &&
                                         (o.Email ?? string.Empty).Equals(expectedOrganization["Email"])),
                       expectedOrganization.ToTableString());
     }
 }
Beispiel #28
0
        public void ThenRoleHasFollowingPermissions(string roleName, Table table)
        {
            Guid  roleId = MockDatabase.GetRole(roleName).Id;
            IRole role   = IdentityManagementService.GetRole(roleId);

            foreach (var permission in table.Rows.Select(row => row["Permission"]))
            {
                Assert.IsTrue(role.Permissions.Any(o => o.Name == permission));
            }

            foreach (var permission in role.Permissions)
            {
                Assert.IsTrue(table.Rows.Any(row => row["Permission"] == permission.Name));
            }
        }
Beispiel #29
0
        public void ThenThereAreFollowingRoles(Table table)
        {
            var roles = IdentityManagementService.GetRoles().ToList();

            Assert.AreEqual(table.Rows.Count, roles.Count());

            foreach (var row in table.Rows)
            {
                var name              = row["Name"];
                var description       = row["Description"];
                var externalGroupName = row["External group"];
                Assert.IsNotNull(
                    roles.SingleOrDefault(o => o.Name == name && Equals(o.Description, description) && Equals(o.ExternalGroupName, externalGroupName)),
                    row.ToTableString());
            }
        }
Beispiel #30
0
 public void WhenAGroupWithNoNameIsAdded()
 {
     Try(() => IdentityManagementService.CreateGroup(string.Empty, string.Empty, string.Empty));
 }