Example #1
0
        public async Task it_should_challenge_the_response()
        {
            var response = this.CreateResponse();

            await _authenticationProvider.Process(response);

            response.Headers.WWWAuthenticate.Should().Be(BasicAuthenticationProvider.AuthenticationScheme + " realm=\"" + RequestExtensions.DefaultHost + "\"");
        }
Example #2
0
        public async Task it_should_authenticate_user()
        {
            var expectedUser     = "******";
            var expectedPassword = "******";
            var authorization    = "Basic " + Convert.ToBase64String(Encoding.UTF8.GetBytes(expectedUser + ":" + expectedPassword));
            var request          = this.CreateRequest(new Header("Authorization", authorization));

            _identityProvider.Setup(instance => instance.ValidateCredentials(expectedUser, expectedPassword)).Returns(new BasicClaimBasedIdentity(expectedUser));

            await _authenticationProvider.Process(request);

            request.Identity.IsAuthenticated.Should().BeTrue();
            request.Identity[ClaimTypes.Name].Should().Contain(expectedUser);
        }