def test_connection_success(self): wd = IWD() psk_agent = PSKAgent("InvalidPassword") wd.register_psk_agent(psk_agent) devices = wd.list_devices(1) self.assertIsNotNone(devices) device = devices[0] condition = 'not obj.scanning' wd.wait_for_object_condition(device, condition) device.scan() condition = 'not obj.scanning' wd.wait_for_object_condition(device, condition) ordered_networks = device.get_ordered_networks() ordered_network = ordered_networks[0] self.assertEqual(ordered_network.name, "ssidCCMP") self.assertEqual(ordered_network.type, NetworkType.psk) condition = 'not obj.connected' wd.wait_for_object_condition(ordered_network.network_object, condition) with self.assertRaises(iwd.FailedEx): ordered_network.network_object.connect() wd.unregister_psk_agent(psk_agent)
def test_connection_success(self): hwsim = Hwsim() bss_radio = hwsim.get_radio('rad0') self.assertIsNotNone(bss_radio) wd = IWD() devices = wd.list_devices(1) device = devices[0] condition = 'not obj.scanning' wd.wait_for_object_condition(device, condition) device.scan() condition = 'not obj.scanning' wd.wait_for_object_condition(device, condition) ordered_network = device.get_ordered_network('ssidOWE') self.assertEqual(ordered_network.type, NetworkType.open) condition = 'not obj.connected' wd.wait_for_object_condition(ordered_network.network_object, condition) rule0 = hwsim.rules.create() rule0.source = bss_radio.addresses[0] rule0.bidirectional = True rule0.drop = True with self.assertRaises(iwd.FailedEx): ordered_network.network_object.connect()
def test_connection_failure(self): wd = IWD() dev1, dev2 = wd.list_devices(2) self.client_connect(wd, dev1) dev1.start_ap('TestAP2', 'Password2') try: condition = 'not obj.scanning' wd.wait_for_object_condition(dev2, condition) dev2.scan() condition = 'obj.scanning' wd.wait_for_object_condition(dev2, condition) condition = 'not obj.scanning' wd.wait_for_object_condition(dev2, condition) ordered_networks = dev2.get_ordered_networks() networks = {n.name: n for n in ordered_networks} self.assertEqual(networks['TestAP1'].type, NetworkType.psk) self.assertEqual(networks['TestAP2'].type, NetworkType.psk) psk_agent = PSKAgent('InvalidPassword') wd.register_psk_agent(psk_agent) with self.assertRaises(iwd.FailedEx): networks['TestAP2'].network_object.connect() wd.unregister_psk_agent(psk_agent) finally: dev1.stop_ap() # Finally test dev1 can go to client mode and connect again self.client_connect(wd, dev1)
def test_connection_success(self): wd = IWD() psk_agent = PSKAgent("secret123") wd.register_psk_agent(psk_agent) devices = wd.list_devices(1) device = devices[0] condition = 'not obj.scanning' wd.wait_for_object_condition(device, condition) device.scan() condition = 'not obj.scanning' wd.wait_for_object_condition(device, condition) ordered_network = device.get_ordered_network('ssidCCMP') self.assertEqual(ordered_network.type, NetworkType.psk) condition = 'not obj.connected' wd.wait_for_object_condition(ordered_network.network_object, condition) ordered_network.network_object.connect() condition = 'obj.connected' wd.wait_for_object_condition(ordered_network.network_object, condition) device.disconnect() condition = 'not obj.connected' wd.wait_for_object_condition(ordered_network.network_object, condition) wd.unregister_psk_agent(psk_agent)
def test_connection_success(self): hapd = HostapdCLI(config='ssidGroup20.conf') wd = IWD() devices = wd.list_devices(1) device = devices[0] condition = 'not obj.scanning' wd.wait_for_object_condition(device, condition) device.scan() condition = 'not obj.scanning' wd.wait_for_object_condition(device, condition) ordered_network = device.get_ordered_network('ssidGroup20') self.assertEqual(ordered_network.type, NetworkType.open) condition = 'not obj.connected' wd.wait_for_object_condition(ordered_network.network_object, condition) ordered_network.network_object.connect() condition = 'obj.state == DeviceState.connected' wd.wait_for_object_condition(device, condition) testutil.test_iface_operstate() testutil.test_ifaces_connected(device.name, hapd.ifname) device.disconnect() condition = 'not obj.connected' wd.wait_for_object_condition(ordered_network.network_object, condition)
def test_disconnect(self): wd = IWD() devices = wd.list_devices(1) device = devices[0] hostapd_if = list(hostapd_map.values())[0] hostapd = HostapdCLI(hostapd_if) device.scan() condition = 'not obj.scanning' wd.wait_for_object_condition(device, condition) ordered_network = device.get_ordered_network('ssidOpen') ordered_network.network_object.connect() condition = 'obj.state == DeviceState.connected' wd.wait_for_object_condition(device, condition) hostapd.deauthenticate(device.address) condition = 'obj.state == DeviceState.connecting' wd.wait_for_object_condition(device, condition) condition = 'obj.state == DeviceState.connected' wd.wait_for_object_condition(device, condition) device.disconnect() condition = 'obj.state == DeviceState.disconnected' wd.wait_for_object_condition(device, condition)
def test_connection_success(self): wd = IWD() devices = wd.list_devices(); self.assertIsNotNone(devices) device = devices[0] condition = 'not obj.scanning' wd.wait_for_object_condition(device, condition) device.scan() condition = 'not obj.scanning' wd.wait_for_object_condition(device, condition) ordered_networks = device.get_ordered_networks() ordered_network = ordered_networks[0] self.assertEqual(ordered_network.name, "ssidEAP-TTLS") self.assertEqual(ordered_network.type, NetworkType.eap) condition = 'not obj.connected' wd.wait_for_object_condition(ordered_network.network_object, condition) ordered_network.network_object.connect() condition = 'obj.connected' wd.wait_for_object_condition(ordered_network.network_object, condition) device.disconnect() condition = 'not obj.connected' wd.wait_for_object_condition(ordered_network.network_object, condition)
def test_connection_success(self): hostapd = None for wname in wiphy_map: wiphy = wiphy_map[wname] intf = list(wiphy.values())[0] if intf.use == 'hostapd': hostapd = HostapdCLI(intf) break hwsim = Hwsim() wd = IWD() psk_agent = PSKAgent("secret123") wd.register_psk_agent(psk_agent) devices = wd.list_devices(1) device = devices[0] condition = 'not obj.scanning' wd.wait_for_object_condition(device, condition) device.scan() condition = 'not obj.scanning' wd.wait_for_object_condition(device, condition) ordered_networks = device.get_ordered_networks() ordered_network = ordered_networks[0] self.assertEqual(ordered_network.name, "ssidCCMP") self.assertEqual(ordered_network.type, NetworkType.psk) condition = 'not obj.connected' wd.wait_for_object_condition(ordered_network.network_object, condition) ordered_network.network_object.connect() condition = 'obj.connected' wd.wait_for_object_condition(ordered_network.network_object, condition) # Make AP go down ungracefully, when hostapd comes back up it should # send an unprotected disassociate frame so the client will re-auth. # This will kick off the SA Query procedure hostapd.ungraceful_restart() condition = 'not obj.connected' wd.wait_for_object_condition(ordered_network.network_object, condition) # IWD should now try and re-connect to the AP condition = 'obj.connected' wd.wait_for_object_condition(ordered_network.network_object, condition) device.disconnect() condition = 'not obj.connected' wd.wait_for_object_condition(ordered_network.network_object, condition) wd.unregister_psk_agent(psk_agent)
def test_connection_success(self): wd = IWD() devices = wd.list_devices(1) device = devices[0] condition = 'not obj.scanning' wd.wait_for_object_condition(device, condition) device.scan() condition = 'not obj.scanning' wd.wait_for_object_condition(device, condition) ordered_network = device.get_ordered_network('ssidEAP-TTLS') self.assertEqual(ordered_network.type, NetworkType.eap) condition = 'not obj.connected' wd.wait_for_object_condition(ordered_network.network_object, condition) ordered_network.network_object.connect() condition = 'obj.connected' wd.wait_for_object_condition(ordered_network.network_object, condition) testutil.test_iface_operstate() testutil.test_ifaces_connected() device.disconnect() condition = 'not obj.connected' wd.wait_for_object_condition(ordered_network.network_object, condition)
def test_connection_success(self): wd = IWD(True) psk_agent = PSKAgent("InvalidSecret") wd.register_psk_agent(psk_agent) devices = wd.list_devices(1) self.assertIsNotNone(devices) device = devices[0] condition = 'not obj.scanning' wd.wait_for_object_condition(device, condition) device.scan() condition = 'not obj.scanning' wd.wait_for_object_condition(device, condition) ordered_networks = device.get_ordered_networks() network = [x for x in ordered_networks if x.name == "ssidSAE"][0] self.assertIsNotNone(network) self.assertEqual(network.name, "ssidSAE") self.assertEqual(network.type, NetworkType.psk) condition = 'not obj.connected' wd.wait_for_object_condition(network.network_object, condition) with self.assertRaises(iwd.FailedEx): network.network_object.connect() wd.unregister_psk_agent(psk_agent) del wd
def test_connection_success(self): wd = IWD() dev = wd.list_devices(1)[0] with self.assertRaises(iwd.NotSupportedEx): dev.start_ap('TestAP2', 'Password2')
def validate(self, ssid, autoconnect, throws=None, use_agent=False): wd = IWD(True) wd.wait(1) if use_agent: psk_agent = PSKAgent("secret123") wd.register_psk_agent(psk_agent) devices = wd.list_devices() self.assertIsNotNone(devices) device = devices[0] if autoconnect: self.check_autoconnect(wd, device, ssid, throws) else: condition = 'not obj.scanning' wd.wait_for_object_condition(device, condition) device.scan() condition = 'not obj.scanning' wd.wait_for_object_condition(device, condition) self.check_connect(wd, device, ssid, throws) if use_agent: wd.unregister_psk_agent(psk_agent) del wd
def test_connection_success(self): ofono = Ofono() ofono.enable_modem('/phonesim') ofono.wait_for_sim_auth() wd = IWD() devices = wd.list_devices(1) device = devices[0] condition = 'not obj.scanning' wd.wait_for_object_condition(device, condition) device.scan() condition = 'not obj.scanning' wd.wait_for_object_condition(device, condition) ordered_network = device.get_ordered_network('ssidEAP-AKA') self.assertEqual(ordered_network.type, NetworkType.eap) condition = 'not obj.connected' wd.wait_for_object_condition(ordered_network.network_object, condition) ordered_network.network_object.connect() condition = 'obj.state == DeviceState.connected' wd.wait_for_object_condition(device, condition) device.disconnect() condition = 'not obj.connected' wd.wait_for_object_condition(ordered_network.network_object, condition)
def test_invalid_command(self): wd = IWD() device = wd.list_devices(1)[0] with self.assertRaises(subprocess.CalledProcessError): subprocess.check_call(['iwctl', 'inexistent', 'command'])
def test_connection_success(self): wd = IWD(True) devices = wd.list_devices(1) self.assertIsNotNone(devices) device = devices[0] condition = 'not obj.scanning' wd.wait_for_object_condition(device, condition) device.scan() condition = 'not obj.scanning' wd.wait_for_object_condition(device, condition) ordered_networks = device.get_ordered_networks() network = [x for x in ordered_networks if x.name == "ssidSAE"][0] self.assertIsNotNone(network) self.assertEqual(network.name, "ssidSAE") self.assertEqual(network.type, NetworkType.psk) condition = 'obj.connected' wd.wait_for_object_condition(network.network_object, condition) device.wait_for_connected() device.disconnect() condition = 'not obj.connected' wd.wait_for_object_condition(network.network_object, condition) del wd
def test_connection_success(self): hapd = HostapdCLI(config='ssidFILS-256.conf') wd = IWD(True) psk_agent = PSKAgent('*****@*****.**', ('*****@*****.**', 'secret123')) wd.register_psk_agent(psk_agent) devices = wd.list_devices(1) device = devices[0] condition = 'not obj.scanning' wd.wait_for_object_condition(device, condition) device.scan() condition = 'not obj.scanning' wd.wait_for_object_condition(device, condition) ordered_network = device.get_ordered_network('ssidFILS-256') self.assertEqual(ordered_network.type, NetworkType.eap) condition = 'not obj.connected' wd.wait_for_object_condition(ordered_network.network_object, condition) ordered_network.network_object.connect() condition = 'obj.connected' wd.wait_for_object_condition(ordered_network.network_object, condition) testutil.test_iface_operstate() testutil.test_ifaces_connected(device.name, hapd.ifname) device.disconnect() condition = 'not obj.connected' wd.wait_for_object_condition(ordered_network.network_object, condition) ordered_network = device.get_ordered_network('ssidFILS-256') self.assertEqual(ordered_network.type, NetworkType.eap) condition = 'not obj.connected' wd.wait_for_object_condition(ordered_network.network_object, condition) ordered_network.network_object.connect() condition = 'obj.connected' wd.wait_for_object_condition(ordered_network.network_object, condition) testutil.test_iface_operstate() testutil.test_ifaces_connected(device.name, hapd.ifname) device.disconnect() wd.unregister_psk_agent(psk_agent)
def test_connection_success(self): hostapd = None for hostapd_if in list(hostapd_map.values()): hpd = HostapdCLI(hostapd_if) if hpd.get_config_value('ssid') == 'ssidEAP-AKA': hostapd = hpd break self.assertIsNotNone(hostapd) auth = AuthCenter('/tmp/hlrauc.sock', '/tmp/sim.db') wd = IWD() devices = wd.list_devices(1) device = devices[0] condition = 'not obj.scanning' wd.wait_for_object_condition(device, condition) device.scan() condition = 'not obj.scanning' wd.wait_for_object_condition(device, condition) ordered_networks = device.get_ordered_networks() ordered_network = ordered_networks[0] self.assertEqual(ordered_network.name, "ssidEAP-AKA") self.assertEqual(ordered_network.type, NetworkType.eap) condition = 'not obj.connected' wd.wait_for_object_condition(ordered_network.network_object, condition) try: ordered_network.network_object.connect() except: auth.stop() raise condition = 'obj.connected' wd.wait_for_object_condition(ordered_network.network_object, condition) hostapd.eapol_reauth(device.address) wd.wait(10) condition = 'obj.connected' wd.wait_for_object_condition(ordered_network.network_object, condition) device.disconnect() condition = 'not obj.connected' wd.wait_for_object_condition(ordered_network.network_object, condition) auth.stop()
def test_connection_success(self): wd = IWD() dev1, dev2 = wd.list_devices(2) dev1.disconnect() dev2.disconnect() self.client_connect(wd, dev1) dev1.start_ap('TestAP2', 'Password2') try: condition = 'not obj.scanning' wd.wait_for_object_condition(dev2, condition) dev2.scan() condition = 'obj.scanning' wd.wait_for_object_condition(dev2, condition) condition = 'not obj.scanning' wd.wait_for_object_condition(dev2, condition) ordered_networks = dev2.get_ordered_networks() self.assertEqual(len(ordered_networks), 2) networks = {n.name: n for n in ordered_networks} self.assertEqual(networks['TestAP1'].type, NetworkType.psk) self.assertEqual(networks['TestAP2'].type, NetworkType.psk) psk_agent = PSKAgent('Password2') wd.register_psk_agent(psk_agent) try: dev2.disconnect() condition = 'not obj.connected' wd.wait_for_object_condition(dev2, condition) except: pass networks['TestAP2'].network_object.connect() condition = 'obj.connected' wd.wait_for_object_condition(networks['TestAP2'].network_object, condition) testutil.test_iface_operstate(dev2.name) testutil.test_ifaces_connected(dev1.name, dev2.name) wd.unregister_psk_agent(psk_agent) dev2.disconnect() condition = 'not obj.connected' wd.wait_for_object_condition(networks['TestAP2'].network_object, condition) finally: dev1.stop_ap() # Finally test dev1 can go to client mode and connect again self.client_connect(wd, dev1)
def test_connection_success(self): networks = [] wd = IWD(True) psk_agent = PSKAgent(["secret123"] * 4) wd.register_psk_agent(psk_agent) devices = wd.list_devices(4) self.assertIsNotNone(devices) for d in devices: condition = 'not obj.scanning' wd.wait_for_object_condition(d, condition) d.scan() for d in devices: condition = 'not obj.scanning' wd.wait_for_object_condition(d, condition) for i in range(len(devices)): ordered_networks = devices[i].get_ordered_networks() network = [ x for x in ordered_networks if x.name == "ssidSAE-Clogging" ][0] self.assertIsNotNone(network) self.assertEqual(network.name, "ssidSAE-Clogging") self.assertEqual(network.type, NetworkType.psk) networks.append(network) condition = 'not obj.connected' wd.wait_for_object_condition(network.network_object, condition) for n in networks: n.network_object.connect(wait=False) for n in networks: condition = 'obj.connected' wd.wait_for_object_condition(n.network_object, condition) for d in devices: d.wait_for_connected() for d in devices: d.disconnect() for n in networks: condition = 'not obj.connected' wd.wait_for_object_condition(n.network_object, condition) wd.unregister_psk_agent(psk_agent) del wd
def test_connection_success(self): hostapd = None for hostapd_if in list(hostapd_map.values()): hpd = HostapdCLI(hostapd_if) if hpd.get_config_value('ssid') == 'ssidEAP-TTLS-MSCHAP': hostapd = hpd break self.assertIsNotNone(hostapd) wd = IWD() psk_agent = PSKAgent('abc', ('user', 'testpasswd')) wd.register_psk_agent(psk_agent) device = wd.list_devices(1)[0]; condition = 'not obj.scanning' wd.wait_for_object_condition(device, condition) device.scan() condition = 'not obj.scanning' wd.wait_for_object_condition(device, condition) ordered_networks = device.get_ordered_networks() ordered_network = ordered_networks[0] self.assertEqual(ordered_network.name, "ssidEAP-TTLS-MSCHAP") self.assertEqual(ordered_network.type, NetworkType.eap) condition = 'not obj.connected' wd.wait_for_object_condition(ordered_network.network_object, condition) ordered_network.network_object.connect() condition = 'obj.connected' wd.wait_for_object_condition(ordered_network.network_object, condition) hostapd.eapol_reauth(device.address) wd.wait(10) condition = 'obj.connected' wd.wait_for_object_condition(ordered_network.network_object, condition) testutil.test_iface_operstate() testutil.test_ifaces_connected() device.disconnect() condition = 'not obj.connected' wd.wait_for_object_condition(ordered_network.network_object, condition) wd.unregister_psk_agent(psk_agent)
def test_invalid_command_line_option(self): ssid = 'ssidPassphrase' wd = IWD() device = wd.list_devices(1)[0] with self.assertRaises(subprocess.CalledProcessError): subprocess.check_call(['iwctl', '-z', 'station', device.name, 'connect', ssid])
def test_connection_failure(self): ssid = 'ssidPassphrase' wd = IWD() device = wd.list_devices(1)[0] with self.assertRaises(subprocess.CalledProcessError): subprocess.check_call(['iwctl', '-P', 'incorrect_passphrase', 'station', device.name, 'connect', ssid])
def test_connection_with_password(self): ssid = 'ssidPWord' wd = IWD() device = wd.list_devices(1)[0] subprocess.check_call(['iwctl', '-p', 'password', 'station', device.name, 'connect', ssid]) self.check_connection_success(ssid)
def test_connection_success(self): hwsim = Hwsim() hostapd = HostapdCLI(config='ssidCCMP.conf') radio = hwsim.get_radio('rad0') wd = IWD() psk_agent = PSKAgent("secret123") wd.register_psk_agent(psk_agent) devices = wd.list_devices(1) device = devices[0] condition = 'not obj.scanning' wd.wait_for_object_condition(device, condition) device.scan() condition = 'not obj.scanning' wd.wait_for_object_condition(device, condition) ordered_network = device.get_ordered_network('ssidCCMP') self.assertEqual(ordered_network.type, NetworkType.psk) condition = 'not obj.connected' wd.wait_for_object_condition(ordered_network.network_object, condition) ordered_network.network_object.connect() condition = 'obj.connected' wd.wait_for_object_condition(ordered_network.network_object, condition) # TODO: for some reason hostapd does not respond to SA query if done # too soon after connection. sleep(1) # Spoof a disassociate frame. This will kick off SA Query procedure. hwsim.spoof_disassociate(radio, hostapd.get_freq(), device.address) # sleep to ensure hostapd responds and SA Query does not timeout sleep(4) # Since disassociate was spoofed we should still be connected condition = 'obj.connected' wd.wait_for_object_condition(ordered_network.network_object, condition) device.disconnect() condition = 'not obj.connected' wd.wait_for_object_condition(ordered_network.network_object, condition) wd.unregister_psk_agent(psk_agent)
def test_connection_success(self): hwsim = Hwsim() bss_radio = hwsim.get_radio('rad0') rule0 = hwsim.rules.create() rule0.source = bss_radio.addresses[0] rule0.bidirectional = True wd = IWD(True) hapd = HostapdCLI(config='ssidHotspot.conf') psk_agent = PSKAgent('abc', ('domain\\user', 'testpasswd')) wd.register_psk_agent(psk_agent) devices = wd.list_devices(1) device = devices[0] # We are dependent on a periodic scan here. We want to wait for this # because this is the first opportunity IWD has to do ANQP. Once ANQP # has been done once the network is set up and we cannot simulate the # 'Connect() before ANQP' race condition anymore. condition = 'obj.scanning' wd.wait_for_object_condition(device, condition) condition = 'not obj.scanning' wd.wait_for_object_condition(device, condition) ordered_network = device.get_ordered_network('Hotspot') self.assertEqual(ordered_network.type, NetworkType.eap) condition = 'not obj.connected' wd.wait_for_object_condition(ordered_network.network_object, condition) # Force the case where ANQP does not finish before Connect() comes in rule0.delay = 100 ordered_network.network_object.connect() rule0.delay = 1 condition = 'obj.state == DeviceState.connected' wd.wait_for_object_condition(device, condition) testutil.test_iface_operstate() testutil.test_ifaces_connected(device.name, hapd.ifname) device.disconnect() condition = 'not obj.connected' wd.wait_for_object_condition(ordered_network.network_object, condition) wd.unregister_psk_agent(psk_agent)
def test_connection_success(self): hostapd_if = None for hostapd in list(hostapd_map.values()): if hostapd.config == 'ssidSAE.conf': hostapd_if = hostapd.name wd = IWD(True) psk_agent = PSKAgent("secret123") wd.register_psk_agent(psk_agent) devices = wd.list_devices(1) self.assertIsNotNone(devices) device = devices[0] condition = 'not obj.scanning' wd.wait_for_object_condition(device, condition) device.scan() condition = 'not obj.scanning' wd.wait_for_object_condition(device, condition) ordered_networks = device.get_ordered_networks() network = [x for x in ordered_networks if x.name == "ssidSAE"][0] self.assertIsNotNone(network) self.assertEqual(network.name, "ssidSAE") self.assertEqual(network.type, NetworkType.psk) condition = 'not obj.connected' wd.wait_for_object_condition(network.network_object, condition) network.network_object.connect() condition = 'obj.connected' wd.wait_for_object_condition(network.network_object, condition) wd.wait(2) testutil.test_iface_operstate(intf=device.name) testutil.test_ifaces_connected(if0=device.name, if1=hostapd_if) device.disconnect() condition = 'not obj.connected' wd.wait_for_object_condition(network.network_object, condition) wd.unregister_psk_agent(psk_agent) del wd
def test_connection_success(self): hwsim = Hwsim() hostapd = HostapdCLI(config='ssidCCMP.conf') radio = hwsim.get_radio('rad0') wd = IWD() psk_agent = PSKAgent("secret123") wd.register_psk_agent(psk_agent) devices = wd.list_devices(1) device = devices[0] condition = 'not obj.scanning' wd.wait_for_object_condition(device, condition) ordered_network = device.get_ordered_network('ssidCCMP', scan_if_needed=True) self.assertEqual(ordered_network.type, NetworkType.psk) condition = 'not obj.connected' wd.wait_for_object_condition(ordered_network.network_object, condition) ordered_network.network_object.connect() condition = 'obj.state == DeviceState.connected' wd.wait_for_object_condition(device, condition) # Ensure IWD is not scanning. This causes problems with mac80211_hwsim # where CMD_FRAME will fail during a scan. This is due to the frame not # having the same frequency as the radio (since hwsim is off-channel) if device.scanning: condition = 'not obj.scanning' wd.wait_for_object_condition(device, condition) # Spoof a disassociate frame. This will kick off SA Query procedure. hwsim.spoof_disassociate(radio, hostapd.get_freq(), device.address) # sleep to ensure hostapd responds and SA Query does not timeout sleep(4) # Since disassociate was spoofed we should still be connected condition = 'obj.state == DeviceState.connected' wd.wait_for_object_condition(device, condition) device.disconnect() condition = 'not obj.connected' wd.wait_for_object_condition(ordered_network.network_object, condition) wd.unregister_psk_agent(psk_agent)
def test_connection_success(self): hostapd = HostapdCLI(config='ssidCCMP.conf') wd = IWD() psk_agent = PSKAgent("secret123") wd.register_psk_agent(psk_agent) devices = wd.list_devices(1) device = devices[0] condition = 'not obj.scanning' wd.wait_for_object_condition(device, condition) device.scan() condition = 'not obj.scanning' wd.wait_for_object_condition(device, condition) ordered_network = device.get_ordered_network('ssidCCMP') self.assertEqual(ordered_network.type, NetworkType.psk) condition = 'not obj.connected' wd.wait_for_object_condition(ordered_network.network_object, condition) ordered_network.network_object.connect() condition = 'obj.state == DeviceState.connected' wd.wait_for_object_condition(device, condition) # Make AP go down ungracefully, when hostapd comes back up it should # send an unprotected disassociate frame so the client will re-auth. # This will kick off the SA Query procedure hostapd.ungraceful_restart() condition = 'not obj.connected' wd.wait_for_object_condition(ordered_network.network_object, condition) # IWD should now try and re-connect to the AP condition = 'obj.state == DeviceState.connected' wd.wait_for_object_condition(device, condition) hostapd.wait_for_event('AP-STA-CONNECTED') device.disconnect() condition = 'not obj.connected' wd.wait_for_object_condition(ordered_network.network_object, condition) wd.unregister_psk_agent(psk_agent)
def do_test_connection_success(self, ssid, passphrase=None): wd = IWD() if passphrase: psk_agent = PSKAgent(passphrase) wd.register_psk_agent(psk_agent) hostapd_ifname = None for ifname in hostapd.hostapd_map: if ssid + '.conf' in hostapd.hostapd_map[ifname].config: hostapd_ifname = ifname break devices = wd.list_devices(1) device = devices[0] condition = 'not obj.scanning' wd.wait_for_object_condition(device, condition) if not device.get_ordered_networks(): device.scan() condition = 'obj.scanning' wd.wait_for_object_condition(device, condition) condition = 'not obj.scanning' wd.wait_for_object_condition(device, condition) ordered_networks = device.get_ordered_networks() ordered_network = [n for n in ordered_networks if n.name == ssid][0] self.assertEqual(ordered_network.type, NetworkType.eap) condition = 'not obj.connected' wd.wait_for_object_condition(ordered_network.network_object, condition) ordered_network.network_object.connect() condition = 'obj.connected' wd.wait_for_object_condition(ordered_network.network_object, condition) testutil.test_iface_operstate() testutil.test_ifaces_connected(hostapd_ifname, 'wln3') device.disconnect() condition = 'not obj.connected' wd.wait_for_object_condition(ordered_network.network_object, condition) if passphrase: wd.unregister_psk_agent(psk_agent)
def test_connection_success(self): hostapd = HostapdCLI(config='ssidEAP-TTLS-PAP.conf') self.assertIsNotNone(hostapd) wd = IWD() psk_agent = PSKAgent('abc', ('user', 'testpasswd')) wd.register_psk_agent(psk_agent) device = wd.list_devices(1)[0] condition = 'not obj.scanning' wd.wait_for_object_condition(device, condition) device.scan() condition = 'not obj.scanning' wd.wait_for_object_condition(device, condition) ordered_network = device.get_ordered_network('ssidEAP-TTLS-PAP') self.assertEqual(ordered_network.type, NetworkType.eap) condition = 'not obj.connected' wd.wait_for_object_condition(ordered_network.network_object, condition) ordered_network.network_object.connect() condition = 'obj.state == DeviceState.connected' wd.wait_for_object_condition(device, condition) hostapd.eapol_reauth(device.address) hostapd.wait_for_event('CTRL-EVENT-EAP-STARTED') hostapd.wait_for_event('CTRL-EVENT-EAP-SUCCESS') condition = 'obj.state == DeviceState.connected' wd.wait_for_object_condition(device, condition) testutil.test_iface_operstate() testutil.test_ifaces_connected() device.disconnect() condition = 'not obj.connected' wd.wait_for_object_condition(ordered_network.network_object, condition) wd.unregister_psk_agent(psk_agent)