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

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

Issue 2126005: Revert 47357 - Revert 47347 (Original patch reviewed at http://codereview.ch... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 10 years, 7 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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_host_state.h" 5 #include "chrome/browser/ssl/ssl_host_state.h"
6 #include "testing/gtest/include/gtest/gtest.h" 6 #include "testing/gtest/include/gtest/gtest.h"
7 7
8 namespace { 8 namespace {
9 9
10 // Certificates for test data. They're obtained with: 10 // Certificates for test data. They're obtained with:
11 // 11 //
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 0x04, 0xfe, 0xd5, 0xe9, 0xb9, 0xb0, 0x9e, 0xfe, 0xa5, 0x11, 0x69, 0xc9, 84 0x04, 0xfe, 0xd5, 0xe9, 0xb9, 0xb0, 0x9e, 0xfe, 0xa5, 0x11, 0x69, 0xc9,
85 0x63, 0xd6, 0x46, 0x81, 0x6f, 0x00, 0xd8, 0x72, 0x2f, 0x82, 0x37, 0x44, 85 0x63, 0xd6, 0x46, 0x81, 0x6f, 0x00, 0xd8, 0x72, 0x2f, 0x82, 0x37, 0x44,
86 0xc1 86 0xc1
87 }; 87 };
88 88
89 } // namespace 89 } // namespace
90 90
91 class SSLHostStateTest : public testing::Test { 91 class SSLHostStateTest : public testing::Test {
92 }; 92 };
93 93
94 TEST_F(SSLHostStateTest, MarkHostAsBroken) { 94 TEST_F(SSLHostStateTest, DidHostRunInsecureContent) {
95 SSLHostState state; 95 SSLHostState state;
96 96
97 EXPECT_FALSE(state.DidMarkHostAsBroken("www.google.com", 42)); 97 EXPECT_FALSE(state.DidHostRunInsecureContent("www.google.com", 42));
98 EXPECT_FALSE(state.DidMarkHostAsBroken("www.google.com", 191)); 98 EXPECT_FALSE(state.DidHostRunInsecureContent("www.google.com", 191));
99 EXPECT_FALSE(state.DidMarkHostAsBroken("example.com", 42)); 99 EXPECT_FALSE(state.DidHostRunInsecureContent("example.com", 42));
100 100
101 state.MarkHostAsBroken("www.google.com", 42); 101 state.HostRanInsecureContent("www.google.com", 42);
102 102
103 EXPECT_TRUE(state.DidMarkHostAsBroken("www.google.com", 42)); 103 EXPECT_TRUE(state.DidHostRunInsecureContent("www.google.com", 42));
104 EXPECT_FALSE(state.DidMarkHostAsBroken("www.google.com", 191)); 104 EXPECT_FALSE(state.DidHostRunInsecureContent("www.google.com", 191));
105 EXPECT_FALSE(state.DidMarkHostAsBroken("example.com", 42)); 105 EXPECT_FALSE(state.DidHostRunInsecureContent("example.com", 42));
106 106
107 state.MarkHostAsBroken("example.com", 42); 107 state.HostRanInsecureContent("example.com", 42);
108 108
109 EXPECT_TRUE(state.DidMarkHostAsBroken("www.google.com", 42)); 109 EXPECT_TRUE(state.DidHostRunInsecureContent("www.google.com", 42));
110 EXPECT_FALSE(state.DidMarkHostAsBroken("www.google.com", 191)); 110 EXPECT_FALSE(state.DidHostRunInsecureContent("www.google.com", 191));
111 EXPECT_TRUE(state.DidMarkHostAsBroken("example.com", 42)); 111 EXPECT_TRUE(state.DidHostRunInsecureContent("example.com", 42));
112 } 112 }
113 113
114 TEST_F(SSLHostStateTest, QueryPolicy) { 114 TEST_F(SSLHostStateTest, QueryPolicy) {
115 scoped_refptr<net::X509Certificate> google_cert = 115 scoped_refptr<net::X509Certificate> google_cert =
116 net::X509Certificate::CreateFromBytes( 116 net::X509Certificate::CreateFromBytes(
117 reinterpret_cast<const char*>(google_der), sizeof(google_der)); 117 reinterpret_cast<const char*>(google_der), sizeof(google_der));
118 118
119 SSLHostState state; 119 SSLHostState state;
120 120
121 EXPECT_EQ(state.QueryPolicy(google_cert.get(), "www.google.com"), 121 EXPECT_EQ(state.QueryPolicy(google_cert.get(), "www.google.com"),
(...skipping 23 matching lines...) Expand all
145 145
146 state.DenyCertForHost(google_cert.get(), "example.com"); 146 state.DenyCertForHost(google_cert.get(), "example.com");
147 147
148 EXPECT_EQ(state.QueryPolicy(google_cert.get(), "www.google.com"), 148 EXPECT_EQ(state.QueryPolicy(google_cert.get(), "www.google.com"),
149 net::X509Certificate::Policy::ALLOWED); 149 net::X509Certificate::Policy::ALLOWED);
150 EXPECT_EQ(state.QueryPolicy(google_cert.get(), "google.com"), 150 EXPECT_EQ(state.QueryPolicy(google_cert.get(), "google.com"),
151 net::X509Certificate::Policy::UNKNOWN); 151 net::X509Certificate::Policy::UNKNOWN);
152 EXPECT_EQ(state.QueryPolicy(google_cert.get(), "example.com"), 152 EXPECT_EQ(state.QueryPolicy(google_cert.get(), "example.com"),
153 net::X509Certificate::Policy::DENIED); 153 net::X509Certificate::Policy::DENIED);
154 } 154 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698