Run domain layer tests on EF core integration.

pull/961/head
Halil ibrahim Kalkan 7 years ago
parent 2de21f72d6
commit 8a7aebaebc

@ -7,7 +7,10 @@ using Volo.Abp.IdentityServer.Clients;
namespace Volo.Abp.IdentityServer
{
public class AllowedCorsOriginsCacheItemInvalidator : ILocalEventHandler<EntityChangedEventData<Client>>, ITransientDependency
public class AllowedCorsOriginsCacheItemInvalidator :
ILocalEventHandler<EntityChangedEventData<Client>>,
ILocalEventHandler<EntityChangedEventData<ClientCorsOrigin>>,
ITransientDependency
{
protected IDistributedCache<AllowedCorsOriginsCacheItem> Cache { get; }
@ -20,5 +23,10 @@ namespace Volo.Abp.IdentityServer
{
await Cache.RemoveAsync(AllowedCorsOriginsCacheItem.AllOrigins);
}
public async Task HandleEventAsync(EntityChangedEventData<ClientCorsOrigin> eventData)
{
await Cache.RemoveAsync(AllowedCorsOriginsCacheItem.AllOrigins);
}
}
}

@ -12,8 +12,7 @@
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Volo.Abp.IdentityServer.MongoDB.Tests\Volo.Abp.IdentityServer.MongoDB.Tests.csproj" />
<ProjectReference Include="..\Volo.Abp.IdentityServer.TestBase\Volo.Abp.IdentityServer.TestBase.csproj" />
<ProjectReference Include="..\Volo.Abp.IdentityServer.EntityFrameworkCore.Tests\Volo.Abp.IdentityServer.EntityFrameworkCore.Tests.csproj" />
</ItemGroup>
<ItemGroup>

@ -2,7 +2,7 @@
namespace Volo.Abp.IdentityServer
{
[DependsOn(typeof(AbpIdentityServerMongoDbTestModule))]
[DependsOn(typeof(AbpIdentityServerTestEntityFrameworkCoreModule))]
public class AbpIdentityServerDomainTestModule : AbpModule
{

@ -2,6 +2,7 @@
using IdentityServer4.Services;
using Shouldly;
using Volo.Abp.IdentityServer.Clients;
using Volo.Abp.Uow;
using Xunit;
namespace Volo.Abp.IdentityServer
@ -10,11 +11,13 @@ namespace Volo.Abp.IdentityServer
{
private readonly ICorsPolicyService _corsPolicyService;
private readonly IClientRepository _clientRepository;
private readonly IUnitOfWorkManager _unitOfWorkManager;
public CorsPolicyService_Tests()
{
_corsPolicyService = GetRequiredService<ICorsPolicyService>();
_clientRepository = GetRequiredService<IClientRepository>();
_unitOfWorkManager = GetRequiredService<IUnitOfWorkManager>();
}
[Fact]
@ -30,9 +33,14 @@ namespace Volo.Abp.IdentityServer
//It does not exists before
(await _corsPolicyService.IsOriginAllowedAsync("https://new-origin.com")).ShouldBeFalse();
var client1 = await _clientRepository.FindByCliendIdAsync("ClientId1");
client1.AddCorsOrigin("https://new-origin.com");
await _clientRepository.UpdateAsync(client1);
using (var uow = _unitOfWorkManager.Begin())
{
var client1 = await _clientRepository.FindByCliendIdAsync("ClientId1");
client1.AddCorsOrigin("https://new-origin.com");
await _clientRepository.UpdateAsync(client1);
await uow.CompleteAsync();
}
//It does exists now
(await _corsPolicyService.IsOriginAllowedAsync("https://new-origin.com")).ShouldBeTrue();

@ -12,6 +12,8 @@ using PersistedGrant = Volo.Abp.IdentityServer.Grants.PersistedGrant;
namespace Volo.Abp.IdentityServer
{
//TODO: There are two data builders (ses AbpIdentityServerTestDataBuilder in Volo.Abp.IdentityServer.TestBase). It should be somehow unified!
public class AbpIdentityServerTestDataBuilder : ITransientDependency
{
private readonly IGuidGenerator _guidGenerator;

@ -1,7 +1,6 @@
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
using Volo.Abp.Autofac;
using Volo.Abp.EntityFrameworkCore;
using Volo.Abp.Identity.EntityFrameworkCore;
using Volo.Abp.IdentityServer.EntityFrameworkCore;
@ -11,7 +10,6 @@ using Volo.Abp.Uow;
namespace Volo.Abp.IdentityServer
{
[DependsOn(
typeof(AbpAutofacModule),
typeof(AbpIdentityEntityFrameworkCoreModule),
typeof(AbpIdentityServerEntityFrameworkCoreModule),
typeof(AbpIdentityServerTestBaseModule)

Loading…
Cancel
Save