public void RoleCheckMultipleCombo() { var identity = new ClaimsIdentity("Test"); identity.AddClaim(new Claim(identity.RoleClaimType, "Allow")); identity.AddClaim(new Claim(identity.RoleClaimType, "AndAllow")); var user = new ClaimsPrincipal(); user.AddIdentity(identity); var attributes = new AuthorizeAttribute[] { new AuthorizeAttribute() { Roles = "Allow,OtherAllow" }, new AuthorizeAttribute() { Roles = "AndAllow" } }; Assert.True(HalcyonExtUtils.CheckRoles(user, attributes)); }
public void NoRolesDeny() { var identity = new ClaimsIdentity(); var user = new ClaimsPrincipal(); user.AddIdentity(identity); var attributes = new AuthorizeAttribute[] { new AuthorizeAttribute() }; Assert.False(HalcyonExtUtils.CheckRoles(user, attributes)); }
public void RoleCheckSingleDeny() { var identity = new ClaimsIdentity("Test"); identity.AddClaim(new Claim(identity.RoleClaimType, "NotValidRole")); var user = new ClaimsPrincipal(); user.AddIdentity(identity); var attributes = new AuthorizeAttribute[] { new AuthorizeAttribute() { Roles = "Allow" } }; Assert.False(HalcyonExtUtils.CheckRoles(user, attributes)); }