Browse Source

Added PersistedGrantStore

pull/190/head
Alper Ebicoglu 9 years ago
parent
commit
487b4860c9
  1. 21
      test/Abp.IdentityServer.EntityFrameworkCore.Tests/Volo/Abp/IdentityServer/AbpIdentityServerTestDataBuilder.cs
  2. 39
      test/Abp.IdentityServer.EntityFrameworkCore.Tests/Volo/Abp/IdentityServer/Clients/PersistentGrant_Tests.cs

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

@ -2,25 +2,30 @@
using Volo.Abp.DependencyInjection;
using Volo.Abp.Guids;
using Volo.Abp.IdentityServer.Clients;
using Volo.Abp.IdentityServer.Grants;
namespace Volo.Abp.IdentityServer
{
public class AbpIdentityServerTestDataBuilder : ITransientDependency
{
private readonly IClientRepository _clientRepository;
private readonly IPersistentGrantRepository _persistentGrantRepository;
private readonly IGuidGenerator _guidGenerator;
public AbpIdentityServerTestDataBuilder(
IClientRepository clientRepository,
IGuidGenerator guidGenerator)
IGuidGenerator guidGenerator,
IPersistentGrantRepository persistentGrantRepository)
{
_clientRepository = clientRepository;
_guidGenerator = guidGenerator;
_persistentGrantRepository = persistentGrantRepository;
}
public void Build()
{
AddClients();
AddPersistentGrants();
}
private void AddClients()
@ -40,5 +45,19 @@ namespace Volo.Abp.IdentityServer
_clientRepository.Insert(client42);
}
private void AddPersistentGrants()
{
var persistentGrant38 = new PersistedGrant(_guidGenerator.Create())
{
Key = "38",
ClientId = "TestClientId-38",
Type = "TestType-38",
SubjectId = "TestSubject-38",
Data = "TestData-38"
};
_persistentGrantRepository.Insert(persistentGrant38);
}
}
}

39
test/Abp.IdentityServer.EntityFrameworkCore.Tests/Volo/Abp/IdentityServer/Clients/PersistentGrant_Tests.cs

@ -0,0 +1,39 @@
using System.Threading.Tasks;
using IdentityServer4.Stores;
using Microsoft.Extensions.DependencyInjection;
using Shouldly;
using Xunit;
namespace Volo.Abp.IdentityServer.Clients
{
public class PersistentGrantStore_Tests : AbpIdentityServerTestBase
{
private readonly IPersistedGrantStore _persistedGrantStore;
public PersistentGrantStore_Tests()
{
_persistedGrantStore = ServiceProvider.GetRequiredService<IPersistedGrantStore>();
}
[Fact]
public async Task FindClientByIdAsync_Should_Return_Null_If_Not_Found()
{
var persistentGrant = await _persistedGrantStore.GetAsync("not-existing-id");
persistentGrant.ShouldBeNull();
}
[Fact]
public async Task FindPersistentGrantByIdAsync_Should_Return_The_PersistentGrant_If_Found()
{
//Act
var client = await _persistedGrantStore.GetAsync("38");
//Assert
client.ShouldNotBeNull();
client.ClientId.ShouldBe("TestClientId-38");
client.SubjectId.ShouldBe("TestSubject-38");
client.Data.ShouldContain("TestData-38");
client.Type.ShouldContain("TestType-38");
}
}
}
Loading…
Cancel
Save