Home | History | Annotate | Download | only in network_DefaultProfileServices
      1 # Copyright (c) 2013 The Chromium OS Authors. All rights reserved.
      2 # Use of this source code is governed by a BSD-style license that can be
      3 # found in the LICENSE file.
      4 
      5 import os
      6 
      7 from autotest_lib.client.bin import test
      8 from autotest_lib.client.common_lib import error
      9 from autotest_lib.client.cros.networking import shill_context
     10 from autotest_lib.client.cros.networking import shill_proxy
     11 
     12 class network_DefaultProfileServices(test.test):
     13     """The Default Profile Services class.
     14 
     15     Wipe the default profile, start shill, configure a service, restart
     16     shill, and check that the service exists.
     17 
     18     The service name is chosen such that it is unlikely match any SSID
     19     that is present over-the-air.
     20 
     21     """
     22     DEFAULT_PROFILE_PATH = '/var/cache/shill/default.profile'
     23     OUR_SSID = 'org.chromium.DfltPrflSrvcsTest'
     24     version = 1
     25 
     26 
     27     def run_once(self):
     28         """Test main loop."""
     29         with shill_context.stopped_shill():
     30             os.remove(self.DEFAULT_PROFILE_PATH)
     31         shill = shill_proxy.ShillProxy.get_proxy()
     32         if shill is None:
     33             raise error.TestFail('Could not connect to shill')
     34 
     35         shill.manager.PopAllUserProfiles()
     36         path = shill.configure_service({
     37                 shill.SERVICE_PROPERTY_TYPE: 'wifi',
     38                 shill.SERVICE_PROPERTY_MODE: 'managed',
     39                 shill.SERVICE_PROPERTY_SSID: self.OUR_SSID,
     40                 shill.SERVICE_PROPERTY_HIDDEN: True,
     41                 shill.SERVICE_PROPERTY_SECURITY_CLASS: 'none',
     42                 })
     43 
     44         with shill_context.stopped_shill():
     45             # We don't actually need to do anything while shill is
     46             # stopped. We just want shill to be restarted.
     47             pass
     48         shill = shill_proxy.ShillProxy.get_proxy()
     49         if shill is None:
     50             raise error.TestFail('Could not connect to shill')
     51 
     52         shill.manager.PopAllUserProfiles()
     53         service = shill.find_object('AnyService',
     54                                     {'Name': self.OUR_SSID})
     55         if not service:
     56             raise error.TestFail('Network not found after restart.')
     57