Refactored.

pull/216/head
Halil İbrahim Kalkan 8 years ago
parent d131d984a2
commit e0544a12db

@ -6,7 +6,6 @@ using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Routing;
using Microsoft.AspNetCore.TestHost;
using Microsoft.Extensions.DependencyInjection;
using Volo.Abp.TestBase;
namespace Volo.Abp.AspNetCore.TestBase
{

@ -0,0 +1,13 @@
using Microsoft.Extensions.DependencyInjection.Extensions;
using Volo.Abp.Authorization.Permissions;
namespace Microsoft.Extensions.DependencyInjection
{
public static class AbpAuthorizationServiceCollectionExtensions
{
public static IServiceCollection AddAlwaysAllowPermissionChecker(this IServiceCollection services)
{
return services.Replace(ServiceDescriptor.Singleton<IPermissionChecker, AlwaysAllowPermissionChecker>());
}
}
}

@ -0,0 +1,18 @@
using System.Threading.Tasks;
namespace Volo.Abp.Authorization.Permissions
{
/// <summary>
/// Always allows for any permission.
///
/// Use IServiceCollection.AddAlwaysAllowPermissionChecker() to replace
/// IPermissionChecker with this class. This is useful for tests.
/// </summary>
public class AlwaysAllowPermissionChecker : IPermissionChecker
{
public Task<PermissionGrantInfo> CheckAsync(string name)
{
return Task.FromResult(new PermissionGrantInfo(name, true, "AlwaysAllow"));
}
}
}

@ -5,6 +5,10 @@ namespace Volo.Abp.Authorization.Permissions
{
public interface IPermissionStore
{
Task<bool> IsGrantedAsync([NotNull] string name, [CanBeNull] string providerName, [CanBeNull] string providerKey);
Task<bool> IsGrantedAsync(
[NotNull] string name,
[CanBeNull] string providerName,
[CanBeNull] string providerKey
);
}
}

@ -1,9 +0,0 @@
using Volo.Abp.Modularity;
namespace Volo.Abp.TestBase
{
public class AbpTestBaseModule : AbpModule
{
}
}

@ -10,7 +10,7 @@
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute>
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
<RootNamespace>Volo.Abp.TestBase</RootNamespace>
<RootNamespace />
</PropertyGroup>
<ItemGroup>

@ -2,7 +2,7 @@
using Microsoft.Extensions.DependencyInjection;
using Volo.Abp.Modularity;
namespace Volo.Abp.TestBase
namespace Volo.Abp
{
public abstract class AbpIntegratedTest<TStartupModule> : AbpTestBaseWithServiceProvider, IDisposable
where TStartupModule : IAbpModule
@ -15,7 +15,7 @@ namespace Volo.Abp.TestBase
protected IServiceScope TestServiceScope { get; }
public AbpIntegratedTest()
protected AbpIntegratedTest()
{
var services = CreateServiceCollection();
@ -57,7 +57,7 @@ namespace Volo.Abp.TestBase
return services.BuildServiceProviderFromFactory();
}
public void Dispose()
public virtual void Dispose()
{
Application.Shutdown();
TestServiceScope.Dispose();

@ -0,0 +1,13 @@
using Microsoft.Extensions.DependencyInjection;
using Volo.Abp.Modularity;
namespace Volo.Abp
{
public class AbpTestBaseModule : AbpModule
{
public override void ConfigureServices(IServiceCollection services)
{
}
}
}

@ -1,7 +1,7 @@
using System;
using Microsoft.Extensions.DependencyInjection;
namespace Volo.Abp.TestBase
namespace Volo.Abp
{
public abstract class AbpTestBaseWithServiceProvider
{

@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using Shouldly;
using Volo.Abp;
using Volo.Abp.DependencyInjection;
using Volo.Abp.Modularity;
using Volo.Abp.TestBase;

@ -9,11 +9,14 @@ namespace Volo.Abp.Identity
typeof(AbpIdentityApplicationModule),
typeof(AbpIdentityEntityFrameworkCoreModule),
typeof(AbpAutofacModule),
typeof(AbpIdentityDomainTestModule))]
typeof(AbpIdentityDomainTestModule),
typeof(AbpTestBaseModule)
)]
public class AbpIdentityApplicationTestModule : AbpModule
{
public override void ConfigureServices(IServiceCollection services)
{
services.AddAlwaysAllowPermissionChecker();
services.AddAssemblyOf<AbpIdentityApplicationTestModule>();
}
}

Loading…
Cancel
Save