From bce5fa63d8efb6b6e2df7b5544c4fb449612f423 Mon Sep 17 00:00:00 2001 From: Alper Ebicoglu Date: Sat, 6 Jan 2018 23:57:56 +0300 Subject: [PATCH] Added new IdentityResource Test --- .../AbpIdentityServerTestDataBuilder.cs | 43 +++++++++---------- .../Clients/IdentityResourceStore_Tests.cs | 17 ++++++++ 2 files changed, 38 insertions(+), 22 deletions(-) diff --git a/test/Abp.IdentityServer.EntityFrameworkCore.Tests/Volo/Abp/IdentityServer/AbpIdentityServerTestDataBuilder.cs b/test/Abp.IdentityServer.EntityFrameworkCore.Tests/Volo/Abp/IdentityServer/AbpIdentityServerTestDataBuilder.cs index 288ceea3d0..3fdb765086 100644 --- a/test/Abp.IdentityServer.EntityFrameworkCore.Tests/Volo/Abp/IdentityServer/AbpIdentityServerTestDataBuilder.cs +++ b/test/Abp.IdentityServer.EntityFrameworkCore.Tests/Volo/Abp/IdentityServer/AbpIdentityServerTestDataBuilder.cs @@ -34,8 +34,8 @@ namespace Volo.Abp.IdentityServer { AddClients(); AddPersistentGrants(); - //AddIdentityResources(); AddApiResources(); + AddIdentityResources(); } private void AddClients() @@ -125,26 +125,25 @@ namespace Volo.Abp.IdentityServer }); } - //private void AddIdentityResources() - //{ - // _identityResourceRepository.Insert(new IdentityResource(_guidGenerator.Create()) - // { - // Enabled = true, - // Description = "Test-Identity-Resource-Description-1", - // DisplayName = "Test-Identity-Resource-DisplayName-1", - // Name = "Test-Identity-Resource-Name-1", - // Required = true, - // ShowInDiscoveryDocument = true, - // Emphasize = true, - // UserClaims = new List - // { - // new IdentityClaim(_guidGenerator.Create()) - // { - // Type = "Test-Identity-Resource-1-IdentityClaim-Type-1", - // IdentityResourceId = _guidGenerator.Create(), - // } - // } - // }); - //} + private void AddIdentityResources() + { + _identityResourceRepository.Insert(new IdentityResource(_guidGenerator.Create()) + { + Enabled = true, + Description = "Test-Identity-Resource-Description-1", + DisplayName = "Test-Identity-Resource-DisplayName-1", + Name = "Test-Identity-Resource-Name-1", + Required = true, + ShowInDiscoveryDocument = true, + Emphasize = true, + UserClaims = new List + { + new IdentityClaim(_guidGenerator.Create()) + { + Type = "Test-Identity-Resource-1-IdentityClaim-Type-1" + } + } + }); + } } } diff --git a/test/Abp.IdentityServer.EntityFrameworkCore.Tests/Volo/Abp/IdentityServer/Clients/IdentityResourceStore_Tests.cs b/test/Abp.IdentityServer.EntityFrameworkCore.Tests/Volo/Abp/IdentityServer/Clients/IdentityResourceStore_Tests.cs index b6450f68b2..90b9397e8e 100644 --- a/test/Abp.IdentityServer.EntityFrameworkCore.Tests/Volo/Abp/IdentityServer/Clients/IdentityResourceStore_Tests.cs +++ b/test/Abp.IdentityServer.EntityFrameworkCore.Tests/Volo/Abp/IdentityServer/Clients/IdentityResourceStore_Tests.cs @@ -57,5 +57,22 @@ namespace Volo.Abp.IdentityServer.Clients apiResources[0].Scopes.GroupBy(x=>x.Name).Count().ShouldBe(1); apiResources[0].Scopes.GroupBy(x=>x.Name).First().Key.ShouldBe("Test-ApiResource-ApiScope-Name-1"); } + + [Fact] + public async Task FindIdentityResourcesByScopeAsync_Should_Return_For_Given_Scopes() + { + //Act + var identityResourcesByScope = await _resourceStore.FindIdentityResourcesByScopeAsync(new List + { + "Test-Identity-Resource-Name-1" + }); + + //Assert + var resourcesByScope = identityResourcesByScope as IdentityResource[] ?? identityResourcesByScope.ToArray(); + resourcesByScope.Length.ShouldBe(1); + resourcesByScope.First().DisplayName.ShouldBe("Test-Identity-Resource-DisplayName-1"); + resourcesByScope.First().Description.ShouldBe("Test-Identity-Resource-Description-1"); + resourcesByScope.First().Required.ShouldBe(true); + } } }