def check_mfp_connection(self, wd, device, ssid, throws_exception): ordered_networks = device.get_ordered_networks() ordered_network = None for o_n in ordered_networks: if o_n.name == ssid: ordered_network = o_n break self.assertEqual(ordered_network.name, ssid) condition = 'not obj.connected' wd.wait_for_object_condition(ordered_network.network_object, condition) if throws_exception: with self.assertRaises(iwd.NotSupportedEx): ordered_network.network_object.connect() return else: 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) IWD.clear_storage()
def test_connection_with_no_agent(self): wd = IWD() with self.assertRaises(iwd.NoAgentEx): self.check_connection(wd, 'ssid1') IWD.clear_storage()
def test_connection_with_own_agent(self): wd = IWD() psk_agent = PSKAgent("secret_ssid1") wd.register_psk_agent(psk_agent) self.check_connection(wd, 'ssid1') wd.unregister_psk_agent(psk_agent) IWD.clear_storage()
def test_connection_with_other_agent(self): wd = IWD() iwctl = subprocess.Popen(['iwctl', '-P', 'secret_ssid2']) # Let iwctl to start and register its agent. wd.wait(2) self.check_connection(wd, 'ssid2') iwctl.terminate() iwctl.communicate() IWD.clear_storage()
def test_8021x(self): tca = TestConnectAutoConnect() tca.validate('ssidEAP-TLS', True, iwd.NotConfiguredEx) IWD.copy_to_storage('ssidEAP-TLS.8021x') tca.validate('ssidEAP-TLS', True) IWD.clear_storage() IWD.copy_to_storage('ssidEAP-Other.8021x') tca.validate('ssidEAP-Other', False, iwd.NotSupportedEx) IWD.clear_storage()
def test_connection_use_own_agent_from_multiple_registered(self): wd = IWD() iwctl = subprocess.Popen(['iwctl', '-P', 'secret_ssid2']) # Let iwctl to start and register its agent. wd.wait(2) psk_agent = PSKAgent("secret_ssid1") wd.register_psk_agent(psk_agent) self.check_connection(wd, 'ssid1') wd.unregister_psk_agent(psk_agent) iwctl.terminate() iwctl.communicate() IWD.clear_storage()
def check_mfp_connection(self, wd, device, ssid, throws_exception): ordered_network = device.get_ordered_network(ssid) condition = 'not obj.connected' wd.wait_for_object_condition(ordered_network.network_object, condition) if throws_exception: with self.assertRaises(iwd.NotSupportedEx): ordered_network.network_object.connect() return else: 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) IWD.clear_storage()
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 stage_iwd(self, config_dir): wd = IWD(True, config_dir) 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) if config_dir == '/tmp/IWD-MFP2': self.check_mfp_connection(wd, device, 'ssidMFP0', True) else: self.check_mfp_connection(wd, device, 'ssidMFP0', False) self.check_mfp_connection(wd, device, 'ssidMFP1', False) if config_dir == '/tmp/IWD-MFP0': self.check_mfp_connection(wd, device, 'ssidMFP2', True) else: self.check_mfp_connection(wd, device, 'ssidMFP2', False) wd.unregister_psk_agent(psk_agent) del wd IWD.clear_storage()
def tearDownClass(cls): IWD.clear_storage() os.remove('/tmp/main.conf')
def test_wpa(self): tca = TestConnectAutoConnect() tca.validate('ssidHiddenWPA', False, None, True) tca.validate('ssidHiddenWPA', True, None, True) IWD.clear_storage()
def tearDownClass(cls): IWD.clear_storage() ctx.stop_process(cls.dhcpd_pid) cls.dhcpd_pid = None os.remove('/tmp/dhcpd.leases')
def tearDownClass(cls): IWD.clear_storage(storage_dir='/tmp/ead') shutil.rmtree('/tmp/ead')
def tearDownClass(cls): IWD.clear_storage() cls.auth.stop() cls.auth = None
def test_open(self): tca = TestConnectAutoConnect() tca.validate('ssidOpen', False) tca.validate('ssidOpen', True) IWD.clear_storage()
def tearDownClass(cls): IWD.clear_storage() cls.dhcpd_pid.kill() os.system('rm -rf /tmp/dhcpd.leases')
def tearDownClass(cls): IWD.clear_storage() cls.bss_hostapd = None cls.bss_radio = None
def tearDownClass(cls): IWD.clear_storage()
def tearDownClass(cls): IWD.clear_storage() cls.hostapd = None