Added identity resource test

pull/190/head
Alper Ebicoglu 8 years ago
parent b4460f7613
commit 0d69dd94dd

@ -1,6 +1,5 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using IdentityServer4.Models;
using Volo.Abp.Domain.Repositories;
using ApiResource = Volo.Abp.IdentityServer.ApiResources.ApiResource;

@ -3,29 +3,34 @@ using Volo.Abp.DependencyInjection;
using Volo.Abp.Guids;
using Volo.Abp.IdentityServer.Clients;
using Volo.Abp.IdentityServer.Grants;
using Volo.Abp.IdentityServer.IdentityResources;
namespace Volo.Abp.IdentityServer
{
public class AbpIdentityServerTestDataBuilder : ITransientDependency
{
private readonly IGuidGenerator _guidGenerator;
private readonly IClientRepository _clientRepository;
private readonly IPersistentGrantRepository _persistentGrantRepository;
private readonly IGuidGenerator _guidGenerator;
private readonly IIdentityResourceRepository _identityResourceRepository;
public AbpIdentityServerTestDataBuilder(
IClientRepository clientRepository,
IGuidGenerator guidGenerator,
IPersistentGrantRepository persistentGrantRepository)
IClientRepository clientRepository,
IGuidGenerator guidGenerator,
IPersistentGrantRepository persistentGrantRepository,
IIdentityResourceRepository identityResourceRepository)
{
_clientRepository = clientRepository;
_guidGenerator = guidGenerator;
_persistentGrantRepository = persistentGrantRepository;
_identityResourceRepository = identityResourceRepository;
}
public void Build()
{
AddClients();
AddPersistentGrants();
//AddIdentityResources();
}
private void AddClients()
@ -42,7 +47,7 @@ namespace Volo.Abp.IdentityServer
Origin = "Origin1"
}
);
_clientRepository.Insert(client42);
}
@ -57,7 +62,6 @@ namespace Volo.Abp.IdentityServer
Data = "TestData-38"
});
_persistentGrantRepository.Insert(new PersistedGrant(_guidGenerator.Create())
{
Key = "37",
@ -84,7 +88,28 @@ namespace Volo.Abp.IdentityServer
SubjectId = "TestSubject-X",
Data = "TestData-35"
});
}
//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<IdentityClaim>
// {
// new IdentityClaim(_guidGenerator.Create())
// {
// Type = "Test-Identity-Resource-1-IdentityClaim-Type-1",
// IdentityResourceId = _guidGenerator.Create(),
// }
// }
// });
//}
}
}

@ -14,7 +14,13 @@ namespace Volo.Abp.IdentityServer.Clients
{
_resourceStore = ServiceProvider.GetRequiredService<IResourceStore>();
}
//too:WRITE TESTS
[Fact]
public async Task FindApiResourceAsync_Should_Return_Null_If_Not_Found()
{
var resource = await _resourceStore.FindApiResourceAsync("non-existing-name");
resource.ShouldBeNull();
}
}
}

Loading…
Cancel
Save