Ejemplo n.º 1
0
    public async Task Global_PermissionState_Test()
    {
        var myPermission2 = PermissionDefinitionManager.Get("MyPermission2");

        (await StateCheckerManager.IsEnabledAsync(myPermission2)).ShouldBeFalse();

        using (CurrentPrincipalAccessor.Change(new Claim(AbpClaimTypes.Role, "admin")))
        {
            (await StateCheckerManager.IsEnabledAsync(myPermission2)).ShouldBeTrue();
        }
    }
Ejemplo n.º 2
0
    public async Task PermissionState_Test()
    {
        var myPermission1 = PermissionDefinitionManager.Get("MyPermission1");

        myPermission1.StateCheckers.ShouldContain(x => x.GetType() == typeof(TestRequireEditionPermissionSimpleStateChecker));

        (await StateCheckerManager.IsEnabledAsync(myPermission1)).ShouldBeFalse();

        using (CurrentPrincipalAccessor.Change(new Claim(AbpClaimTypes.EditionId, Guid.NewGuid().ToString())))
        {
            (await StateCheckerManager.IsEnabledAsync(myPermission1)).ShouldBeTrue();
        }
    }