Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(156)

Side by Side Diff: chrome/browser/chromeos/extensions/networking_private_apitest.cc

Issue 12676017: Adding policy support to the new network configuration stack. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed clang errors. Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 <stdio.h> 5 #include <stdio.h>
6 6
7 #include "base/stl_util.h" 7 #include "base/stl_util.h"
8 #include "chrome/browser/extensions/extension_apitest.h" 8 #include "chrome/browser/extensions/extension_apitest.h"
9 #include "chrome/common/chrome_switches.h" 9 #include "chrome/common/chrome_switches.h"
10 #include "chrome/test/base/ui_test_utils.h" 10 #include "chrome/test/base/ui_test_utils.h"
11 #include "chromeos/dbus/dbus_thread_manager.h" 11 #include "chromeos/dbus/dbus_thread_manager.h"
12 #include "chromeos/dbus/shill_device_client.h" 12 #include "chromeos/dbus/shill_device_client.h"
13 #include "chromeos/dbus/shill_profile_client.h"
13 #include "chromeos/dbus/shill_service_client.h" 14 #include "chromeos/dbus/shill_service_client.h"
15 #include "chromeos/network/managed_network_configuration_handler.h"
16 #include "chromeos/network/onc/onc_constants.h"
17 #include "chromeos/network/onc/onc_utils.h"
14 #include "third_party/cros_system_api/dbus/service_constants.h" 18 #include "third_party/cros_system_api/dbus/service_constants.h"
15 19
16 namespace chromeos { 20 namespace chromeos {
17 21
22 const char kSharedProfilePath[] = "/profile/default";
23 const char kUserProfilePath[] = "/profile/chronos/shill";
24
18 class ExtensionNetworkingPrivateApiTest : public ExtensionApiTest { 25 class ExtensionNetworkingPrivateApiTest : public ExtensionApiTest {
19 public: 26 public:
20 // Whitelist the extension ID of the test extension. 27 // Whitelist the extension ID of the test extension.
21 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { 28 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
22 ExtensionApiTest::SetUpCommandLine(command_line); 29 ExtensionApiTest::SetUpCommandLine(command_line);
23 command_line->AppendSwitchASCII( 30 command_line->AppendSwitchASCII(
24 switches::kWhitelistedExtensionID, "epcifkihnkjgphfkloaaleeakhpmgdmn"); 31 switches::kWhitelistedExtensionID, "epcifkihnkjgphfkloaaleeakhpmgdmn");
25 } 32 }
26 33
27 bool RunNetworkingSubtest(const std::string& subtest) { 34 bool RunNetworkingSubtest(const std::string& subtest) {
(...skipping 26 matching lines...) Expand all
54 flimflam::kTypeWifi, flimflam::kStateOnline, 61 flimflam::kTypeWifi, flimflam::kStateOnline,
55 add_to_watchlist); 62 add_to_watchlist);
56 service_test->SetServiceProperty("stub_wifi1", 63 service_test->SetServiceProperty("stub_wifi1",
57 flimflam::kSecurityProperty, 64 flimflam::kSecurityProperty,
58 base::StringValue(flimflam::kSecurityWep)); 65 base::StringValue(flimflam::kSecurityWep));
59 66
60 service_test->AddService("stub_wifi2", "wifi2_PSK", 67 service_test->AddService("stub_wifi2", "wifi2_PSK",
61 flimflam::kTypeWifi, flimflam::kStateIdle, 68 flimflam::kTypeWifi, flimflam::kStateIdle,
62 add_to_watchlist); 69 add_to_watchlist);
63 service_test->SetServiceProperty("stub_wifi2", 70 service_test->SetServiceProperty("stub_wifi2",
71 flimflam::kGuidProperty,
72 base::StringValue("stub_wifi2"));
73 service_test->SetServiceProperty("stub_wifi2",
64 flimflam::kSecurityProperty, 74 flimflam::kSecurityProperty,
65 base::StringValue(flimflam::kSecurityPsk)); 75 base::StringValue(flimflam::kSecurityPsk));
66 service_test->SetServiceProperty("stub_wifi2", 76 service_test->SetServiceProperty("stub_wifi2",
67 flimflam::kSignalStrengthProperty, 77 flimflam::kSignalStrengthProperty,
68 base::FundamentalValue(80)); 78 base::FundamentalValue(80));
69 79
70 service_test->AddService("stub_cellular1", "cellular1", 80 service_test->AddService("stub_cellular1", "cellular1",
71 flimflam::kTypeCellular, flimflam::kStateIdle, 81 flimflam::kTypeCellular, flimflam::kStateIdle,
72 add_to_watchlist); 82 add_to_watchlist);
73 service_test->SetServiceProperty( 83 service_test->SetServiceProperty(
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 // ShillToONCTranslator::TranslateWiFiWithState 145 // ShillToONCTranslator::TranslateWiFiWithState
136 IN_PROC_BROWSER_TEST_F(ExtensionNetworkingPrivateApiTest, GetProperties) { 146 IN_PROC_BROWSER_TEST_F(ExtensionNetworkingPrivateApiTest, GetProperties) {
137 EXPECT_TRUE(RunNetworkingSubtest("getProperties")) << message_; 147 EXPECT_TRUE(RunNetworkingSubtest("getProperties")) << message_;
138 } 148 }
139 149
140 IN_PROC_BROWSER_TEST_F(ExtensionNetworkingPrivateApiTest, GetState) { 150 IN_PROC_BROWSER_TEST_F(ExtensionNetworkingPrivateApiTest, GetState) {
141 EXPECT_TRUE(RunNetworkingSubtest("getState")) << message_; 151 EXPECT_TRUE(RunNetworkingSubtest("getState")) << message_;
142 } 152 }
143 153
144 IN_PROC_BROWSER_TEST_F(ExtensionNetworkingPrivateApiTest, SetProperties) { 154 IN_PROC_BROWSER_TEST_F(ExtensionNetworkingPrivateApiTest, SetProperties) {
155 scoped_ptr<base::DictionaryValue> empty_policy =
156 onc::ReadDictionaryFromJson(onc::kEmptyUnencryptedConfiguration);
157 ManagedNetworkConfigurationHandler::Get()->SetPolicy(
158 onc::ONC_SOURCE_USER_POLICY, *empty_policy);
159 ManagedNetworkConfigurationHandler::Get()->SetPolicy(
160 onc::ONC_SOURCE_DEVICE_POLICY, *empty_policy);
161 content::RunAllPendingInMessageLoop();
162
145 EXPECT_TRUE(RunNetworkingSubtest("setProperties")) << message_; 163 EXPECT_TRUE(RunNetworkingSubtest("setProperties")) << message_;
146 } 164 }
147 165
148 IN_PROC_BROWSER_TEST_F(ExtensionNetworkingPrivateApiTest, 166 IN_PROC_BROWSER_TEST_F(ExtensionNetworkingPrivateApiTest,
167 GetManagedProperties) {
168 ShillServiceClient::TestInterface* service_test =
169 DBusThreadManager::Get()->GetShillServiceClient()->GetTestInterface();
170 const std::string uidata_blob =
171 "{ \"user_settings\": {"
172 " \"WiFi\": {"
173 " \"Passphrase\": \"top secret\","
174 " }"
175 " }"
176 "}";
177 service_test->SetServiceProperty("stub_wifi2",
178 flimflam::kGuidProperty,
179 base::StringValue("stub_wifi2"));
180 service_test->SetServiceProperty("stub_wifi2",
181 flimflam::kUIDataProperty,
182 base::StringValue(uidata_blob));
183 service_test->SetServiceProperty("stub_wifi2",
184 flimflam::kProfileProperty,
185 base::StringValue(kUserProfilePath));
186 service_test->SetServiceProperty("stub_wifi2",
187 flimflam::kAutoConnectProperty,
188 base::FundamentalValue(false));
189
190 ShillProfileClient::TestInterface* profile_test =
191 DBusThreadManager::Get()->GetShillProfileClient()->GetTestInterface();
192
193 profile_test->AddService("stub_wifi2");
194
195 content::RunAllPendingInMessageLoop();
196
197 const std::string user_policy_blob =
198 "{ \"NetworkConfigurations\": ["
199 " { \"GUID\": \"stub_wifi2\","
200 " \"Type\": \"WiFi\","
201 " \"Name\": \"My WiFi Network\","
202 " \"WiFi\": {"
203 " \"Passphrase\": \"passphrase\","
204 " \"Recommended\": [ \"AutoConnect\", \"Passphrase\" ],"
205 " \"SSID\": \"stub_wifi2\","
206 " \"Security\": \"WPA-PSK\""
207 " }"
208 " }"
209 " ],"
210 " \"Certificates\": [],"
211 " \"Type\": \"UnencryptedConfiguration\""
212 "}";
213 scoped_ptr<base::DictionaryValue> user_policy =
214 onc::ReadDictionaryFromJson(user_policy_blob);
215 ManagedNetworkConfigurationHandler::Get()->SetPolicy(
216 onc::ONC_SOURCE_USER_POLICY, *user_policy);
217
218 scoped_ptr<base::DictionaryValue> device_policy =
219 onc::ReadDictionaryFromJson(onc::kEmptyUnencryptedConfiguration);
220 ManagedNetworkConfigurationHandler::Get()->SetPolicy(
221 onc::ONC_SOURCE_DEVICE_POLICY, *device_policy);
222
223 content::RunAllPendingInMessageLoop();
224
225 EXPECT_TRUE(RunNetworkingSubtest("getManagedProperties")) << message_;
226 }
227
228 IN_PROC_BROWSER_TEST_F(ExtensionNetworkingPrivateApiTest,
149 OnNetworksChangedEventConnect) { 229 OnNetworksChangedEventConnect) {
150 EXPECT_TRUE(RunNetworkingSubtest("onNetworksChangedEventConnect")) 230 EXPECT_TRUE(RunNetworkingSubtest("onNetworksChangedEventConnect"))
151 << message_; 231 << message_;
152 } 232 }
153 233
154 IN_PROC_BROWSER_TEST_F(ExtensionNetworkingPrivateApiTest, 234 IN_PROC_BROWSER_TEST_F(ExtensionNetworkingPrivateApiTest,
155 OnNetworksChangedEventDisconnect) { 235 OnNetworksChangedEventDisconnect) {
156 EXPECT_TRUE(RunNetworkingSubtest("onNetworksChangedEventDisconnect")) 236 EXPECT_TRUE(RunNetworkingSubtest("onNetworksChangedEventDisconnect"))
157 << message_; 237 << message_;
158 } 238 }
(...skipping 13 matching lines...) Expand all
172 EXPECT_TRUE(RunNetworkingSubtest("verifyAndEncryptCredentials")) << message_; 252 EXPECT_TRUE(RunNetworkingSubtest("verifyAndEncryptCredentials")) << message_;
173 } 253 }
174 254
175 IN_PROC_BROWSER_TEST_F(ExtensionNetworkingPrivateApiTest, 255 IN_PROC_BROWSER_TEST_F(ExtensionNetworkingPrivateApiTest,
176 VerifyAndEncryptData) { 256 VerifyAndEncryptData) {
177 EXPECT_TRUE(RunNetworkingSubtest("verifyAndEncryptData")) << message_; 257 EXPECT_TRUE(RunNetworkingSubtest("verifyAndEncryptData")) << message_;
178 } 258 }
179 259
180 260
181 } // namespace chromeos 261 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/extensions/networking_private_api.cc ('k') | chrome/browser/chromeos/login/login_utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698