| 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/ssl/ssl_config_service.h" | 5 #include "net/ssl/ssl_config_service.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "testing/gmock/include/gmock/gmock.h" | 9 #include "testing/gmock/include/gmock/gmock.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 mock_service->SetSSLConfig(initial_config); | 60 mock_service->SetSSLConfig(initial_config); |
| 61 | 61 |
| 62 mock_service->RemoveObserver(&observer); | 62 mock_service->RemoveObserver(&observer); |
| 63 } | 63 } |
| 64 | 64 |
| 65 TEST(SSLConfigServiceTest, ConfigUpdatesNotifyObservers) { | 65 TEST(SSLConfigServiceTest, ConfigUpdatesNotifyObservers) { |
| 66 SSLConfig initial_config; | 66 SSLConfig initial_config; |
| 67 initial_config.rev_checking_enabled = true; | 67 initial_config.rev_checking_enabled = true; |
| 68 initial_config.rev_checking_required_local_anchors = false; | 68 initial_config.rev_checking_required_local_anchors = false; |
| 69 initial_config.sha1_local_anchors_enabled = true; | 69 initial_config.sha1_local_anchors_enabled = true; |
| 70 initial_config.common_name_fallback_local_anchors_enabled = true; |
| 70 initial_config.false_start_enabled = false; | 71 initial_config.false_start_enabled = false; |
| 71 initial_config.require_ecdhe = false; | 72 initial_config.require_ecdhe = false; |
| 72 initial_config.version_min = SSL_PROTOCOL_VERSION_TLS1; | 73 initial_config.version_min = SSL_PROTOCOL_VERSION_TLS1; |
| 73 initial_config.version_max = SSL_PROTOCOL_VERSION_TLS1_2; | 74 initial_config.version_max = SSL_PROTOCOL_VERSION_TLS1_2; |
| 74 | 75 |
| 75 scoped_refptr<MockSSLConfigService> mock_service( | 76 scoped_refptr<MockSSLConfigService> mock_service( |
| 76 new MockSSLConfigService(initial_config)); | 77 new MockSSLConfigService(initial_config)); |
| 77 MockSSLConfigServiceObserver observer; | 78 MockSSLConfigServiceObserver observer; |
| 78 mock_service->AddObserver(&observer); | 79 mock_service->AddObserver(&observer); |
| 79 | 80 |
| 80 // Test that the basic boolean preferences trigger updates. | 81 // Test that the basic boolean preferences trigger updates. |
| 81 initial_config.rev_checking_enabled = false; | 82 initial_config.rev_checking_enabled = false; |
| 82 EXPECT_CALL(observer, OnSSLConfigChanged()).Times(1); | 83 EXPECT_CALL(observer, OnSSLConfigChanged()).Times(1); |
| 83 mock_service->SetSSLConfig(initial_config); | 84 mock_service->SetSSLConfig(initial_config); |
| 84 | 85 |
| 85 initial_config.rev_checking_required_local_anchors = true; | 86 initial_config.rev_checking_required_local_anchors = true; |
| 86 EXPECT_CALL(observer, OnSSLConfigChanged()).Times(1); | 87 EXPECT_CALL(observer, OnSSLConfigChanged()).Times(1); |
| 87 mock_service->SetSSLConfig(initial_config); | 88 mock_service->SetSSLConfig(initial_config); |
| 88 | 89 |
| 89 initial_config.sha1_local_anchors_enabled = false; | 90 initial_config.sha1_local_anchors_enabled = false; |
| 90 EXPECT_CALL(observer, OnSSLConfigChanged()).Times(1); | 91 EXPECT_CALL(observer, OnSSLConfigChanged()).Times(1); |
| 91 mock_service->SetSSLConfig(initial_config); | 92 mock_service->SetSSLConfig(initial_config); |
| 92 | 93 |
| 94 initial_config.common_name_fallback_local_anchors_enabled = false; |
| 95 EXPECT_CALL(observer, OnSSLConfigChanged()).Times(1); |
| 96 mock_service->SetSSLConfig(initial_config); |
| 97 |
| 93 initial_config.false_start_enabled = true; | 98 initial_config.false_start_enabled = true; |
| 94 EXPECT_CALL(observer, OnSSLConfigChanged()).Times(1); | 99 EXPECT_CALL(observer, OnSSLConfigChanged()).Times(1); |
| 95 mock_service->SetSSLConfig(initial_config); | 100 mock_service->SetSSLConfig(initial_config); |
| 96 | 101 |
| 97 initial_config.require_ecdhe = true; | 102 initial_config.require_ecdhe = true; |
| 98 EXPECT_CALL(observer, OnSSLConfigChanged()).Times(1); | 103 EXPECT_CALL(observer, OnSSLConfigChanged()).Times(1); |
| 99 mock_service->SetSSLConfig(initial_config); | 104 mock_service->SetSSLConfig(initial_config); |
| 100 | 105 |
| 101 // Test that changing the SSL version range triggers updates. | 106 // Test that changing the SSL version range triggers updates. |
| 102 initial_config.version_min = SSL_PROTOCOL_VERSION_TLS1_1; | 107 initial_config.version_min = SSL_PROTOCOL_VERSION_TLS1_1; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 127 // cipher suites disabled, triggers an update. | 132 // cipher suites disabled, triggers an update. |
| 128 disabled_ciphers.pop_back(); | 133 disabled_ciphers.pop_back(); |
| 129 initial_config.disabled_cipher_suites = disabled_ciphers; | 134 initial_config.disabled_cipher_suites = disabled_ciphers; |
| 130 EXPECT_CALL(observer, OnSSLConfigChanged()).Times(1); | 135 EXPECT_CALL(observer, OnSSLConfigChanged()).Times(1); |
| 131 mock_service->SetSSLConfig(initial_config); | 136 mock_service->SetSSLConfig(initial_config); |
| 132 | 137 |
| 133 mock_service->RemoveObserver(&observer); | 138 mock_service->RemoveObserver(&observer); |
| 134 } | 139 } |
| 135 | 140 |
| 136 } // namespace net | 141 } // namespace net |
| OLD | NEW |