Browse Source

Added new IdentityResource Test

pull/190/head
Alper Ebicoglu 9 years ago
parent
commit
bce5fa63d8
  1. 43
      test/Abp.IdentityServer.EntityFrameworkCore.Tests/Volo/Abp/IdentityServer/AbpIdentityServerTestDataBuilder.cs
  2. 17
      test/Abp.IdentityServer.EntityFrameworkCore.Tests/Volo/Abp/IdentityServer/Clients/IdentityResourceStore_Tests.cs

43
test/Abp.IdentityServer.EntityFrameworkCore.Tests/Volo/Abp/IdentityServer/AbpIdentityServerTestDataBuilder.cs

@ -34,8 +34,8 @@ namespace Volo.Abp.IdentityServer
{ {
AddClients(); AddClients();
AddPersistentGrants(); AddPersistentGrants();
//AddIdentityResources();
AddApiResources(); AddApiResources();
AddIdentityResources();
} }
private void AddClients() private void AddClients()
@ -125,26 +125,25 @@ namespace Volo.Abp.IdentityServer
}); });
} }
//private void AddIdentityResources() private void AddIdentityResources()
//{ {
// _identityResourceRepository.Insert(new IdentityResource(_guidGenerator.Create()) _identityResourceRepository.Insert(new IdentityResource(_guidGenerator.Create())
// { {
// Enabled = true, Enabled = true,
// Description = "Test-Identity-Resource-Description-1", Description = "Test-Identity-Resource-Description-1",
// DisplayName = "Test-Identity-Resource-DisplayName-1", DisplayName = "Test-Identity-Resource-DisplayName-1",
// Name = "Test-Identity-Resource-Name-1", Name = "Test-Identity-Resource-Name-1",
// Required = true, Required = true,
// ShowInDiscoveryDocument = true, ShowInDiscoveryDocument = true,
// Emphasize = true, Emphasize = true,
// UserClaims = new List<IdentityClaim> UserClaims = new List<IdentityClaim>
// { {
// new IdentityClaim(_guidGenerator.Create()) new IdentityClaim(_guidGenerator.Create())
// { {
// Type = "Test-Identity-Resource-1-IdentityClaim-Type-1", Type = "Test-Identity-Resource-1-IdentityClaim-Type-1"
// IdentityResourceId = _guidGenerator.Create(), }
// } }
// } });
// }); }
//}
} }
} }

17
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).Count().ShouldBe(1);
apiResources[0].Scopes.GroupBy(x=>x.Name).First().Key.ShouldBe("Test-ApiResource-ApiScope-Name-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<string>
{
"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);
}
} }
} }

Loading…
Cancel
Save