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"));
        }
Ejemplo n.º 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));
        }
Ejemplo n.º 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()));
        }