Exemple #1
0
        public void NoExtraDataMeansChallengesAreDeterminedOnlyByActiveOrPassiveMode()
        {
            IOwinContext  context  = new OwinContext();
            IOwinRequest  request  = context.Request;
            IOwinResponse response = context.Response;
            var           helper   = new SecurityHelper(context);

            AuthenticationResponseChallenge activeNoChallenge  = helper.LookupChallenge("Alpha", AuthenticationMode.Active);
            AuthenticationResponseChallenge passiveNoChallenge = helper.LookupChallenge("Alpha", AuthenticationMode.Passive);

            response.StatusCode = 401;

            AuthenticationResponseChallenge activeEmptyChallenge  = helper.LookupChallenge("Alpha", AuthenticationMode.Active);
            AuthenticationResponseChallenge passiveEmptyChallenge = helper.LookupChallenge("Alpha", AuthenticationMode.Passive);

            activeNoChallenge.ShouldNotBe(null);
            passiveNoChallenge.ShouldBe(null);
            activeEmptyChallenge.ShouldNotBe(null);
            passiveEmptyChallenge.ShouldBe(null);
        }
Exemple #2
0
        public void WithExtraDataMeansChallengesAreDeterminedOnlyByMatchingAuthenticationType()
        {
            IOwinContext  context  = new OwinContext();
            IOwinRequest  request  = context.Request;
            IOwinResponse response = context.Response;
            var           helper   = new SecurityHelper(context);

            context.Authentication.Challenge(new AuthenticationProperties(), "Beta", "Gamma");

            AuthenticationResponseChallenge activeNoMatch  = helper.LookupChallenge("Alpha", AuthenticationMode.Active);
            AuthenticationResponseChallenge passiveNoMatch = helper.LookupChallenge("Alpha", AuthenticationMode.Passive);

            context.Authentication.Challenge(new AuthenticationProperties(), "Beta", "Alpha");

            AuthenticationResponseChallenge activeWithMatch  = helper.LookupChallenge("Alpha", AuthenticationMode.Active);
            AuthenticationResponseChallenge passiveWithMatch = helper.LookupChallenge("Alpha", AuthenticationMode.Passive);

            activeNoMatch.ShouldBe(null);
            passiveNoMatch.ShouldBe(null);
            activeWithMatch.ShouldNotBe(null);
            passiveWithMatch.ShouldNotBe(null);
        }