OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/base/net_util.h" | 5 #include "net/base/net_util.h" |
6 | 6 |
7 #include "base/file_path.h" | 7 #include "base/file_path.h" |
8 #include "base/format_macros.h" | 8 #include "base/format_macros.h" |
9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
10 #include "base/sys_string_conversions.h" | 10 #include "base/sys_string_conversions.h" |
(...skipping 1574 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1585 "http://google.com/sup?yo", | 1585 "http://google.com/sup?yo", |
1586 }, | 1586 }, |
1587 { // Try an HTTPS URL -- strip both the reference and the username/password. | 1587 { // Try an HTTPS URL -- strip both the reference and the username/password. |
1588 "https://user:pass@google.com:80/sup?yo#X#X", | 1588 "https://user:pass@google.com:80/sup?yo#X#X", |
1589 "https://google.com:80/sup?yo", | 1589 "https://google.com:80/sup?yo", |
1590 }, | 1590 }, |
1591 { // Try an FTP URL -- strip both the reference and the username/password. | 1591 { // Try an FTP URL -- strip both the reference and the username/password. |
1592 "ftp://user:pass@google.com:80/sup?yo#X#X", | 1592 "ftp://user:pass@google.com:80/sup?yo#X#X", |
1593 "ftp://google.com:80/sup?yo", | 1593 "ftp://google.com:80/sup?yo", |
1594 }, | 1594 }, |
1595 { // Try an standard URL with unknow scheme. | 1595 { // Try an nonstandard URL |
1596 "foobar://user:pass@google.com:80/sup?yo#X#X", | 1596 "foobar://user:pass@google.com:80/sup?yo#X#X", |
1597 "foobar://google.com:80/sup?yo", | 1597 "foobar://user:pass@google.com:80/sup?yo#X#X", |
1598 }, | 1598 }, |
1599 }; | 1599 }; |
1600 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) { | 1600 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) { |
1601 SCOPED_TRACE(StringPrintf("Test[%" PRIuS "]: %s", i, tests[i].input_url)); | 1601 SCOPED_TRACE(StringPrintf("Test[%" PRIuS "]: %s", i, tests[i].input_url)); |
1602 GURL input_url(GURL(tests[i].input_url)); | 1602 GURL input_url(GURL(tests[i].input_url)); |
1603 GURL expected_url(GURL(tests[i].expected_simplified_url)); | 1603 GURL expected_url(GURL(tests[i].expected_simplified_url)); |
1604 EXPECT_EQ(expected_url, net::SimplifyUrlForRequest(input_url)); | 1604 EXPECT_EQ(expected_url, net::SimplifyUrlForRequest(input_url)); |
1605 } | 1605 } |
1606 } | 1606 } |
1607 | 1607 |
1608 TEST(NetUtilTest, SetExplicitlyAllowedPortsTest) { | 1608 TEST(NetUtilTest, SetExplicitlyAllowedPortsTest) { |
1609 std::wstring invalid[] = { L"1,2,a", L"'1','2'", L"1, 2, 3", L"1 0,11,12" }; | 1609 std::wstring invalid[] = { L"1,2,a", L"'1','2'", L"1, 2, 3", L"1 0,11,12" }; |
1610 std::wstring valid[] = { L"", L"1", L"1,2", L"1,2,3", L"10,11,12,13" }; | 1610 std::wstring valid[] = { L"", L"1", L"1,2", L"1,2,3", L"10,11,12,13" }; |
1611 | 1611 |
1612 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(invalid); ++i) { | 1612 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(invalid); ++i) { |
1613 net::SetExplicitlyAllowedPorts(invalid[i]); | 1613 net::SetExplicitlyAllowedPorts(invalid[i]); |
1614 EXPECT_EQ(0, static_cast<int>(net::explicitly_allowed_ports.size())); | 1614 EXPECT_EQ(0, static_cast<int>(net::explicitly_allowed_ports.size())); |
1615 } | 1615 } |
1616 | 1616 |
1617 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(valid); ++i) { | 1617 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(valid); ++i) { |
1618 net::SetExplicitlyAllowedPorts(valid[i]); | 1618 net::SetExplicitlyAllowedPorts(valid[i]); |
1619 EXPECT_EQ(i, net::explicitly_allowed_ports.size()); | 1619 EXPECT_EQ(i, net::explicitly_allowed_ports.size()); |
1620 } | 1620 } |
1621 } | 1621 } |
OLD | NEW |