mirror of https://github.com/abpframework/abp.git
committed by
GitHub
47 changed files with 816 additions and 79 deletions
@ -0,0 +1,43 @@ |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
|
|||
namespace Volo.Abp.Authorization.Permissions |
|||
{ |
|||
public class MultiplePermissionGrantResult |
|||
{ |
|||
public bool AllGranted |
|||
{ |
|||
get |
|||
{ |
|||
return Result.Values.All(x => x == PermissionGrantResult.Granted); |
|||
} |
|||
} |
|||
|
|||
public bool AllProhibited |
|||
{ |
|||
get |
|||
{ |
|||
return Result.Values.All(x => x == PermissionGrantResult.Prohibited); |
|||
} |
|||
} |
|||
|
|||
public Dictionary<string, PermissionGrantResult> Result { get; } |
|||
|
|||
public MultiplePermissionGrantResult() |
|||
{ |
|||
Result = new Dictionary<string, PermissionGrantResult>(); |
|||
} |
|||
|
|||
public MultiplePermissionGrantResult(string[] names, PermissionGrantResult grantResult = PermissionGrantResult.Undefined) |
|||
{ |
|||
Check.NotNull(names, nameof(names)); |
|||
|
|||
Result = new Dictionary<string, PermissionGrantResult>(); |
|||
|
|||
foreach (var name in names) |
|||
{ |
|||
Result.Add(name, grantResult); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,25 @@ |
|||
using System.Collections.Generic; |
|||
using System.Security.Claims; |
|||
using JetBrains.Annotations; |
|||
|
|||
namespace Volo.Abp.Authorization.Permissions |
|||
{ |
|||
public class PermissionValuesCheckContext |
|||
{ |
|||
[NotNull] |
|||
public List<PermissionDefinition> Permissions { get; } |
|||
|
|||
[CanBeNull] |
|||
public ClaimsPrincipal Principal { get; } |
|||
|
|||
public PermissionValuesCheckContext( |
|||
[NotNull] List<PermissionDefinition> permissions, |
|||
[CanBeNull] ClaimsPrincipal principal) |
|||
{ |
|||
Check.NotNull(permissions, nameof(permissions)); |
|||
|
|||
Permissions = permissions; |
|||
Principal = principal; |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,16 @@ |
|||
using Shouldly; |
|||
using Xunit; |
|||
|
|||
namespace Volo.Abp.PermissionManagement |
|||
{ |
|||
public class PermissionGrantCacheItem_Tests |
|||
{ |
|||
[Fact] |
|||
public void GetPermissionNameFormCacheKeyOrNull() |
|||
{ |
|||
var key = PermissionGrantCacheItem.CalculateCacheKey("aaa", "bbb", "ccc"); |
|||
PermissionGrantCacheItem.GetPermissionNameFormCacheKeyOrNull(key).ShouldBe("aaa"); |
|||
PermissionGrantCacheItem.GetPermissionNameFormCacheKeyOrNull("aaabbbccc").ShouldBeNull(); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,16 @@ |
|||
using Shouldly; |
|||
using Xunit; |
|||
|
|||
namespace Volo.Abp.SettingManagement |
|||
{ |
|||
public class SettingCacheItem_Tests |
|||
{ |
|||
[Fact] |
|||
public void GetSettingNameFormCacheKeyOrNull() |
|||
{ |
|||
var key = SettingCacheItem.CalculateCacheKey("aaa", "bbb", "ccc"); |
|||
SettingCacheItem.GetSettingNameFormCacheKeyOrNull(key).ShouldBe("aaa"); |
|||
SettingCacheItem.GetSettingNameFormCacheKeyOrNull("aaabbbccc").ShouldBeNull(); |
|||
} |
|||
} |
|||
} |
|||
Loading…
Reference in new issue