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 1252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1746 // preloaded HSTS entries in the TransportSecurityState. This means that we | 1746 // preloaded HSTS entries in the TransportSecurityState. This means that we |
1747 // have to use a MockHostResolver in order to direct www.google.com to the | 1747 // have to use a MockHostResolver in order to direct www.google.com to the |
1748 // testserver. | 1748 // testserver. |
1749 | 1749 |
1750 MockHostResolver host_resolver; | 1750 MockHostResolver host_resolver; |
1751 host_resolver.rules()->AddRule("www.google.com", "127.0.0.1"); | 1751 host_resolver.rules()->AddRule("www.google.com", "127.0.0.1"); |
1752 TestNetworkDelegate network_delegate; // must outlive URLRequest | 1752 TestNetworkDelegate network_delegate; // must outlive URLRequest |
1753 scoped_refptr<TestURLRequestContext> context(new TestURLRequestContext(true)); | 1753 scoped_refptr<TestURLRequestContext> context(new TestURLRequestContext(true)); |
1754 context->set_network_delegate(&network_delegate); | 1754 context->set_network_delegate(&network_delegate); |
1755 context->set_host_resolver(&host_resolver); | 1755 context->set_host_resolver(&host_resolver); |
1756 TransportSecurityState transport_security_state(""); | 1756 TransportSecurityState transport_security_state; |
1757 context->set_transport_security_state(&transport_security_state); | 1757 context->set_transport_security_state(&transport_security_state); |
1758 context->Init(); | 1758 context->Init(); |
1759 | 1759 |
1760 TestDelegate d; | 1760 TestDelegate d; |
1761 TestURLRequest r(GURL(StringPrintf("https://www.google.com:%d", | 1761 TestURLRequest r(GURL(StringPrintf("https://www.google.com:%d", |
1762 test_server.host_port_pair().port())), | 1762 test_server.host_port_pair().port())), |
1763 &d); | 1763 &d); |
1764 r.set_context(context); | 1764 r.set_context(context); |
1765 | 1765 |
1766 r.Start(); | 1766 r.Start(); |
(...skipping 22 matching lines...) Expand all Loading... |
1789 // preloaded and dynamic HSTS and public key pin entries in the | 1789 // preloaded and dynamic HSTS and public key pin entries in the |
1790 // TransportSecurityState. This means that we have to use a | 1790 // TransportSecurityState. This means that we have to use a |
1791 // MockHostResolver in order to direct www.google.com to the testserver. | 1791 // MockHostResolver in order to direct www.google.com to the testserver. |
1792 | 1792 |
1793 MockHostResolver host_resolver; | 1793 MockHostResolver host_resolver; |
1794 host_resolver.rules()->AddRule("www.google.com", "127.0.0.1"); | 1794 host_resolver.rules()->AddRule("www.google.com", "127.0.0.1"); |
1795 TestNetworkDelegate network_delegate; // must outlive URLRequest | 1795 TestNetworkDelegate network_delegate; // must outlive URLRequest |
1796 scoped_refptr<TestURLRequestContext> context(new TestURLRequestContext(true)); | 1796 scoped_refptr<TestURLRequestContext> context(new TestURLRequestContext(true)); |
1797 context->set_network_delegate(&network_delegate); | 1797 context->set_network_delegate(&network_delegate); |
1798 context->set_host_resolver(&host_resolver); | 1798 context->set_host_resolver(&host_resolver); |
1799 TransportSecurityState transport_security_state(""); | 1799 TransportSecurityState transport_security_state; |
1800 TransportSecurityState::DomainState domain_state; | 1800 TransportSecurityState::DomainState domain_state; |
1801 EXPECT_TRUE(transport_security_state.HasMetadata(&domain_state, | 1801 EXPECT_TRUE(transport_security_state.GetDomainState("www.google.com", true, |
1802 "www.google.com", true)); | 1802 &domain_state)); |
1803 context->set_transport_security_state(&transport_security_state); | 1803 context->set_transport_security_state(&transport_security_state); |
1804 context->Init(); | 1804 context->Init(); |
1805 | 1805 |
1806 TestDelegate d; | 1806 TestDelegate d; |
1807 TestURLRequest r(GURL(StringPrintf("https://www.google.com:%d", | 1807 TestURLRequest r(GURL(StringPrintf("https://www.google.com:%d", |
1808 test_server.host_port_pair().port())), | 1808 test_server.host_port_pair().port())), |
1809 &d); | 1809 &d); |
1810 r.set_context(context); | 1810 r.set_context(context); |
1811 | 1811 |
1812 r.Start(); | 1812 r.Start(); |
1813 EXPECT_TRUE(r.is_pending()); | 1813 EXPECT_TRUE(r.is_pending()); |
1814 | 1814 |
1815 MessageLoop::current()->Run(); | 1815 MessageLoop::current()->Run(); |
1816 | 1816 |
1817 EXPECT_EQ(1, d.response_started_count()); | 1817 EXPECT_EQ(1, d.response_started_count()); |
1818 EXPECT_FALSE(d.received_data_before_response()); | 1818 EXPECT_FALSE(d.received_data_before_response()); |
1819 EXPECT_TRUE(d.have_certificate_errors()); | 1819 EXPECT_TRUE(d.have_certificate_errors()); |
1820 EXPECT_TRUE(d.certificate_errors_are_fatal()); | 1820 EXPECT_TRUE(d.certificate_errors_are_fatal()); |
1821 | 1821 |
1822 // Get a fresh copy of the state, and check that it hasn't been updated. | 1822 // Get a fresh copy of the state, and check that it hasn't been updated. |
1823 TransportSecurityState::DomainState new_domain_state; | 1823 TransportSecurityState::DomainState new_domain_state; |
1824 EXPECT_TRUE(transport_security_state.HasMetadata(&new_domain_state, | 1824 EXPECT_TRUE(transport_security_state.GetDomainState("www.google.com", true, |
1825 "www.google.com", true)); | 1825 &new_domain_state)); |
1826 EXPECT_EQ(new_domain_state.mode, domain_state.mode); | 1826 EXPECT_EQ(new_domain_state.upgrade_mode, domain_state.upgrade_mode); |
1827 EXPECT_EQ(new_domain_state.include_subdomains, | 1827 EXPECT_EQ(new_domain_state.include_subdomains, |
1828 domain_state.include_subdomains); | 1828 domain_state.include_subdomains); |
1829 EXPECT_TRUE(FingerprintsEqual(new_domain_state.preloaded_spki_hashes, | 1829 EXPECT_TRUE(FingerprintsEqual(new_domain_state.static_spki_hashes, |
1830 domain_state.preloaded_spki_hashes)); | 1830 domain_state.static_spki_hashes)); |
1831 EXPECT_TRUE(FingerprintsEqual(new_domain_state.dynamic_spki_hashes, | 1831 EXPECT_TRUE(FingerprintsEqual(new_domain_state.dynamic_spki_hashes, |
1832 domain_state.dynamic_spki_hashes)); | 1832 domain_state.dynamic_spki_hashes)); |
1833 EXPECT_TRUE(FingerprintsEqual(new_domain_state.bad_preloaded_spki_hashes, | 1833 EXPECT_TRUE(FingerprintsEqual(new_domain_state.bad_static_spki_hashes, |
1834 domain_state.bad_preloaded_spki_hashes)); | 1834 domain_state.bad_static_spki_hashes)); |
1835 } | 1835 } |
1836 | 1836 |
1837 namespace { | 1837 namespace { |
1838 | 1838 |
1839 class SSLClientAuthTestDelegate : public TestDelegate { | 1839 class SSLClientAuthTestDelegate : public TestDelegate { |
1840 public: | 1840 public: |
1841 SSLClientAuthTestDelegate() : on_certificate_requested_count_(0) { | 1841 SSLClientAuthTestDelegate() : on_certificate_requested_count_(0) { |
1842 } | 1842 } |
1843 virtual void OnCertificateRequested( | 1843 virtual void OnCertificateRequested( |
1844 URLRequest* request, | 1844 URLRequest* request, |
(...skipping 698 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2543 FilePath app_path; | 2543 FilePath app_path; |
2544 PathService::Get(base::DIR_SOURCE_ROOT, &app_path); | 2544 PathService::Get(base::DIR_SOURCE_ROOT, &app_path); |
2545 app_path = app_path.AppendASCII("net"); | 2545 app_path = app_path.AppendASCII("net"); |
2546 app_path = app_path.AppendASCII("data"); | 2546 app_path = app_path.AppendASCII("data"); |
2547 app_path = app_path.AppendASCII("url_request_unittest"); | 2547 app_path = app_path.AppendASCII("url_request_unittest"); |
2548 app_path = app_path.AppendASCII("with-headers.html"); | 2548 app_path = app_path.AppendASCII("with-headers.html"); |
2549 | 2549 |
2550 std::wstring lnk_path = app_path.value() + L".lnk"; | 2550 std::wstring lnk_path = app_path.value() + L".lnk"; |
2551 | 2551 |
2552 HRESULT result; | 2552 HRESULT result; |
2553 IShellLink *shell = NULL; | 2553 IShellLink* shell = NULL; |
2554 IPersistFile *persist = NULL; | 2554 IPersistFile* persist = NULL; |
2555 | 2555 |
2556 CoInitialize(NULL); | 2556 CoInitialize(NULL); |
2557 // Temporarily create a shortcut for test | 2557 // Temporarily create a shortcut for test |
2558 result = CoCreateInstance(CLSID_ShellLink, NULL, | 2558 result = CoCreateInstance(CLSID_ShellLink, NULL, |
2559 CLSCTX_INPROC_SERVER, IID_IShellLink, | 2559 CLSCTX_INPROC_SERVER, IID_IShellLink, |
2560 reinterpret_cast<LPVOID*>(&shell)); | 2560 reinterpret_cast<LPVOID*>(&shell)); |
2561 ASSERT_TRUE(SUCCEEDED(result)); | 2561 ASSERT_TRUE(SUCCEEDED(result)); |
2562 result = shell->QueryInterface(IID_IPersistFile, | 2562 result = shell->QueryInterface(IID_IPersistFile, |
2563 reinterpret_cast<LPVOID*>(&persist)); | 2563 reinterpret_cast<LPVOID*>(&persist)); |
2564 ASSERT_TRUE(SUCCEEDED(result)); | 2564 ASSERT_TRUE(SUCCEEDED(result)); |
(...skipping 1998 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4563 req.SetExtraRequestHeaders(headers); | 4563 req.SetExtraRequestHeaders(headers); |
4564 req.Start(); | 4564 req.Start(); |
4565 MessageLoop::current()->Run(); | 4565 MessageLoop::current()->Run(); |
4566 // If the net tests are being run with ChromeFrame then we need to allow for | 4566 // If the net tests are being run with ChromeFrame then we need to allow for |
4567 // the 'chromeframe' suffix which is added to the user agent before the | 4567 // the 'chromeframe' suffix which is added to the user agent before the |
4568 // closing parentheses. | 4568 // closing parentheses. |
4569 EXPECT_TRUE(StartsWithASCII(d.data_received(), "Lynx (textmode", true)); | 4569 EXPECT_TRUE(StartsWithASCII(d.data_received(), "Lynx (textmode", true)); |
4570 } | 4570 } |
4571 | 4571 |
4572 } // namespace net | 4572 } // namespace net |
OLD | NEW |