OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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/quic/crypto/crypto_utils.h" | 5 #include "net/quic/crypto/crypto_utils.h" |
6 | 6 |
7 #include "testing/gtest/include/gtest/gtest.h" | 7 #include "testing/gtest/include/gtest/gtest.h" |
8 | 8 |
9 namespace net { | 9 namespace net { |
10 namespace test { | 10 namespace test { |
(...skipping 10 matching lines...) Expand all Loading... |
21 // An empty string must be invalid otherwise the QUIC client will try sending | 21 // An empty string must be invalid otherwise the QUIC client will try sending |
22 // it. | 22 // it. |
23 EXPECT_FALSE(CryptoUtils::IsValidSNI("")); | 23 EXPECT_FALSE(CryptoUtils::IsValidSNI("")); |
24 | 24 |
25 // Valid SNI | 25 // Valid SNI |
26 EXPECT_TRUE(CryptoUtils::IsValidSNI("test.google.com")); | 26 EXPECT_TRUE(CryptoUtils::IsValidSNI("test.google.com")); |
27 } | 27 } |
28 | 28 |
29 TEST(CryptoUtilsTest, NormalizeHostname) { | 29 TEST(CryptoUtilsTest, NormalizeHostname) { |
30 struct { | 30 struct { |
31 const char *input, *expected; | 31 const char* input, *expected; |
32 } tests[] = { | 32 } tests[] = { |
33 { "www.google.com", "www.google.com", }, | 33 { |
34 { "WWW.GOOGLE.COM", "www.google.com", }, | 34 "www.google.com", "www.google.com", |
35 { "www.google.com.", "www.google.com", }, | 35 }, |
36 { "www.google.COM.", "www.google.com", }, | 36 { |
37 { "www.google.com..", "www.google.com", }, | 37 "WWW.GOOGLE.COM", "www.google.com", |
38 { "www.google.com........", "www.google.com", }, | 38 }, |
39 }; | 39 { |
| 40 "www.google.com.", "www.google.com", |
| 41 }, |
| 42 { |
| 43 "www.google.COM.", "www.google.com", |
| 44 }, |
| 45 { |
| 46 "www.google.com..", "www.google.com", |
| 47 }, |
| 48 { |
| 49 "www.google.com........", "www.google.com", |
| 50 }, |
| 51 }; |
40 | 52 |
41 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) { | 53 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) { |
42 EXPECT_EQ(std::string(tests[i].expected), | 54 EXPECT_EQ(std::string(tests[i].expected), |
43 CryptoUtils::NormalizeHostname(tests[i].input)); | 55 CryptoUtils::NormalizeHostname(tests[i].input)); |
44 } | 56 } |
45 } | 57 } |
46 | 58 |
47 } // namespace | 59 } // namespace |
48 } // namespace test | 60 } // namespace test |
49 } // namespace net | 61 } // namespace net |
OLD | NEW |