mirror of
https://git.kernel.org/pub/scm/network/wireless/iwd.git
synced 2024-11-29 05:39:24 +01:00
auto-t: add test for the hidden networks
This commit is contained in:
parent
48e9f2aee0
commit
4f953586e6
42
autotests/testHiddenNetworks/exceptions_test.py
Normal file
42
autotests/testHiddenNetworks/exceptions_test.py
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
#!/usr/bin/python3
|
||||||
|
|
||||||
|
import unittest
|
||||||
|
import sys
|
||||||
|
|
||||||
|
sys.path.append('../util')
|
||||||
|
import iwd
|
||||||
|
import validation
|
||||||
|
from validation import TestConnectAutoconnect
|
||||||
|
from iwd import IWD
|
||||||
|
|
||||||
|
class TestWpaNetwork(unittest.TestCase):
|
||||||
|
'''
|
||||||
|
The bellow test cases excesise the following connection scenarios:
|
||||||
|
|
||||||
|
Network config is
|
||||||
|
present at start time: Connect: Autoconnect: Result:
|
||||||
|
--------------------------------------------------------------------------
|
||||||
|
False True NotFoundEx raised
|
||||||
|
False True ServiceSetOverlapEx raised
|
||||||
|
False True NotHiddenEx raised
|
||||||
|
True True AlreadyProvisionedEx raised
|
||||||
|
'''
|
||||||
|
|
||||||
|
def test_wpa(self):
|
||||||
|
tca = TestConnectAutoconnect()
|
||||||
|
|
||||||
|
tca.validate('UnExistingNetwork', False, iwd.NotFoundEx)
|
||||||
|
tca.validate('ssidOverlap', False, iwd.ServiceSetOverlapEx)
|
||||||
|
tca.validate('ssidOpen', False, iwd.NotHiddenEx, False, True)
|
||||||
|
tca.validate('ssidAlreadyKnown', False, iwd.AlreadyProvisionedEx)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def setUpClass(cls):
|
||||||
|
IWD.copy_to_storage('ssidAlreadyKnown.open')
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def tearDownClass(cls):
|
||||||
|
IWD.clear_storage()
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
unittest.main(exit=True)
|
11
autotests/testHiddenNetworks/hw.conf
Normal file
11
autotests/testHiddenNetworks/hw.conf
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
[SETUP]
|
||||||
|
num_radios=6
|
||||||
|
start_iwd=0
|
||||||
|
max_test_exec_interval_sec=160
|
||||||
|
|
||||||
|
[HOSTAPD]
|
||||||
|
rad0=ssidHiddenOpen.conf
|
||||||
|
rad1=ssidHiddenWPA.conf
|
||||||
|
rad2=ssidOverlap1.conf
|
||||||
|
rad3=ssidOverlap2.conf
|
||||||
|
rad4=ssidOpen.conf
|
30
autotests/testHiddenNetworks/open_network_test.py
Normal file
30
autotests/testHiddenNetworks/open_network_test.py
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
#!/usr/bin/python3
|
||||||
|
|
||||||
|
import unittest
|
||||||
|
import sys
|
||||||
|
|
||||||
|
sys.path.append('../util')
|
||||||
|
import iwd
|
||||||
|
import validation
|
||||||
|
from validation import TestConnectAutoconnect
|
||||||
|
from iwd import IWD
|
||||||
|
|
||||||
|
class TestOpenNetwork(unittest.TestCase):
|
||||||
|
'''
|
||||||
|
The bellow test cases excesise the following connection scenarios:
|
||||||
|
|
||||||
|
Network config is
|
||||||
|
present at start time: Connect: Autoconnect: Result:
|
||||||
|
--------------------------------------------------------------------------
|
||||||
|
False True Connection succeeds
|
||||||
|
True True Connection succeeds
|
||||||
|
'''
|
||||||
|
def test_open(self):
|
||||||
|
tca = TestConnectAutoconnect()
|
||||||
|
tca.validate('ssidHiddenOpen', False)
|
||||||
|
tca.validate('ssidHiddenOpen', True)
|
||||||
|
|
||||||
|
IWD.clear_storage()
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
unittest.main(exit=True)
|
0
autotests/testHiddenNetworks/ssidAlreadyKnown.open
Normal file
0
autotests/testHiddenNetworks/ssidAlreadyKnown.open
Normal file
5
autotests/testHiddenNetworks/ssidHiddenOpen.conf
Normal file
5
autotests/testHiddenNetworks/ssidHiddenOpen.conf
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
hw_mode=g
|
||||||
|
channel=1
|
||||||
|
ssid=ssidHiddenOpen
|
||||||
|
|
||||||
|
ignore_broadcast_ssid=1
|
9
autotests/testHiddenNetworks/ssidHiddenWPA.conf
Normal file
9
autotests/testHiddenNetworks/ssidHiddenWPA.conf
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
hw_mode=g
|
||||||
|
channel=1
|
||||||
|
ssid=ssidHiddenWPA
|
||||||
|
|
||||||
|
wpa=1
|
||||||
|
wpa_pairwise=TKIP
|
||||||
|
wpa_passphrase=secret123
|
||||||
|
|
||||||
|
ignore_broadcast_ssid=1
|
3
autotests/testHiddenNetworks/ssidOpen.conf
Normal file
3
autotests/testHiddenNetworks/ssidOpen.conf
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
hw_mode=g
|
||||||
|
channel=1
|
||||||
|
ssid=ssidOpen
|
5
autotests/testHiddenNetworks/ssidOverlap1.conf
Normal file
5
autotests/testHiddenNetworks/ssidOverlap1.conf
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
hw_mode=g
|
||||||
|
channel=1
|
||||||
|
ssid=ssidOverlap
|
||||||
|
|
||||||
|
ignore_broadcast_ssid=1
|
9
autotests/testHiddenNetworks/ssidOverlap2.conf
Normal file
9
autotests/testHiddenNetworks/ssidOverlap2.conf
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
hw_mode=g
|
||||||
|
channel=1
|
||||||
|
ssid=ssidOverlap
|
||||||
|
|
||||||
|
wpa=1
|
||||||
|
wpa_pairwise=TKIP
|
||||||
|
wpa_passphrase=secret123
|
||||||
|
|
||||||
|
ignore_broadcast_ssid=1
|
85
autotests/testHiddenNetworks/validation.py
Normal file
85
autotests/testHiddenNetworks/validation.py
Normal file
@ -0,0 +1,85 @@
|
|||||||
|
#!/usr/bin/python3
|
||||||
|
|
||||||
|
import unittest
|
||||||
|
import sys
|
||||||
|
|
||||||
|
sys.path.append('../util')
|
||||||
|
import iwd
|
||||||
|
from iwd import IWD
|
||||||
|
from iwd import PSKAgent
|
||||||
|
from iwd import NetworkType
|
||||||
|
|
||||||
|
class TestConnectAutoconnect(unittest.TestCase):
|
||||||
|
|
||||||
|
def check_connect_hidden_network(self, wd, device, ssid, throws):
|
||||||
|
if not throws is None:
|
||||||
|
with self.assertRaises(throws):
|
||||||
|
device.connect_hidden_network(ssid)
|
||||||
|
return
|
||||||
|
else:
|
||||||
|
device.connect_hidden_network(ssid)
|
||||||
|
|
||||||
|
condition = 'obj.state == DeviceState.connected'
|
||||||
|
wd.wait_for_object_condition(device, condition, 30)
|
||||||
|
|
||||||
|
def check_autoconnect_hidden_network(self, wd, device, ssid, throws):
|
||||||
|
if throws is None:
|
||||||
|
condition = 'obj.state == DeviceState.connected'
|
||||||
|
wd.wait_for_object_condition(device, condition, 30)
|
||||||
|
|
||||||
|
condition = 'obj.connected_network is not None'
|
||||||
|
wd.wait_for_object_condition(device, condition)
|
||||||
|
|
||||||
|
ordered_network = device.get_ordered_networks()[0]
|
||||||
|
|
||||||
|
self.assertIsNotNone(ordered_network)
|
||||||
|
self.assertEqual(ordered_network.name, ssid)
|
||||||
|
self.assertTrue(ordered_network.network_object.connected)
|
||||||
|
|
||||||
|
device.disconnect()
|
||||||
|
|
||||||
|
condition = 'obj.state == DeviceState.disconnected'
|
||||||
|
wd.wait_for_object_condition(device, condition, 30)
|
||||||
|
|
||||||
|
def validate_connection(self, wd, ssid, autoconnect, throws, use_agent,
|
||||||
|
wait_periodic_scan):
|
||||||
|
if use_agent:
|
||||||
|
psk_agent = PSKAgent(["secret123"], ('domain\\User', 'Password'))
|
||||||
|
wd.register_psk_agent(psk_agent)
|
||||||
|
|
||||||
|
devices = wd.list_devices(1);
|
||||||
|
self.assertIsNotNone(devices)
|
||||||
|
device = devices[0]
|
||||||
|
|
||||||
|
if autoconnect:
|
||||||
|
condition = 'obj.scanning'
|
||||||
|
wd.wait_for_object_condition(device, condition)
|
||||||
|
condition = 'not obj.scanning'
|
||||||
|
wd.wait_for_object_condition(device, condition)
|
||||||
|
|
||||||
|
self.check_autoconnect_hidden_network(wd, device, ssid, throws)
|
||||||
|
else:
|
||||||
|
if wait_periodic_scan:
|
||||||
|
condition = 'obj.scanning'
|
||||||
|
wd.wait_for_object_condition(device, condition)
|
||||||
|
condition = 'not obj.scanning'
|
||||||
|
wd.wait_for_object_condition(device, condition)
|
||||||
|
|
||||||
|
self.check_connect_hidden_network(wd, device, ssid, throws)
|
||||||
|
|
||||||
|
if use_agent:
|
||||||
|
wd.unregister_psk_agent(psk_agent)
|
||||||
|
|
||||||
|
|
||||||
|
def validate(self, ssid, autoconnect, throws = None, use_agent = False,
|
||||||
|
wait_periodic_scan = False):
|
||||||
|
wd = IWD(True)
|
||||||
|
|
||||||
|
try:
|
||||||
|
self.validate_connection(wd, ssid, autoconnect, throws, use_agent,
|
||||||
|
wait_periodic_scan)
|
||||||
|
except:
|
||||||
|
del wd
|
||||||
|
raise
|
||||||
|
|
||||||
|
del wd
|
31
autotests/testHiddenNetworks/wpa_network_test.py
Normal file
31
autotests/testHiddenNetworks/wpa_network_test.py
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
#!/usr/bin/python3
|
||||||
|
|
||||||
|
import unittest
|
||||||
|
import sys
|
||||||
|
|
||||||
|
sys.path.append('../util')
|
||||||
|
import iwd
|
||||||
|
import validation
|
||||||
|
from validation import TestConnectAutoconnect
|
||||||
|
from iwd import IWD
|
||||||
|
|
||||||
|
class TestWpaNetwork(unittest.TestCase):
|
||||||
|
'''
|
||||||
|
The bellow test cases excesise the following connection scenarios:
|
||||||
|
|
||||||
|
Network config is
|
||||||
|
present at start time: Connect: Autoconnect: Result:
|
||||||
|
--------------------------------------------------------------------------
|
||||||
|
False True Connection succeeds
|
||||||
|
True True Connection succeeds
|
||||||
|
'''
|
||||||
|
|
||||||
|
def test_wpa(self):
|
||||||
|
tca = TestConnectAutoconnect()
|
||||||
|
tca.validate('ssidHiddenWPA', False, None, True)
|
||||||
|
tca.validate('ssidHiddenWPA', True, None, True)
|
||||||
|
|
||||||
|
IWD.clear_storage()
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
unittest.main(exit=True)
|
Loading…
Reference in New Issue
Block a user