summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorstanleyw@chromium.org <stanleyw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-11-04 21:40:42 +0000
committerstanleyw@chromium.org <stanleyw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-11-04 21:40:42 +0000
commit550c5bcedc53b42a53ddd48fdc2b218864c9bb4a (patch)
treeecacfb1e4a39e061172eb16053ece129f4ade14c
parent8c6b2c145d66a802b45ef0f396494e4db62da88c (diff)
downloadchromium_src-550c5bcedc53b42a53ddd48fdc2b218864c9bb4a.zip
chromium_src-550c5bcedc53b42a53ddd48fdc2b218864c9bb4a.tar.gz
chromium_src-550c5bcedc53b42a53ddd48fdc2b218864c9bb4a.tar.bz2
Adding sharing networks support for Wifi networks
Encrypted wifi networks should support the option to share or not. Adding sharing option to the ConnectToWifiNetwork and ConnectToHiddenWifiNetwork call. Also, testAddRemoveRememberedNetworks replaced with individual instances of shared/unsared networks. Separate tests will be added for specific scenarios. Change-Id: Ide05accc7d5390f0c66617f25c47173f265d134b BUG=CHROMIUM-OS:22187 TEST= Run pyauto test chromeos_wifi_functional.py Review URL: http://codereview.chromium.org/8341077 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@108720 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/automation/testing_automation_provider_chromeos.cc21
-rw-r--r--chrome/test/functional/chromeos_wifi_functional.py70
-rw-r--r--chrome/test/pyautolib/chromeos_network.py6
-rw-r--r--chrome/test/pyautolib/pyauto.py24
4 files changed, 105 insertions, 16 deletions
diff --git a/chrome/browser/automation/testing_automation_provider_chromeos.cc b/chrome/browser/automation/testing_automation_provider_chromeos.cc
index bdfb531..d74d81d 100644
--- a/chrome/browser/automation/testing_automation_provider_chromeos.cc
+++ b/chrome/browser/automation/testing_automation_provider_chromeos.cc
@@ -613,8 +613,10 @@ void TestingAutomationProvider::ConnectToWifiNetwork(
AutomationJSONReply reply(this, reply_message);
std::string service_path, password;
+ bool shared;
if (!args->GetString("service_path", &service_path) ||
- !args->GetString("password", &password)) {
+ !args->GetString("password", &password) ||
+ !args->GetBoolean("shared", &shared)) {
reply.SendError("Invalid or missing args.");
return;
}
@@ -629,10 +631,15 @@ void TestingAutomationProvider::ConnectToWifiNetwork(
if (!password.empty())
wifi->SetPassphrase(password);
+ // Regardless of what was passed, if the network is open and visible,
+ // the network must be shared because of a UI restriction.
+ if (wifi->encryption() == chromeos::SECURITY_NONE)
+ shared = true;
+
// Set up an observer (it will delete itself).
new ServicePathConnectObserver(this, reply_message, service_path);
- network_library->ConnectToWifiNetwork(wifi);
+ network_library->ConnectToWifiNetwork(wifi, shared);
network_library->RequestNetworkScan();
}
@@ -657,9 +664,11 @@ void TestingAutomationProvider::ConnectToHiddenWifiNetwork(
return;
std::string ssid, security, password;
+ bool shared;
if (!args->GetString("ssid", &ssid) ||
!args->GetString("security", &security) ||
- !args->GetString("password", &password)) {
+ !args->GetString("password", &password) ||
+ !args->GetBoolean("shared", &shared)) {
AutomationJSONReply(this, reply_message).SendError(
"Invalid or missing args.");
return;
@@ -685,15 +694,15 @@ void TestingAutomationProvider::ConnectToHiddenWifiNetwork(
// Set up an observer (it will delete itself).
new SSIDConnectObserver(this, reply_message, ssid);
- const bool shared = true;
- const bool save_credentials = false;
+ bool save_credentials = false;
if (connection_security == chromeos::SECURITY_8021X) {
chromeos::NetworkLibrary::EAPConfigData config_data;
std::string eap_method, eap_auth, eap_identity;
if (!args->GetString("eap_method", &eap_method) ||
!args->GetString("eap_auth", &eap_auth) ||
- !args->GetString("eap_identity", &eap_identity)) {
+ !args->GetString("eap_identity", &eap_identity) ||
+ !args->GetBoolean("save_credentials", &save_credentials)) {
AutomationJSONReply(this, reply_message).SendError(
"Invalid or missing EAP args.");
return;
diff --git a/chrome/test/functional/chromeos_wifi_functional.py b/chrome/test/functional/chromeos_wifi_functional.py
index aa11326..e8c836d 100644
--- a/chrome/test/functional/chromeos_wifi_functional.py
+++ b/chrome/test/functional/chromeos_wifi_functional.py
@@ -3,8 +3,11 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
+import os
+
import pyauto_functional
import chromeos_network # pyauto_functional must come before chromeos_network
+import pyauto_utils
class ChromeosWifiFunctional(chromeos_network.PyNetworkUITest):
@@ -13,9 +16,38 @@ class ChromeosWifiFunctional(chromeos_network.PyNetworkUITest):
These tests should be run within vacinity of the power strip where the wifi
routers are attached.
"""
- def testAddForgetRememberedNetworks(self):
- """Verifies that networks are remembered on connect and can be forgotten."""
- router_name = 'Belkin_G'
+
+ def _LoginDevice(self):
+ """Logs into the device and cleans up flimflam profile."""
+ if not self.GetLoginInfo()['is_logged_in']:
+ credentials = self.GetPrivateInfo()['test_google_account']
+ self.Login(credentials['username'], credentials['password'])
+ login_info = self.GetLoginInfo()
+ self.assertTrue(login_info['is_logged_in'], msg='Login failed.')
+
+ ff_dir = '/home/chronos/user/flimflam'
+ self.assertTrue(os.path.isdir(ff_dir), 'User is logged in but user '
+ 'flimflam profile is not present.')
+
+ # Clean up the items in the flimflam profile directory.
+ for item in os.listdir(ff_dir):
+ pyauto_utils.RemovePath(os.path.join(ff_dir, item))
+
+ def tearDown(self):
+ if self.GetLoginInfo().get('is_logged_in'):
+ self.Logout()
+ chromeos_network.PyNetworkUITest.tearDown(self)
+
+ def _SetupRouter(self, router_name):
+ """Turn on the router and wait for it to come on.
+
+ Args:
+ router_name: The name of the router as defined in wifi_testbed_config.
+
+ Returns:
+ A dictionary of the router and its attributes. The format is same as
+ the definition in wifi_testbed_config
+ """
self.InitWifiPowerStrip()
router = self.GetRouterConfig(router_name)
self.RouterPower(router_name, True)
@@ -24,14 +56,42 @@ class ChromeosWifiFunctional(chromeos_network.PyNetworkUITest):
# remembered_wifi list.
self.WaitUntilWifiNetworkAvailable(router['ssid'],
is_hidden=router.get('hidden'))
- error = self.ConnectToWifiRouter(router_name)
+ return router
+
+ def testConnectShareEncryptedNetwork(self):
+ """A shared encrypted network can connect and is remembered.
+
+ Note: This test does not verify that the network is added to the public
+ profile
+ """
+ router_name = 'D-Link_N150'
+ self._LoginDevice()
+ router = self._SetupRouter(router_name)
+ error = self.ConnectToWifiRouter(router_name, shared=True)
self.assertFalse(error, 'Failed to connect to wifi network %s. '
'Reason: %s.' % (router['ssid'], error))
-
service_path = self.GetServicePath(router['ssid'])
self.assertTrue(service_path in self.GetNetworkInfo()['remembered_wifi'],
'Connected wifi was not added to the remembered list.')
+ self.ForgetWifiNetwork(service_path)
+ self.assertFalse(service_path in self.GetNetworkInfo()['remembered_wifi'],
+ 'Connected wifi was not removed from the remembered list.')
+
+ def testConnectNoShareEncryptedNetwork(self):
+ """A non-shared encrypted network can connect and is remembered.
+ Note: This test does not verify that the network is added to the private
+ profile
+ """
+ router_name = 'D-Link_N150'
+ self._LoginDevice()
+ router = self._SetupRouter(router_name)
+ error = self.ConnectToWifiRouter(router_name, shared=False)
+ self.assertFalse(error, 'Failed to connect to wifi network %s. '
+ 'Reason: %s.' % (router['ssid'], error))
+ service_path = self.GetServicePath(router['ssid'])
+ self.assertTrue(service_path in self.GetNetworkInfo()['remembered_wifi'],
+ 'Connected wifi was not added to the remembered list.')
self.ForgetWifiNetwork(service_path)
self.assertFalse(service_path in self.GetNetworkInfo()['remembered_wifi'],
'Connected wifi was not removed from the remembered list.')
diff --git a/chrome/test/pyautolib/chromeos_network.py b/chrome/test/pyautolib/chromeos_network.py
index 9665cfa..01d416d 100644
--- a/chrome/test/pyautolib/chromeos_network.py
+++ b/chrome/test/pyautolib/chromeos_network.py
@@ -321,7 +321,7 @@ class PyNetworkUITest(pyauto.PyUITest):
return service_path
return None
- def ConnectToWifiRouter(self, router_name):
+ def ConnectToWifiRouter(self, router_name, shared=True):
"""Connects to a router by name.
Args:
@@ -346,5 +346,7 @@ class PyNetworkUITest(pyauto.PyUITest):
router['ssid']
logging.debug('Connecting to router %s.' % router_name)
- error_string = self.ConnectToWifiNetwork(service_path, passphrase)
+ error_string = self.ConnectToWifiNetwork(service_path,
+ password=passphrase,
+ shared=shared)
return error_string
diff --git a/chrome/test/pyautolib/pyauto.py b/chrome/test/pyautolib/pyauto.py
index 3f1a593..a7df82e 100644
--- a/chrome/test/pyautolib/pyauto.py
+++ b/chrome/test/pyautolib/pyauto.py
@@ -372,7 +372,17 @@ class PyUITest(pyautolib.PyUITestBase, unittest.TestCase):
"""
profile_dir = '/home/chronos/user'
for item in os.listdir(profile_dir):
- # Deleting .pki causes stateful partition to get erased
+
+ # We should not delete the flimflam directory because it puts
+ # flimflam in a weird state if the device is already logged in.
+ # However, deleting its contents is okay.
+ if item == 'flimflam' and os.path.isdir(os.path.join(profile_dir,
+ 'flimflam')):
+ for fname in os.listdir(os.path.join(profile_dir, item)):
+ pyauto_utils.RemovePath(os.path.join(profile_dir, item, fname))
+ continue
+
+ # Deleting .pki causes stateful partition to get erased.
if item != 'log' and not item.startswith('.'):
pyauto_utils.RemovePath(os.path.join(profile_dir, item))
@@ -3767,7 +3777,7 @@ class PyUITest(pyautolib.PyUITestBase, unittest.TestCase):
}
self._GetResultFromJSONRequest(cmd_dict, windex=-1)
- def ConnectToWifiNetwork(self, service_path, password=''):
+ def ConnectToWifiNetwork(self, service_path, password='', shared=True):
"""Connect to a wifi network by its service path.
Blocks until connection succeeds or fails.
@@ -3775,6 +3785,7 @@ class PyUITest(pyautolib.PyUITestBase, unittest.TestCase):
Args:
service_path: Flimflam path that defines the wifi network.
password: Passphrase for connecting to the wifi network.
+ shared: Boolean value specifying whether the network should be shared.
Returns:
An error string if an error occured.
@@ -3787,11 +3798,13 @@ class PyUITest(pyautolib.PyUITestBase, unittest.TestCase):
'command': 'ConnectToWifiNetwork',
'service_path': service_path,
'password': password,
+ 'shared': shared,
}
result = self._GetResultFromJSONRequest(cmd_dict, windex=-1, timeout=50000)
return result.get('error_string')
- def ConnectToHiddenWifiNetwork(self, ssid, security, password=''):
+ def ConnectToHiddenWifiNetwork(self, ssid, security, password='',
+ shared=True, save_credentials=False):
"""Connect to a wifi network by its service path.
Blocks until connection succeeds or fails.
@@ -3801,6 +3814,9 @@ class PyUITest(pyautolib.PyUITestBase, unittest.TestCase):
security: The network's security type. One of: 'SECURITY_NONE',
'SECURITY_WEP', 'SECURITY_WPA', 'SECURITY_RSN', 'SECURITY_8021X'
password: Passphrase for connecting to the wifi network.
+ shared: Boolean value specifying whether the network should be shared.
+ save_credentials: Boolean value specifying whether 802.1x credentials are
+ saved.
Returns:
An error string if an error occured.
@@ -3816,6 +3832,8 @@ class PyUITest(pyautolib.PyUITestBase, unittest.TestCase):
'ssid': ssid,
'security': security,
'password': password,
+ 'shared': shared,
+ 'save_credentials': save_credentials,
}
result = self._GetResultFromJSONRequest(cmd_dict, windex=-1, timeout=50000)
return result.get('error_string')