Browse Source

Run domain layer tests on EF core integration.

pull/961/head
Halil ibrahim Kalkan 7 years ago
parent
commit
8a7aebaebc
  1. 10
      modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/AllowedCorsOriginsCacheItemInvalidator.cs
  2. 3
      modules/identityserver/test/Volo.Abp.IdentityServer.Domain.Tests/Volo.Abp.IdentityServer.Domain.Tests.csproj
  3. 2
      modules/identityserver/test/Volo.Abp.IdentityServer.Domain.Tests/Volo/Abp/IdentityServer/AbpIdentityServerDomainTestModule.cs
  4. 14
      modules/identityserver/test/Volo.Abp.IdentityServer.Domain.Tests/Volo/Abp/IdentityServer/CorsPolicyService_Tests.cs
  5. 2
      modules/identityserver/test/Volo.Abp.IdentityServer.EntityFrameworkCore.Tests/Volo/Abp/IdentityServer/AbpIdentityServerTestDataBuilder.cs
  6. 2
      modules/identityserver/test/Volo.Abp.IdentityServer.EntityFrameworkCore.Tests/Volo/Abp/IdentityServer/AbpIdentityServerTestEntityFrameworkCoreModule.cs

10
modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/AllowedCorsOriginsCacheItemInvalidator.cs

@ -7,7 +7,10 @@ using Volo.Abp.IdentityServer.Clients;
namespace Volo.Abp.IdentityServer 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; } protected IDistributedCache<AllowedCorsOriginsCacheItem> Cache { get; }
@ -20,5 +23,10 @@ namespace Volo.Abp.IdentityServer
{ {
await Cache.RemoveAsync(AllowedCorsOriginsCacheItem.AllOrigins); await Cache.RemoveAsync(AllowedCorsOriginsCacheItem.AllOrigins);
} }
public async Task HandleEventAsync(EntityChangedEventData<ClientCorsOrigin> eventData)
{
await Cache.RemoveAsync(AllowedCorsOriginsCacheItem.AllOrigins);
}
} }
} }

3
modules/identityserver/test/Volo.Abp.IdentityServer.Domain.Tests/Volo.Abp.IdentityServer.Domain.Tests.csproj

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

2
modules/identityserver/test/Volo.Abp.IdentityServer.Domain.Tests/Volo/Abp/IdentityServer/AbpIdentityServerDomainTestModule.cs

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

14
modules/identityserver/test/Volo.Abp.IdentityServer.Domain.Tests/Volo/Abp/IdentityServer/CorsPolicyService_Tests.cs

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

2
modules/identityserver/test/Volo.Abp.IdentityServer.EntityFrameworkCore.Tests/Volo/Abp/IdentityServer/AbpIdentityServerTestDataBuilder.cs

@ -12,6 +12,8 @@ using PersistedGrant = Volo.Abp.IdentityServer.Grants.PersistedGrant;
namespace Volo.Abp.IdentityServer 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 public class AbpIdentityServerTestDataBuilder : ITransientDependency
{ {
private readonly IGuidGenerator _guidGenerator; private readonly IGuidGenerator _guidGenerator;

2
modules/identityserver/test/Volo.Abp.IdentityServer.EntityFrameworkCore.Tests/Volo/Abp/IdentityServer/AbpIdentityServerTestEntityFrameworkCoreModule.cs

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

Loading…
Cancel
Save