Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(8)

Side by Side Diff: chrome/browser/ssl/ssl_error_classification_unittest.cc

Issue 511473002: Remove implicit conversions from scoped_refptr to T* in chrome/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Move download out Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "chrome/browser/ssl/ssl_error_classification.h" 5 #include "chrome/browser/ssl/ssl_error_classification.h"
6 6
7 #include "base/files/file_path.h" 7 #include "base/files/file_path.h"
8 #include "base/strings/string_split.h" 8 #include "base/strings/string_split.h"
9 #include "base/time/time.h" 9 #include "base/time/time.h"
10 #include "net/base/test_data_directory.h" 10 #include "net/base/test_data_directory.h"
(...skipping 29 matching lines...) Expand all
40 EXPECT_TRUE(base::Time::FromString("Mon, 08 Jan 2007 12:00:00 GMT", &time)); 40 EXPECT_TRUE(base::Time::FromString("Mon, 08 Jan 2007 12:00:00 GMT", &time));
41 SSLErrorClassification ssl_error(time, origin, *expired_cert); 41 SSLErrorClassification ssl_error(time, origin, *expired_cert);
42 EXPECT_FLOAT_EQ(0.4f, ssl_error.CalculateScoreTimePassedSinceExpiry()); 42 EXPECT_FLOAT_EQ(0.4f, ssl_error.CalculateScoreTimePassedSinceExpiry());
43 } 43 }
44 } 44 }
45 45
46 TEST(SSLErrorClassificationTest, TestNameMismatch) { 46 TEST(SSLErrorClassificationTest, TestNameMismatch) {
47 scoped_refptr<net::X509Certificate> google_cert( 47 scoped_refptr<net::X509Certificate> google_cert(
48 net::X509Certificate::CreateFromBytes( 48 net::X509Certificate::CreateFromBytes(
49 reinterpret_cast<const char*>(google_der), sizeof(google_der))); 49 reinterpret_cast<const char*>(google_der), sizeof(google_der)));
50 ASSERT_NE(static_cast<net::X509Certificate*>(NULL), google_cert); 50 ASSERT_NE(static_cast<net::X509Certificate*>(NULL), google_cert.get());
51 base::Time time = base::Time::NowFromSystemTime(); 51 base::Time time = base::Time::NowFromSystemTime();
52 std::vector<std::string> dns_names_google; 52 std::vector<std::string> dns_names_google;
53 dns_names_google.push_back("www"); 53 dns_names_google.push_back("www");
54 dns_names_google.push_back("google"); 54 dns_names_google.push_back("google");
55 dns_names_google.push_back("com"); 55 dns_names_google.push_back("com");
56 std::vector<std::vector<std::string>> dns_name_tokens_google; 56 std::vector<std::vector<std::string>> dns_name_tokens_google;
57 dns_name_tokens_google.push_back(dns_names_google); 57 dns_name_tokens_google.push_back(dns_names_google);
58 { 58 {
59 GURL origin("https://google.com"); 59 GURL origin("https://google.com");
60 std::string host_name = origin.host(); 60 std::string host_name = origin.host();
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 EXPECT_FALSE(ssl_error.IsWWWSubDomainMatch()); 118 EXPECT_FALSE(ssl_error.IsWWWSubDomainMatch());
119 EXPECT_FALSE(ssl_error.NameUnderAnyNames(host_name_tokens, 119 EXPECT_FALSE(ssl_error.NameUnderAnyNames(host_name_tokens,
120 dns_name_tokens_google)); 120 dns_name_tokens_google));
121 EXPECT_FALSE(ssl_error.AnyNamesUnderName(dns_name_tokens_google, 121 EXPECT_FALSE(ssl_error.AnyNamesUnderName(dns_name_tokens_google,
122 host_name_tokens)); 122 host_name_tokens));
123 } 123 }
124 124
125 scoped_refptr<net::X509Certificate> webkit_cert( 125 scoped_refptr<net::X509Certificate> webkit_cert(
126 net::X509Certificate::CreateFromBytes( 126 net::X509Certificate::CreateFromBytes(
127 reinterpret_cast<const char*>(webkit_der), sizeof(webkit_der))); 127 reinterpret_cast<const char*>(webkit_der), sizeof(webkit_der)));
128 ASSERT_NE(static_cast<net::X509Certificate*>(NULL), webkit_cert); 128 ASSERT_NE(static_cast<net::X509Certificate*>(NULL), webkit_cert.get());
129 std::vector<std::string> dns_names_webkit; 129 std::vector<std::string> dns_names_webkit;
130 dns_names_webkit.push_back("webkit"); 130 dns_names_webkit.push_back("webkit");
131 dns_names_webkit.push_back("org"); 131 dns_names_webkit.push_back("org");
132 std::vector<std::vector<std::string>> dns_name_tokens_webkit; 132 std::vector<std::vector<std::string>> dns_name_tokens_webkit;
133 dns_name_tokens_webkit.push_back(dns_names_webkit); 133 dns_name_tokens_webkit.push_back(dns_names_webkit);
134 { 134 {
135 GURL origin("https://a.b.webkit.org"); 135 GURL origin("https://a.b.webkit.org");
136 std::string host_name = origin.host(); 136 std::string host_name = origin.host();
137 std::vector<std::string> host_name_tokens; 137 std::vector<std::string> host_name_tokens;
138 base::SplitStringDontTrim(host_name, '.', &host_name_tokens); 138 base::SplitStringDontTrim(host_name, '.', &host_name_tokens);
139 SSLErrorClassification ssl_error(time, origin, *webkit_cert); 139 SSLErrorClassification ssl_error(time, origin, *webkit_cert);
140 EXPECT_FALSE(ssl_error.IsWWWSubDomainMatch()); 140 EXPECT_FALSE(ssl_error.IsWWWSubDomainMatch());
141 EXPECT_FALSE(ssl_error.NameUnderAnyNames(host_name_tokens, 141 EXPECT_FALSE(ssl_error.NameUnderAnyNames(host_name_tokens,
142 dns_name_tokens_webkit)); 142 dns_name_tokens_webkit));
143 EXPECT_FALSE(ssl_error.AnyNamesUnderName(dns_name_tokens_webkit, 143 EXPECT_FALSE(ssl_error.AnyNamesUnderName(dns_name_tokens_webkit,
144 host_name_tokens)); 144 host_name_tokens));
145 EXPECT_TRUE(ssl_error.IsSubDomainOutsideWildcard(host_name_tokens)); 145 EXPECT_TRUE(ssl_error.IsSubDomainOutsideWildcard(host_name_tokens));
146 EXPECT_FALSE(ssl_error.IsCertLikelyFromMultiTenantHosting()); 146 EXPECT_FALSE(ssl_error.IsCertLikelyFromMultiTenantHosting());
147 } 147 }
148 } 148 }
149 149
150 TEST(SSLErrorClassificationTest, TestHostNameHasKnownTLD) { 150 TEST(SSLErrorClassificationTest, TestHostNameHasKnownTLD) {
151 std::string url1 = "www.google.com"; 151 std::string url1 = "www.google.com";
152 std::string url2 = "b.appspot.com"; 152 std::string url2 = "b.appspot.com";
153 std::string url3 = "a.private"; 153 std::string url3 = "a.private";
154 EXPECT_TRUE(SSLErrorClassification::IsHostNameKnownTLD(url1)); 154 EXPECT_TRUE(SSLErrorClassification::IsHostNameKnownTLD(url1));
155 EXPECT_TRUE(SSLErrorClassification::IsHostNameKnownTLD(url2)); 155 EXPECT_TRUE(SSLErrorClassification::IsHostNameKnownTLD(url2));
156 EXPECT_FALSE(SSLErrorClassification::IsHostNameKnownTLD(url3)); 156 EXPECT_FALSE(SSLErrorClassification::IsHostNameKnownTLD(url3));
157 } 157 }
OLDNEW
« no previous file with comments | « chrome/browser/signin/easy_unlock_service.cc ('k') | chrome/browser/supervised_user/supervised_user_settings_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698