Browse Source

refactored and renamed

pull/3732/head
Galip Tolga Erdem 7 years ago
parent
commit
3705c627b3
  1. 4
      modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IIdentityRoleRepository.cs
  2. 10
      modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IIdentityUserRepository.cs
  3. 23
      modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IOrganizationUnitRepository.cs
  4. 19
      modules/identity/src/Volo.Abp.Identity.EntityFrameworkCore/Volo/Abp/Identity/EntityFrameworkCore/EfCoreIdentityRoleRepository.cs
  5. 19
      modules/identity/src/Volo.Abp.Identity.EntityFrameworkCore/Volo/Abp/Identity/EntityFrameworkCore/EfCoreIdentityUserRepository.cs
  6. 12
      modules/identity/src/Volo.Abp.Identity.EntityFrameworkCore/Volo/Abp/Identity/EntityFrameworkCore/EfCoreOrganizationUnitRepository.cs
  7. 13
      modules/identity/src/Volo.Abp.Identity.MongoDB/Volo/Abp/Identity/MongoDB/MongoIdentityRoleRepository.cs
  8. 31
      modules/identity/src/Volo.Abp.Identity.MongoDB/Volo/Abp/Identity/MongoDB/MongoIdentityUserRepository.cs
  9. 6
      modules/identity/src/Volo.Abp.Identity.MongoDB/Volo/Abp/Identity/MongoDB/MongoOrganizationUnitRepository.cs
  10. 6
      modules/identity/test/Volo.Abp.Identity.Domain.Tests/Volo/Abp/Identity/IdentityUserManager_Tests.cs
  11. 32
      modules/identity/test/Volo.Abp.Identity.Domain.Tests/Volo/Abp/Identity/OrganizationUnitManager_Tests.cs
  12. 1
      modules/identity/test/Volo.Abp.Identity.TestBase/Volo/Abp/Identity/AbpIdentityTestDataBuilder.cs
  13. 2
      modules/identity/test/Volo.Abp.Identity.TestBase/Volo/Abp/Identity/IdentityUserRepository_Tests.cs
  14. 2
      modules/identity/test/Volo.Abp.Identity.TestBase/Volo/Abp/Identity/LazyLoading_Tests.cs
  15. 22
      modules/identity/test/Volo.Abp.Identity.TestBase/Volo/Abp/Identity/OrganizationUnitRepository_Tests.cs

4
modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IIdentityRoleRepository.cs

@ -20,6 +20,10 @@ namespace Volo.Abp.Identity
int skipCount = 0,
bool includeDetails = false,
CancellationToken cancellationToken = default
);
Task<List<IdentityRole>> GetListAsync(
IEnumerable<Guid> ids,
CancellationToken cancellationToken = default
);
Task<List<IdentityRole>> GetDefaultOnesAsync(

10
modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IIdentityUserRepository.cs

@ -33,19 +33,19 @@ namespace Volo.Abp.Identity
);
Task<IdentityUser> FindByNormalizedEmailAsync(
[NotNull] string normalizedEmail,
[NotNull] string normalizedEmail,
bool includeDetails = true,
CancellationToken cancellationToken = default
);
Task<List<IdentityUser>> GetListByClaimAsync(
Claim claim,
Claim claim,
bool includeDetails = false,
CancellationToken cancellationToken = default
);
Task<List<IdentityUser>> GetListByNormalizedRoleNameAsync(
string normalizedRoleName,
string normalizedRoleName,
bool includeDetails = false,
CancellationToken cancellationToken = default
);
@ -73,6 +73,10 @@ namespace Volo.Abp.Identity
Task<List<IdentityUser>> GetUsersInOrganizationUnitAsync(
Guid organizationUnitId,
CancellationToken cancellationToken = default
);
Task<List<IdentityUser>> GetUsersInOrganizationsListAsync(
List<Guid> organizationUnitIds,
CancellationToken cancellationToken = default
);
Task<List<IdentityUser>> GetUsersInOrganizationUnitWithChildrenAsync(

23
modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IOrganizationUnitRepository.cs

@ -20,25 +20,28 @@ namespace Volo.Abp.Identity
bool includeDetails = false,
CancellationToken cancellationToken = default
);
Task<List<OrganizationUnit>> GetListAsync(
IEnumerable<Guid> ids,
bool includeDetails = false,
Task<OrganizationUnit> GetAsync(
string displayName,
bool includeDetails = true,
CancellationToken cancellationToken = default
);
Task<List<OrganizationUnit>> GetListAsync(
string sorting = null,
int maxResultCount = int.MaxValue,
int skipCount = 0,
bool includeDetails = true,
CancellationToken cancellationToken = default
);
Task<OrganizationUnit> GetOrganizationUnitAsync(
string displayName,
bool includeDetails = false,
CancellationToken cancellationToken = default
);
Task<List<OrganizationUnit>> GetListAsync(
IEnumerable<Guid> ids,
bool includeDetails = false,
CancellationToken cancellationToken = default
);
Task<List<IdentityRole>> GetOrganizationUnitRoles(
Task<List<IdentityRole>> GetRolesAsync(
Guid organizationUnitId,
bool includeDetails = false,
CancellationToken cancellationToken = default

19
modules/identity/src/Volo.Abp.Identity.EntityFrameworkCore/Volo/Abp/Identity/EntityFrameworkCore/EfCoreIdentityRoleRepository.cs

@ -19,7 +19,7 @@ namespace Volo.Abp.Identity.EntityFrameworkCore
}
public virtual async Task<IdentityRole> FindByNormalizedNameAsync(
string normalizedRoleName,
string normalizedRoleName,
bool includeDetails = true,
CancellationToken cancellationToken = default)
{
@ -29,9 +29,9 @@ namespace Volo.Abp.Identity.EntityFrameworkCore
}
public virtual async Task<List<IdentityRole>> GetListAsync(
string sorting = null,
int maxResultCount = int.MaxValue,
int skipCount = 0,
string sorting = null,
int maxResultCount = int.MaxValue,
int skipCount = 0,
bool includeDetails = true,
CancellationToken cancellationToken = default)
{
@ -40,6 +40,15 @@ namespace Volo.Abp.Identity.EntityFrameworkCore
.OrderBy(sorting ?? nameof(IdentityRole.Name))
.PageBy(skipCount, maxResultCount)
.ToListAsync(GetCancellationToken(cancellationToken));
}
public virtual async Task<List<IdentityRole>> GetListAsync(
IEnumerable<Guid> ids,
CancellationToken cancellationToken = default)
{
return await DbSet
.Where(t => ids.Contains(t.Id))
.ToListAsync(GetCancellationToken(cancellationToken));
}
public virtual async Task<List<IdentityRole>> GetDefaultOnesAsync(
@ -51,6 +60,6 @@ namespace Volo.Abp.Identity.EntityFrameworkCore
public override IQueryable<IdentityRole> WithDetails()
{
return GetQueryable().IncludeDetails();
}
}
}
}

19
modules/identity/src/Volo.Abp.Identity.EntityFrameworkCore/Volo/Abp/Identity/EntityFrameworkCore/EfCoreIdentityUserRepository.cs

@ -197,9 +197,24 @@ namespace Volo.Abp.Identity.EntityFrameworkCore
where userOu.OrganizationUnitId == organizationUnitId
select user;
return await query.ToListAsync(GetCancellationToken(cancellationToken));
}
public async Task<List<IdentityUser>> GetUsersInOrganizationsListAsync(
List<Guid> organizationUnitIds,
CancellationToken cancellationToken = default
)
{
//var userIds = DbContext.Set<IdentityUserOrganizationUnit>()
// .Where(q => organizationUnitIds.Contains(q.OrganizationUnitId))
// .Select(u => u.UserId);
//var query = DbContext.Users.Where(u => userIds.Contains(u.Id));
var query = from userOu in DbContext.Set<IdentityUserOrganizationUnit>()
join user in DbSet on userOu.UserId equals user.Id
where organizationUnitIds.Contains(userOu.OrganizationUnitId)
select user;
return await query.ToListAsync(GetCancellationToken(cancellationToken));
}
public virtual async Task<List<IdentityUser>> GetUsersInOrganizationUnitWithChildrenAsync(
string code,
CancellationToken cancellationToken = default
@ -216,6 +231,6 @@ namespace Volo.Abp.Identity.EntityFrameworkCore
public override IQueryable<IdentityUser> WithDetails()
{
return GetQueryable().IncludeDetails();
}
}
}
}

12
modules/identity/src/Volo.Abp.Identity.EntityFrameworkCore/Volo/Abp/Identity/EntityFrameworkCore/EfCoreOrganizationUnitRepository.cs

@ -67,9 +67,9 @@ namespace Volo.Abp.Identity.EntityFrameworkCore
.ToListAsync(GetCancellationToken(cancellationToken));
}
public async Task<OrganizationUnit> GetOrganizationUnitAsync(
public async Task<OrganizationUnit> GetAsync(
string displayName,
bool includeDetails = false,
bool includeDetails = true,
CancellationToken cancellationToken = default)
{
return await DbSet
@ -79,7 +79,7 @@ namespace Volo.Abp.Identity.EntityFrameworkCore
GetCancellationToken(cancellationToken)
);
}
public async Task<List<IdentityRole>> GetOrganizationUnitRoles(
public async Task<List<IdentityRole>> GetRolesAsync(
Guid organizationUnitId, bool includeDetails = false,
CancellationToken cancellationToken = default)
{
@ -96,10 +96,4 @@ namespace Volo.Abp.Identity.EntityFrameworkCore
return GetQueryable().IncludeDetails();
}
}
public class OrganizationUnitRoleWithIdentityRole
{
public IdentityRole IdentityRole { get; set; }
public OrganizationUnitRole OrganizationUnitRole { get; set; }
}
}

13
modules/identity/src/Volo.Abp.Identity.MongoDB/Volo/Abp/Identity/MongoDB/MongoIdentityRoleRepository.cs

@ -26,7 +26,7 @@ namespace Volo.Abp.Identity.MongoDB
return await GetMongoQueryable().FirstOrDefaultAsync(r => r.NormalizedName == normalizedRoleName, GetCancellationToken(cancellationToken));
}
public async Task<List<IdentityRole>> GetListAsync(
public virtual async Task<List<IdentityRole>> GetListAsync(
string sorting = null,
int maxResultCount = int.MaxValue,
int skipCount = 0,
@ -40,10 +40,19 @@ namespace Volo.Abp.Identity.MongoDB
.ToListAsync(GetCancellationToken(cancellationToken));
}
public virtual async Task<List<IdentityRole>> GetListAsync(
IEnumerable<Guid> ids,
CancellationToken cancellationToken = default)
{
return await GetMongoQueryable()
.Where(t => ids.Contains(t.Id))
.ToListAsync(GetCancellationToken(cancellationToken));
}
public virtual async Task<List<IdentityRole>> GetDefaultOnesAsync(
bool includeDetails = false, CancellationToken cancellationToken = default)
{
return await GetMongoQueryable().Where(r => r.IsDefault).ToListAsync(cancellationToken: GetCancellationToken(cancellationToken));
}
}
}
}

31
modules/identity/src/Volo.Abp.Identity.MongoDB/Volo/Abp/Identity/MongoDB/MongoIdentityUserRepository.cs

@ -23,7 +23,7 @@ namespace Volo.Abp.Identity.MongoDB
}
public virtual async Task<IdentityUser> FindByNormalizedUserNameAsync(
string normalizedUserName,
string normalizedUserName,
bool includeDetails = true,
CancellationToken cancellationToken = default)
{
@ -35,7 +35,7 @@ namespace Volo.Abp.Identity.MongoDB
}
public virtual async Task<List<string>> GetRoleNamesAsync(
Guid id,
Guid id,
CancellationToken cancellationToken = default)
{
var user = await GetAsync(id, cancellationToken: GetCancellationToken(cancellationToken));
@ -60,13 +60,13 @@ namespace Volo.Abp.Identity.MongoDB
var organizationUnitIds = user.OrganizationUnits
.Select(r => r.OrganizationUnitId)
.ToArray();
.ToArray();
var organizationUnits = DbContext.OrganizationUnits
.AsQueryable()
.Where(ou => organizationUnitIds.Contains(ou.Id))
.ToArray();
.ToArray();
var roleIds = organizationUnits.SelectMany(x => x.Roles.Select(r => r.RoleId)).ToArray();
return await DbContext.Roles //TODO: Such usage suppress filters!
@ -77,8 +77,8 @@ namespace Volo.Abp.Identity.MongoDB
}
public virtual async Task<IdentityUser> FindByLoginAsync(
string loginProvider,
string providerKey,
string loginProvider,
string providerKey,
bool includeDetails = true,
CancellationToken cancellationToken = default)
{
@ -106,7 +106,7 @@ namespace Volo.Abp.Identity.MongoDB
}
public virtual async Task<List<IdentityUser>> GetListByNormalizedRoleNameAsync(
string normalizedRoleName,
string normalizedRoleName,
bool includeDetails = false,
CancellationToken cancellationToken = default)
{
@ -200,6 +200,17 @@ namespace Volo.Abp.Identity.MongoDB
return result;
}
public async Task<List<IdentityUser>> GetUsersInOrganizationsListAsync(
List<Guid> organizationUnitIds,
CancellationToken cancellationToken = default)
{
var result = await GetMongoQueryable()
.Where(u => u.OrganizationUnits.Any(uou => organizationUnitIds.Contains(uou.OrganizationUnitId)))
.ToListAsync(GetCancellationToken(cancellationToken))
;
return result;
}
public async Task<List<IdentityUser>> GetUsersInOrganizationUnitWithChildrenAsync(
string code,
CancellationToken cancellationToken = default)
@ -214,6 +225,6 @@ namespace Volo.Abp.Identity.MongoDB
.Where(u => u.OrganizationUnits.Any(uou => organizationUnitIds.Contains(uou.OrganizationUnitId)))
.ToListAsync(GetCancellationToken(cancellationToken))
;
}
}
}
}

6
modules/identity/src/Volo.Abp.Identity.MongoDB/Volo/Abp/Identity/MongoDB/MongoOrganizationUnitRepository.cs

@ -64,9 +64,9 @@ namespace Volo.Abp.Identity.MongoDB
.ToListAsync(GetCancellationToken(cancellationToken));
}
public async Task<OrganizationUnit> GetOrganizationUnitAsync(
public async Task<OrganizationUnit> GetAsync(
string displayName,
bool includeDetails = false,
bool includeDetails = true,
CancellationToken cancellationToken = default)
{
return await GetMongoQueryable()
@ -76,7 +76,7 @@ namespace Volo.Abp.Identity.MongoDB
);
}
public async Task<List<IdentityRole>> GetOrganizationUnitRoles(
public async Task<List<IdentityRole>> GetRolesAsync(
Guid organizationUnitId,
bool includeDetails = false,
CancellationToken cancellationToken = default)

6
modules/identity/test/Volo.Abp.Identity.Domain.Tests/Volo/Abp/Identity/IdentityUserManager_Tests.cs

@ -97,7 +97,7 @@ namespace Volo.Abp.Identity
_lookupNormalizer.NormalizeName("david"));
user.ShouldNotBeNull();
var ou = await _organizationUnitRepository.GetOrganizationUnitAsync(
var ou = await _organizationUnitRepository.GetAsync(
_lookupNormalizer.NormalizeName("OU11"));
ou.ShouldNotBeNull();
@ -150,7 +150,7 @@ namespace Volo.Abp.Identity
{
using (var uow = _unitOfWorkManager.Begin())
{
var ou = await _organizationUnitRepository.GetOrganizationUnitAsync(
var ou = await _organizationUnitRepository.GetAsync(
_lookupNormalizer.NormalizeName("OU111"));
ou.ShouldNotBeNull();
@ -158,7 +158,7 @@ namespace Volo.Abp.Identity
_lookupNormalizer.NormalizeName("john.nash"));
user.ShouldNotBeNull();
var ouNew = await _organizationUnitRepository.GetOrganizationUnitAsync(
var ouNew = await _organizationUnitRepository.GetAsync(
_lookupNormalizer.NormalizeName("OU2"));
ouNew.ShouldNotBeNull();

32
modules/identity/test/Volo.Abp.Identity.Domain.Tests/Volo/Abp/Identity/OrganizationUnitManager_Tests.cs

@ -33,55 +33,55 @@ namespace Volo.Abp.Identity
{
await _organizationUnitManager.CreateAsync(new OrganizationUnit(_guidGenerator.Create(), "Root 1"));
var root1 = await _organizationUnitRepository.GetOrganizationUnitAsync("Root 1");
var root1 = await _organizationUnitRepository.GetAsync("Root 1");
root1.ShouldNotBeNull();
}
[Fact]
public async Task UpdateAsync()
{
var ou = await _organizationUnitRepository.GetOrganizationUnitAsync("OU111");
var ou = await _organizationUnitRepository.GetAsync("OU111");
ou.Code = OrganizationUnit.CreateCode(123);
await _organizationUnitManager.UpdateAsync(ou);
var ouAfterChange = await _organizationUnitRepository.GetOrganizationUnitAsync("OU111");
var ouAfterChange = await _organizationUnitRepository.GetAsync("OU111");
ouAfterChange.Code.ShouldContain("123");
}
[Fact]
public async Task DeleteAsync()
{
var ou = await _organizationUnitRepository.GetOrganizationUnitAsync("OU11");
var ou = await _organizationUnitRepository.GetAsync("OU11");
await _organizationUnitManager.DeleteAsync(ou.Id);
(await _organizationUnitRepository.GetOrganizationUnitAsync("OU11")).ShouldBeNull();
(await _organizationUnitRepository.GetAsync("OU11")).ShouldBeNull();
}
[Fact]
public async Task MoveAsync()
{
var ou1 = await _organizationUnitRepository.GetOrganizationUnitAsync("OU1");
var ou2 = await _organizationUnitRepository.GetOrganizationUnitAsync("OU2");
var ou1 = await _organizationUnitRepository.GetAsync("OU1");
var ou2 = await _organizationUnitRepository.GetAsync("OU2");
await _organizationUnitManager.MoveAsync(ou1.Id, ou2.Id);
ou1 = await _organizationUnitRepository.GetOrganizationUnitAsync("OU1");
ou1 = await _organizationUnitRepository.GetAsync("OU1");
ou1.ParentId.ShouldBe(ou2.Id);
ou1.Code.ShouldBe(OrganizationUnit.CreateCode(2, 2));
var ou11 = await _organizationUnitRepository.GetOrganizationUnitAsync("OU11");
var ou11 = await _organizationUnitRepository.GetAsync("OU11");
ou11.ParentId.ShouldBe(ou1.Id);
ou11.Code.ShouldBe(OrganizationUnit.CreateCode(2, 2, 1));
var ou111 = await _organizationUnitRepository.GetOrganizationUnitAsync("OU111");
var ou111 = await _organizationUnitRepository.GetAsync("OU111");
ou111.ParentId.ShouldBe(ou11.Id);
ou111.Code.ShouldBe(OrganizationUnit.CreateCode(2, 2, 1, 1));
var ou112 = await _organizationUnitRepository.GetOrganizationUnitAsync("OU112");
var ou112 = await _organizationUnitRepository.GetAsync("OU112");
ou112.ParentId.ShouldBe(ou11.Id);
ou112.Code.ShouldBe(OrganizationUnit.CreateCode(2, 2, 1, 2));
var ou12 = await _organizationUnitRepository.GetOrganizationUnitAsync("OU12");
var ou12 = await _organizationUnitRepository.GetAsync("OU12");
ou12.ParentId.ShouldBe(ou1.Id);
ou12.Code.ShouldBe(OrganizationUnit.CreateCode(2, 2, 2));
}
@ -94,7 +94,7 @@ namespace Volo.Abp.Identity
using (var uow = _unitOfWorkManager.Begin())
{
ou = await _organizationUnitRepository.GetOrganizationUnitAsync("OU1", true);
ou = await _organizationUnitRepository.GetAsync("OU1", true);
adminRole = await _identityRoleRepository.FindByNormalizedNameAsync(_lookupNormalizer.NormalizeName("admin"));
await _organizationUnitManager.AddRoleToOrganizationUnitAsync(adminRole, ou);
await _organizationUnitRepository.UpdateAsync(ou);
@ -102,19 +102,19 @@ namespace Volo.Abp.Identity
await uow.CompleteAsync();
}
ou = await _organizationUnitRepository.GetOrganizationUnitAsync("OU1", includeDetails: true);
ou = await _organizationUnitRepository.GetAsync("OU1", includeDetails: true);
ou.Roles.First().RoleId.ShouldBe(adminRole.Id);
}
[Fact]
public async Task RemoveRoleFromOrganizationUnitAsync()
{
var ou = await _organizationUnitRepository.GetOrganizationUnitAsync("OU1", true);
var ou = await _organizationUnitRepository.GetAsync("OU1", true);
var adminRole = await _identityRoleRepository.FindByNormalizedNameAsync(_lookupNormalizer.NormalizeName("admin"));
await _organizationUnitManager.AddRoleToOrganizationUnitAsync(adminRole.Id, ou.Id);
await _organizationUnitManager.RemoveRoleFromOrganizationUnitAsync(adminRole.Id, ou.Id);
ou = await _organizationUnitRepository.GetOrganizationUnitAsync("OU1", includeDetails: true);
ou = await _organizationUnitRepository.GetAsync("OU1", includeDetails: true);
ou.Roles.FirstOrDefault(r => r.RoleId == adminRole.Id).ShouldBeNull();
}
}

1
modules/identity/test/Volo.Abp.Identity.TestBase/Volo/Abp/Identity/AbpIdentityTestDataBuilder.cs

@ -113,6 +113,7 @@ namespace Volo.Abp.Identity
await _userRepository.InsertAsync(john);
var david = new IdentityUser(_testData.UserDavidId, "david", "david@abp.io");
david.AddOrganizationUnit(_ou112.Id);
await _userRepository.InsertAsync(david);
var neo = new IdentityUser(_testData.UserNeoId, "neo", "neo@abp.io");

2
modules/identity/test/Volo.Abp.Identity.TestBase/Volo/Abp/Identity/IdentityUserRepository_Tests.cs

@ -171,7 +171,7 @@ namespace Volo.Abp.Identity
private async Task<OrganizationUnit> GetOU(string diplayName)
{
var organizationUnit = await OrganizationUnitRepository.GetOrganizationUnitAsync(diplayName);
var organizationUnit = await OrganizationUnitRepository.GetAsync(diplayName);
organizationUnit.ShouldNotBeNull();
return organizationUnit;
}

2
modules/identity/test/Volo.Abp.Identity.TestBase/Volo/Abp/Identity/LazyLoading_Tests.cs

@ -69,7 +69,7 @@ namespace Volo.Abp.Identity
{
using (var uow = GetRequiredService<IUnitOfWorkManager>().Begin())
{
var ou = await OrganizationUnitRepository.GetOrganizationUnitAsync(LookupNormalizer.NormalizeName("OU111"), includeDetails: false);
var ou = await OrganizationUnitRepository.GetAsync(LookupNormalizer.NormalizeName("OU111"), includeDetails: false);
ou.Roles.ShouldNotBeNull(); //?
ou.Roles.Any().ShouldBeTrue();

22
modules/identity/test/Volo.Abp.Identity.TestBase/Volo/Abp/Identity/OrganizationUnitRepository_Tests.cs

@ -1,6 +1,8 @@
using Microsoft.AspNetCore.Identity;
using Microsoft.Extensions.DependencyInjection;
using Shouldly;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Volo.Abp.Guids;
@ -20,6 +22,7 @@ namespace Volo.Abp.Identity
private readonly OrganizationUnitManager _organizationUnitManager;
private readonly IIdentityRoleRepository _identityRoleRepository;
private readonly IUnitOfWorkManager _unitOfWorkManager;
private readonly IIdentityUserRepository _identityUserRepository;
public OrganizationUnitRepository_Tests()
{
@ -29,7 +32,8 @@ namespace Volo.Abp.Identity
_guidGenerator = GetRequiredService<IGuidGenerator>();
_organizationUnitManager = GetRequiredService<OrganizationUnitManager>();
_identityRoleRepository = GetRequiredService<IIdentityRoleRepository>();
_unitOfWorkManager = GetRequiredService<IUnitOfWorkManager>();
_unitOfWorkManager = GetRequiredService<IUnitOfWorkManager>();
_identityUserRepository = GetRequiredService<IIdentityUserRepository>();
}
[Fact]
@ -57,7 +61,7 @@ namespace Volo.Abp.Identity
[Fact]
public async Task GetOrganizationUnitAsync()
{
var organizationUnit = await _organizationUnitRepository.GetOrganizationUnitAsync("OU111");
var organizationUnit = await _organizationUnitRepository.GetAsync("OU111");
organizationUnit.ShouldNotBeNull();
}
@ -78,12 +82,22 @@ namespace Volo.Abp.Identity
[Fact]
public async Task GetOrganizationUnitRolesAsync()
{
OrganizationUnit ou = await _organizationUnitRepository.GetOrganizationUnitAsync("OU111", true);
OrganizationUnit ou = await _organizationUnitRepository.GetAsync("OU111", true);
var ou111Roles = await _organizationUnitRepository.GetOrganizationUnitRoles(ou.Id, true);
var ou111Roles = await _organizationUnitRepository.GetRolesAsync(ou.Id, true);
ou111Roles.Count.ShouldBe(2);
ou111Roles.ShouldContain(n => n.Name == "manager");
ou111Roles.ShouldContain(n => n.Name == "moderator");
}
[Fact]
public async Task GetUsersInOrganizationUnitListAsync()
{
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 });
//var dodo = users.ToDictionary(u => u.Id, u => u);
users.Count.ShouldBeGreaterThan(0);
}
}
}

Loading…
Cancel
Save