3
0
mirror of https://git.kernel.org/pub/scm/network/wireless/iwd.git synced 2024-11-25 01:19:23 +01:00

auto-t: Support multiple pairwise ciphers in WPA2

This commit is contained in:
Denis Kenzior 2022-10-20 11:27:45 -05:00
parent 8799d5a393
commit e30298d957
5 changed files with 31 additions and 12 deletions

View File

@ -8,20 +8,19 @@ import iwd
from iwd import IWD from iwd import IWD
from iwd import PSKAgent from iwd import PSKAgent
from iwd import NetworkType from iwd import NetworkType
from hostapd import HostapdCLI
import testutil import testutil
class Test(unittest.TestCase): class Test(unittest.TestCase):
def test_connection_success(self): def validate_connection_success(self, wd):
wd = IWD()
psk_agent = PSKAgent("secret123") psk_agent = PSKAgent("secret123")
wd.register_psk_agent(psk_agent) wd.register_psk_agent(psk_agent)
devices = wd.list_devices(1) devices = wd.list_devices(1)
device = devices[0] device = devices[0]
ordered_network = device.get_ordered_network('ssidCCMP') ordered_network = device.get_ordered_network('ssidWPA2')
self.assertEqual(ordered_network.type, NetworkType.psk) self.assertEqual(ordered_network.type, NetworkType.psk)
@ -43,13 +42,32 @@ class Test(unittest.TestCase):
wd.unregister_psk_agent(psk_agent) wd.unregister_psk_agent(psk_agent)
def test_ccmp(self):
self.hostapd.set_value('rsn_pairwise', 'CCMP')
self.hostapd.reload()
self.hostapd.wait_for_event("AP-ENABLED")
self.validate_connection_success(self.wd)
def test_gcmp(self):
self.hostapd.set_value('rsn_pairwise', 'GCMP')
self.hostapd.reload()
self.hostapd.wait_for_event("AP-ENABLED")
self.validate_connection_success(self.wd)
def setUp(self):
self.wd = IWD(True)
def tearDown(self):
self.wd.clear_storage()
self.wd = None
@classmethod @classmethod
def setUpClass(cls): def setUpClass(cls):
pass cls.hostapd = HostapdCLI(config='ssidWPA2.conf')
@classmethod @classmethod
def tearDownClass(cls): def tearDownClass(cls):
IWD.clear_storage() pass
if __name__ == '__main__': if __name__ == '__main__':
unittest.main(exit=True) unittest.main(exit=True)

View File

@ -13,7 +13,7 @@ import testutil
class Test(unittest.TestCase): class Test(unittest.TestCase):
def test_connection_success(self): def test_connection_success(self):
wd = IWD() wd = IWD(True)
psk_agent = PSKAgent("InvalidPassword") psk_agent = PSKAgent("InvalidPassword")
wd.register_psk_agent(psk_agent) wd.register_psk_agent(psk_agent)
@ -22,7 +22,7 @@ class Test(unittest.TestCase):
self.assertIsNotNone(devices) self.assertIsNotNone(devices)
device = devices[0] device = devices[0]
ordered_network = device.get_ordered_network('ssidCCMP') ordered_network = device.get_ordered_network('ssidWPA2')
self.assertEqual(ordered_network.type, NetworkType.psk) self.assertEqual(ordered_network.type, NetworkType.psk)

View File

@ -1,5 +1,6 @@
[SETUP] [SETUP]
num_radios=2 num_radios=2
start_iwd=0
[HOSTAPD] [HOSTAPD]
rad0=ssidCCMP.conf rad0=ssidWPA2.conf

View File

@ -13,7 +13,7 @@ import testutil
class Test(unittest.TestCase): class Test(unittest.TestCase):
def test_connection_success(self): def test_connection_success(self):
wd = IWD() wd = IWD(True)
devices = wd.list_devices(1) devices = wd.list_devices(1)
device = devices[0] device = devices[0]
@ -22,7 +22,7 @@ class Test(unittest.TestCase):
condition = 'obj.state == DeviceState.disconnected' condition = 'obj.state == DeviceState.disconnected'
wd.wait_for_object_condition(device, condition) wd.wait_for_object_condition(device, condition)
ordered_network = device.get_ordered_network("ssidCCMP") ordered_network = device.get_ordered_network("ssidWPA2")
self.assertEqual(ordered_network.type, NetworkType.psk) self.assertEqual(ordered_network.type, NetworkType.psk)
network = ordered_network.network_object network = ordered_network.network_object

View File

@ -1,6 +1,6 @@
hw_mode=g hw_mode=g
channel=1 channel=1
ssid=ssidCCMP ssid=ssidWPA2
wpa=2 wpa=2
wpa_pairwise=CCMP wpa_pairwise=CCMP