public void RemoveRoleTest() { cache.AddRole("resouce:operation", "operator"); Assert.IsTrue(cache.GetRoles("resouce:operation").Contains("operator")); cache.RemoveRole("resouce:operation", "operator"); Assert.IsFalse(cache.GetRoles("resouce:operation").Contains("operator")); }
async Task IIamProvider.RemoveRole(string policyName, string roleName, IIamProviderCache cache) { var policyId = await CreateOrGetPolicy(policyName); var role = await _roleManager.FindByNameAsync(roleName); if (role != null) { var iamRole = await _context.IamPolicyRoles.FirstOrDefaultAsync(x => x.PolicyId.Equals(policyId) && x.RoleId.Equals(role.Id)); if (iamRole != null) { _context.IamPolicyRoles.Remove(iamRole); await _context.SaveChangesAsync(); } cache.RemoveRole(policyName, roleName); } }
Task IIamProvider.RemoveRole(string policyName, string roleName, IIamProviderCache cache) { cache.RemoveRole(policyName, roleName); return(Task.CompletedTask); }