2016-12-14 23:15:31 +01:00
|
|
|
#!/usr/bin/python3
|
|
|
|
|
|
|
|
import unittest
|
|
|
|
import sys
|
|
|
|
|
|
|
|
sys.path.append('../util')
|
|
|
|
import iwd
|
|
|
|
from iwd import IWD
|
|
|
|
from iwd import NetworkType
|
|
|
|
|
|
|
|
class Test(unittest.TestCase):
|
|
|
|
|
2021-08-13 21:55:07 +02:00
|
|
|
def run_connection_test(self, *secrets):
|
2016-12-14 23:15:31 +01:00
|
|
|
wd = IWD()
|
|
|
|
|
2018-06-13 18:58:32 +02:00
|
|
|
psk_agent = iwd.PSKAgent(*secrets)
|
|
|
|
wd.register_psk_agent(psk_agent)
|
|
|
|
|
2018-12-14 20:15:26 +01:00
|
|
|
devices = wd.list_devices(1)
|
2016-12-14 23:15:31 +01:00
|
|
|
device = devices[0]
|
|
|
|
|
|
|
|
condition = 'not obj.scanning'
|
|
|
|
wd.wait_for_object_condition(device, condition)
|
|
|
|
|
2018-06-13 18:58:32 +02:00
|
|
|
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)
|
2016-12-14 23:15:31 +01:00
|
|
|
|
2021-08-13 21:55:07 +02:00
|
|
|
ordered_network = device.get_ordered_network("ssidEAP-MSCHAPV2")
|
2018-12-14 20:15:28 +01:00
|
|
|
|
|
|
|
self.assertEqual(ordered_network.type, NetworkType.eap)
|
2016-12-14 23:15:31 +01:00
|
|
|
|
|
|
|
condition = 'not obj.connected'
|
|
|
|
wd.wait_for_object_condition(ordered_network.network_object, condition)
|
|
|
|
|
|
|
|
ordered_network.network_object.connect()
|
|
|
|
|
2020-09-14 23:02:33 +02:00
|
|
|
condition = 'obj.state == DeviceState.connected'
|
|
|
|
wd.wait_for_object_condition(device, condition)
|
2016-12-14 23:15:31 +01:00
|
|
|
|
2018-06-13 18:58:32 +02:00
|
|
|
wd.unregister_psk_agent(psk_agent)
|
|
|
|
|
2016-12-14 23:15:31 +01:00
|
|
|
device.disconnect()
|
|
|
|
|
|
|
|
condition = 'not obj.connected'
|
|
|
|
wd.wait_for_object_condition(ordered_network.network_object, condition)
|
|
|
|
|
2018-06-13 18:58:32 +02:00
|
|
|
def test_agent_none(self):
|
2021-08-13 21:55:07 +02:00
|
|
|
IWD.copy_to_storage('ssidEAP-MSCHAPV2-1.8021x', name='ssidEAP-MSCHAPV2.8021x')
|
|
|
|
self.run_connection_test()
|
2018-06-13 18:58:32 +02:00
|
|
|
|
|
|
|
def test_agent_none_hash(self):
|
2021-08-13 21:55:07 +02:00
|
|
|
IWD.copy_to_storage('ssidEAP-MSCHAPV2-2.8021x', name='ssidEAP-MSCHAPV2.8021x')
|
|
|
|
self.run_connection_test()
|
2018-06-13 18:58:32 +02:00
|
|
|
|
|
|
|
def test_agent_passwd(self):
|
2021-08-13 21:55:07 +02:00
|
|
|
IWD.copy_to_storage('ssidEAP-MSCHAPV2-3.8021x', name='ssidEAP-MSCHAPV2.8021x')
|
|
|
|
self.run_connection_test([], ('domain\\User', 'Password'))
|
2018-06-13 18:58:32 +02:00
|
|
|
|
|
|
|
def test_agent_username_and_passwd(self):
|
2021-08-13 21:55:07 +02:00
|
|
|
IWD.copy_to_storage('ssidEAP-MSCHAPV2-4.8021x', name='ssidEAP-MSCHAPV2.8021x')
|
|
|
|
self.run_connection_test([], ('domain\\User', 'Password'))
|
2018-06-13 18:58:32 +02:00
|
|
|
|
2016-12-14 23:15:31 +01:00
|
|
|
@classmethod
|
|
|
|
def setUpClass(cls):
|
2021-08-13 21:55:07 +02:00
|
|
|
pass
|
2016-12-14 23:15:31 +01:00
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def tearDownClass(cls):
|
|
|
|
IWD.clear_storage()
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
unittest.main(exit=True)
|