| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "net/http/http_network_transaction.h" | 5 #include "net/http/http_network_transaction.h" |
| 6 | 6 |
| 7 #include <math.h> // ceil | 7 #include <math.h> // ceil |
| 8 #include <stdarg.h> | 8 #include <stdarg.h> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 487 const int num_rows = static_cast<int>( | 487 const int num_rows = static_cast<int>( |
| 488 ceil(static_cast<float>(size) / sizeof_row)); | 488 ceil(static_cast<float>(size) / sizeof_row)); |
| 489 const int sizeof_data = num_rows * sizeof_row; | 489 const int sizeof_data = num_rows * sizeof_row; |
| 490 DCHECK(sizeof_data >= size); | 490 DCHECK(sizeof_data >= size); |
| 491 str->reserve(sizeof_data); | 491 str->reserve(sizeof_data); |
| 492 | 492 |
| 493 for (int i = 0; i < num_rows; ++i) | 493 for (int i = 0; i < num_rows; ++i) |
| 494 str->append(row, sizeof_row); | 494 str->append(row, sizeof_row); |
| 495 } | 495 } |
| 496 | 496 |
| 497 #if defined(NTLM_PORTABLE) |
| 497 // Alternative functions that eliminate randomness and dependency on the local | 498 // Alternative functions that eliminate randomness and dependency on the local |
| 498 // host name so that the generated NTLM messages are reproducible. | 499 // host name so that the generated NTLM messages are reproducible. |
| 499 void MockGenerateRandom1(uint8* output, size_t n) { | 500 void MockGenerateRandom1(uint8* output, size_t n) { |
| 500 static const uint8 bytes[] = { | 501 static const uint8 bytes[] = { |
| 501 0x55, 0x29, 0x66, 0x26, 0x6b, 0x9c, 0x73, 0x54 | 502 0x55, 0x29, 0x66, 0x26, 0x6b, 0x9c, 0x73, 0x54 |
| 502 }; | 503 }; |
| 503 static size_t current_byte = 0; | 504 static size_t current_byte = 0; |
| 504 for (size_t i = 0; i < n; ++i) { | 505 for (size_t i = 0; i < n; ++i) { |
| 505 output[i] = bytes[current_byte++]; | 506 output[i] = bytes[current_byte++]; |
| 506 current_byte %= arraysize(bytes); | 507 current_byte %= arraysize(bytes); |
| 507 } | 508 } |
| 508 } | 509 } |
| 509 | 510 |
| 510 void MockGenerateRandom2(uint8* output, size_t n) { | 511 void MockGenerateRandom2(uint8* output, size_t n) { |
| 511 static const uint8 bytes[] = { | 512 static const uint8 bytes[] = { |
| 512 0x96, 0x79, 0x85, 0xe7, 0x49, 0x93, 0x70, 0xa1, | 513 0x96, 0x79, 0x85, 0xe7, 0x49, 0x93, 0x70, 0xa1, |
| 513 0x4e, 0xe7, 0x87, 0x45, 0x31, 0x5b, 0xd3, 0x1f | 514 0x4e, 0xe7, 0x87, 0x45, 0x31, 0x5b, 0xd3, 0x1f |
| 514 }; | 515 }; |
| 515 static size_t current_byte = 0; | 516 static size_t current_byte = 0; |
| 516 for (size_t i = 0; i < n; ++i) { | 517 for (size_t i = 0; i < n; ++i) { |
| 517 output[i] = bytes[current_byte++]; | 518 output[i] = bytes[current_byte++]; |
| 518 current_byte %= arraysize(bytes); | 519 current_byte %= arraysize(bytes); |
| 519 } | 520 } |
| 520 } | 521 } |
| 521 | 522 |
| 522 std::string MockGetHostName() { | 523 std::string MockGetHostName() { |
| 523 return "WTC-WIN7"; | 524 return "WTC-WIN7"; |
| 524 } | 525 } |
| 526 #endif // defined(NTLM_PORTABLE) |
| 525 | 527 |
| 526 template<typename ParentPool> | 528 template<typename ParentPool> |
| 527 class CaptureGroupNameSocketPool : public ParentPool { | 529 class CaptureGroupNameSocketPool : public ParentPool { |
| 528 public: | 530 public: |
| 529 CaptureGroupNameSocketPool(HostResolver* host_resolver, | 531 CaptureGroupNameSocketPool(HostResolver* host_resolver, |
| 530 CertVerifier* cert_verifier); | 532 CertVerifier* cert_verifier); |
| 531 | 533 |
| 532 const std::string last_group_name_received() const { | 534 const std::string last_group_name_received() const { |
| 533 return last_group_name_; | 535 return last_group_name_; |
| 534 } | 536 } |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 634 bool CheckDigestServerAuth(const AuthChallengeInfo* auth_challenge) { | 636 bool CheckDigestServerAuth(const AuthChallengeInfo* auth_challenge) { |
| 635 if (!auth_challenge) | 637 if (!auth_challenge) |
| 636 return false; | 638 return false; |
| 637 EXPECT_FALSE(auth_challenge->is_proxy); | 639 EXPECT_FALSE(auth_challenge->is_proxy); |
| 638 EXPECT_EQ("www.example.org:80", auth_challenge->challenger.ToString()); | 640 EXPECT_EQ("www.example.org:80", auth_challenge->challenger.ToString()); |
| 639 EXPECT_EQ("digestive", auth_challenge->realm); | 641 EXPECT_EQ("digestive", auth_challenge->realm); |
| 640 EXPECT_EQ("digest", auth_challenge->scheme); | 642 EXPECT_EQ("digest", auth_challenge->scheme); |
| 641 return true; | 643 return true; |
| 642 } | 644 } |
| 643 | 645 |
| 646 #if defined(NTLM_PORTABLE) |
| 644 bool CheckNTLMServerAuth(const AuthChallengeInfo* auth_challenge) { | 647 bool CheckNTLMServerAuth(const AuthChallengeInfo* auth_challenge) { |
| 645 if (!auth_challenge) | 648 if (!auth_challenge) |
| 646 return false; | 649 return false; |
| 647 EXPECT_FALSE(auth_challenge->is_proxy); | 650 EXPECT_FALSE(auth_challenge->is_proxy); |
| 648 EXPECT_EQ("172.22.68.17:80", auth_challenge->challenger.ToString()); | 651 EXPECT_EQ("172.22.68.17:80", auth_challenge->challenger.ToString()); |
| 649 EXPECT_EQ(std::string(), auth_challenge->realm); | 652 EXPECT_EQ(std::string(), auth_challenge->realm); |
| 650 EXPECT_EQ("ntlm", auth_challenge->scheme); | 653 EXPECT_EQ("ntlm", auth_challenge->scheme); |
| 651 return true; | 654 return true; |
| 652 } | 655 } |
| 656 #endif // defined(NTLM_PORTABLE) |
| 653 | 657 |
| 654 } // namespace | 658 } // namespace |
| 655 | 659 |
| 656 TEST_P(HttpNetworkTransactionTest, Basic) { | 660 TEST_P(HttpNetworkTransactionTest, Basic) { |
| 657 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); | 661 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); |
| 658 scoped_ptr<HttpTransaction> trans( | 662 scoped_ptr<HttpTransaction> trans( |
| 659 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); | 663 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
| 660 } | 664 } |
| 661 | 665 |
| 662 TEST_P(HttpNetworkTransactionTest, SimpleGET) { | 666 TEST_P(HttpNetworkTransactionTest, SimpleGET) { |
| (...skipping 13512 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 14175 ASSERT_TRUE(response); | 14179 ASSERT_TRUE(response); |
| 14176 ASSERT_TRUE(response->headers.get()); | 14180 ASSERT_TRUE(response->headers.get()); |
| 14177 | 14181 |
| 14178 EXPECT_EQ(101, response->headers->response_code()); | 14182 EXPECT_EQ(101, response->headers->response_code()); |
| 14179 | 14183 |
| 14180 trans.reset(); | 14184 trans.reset(); |
| 14181 session->CloseAllConnections(); | 14185 session->CloseAllConnections(); |
| 14182 } | 14186 } |
| 14183 | 14187 |
| 14184 } // namespace net | 14188 } // namespace net |
| OLD | NEW |