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): 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 client_connect(self, wd, dev): condition = 'not obj.scanning' wd.wait_for_object_condition(dev, condition) if not dev.get_ordered_networks(): dev.scan() condition = 'obj.scanning' wd.wait_for_object_condition(dev, condition) condition = 'not obj.scanning' wd.wait_for_object_condition(dev, condition) ordered_network = dev.get_ordered_network('TestAP1') self.assertEqual(ordered_network.type, NetworkType.psk) psk_agent = PSKAgent('Password1') wd.register_psk_agent(psk_agent) ordered_network.network_object.connect() condition = 'obj.connected' wd.wait_for_object_condition(ordered_network.network_object, condition) wd.unregister_psk_agent(psk_agent) testutil.test_iface_operstate(dev.name) testutil.test_ifaces_connected( list(hostapd.hostapd_map.keys())[0], dev.name) dev.disconnect() condition = 'not obj.connected' wd.wait_for_object_condition(ordered_network.network_object, condition)
def validate_connection(self, wd): dev1, dev2 = wd.list_devices(2) self.assertIsNotNone(dev1) self.assertIsNotNone(dev2) adhoc1 = dev1.start_adhoc("AdHocNetwork") condition = 'obj.started == True' wd.wait_for_object_condition(adhoc1, condition) adhoc2 = dev2.start_adhoc("AdHocNetwork") condition = 'obj.started == True' wd.wait_for_object_condition(adhoc1, condition) condition = '"%s" in obj.connected_peers' % dev2.address wd.wait_for_object_condition(adhoc1, condition) condition = '"%s" in obj.connected_peers' % dev1.address wd.wait_for_object_condition(adhoc2, condition) testutil.test_iface_operstate(dev1.name) testutil.test_iface_operstate(dev2.name) testutil.test_ifaces_connected(dev1.name, dev2.name)
def try_connection(self, wd): devices = wd.list_devices(1) device = devices[0] 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) testutil.test_iface_operstate() testutil.test_ifaces_connected() device.disconnect() condition = 'not obj.connected' wd.wait_for_object_condition(ordered_network.network_object, condition) return device.address
def do_connect(self, wd, device, hostapd): condition = 'not obj.scanning' wd.wait_for_object_condition(device, condition) device.scan() 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('testSSID') 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) testutil.test_iface_operstate() testutil.test_ifaces_connected(device.name, hostapd.ifname) device.disconnect() condition = 'not obj.connected' wd.wait_for_object_condition(ordered_network.network_object, condition)
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): 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): 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_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 validate_connection(self, wd): hostapd_if = None for hostapd in hostapd_map.values(): if hostapd.config == 'ssidSAE.conf': hostapd_if = hostapd.name psk_agent = PSKAgent("secret123") wd.register_psk_agent(psk_agent) devices = wd.list_devices(4) self.assertIsNotNone(devices) device = devices[0] # These devices aren't used in this test, this makes logs a bit nicer # since these devices would presumably start autoconnecting. devices[1].disconnect() devices[2].disconnect() devices[3].disconnect() condition = 'not obj.scanning' wd.wait_for_object_condition(device, condition) device.scan() condition = 'not obj.scanning' wd.wait_for_object_condition(device, condition) network = device.get_ordered_network('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)
def validate_connection(self, wd): hostapd = None for hostapd_if in list(hostapd_map.values()): hpd = HostapdCLI(hostapd_if) if hpd.get_config_value('ssid') == 'ssidEAP-PEAPv0-NoISK': hostapd = hpd break self.assertIsNotNone(hostapd) 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_network = device.get_ordered_network('ssidEAP-PEAPv0-NoISK') 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)
def validate_connection(self, wd): hostapd = HostapdCLI(config='ssidEAP-TTLS-MSCHAPv2.conf') self.assertIsNotNone(hostapd) psk_agent = PSKAgent('abc', ('domain\\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-MSCHAPv2") 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)
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 validate_connection(self, wd): dev1, dev2 = wd.list_devices(2) self.assertIsNotNone(dev1) self.assertIsNotNone(dev2) dev1.start_adhoc("AdHocNetwork", "secret123") dev2.start_adhoc("AdHocNetwork", "secret123") dev1.adhoc_wait_for_connected(dev2.address) dev2.adhoc_wait_for_connected(dev1.address) testutil.test_iface_operstate(dev1.name) testutil.test_iface_operstate(dev2.name) testutil.test_ifaces_connected(dev1.name, dev2.name)
def check_connection(self, wd, ssid): device = wd.list_devices(1)[0] ordered_network = device.get_ordered_network(ssid, scan_if_needed=True) ordered_network.network_object.connect() condition = 'obj.state == DeviceState.connected' wd.wait_for_object_condition(device, condition) condition = 'obj.connected_network is not None' wd.wait_for_object_condition(device, condition) testutil.test_iface_operstate(device.name) device.disconnect() condition = 'obj.state == DeviceState.disconnected' wd.wait_for_object_condition(device, condition)
def validate_connection(self, wd): hostapd = HostapdCLI(config='ssidEAP-PEAPv0-NoISK.conf') self.assertIsNotNone(hostapd) 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_network = device.get_ordered_network('ssidEAP-PEAPv0-NoISK') 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)
def do_test_connection_success(self, ssid, passphrase=None): hapd = HostapdCLI(config=ssid + '.conf') wd = IWD() if passphrase: psk_agent = PSKAgent(passphrase) 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) 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_network = device.get_ordered_network(ssid) 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(hapd.ifname, device.name) 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): wd = IWD() psk_agent = PSKAgent('abc', ('user', 'testpasswd')) 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) 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 = 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) 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_connection_success(self): wd = IWD(True) dev1, dev2 = wd.list_devices(2) self.assertIsNotNone(dev1) self.assertIsNotNone(dev2) dev1.start_adhoc("AdHocNetwork", "secret123") sleep(1) dev2.start_adhoc("AdHocNetwork", "secret123") dev1.adhoc_wait_for_connected(dev2.address) dev2.adhoc_wait_for_connected(dev1.address) testutil.test_iface_operstate(dev1.name) testutil.test_iface_operstate(dev2.name) testutil.test_ifaces_connected(dev1.name, dev2.name) del wd
def test_connection_success(self): wd = IWD() psk_agent = PSKAgent("secret123") wd.register_psk_agent(psk_agent) 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, "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) 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_connection_success(self): wd = IWD(True, '/tmp') 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] 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('Hotspot') 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) wd.unregister_psk_agent(psk_agent)
def test_connection_success(self): 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('ssidTKIP') 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) 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_connection(self): wd = IWD(True) psk_agent = PSKAgent("secret123") wd.register_psk_agent(psk_agent) device = wd.list_devices(1)[0] ordered_network = device.get_ordered_network('ssidOpen', scan_if_needed=True) device.connect_hidden_network_async(name='ssidSomeHidden', reply_handler=self._success, error_handler=self._failure) ordered_network.network_object.connect() condition = 'obj.state == DeviceState.connected' wd.wait_for_object_condition(device, condition) condition = 'obj.connected_network is not None' wd.wait_for_object_condition(device, condition) testutil.test_iface_operstate(device.name) device.disconnect() condition = 'obj.state == DeviceState.disconnected' wd.wait_for_object_condition(device, condition) wd.unregister_psk_agent(psk_agent) IWD.clear_storage() while not self._done: time.sleep(.300) if self._ex is not None: if self._ex.get_dbus_name() != 'net.connman.iwd.Failed': raise self._ex
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, "ssidOpen") 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.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 client_connect(self, wd, dev): hostapd = HostapdCLI(config='psk-ccmp.conf') ordered_network = dev.get_ordered_network('TestAP1', True) self.assertEqual(ordered_network.type, NetworkType.psk) psk_agent = PSKAgent('Password1') wd.register_psk_agent(psk_agent) ordered_network.network_object.connect() condition = 'obj.state == DeviceState.connected' wd.wait_for_object_condition(dev, condition) wd.unregister_psk_agent(psk_agent) testutil.test_iface_operstate(dev.name) testutil.test_ifaces_connected(hostapd.ifname, dev.name) dev.disconnect() condition = 'not obj.connected' wd.wait_for_object_condition(ordered_network.network_object, condition)
def test_roam_success(self): hwsim = Hwsim() rule0 = hwsim.rules.create() rule0.source = self.bss_radio[0].addresses[0] rule0.bidirectional = True rule1 = hwsim.rules.create() rule1.source = self.bss_radio[1].addresses[0] rule1.bidirectional = True wd = IWD() psk_agent = PSKAgent("EasilyGuessedPassword") wd.register_psk_agent(psk_agent) device = wd.list_devices(1)[0] # Check that iwd selects BSS 0 first rule0.signal = -2000 rule1.signal = -2500 condition = 'not obj.scanning' wd.wait_for_object_condition(device, condition) device.scan() 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('TestFT') self.assertEqual(ordered_network.type, NetworkType.psk) self.assertEqual(ordered_network.signal_strength, -2000) condition = 'not obj.connected' wd.wait_for_object_condition(ordered_network.network_object, condition) self.assertFalse(self.bss_hostapd[0].list_sta()) self.assertFalse(self.bss_hostapd[1].list_sta()) ordered_network.network_object.connect() condition = 'obj.connected' wd.wait_for_object_condition(ordered_network.network_object, condition) self.assertTrue(self.bss_hostapd[0].list_sta()) self.assertFalse(self.bss_hostapd[1].list_sta()) wd.unregister_psk_agent(psk_agent) testutil.test_iface_operstate(device.name) testutil.test_ifaces_connected(self.bss_hostapd[0].ifname, device.name) self.assertRaises(Exception, testutil.test_ifaces_connected, (self.bss_hostapd[1].ifname, device.name)) # Check that iwd starts transition to BSS 1 in less than 10 seconds. # The 10 seconds is longer than needed to scan on just two channels # but short enough that a full scan on the 2.4 + 5.8 bands supported # by mac80211_hwsim will not finish. If this times out then, but # device_roam_trigger_cb has happened, it probably means that # Neighbor Reports are broken. rule0.signal = -8000 condition = 'obj.state == DeviceState.roaming' wd.wait_for_object_condition(device, condition, 10) # Check that iwd is on BSS 1 once out of roaming state and doesn't # go through 'disconnected', 'autoconnect', 'connecting' in between condition = 'obj.state != DeviceState.roaming' wd.wait_for_object_condition(device, condition, 5) self.assertEqual(device.state, iwd.DeviceState.connected) self.assertTrue(self.bss_hostapd[1].list_sta()) testutil.test_iface_operstate(device.name) testutil.test_ifaces_connected(self.bss_hostapd[1].ifname, device.name) self.assertRaises(Exception, testutil.test_ifaces_connected, (self.bss_hostapd[0].ifname, device.name))
def test_connection_success(self): wd = IWD(True, '/tmp/dhcp') # dev1, dev3, and dev4 are all AP's # The configured IP range only supports 2 subnets, so dev4 should fail # to start AP. dev1, dev2, dev3, dev4 = wd.list_devices(4) dev1.start_ap('TestAP2', "Password2") dev3.start_ap('TestAP3', 'Password3') with self.assertRaises(iwd.AlreadyExistsEx): dev4.start_ap('TestAP4', 'Password4') 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['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.state == DeviceState.connected' wd.wait_for_object_condition(dev2, condition) testutil.test_iface_operstate(dev2.name) testutil.test_ifaces_connected(dev1.name, dev2.name, group=False) try: testutil.test_ip_address_match(dev1.name, "192.168.80.1") testutil.test_ip_address_match(dev2.name, "192.168.80.2") ip = "192.168.80.1" except: testutil.test_ip_address_match(dev1.name, "192.168.80.17") testutil.test_ip_address_match(dev2.name, "192.168.80.18") ip = "192.168.80.17" wd.unregister_psk_agent(psk_agent) dev2.disconnect() condition = 'not obj.connected' wd.wait_for_object_condition(networks['TestAP2'].network_object, condition) # This should release the IP */ dev1.stop_ap() # This should now succeed and the IP should match the old IP dev1 # got initially. dev4.start_ap('TestAP4', 'Password4') testutil.test_ip_address_match(dev4.name, ip) finally: dev1.stop_ap()
def test_fast_retry(self): hwsim = Hwsim() bss_hostapd = [ HostapdCLI(config='ssid1.conf'), HostapdCLI(config='ssid2.conf') ] bss_radio = [hwsim.get_radio('rad0'), hwsim.get_radio('rad1')] rule0 = hwsim.rules.create() rule0.source = bss_radio[0].addresses[0] rule0.bidirectional = True rule1 = hwsim.rules.create() rule1.source = bss_radio[1].addresses[0] rule1.bidirectional = True # Fill in the neighbor AP tables in both BSSes. By default each # instance knows only about current BSS, even inside one hostapd # process. # Roaming still works without the neighbor AP table but neighbor # reports have to be disabled in the .conf files bss0_nr = ''.join(bss_radio[0].addresses[0].split(':')) + \ '8f0000005101060603000000' bss1_nr = ''.join(bss_radio[1].addresses[0].split(':')) + \ '8f0000005102060603000000' bss_hostapd[0].set_neighbor(bss_radio[1].addresses[0], 'TestRoamRetry', bss1_nr) bss_hostapd[1].set_neighbor(bss_radio[0].addresses[0], 'TestRoamRetry', bss0_nr) # Start in the vicinity of BSS 0, check that iwd connects to BSS 0 rule0.signal = -2000 rule1.signal = -8500 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('TestRoamRetry') 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) self.assertTrue(bss_hostapd[0].list_sta()) self.assertFalse(bss_hostapd[1].list_sta()) wd.wait(5) # Now push the signal LOW, wait for iwd to attempt a roam, fail, and # schedule another attempt for 60 seconds later rule0.signal = -8000 wd.wait(20) self.assertEqual(device.state, iwd.DeviceState.connected) self.assertTrue(bss_hostapd[0].list_sta()) self.assertFalse(bss_hostapd[1].list_sta()) testutil.test_iface_operstate(device.name) testutil.test_ifaces_connected(bss_hostapd[0].ifname, device.name) # Assert high signal for BSS 0 again. This clears the way for a faster # roam attempt on LOW again rule0.signal = -5000 # Wait a little for signal recognition wd.wait(1) # Assert low signal for BSS 0, check that iwd starts transition to BSS 1 # in less than 10 seconds. Because of the neighbor report a scan should # not be necessary. rule0.signal = -8000 rule1.signal = -2000 condition = 'obj.state == DeviceState.roaming' wd.wait_for_object_condition(device, condition, max_wait=10) # Check that iwd is on BSS 1 once out of roaming state and doesn't # go through 'disconnected', 'autoconnect', 'connecting' in between from_condition = 'obj.state == DeviceState.roaming' to_condition = 'obj.state == DeviceState.connected' wd.wait_for_object_change(device, from_condition, to_condition) self.assertTrue(bss_hostapd[1].list_sta()) device.disconnect() condition = 'not obj.connected' wd.wait_for_object_condition(ordered_network.network_object, condition) wd.unregister_psk_agent(psk_agent) rule0.remove() rule1.remove()