Example #1
0
        public void Reuse_last_used_credentials()
        {
            // Arrange
            var cache = new HttpCredentialCache
            {
                new BasicCredentials(new Uri("http://example.org"), username: "", password: "")
            };

            var authService = new CredentialService(cache);
            var request     = new HttpRequestMessage()
            {
                RequestUri = new Uri("http://example.org")
            };

            authService.CreateAuthenticationHeaderFromChallenge(request, new[] { new AuthenticationHeaderValue("basic", "") });

            // Act
            var header = authService.CreateAuthenticationHeaderFromRequest(request);

            // Assert
            Assert.Equal("basic", header.Scheme);
        }
Example #2
0
        public void Reuse_last_used_credentials()
        {
            // Arrange
            var cache = new HttpCredentialCache
            {
                new BasicCredentials(new Uri("http://example.org"), username: "", password: "")
            };

            var authService = new CredentialService(cache);
            var request = new HttpRequestMessage(){RequestUri = new Uri("http://example.org")};
            authService.CreateAuthenticationHeaderFromChallenge(request, new[] { new AuthenticationHeaderValue("basic", "") });

            // Act
            var header = authService.CreateAuthenticationHeaderFromRequest(request);

            // Assert
            Assert.Equal("basic", header.Scheme);

        }