| OLD | NEW |
| 1 // Copyright (c) 2010 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: |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 state.HostRanInsecureContent("example.com", 42); | 107 state.HostRanInsecureContent("example.com", 42); |
| 108 | 108 |
| 109 EXPECT_TRUE(state.DidHostRunInsecureContent("www.google.com", 42)); | 109 EXPECT_TRUE(state.DidHostRunInsecureContent("www.google.com", 42)); |
| 110 EXPECT_FALSE(state.DidHostRunInsecureContent("www.google.com", 191)); | 110 EXPECT_FALSE(state.DidHostRunInsecureContent("www.google.com", 191)); |
| 111 EXPECT_TRUE(state.DidHostRunInsecureContent("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 X509Certificate::FORMAT_DER); |
| 118 | 119 |
| 119 SSLHostState state; | 120 SSLHostState state; |
| 120 | 121 |
| 121 EXPECT_EQ(state.QueryPolicy(google_cert.get(), "www.google.com"), | 122 EXPECT_EQ(state.QueryPolicy(google_cert.get(), "www.google.com"), |
| 122 net::X509Certificate::Policy::UNKNOWN); | 123 net::X509Certificate::Policy::UNKNOWN); |
| 123 EXPECT_EQ(state.QueryPolicy(google_cert.get(), "google.com"), | 124 EXPECT_EQ(state.QueryPolicy(google_cert.get(), "google.com"), |
| 124 net::X509Certificate::Policy::UNKNOWN); | 125 net::X509Certificate::Policy::UNKNOWN); |
| 125 EXPECT_EQ(state.QueryPolicy(google_cert.get(), "example.com"), | 126 EXPECT_EQ(state.QueryPolicy(google_cert.get(), "example.com"), |
| 126 net::X509Certificate::Policy::UNKNOWN); | 127 net::X509Certificate::Policy::UNKNOWN); |
| 127 | 128 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 145 | 146 |
| 146 state.DenyCertForHost(google_cert.get(), "example.com"); | 147 state.DenyCertForHost(google_cert.get(), "example.com"); |
| 147 | 148 |
| 148 EXPECT_EQ(state.QueryPolicy(google_cert.get(), "www.google.com"), | 149 EXPECT_EQ(state.QueryPolicy(google_cert.get(), "www.google.com"), |
| 149 net::X509Certificate::Policy::ALLOWED); | 150 net::X509Certificate::Policy::ALLOWED); |
| 150 EXPECT_EQ(state.QueryPolicy(google_cert.get(), "google.com"), | 151 EXPECT_EQ(state.QueryPolicy(google_cert.get(), "google.com"), |
| 151 net::X509Certificate::Policy::UNKNOWN); | 152 net::X509Certificate::Policy::UNKNOWN); |
| 152 EXPECT_EQ(state.QueryPolicy(google_cert.get(), "example.com"), | 153 EXPECT_EQ(state.QueryPolicy(google_cert.get(), "example.com"), |
| 153 net::X509Certificate::Policy::DENIED); | 154 net::X509Certificate::Policy::DENIED); |
| 154 } | 155 } |
| OLD | NEW |