2019-01-10 23:34:29 +01:00
|
|
|
#!/usr/bin/python3
|
|
|
|
|
|
|
|
import unittest
|
|
|
|
import sys
|
|
|
|
|
|
|
|
sys.path.append('../util')
|
|
|
|
import iwd
|
|
|
|
import testutil
|
|
|
|
from iwd import IWD
|
|
|
|
from iwd import PSKAgent
|
|
|
|
from iwd import NetworkType
|
|
|
|
|
|
|
|
from hostapd import HostapdCLI
|
|
|
|
|
|
|
|
class Test(unittest.TestCase):
|
|
|
|
|
2019-03-15 23:02:48 +01:00
|
|
|
def validate_connection(self, wd):
|
2019-11-14 20:58:06 +01:00
|
|
|
hostapd = HostapdCLI(config='ssidEAP-TTLS-MSCHAPv2.conf')
|
2019-01-10 23:34:29 +01:00
|
|
|
|
|
|
|
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()
|
|
|
|
|
2020-09-14 23:02:33 +02:00
|
|
|
condition = 'obj.state == DeviceState.connected'
|
|
|
|
wd.wait_for_object_condition(device, condition)
|
2019-01-10 23:34:29 +01:00
|
|
|
|
|
|
|
hostapd.eapol_reauth(device.address)
|
|
|
|
|
2020-07-08 19:48:01 +02:00
|
|
|
hostapd.wait_for_event('CTRL-EVENT-EAP-STARTED')
|
|
|
|
hostapd.wait_for_event('CTRL-EVENT-EAP-SUCCESS')
|
2019-01-10 23:34:29 +01:00
|
|
|
|
2020-09-14 23:02:33 +02:00
|
|
|
condition = 'obj.state == DeviceState.connected'
|
|
|
|
wd.wait_for_object_condition(device, condition)
|
2019-01-10 23:34:29 +01:00
|
|
|
|
|
|
|
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)
|
|
|
|
|
2019-03-15 23:02:48 +01:00
|
|
|
def test_connection_success(self):
|
|
|
|
wd = IWD(True)
|
|
|
|
|
2019-04-20 22:29:05 +02:00
|
|
|
self.validate_connection(wd)
|
2019-01-10 23:34:29 +01:00
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def setUpClass(cls):
|
|
|
|
IWD.copy_to_storage('ssidEAP-TTLS-MSCHAPv2.8021x')
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def tearDownClass(cls):
|
|
|
|
IWD.clear_storage()
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
unittest.main(exit=True)
|