public async Task GetAllAsync()
        {
            await _permissionGrantRepository.InsertAsync(new PermissionGrant(
                                                             Guid.NewGuid(),
                                                             "MyPermission1",
                                                             "Test",
                                                             "Test")
                                                         );

            await _permissionGrantRepository.InsertAsync(new PermissionGrant(
                                                             Guid.NewGuid(),
                                                             "MyPermission2",
                                                             "Test",
                                                             "Test")
                                                         );

            var permissionWithGrantedProviders = await _permissionManager.GetAllAsync(
                "Test",
                "Test");

            permissionWithGrantedProviders.ShouldNotBeNull();
            permissionWithGrantedProviders.ShouldContain(x =>
                                                         x.IsGranted && x.Name == "MyPermission1" && x.Providers.Any(p => p.Key == "Test"));
            permissionWithGrantedProviders.ShouldContain(x =>
                                                         x.IsGranted && x.Name == "MyPermission2" && x.Providers.Any(p => p.Key == "Test"));
        }
示例#2
0
        public static Task <List <PermissionWithGrantedProviders> > GetAllForRoleAsync([NotNull] this IPermissionManager permissionManager, string roleName)
        {
            Check.NotNull(permissionManager, nameof(permissionManager));

            return(permissionManager.GetAllAsync(RolePermissionValueProvider.ProviderName, roleName));
        }
示例#3
0
        public static Task <List <PermissionWithGrantedProviders> > GetAllForUserAsync([NotNull] this IPermissionManager permissionManager, Guid userId)
        {
            Check.NotNull(permissionManager, nameof(permissionManager));

            return(permissionManager.GetAllAsync(UserPermissionValueProvider.ProviderName, userId.ToString()));
        }