| 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 "chromeos/network/onc/onc_utils.h" | 5 #include "chromeos/network/onc/onc_utils.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/strings/string_number_conversions.h" |
| 9 #include "base/values.h" | 10 #include "base/values.h" |
| 11 #include "chromeos/network/network_ui_data.h" |
| 10 #include "chromeos/network/onc/onc_signature.h" | 12 #include "chromeos/network/onc/onc_signature.h" |
| 11 #include "chromeos/network/onc/onc_test_utils.h" | 13 #include "chromeos/network/onc/onc_test_utils.h" |
| 14 #include "google_apis/drive/test_util.h" |
| 12 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
| 13 | 16 |
| 14 namespace chromeos { | 17 namespace chromeos { |
| 15 namespace onc { | 18 namespace onc { |
| 16 | 19 |
| 17 TEST(ONCDecrypterTest, BrokenEncryptionIterations) { | 20 TEST(ONCDecrypterTest, BrokenEncryptionIterations) { |
| 18 scoped_ptr<base::DictionaryValue> encrypted_onc = | 21 scoped_ptr<base::DictionaryValue> encrypted_onc = |
| 19 test_utils::ReadTestDictionary("broken-encrypted-iterations.onc"); | 22 test_utils::ReadTestDictionary("broken-encrypted-iterations.onc"); |
| 20 | 23 |
| 21 scoped_ptr<base::DictionaryValue> decrypted_onc = | 24 scoped_ptr<base::DictionaryValue> decrypted_onc = |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 networks_with_cert_refs->DeepCopy()); | 132 networks_with_cert_refs->DeepCopy()); |
| 130 | 133 |
| 131 bool success = ResolveServerCertRefsInNetworks(certs, | 134 bool success = ResolveServerCertRefsInNetworks(certs, |
| 132 actual_resolved_onc.get()); | 135 actual_resolved_onc.get()); |
| 133 EXPECT_EQ(expected_success, success); | 136 EXPECT_EQ(expected_success, success); |
| 134 EXPECT_TRUE(test_utils::Equals(expected_resolved_onc, | 137 EXPECT_TRUE(test_utils::Equals(expected_resolved_onc, |
| 135 actual_resolved_onc.get())); | 138 actual_resolved_onc.get())); |
| 136 } | 139 } |
| 137 } | 140 } |
| 138 | 141 |
| 142 TEST(ONCUtils, ProxySettingsToProxyConfig) { |
| 143 scoped_ptr<base::Value> test_data = |
| 144 google_apis::test_util::LoadJSONFile("chromeos/net/proxy_config.json"); |
| 145 |
| 146 base::ListValue* list_of_tests; |
| 147 test_data->GetAsList(&list_of_tests); |
| 148 |
| 149 int index = 0; |
| 150 for (base::ListValue::iterator it = list_of_tests->begin(); |
| 151 it != list_of_tests->end(); ++it, ++index) { |
| 152 SCOPED_TRACE("Test case #" + base::IntToString(index)); |
| 153 |
| 154 base::DictionaryValue* test_case; |
| 155 (*it)->GetAsDictionary(&test_case); |
| 156 |
| 157 base::DictionaryValue* onc_proxy_settings; |
| 158 test_case->GetDictionary("ONC_ProxySettings", &onc_proxy_settings); |
| 159 |
| 160 base::DictionaryValue* expected_proxy_config; |
| 161 test_case->GetDictionary("ProxyConfig", &expected_proxy_config); |
| 162 |
| 163 scoped_ptr<base::DictionaryValue> actual_proxy_config = |
| 164 ConvertOncProxySettingsToProxyConfig(*onc_proxy_settings); |
| 165 EXPECT_TRUE( |
| 166 test_utils::Equals(expected_proxy_config, actual_proxy_config.get())); |
| 167 } |
| 168 } |
| 169 |
| 170 TEST(ONCUtils, ProxyConfigToOncProxySettings) { |
| 171 scoped_ptr<base::Value> test_data = |
| 172 google_apis::test_util::LoadJSONFile("chromeos/net/proxy_config.json"); |
| 173 |
| 174 base::ListValue* list_of_tests; |
| 175 test_data->GetAsList(&list_of_tests); |
| 176 |
| 177 int index = 0; |
| 178 for (base::ListValue::iterator it = list_of_tests->begin(); |
| 179 it != list_of_tests->end(); ++it, ++index) { |
| 180 SCOPED_TRACE("Test case #" + base::IntToString(index)); |
| 181 |
| 182 base::DictionaryValue* test_case; |
| 183 (*it)->GetAsDictionary(&test_case); |
| 184 |
| 185 base::DictionaryValue* shill_proxy_config; |
| 186 test_case->GetDictionary("ProxyConfig", &shill_proxy_config); |
| 187 |
| 188 base::DictionaryValue* onc_proxy_settings; |
| 189 test_case->GetDictionary("ONC_ProxySettings", &onc_proxy_settings); |
| 190 |
| 191 scoped_ptr<base::DictionaryValue> actual_proxy_settings = |
| 192 ConvertProxyConfigToOncProxySettings(*shill_proxy_config); |
| 193 EXPECT_TRUE( |
| 194 test_utils::Equals(onc_proxy_settings, actual_proxy_settings.get())); |
| 195 } |
| 196 } |
| 197 |
| 139 } // namespace onc | 198 } // namespace onc |
| 140 } // namespace chromeos | 199 } // namespace chromeos |
| OLD | NEW |