public async Task Global_PermissionState_Test() { var myPermission2 = PermissionDefinitionManager.Get("MyPermission2"); (await PermissionSimpleStateCheckerManager.IsEnabledAsync(myPermission2)).ShouldBeFalse(); using (CurrentPrincipalAccessor.Change(new Claim(AbpClaimTypes.Role, "admin"))) { (await PermissionSimpleStateCheckerManager.IsEnabledAsync(myPermission2)).ShouldBeTrue(); } }
public async Task PermissionState_Test() { var myPermission1 = PermissionDefinitionManager.Get("MyPermission1"); myPermission1.SimpleStateCheckers.ShouldContain(x => x.GetType() == typeof(TestRequireEditionPermissionSimpleStateChecker)); (await PermissionSimpleStateCheckerManager.IsEnabledAsync(myPermission1)).ShouldBeFalse(); using (CurrentPrincipalAccessor.Change(new Claim(AbpClaimTypes.EditionId, Guid.NewGuid().ToString()))) { (await PermissionSimpleStateCheckerManager.IsEnabledAsync(myPermission1)).ShouldBeTrue(); } }