Ejemplo n.º 1
0
        public async void GetAsync_CredentialIsNetworkCredentialUriRedirect_StatusCodeUnauthorized()
        {
            Uri redirectUri = HttpTestServers.RedirectUriForCreds(Username, Password);

            using (var handler = new HttpClientHandler())
            {
                handler.Credentials = _credential;
                var client = new HttpClient(handler);
                HttpResponseMessage unAuthResponse = await client.GetAsync(redirectUri);

                Assert.Equal(HttpStatusCode.Unauthorized, unAuthResponse.StatusCode);
            }
        }
Ejemplo n.º 2
0
        public async Task GetAsync_CredentialIsNetworkCredentialUriRedirect_StatusCodeUnauthorized()
        {
            var handler = new HttpClientHandler();

            handler.Credentials = _credential;
            using (var client = new HttpClient(handler))
            {
                Uri redirectUri = HttpTestServers.RedirectUriForCreds(secure: false, userName: Username, password: Password);
                using (HttpResponseMessage unAuthResponse = await client.GetAsync(redirectUri))
                {
                    Assert.Equal(HttpStatusCode.Unauthorized, unAuthResponse.StatusCode);
                }
            }
        }
Ejemplo n.º 3
0
        public void GetAsync_CredentialIsCredentialCacheUriRedirect_HttpStatusCodeOK()
        {
            Uri uri             = HttpTestServers.BasicAuthUriForCreds(Username, Password);
            Uri redirectUri     = HttpTestServers.RedirectUriForCreds(Username, Password);
            var credentialCache = new CredentialCache();

            credentialCache.Add(uri, "Basic", _credential);

            using (var handler = new HttpClientHandler())
            {
                handler.Credentials = credentialCache;
                var client   = new HttpClient(handler);
                var response = client.GetAsync(uri).Result;
                Assert.Equal(HttpStatusCode.OK, response.StatusCode);
            }
        }
Ejemplo n.º 4
0
        public async Task GetAsync_CredentialIsCredentialCacheUriRedirect_StatusCodeOK()
        {
            Uri uri             = HttpTestServers.BasicAuthUriForCreds(Username, Password);
            Uri redirectUri     = HttpTestServers.RedirectUriForCreds(Username, Password);
            var credentialCache = new CredentialCache();

            credentialCache.Add(uri, "Basic", _credential);

            var handler = new HttpClientHandler();

            handler.Credentials = credentialCache;
            using (var client = new HttpClient(handler))
            {
                HttpResponseMessage response = await client.GetAsync(redirectUri);

                Assert.Equal(HttpStatusCode.OK, response.StatusCode);
            }
        }
Ejemplo n.º 5
0
        public async Task GetAsync_CredentialIsCredentialCacheUriRedirect_StatusCodeOK()
        {
            Uri uri         = HttpTestServers.BasicAuthUriForCreds(secure: false, userName: Username, password: Password);
            Uri redirectUri = HttpTestServers.RedirectUriForCreds(secure: false, userName: Username, password: Password);

            _output.WriteLine(uri.AbsoluteUri);
            _output.WriteLine(redirectUri.AbsoluteUri);
            var credentialCache = new CredentialCache();

            credentialCache.Add(uri, "Basic", _credential);

            var handler = new HttpClientHandler();

            handler.Credentials = credentialCache;
            using (var client = new HttpClient(handler))
            {
                using (HttpResponseMessage response = await client.GetAsync(redirectUri))
                {
                    Assert.Equal(HttpStatusCode.OK, response.StatusCode);
                }
            }
        }