mirror of
https://git.kernel.org/pub/scm/network/wireless/iwd.git
synced 2024-11-22 14:49:24 +01:00
auto-t: connect, auto-connect scenarios
Exercise connect, auto connect scenarios for the open, psk, 8021x networks
This commit is contained in:
parent
f4f1450880
commit
ec0aab7829
41
autotests/testConnectAutoconnect/8021x_network_test.py
Normal file
41
autotests/testConnectAutoconnect/8021x_network_test.py
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
#!/usr/bin/python3
|
||||||
|
|
||||||
|
import unittest
|
||||||
|
import sys
|
||||||
|
|
||||||
|
sys.path.append('../util')
|
||||||
|
import iwd
|
||||||
|
import validation
|
||||||
|
from validation import TestConnectAutoconnect
|
||||||
|
from iwd import IWD
|
||||||
|
|
||||||
|
class Test8021xNetwork(unittest.TestCase):
|
||||||
|
'''
|
||||||
|
The bellow test cases excesise the following connection scenarios:
|
||||||
|
|
||||||
|
Network config is
|
||||||
|
present at start time: Connect: Autoconnect: Result:
|
||||||
|
--------------------------------------------------------------------------
|
||||||
|
False True NotConfiguredEx is thrown
|
||||||
|
True True Connection succeeds
|
||||||
|
True - EAP method in True FailedEx is thrown
|
||||||
|
config file is not
|
||||||
|
supported by IWD
|
||||||
|
'''
|
||||||
|
def test_8021x(self):
|
||||||
|
tca = TestConnectAutoconnect()
|
||||||
|
tca.validate('ssidEAP-TLS', True, iwd.NotConfiguredEx)
|
||||||
|
|
||||||
|
IWD.copy_to_storage('ssidEAP-TLS.8021x')
|
||||||
|
|
||||||
|
tca.validate('ssidEAP-TLS', True)
|
||||||
|
|
||||||
|
IWD.clear_storage()
|
||||||
|
IWD.copy_to_storage('ssidEAP-Other.8021x')
|
||||||
|
|
||||||
|
tca.validate('ssidEAP-Other', False, iwd.FailedEx)
|
||||||
|
|
||||||
|
IWD.clear_storage()
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
unittest.main(exit=True)
|
11
autotests/testConnectAutoconnect/hw.conf
Normal file
11
autotests/testConnectAutoconnect/hw.conf
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
[SETUP]
|
||||||
|
num_radios=5
|
||||||
|
start_iwd=0
|
||||||
|
max_test_exec_interval_sec=120
|
||||||
|
tmpfs_extra_stuff=../misc/certs
|
||||||
|
|
||||||
|
[HOSTAPD]
|
||||||
|
rad0=ssidOpen.conf
|
||||||
|
rad1=ssidWPA.conf
|
||||||
|
rad2=ssidEAP-TLS.conf
|
||||||
|
rad3=ssidEAP-Other.conf
|
30
autotests/testConnectAutoconnect/open_network_test.py
Normal file
30
autotests/testConnectAutoconnect/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('ssidOpen', False)
|
||||||
|
tca.validate('ssidOpen', True)
|
||||||
|
|
||||||
|
IWD.clear_storage()
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
unittest.main(exit=True)
|
2
autotests/testConnectAutoconnect/ssidEAP-Other.8021x
Normal file
2
autotests/testConnectAutoconnect/ssidEAP-Other.8021x
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
[Security]
|
||||||
|
EAP-Method=UNSUPPORTED
|
12
autotests/testConnectAutoconnect/ssidEAP-Other.conf
Normal file
12
autotests/testConnectAutoconnect/ssidEAP-Other.conf
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
hw_mode=g
|
||||||
|
channel=1
|
||||||
|
ssid=ssidEAP-Other
|
||||||
|
|
||||||
|
wpa=3
|
||||||
|
wpa_key_mgmt=WPA-EAP
|
||||||
|
ieee8021x=1
|
||||||
|
eap_server=1
|
||||||
|
eap_user_file=/tmp/certs/eap-user-ttls.text
|
||||||
|
ca_cert=/tmp/certs/cert-ca.pem
|
||||||
|
server_cert=/tmp/certs/cert-server.pem
|
||||||
|
private_key=/tmp/certs/cert-server-key.pem
|
6
autotests/testConnectAutoconnect/ssidEAP-TLS.8021x
Normal file
6
autotests/testConnectAutoconnect/ssidEAP-TLS.8021x
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
[Security]
|
||||||
|
EAP-Method=TLS
|
||||||
|
EAP-TLS-CACert=/tmp/certs/cert-ca.pem
|
||||||
|
EAP-TLS-ClientCert=/tmp/certs/cert-client.pem
|
||||||
|
EAP-TLS-ClientKey=/tmp/certs/cert-client-key-pkcs8.pem
|
||||||
|
EAP-Identity=abc@example.com
|
12
autotests/testConnectAutoconnect/ssidEAP-TLS.conf
Normal file
12
autotests/testConnectAutoconnect/ssidEAP-TLS.conf
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
hw_mode=g
|
||||||
|
channel=1
|
||||||
|
ssid=ssidEAP-TLS
|
||||||
|
|
||||||
|
wpa=3
|
||||||
|
wpa_key_mgmt=WPA-EAP
|
||||||
|
ieee8021x=1
|
||||||
|
eap_server=1
|
||||||
|
eap_user_file=/tmp/certs/eap-user-tls.text
|
||||||
|
ca_cert=/tmp/certs/cert-ca.pem
|
||||||
|
server_cert=/tmp/certs/cert-server.pem
|
||||||
|
private_key=/tmp/certs/cert-server-key.pem
|
3
autotests/testConnectAutoconnect/ssidOpen.conf
Normal file
3
autotests/testConnectAutoconnect/ssidOpen.conf
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
hw_mode=g
|
||||||
|
channel=1
|
||||||
|
ssid=ssidOpen
|
7
autotests/testConnectAutoconnect/ssidWPA.conf
Normal file
7
autotests/testConnectAutoconnect/ssidWPA.conf
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
hw_mode=g
|
||||||
|
channel=1
|
||||||
|
ssid=ssidWPA
|
||||||
|
|
||||||
|
wpa=1
|
||||||
|
wpa_pairwise=TKIP
|
||||||
|
wpa_passphrase=secret123
|
89
autotests/testConnectAutoconnect/validation.py
Normal file
89
autotests/testConnectAutoconnect/validation.py
Normal file
@ -0,0 +1,89 @@
|
|||||||
|
#!/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(self, wd, device, ssid, throws):
|
||||||
|
wd.wait(3);
|
||||||
|
ordered_networks = device.get_ordered_networks()
|
||||||
|
ordered_network = None
|
||||||
|
|
||||||
|
for o_n in ordered_networks:
|
||||||
|
if o_n.name == ssid:
|
||||||
|
ordered_network = o_n
|
||||||
|
break
|
||||||
|
|
||||||
|
self.assertEqual(ordered_network.name, ssid)
|
||||||
|
|
||||||
|
condition = 'not obj.connected'
|
||||||
|
wd.wait_for_object_condition(ordered_network.network_object, condition)
|
||||||
|
|
||||||
|
if not throws is None:
|
||||||
|
with self.assertRaises(throws):
|
||||||
|
ordered_network.network_object.connect()
|
||||||
|
return
|
||||||
|
else:
|
||||||
|
ordered_network.network_object.connect()
|
||||||
|
|
||||||
|
condition = 'obj.connected'
|
||||||
|
wd.wait_for_object_condition(ordered_network.network_object, condition)
|
||||||
|
|
||||||
|
def check_autoconnect(self, wd, device, ssid, throws):
|
||||||
|
wd.wait(3);
|
||||||
|
|
||||||
|
if throws is None:
|
||||||
|
condition = 'obj.state == DeviceState.connected'
|
||||||
|
wd.wait_for_object_condition(device, condition)
|
||||||
|
|
||||||
|
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)
|
||||||
|
|
||||||
|
def validate(self, ssid, autoconnect, throws = None, use_agent = False):
|
||||||
|
|
||||||
|
wd = IWD(True)
|
||||||
|
wd.wait(1);
|
||||||
|
|
||||||
|
if use_agent:
|
||||||
|
psk_agent = PSKAgent("secret123")
|
||||||
|
wd.register_psk_agent(psk_agent)
|
||||||
|
|
||||||
|
devices = wd.list_devices();
|
||||||
|
self.assertIsNotNone(devices)
|
||||||
|
device = devices[0]
|
||||||
|
|
||||||
|
if autoconnect:
|
||||||
|
self.check_autoconnect(wd, device, ssid, throws)
|
||||||
|
else:
|
||||||
|
condition = 'not obj.scanning'
|
||||||
|
wd.wait_for_object_condition(device, condition)
|
||||||
|
|
||||||
|
device.scan()
|
||||||
|
|
||||||
|
condition = 'not obj.scanning'
|
||||||
|
wd.wait_for_object_condition(device, condition)
|
||||||
|
|
||||||
|
self.check_connect(wd, device, ssid, throws)
|
||||||
|
|
||||||
|
if use_agent:
|
||||||
|
wd.unregister_psk_agent(psk_agent)
|
||||||
|
|
||||||
|
del wd
|
31
autotests/testConnectAutoconnect/wpa_network_test.py
Normal file
31
autotests/testConnectAutoconnect/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('ssidWPA', False, None, True)
|
||||||
|
tca.validate('ssidWPA', True, None, True)
|
||||||
|
|
||||||
|
IWD.clear_storage()
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
unittest.main(exit=True)
|
Loading…
Reference in New Issue
Block a user