Beispiel #1
0
        public void RemoveRolesTest()
        {
            cache.AddRole("resouce:operation", tenantId, "operator");
            cache.AddRole("resouce:operation", tenantId, "admin");

            Assert.AreEqual(2, cache.GetRoles("resouce:operation", tenantId).Count);

            cache.RemoveRoles("resouce:operation", tenantId);

            Assert.AreEqual(0, cache.GetRoles("resouce:operation", tenantId).Count);
        }
        async Task IMultiTenantIamProvider <TTenantKey> .RemoveRoles(string policyName, TTenantKey tenantId, IMultiTenantIamProviderCache <TTenantKey> cache)
        {
            var policyId = await CreateOrGetPolicy(policyName);

            var iamRoles = await _context.IamPolicyRoles
                           .Where(x => x.PolicyId.Equals(policyId) && x.TenantId.Equals(tenantId))
                           .ToListAsync();

            _context.IamPolicyRoles.RemoveRange(iamRoles);

            await _context.SaveChangesAsync();

            cache.RemoveRoles(policyName, tenantId);
        }
        Task IMultiTenantIamProvider <TTenantKey> .RemoveRoles(string policyName, TTenantKey tenantId, IMultiTenantIamProviderCache <TTenantKey> cache)
        {
            cache.RemoveRoles(policyName, tenantId);

            return(Task.CompletedTask);
        }