summaryrefslogtreecommitdiffstats
path: root/net/base/ssl_config_service_mac_unittest.cc
diff options
context:
space:
mode:
authorhawk@chromium.org <hawk@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-09 22:07:32 +0000
committerhawk@chromium.org <hawk@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-09 22:07:32 +0000
commitf37c98ff15a2c2de0b86646be4ff7c5e2f59b703 (patch)
tree07f3dab046d81479ad73a521216ded00b32fb051 /net/base/ssl_config_service_mac_unittest.cc
parentf7238c977a13f719f2d540a2927a51f6c1e70e74 (diff)
downloadchromium_src-f37c98ff15a2c2de0b86646be4ff7c5e2f59b703.zip
chromium_src-f37c98ff15a2c2de0b86646be4ff7c5e2f59b703.tar.gz
chromium_src-f37c98ff15a2c2de0b86646be4ff7c5e2f59b703.tar.bz2
Add an SSLConfigService implementation for Mac OS X
BUG=19293 TEST=https://test-ssev.verisign.com/ has three links: one should work OK, the other should warn that the certificate is expired, the other that the certificate is revoked. Review URL: http://codereview.chromium.org/193009 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@25798 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/base/ssl_config_service_mac_unittest.cc')
-rw-r--r--net/base/ssl_config_service_mac_unittest.cc115
1 files changed, 115 insertions, 0 deletions
diff --git a/net/base/ssl_config_service_mac_unittest.cc b/net/base/ssl_config_service_mac_unittest.cc
new file mode 100644
index 0000000..d16129b
--- /dev/null
+++ b/net/base/ssl_config_service_mac_unittest.cc
@@ -0,0 +1,115 @@
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "net/base/ssl_config_service_mac.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+using base::TimeDelta;
+using base::TimeTicks;
+
+namespace {
+
+class SSLConfigServiceMacTest : public testing::Test {
+};
+
+} // namespace
+
+TEST(SSLConfigServiceMacTest, GetNowTest) {
+ // Verify that the constructor sets the correct default values.
+ net::SSLConfig config;
+ EXPECT_EQ(true, config.rev_checking_enabled);
+ EXPECT_EQ(false, config.ssl2_enabled);
+ EXPECT_EQ(true, config.ssl3_enabled);
+ EXPECT_EQ(true, config.tls1_enabled);
+
+ bool rv = net::SSLConfigServiceMac::GetSSLConfigNow(&config);
+ EXPECT_TRUE(rv);
+}
+
+TEST(SSLConfigServiceMacTest, SetTest) {
+ // Save the current settings so we can restore them after the tests.
+ net::SSLConfig config_save;
+ bool rv = net::SSLConfigServiceMac::GetSSLConfigNow(&config_save);
+ EXPECT_TRUE(rv);
+
+ net::SSLConfig config;
+
+ // Test SetRevCheckingEnabled.
+ net::SSLConfigServiceMac::SetRevCheckingEnabled(true);
+ rv = net::SSLConfigServiceMac::GetSSLConfigNow(&config);
+ EXPECT_TRUE(rv);
+ EXPECT_TRUE(config.rev_checking_enabled);
+
+ net::SSLConfigServiceMac::SetRevCheckingEnabled(false);
+ rv = net::SSLConfigServiceMac::GetSSLConfigNow(&config);
+ EXPECT_TRUE(rv);
+ EXPECT_FALSE(config.rev_checking_enabled);
+
+ net::SSLConfigServiceMac::SetRevCheckingEnabled(
+ config_save.rev_checking_enabled);
+
+ // Test SetSSL2Enabled.
+ net::SSLConfigServiceMac::SetSSL2Enabled(true);
+ rv = net::SSLConfigServiceMac::GetSSLConfigNow(&config);
+ EXPECT_TRUE(rv);
+ EXPECT_TRUE(config.ssl2_enabled);
+
+ net::SSLConfigServiceMac::SetSSL2Enabled(false);
+ rv = net::SSLConfigServiceMac::GetSSLConfigNow(&config);
+ EXPECT_TRUE(rv);
+ EXPECT_FALSE(config.ssl2_enabled);
+
+ net::SSLConfigServiceMac::SetSSL2Enabled(config_save.ssl2_enabled);
+
+ // Test SetSSL3Enabled.
+ net::SSLConfigServiceMac::SetSSL3Enabled(true);
+ rv = net::SSLConfigServiceMac::GetSSLConfigNow(&config);
+ EXPECT_TRUE(rv);
+ EXPECT_TRUE(config.ssl3_enabled);
+
+ net::SSLConfigServiceMac::SetSSL3Enabled(false);
+ rv = net::SSLConfigServiceMac::GetSSLConfigNow(&config);
+ EXPECT_TRUE(rv);
+ EXPECT_FALSE(config.ssl3_enabled);
+
+ net::SSLConfigServiceMac::SetSSL3Enabled(config_save.ssl3_enabled);
+
+ // Test SetTLS1Enabled.
+ net::SSLConfigServiceMac::SetTLS1Enabled(true);
+ rv = net::SSLConfigServiceMac::GetSSLConfigNow(&config);
+ EXPECT_TRUE(rv);
+ EXPECT_TRUE(config.tls1_enabled);
+
+ net::SSLConfigServiceMac::SetTLS1Enabled(false);
+ rv = net::SSLConfigServiceMac::GetSSLConfigNow(&config);
+ EXPECT_TRUE(rv);
+ EXPECT_FALSE(config.tls1_enabled);
+
+ net::SSLConfigServiceMac::SetTLS1Enabled(config_save.tls1_enabled);
+}
+
+TEST(SSLConfigServiceMacTest, GetTest) {
+ TimeTicks now = TimeTicks::Now();
+ TimeTicks now_1 = now + TimeDelta::FromSeconds(1);
+ TimeTicks now_11 = now + TimeDelta::FromSeconds(11);
+
+ net::SSLConfig config, config_1, config_11;
+ scoped_refptr<net::SSLConfigServiceMac> config_service(
+ new net::SSLConfigServiceMac(now));
+ config_service->GetSSLConfigAt(&config, now);
+
+ // Flip rev_checking_enabled.
+ net::SSLConfigServiceMac::SetRevCheckingEnabled(
+ !config.rev_checking_enabled);
+
+ config_service->GetSSLConfigAt(&config_1, now_1);
+ EXPECT_EQ(config.rev_checking_enabled, config_1.rev_checking_enabled);
+
+ config_service->GetSSLConfigAt(&config_11, now_11);
+ EXPECT_EQ(!config.rev_checking_enabled, config_11.rev_checking_enabled);
+
+ // Restore the original value.
+ net::SSLConfigServiceMac::SetRevCheckingEnabled(
+ config.rev_checking_enabled);
+}