| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/http/transport_security_state.h" | 5 #include "net/http/transport_security_state.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 1016 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1027 EXPECT_TRUE(StaticShouldRedirect("www.sandbox.mydigipass.com")); | 1027 EXPECT_TRUE(StaticShouldRedirect("www.sandbox.mydigipass.com")); |
| 1028 EXPECT_FALSE(StaticShouldRedirect("foo.www.sandbox.mydigipass.com")); | 1028 EXPECT_FALSE(StaticShouldRedirect("foo.www.sandbox.mydigipass.com")); |
| 1029 | 1029 |
| 1030 EXPECT_TRUE(StaticShouldRedirect("bigshinylock.minazo.net")); | 1030 EXPECT_TRUE(StaticShouldRedirect("bigshinylock.minazo.net")); |
| 1031 EXPECT_TRUE(StaticShouldRedirect("foo.bigshinylock.minazo.net")); | 1031 EXPECT_TRUE(StaticShouldRedirect("foo.bigshinylock.minazo.net")); |
| 1032 | 1032 |
| 1033 EXPECT_TRUE(StaticShouldRedirect("crate.io")); | 1033 EXPECT_TRUE(StaticShouldRedirect("crate.io")); |
| 1034 EXPECT_TRUE(StaticShouldRedirect("foo.crate.io")); | 1034 EXPECT_TRUE(StaticShouldRedirect("foo.crate.io")); |
| 1035 } | 1035 } |
| 1036 | 1036 |
| 1037 TEST_F(TransportSecurityStateTest, PreloadedPins) { | 1037 // http://crbug.com/624946 |
| 1038 #if defined(OS_IOS) |
| 1039 #define MAYBE_PreloadedPins DISABLED_PreloadedPins |
| 1040 #else |
| 1041 #define MAYBE_PreloadedPins PreloadedPins |
| 1042 #endif |
| 1043 TEST_F(TransportSecurityStateTest, MAYBE_PreloadedPins) { |
| 1038 TransportSecurityState state; | 1044 TransportSecurityState state; |
| 1039 EnableStaticPins(&state); | 1045 EnableStaticPins(&state); |
| 1040 TransportSecurityState::STSState sts_state; | 1046 TransportSecurityState::STSState sts_state; |
| 1041 TransportSecurityState::PKPState pkp_state; | 1047 TransportSecurityState::PKPState pkp_state; |
| 1042 | 1048 |
| 1043 // We do more extensive checks for the first domain. | 1049 // We do more extensive checks for the first domain. |
| 1044 EXPECT_TRUE( | 1050 EXPECT_TRUE( |
| 1045 state.GetStaticDomainState("www.paypal.com", &sts_state, &pkp_state)); | 1051 state.GetStaticDomainState("www.paypal.com", &sts_state, &pkp_state)); |
| 1046 EXPECT_EQ(sts_state.upgrade_mode, | 1052 EXPECT_EQ(sts_state.upgrade_mode, |
| 1047 TransportSecurityState::STSState::MODE_FORCE_HTTPS); | 1053 TransportSecurityState::STSState::MODE_FORCE_HTTPS); |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1202 TransportSecurityState::PKPState pkp_state; | 1208 TransportSecurityState::PKPState pkp_state; |
| 1203 EXPECT_TRUE(state.GetStaticDomainState("blog.torproject.org", &sts_state, | 1209 EXPECT_TRUE(state.GetStaticDomainState("blog.torproject.org", &sts_state, |
| 1204 &pkp_state)); | 1210 &pkp_state)); |
| 1205 EXPECT_TRUE(pkp_state.HasPublicKeyPins()); | 1211 EXPECT_TRUE(pkp_state.HasPublicKeyPins()); |
| 1206 | 1212 |
| 1207 std::string failure_log; | 1213 std::string failure_log; |
| 1208 EXPECT_TRUE(pkp_state.CheckPublicKeyPins(good_hashes, &failure_log)); | 1214 EXPECT_TRUE(pkp_state.CheckPublicKeyPins(good_hashes, &failure_log)); |
| 1209 EXPECT_FALSE(pkp_state.CheckPublicKeyPins(bad_hashes, &failure_log)); | 1215 EXPECT_FALSE(pkp_state.CheckPublicKeyPins(bad_hashes, &failure_log)); |
| 1210 } | 1216 } |
| 1211 | 1217 |
| 1212 TEST_F(TransportSecurityStateTest, OptionalHSTSCertPins) { | 1218 // http://crbug.com/624946 |
| 1219 #if defined(OS_IOS) |
| 1220 #define MAYBE_OptionalHSTSCertPins DISABLED_OptionalHSTSCertPins |
| 1221 #else |
| 1222 #define MAYBE_OptionalHSTSCertPins OptionalHSTSCertPins |
| 1223 #endif |
| 1224 TEST_F(TransportSecurityStateTest, MAYBE_OptionalHSTSCertPins) { |
| 1213 TransportSecurityState state; | 1225 TransportSecurityState state; |
| 1214 EnableStaticPins(&state); | 1226 EnableStaticPins(&state); |
| 1215 | 1227 |
| 1216 EXPECT_TRUE(HasStaticPublicKeyPins("google.com")); | 1228 EXPECT_TRUE(HasStaticPublicKeyPins("google.com")); |
| 1217 EXPECT_TRUE(HasStaticPublicKeyPins("www.google.com")); | 1229 EXPECT_TRUE(HasStaticPublicKeyPins("www.google.com")); |
| 1218 EXPECT_TRUE(HasStaticPublicKeyPins("mail-attachment.googleusercontent.com")); | 1230 EXPECT_TRUE(HasStaticPublicKeyPins("mail-attachment.googleusercontent.com")); |
| 1219 EXPECT_TRUE(HasStaticPublicKeyPins("www.youtube.com")); | 1231 EXPECT_TRUE(HasStaticPublicKeyPins("www.youtube.com")); |
| 1220 EXPECT_TRUE(HasStaticPublicKeyPins("i.ytimg.com")); | 1232 EXPECT_TRUE(HasStaticPublicKeyPins("i.ytimg.com")); |
| 1221 EXPECT_TRUE(HasStaticPublicKeyPins("googleapis.com")); | 1233 EXPECT_TRUE(HasStaticPublicKeyPins("googleapis.com")); |
| 1222 EXPECT_TRUE(HasStaticPublicKeyPins("ajax.googleapis.com")); | 1234 EXPECT_TRUE(HasStaticPublicKeyPins("ajax.googleapis.com")); |
| (...skipping 794 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2017 base::FieldTrialList::CreateFieldTrial("EnforceCTForProblematicRoots", | 2029 base::FieldTrialList::CreateFieldTrial("EnforceCTForProblematicRoots", |
| 2018 "disabled"); | 2030 "disabled"); |
| 2019 | 2031 |
| 2020 EXPECT_FALSE( | 2032 EXPECT_FALSE( |
| 2021 state.ShouldRequireCT("www.example.com", before_cert.get(), hashes)); | 2033 state.ShouldRequireCT("www.example.com", before_cert.get(), hashes)); |
| 2022 EXPECT_FALSE( | 2034 EXPECT_FALSE( |
| 2023 state.ShouldRequireCT("www.example.com", after_cert.get(), hashes)); | 2035 state.ShouldRequireCT("www.example.com", after_cert.get(), hashes)); |
| 2024 } | 2036 } |
| 2025 | 2037 |
| 2026 } // namespace net | 2038 } // namespace net |
| OLD | NEW |