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)); }
public void WhenTheExternalGroupNameOfTheGroupIsCleared(string groupName) { Guid groupId = nameIdentifierPairs[groupName]; IGroup group = IdentityManagementService.GetGroup(groupId); Try(() => IdentityManagementService.UpdateGroup(groupId, groupName, group.Description, group.IsDisabled, null)); }
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)); }
public void WhenActiveDirectoryAccountNameIsChangedToForUser(string accountName, string userName) { Guid userId = nameIdentifierPairs[userName]; IUser user = IdentityManagementService.GetUser(userId); Try(() => IdentityManagementService.UpdateExternalUserAccount(user.Id, AccountType.ActiveDirectory, accountName)); }
public void WhenPermissionIsRemovedFromRole(string permissionName, string roleName) { Permission permission = MockDatabase.GetOrCreatePermission(permissionName); Role role = MockDatabase.GetRole(roleName); Try(() => IdentityManagementService.RemoveRolePermission(role.Id, permission.Id)); }
public void ThenRoleHasNoPermissions(string roleName) { Guid roleId = MockDatabase.GetRole(roleName).Id; IRole role = IdentityManagementService.GetRole(roleId); Assert.AreEqual(0, role.Permissions.Count); }
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))); }
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)); }
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; }
public void WhenUsersAreSearchedByCustomPropertyNameAndValue(string customPropertyName, string customPropertyValue) { Try(() => { returnedUsers = IdentityManagementService.GetUsers(customPropertyName, customPropertyValue).ToList(); }); }
public void WhenTheUserIsRemovedFromTheOrganization(string user, string organization) { Guid organizationId = MockDatabase.GetOrganization(organization).Id; Guid userId = nameIdentifierPairs[user]; Try(() => IdentityManagementService.RemoveUserOrganization(userId, organizationId)); }
public void WhenAUserIsAdded(string userName) { Try(() => { IUserListItem userListItem = IdentityManagementService.CreateUser(userName); nameIdentifierPairs.Add(userName, userListItem.Id); }); }
public void ThenAllUsersAreEnabled() { IEnumerable <IUserListItem> users = IdentityManagementService.GetUsers(); foreach (IUserListItem user in users) { Assert.IsFalse(user.IsDisabled, user.Name); } }
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); }); }
public void ThenAllGroupsAreEnabled() { IEnumerable <IGroup> groups = IdentityManagementService.GetGroups(); foreach (IGroup group in groups) { Assert.IsFalse(group.IsDisabled, group.Name); } }
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()); } }
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)); }
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); }
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); }
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"])); } }
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()); } }
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()); } }
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"]))); } }
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"])); } }
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()); } }
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()); } }
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)); } }
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()); } }
public void WhenAGroupWithNoNameIsAdded() { Try(() => IdentityManagementService.CreateGroup(string.Empty, string.Empty, string.Empty)); }