From a4d57d63fee1567977f32ebe87ec819000806d34 Mon Sep 17 00:00:00 2001 From: maliming Date: Wed, 4 Oct 2023 11:14:24 +0800 Subject: [PATCH] Add `SetForClientAsync` extension method to `IPermissionManager `. Resolve #17796 --- .../Abp/ClientPermissionManagerExtensions.cs | 31 +++++++++++++ ...olo.Abp.IdentityServer.Domain.Tests.csproj | 1 + .../AbpIdentityServerDomainTestModule.cs | 6 ++- .../IdentityServer/PermissionManager_Tests.cs | 44 +++++++++++++++++++ .../Abp/IdentityServer/TestPermissionNames.cs | 13 ++++++ .../TestTestPermissionDefinitionProvider.cs | 13 ++++++ ...ityServer.EntityFrameworkCore.Tests.csproj | 1 + ...tityServerTestEntityFrameworkCoreModule.cs | 8 +++- .../AbpIdentityServerTestData.cs | 2 + .../AbpIdentityServerTestDataBuilder.cs | 2 +- .../ClientPermissionManagerExtensions.cs | 31 +++++++++++++ .../Volo.Abp.OpenIddict.Domain.Tests.csproj | 1 + .../OpenIddict/OpenIddictDomainTestModule.cs | 6 ++- .../Abp/OpenIddict/PermissionManager_Tests.cs | 43 ++++++++++++++++++ .../TestPermissionDefinitionProvider.cs | 13 ++++++ .../Abp/OpenIddict/TestPermissionNames.cs | 13 ++++++ ...penIddict.EntityFrameworkCore.Tests.csproj | 1 + ...OpenIddictEntityFrameworkCoreTestModule.cs | 10 ++++- 18 files changed, 232 insertions(+), 7 deletions(-) create mode 100644 modules/identityserver/src/Volo.Abp.PermissionManagement.Domain.IdentityServer/Volo/Abp/ClientPermissionManagerExtensions.cs create mode 100644 modules/identityserver/test/Volo.Abp.IdentityServer.Domain.Tests/Volo/Abp/IdentityServer/PermissionManager_Tests.cs create mode 100644 modules/identityserver/test/Volo.Abp.IdentityServer.Domain.Tests/Volo/Abp/IdentityServer/TestPermissionNames.cs create mode 100644 modules/identityserver/test/Volo.Abp.IdentityServer.Domain.Tests/Volo/Abp/IdentityServer/TestTestPermissionDefinitionProvider.cs create mode 100644 modules/openiddict/src/Volo.Abp.PermissionManagement.Domain.OpenIddict/Volo/Abp/PermissionManagement/ClientPermissionManagerExtensions.cs create mode 100644 modules/openiddict/test/Volo.Abp.OpenIddict.Domain.Tests/Volo/Abp/OpenIddict/PermissionManager_Tests.cs create mode 100644 modules/openiddict/test/Volo.Abp.OpenIddict.Domain.Tests/Volo/Abp/OpenIddict/TestPermissionDefinitionProvider.cs create mode 100644 modules/openiddict/test/Volo.Abp.OpenIddict.Domain.Tests/Volo/Abp/OpenIddict/TestPermissionNames.cs diff --git a/modules/identityserver/src/Volo.Abp.PermissionManagement.Domain.IdentityServer/Volo/Abp/ClientPermissionManagerExtensions.cs b/modules/identityserver/src/Volo.Abp.PermissionManagement.Domain.IdentityServer/Volo/Abp/ClientPermissionManagerExtensions.cs new file mode 100644 index 0000000000..8e468b9970 --- /dev/null +++ b/modules/identityserver/src/Volo.Abp.PermissionManagement.Domain.IdentityServer/Volo/Abp/ClientPermissionManagerExtensions.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using JetBrains.Annotations; +using Volo.Abp.Authorization.Permissions; + +namespace Volo.Abp.PermissionManagement; + +public static class ClientPermissionManagerExtensions +{ + public static Task GetForClientAsync([NotNull] this IPermissionManager permissionManager, string clientId, string permissionName) + { + Check.NotNull(permissionManager, nameof(permissionManager)); + + return permissionManager.GetAsync(permissionName, ClientPermissionValueProvider.ProviderName, clientId); + } + + public static Task> GetAllForClientAsync([NotNull] this IPermissionManager permissionManager, string clientId) + { + Check.NotNull(permissionManager, nameof(permissionManager)); + + return permissionManager.GetAllAsync(ClientPermissionValueProvider.ProviderName, clientId); + } + + public static Task SetForClientAsync([NotNull] this IPermissionManager permissionManager, string clientId, [NotNull] string permissionName, bool isGranted) + { + Check.NotNull(permissionManager, nameof(permissionManager)); + + return permissionManager.SetAsync(permissionName, ClientPermissionValueProvider.ProviderName, clientId, isGranted); + } +} diff --git a/modules/identityserver/test/Volo.Abp.IdentityServer.Domain.Tests/Volo.Abp.IdentityServer.Domain.Tests.csproj b/modules/identityserver/test/Volo.Abp.IdentityServer.Domain.Tests/Volo.Abp.IdentityServer.Domain.Tests.csproj index 531d7db8cf..be7826ee79 100644 --- a/modules/identityserver/test/Volo.Abp.IdentityServer.Domain.Tests/Volo.Abp.IdentityServer.Domain.Tests.csproj +++ b/modules/identityserver/test/Volo.Abp.IdentityServer.Domain.Tests/Volo.Abp.IdentityServer.Domain.Tests.csproj @@ -12,6 +12,7 @@ + diff --git a/modules/identityserver/test/Volo.Abp.IdentityServer.Domain.Tests/Volo/Abp/IdentityServer/AbpIdentityServerDomainTestModule.cs b/modules/identityserver/test/Volo.Abp.IdentityServer.Domain.Tests/Volo/Abp/IdentityServer/AbpIdentityServerDomainTestModule.cs index ac5a48a28f..421b3dd076 100644 --- a/modules/identityserver/test/Volo.Abp.IdentityServer.Domain.Tests/Volo/Abp/IdentityServer/AbpIdentityServerDomainTestModule.cs +++ b/modules/identityserver/test/Volo.Abp.IdentityServer.Domain.Tests/Volo/Abp/IdentityServer/AbpIdentityServerDomainTestModule.cs @@ -1,8 +1,12 @@ using Volo.Abp.Modularity; +using Volo.Abp.PermissionManagement.IdentityServer; namespace Volo.Abp.IdentityServer; -[DependsOn(typeof(AbpIdentityServerTestEntityFrameworkCoreModule))] +[DependsOn( + typeof(AbpIdentityServerTestEntityFrameworkCoreModule), + typeof(AbpPermissionManagementDomainIdentityServerModule) +)] public class AbpIdentityServerDomainTestModule : AbpModule { diff --git a/modules/identityserver/test/Volo.Abp.IdentityServer.Domain.Tests/Volo/Abp/IdentityServer/PermissionManager_Tests.cs b/modules/identityserver/test/Volo.Abp.IdentityServer.Domain.Tests/Volo/Abp/IdentityServer/PermissionManager_Tests.cs new file mode 100644 index 0000000000..3558b2a33f --- /dev/null +++ b/modules/identityserver/test/Volo.Abp.IdentityServer.Domain.Tests/Volo/Abp/IdentityServer/PermissionManager_Tests.cs @@ -0,0 +1,44 @@ +using System.Threading.Tasks; +using Shouldly; +using Volo.Abp.Authorization.Permissions; +using Volo.Abp.IdentityServer; +using Volo.Abp.PermissionManagement; +using Xunit; + +namespace Volo.Abp.OpenIddict; + +public class PermissionManager_Tests : AbpIdentityServerDomainTestBase +{ + private readonly IPermissionManager _permissionManager; + private readonly IPermissionStore _permissionStore; + private readonly AbpIdentityServerTestData _testData; + + public PermissionManager_Tests() + { + _permissionManager = GetRequiredService(); + _permissionStore = GetRequiredService(); + _testData = GetRequiredService(); + } + + [Fact] + public async Task Should_Grant_Permission_To_Client() + { + (await _permissionManager.GetForClientAsync(_testData.Client1Name, TestPermissionNames.MyPermission1)).IsGranted.ShouldBeFalse(); + (await _permissionStore.IsGrantedAsync(TestPermissionNames.MyPermission2, ClientPermissionValueProvider.ProviderName, _testData.Client1Name)).ShouldBeFalse(); + + await _permissionManager.SetForClientAsync(_testData.Client1Name, TestPermissionNames.MyPermission2, true); + + (await _permissionManager.GetForClientAsync(_testData.Client1Name, TestPermissionNames.MyPermission2)).IsGranted.ShouldBeTrue(); + (await _permissionStore.IsGrantedAsync(TestPermissionNames.MyPermission2, ClientPermissionValueProvider.ProviderName, _testData.Client1Name)).ShouldBeTrue(); + } + + [Fact] + public async Task Should_Revoke_Permission_From_Client() + { + await _permissionManager.SetForClientAsync(_testData.Client1Name, TestPermissionNames.MyPermission1, true); + (await _permissionManager.GetForClientAsync(_testData.Client1Name, TestPermissionNames.MyPermission1)).IsGranted.ShouldBeTrue(); + + await _permissionManager.SetForClientAsync(_testData.Client1Name, TestPermissionNames.MyPermission1, false); + (await _permissionManager.GetForClientAsync(_testData.Client1Name, TestPermissionNames.MyPermission1)).IsGranted.ShouldBeFalse(); + } +} diff --git a/modules/identityserver/test/Volo.Abp.IdentityServer.Domain.Tests/Volo/Abp/IdentityServer/TestPermissionNames.cs b/modules/identityserver/test/Volo.Abp.IdentityServer.Domain.Tests/Volo/Abp/IdentityServer/TestPermissionNames.cs new file mode 100644 index 0000000000..8e8b8fbf6e --- /dev/null +++ b/modules/identityserver/test/Volo.Abp.IdentityServer.Domain.Tests/Volo/Abp/IdentityServer/TestPermissionNames.cs @@ -0,0 +1,13 @@ +namespace Volo.Abp.IdentityServer; + +public static class TestPermissionNames +{ + public static class Groups + { + public const string TestGroup = "TestGroup"; + } + + public const string MyPermission1 = "MyPermission1"; + + public const string MyPermission2 = "MyPermission2"; +} diff --git a/modules/identityserver/test/Volo.Abp.IdentityServer.Domain.Tests/Volo/Abp/IdentityServer/TestTestPermissionDefinitionProvider.cs b/modules/identityserver/test/Volo.Abp.IdentityServer.Domain.Tests/Volo/Abp/IdentityServer/TestTestPermissionDefinitionProvider.cs new file mode 100644 index 0000000000..c253e64fab --- /dev/null +++ b/modules/identityserver/test/Volo.Abp.IdentityServer.Domain.Tests/Volo/Abp/IdentityServer/TestTestPermissionDefinitionProvider.cs @@ -0,0 +1,13 @@ +using Volo.Abp.Authorization.Permissions; + +namespace Volo.Abp.IdentityServer; + +public class TestTestPermissionDefinitionProvider : PermissionDefinitionProvider +{ + public override void Define(IPermissionDefinitionContext context) + { + var testGroup = context.AddGroup(TestPermissionNames.Groups.TestGroup); + testGroup.AddPermission(TestPermissionNames.MyPermission1); + testGroup.AddPermission(TestPermissionNames.MyPermission2); + } +} diff --git a/modules/identityserver/test/Volo.Abp.IdentityServer.EntityFrameworkCore.Tests/Volo.Abp.IdentityServer.EntityFrameworkCore.Tests.csproj b/modules/identityserver/test/Volo.Abp.IdentityServer.EntityFrameworkCore.Tests/Volo.Abp.IdentityServer.EntityFrameworkCore.Tests.csproj index 49fcacef4e..880326f28f 100644 --- a/modules/identityserver/test/Volo.Abp.IdentityServer.EntityFrameworkCore.Tests/Volo.Abp.IdentityServer.EntityFrameworkCore.Tests.csproj +++ b/modules/identityserver/test/Volo.Abp.IdentityServer.EntityFrameworkCore.Tests/Volo.Abp.IdentityServer.EntityFrameworkCore.Tests.csproj @@ -16,6 +16,7 @@ + diff --git a/modules/identityserver/test/Volo.Abp.IdentityServer.EntityFrameworkCore.Tests/Volo/Abp/IdentityServer/AbpIdentityServerTestEntityFrameworkCoreModule.cs b/modules/identityserver/test/Volo.Abp.IdentityServer.EntityFrameworkCore.Tests/Volo/Abp/IdentityServer/AbpIdentityServerTestEntityFrameworkCoreModule.cs index d23ea92195..b8f61c6662 100644 --- a/modules/identityserver/test/Volo.Abp.IdentityServer.EntityFrameworkCore.Tests/Volo/Abp/IdentityServer/AbpIdentityServerTestEntityFrameworkCoreModule.cs +++ b/modules/identityserver/test/Volo.Abp.IdentityServer.EntityFrameworkCore.Tests/Volo/Abp/IdentityServer/AbpIdentityServerTestEntityFrameworkCoreModule.cs @@ -8,6 +8,7 @@ using Volo.Abp.EntityFrameworkCore.Sqlite; using Volo.Abp.Identity.EntityFrameworkCore; using Volo.Abp.IdentityServer.EntityFrameworkCore; using Volo.Abp.Modularity; +using Volo.Abp.PermissionManagement.EntityFrameworkCore; using Volo.Abp.Threading; namespace Volo.Abp.IdentityServer; @@ -16,7 +17,8 @@ namespace Volo.Abp.IdentityServer; typeof(AbpIdentityEntityFrameworkCoreModule), typeof(AbpIdentityServerEntityFrameworkCoreModule), typeof(AbpIdentityServerTestBaseModule), - typeof(AbpEntityFrameworkCoreSqliteModule) + typeof(AbpEntityFrameworkCoreSqliteModule), + typeof(AbpPermissionManagementEntityFrameworkCoreModule) )] public class AbpIdentityServerTestEntityFrameworkCoreModule : AbpModule { @@ -46,6 +48,10 @@ public class AbpIdentityServerTestEntityFrameworkCoreModule : AbpModule new DbContextOptionsBuilder().UseSqlite(connection).Options ).GetService().CreateTables(); + new PermissionManagementDbContext( + new DbContextOptionsBuilder().UseSqlite(connection).Options + ).GetService().CreateTables(); + return connection; } } diff --git a/modules/identityserver/test/Volo.Abp.IdentityServer.TestBase/Volo/Abp/IdentityServer/AbpIdentityServerTestData.cs b/modules/identityserver/test/Volo.Abp.IdentityServer.TestBase/Volo/Abp/IdentityServer/AbpIdentityServerTestData.cs index afca6589e1..efb0f929bb 100644 --- a/modules/identityserver/test/Volo.Abp.IdentityServer.TestBase/Volo/Abp/IdentityServer/AbpIdentityServerTestData.cs +++ b/modules/identityserver/test/Volo.Abp.IdentityServer.TestBase/Volo/Abp/IdentityServer/AbpIdentityServerTestData.cs @@ -7,6 +7,8 @@ public class AbpIdentityServerTestData : ISingletonDependency { public Guid Client1Id { get; } = Guid.NewGuid(); + public string Client1Name { get; } = "ClientId1"; + public Guid ApiResource1Id { get; } = Guid.NewGuid(); public Guid IdentityResource1Id { get; } = Guid.NewGuid(); diff --git a/modules/identityserver/test/Volo.Abp.IdentityServer.TestBase/Volo/Abp/IdentityServer/AbpIdentityServerTestDataBuilder.cs b/modules/identityserver/test/Volo.Abp.IdentityServer.TestBase/Volo/Abp/IdentityServer/AbpIdentityServerTestDataBuilder.cs index e6344f9c6f..20ef478649 100644 --- a/modules/identityserver/test/Volo.Abp.IdentityServer.TestBase/Volo/Abp/IdentityServer/AbpIdentityServerTestDataBuilder.cs +++ b/modules/identityserver/test/Volo.Abp.IdentityServer.TestBase/Volo/Abp/IdentityServer/AbpIdentityServerTestDataBuilder.cs @@ -139,7 +139,7 @@ public class AbpIdentityServerTestDataBuilder : ITransientDependency private async Task AddClients() { - var client = new Client(_testData.Client1Id, "ClientId1") + var client = new Client(_testData.Client1Id, _testData.Client1Name) { Description = nameof(Client.Description), ClientName = nameof(Client.ClientName), diff --git a/modules/openiddict/src/Volo.Abp.PermissionManagement.Domain.OpenIddict/Volo/Abp/PermissionManagement/ClientPermissionManagerExtensions.cs b/modules/openiddict/src/Volo.Abp.PermissionManagement.Domain.OpenIddict/Volo/Abp/PermissionManagement/ClientPermissionManagerExtensions.cs new file mode 100644 index 0000000000..8e468b9970 --- /dev/null +++ b/modules/openiddict/src/Volo.Abp.PermissionManagement.Domain.OpenIddict/Volo/Abp/PermissionManagement/ClientPermissionManagerExtensions.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using JetBrains.Annotations; +using Volo.Abp.Authorization.Permissions; + +namespace Volo.Abp.PermissionManagement; + +public static class ClientPermissionManagerExtensions +{ + public static Task GetForClientAsync([NotNull] this IPermissionManager permissionManager, string clientId, string permissionName) + { + Check.NotNull(permissionManager, nameof(permissionManager)); + + return permissionManager.GetAsync(permissionName, ClientPermissionValueProvider.ProviderName, clientId); + } + + public static Task> GetAllForClientAsync([NotNull] this IPermissionManager permissionManager, string clientId) + { + Check.NotNull(permissionManager, nameof(permissionManager)); + + return permissionManager.GetAllAsync(ClientPermissionValueProvider.ProviderName, clientId); + } + + public static Task SetForClientAsync([NotNull] this IPermissionManager permissionManager, string clientId, [NotNull] string permissionName, bool isGranted) + { + Check.NotNull(permissionManager, nameof(permissionManager)); + + return permissionManager.SetAsync(permissionName, ClientPermissionValueProvider.ProviderName, clientId, isGranted); + } +} diff --git a/modules/openiddict/test/Volo.Abp.OpenIddict.Domain.Tests/Volo.Abp.OpenIddict.Domain.Tests.csproj b/modules/openiddict/test/Volo.Abp.OpenIddict.Domain.Tests/Volo.Abp.OpenIddict.Domain.Tests.csproj index 3e06388401..3b280bb55c 100644 --- a/modules/openiddict/test/Volo.Abp.OpenIddict.Domain.Tests/Volo.Abp.OpenIddict.Domain.Tests.csproj +++ b/modules/openiddict/test/Volo.Abp.OpenIddict.Domain.Tests/Volo.Abp.OpenIddict.Domain.Tests.csproj @@ -12,6 +12,7 @@ + diff --git a/modules/openiddict/test/Volo.Abp.OpenIddict.Domain.Tests/Volo/Abp/OpenIddict/OpenIddictDomainTestModule.cs b/modules/openiddict/test/Volo.Abp.OpenIddict.Domain.Tests/Volo/Abp/OpenIddict/OpenIddictDomainTestModule.cs index b061e36c69..26c37dac31 100644 --- a/modules/openiddict/test/Volo.Abp.OpenIddict.Domain.Tests/Volo/Abp/OpenIddict/OpenIddictDomainTestModule.cs +++ b/modules/openiddict/test/Volo.Abp.OpenIddict.Domain.Tests/Volo/Abp/OpenIddict/OpenIddictDomainTestModule.cs @@ -1,5 +1,6 @@ using Volo.Abp.OpenIddict.EntityFrameworkCore; using Volo.Abp.Modularity; +using Volo.Abp.PermissionManagement.OpenIddict; namespace Volo.Abp.OpenIddict; @@ -8,9 +9,10 @@ namespace Volo.Abp.OpenIddict; * database independent anyway. */ [DependsOn( - typeof(OpenIddictEntityFrameworkCoreTestModule) + typeof(OpenIddictEntityFrameworkCoreTestModule), + typeof(AbpPermissionManagementDomainOpenIddictModule) )] public class OpenIddictDomainTestModule : AbpModule { - + } diff --git a/modules/openiddict/test/Volo.Abp.OpenIddict.Domain.Tests/Volo/Abp/OpenIddict/PermissionManager_Tests.cs b/modules/openiddict/test/Volo.Abp.OpenIddict.Domain.Tests/Volo/Abp/OpenIddict/PermissionManager_Tests.cs new file mode 100644 index 0000000000..b52feae019 --- /dev/null +++ b/modules/openiddict/test/Volo.Abp.OpenIddict.Domain.Tests/Volo/Abp/OpenIddict/PermissionManager_Tests.cs @@ -0,0 +1,43 @@ +using System.Threading.Tasks; +using Shouldly; +using Volo.Abp.Authorization.Permissions; +using Volo.Abp.PermissionManagement; +using Xunit; + +namespace Volo.Abp.OpenIddict; + +public class PermissionManager_Tests : OpenIddictDomainTestBase +{ + private readonly IPermissionManager _permissionManager; + private readonly IPermissionStore _permissionStore; + private readonly AbpOpenIddictTestData _testData; + + public PermissionManager_Tests() + { + _permissionManager = GetRequiredService(); + _permissionStore = GetRequiredService(); + _testData = GetRequiredService(); + } + + [Fact] + public async Task Should_Grant_Permission_To_Client() + { + (await _permissionManager.GetForClientAsync(_testData.App1ClientId, TestPermissionNames.MyPermission1)).IsGranted.ShouldBeFalse(); + (await _permissionStore.IsGrantedAsync(TestPermissionNames.MyPermission2, ClientPermissionValueProvider.ProviderName, _testData.App1ClientId)).ShouldBeFalse(); + + await _permissionManager.SetForClientAsync(_testData.App1ClientId, TestPermissionNames.MyPermission2, true); + + (await _permissionManager.GetForClientAsync(_testData.App1ClientId, TestPermissionNames.MyPermission2)).IsGranted.ShouldBeTrue(); + (await _permissionStore.IsGrantedAsync(TestPermissionNames.MyPermission2, ClientPermissionValueProvider.ProviderName, _testData.App1ClientId)).ShouldBeTrue(); + } + + [Fact] + public async Task Should_Revoke_Permission_From_Client() + { + await _permissionManager.SetForClientAsync(_testData.App1ClientId, TestPermissionNames.MyPermission1, true); + (await _permissionManager.GetForClientAsync(_testData.App1ClientId, TestPermissionNames.MyPermission1)).IsGranted.ShouldBeTrue(); + + await _permissionManager.SetForClientAsync(_testData.App1ClientId, TestPermissionNames.MyPermission1, false); + (await _permissionManager.GetForClientAsync(_testData.App1ClientId, TestPermissionNames.MyPermission1)).IsGranted.ShouldBeFalse(); + } +} diff --git a/modules/openiddict/test/Volo.Abp.OpenIddict.Domain.Tests/Volo/Abp/OpenIddict/TestPermissionDefinitionProvider.cs b/modules/openiddict/test/Volo.Abp.OpenIddict.Domain.Tests/Volo/Abp/OpenIddict/TestPermissionDefinitionProvider.cs new file mode 100644 index 0000000000..bc033b646e --- /dev/null +++ b/modules/openiddict/test/Volo.Abp.OpenIddict.Domain.Tests/Volo/Abp/OpenIddict/TestPermissionDefinitionProvider.cs @@ -0,0 +1,13 @@ +using Volo.Abp.Authorization.Permissions; + +namespace Volo.Abp.OpenIddict; + +public class TestPermissionDefinitionProvider : PermissionDefinitionProvider +{ + public override void Define(IPermissionDefinitionContext context) + { + var testGroup = context.AddGroup(TestPermissionNames.Groups.TestGroup); + testGroup.AddPermission(TestPermissionNames.MyPermission1); + testGroup.AddPermission(TestPermissionNames.MyPermission2); + } +} diff --git a/modules/openiddict/test/Volo.Abp.OpenIddict.Domain.Tests/Volo/Abp/OpenIddict/TestPermissionNames.cs b/modules/openiddict/test/Volo.Abp.OpenIddict.Domain.Tests/Volo/Abp/OpenIddict/TestPermissionNames.cs new file mode 100644 index 0000000000..4b0435b27f --- /dev/null +++ b/modules/openiddict/test/Volo.Abp.OpenIddict.Domain.Tests/Volo/Abp/OpenIddict/TestPermissionNames.cs @@ -0,0 +1,13 @@ +namespace Volo.Abp.OpenIddict; + +public static class TestPermissionNames +{ + public static class Groups + { + public const string TestGroup = "TestGroup"; + } + + public const string MyPermission1 = "MyPermission1"; + + public const string MyPermission2 = "MyPermission2"; +} diff --git a/modules/openiddict/test/Volo.Abp.OpenIddict.EntityFrameworkCore.Tests/Volo.Abp.OpenIddict.EntityFrameworkCore.Tests.csproj b/modules/openiddict/test/Volo.Abp.OpenIddict.EntityFrameworkCore.Tests/Volo.Abp.OpenIddict.EntityFrameworkCore.Tests.csproj index 46e791178d..9c13659b17 100644 --- a/modules/openiddict/test/Volo.Abp.OpenIddict.EntityFrameworkCore.Tests/Volo.Abp.OpenIddict.EntityFrameworkCore.Tests.csproj +++ b/modules/openiddict/test/Volo.Abp.OpenIddict.EntityFrameworkCore.Tests/Volo.Abp.OpenIddict.EntityFrameworkCore.Tests.csproj @@ -16,6 +16,7 @@ + diff --git a/modules/openiddict/test/Volo.Abp.OpenIddict.EntityFrameworkCore.Tests/Volo/Abp/OpenIddict/EntityFrameworkCore/OpenIddictEntityFrameworkCoreTestModule.cs b/modules/openiddict/test/Volo.Abp.OpenIddict.EntityFrameworkCore.Tests/Volo/Abp/OpenIddict/EntityFrameworkCore/OpenIddictEntityFrameworkCoreTestModule.cs index 7d7e630ab8..6fc770b5cb 100644 --- a/modules/openiddict/test/Volo.Abp.OpenIddict.EntityFrameworkCore.Tests/Volo/Abp/OpenIddict/EntityFrameworkCore/OpenIddictEntityFrameworkCoreTestModule.cs +++ b/modules/openiddict/test/Volo.Abp.OpenIddict.EntityFrameworkCore.Tests/Volo/Abp/OpenIddict/EntityFrameworkCore/OpenIddictEntityFrameworkCoreTestModule.cs @@ -6,6 +6,7 @@ using Volo.Abp.EntityFrameworkCore; using Volo.Abp.EntityFrameworkCore.Sqlite; using Volo.Abp.Identity.EntityFrameworkCore; using Volo.Abp.Modularity; +using Volo.Abp.PermissionManagement.EntityFrameworkCore; namespace Volo.Abp.OpenIddict.EntityFrameworkCore; @@ -13,7 +14,8 @@ namespace Volo.Abp.OpenIddict.EntityFrameworkCore; typeof(OpenIddictTestBaseModule), typeof(AbpOpenIddictEntityFrameworkCoreModule), typeof(AbpIdentityEntityFrameworkCoreModule), - typeof(AbpEntityFrameworkCoreSqliteModule) + typeof(AbpEntityFrameworkCoreSqliteModule), + typeof(AbpPermissionManagementEntityFrameworkCoreModule) )] public class OpenIddictEntityFrameworkCoreTestModule : AbpModule { @@ -38,11 +40,15 @@ public class OpenIddictEntityFrameworkCoreTestModule : AbpModule new IdentityDbContext( new DbContextOptionsBuilder().UseSqlite(connection).Options ).GetService().CreateTables(); - + new OpenIddictDbContext( new DbContextOptionsBuilder().UseSqlite(connection).Options ).GetService().CreateTables(); + new PermissionManagementDbContext( + new DbContextOptionsBuilder().UseSqlite(connection).Options + ).GetService().CreateTables(); + return connection; } }