Esempio n. 1
0
        public void RequiresAnyClaims_AuthorizedUserWithAllClaims_ReturnsAuthorized()
        {
            var attr        = new RequiresAnyClaimAttribute("b", "c", "a");
            var user        = UserSetup.GetUserWithClaims("a:0", "b:1", "c:2");
            var httpContext = new Fakes.FakeHttpContext();

            httpContext.User = user;
            var shouldContinue = attr.ShouldContinue(httpContext);

            Assert.True(shouldContinue.ShouldContinue);
        }
Esempio n. 2
0
        public void RequiresAnyClaims_UnauthenticatedUser_ReturnsUnauthenticated()
        {
            var attr        = new RequiresAnyClaimAttribute("a");
            var user        = new ClaimsPrincipal();
            var httpContext = new Fakes.FakeHttpContext();

            httpContext.User = user;
            var shouldContinue = attr.ShouldContinue(httpContext);

            Assert.False(shouldContinue.ShouldContinue);
            Assert.Equal(ApiFilterRunResult.Unauthenticated.SetResponseCode, shouldContinue.SetResponseCode);
        }