diff --git a/modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/IIdentityUserLookupAppService.cs b/modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/IIdentityUserLookupAppService.cs index 7a14579af5..d7ae1a5291 100644 --- a/modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/IIdentityUserLookupAppService.cs +++ b/modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/IIdentityUserLookupAppService.cs @@ -6,6 +6,7 @@ using Volo.Abp.Users; namespace Volo.Abp.Identity; +[Obsolete("Use IIdentityUserIntegrationService for module-to-module (or service-to-service) communication.")] public interface IIdentityUserLookupAppService : IApplicationService { Task FindByIdAsync(Guid id); diff --git a/modules/identity/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/IdentityUserLookupAppService.cs b/modules/identity/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/IdentityUserLookupAppService.cs index 297032c7a9..7595de7a23 100644 --- a/modules/identity/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/IdentityUserLookupAppService.cs +++ b/modules/identity/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/IdentityUserLookupAppService.cs @@ -7,7 +7,7 @@ using Volo.Abp.Users; namespace Volo.Abp.Identity; -[Obsolete("Use IIdentityUserIntegrationService for module-to-module (or service-to-service) communication.")] +[Obsolete("Use IdentityUserIntegrationService for module-to-module (or service-to-service) communication.")] [Authorize(IdentityPermissions.UserLookup.Default)] public class IdentityUserLookupAppService : IdentityAppServiceBase, IIdentityUserLookupAppService { diff --git a/modules/identity/test/Volo.Abp.Identity.Application.Tests/Volo/Abp/Identity/IdentityUserLookupAppService_Tests.cs b/modules/identity/test/Volo.Abp.Identity.Application.Tests/Volo/Abp/Identity/Integration/IdentityUserIntegrationService_Tests.cs similarity index 56% rename from modules/identity/test/Volo.Abp.Identity.Application.Tests/Volo/Abp/Identity/IdentityUserLookupAppService_Tests.cs rename to modules/identity/test/Volo.Abp.Identity.Application.Tests/Volo/Abp/Identity/Integration/IdentityUserIntegrationService_Tests.cs index e774b0e440..a74b5cdcfc 100644 --- a/modules/identity/test/Volo.Abp.Identity.Application.Tests/Volo/Abp/Identity/IdentityUserLookupAppService_Tests.cs +++ b/modules/identity/test/Volo.Abp.Identity.Application.Tests/Volo/Abp/Identity/Integration/IdentityUserIntegrationService_Tests.cs @@ -1,23 +1,35 @@ using System; +using System.Linq; using System.Threading.Tasks; using Microsoft.AspNetCore.Identity; using Shouldly; using Xunit; -namespace Volo.Abp.Identity; +namespace Volo.Abp.Identity.Integration; -public class IdentityUserLookupAppService_Tests : AbpIdentityApplicationTestBase +public class IdentityUserIntegrationService_Tests : AbpIdentityApplicationTestBase { - private readonly IIdentityUserLookupAppService _identityUserLookupAppService; + private readonly IIdentityUserIntegrationService _identityUserIntegrationService; private readonly IIdentityUserRepository _identityUserRepository; private readonly ILookupNormalizer _lookupNormalizer; - public IdentityUserLookupAppService_Tests() + public IdentityUserIntegrationService_Tests() { - _identityUserLookupAppService = GetRequiredService(); + _identityUserIntegrationService = GetRequiredService(); _identityUserRepository = GetRequiredService(); _lookupNormalizer = GetRequiredService(); } + + [Fact] + public async Task GetRoleNamesAsync() + { + var adminUser = await _identityUserRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("admin")); + adminUser.ShouldNotBeNull(); + + var roles = await _identityUserIntegrationService.GetRoleNamesAsync(adminUser.Id); + roles.Length.ShouldBe(1); + roles.ShouldContain("admin"); + } [Fact] public async Task FindByIdAsync() @@ -25,13 +37,13 @@ public class IdentityUserLookupAppService_Tests : AbpIdentityApplicationTestBase var user = await _identityUserRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")); user.ShouldNotBeNull(); - (await _identityUserLookupAppService.FindByIdAsync(user.Id)).UserName.ShouldBe(user.UserName); + (await _identityUserIntegrationService.FindByIdAsync(user.Id)).UserName.ShouldBe(user.UserName); } [Fact] public async Task FindById_NotExist_Should_Return_Null() { - var user = await _identityUserLookupAppService.FindByIdAsync(Guid.NewGuid()); + var user = await _identityUserIntegrationService.FindByIdAsync(Guid.NewGuid()); user.ShouldBeNull(); } @@ -41,20 +53,20 @@ public class IdentityUserLookupAppService_Tests : AbpIdentityApplicationTestBase var user = await _identityUserRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")); user.ShouldNotBeNull(); - (await _identityUserLookupAppService.FindByUserNameAsync(user.UserName)).UserName.ShouldBe(user.UserName); + (await _identityUserIntegrationService.FindByUserNameAsync(user.UserName)).UserName.ShouldBe(user.UserName); } [Fact] public async Task FindByUserName_NotExist_Should_Return_Null() { - var user = await _identityUserLookupAppService.FindByUserNameAsync(Guid.NewGuid().ToString()); + var user = await _identityUserIntegrationService.FindByUserNameAsync(Guid.NewGuid().ToString()); user.ShouldBeNull(); } [Fact] public async Task Search_Without_Filter_And_Sorting() { - var result = await _identityUserLookupAppService.SearchAsync(new UserLookupSearchInputDto()); + var result = await _identityUserIntegrationService.SearchAsync(new UserLookupSearchInputDto()); result.Items.Count.ShouldBeGreaterThanOrEqualTo(3); result.Items.ShouldContain(u => u.UserName == "john.nash"); } @@ -62,7 +74,7 @@ public class IdentityUserLookupAppService_Tests : AbpIdentityApplicationTestBase [Fact] public async Task Search_With_Filter() { - var result = await _identityUserLookupAppService.SearchAsync( + var result = await _identityUserIntegrationService.SearchAsync( new UserLookupSearchInputDto { Filter = "a" @@ -73,7 +85,7 @@ public class IdentityUserLookupAppService_Tests : AbpIdentityApplicationTestBase result.Items.ShouldContain(u => u.UserName == "john.nash"); result.Items.ShouldContain(u => u.UserName == "david"); - result = await _identityUserLookupAppService.SearchAsync( + result = await _identityUserIntegrationService.SearchAsync( new UserLookupSearchInputDto { Filter = "neo"