예제 #1
0
        public async Task GetAsync_NtAuthServer_ExpectedStatusCode(bool ntlm, HttpStatusCode expectedStatusCode)
        {
            NtAuthServer server = ntlm ? _servers.NtlmServer : _servers.NegotiateServer;

            var handler = new HttpClientHandler();

            handler.UseDefaultCredentials = true;
            using (var client = new HttpClient(handler))
            {
                client.BaseAddress = new Uri(server.BaseUrl);
                string path = expectedStatusCode == HttpStatusCode.Unauthorized ? server.NoAccessUrl : "";
                HttpResponseMessage response = await client.GetAsync(path);

                Assert.Equal(expectedStatusCode, response.StatusCode);
            }
        }
예제 #2
0
        public async Task PostAsync_NtAuthServer_UseExpect100Header_Success(bool ntlm, int contentSize)
        {
            NtAuthServer server = ntlm ? _servers.NtlmServer : _servers.NegotiateServer;

            var handler = new HttpClientHandler()
            {
                UseDefaultCredentials = true
            };

            using (var client = new HttpClient(handler))
            {
                client.DefaultRequestHeaders.ExpectContinue = true;
                var content = new StringContent(new string('A', contentSize));
                using (HttpResponseMessage response = await client.PostAsync(server.BaseUrl, content))
                {
                    Assert.Equal(HttpStatusCode.OK, response.StatusCode);
                }
            }
        }