mirror of
https://git.kernel.org/pub/scm/network/wireless/iwd.git
synced 2024-11-16 17:09:24 +01:00
auto-t: add DPP tests for state change checks
This commit is contained in:
parent
eff2a2afcf
commit
a63fd6abb9
@ -4,7 +4,7 @@ import unittest
|
||||
import sys
|
||||
|
||||
sys.path.append('../util')
|
||||
from iwd import IWD, SharedCodeAgent
|
||||
from iwd import IWD, SharedCodeAgent, DeviceState
|
||||
from iwd import DeviceProvisioning
|
||||
from wpas import Wpas
|
||||
from hostapd import HostapdCLI
|
||||
@ -210,6 +210,24 @@ class Test(unittest.TestCase):
|
||||
|
||||
self.assertIn("SendHostname=true", settings)
|
||||
|
||||
def test_existing_incorrect_profile(self):
|
||||
self.hapd.reload()
|
||||
self.hapd.wait_for_event('AP-ENABLED')
|
||||
IWD.copy_to_storage("existingProfile.psk", "/tmp/ns0/", "ssidCCMP.psk")
|
||||
|
||||
# Start connecting
|
||||
self.device[1].autoconnect = True
|
||||
self.wd.wait_for_object_condition(self.device[1], 'obj.state == DeviceState.connecting')
|
||||
|
||||
# We should be able to start DPP despite the connecting state
|
||||
self.device[1].dpp_pkex_enroll('secret123', identifier="test")
|
||||
|
||||
self.start_iwd_pkex_configurator(self.device[0])
|
||||
self.assertEqual(self.device[1].state, DeviceState.disconnected)
|
||||
|
||||
condition = 'obj.state == DeviceState.connected'
|
||||
self.wd.wait_for_object_condition(self.device[1], condition)
|
||||
|
||||
def test_existing_hidden_network(self):
|
||||
self.hapd_hidden.reload()
|
||||
self.hapd_hidden.wait_for_event('AP-ENABLED')
|
||||
|
107
autotests/testDPP/state_change_test.py
Normal file
107
autotests/testDPP/state_change_test.py
Normal file
@ -0,0 +1,107 @@
|
||||
#!/usr/bin/python3
|
||||
|
||||
import unittest
|
||||
import sys
|
||||
|
||||
sys.path.append('../util')
|
||||
from iwd import IWD, SharedCodeAgent, DeviceState
|
||||
from iwd import DeviceProvisioning
|
||||
from wpas import Wpas
|
||||
from hostapd import HostapdCLI
|
||||
from hwsim import Hwsim
|
||||
from config import ctx
|
||||
from time import time
|
||||
import os
|
||||
|
||||
class Test(unittest.TestCase):
|
||||
def auto_connect(self):
|
||||
IWD.copy_to_storage('ssidCCMP.psk')
|
||||
self.device.autoconnect = True
|
||||
|
||||
condition = 'obj.state == DeviceState.connected'
|
||||
self.wd.wait_for_object_condition(self.device, condition)
|
||||
|
||||
def test_configurator_stops_on_disconnect(self):
|
||||
self.auto_connect()
|
||||
|
||||
self.device.dpp_start_configurator()
|
||||
|
||||
self.device.disconnect()
|
||||
|
||||
condition = 'obj.state == DeviceState.disconnected'
|
||||
self.wd.wait_for_object_condition(self.device, condition)
|
||||
|
||||
self.assertEqual(self.device._device_provisioning.started, False)
|
||||
|
||||
def test_enrollee_stops_on_connect(self):
|
||||
# Scan to get a list of networks
|
||||
self.device.scan()
|
||||
self.wd.wait_for_object_condition(self.device, 'obj.scanning == True')
|
||||
self.wd.wait_for_object_condition(self.device, 'obj.scanning == False')
|
||||
|
||||
self.device.dpp_start_enrollee()
|
||||
|
||||
network = self.device.get_ordered_network("ssidCCMP")
|
||||
network.network_object.connect()
|
||||
|
||||
condition = 'obj.state == DeviceState.connected'
|
||||
self.wd.wait_for_object_condition(self.device, condition)
|
||||
|
||||
self.assertEqual(self.device._device_provisioning.started, False)
|
||||
|
||||
def test_enrollee_disconnects_automatically(self):
|
||||
self.auto_connect()
|
||||
|
||||
self.device.dpp_start_enrollee()
|
||||
|
||||
condition = 'obj.state == DeviceState.disconnected'
|
||||
self.wd.wait_for_object_condition(self.device, condition)
|
||||
|
||||
def test_enrollee_autoconnect_stays_on(self):
|
||||
# Put in an autoconnecting state, no saved profile though
|
||||
self.device.autoconnect = True
|
||||
|
||||
self.device.dpp_start_enrollee()
|
||||
|
||||
# DPP should set autoconnect false, but then re-enable after it stops
|
||||
self.wd.wait_for_object_condition(self.device, "obj.autoconnect == False")
|
||||
self.wd.wait_for_object_condition(self.device._device_provisioning, "obj.started == True")
|
||||
|
||||
# Stop DPP
|
||||
self.device.dpp_stop()
|
||||
self.wd.wait_for_object_condition(self.device, "obj.autoconnect == True")
|
||||
|
||||
def test_enrollee_autoconnect_stays_off(self):
|
||||
# Autoconnect should be off by default
|
||||
|
||||
self.device.dpp_start_enrollee()
|
||||
|
||||
# DPP should set autoconnect false, but stay off after it stops
|
||||
self.wd.wait_for_object_condition(self.device, "obj.autoconnect == False")
|
||||
self.wd.wait_for_object_condition(self.device._device_provisioning, "obj.started == True")
|
||||
|
||||
# Stop DPP
|
||||
self.device.dpp_stop()
|
||||
self.wd.wait_for_object_condition(self.device, "obj.autoconnect == False")
|
||||
|
||||
def setUp(self):
|
||||
self.wd = IWD(True)
|
||||
self.device = self.wd.list_devices(1)[0]
|
||||
|
||||
def tearDown(self):
|
||||
self.wd.stop()
|
||||
self.wd = None
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
hapd = HostapdCLI(config="hostapd.conf")
|
||||
hapd.reload()
|
||||
|
||||
hapd.wait_for_event("AP-ENABLED")
|
||||
|
||||
@classmethod
|
||||
def tearDownClass(cls):
|
||||
pass
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main(exit=True)
|
Loading…
Reference in New Issue
Block a user