Ejemplo n.º 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));
        }
Ejemplo n.º 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));
        }
Ejemplo n.º 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));
        }
Ejemplo n.º 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));
        }
Ejemplo n.º 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));
        }
Ejemplo n.º 6
0
        public void ThenRoleHasNoPermissions(string roleName)
        {
            Guid  roleId = MockDatabase.GetRole(roleName).Id;
            IRole role   = IdentityManagementService.GetRole(roleId);

            Assert.AreEqual(0, role.Permissions.Count);
        }
Ejemplo n.º 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)));
        }
Ejemplo n.º 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));
        }
Ejemplo n.º 9
0
 public void WhenExternalActiveDirectoryUsersAreSearchedByCustomPropertyNameAndValue(string customPropertyName, string customPropertyValue)
 {
     Try(() =>
     {
         returnedUsers = IdentityManagementService.GetUsers(customPropertyName, customPropertyValue, AccountType.ActiveDirectory).ToList();
     });
 }
Ejemplo n.º 10
0
 public AccessManagement(
     IIdentityService identityService,
     IdentityManagementService managementService)
 {
     _identityService   = identityService;
     _managementService = managementService;
 }
Ejemplo n.º 11
0
 public void WhenUsersAreSearchedByCustomPropertyNameAndValue(string customPropertyName, string customPropertyValue)
 {
     Try(() =>
     {
         returnedUsers = IdentityManagementService.GetUsers(customPropertyName, customPropertyValue).ToList();
     });
 }
Ejemplo n.º 12
0
        public void WhenTheUserIsRemovedFromTheOrganization(string user, string organization)
        {
            Guid organizationId = MockDatabase.GetOrganization(organization).Id;
            Guid userId         = nameIdentifierPairs[user];

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

            foreach (IUserListItem user in users)
            {
                Assert.IsFalse(user.IsDisabled, user.Name);
            }
        }
Ejemplo n.º 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);
     });
 }
Ejemplo n.º 16
0
        public void ThenAllGroupsAreEnabled()
        {
            IEnumerable <IGroup> groups = IdentityManagementService.GetGroups();

            foreach (IGroup group in groups)
            {
                Assert.IsFalse(group.IsDisabled, group.Name);
            }
        }
Ejemplo n.º 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());
            }
        }
Ejemplo n.º 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));
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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"]));
            }
        }
Ejemplo n.º 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());
            }
        }
Ejemplo n.º 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());
            }
        }
Ejemplo n.º 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"])));
            }
        }
Ejemplo n.º 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"]));
            }
        }
Ejemplo n.º 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());
            }
        }
Ejemplo n.º 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());
     }
 }
Ejemplo n.º 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));
            }
        }
Ejemplo n.º 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());
            }
        }
Ejemplo n.º 30
0
 public void WhenAGroupWithNoNameIsAdded()
 {
     Try(() => IdentityManagementService.CreateGroup(string.Empty, string.Empty, string.Empty));
 }