Esempio n. 1
0
        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));
        }
Esempio n. 2
0
        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));
        }
Esempio n. 3
0
        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));
        }