Browse Source
Merge pull request #817 from Nokecy/addPermissionDefinitionRemoveGroupMethod
Add permission definition remove group method
pull/839/head
Halil İbrahim Kalkan
8 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with
16 additions and
1 deletions
-
framework/src/Volo.Abp.Authorization/Volo/Abp/Authorization/Permissions/IPermissionDefinitionContext.cs
-
framework/src/Volo.Abp.Authorization/Volo/Abp/Authorization/Permissions/PermissionDefinitionContext.cs
-
framework/test/Volo.Abp.Authorization.Tests/Volo/Abp/Authorization/Authorization_Tests.cs
-
framework/test/Volo.Abp.Authorization.Tests/Volo/Abp/Authorization/TestServices/AuthorizationTestPermissionDefinitionProvider.cs
|
|
|
@ -9,5 +9,7 @@ namespace Volo.Abp.Authorization.Permissions |
|
|
|
PermissionGroupDefinition GetGroupOrNull(string name); |
|
|
|
|
|
|
|
PermissionGroupDefinition AddGroup([NotNull] string name, ILocalizableString displayName = null); |
|
|
|
|
|
|
|
void RemoveGroup(string name); |
|
|
|
} |
|
|
|
} |
|
|
|
@ -36,5 +36,16 @@ namespace Volo.Abp.Authorization.Permissions |
|
|
|
return Groups[name]; |
|
|
|
} |
|
|
|
|
|
|
|
public virtual void RemoveGroup(string name) |
|
|
|
{ |
|
|
|
Check.NotNull(name, nameof(name)); |
|
|
|
|
|
|
|
if (!Groups.ContainsKey(name)) |
|
|
|
{ |
|
|
|
throw new AbpException($"Not found permission group with name: {name}"); |
|
|
|
} |
|
|
|
|
|
|
|
Groups.Remove(name); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
@ -50,7 +50,7 @@ namespace Volo.Abp.Authorization |
|
|
|
[Fact] |
|
|
|
public void Should_Permission_Definition_GetGroup() |
|
|
|
{ |
|
|
|
_permissionDefinitionManager.GetGroups().Count.ShouldBe(2); |
|
|
|
_permissionDefinitionManager.GetGroups().Count.ShouldBe(1); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
@ -13,6 +13,8 @@ namespace Volo.Abp.Authorization.TestServices |
|
|
|
} |
|
|
|
PermissionGroupDefinition group = context.AddGroup("TestGroup"); |
|
|
|
group.AddPermission("MyAuthorizedService1"); |
|
|
|
|
|
|
|
context.RemoveGroup("TestGetGroup"); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|