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

auto-t: Add test for extended key IDs

This commit is contained in:
James Prestwood 2021-10-08 11:07:25 -07:00 committed by Denis Kenzior
parent 1ec6c46a1d
commit adceab280b
4 changed files with 131 additions and 0 deletions

View File

@ -0,0 +1,112 @@
#!/usr/bin/python3
import unittest
import sys
import os
sys.path.append('../util')
from iwd import IWD_CONFIG_DIR
from iwd import IWD
from iwd import PSKAgent
from iwd import NetworkType
from hwsim import Hwsim
from hostapd import HostapdCLI
import testutil
class Test(unittest.TestCase):
def validate(self, wd, resend_m3=False):
hapd = HostapdCLI('ssidCCMP.conf')
psk_agent = PSKAgent("secret123")
wd.register_psk_agent(psk_agent)
devices = wd.list_devices(1)
device = devices[0]
ordered_network = device.get_ordered_network('ssidCCMP')
self.assertEqual(ordered_network.type, NetworkType.psk)
condition = 'not obj.connected'
wd.wait_for_object_condition(ordered_network.network_object, condition)
ordered_network.network_object.connect()
condition = 'obj.state == DeviceState.connected'
wd.wait_for_object_condition(device, condition)
testutil.test_iface_operstate()
testutil.test_ifaces_connected()
# Rekey 5 times just to make sure the key ID can be toggled back and
# forth without causing problems.
for i in range(5):
hapd.rekey(device.address)
if resend_m3:
hapd.resend_m3(device.address)
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)
def test_ext_key_control_port(self):
self.hapd.set_value('extended_key_id', '1')
self.hapd.reload()
self.wd = IWD(True)
self.validate(self.wd)
def test_ext_key_control_port_retransmit(self):
self.hapd.set_value('extended_key_id', '1')
self.hapd.reload()
self.wd = IWD(True)
self.validate(self.wd, resend_m3=True)
def test_ext_key_index_1(self):
self.hapd.set_value('extended_key_id', '2')
self.hapd.reload()
self.wd = IWD(True)
self.validate(self.wd)
def test_ext_key_pae(self):
self.hapd.set_value('extended_key_id', '1')
self.hapd.reload()
IWD.copy_to_storage('main_pae.conf', storage_dir=IWD_CONFIG_DIR, name='main.conf')
self.wd = IWD(True)
self.validate(self.wd)
def tearDown(self):
try:
os.system('rm -rf %s/main.conf' % IWD_CONFIG_DIR)
except:
pass
self.wd = None
@classmethod
def setUpClass(cls):
cls.hapd = HostapdCLI()
@classmethod
def tearDownClass(cls):
IWD.clear_storage()
cls.hapd = None
if __name__ == '__main__':
unittest.main(exit=True)

View File

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

View File

@ -0,0 +1,2 @@
[General]
ControlPortOverNL80211=false

View File

@ -0,0 +1,11 @@
hw_mode=g
channel=1
ssid=ssidCCMP
wpa=2
wpa_pairwise=CCMP
wpa_passphrase=secret123
ieee80211w=2
wpa_key_mgmt=WPA-PSK-SHA256
extended_key_id=1