| OLD | NEW |
| 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 "net/base/ssl_config_service_mac.h" | 5 #include "net/base/ssl_config_service_mac.h" |
| 6 #include "testing/gtest/include/gtest/gtest.h" | 6 #include "testing/gtest/include/gtest/gtest.h" |
| 7 | 7 |
| 8 using base::TimeDelta; | 8 using base::TimeDelta; |
| 9 using base::TimeTicks; | 9 using base::TimeTicks; |
| 10 | 10 |
| 11 namespace { | 11 namespace { |
| (...skipping 20 matching lines...) Expand all Loading... |
| 32 | 32 |
| 33 class SSLConfigServiceMacTest : public testing::Test { | 33 class SSLConfigServiceMacTest : public testing::Test { |
| 34 }; | 34 }; |
| 35 | 35 |
| 36 } // namespace | 36 } // namespace |
| 37 | 37 |
| 38 TEST(SSLConfigServiceMacTest, GetNowTest) { | 38 TEST(SSLConfigServiceMacTest, GetNowTest) { |
| 39 // Verify that the constructor sets the correct default values. | 39 // Verify that the constructor sets the correct default values. |
| 40 net::SSLConfig config; | 40 net::SSLConfig config; |
| 41 EXPECT_TRUE(config.rev_checking_enabled); | 41 EXPECT_TRUE(config.rev_checking_enabled); |
| 42 EXPECT_FALSE(config.ssl2_enabled); | |
| 43 EXPECT_TRUE(config.ssl3_enabled); | 42 EXPECT_TRUE(config.ssl3_enabled); |
| 44 EXPECT_TRUE(config.tls1_enabled); | 43 EXPECT_TRUE(config.tls1_enabled); |
| 45 | 44 |
| 46 bool rv = net::SSLConfigServiceMac::GetSSLConfigNow(&config); | 45 bool rv = net::SSLConfigServiceMac::GetSSLConfigNow(&config); |
| 47 EXPECT_TRUE(rv); | 46 EXPECT_TRUE(rv); |
| 48 } | 47 } |
| 49 | 48 |
| 50 TEST(SSLConfigServiceMacTest, SetTest) { | 49 TEST(SSLConfigServiceMacTest, SetTest) { |
| 51 // Save the current settings so we can restore them after the tests. | 50 // Save the current settings so we can restore them after the tests. |
| 52 net::SSLConfig config_save; | 51 net::SSLConfig config_save; |
| 53 bool rv = net::SSLConfigServiceMac::GetSSLConfigNow(&config_save); | 52 bool rv = net::SSLConfigServiceMac::GetSSLConfigNow(&config_save); |
| 54 EXPECT_TRUE(rv); | 53 EXPECT_TRUE(rv); |
| 55 | 54 |
| 56 net::SSLConfig config; | 55 net::SSLConfig config; |
| 57 | 56 |
| 58 // Test SetRevCheckingEnabled. | 57 // Test SetRevCheckingEnabled. |
| 59 net::SSLConfigServiceMac::SetRevCheckingEnabled(true); | 58 net::SSLConfigServiceMac::SetRevCheckingEnabled(true); |
| 60 rv = net::SSLConfigServiceMac::GetSSLConfigNow(&config); | 59 rv = net::SSLConfigServiceMac::GetSSLConfigNow(&config); |
| 61 EXPECT_TRUE(rv); | 60 EXPECT_TRUE(rv); |
| 62 EXPECT_TRUE(config.rev_checking_enabled); | 61 EXPECT_TRUE(config.rev_checking_enabled); |
| 63 | 62 |
| 64 net::SSLConfigServiceMac::SetRevCheckingEnabled(false); | 63 net::SSLConfigServiceMac::SetRevCheckingEnabled(false); |
| 65 rv = net::SSLConfigServiceMac::GetSSLConfigNow(&config); | 64 rv = net::SSLConfigServiceMac::GetSSLConfigNow(&config); |
| 66 EXPECT_TRUE(rv); | 65 EXPECT_TRUE(rv); |
| 67 EXPECT_FALSE(config.rev_checking_enabled); | 66 EXPECT_FALSE(config.rev_checking_enabled); |
| 68 | 67 |
| 69 net::SSLConfigServiceMac::SetRevCheckingEnabled( | 68 net::SSLConfigServiceMac::SetRevCheckingEnabled( |
| 70 config_save.rev_checking_enabled); | 69 config_save.rev_checking_enabled); |
| 71 | 70 |
| 72 // Test SetSSL2Enabled. | |
| 73 net::SSLConfigServiceMac::SetSSL2Enabled(true); | |
| 74 rv = net::SSLConfigServiceMac::GetSSLConfigNow(&config); | |
| 75 EXPECT_TRUE(rv); | |
| 76 EXPECT_TRUE(config.ssl2_enabled); | |
| 77 | |
| 78 net::SSLConfigServiceMac::SetSSL2Enabled(false); | |
| 79 rv = net::SSLConfigServiceMac::GetSSLConfigNow(&config); | |
| 80 EXPECT_TRUE(rv); | |
| 81 EXPECT_FALSE(config.ssl2_enabled); | |
| 82 | |
| 83 net::SSLConfigServiceMac::SetSSL2Enabled(config_save.ssl2_enabled); | |
| 84 | |
| 85 // Test SetSSL3Enabled. | 71 // Test SetSSL3Enabled. |
| 86 net::SSLConfigServiceMac::SetSSL3Enabled(true); | 72 net::SSLConfigServiceMac::SetSSL3Enabled(true); |
| 87 rv = net::SSLConfigServiceMac::GetSSLConfigNow(&config); | 73 rv = net::SSLConfigServiceMac::GetSSLConfigNow(&config); |
| 88 EXPECT_TRUE(rv); | 74 EXPECT_TRUE(rv); |
| 89 EXPECT_TRUE(config.ssl3_enabled); | 75 EXPECT_TRUE(config.ssl3_enabled); |
| 90 | 76 |
| 91 net::SSLConfigServiceMac::SetSSL3Enabled(false); | 77 net::SSLConfigServiceMac::SetSSL3Enabled(false); |
| 92 rv = net::SSLConfigServiceMac::GetSSLConfigNow(&config); | 78 rv = net::SSLConfigServiceMac::GetSSLConfigNow(&config); |
| 93 EXPECT_TRUE(rv); | 79 EXPECT_TRUE(rv); |
| 94 EXPECT_FALSE(config.ssl3_enabled); | 80 EXPECT_FALSE(config.ssl3_enabled); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 | 126 |
| 141 scoped_refptr<net::SSLConfigServiceMac> config_service( | 127 scoped_refptr<net::SSLConfigServiceMac> config_service( |
| 142 new net::SSLConfigServiceMac(now)); | 128 new net::SSLConfigServiceMac(now)); |
| 143 | 129 |
| 144 // Save the current settings so we can restore them after the tests. | 130 // Save the current settings so we can restore them after the tests. |
| 145 net::SSLConfig config_save; | 131 net::SSLConfig config_save; |
| 146 bool rv = net::SSLConfigServiceMac::GetSSLConfigNow(&config_save); | 132 bool rv = net::SSLConfigServiceMac::GetSSLConfigNow(&config_save); |
| 147 EXPECT_TRUE(rv); | 133 EXPECT_TRUE(rv); |
| 148 | 134 |
| 149 net::SSLConfig config; | 135 net::SSLConfig config; |
| 150 net::SSLConfigServiceMac::SetSSL2Enabled(false); | 136 net::SSLConfigServiceMac::SetSSL3Enabled(false); |
| 151 config_service->GetSSLConfigAt(&config, now); | 137 config_service->GetSSLConfigAt(&config, now); |
| 152 | 138 |
| 153 // Add an observer. | 139 // Add an observer. |
| 154 SSLConfigServiceMacObserver observer; | 140 SSLConfigServiceMacObserver observer; |
| 155 config_service->AddObserver(&observer); | 141 config_service->AddObserver(&observer); |
| 156 | 142 |
| 157 // Toggle SSL2. | 143 // Toggle SSL3. |
| 158 net::SSLConfigServiceMac::SetSSL2Enabled(!config_save.ssl2_enabled); | 144 net::SSLConfigServiceMac::SetSSL3Enabled(!config_save.ssl3_enabled); |
| 159 config_service->GetSSLConfigAt(&config, later); | 145 config_service->GetSSLConfigAt(&config, later); |
| 160 | 146 |
| 161 // Verify that the observer was notified. | 147 // Verify that the observer was notified. |
| 162 EXPECT_TRUE(observer.change_was_observed()); | 148 EXPECT_TRUE(observer.change_was_observed()); |
| 163 | 149 |
| 164 // Remove the observer. | 150 // Remove the observer. |
| 165 config_service->RemoveObserver(&observer); | 151 config_service->RemoveObserver(&observer); |
| 166 | 152 |
| 167 // Restore the original SSL2 setting. | 153 // Restore the original SSL3 setting. |
| 168 net::SSLConfigServiceMac::SetSSL2Enabled(config_save.ssl2_enabled); | 154 net::SSLConfigServiceMac::SetSSL3Enabled(config_save.ssl3_enabled); |
| 169 } | 155 } |
| 170 | 156 |
| OLD | NEW |