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 "base/basictypes.h" | |
10 #include "testing/gmock/include/gmock/gmock.h" | 9 #include "testing/gmock/include/gmock/gmock.h" |
11 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
12 | 11 |
13 namespace net { | 12 namespace net { |
14 | 13 |
15 namespace { | 14 namespace { |
16 | 15 |
17 class MockSSLConfigService : public SSLConfigService { | 16 class MockSSLConfigService : public SSLConfigService { |
18 public: | 17 public: |
19 explicit MockSSLConfigService(const SSLConfig& config) : config_(config) {} | 18 explicit MockSSLConfigService(const SSLConfig& config) : config_(config) {} |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 // Test that changing the SSL version range triggers updates. | 86 // Test that changing the SSL version range triggers updates. |
88 initial_config.version_min = SSL_PROTOCOL_VERSION_TLS1_1; | 87 initial_config.version_min = SSL_PROTOCOL_VERSION_TLS1_1; |
89 EXPECT_CALL(observer, OnSSLConfigChanged()).Times(1); | 88 EXPECT_CALL(observer, OnSSLConfigChanged()).Times(1); |
90 mock_service->SetSSLConfig(initial_config); | 89 mock_service->SetSSLConfig(initial_config); |
91 | 90 |
92 initial_config.version_max = SSL_PROTOCOL_VERSION_TLS1_1; | 91 initial_config.version_max = SSL_PROTOCOL_VERSION_TLS1_1; |
93 EXPECT_CALL(observer, OnSSLConfigChanged()).Times(1); | 92 EXPECT_CALL(observer, OnSSLConfigChanged()).Times(1); |
94 mock_service->SetSSLConfig(initial_config); | 93 mock_service->SetSSLConfig(initial_config); |
95 | 94 |
96 // Test that disabling certain cipher suites triggers an update. | 95 // Test that disabling certain cipher suites triggers an update. |
97 std::vector<uint16> disabled_ciphers; | 96 std::vector<uint16_t> disabled_ciphers; |
98 disabled_ciphers.push_back(0x0004u); | 97 disabled_ciphers.push_back(0x0004u); |
99 disabled_ciphers.push_back(0xBEEFu); | 98 disabled_ciphers.push_back(0xBEEFu); |
100 disabled_ciphers.push_back(0xDEADu); | 99 disabled_ciphers.push_back(0xDEADu); |
101 initial_config.disabled_cipher_suites = disabled_ciphers; | 100 initial_config.disabled_cipher_suites = disabled_ciphers; |
102 EXPECT_CALL(observer, OnSSLConfigChanged()).Times(1); | 101 EXPECT_CALL(observer, OnSSLConfigChanged()).Times(1); |
103 mock_service->SetSSLConfig(initial_config); | 102 mock_service->SetSSLConfig(initial_config); |
104 | 103 |
105 // Ensure that changing a disabled cipher suite, while still maintaining | 104 // Ensure that changing a disabled cipher suite, while still maintaining |
106 // sorted order, triggers an update. | 105 // sorted order, triggers an update. |
107 disabled_ciphers[1] = 0xCAFEu; | 106 disabled_ciphers[1] = 0xCAFEu; |
108 initial_config.disabled_cipher_suites = disabled_ciphers; | 107 initial_config.disabled_cipher_suites = disabled_ciphers; |
109 EXPECT_CALL(observer, OnSSLConfigChanged()).Times(1); | 108 EXPECT_CALL(observer, OnSSLConfigChanged()).Times(1); |
110 mock_service->SetSSLConfig(initial_config); | 109 mock_service->SetSSLConfig(initial_config); |
111 | 110 |
112 // Ensure that removing a disabled cipher suite, while still keeping some | 111 // Ensure that removing a disabled cipher suite, while still keeping some |
113 // cipher suites disabled, triggers an update. | 112 // cipher suites disabled, triggers an update. |
114 disabled_ciphers.pop_back(); | 113 disabled_ciphers.pop_back(); |
115 initial_config.disabled_cipher_suites = disabled_ciphers; | 114 initial_config.disabled_cipher_suites = disabled_ciphers; |
116 EXPECT_CALL(observer, OnSSLConfigChanged()).Times(1); | 115 EXPECT_CALL(observer, OnSSLConfigChanged()).Times(1); |
117 mock_service->SetSSLConfig(initial_config); | 116 mock_service->SetSSLConfig(initial_config); |
118 | 117 |
119 mock_service->RemoveObserver(&observer); | 118 mock_service->RemoveObserver(&observer); |
120 } | 119 } |
121 | 120 |
122 } // namespace net | 121 } // namespace net |
OLD | NEW |