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
3 // found in the LICENSE file.
5 #include "net/quic/crypto/crypto_utils.h"
7 #include "testing/gtest/include/gtest/gtest.h"
13 TEST(CryptoUtilsTest
, IsValidSNI
) {
15 EXPECT_FALSE(CryptoUtils::IsValidSNI("192.168.0.1"));
16 // SNI without any dot.
17 EXPECT_FALSE(CryptoUtils::IsValidSNI("somedomain"));
18 // Invalid RFC2396 hostname
19 // TODO(rtenneti): Support RFC2396 hostname.
20 // EXPECT_FALSE(CryptoUtils::IsValidSNI("some_domain.com"));
21 // An empty string must be invalid otherwise the QUIC client will try sending
23 EXPECT_FALSE(CryptoUtils::IsValidSNI(""));
26 EXPECT_TRUE(CryptoUtils::IsValidSNI("test.google.com"));
29 TEST(CryptoUtilsTest
, NormalizeHostname
) {
31 const char *input
, *expected
;
33 { "www.google.com", "www.google.com", },
34 { "WWW.GOOGLE.COM", "www.google.com", },
35 { "www.google.com.", "www.google.com", },
36 { "www.google.COM.", "www.google.com", },
37 { "www.google.com..", "www.google.com", },
38 { "www.google.com........", "www.google.com", },
41 for (size_t i
= 0; i
< ARRAYSIZE_UNSAFE(tests
); ++i
) {
42 EXPECT_EQ(std::string(tests
[i
].expected
),
43 CryptoUtils::NormalizeHostname(tests
[i
].input
));