Exemple #1
0
        public async Task When_no_user_is_provided__handler_does_not_authorize()
        {
            var handler = new PassThroughAuthorizationHandler();

            var context = new AuthorizationHandlerContext(new[] { new CandidateRequirement() }, null, null);
            await handler.HandleAsync(context);

            Assert.False(context.HasSucceeded);
        }
Exemple #2
0
        public async Task When_has_no_Candidate_claim_and_no_roles__handler_does_not_authorize()
        {
            var handler = new PassThroughAuthorizationHandler();
            var user    = BuildClaimsPrincipalWithClaims();

            var context = new AuthorizationHandlerContext(new[] { new CandidateRequirement() }, user, null);
            await handler.HandleAsync(context);

            Assert.False(context.HasSucceeded);
        }
Exemple #3
0
        public async Task When_user_has_Candidate_claim__handler_authorizes()
        {
            var handler = new PassThroughAuthorizationHandler();
            var user    = BuildClaimsPrincipalWithClaims(new Claim(SharedKernel.ClaimTypes.Candidate, Guid.NewGuid().ToString()));

            var context = new AuthorizationHandlerContext(new[] { new CandidateRequirement() }, user, null);
            await handler.HandleAsync(context);

            Assert.True(context.HasSucceeded);
        }