コード例 #1
0
        public void AuthorizeAuthenticatedAttribute_AsAnonymous()
        {
            var context = generateContext();

            var admin = new AdminAttribute();

            Assert.Throws <AuthorizationException>(() => admin.OnActionExecuting(context));
        }
コード例 #2
0
        public void AuthorizeAdminAttribute_AsAdmin()
        {
            var context = generateContext();

            context.HttpContext.Request.Headers["Authorization"] = "admin";

            var admin = new AdminAttribute();

            admin.OnActionExecuting(context);
        }
コード例 #3
0
        public void AuthorizeAdminAttribute_AsAuthenticated()
        {
            var context = generateContext();

            context.HttpContext.Request.Headers["Authorization"] = "auth";

            var admin = new AdminAttribute();

            Assert.Throws <AuthorizationException>(() => admin.OnActionExecuting(context));
        }