From 85eb89fe5613f06bd01d382cb9ef51f14bed041d Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Tue, 9 Jun 2015 21:31:09 +0300 Subject: [PATCH] tests: FST with RSN Signed-off-by: Jouni Malinen --- tests/hwsim/fst_module_aux.py | 42 ++++++++++++++++++++++------------ tests/hwsim/test_fst_module.py | 11 ++++++--- 2 files changed, 35 insertions(+), 18 deletions(-) diff --git a/tests/hwsim/fst_module_aux.py b/tests/hwsim/fst_module_aux.py index c51649238..a3402974e 100644 --- a/tests/hwsim/fst_module_aux.py +++ b/tests/hwsim/fst_module_aux.py @@ -69,30 +69,30 @@ def parse_fst_session_event(ev): event['reason'] = f.group(1) return event -def start_two_ap_sta_pairs(apdev): +def start_two_ap_sta_pairs(apdev, rsn=False): """auxiliary function that creates two pairs of APs and STAs""" ap1 = FstAP(apdev[0]['ifname'], 'fst_11a', 'a', fst_test_common.fst_test_def_chan_a, fst_test_common.fst_test_def_group, fst_test_common.fst_test_def_prio_low, - fst_test_common.fst_test_def_llt) + fst_test_common.fst_test_def_llt, rsn=rsn) ap1.start() ap2 = FstAP(apdev[1]['ifname'], 'fst_11g', 'g', fst_test_common.fst_test_def_chan_g, fst_test_common.fst_test_def_group, fst_test_common.fst_test_def_prio_high, - fst_test_common.fst_test_def_llt) + fst_test_common.fst_test_def_llt, rsn=rsn) ap2.start() sta1 = FstSTA('wlan5', fst_test_common.fst_test_def_group, fst_test_common.fst_test_def_prio_low, - fst_test_common.fst_test_def_llt) + fst_test_common.fst_test_def_llt, rsn=rsn) sta1.start() sta2 = FstSTA('wlan6', fst_test_common.fst_test_def_group, fst_test_common.fst_test_def_prio_high, - fst_test_common.fst_test_def_llt) + fst_test_common.fst_test_def_llt, rsn=rsn) sta2.start() return ap1, ap2, sta1, sta2 @@ -103,15 +103,21 @@ def stop_two_ap_sta_pairs(ap1, ap2, sta1, sta2): ap1.stop() ap2.stop() -def connect_two_ap_sta_pairs(ap1, ap2, dev1, dev2): +def connect_two_ap_sta_pairs(ap1, ap2, dev1, dev2, rsn=False): """Connects a pair of stations, each one to a separate AP""" dev1.scan(freq=fst_test_common.fst_test_def_freq_a) dev2.scan(freq=fst_test_common.fst_test_def_freq_g) - dev1.connect(ap1, key_mgmt="NONE", - scan_freq=fst_test_common.fst_test_def_freq_a) - dev2.connect(ap2, key_mgmt="NONE", - scan_freq=fst_test_common.fst_test_def_freq_g) + if rsn: + dev1.connect(ap1, psk="12345678", + scan_freq=fst_test_common.fst_test_def_freq_a) + dev2.connect(ap2, psk="12345678", + scan_freq=fst_test_common.fst_test_def_freq_g) + else: + dev1.connect(ap1, key_mgmt="NONE", + scan_freq=fst_test_common.fst_test_def_freq_a) + dev2.connect(ap2, key_mgmt="NONE", + scan_freq=fst_test_common.fst_test_def_freq_g) def disconnect_two_ap_sta_pairs(ap1, ap2, dev1, dev2): dev1.disconnect() @@ -145,7 +151,7 @@ def disconnect_external_sta(sta, ap, check_disconnect=True): # FST functionality. # class FstDevice: - def __init__(self, iface, fst_group, fst_pri, fst_llt=None): + def __init__(self, iface, fst_group, fst_pri, fst_llt=None, rsn=False): self.iface = iface self.fst_group = fst_group self.fst_pri = fst_pri @@ -158,6 +164,7 @@ class FstDevice: s = self.grequest("FST-MANAGER TEST_REQUEST IS_SUPPORTED") if not s.startswith('OK'): raise utils.HwsimSkip("FST not supported") + self.rsn = rsn def ifname(self): return self.iface @@ -571,7 +578,7 @@ class FstDevice: # class FstAP (FstDevice): def __init__(self, iface, ssid, mode, chan, fst_group, fst_pri, - fst_llt=None): + fst_llt=None, rsn=False): """If fst_group is empty, then FST parameters will not be set If fst_llt is empty, the parameter will not be set and the default value is expected to be configured.""" @@ -581,7 +588,7 @@ class FstAP (FstDevice): self.reg_ctrl = fst_test_common.HapdRegCtrl() self.reg_ctrl.add_ap(iface, self.chan) self.global_instance = hostapd.HostapdGlobal() - FstDevice.__init__(self, iface, fst_group, fst_pri, fst_llt) + FstDevice.__init__(self, iface, fst_group, fst_pri, fst_llt, rsn) def start(self): """Starts AP the "standard" way as it was intended by hostapd tests. @@ -592,6 +599,11 @@ class FstAP (FstDevice): params['hw_mode'] = self.mode params['channel'] = self.chan params['country_code'] = 'US' + if self.rsn: + params['wpa'] = '2' + params['wpa_key_mgmt'] = 'WPA-PSK' + params['rsn_pairwise'] = 'CCMP' + params['wpa_passphrase'] = '12345678' self.hapd=hostapd.add_ap(self.iface, params) if not self.hapd.ping(): raise Exception("Could not ping FST hostapd") @@ -661,11 +673,11 @@ class FstAP (FstDevice): # FstSTA class # class FstSTA (FstDevice): - def __init__(self, iface, fst_group, fst_pri, fst_llt=None): + def __init__(self, iface, fst_group, fst_pri, fst_llt=None, rsn=False): """If fst_group is empty, then FST parameters will not be set If fst_llt is empty, the parameter will not be set and the default value is expected to be configured.""" - FstDevice.__init__(self, iface, fst_group, fst_pri, fst_llt) + FstDevice.__init__(self, iface, fst_group, fst_pri, fst_llt, rsn) self.connected = None # FstAP object the station is connected to def start(self): diff --git a/tests/hwsim/test_fst_module.py b/tests/hwsim/test_fst_module.py index 4d2b5241a..21a812997 100644 --- a/tests/hwsim/test_fst_module.py +++ b/tests/hwsim/test_fst_module.py @@ -325,17 +325,18 @@ def fst_initiate_session(apdev, test_params, bad_param_type, init_on_ap): else: print "Failure. Unexpected exception" -def fst_transfer_session(apdev, test_params, bad_param_type, init_on_ap): +def fst_transfer_session(apdev, test_params, bad_param_type, init_on_ap, + rsn=False): """This function makes the necessary preparations and then adds, sets, initiates and attempts to transfer a session using either correct or incorrect parameters at each stage depending on the value of bad_param_type. If the call ends as expected the function silently exits. Otherwise, it throws an exception thus failing the test.""" - ap1, ap2, sta1, sta2 = fst_module_aux.start_two_ap_sta_pairs(apdev) + ap1, ap2, sta1, sta2 = fst_module_aux.start_two_ap_sta_pairs(apdev, rsn=rsn) bad_parameter_detected = False exception_already_raised = False try: - fst_module_aux.connect_two_ap_sta_pairs(ap1, ap2, sta1, sta2) + fst_module_aux.connect_two_ap_sta_pairs(ap1, ap2, sta1, sta2, rsn=rsn) # This call makes sure FstHostapd singleton object is created and, as a # result, the global control interface is registered (this is done from # the constructor). @@ -1770,3 +1771,7 @@ def test_fst_sta_remove_session_bad_session_id(dev, apdev, test_params): """FST STA remove session - bad session id""" fst_remove_session(apdev, test_params, remove_scenario_bad_session_id, False) + +def test_fst_rsn_ap_transfer_session(dev, apdev, test_params): + """FST RSN AP transfer session""" + fst_transfer_session(apdev, test_params, bad_param_none, True, rsn=True)