Revert "PermissionManagement application unit tests."

This reverts commit f91da9ea90.
pull/985/head
maliming 6 years ago
parent f91da9ea90
commit 39a92c2a99

@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.28729.10
# Visual Studio 15
VisualStudioVersion = 15.0.27428.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{B559B878-38F7-49CC-BC06-43A32D68C1A7}"
EndProject
@ -29,11 +29,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Volo.Abp.PermissionManageme
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Volo.Abp.PermissionManagement.MongoDB.Tests", "test\Volo.Abp.PermissionManagement.MongoDB.Tests\Volo.Abp.PermissionManagement.MongoDB.Tests.csproj", "{AFA65E08-1F17-4BBE-96A6-80F3CFE22A75}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Volo.Abp.PermissionManagement.HttpApi", "src\Volo.Abp.PermissionManagement.HttpApi\Volo.Abp.PermissionManagement.HttpApi.csproj", "{9E0B517E-F02E-436F-9695-7CF12795D34C}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Volo.Abp.PermissionManagement.HttpApi", "src\Volo.Abp.PermissionManagement.HttpApi\Volo.Abp.PermissionManagement.HttpApi.csproj", "{9E0B517E-F02E-436F-9695-7CF12795D34C}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Volo.Abp.PermissionManagement.HttpApi.Client", "src\Volo.Abp.PermissionManagement.HttpApi.Client\Volo.Abp.PermissionManagement.HttpApi.Client.csproj", "{1CD80519-9431-48DB-B0EA-291A73FF9F49}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Volo.Abp.PermissionManagement.Application.Tests", "test\Volo.Abp.PermissionManagement.Application.Tests\Volo.Abp.PermissionManagement.Application.Tests.csproj", "{A0F72F5F-3713-4E06-ADB7-15ADFDCB79B1}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Volo.Abp.PermissionManagement.HttpApi.Client", "src\Volo.Abp.PermissionManagement.HttpApi.Client\Volo.Abp.PermissionManagement.HttpApi.Client.csproj", "{1CD80519-9431-48DB-B0EA-291A73FF9F49}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -93,10 +91,6 @@ Global
{1CD80519-9431-48DB-B0EA-291A73FF9F49}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1CD80519-9431-48DB-B0EA-291A73FF9F49}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1CD80519-9431-48DB-B0EA-291A73FF9F49}.Release|Any CPU.Build.0 = Release|Any CPU
{A0F72F5F-3713-4E06-ADB7-15ADFDCB79B1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A0F72F5F-3713-4E06-ADB7-15ADFDCB79B1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A0F72F5F-3713-4E06-ADB7-15ADFDCB79B1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A0F72F5F-3713-4E06-ADB7-15ADFDCB79B1}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@ -115,7 +109,6 @@ Global
{AFA65E08-1F17-4BBE-96A6-80F3CFE22A75} = {63DA4A89-5908-4F37-B7E6-525AEEF20C77}
{9E0B517E-F02E-436F-9695-7CF12795D34C} = {B559B878-38F7-49CC-BC06-43A32D68C1A7}
{1CD80519-9431-48DB-B0EA-291A73FF9F49} = {B559B878-38F7-49CC-BC06-43A32D68C1A7}
{A0F72F5F-3713-4E06-ADB7-15ADFDCB79B1} = {63DA4A89-5908-4F37-B7E6-525AEEF20C77}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {8FC7DF78-5E2D-489F-9D43-147D2ABAA112}

@ -1,18 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.9.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\Volo.Abp.PermissionManagement.Application\Volo.Abp.PermissionManagement.Application.csproj" />
<ProjectReference Include="..\Volo.Abp.PermissionManagement.Tests\Volo.Abp.PermissionManagement.Tests.csproj" />
</ItemGroup>
</Project>

@ -1,27 +0,0 @@
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Extensions.DependencyInjection;
using NSubstitute;
using Volo.Abp.Users;
namespace Volo.Abp.PermissionManagement
{
public class AbpPermissionManagementApplicationTestBase : PermissionManagementTestBase<AbpPermissionManagementApplicationTestModule>
{
protected Guid? CurrentUserId { get; set; }
protected AbpPermissionManagementApplicationTestBase()
{
CurrentUserId = Guid.NewGuid();
}
protected override void AfterAddApplication(IServiceCollection services)
{
var currentUser = Substitute.For<ICurrentUser>();
//currentUser.Id.Returns(ci => CurrentUserId);
currentUser.IsAuthenticated.Returns(true);
services.AddSingleton(currentUser);
}
}
}

@ -1,28 +0,0 @@
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Extensions.DependencyInjection;
using Volo.Abp.Authorization.Permissions;
using Volo.Abp.Modularity;
namespace Volo.Abp.PermissionManagement
{
[DependsOn(
typeof(AbpPermissionManagementApplicationModule),
typeof(AbpPermissionManagementTestModule)
)]
public class AbpPermissionManagementApplicationTestModule : AbpModule
{
public override void ConfigureServices(ServiceConfigurationContext context)
{
context.Services.AddAlwaysAllowAuthorization();
context.Services.Configure<PermissionManagementOptions>(options =>
{
options.ProviderPolicies["Test"] = "Test";
options.ManagementProviders.Add<TestPermissionManagementProvider>();
});
}
}
}

@ -1,96 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Shouldly;
using Volo.Abp.Authorization.Permissions;
using Xunit;
namespace Volo.Abp.PermissionManagement.Application.Tests.Volo.Abp.PermissionManagement
{
public class PermissionAppService_Tests : AbpPermissionManagementApplicationTestBase
{
private readonly IPermissionAppService _permissionAppService;
private readonly IPermissionGrantRepository _permissionGrantRepository;
public PermissionAppService_Tests()
{
_permissionAppService = GetRequiredService<IPermissionAppService>();
_permissionGrantRepository = GetRequiredService<IPermissionGrantRepository>();
}
[Fact]
public async Task GetAsync()
{
var permissionListResultDto = await _permissionAppService.GetAsync(UserPermissionValueProvider.ProviderName,
PermissionTestDataBuilder.User1Id.ToString());
permissionListResultDto.ShouldNotBeNull();
permissionListResultDto.EntityDisplayName.ShouldBe(PermissionTestDataBuilder.User1Id.ToString());
permissionListResultDto.Groups.Count.ShouldBe(1);
permissionListResultDto.Groups.ShouldContain(x => x.Name == "TestGroup");
permissionListResultDto.Groups.First().Permissions.Count.ShouldBe(4);
permissionListResultDto.Groups.First().Permissions.ShouldContain(x => x.Name == "MyPermission1");
permissionListResultDto.Groups.First().Permissions.ShouldContain(x => x.Name == "MyPermission2");
permissionListResultDto.Groups.First().Permissions.ShouldContain(x => x.Name == "MyPermission2.ChildPermission1");
permissionListResultDto.Groups.First().Permissions.ShouldContain(x => x.Name == "MyPermission3");
}
[Fact]
public async Task UpdateAsync()
{
(await _permissionGrantRepository.FindAsync("MyPermission1", "Test",
PermissionTestDataBuilder.User1Id.ToString())).ShouldBeNull();
await _permissionAppService.UpdateAsync("Test",
PermissionTestDataBuilder.User1Id.ToString(), new UpdatePermissionsDto()
{
Permissions = new UpdatePermissionDto[]
{
new UpdatePermissionDto()
{
IsGranted = true,
Name = "MyPermission1"
}
}
});
(await _permissionGrantRepository.FindAsync("MyPermission1", "Test",
PermissionTestDataBuilder.User1Id.ToString())).ShouldNotBeNull();
}
[Fact]
public async Task Update_Revoke_Test()
{
_permissionGrantRepository.Insert(
new PermissionGrant(
Guid.NewGuid(),
"MyPermission1",
"Test",
PermissionTestDataBuilder.User1Id.ToString()
)
);
(await _permissionGrantRepository.FindAsync("MyPermission1", "Test",
PermissionTestDataBuilder.User1Id.ToString())).ShouldNotBeNull();
await _permissionAppService.UpdateAsync("Test",
PermissionTestDataBuilder.User1Id.ToString(), new UpdatePermissionsDto()
{
Permissions = new UpdatePermissionDto[]
{
new UpdatePermissionDto()
{
IsGranted = false,
Name = "MyPermission1"
}
}
});
(await _permissionGrantRepository.FindAsync("MyPermission1", "Test",
PermissionTestDataBuilder.User1Id.ToString())).ShouldBeNull();
}
}
}

@ -1,25 +0,0 @@
using System;
using System.Collections.Generic;
using System.Text;
using Volo.Abp.Guids;
using Volo.Abp.MultiTenancy;
namespace Volo.Abp.PermissionManagement
{
public class TestPermissionManagementProvider : PermissionManagementProvider
{
public override string Name => "Test";
public TestPermissionManagementProvider(
IPermissionGrantRepository permissionGrantRepository,
IGuidGenerator guidGenerator,
ICurrentTenant currentTenant)
: base(
permissionGrantRepository,
guidGenerator,
currentTenant)
{
}
}
}
Loading…
Cancel
Save