|
|
|
@ -1,13 +1,13 @@ |
|
|
|
using Microsoft.AspNetCore.Identity; |
|
|
|
using Microsoft.Extensions.DependencyInjection; |
|
|
|
using Shouldly; |
|
|
|
using System; |
|
|
|
using System.Collections.Generic; |
|
|
|
using System; |
|
|
|
using System.Collections.Generic; |
|
|
|
using System.Linq; |
|
|
|
using System.Threading.Tasks; |
|
|
|
using Volo.Abp.Guids; |
|
|
|
using Volo.Abp.Modularity; |
|
|
|
using Volo.Abp.Uow; |
|
|
|
using Volo.Abp.Uow; |
|
|
|
using Xunit; |
|
|
|
|
|
|
|
namespace Volo.Abp.Identity |
|
|
|
@ -18,7 +18,7 @@ namespace Volo.Abp.Identity |
|
|
|
private readonly IOrganizationUnitRepository _organizationUnitRepository; |
|
|
|
private readonly ILookupNormalizer _lookupNormalizer; |
|
|
|
private readonly IdentityTestData _testData; |
|
|
|
private readonly IGuidGenerator _guidGenerator; |
|
|
|
private readonly IGuidGenerator _guidGenerator; |
|
|
|
private readonly OrganizationUnitManager _organizationUnitManager; |
|
|
|
private readonly IIdentityRoleRepository _identityRoleRepository; |
|
|
|
private readonly IUnitOfWorkManager _unitOfWorkManager; |
|
|
|
@ -32,8 +32,8 @@ namespace Volo.Abp.Identity |
|
|
|
_guidGenerator = GetRequiredService<IGuidGenerator>(); |
|
|
|
_organizationUnitManager = GetRequiredService<OrganizationUnitManager>(); |
|
|
|
_identityRoleRepository = GetRequiredService<IIdentityRoleRepository>(); |
|
|
|
_unitOfWorkManager = GetRequiredService<IUnitOfWorkManager>(); |
|
|
|
_identityUserRepository = GetRequiredService<IIdentityUserRepository>(); |
|
|
|
_unitOfWorkManager = GetRequiredService<IUnitOfWorkManager>(); |
|
|
|
_identityUserRepository = GetRequiredService<IIdentityUserRepository>(); |
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
@ -78,36 +78,46 @@ namespace Volo.Abp.Identity |
|
|
|
.FirstOrDefault(ou => ou.DisplayName == "OU111"); |
|
|
|
ou.Roles.ShouldNotBeNull(); |
|
|
|
ou.Roles.Any().ShouldBeTrue(); |
|
|
|
} |
|
|
|
} |
|
|
|
[Fact] |
|
|
|
public async Task GetOrganizationUnitRolesAsync() |
|
|
|
{ |
|
|
|
OrganizationUnit ou = await _organizationUnitRepository.GetAsync("OU111", true); |
|
|
|
OrganizationUnit ou = await _organizationUnitRepository.GetAsync("OU111", includeDetails: true); |
|
|
|
|
|
|
|
var ou111Roles = await _organizationUnitRepository.GetRolesAsync(ou, true); |
|
|
|
var ou111Roles = await _organizationUnitRepository.GetRolesAsync(ou, includeDetails: true); |
|
|
|
ou111Roles.Count.ShouldBe(2); |
|
|
|
ou111Roles.ShouldContain(n => n.Name == "manager"); |
|
|
|
ou111Roles.ShouldContain(n => n.Name == "moderator"); |
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
public async Task GetMembersInOrganizationUnitListAsync() |
|
|
|
{ |
|
|
|
OrganizationUnit ou1 = await _organizationUnitRepository.GetAsync("OU111", true); |
|
|
|
OrganizationUnit ou2 = await _organizationUnitRepository.GetAsync("OU112", true); |
|
|
|
var users = await _identityUserRepository.GetUsersInOrganizationsListAsync(new List<Guid> { ou1.Id, ou2.Id }); |
|
|
|
users.Count.ShouldBeGreaterThan(0); |
|
|
|
public async Task GetOrganizationUnitRolesWithPagingAsync() |
|
|
|
{ |
|
|
|
OrganizationUnit ou = await _organizationUnitRepository.GetAsync("OU111", includeDetails: true); |
|
|
|
|
|
|
|
var ou111Roles = await _organizationUnitRepository.GetRolesAsync(ou, sorting: "name desc", maxResultCount: 1, includeDetails: true); |
|
|
|
ou111Roles.Count.ShouldBe(1); |
|
|
|
ou111Roles.ShouldContain(n => n.Name == "moderator"); |
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
public async Task GetMembersInOrganizationUnitListAsync() |
|
|
|
{ |
|
|
|
OrganizationUnit ou1 = await _organizationUnitRepository.GetAsync("OU111", true); |
|
|
|
OrganizationUnit ou2 = await _organizationUnitRepository.GetAsync("OU112", true); |
|
|
|
var users = await _identityUserRepository.GetUsersInOrganizationsListAsync(new List<Guid> { ou1.Id, ou2.Id }); |
|
|
|
users.Count.ShouldBeGreaterThan(0); |
|
|
|
} |
|
|
|
[Fact] |
|
|
|
public async Task GetMembersInOrganizationUnitWithParamsAsync() |
|
|
|
{ |
|
|
|
OrganizationUnit ou = await _organizationUnitRepository.GetAsync("OU111", true); |
|
|
|
var users = await _organizationUnitRepository.GetMembersAsync(ou, "UserName DESC", 5, 0, "n"); |
|
|
|
|
|
|
|
public async Task GetMembersInOrganizationUnitWithParamsAsync() |
|
|
|
{ |
|
|
|
OrganizationUnit ou = await _organizationUnitRepository.GetAsync("OU111", true); |
|
|
|
var users = await _organizationUnitRepository.GetMembersAsync(ou, "UserName DESC", 5, 0, "n"); |
|
|
|
|
|
|
|
users.Count.ShouldBeGreaterThan(1); |
|
|
|
users.Count.ShouldBeLessThanOrEqualTo(5); |
|
|
|
|
|
|
|
//Filter check
|
|
|
|
users.Count.ShouldBeLessThanOrEqualTo(5); |
|
|
|
|
|
|
|
//Filter check
|
|
|
|
users.ShouldAllBe(u => u.UserName.Contains("ne") || u.Email.Contains("n")); |
|
|
|
|
|
|
|
//Order check
|
|
|
|
@ -121,16 +131,16 @@ namespace Volo.Abp.Identity |
|
|
|
} |
|
|
|
|
|
|
|
users = await _organizationUnitRepository.GetMembersAsync(ou, null, 999, 0, "undefined-username"); |
|
|
|
users.Count.ShouldBe(0); |
|
|
|
users.Count.ShouldBe(0); |
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
public async Task GetCountMembersCountInOrganizationUnit() |
|
|
|
{ |
|
|
|
OrganizationUnit ou = await _organizationUnitRepository.GetAsync("OU111", true); |
|
|
|
var users = await _organizationUnitRepository.GetMembersCountAsync(ou); |
|
|
|
|
|
|
|
users.ShouldBeGreaterThan(1); |
|
|
|
public async Task GetCountMembersCountInOrganizationUnit() |
|
|
|
{ |
|
|
|
OrganizationUnit ou = await _organizationUnitRepository.GetAsync("OU111", true); |
|
|
|
var users = await _organizationUnitRepository.GetMembersCountAsync(ou); |
|
|
|
|
|
|
|
users.ShouldBeGreaterThan(1); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|