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

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: Remove policy initialized flags and wrap PolicyMaps with scoped_ptr. 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 145
136 IN_PROC_BROWSER_TEST_F(ExtensionNetworkingPrivateApiTest, GetState) { 146 IN_PROC_BROWSER_TEST_F(ExtensionNetworkingPrivateApiTest, GetState) {
137 EXPECT_TRUE(RunNetworkingSubtest("getState")) << message_; 147 EXPECT_TRUE(RunNetworkingSubtest("getState")) << message_;
138 } 148 }
139 149
140 IN_PROC_BROWSER_TEST_F(ExtensionNetworkingPrivateApiTest, SetProperties) { 150 IN_PROC_BROWSER_TEST_F(ExtensionNetworkingPrivateApiTest, SetProperties) {
141 EXPECT_TRUE(RunNetworkingSubtest("setProperties")) << message_; 151 EXPECT_TRUE(RunNetworkingSubtest("setProperties")) << message_;
142 } 152 }
143 153
144 IN_PROC_BROWSER_TEST_F(ExtensionNetworkingPrivateApiTest, 154 IN_PROC_BROWSER_TEST_F(ExtensionNetworkingPrivateApiTest,
155 GetManagedProperties) {
156 ShillServiceClient::TestInterface* service_test =
157 DBusThreadManager::Get()->GetShillServiceClient()->GetTestInterface();
158 std::string uidata_blob =
stevenjb 2013/04/11 18:20:08 nit: const std::string
pneubeck (no reviews) 2013/04/15 12:16:24 Done.
159 "{"
160 " \"user_settings\":"
161 " {"
162 " \"WiFi\": {"
163 " \"Passphrase\": \"top secret\","
164 " }"
165 " }"
166 "}";
stevenjb 2013/04/11 18:20:08 nit: maybe use less space by not putting {} on the
pneubeck (no reviews) 2013/04/15 12:16:24 Whitespace and linebreaks don't matter. But I'd pr
stevenjb 2013/04/15 17:38:54 +1
167 service_test->SetServiceProperty("stub_wifi2",
168 flimflam::kGuidProperty,
169 base::StringValue("stub_wifi2"));
170 service_test->SetServiceProperty("stub_wifi2",
171 flimflam::kUIDataProperty,
172 base::StringValue(uidata_blob));
173 service_test->SetServiceProperty("stub_wifi2",
174 flimflam::kProfileProperty,
175 base::StringValue(kUserProfilePath));
176 service_test->SetServiceProperty("stub_wifi2",
177 flimflam::kAutoConnectProperty,
178 base::FundamentalValue(false));
179
180 ShillProfileClient::TestInterface* profile_test =
181 DBusThreadManager::Get()->GetShillProfileClient()->GetTestInterface();
182
183 profile_test->AddService("stub_wifi2");
184
185 content::RunAllPendingInMessageLoop();
186
187 std::string user_policy_blob =
stevenjb 2013/04/11 18:20:08 Same nits as above.
pneubeck (no reviews) 2013/04/15 12:16:24 Done.
188 "{"
189 " \"NetworkConfigurations\": ["
190 " {"
191 " \"GUID\": \"stub_wifi2\","
192 " \"Type\": \"WiFi\","
193 " \"Name\": \"My WiFi Network\","
194 " \"WiFi\": {"
195 " \"Passphrase\": \"passphrase\","
196 " \"Recommended\": [ \"AutoConnect\", \"Passphrase\" ],"
197 " \"SSID\": \"stub_wifi2\","
198 " \"Security\": \"WPA-PSK\""
199 " }"
200 " }"
201 " ],"
202 " \"Certificates\": [],"
203 " \"Type\": \"UnencryptedConfiguration\""
204 "}";
205 scoped_ptr<base::DictionaryValue> user_policy =
206 onc::ReadDictionaryFromJson(user_policy_blob);
207 ManagedNetworkConfigurationHandler::Get()->SetPolicy(
208 onc::ONC_SOURCE_USER_POLICY,
209 *user_policy);
210
211 scoped_ptr<base::DictionaryValue> device_policy =
212 onc::ReadDictionaryFromJson(onc::kEmptyUnencryptedConfiguration);
213 ManagedNetworkConfigurationHandler::Get()->SetPolicy(
214 onc::ONC_SOURCE_DEVICE_POLICY,
215 *device_policy);
216
217 content::RunAllPendingInMessageLoop();
218
219 EXPECT_TRUE(RunNetworkingSubtest("getManagedProperties")) << message_;
220 }
221
222 IN_PROC_BROWSER_TEST_F(ExtensionNetworkingPrivateApiTest,
145 OnNetworksChangedEventConnect) { 223 OnNetworksChangedEventConnect) {
146 EXPECT_TRUE(RunNetworkingSubtest("onNetworksChangedEventConnect")) 224 EXPECT_TRUE(RunNetworkingSubtest("onNetworksChangedEventConnect"))
147 << message_; 225 << message_;
148 } 226 }
149 227
150 IN_PROC_BROWSER_TEST_F(ExtensionNetworkingPrivateApiTest, 228 IN_PROC_BROWSER_TEST_F(ExtensionNetworkingPrivateApiTest,
151 OnNetworksChangedEventDisconnect) { 229 OnNetworksChangedEventDisconnect) {
152 EXPECT_TRUE(RunNetworkingSubtest("onNetworksChangedEventDisconnect")) 230 EXPECT_TRUE(RunNetworkingSubtest("onNetworksChangedEventDisconnect"))
153 << message_; 231 << message_;
154 } 232 }
(...skipping 13 matching lines...) Expand all
168 EXPECT_TRUE(RunNetworkingSubtest("verifyAndEncryptCredentials")) << message_; 246 EXPECT_TRUE(RunNetworkingSubtest("verifyAndEncryptCredentials")) << message_;
169 } 247 }
170 248
171 IN_PROC_BROWSER_TEST_F(ExtensionNetworkingPrivateApiTest, 249 IN_PROC_BROWSER_TEST_F(ExtensionNetworkingPrivateApiTest,
172 VerifyAndEncryptData) { 250 VerifyAndEncryptData) {
173 EXPECT_TRUE(RunNetworkingSubtest("verifyAndEncryptData")) << message_; 251 EXPECT_TRUE(RunNetworkingSubtest("verifyAndEncryptData")) << message_;
174 } 252 }
175 253
176 254
177 } // namespace chromeos 255 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698