OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "build/build_config.h" | 5 #include "build/build_config.h" |
6 | 6 |
7 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
8 #include <windows.h> | 8 #include <windows.h> |
9 #include <shlobj.h> | 9 #include <shlobj.h> |
10 #endif | 10 #endif |
(...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
472 EXPECT_NE(kData, d.data_received()); | 472 EXPECT_NE(kData, d.data_received()); |
473 } | 473 } |
474 } | 474 } |
475 if (HasFailure()) | 475 if (HasFailure()) |
476 LOG(WARNING) << "Request method was: " << request_method; | 476 LOG(WARNING) << "Request method was: " << request_method; |
477 } | 477 } |
478 | 478 |
479 void HTTPUploadDataOperationTest(const std::string& method) { | 479 void HTTPUploadDataOperationTest(const std::string& method) { |
480 const int kMsgSize = 20000; // multiple of 10 | 480 const int kMsgSize = 20000; // multiple of 10 |
481 const int kIterations = 50; | 481 const int kIterations = 50; |
482 char *uploadBytes = new char[kMsgSize+1]; | 482 char* uploadBytes = new char[kMsgSize+1]; |
483 char *ptr = uploadBytes; | 483 char* ptr = uploadBytes; |
484 char marker = 'a'; | 484 char marker = 'a'; |
485 for (int idx = 0; idx < kMsgSize/10; idx++) { | 485 for (int idx = 0; idx < kMsgSize/10; idx++) { |
486 memcpy(ptr, "----------", 10); | 486 memcpy(ptr, "----------", 10); |
487 ptr += 10; | 487 ptr += 10; |
488 if (idx % 100 == 0) { | 488 if (idx % 100 == 0) { |
489 ptr--; | 489 ptr--; |
490 *ptr++ = marker; | 490 *ptr++ = marker; |
491 if (++marker > 'z') | 491 if (++marker > 'z') |
492 marker = 'a'; | 492 marker = 'a'; |
493 } | 493 } |
(...skipping 1210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1704 // preloaded HSTS entries in the TransportSecurityState. This means that we | 1704 // preloaded HSTS entries in the TransportSecurityState. This means that we |
1705 // have to use a MockHostResolver in order to direct www.google.com to the | 1705 // have to use a MockHostResolver in order to direct www.google.com to the |
1706 // testserver. | 1706 // testserver. |
1707 | 1707 |
1708 MockHostResolver host_resolver; | 1708 MockHostResolver host_resolver; |
1709 host_resolver.rules()->AddRule("www.google.com", "127.0.0.1"); | 1709 host_resolver.rules()->AddRule("www.google.com", "127.0.0.1"); |
1710 TestNetworkDelegate network_delegate; // must outlive URLRequest | 1710 TestNetworkDelegate network_delegate; // must outlive URLRequest |
1711 scoped_refptr<TestURLRequestContext> context(new TestURLRequestContext(true)); | 1711 scoped_refptr<TestURLRequestContext> context(new TestURLRequestContext(true)); |
1712 context->set_network_delegate(&network_delegate); | 1712 context->set_network_delegate(&network_delegate); |
1713 context->set_host_resolver(&host_resolver); | 1713 context->set_host_resolver(&host_resolver); |
1714 TransportSecurityState transport_security_state(""); | 1714 TransportSecurityState transport_security_state; |
1715 context->set_transport_security_state(&transport_security_state); | 1715 context->set_transport_security_state(&transport_security_state); |
1716 context->Init(); | 1716 context->Init(); |
1717 | 1717 |
1718 TestDelegate d; | 1718 TestDelegate d; |
1719 TestURLRequest r(GURL(StringPrintf("https://www.google.com:%d", | 1719 TestURLRequest r(GURL(StringPrintf("https://www.google.com:%d", |
1720 test_server.host_port_pair().port())), | 1720 test_server.host_port_pair().port())), |
1721 &d); | 1721 &d); |
1722 r.set_context(context); | 1722 r.set_context(context); |
1723 | 1723 |
1724 r.Start(); | 1724 r.Start(); |
(...skipping 22 matching lines...) Expand all Loading... |
1747 // preloaded and dynamic HSTS and public key pin entries in the | 1747 // preloaded and dynamic HSTS and public key pin entries in the |
1748 // TransportSecurityState. This means that we have to use a | 1748 // TransportSecurityState. This means that we have to use a |
1749 // MockHostResolver in order to direct www.google.com to the testserver. | 1749 // MockHostResolver in order to direct www.google.com to the testserver. |
1750 | 1750 |
1751 MockHostResolver host_resolver; | 1751 MockHostResolver host_resolver; |
1752 host_resolver.rules()->AddRule("www.google.com", "127.0.0.1"); | 1752 host_resolver.rules()->AddRule("www.google.com", "127.0.0.1"); |
1753 TestNetworkDelegate network_delegate; // must outlive URLRequest | 1753 TestNetworkDelegate network_delegate; // must outlive URLRequest |
1754 scoped_refptr<TestURLRequestContext> context(new TestURLRequestContext(true)); | 1754 scoped_refptr<TestURLRequestContext> context(new TestURLRequestContext(true)); |
1755 context->set_network_delegate(&network_delegate); | 1755 context->set_network_delegate(&network_delegate); |
1756 context->set_host_resolver(&host_resolver); | 1756 context->set_host_resolver(&host_resolver); |
1757 TransportSecurityState transport_security_state(""); | 1757 TransportSecurityState transport_security_state; |
1758 TransportSecurityState::DomainState domain_state; | 1758 TransportSecurityState::DomainState domain_state; |
1759 EXPECT_TRUE(transport_security_state.HasMetadata(&domain_state, | 1759 EXPECT_TRUE(transport_security_state.GetDomainState("www.google.com", true, |
1760 "www.google.com", true)); | 1760 &domain_state)); |
1761 context->set_transport_security_state(&transport_security_state); | 1761 context->set_transport_security_state(&transport_security_state); |
1762 context->Init(); | 1762 context->Init(); |
1763 | 1763 |
1764 TestDelegate d; | 1764 TestDelegate d; |
1765 TestURLRequest r(GURL(StringPrintf("https://www.google.com:%d", | 1765 TestURLRequest r(GURL(StringPrintf("https://www.google.com:%d", |
1766 test_server.host_port_pair().port())), | 1766 test_server.host_port_pair().port())), |
1767 &d); | 1767 &d); |
1768 r.set_context(context); | 1768 r.set_context(context); |
1769 | 1769 |
1770 r.Start(); | 1770 r.Start(); |
1771 EXPECT_TRUE(r.is_pending()); | 1771 EXPECT_TRUE(r.is_pending()); |
1772 | 1772 |
1773 MessageLoop::current()->Run(); | 1773 MessageLoop::current()->Run(); |
1774 | 1774 |
1775 EXPECT_EQ(1, d.response_started_count()); | 1775 EXPECT_EQ(1, d.response_started_count()); |
1776 EXPECT_FALSE(d.received_data_before_response()); | 1776 EXPECT_FALSE(d.received_data_before_response()); |
1777 EXPECT_TRUE(d.have_certificate_errors()); | 1777 EXPECT_TRUE(d.have_certificate_errors()); |
1778 EXPECT_TRUE(d.certificate_errors_are_fatal()); | 1778 EXPECT_TRUE(d.certificate_errors_are_fatal()); |
1779 | 1779 |
1780 // Get a fresh copy of the state, and check that it hasn't been updated. | 1780 // Get a fresh copy of the state, and check that it hasn't been updated. |
1781 TransportSecurityState::DomainState new_domain_state; | 1781 TransportSecurityState::DomainState new_domain_state; |
1782 EXPECT_TRUE(transport_security_state.HasMetadata(&new_domain_state, | 1782 EXPECT_TRUE(transport_security_state.GetDomainState("www.google.com", true, |
1783 "www.google.com", true)); | 1783 &new_domain_state)); |
1784 EXPECT_EQ(new_domain_state.mode, domain_state.mode); | 1784 EXPECT_EQ(new_domain_state.upgrade_mode, domain_state.upgrade_mode); |
1785 EXPECT_EQ(new_domain_state.include_subdomains, | 1785 EXPECT_EQ(new_domain_state.include_subdomains, |
1786 domain_state.include_subdomains); | 1786 domain_state.include_subdomains); |
1787 EXPECT_TRUE(FingerprintsEqual(new_domain_state.preloaded_spki_hashes, | 1787 EXPECT_TRUE(FingerprintsEqual(new_domain_state.static_spki_hashes, |
1788 domain_state.preloaded_spki_hashes)); | 1788 domain_state.static_spki_hashes)); |
1789 EXPECT_TRUE(FingerprintsEqual(new_domain_state.dynamic_spki_hashes, | 1789 EXPECT_TRUE(FingerprintsEqual(new_domain_state.dynamic_spki_hashes, |
1790 domain_state.dynamic_spki_hashes)); | 1790 domain_state.dynamic_spki_hashes)); |
1791 EXPECT_TRUE(FingerprintsEqual(new_domain_state.bad_preloaded_spki_hashes, | 1791 EXPECT_TRUE(FingerprintsEqual(new_domain_state.bad_static_spki_hashes, |
1792 domain_state.bad_preloaded_spki_hashes)); | 1792 domain_state.bad_static_spki_hashes)); |
1793 } | 1793 } |
1794 | 1794 |
1795 namespace { | 1795 namespace { |
1796 | 1796 |
1797 class SSLClientAuthTestDelegate : public TestDelegate { | 1797 class SSLClientAuthTestDelegate : public TestDelegate { |
1798 public: | 1798 public: |
1799 SSLClientAuthTestDelegate() : on_certificate_requested_count_(0) { | 1799 SSLClientAuthTestDelegate() : on_certificate_requested_count_(0) { |
1800 } | 1800 } |
1801 virtual void OnCertificateRequested( | 1801 virtual void OnCertificateRequested( |
1802 URLRequest* request, | 1802 URLRequest* request, |
(...skipping 698 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2501 FilePath app_path; | 2501 FilePath app_path; |
2502 PathService::Get(base::DIR_SOURCE_ROOT, &app_path); | 2502 PathService::Get(base::DIR_SOURCE_ROOT, &app_path); |
2503 app_path = app_path.AppendASCII("net"); | 2503 app_path = app_path.AppendASCII("net"); |
2504 app_path = app_path.AppendASCII("data"); | 2504 app_path = app_path.AppendASCII("data"); |
2505 app_path = app_path.AppendASCII("url_request_unittest"); | 2505 app_path = app_path.AppendASCII("url_request_unittest"); |
2506 app_path = app_path.AppendASCII("with-headers.html"); | 2506 app_path = app_path.AppendASCII("with-headers.html"); |
2507 | 2507 |
2508 std::wstring lnk_path = app_path.value() + L".lnk"; | 2508 std::wstring lnk_path = app_path.value() + L".lnk"; |
2509 | 2509 |
2510 HRESULT result; | 2510 HRESULT result; |
2511 IShellLink *shell = NULL; | 2511 IShellLink* shell = NULL; |
2512 IPersistFile *persist = NULL; | 2512 IPersistFile* persist = NULL; |
2513 | 2513 |
2514 CoInitialize(NULL); | 2514 CoInitialize(NULL); |
2515 // Temporarily create a shortcut for test | 2515 // Temporarily create a shortcut for test |
2516 result = CoCreateInstance(CLSID_ShellLink, NULL, | 2516 result = CoCreateInstance(CLSID_ShellLink, NULL, |
2517 CLSCTX_INPROC_SERVER, IID_IShellLink, | 2517 CLSCTX_INPROC_SERVER, IID_IShellLink, |
2518 reinterpret_cast<LPVOID*>(&shell)); | 2518 reinterpret_cast<LPVOID*>(&shell)); |
2519 ASSERT_TRUE(SUCCEEDED(result)); | 2519 ASSERT_TRUE(SUCCEEDED(result)); |
2520 result = shell->QueryInterface(IID_IPersistFile, | 2520 result = shell->QueryInterface(IID_IPersistFile, |
2521 reinterpret_cast<LPVOID*>(&persist)); | 2521 reinterpret_cast<LPVOID*>(&persist)); |
2522 ASSERT_TRUE(SUCCEEDED(result)); | 2522 ASSERT_TRUE(SUCCEEDED(result)); |
(...skipping 1998 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4521 req.SetExtraRequestHeaders(headers); | 4521 req.SetExtraRequestHeaders(headers); |
4522 req.Start(); | 4522 req.Start(); |
4523 MessageLoop::current()->Run(); | 4523 MessageLoop::current()->Run(); |
4524 // If the net tests are being run with ChromeFrame then we need to allow for | 4524 // If the net tests are being run with ChromeFrame then we need to allow for |
4525 // the 'chromeframe' suffix which is added to the user agent before the | 4525 // the 'chromeframe' suffix which is added to the user agent before the |
4526 // closing parentheses. | 4526 // closing parentheses. |
4527 EXPECT_TRUE(StartsWithASCII(d.data_received(), "Lynx (textmode", true)); | 4527 EXPECT_TRUE(StartsWithASCII(d.data_received(), "Lynx (textmode", true)); |
4528 } | 4528 } |
4529 | 4529 |
4530 } // namespace net | 4530 } // namespace net |
OLD | NEW |