2019-04-22 22:32:02 +02:00
|
|
|
#!/usr/bin/python3
|
|
|
|
|
|
|
|
import unittest
|
|
|
|
import sys
|
|
|
|
import os
|
|
|
|
|
|
|
|
sys.path.append('../util')
|
|
|
|
import iwd
|
|
|
|
from iwd import IWD
|
|
|
|
from iwd import NetworkType
|
2019-04-25 21:36:47 +02:00
|
|
|
from hostapd import HostapdCLI
|
2019-04-22 22:32:02 +02:00
|
|
|
import testutil
|
|
|
|
|
|
|
|
class Test(unittest.TestCase):
|
|
|
|
def test_connection_success(self):
|
2019-06-05 23:02:26 +02:00
|
|
|
hapd = HostapdCLI(config='ssidFILS-256.conf')
|
2019-04-25 21:36:47 +02:00
|
|
|
|
2019-04-22 22:32:02 +02:00
|
|
|
wd = IWD(True)
|
|
|
|
|
|
|
|
devices = wd.list_devices(1)
|
|
|
|
device = devices[0]
|
|
|
|
|
|
|
|
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()
|
|
|
|
|
2020-09-14 23:02:33 +02:00
|
|
|
condition = 'obj.state == DeviceState.connected'
|
|
|
|
wd.wait_for_object_condition(device, condition)
|
2019-04-22 22:32:02 +02:00
|
|
|
|
|
|
|
testutil.test_iface_operstate()
|
2019-04-25 21:36:47 +02:00
|
|
|
testutil.test_ifaces_connected(device.name, hapd.ifname)
|
2019-04-22 22:32:02 +02:00
|
|
|
|
|
|
|
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()
|
|
|
|
|
2020-09-14 23:02:33 +02:00
|
|
|
condition = 'obj.state == DeviceState.connected'
|
|
|
|
wd.wait_for_object_condition(device, condition)
|
2019-04-22 22:32:02 +02:00
|
|
|
|
|
|
|
testutil.test_iface_operstate()
|
2019-04-25 21:36:47 +02:00
|
|
|
testutil.test_ifaces_connected(device.name, hapd.ifname)
|
2019-04-22 22:32:02 +02:00
|
|
|
|
2021-09-29 00:36:09 +02:00
|
|
|
hapd.rekey(device.address)
|
|
|
|
|
2019-04-22 22:32:02 +02:00
|
|
|
device.disconnect()
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def setUpClass(cls):
|
|
|
|
IWD.copy_to_storage('ssidFILS-256.8021x')
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def tearDownClass(cls):
|
|
|
|
IWD.clear_storage()
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
unittest.main(exit=True)
|