| 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 "net/cert/cert_verify_proc.h" | 5 #include "net/cert/cert_verify_proc.h" | 
| 6 | 6 | 
| 7 #include <vector> | 7 #include <vector> | 
| 8 | 8 | 
| 9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" | 
| 10 #include "base/logging.h" | 10 #include "base/logging.h" | 
| (...skipping 1338 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1349 #if defined(USE_NSS) || defined(OS_IOS) | 1349 #if defined(USE_NSS) || defined(OS_IOS) | 
| 1350 #define MAYBE_VerifyMixed DISABLED_VerifyMixed | 1350 #define MAYBE_VerifyMixed DISABLED_VerifyMixed | 
| 1351 #else | 1351 #else | 
| 1352 #define MAYBE_VerifyMixed VerifyMixed | 1352 #define MAYBE_VerifyMixed VerifyMixed | 
| 1353 #endif | 1353 #endif | 
| 1354 WRAPPED_INSTANTIATE_TEST_CASE_P( | 1354 WRAPPED_INSTANTIATE_TEST_CASE_P( | 
| 1355     MAYBE_VerifyMixed, | 1355     MAYBE_VerifyMixed, | 
| 1356     CertVerifyProcWeakDigestTest, | 1356     CertVerifyProcWeakDigestTest, | 
| 1357     testing::ValuesIn(kVerifyMixedTestData)); | 1357     testing::ValuesIn(kVerifyMixedTestData)); | 
| 1358 | 1358 | 
| 1359 struct NonUniqueNameTestData { |  | 
| 1360   bool is_unique; |  | 
| 1361   const char* hostname; |  | 
| 1362 }; |  | 
| 1363 |  | 
| 1364 // Google Test pretty-printer. |  | 
| 1365 void PrintTo(const NonUniqueNameTestData& data, std::ostream* os) { |  | 
| 1366   ASSERT_TRUE(data.hostname); |  | 
| 1367   *os << " hostname: " << testing::PrintToString(data.hostname) |  | 
| 1368       << "; is_unique: " << testing::PrintToString(data.is_unique); |  | 
| 1369 } |  | 
| 1370 |  | 
| 1371 const NonUniqueNameTestData kNonUniqueNameTestData[] = { |  | 
| 1372     // Domains under ICANN-assigned domains. |  | 
| 1373     { true, "google.com" }, |  | 
| 1374     { true, "google.co.uk" }, |  | 
| 1375     // Domains under private registries. |  | 
| 1376     { true, "appspot.com" }, |  | 
| 1377     { true, "test.appspot.com" }, |  | 
| 1378     // IPv4 addresses (in various forms). |  | 
| 1379     { true, "8.8.8.8" }, |  | 
| 1380     { true, "1.2.3" }, |  | 
| 1381     { true, "14.15" }, |  | 
| 1382     { true, "676768" }, |  | 
| 1383     // IPv6 addresses. |  | 
| 1384     { true, "FEDC:ba98:7654:3210:FEDC:BA98:7654:3210" }, |  | 
| 1385     { true, "::192.9.5.5" }, |  | 
| 1386     { true, "FEED::BEEF" }, |  | 
| 1387     // 'internal'/non-IANA assigned domains. |  | 
| 1388     { false, "intranet" }, |  | 
| 1389     { false, "intranet." }, |  | 
| 1390     { false, "intranet.example" }, |  | 
| 1391     { false, "host.intranet.example" }, |  | 
| 1392     // gTLDs under discussion, but not yet assigned. |  | 
| 1393     { false, "intranet.corp" }, |  | 
| 1394     { false, "example.tech" }, |  | 
| 1395     { false, "intranet.internal" }, |  | 
| 1396     // Invalid host names are treated as unique - but expected to be |  | 
| 1397     // filtered out before then. |  | 
| 1398     { true, "junk)(£)$*!@~#" }, |  | 
| 1399     { true, "w$w.example.com" }, |  | 
| 1400     { true, "nocolonsallowed:example" }, |  | 
| 1401     { true, "[::4.5.6.9]" }, |  | 
| 1402 }; |  | 
| 1403 |  | 
| 1404 class CertVerifyProcNonUniqueNameTest |  | 
| 1405     : public testing::TestWithParam<NonUniqueNameTestData> { |  | 
| 1406  public: |  | 
| 1407   virtual ~CertVerifyProcNonUniqueNameTest() {} |  | 
| 1408 |  | 
| 1409  protected: |  | 
| 1410   bool IsUnique(const std::string& hostname) { |  | 
| 1411     return !CertVerifyProc::IsHostnameNonUnique(hostname); |  | 
| 1412   } |  | 
| 1413 }; |  | 
| 1414 |  | 
| 1415 // Test that internal/non-unique names are properly identified as such, but |  | 
| 1416 // that IP addresses and hosts beneath registry-controlled domains are flagged |  | 
| 1417 // as unique names. |  | 
| 1418 TEST_P(CertVerifyProcNonUniqueNameTest, IsHostnameNonUnique) { |  | 
| 1419   const NonUniqueNameTestData& test_data = GetParam(); |  | 
| 1420 |  | 
| 1421   EXPECT_EQ(test_data.is_unique, IsUnique(test_data.hostname)); |  | 
| 1422 } |  | 
| 1423 |  | 
| 1424 INSTANTIATE_TEST_CASE_P(, CertVerifyProcNonUniqueNameTest, |  | 
| 1425                         testing::ValuesIn(kNonUniqueNameTestData)); |  | 
| 1426 |  | 
| 1427 }  // namespace net | 1359 }  // namespace net | 
| OLD | NEW | 
|---|