mirror of
https://git.kernel.org/pub/scm/network/wireless/iwd.git
synced 2025-02-16 15:20:42 +01:00
auto-t: Test client's non-interactive connect command
This commit is contained in:
parent
cc7cab63d2
commit
636bf5749f
124
autotests/testClientNonInteractive/connect_command_test.py
Normal file
124
autotests/testClientNonInteractive/connect_command_test.py
Normal file
@ -0,0 +1,124 @@
|
|||||||
|
#!/usr/bin/python3
|
||||||
|
|
||||||
|
import unittest
|
||||||
|
import sys
|
||||||
|
|
||||||
|
sys.path.append('../util')
|
||||||
|
import iwd
|
||||||
|
from iwd import IWD
|
||||||
|
import testutil
|
||||||
|
import subprocess
|
||||||
|
|
||||||
|
class Test(unittest.TestCase):
|
||||||
|
|
||||||
|
def check_connection_success(self, ssid):
|
||||||
|
wd = IWD()
|
||||||
|
|
||||||
|
device = wd.list_devices(1)[0]
|
||||||
|
|
||||||
|
condition = 'not obj.scanning'
|
||||||
|
wd.wait_for_object_condition(device, condition)
|
||||||
|
|
||||||
|
ordered_network = device.get_ordered_network(ssid)
|
||||||
|
|
||||||
|
condition = 'obj.connected'
|
||||||
|
wd.wait_for_object_condition(ordered_network.network_object, condition)
|
||||||
|
|
||||||
|
device.disconnect()
|
||||||
|
|
||||||
|
condition = 'not obj.connected'
|
||||||
|
wd.wait_for_object_condition(ordered_network.network_object, condition)
|
||||||
|
|
||||||
|
def test_connection_with_passphrase(self):
|
||||||
|
ssid = 'ssidPassphrase'
|
||||||
|
|
||||||
|
wd = IWD()
|
||||||
|
|
||||||
|
device = wd.list_devices(1)[0]
|
||||||
|
|
||||||
|
with self.assertRaises(subprocess.CalledProcessError):
|
||||||
|
subprocess.check_call(['iwctl', 'station', device.name,
|
||||||
|
'connect', ssid])
|
||||||
|
|
||||||
|
subprocess.check_call(['iwctl', '-P', 'passphrase',
|
||||||
|
'station', device.name, 'connect', ssid])
|
||||||
|
|
||||||
|
self.check_connection_success(ssid)
|
||||||
|
|
||||||
|
def test_connection_with_username_and_password(self):
|
||||||
|
ssid = 'ssidUNameAndPWord'
|
||||||
|
|
||||||
|
wd = IWD()
|
||||||
|
|
||||||
|
device = wd.list_devices(1)[0]
|
||||||
|
|
||||||
|
subprocess.check_call(['iwctl', '-u', 'user', '-p', 'password',
|
||||||
|
'station', device.name, 'connect', ssid])
|
||||||
|
|
||||||
|
self.check_connection_success(ssid)
|
||||||
|
|
||||||
|
def test_connection_with_password(self):
|
||||||
|
ssid = 'ssidPWord'
|
||||||
|
|
||||||
|
wd = IWD()
|
||||||
|
|
||||||
|
device = wd.list_devices(1)[0]
|
||||||
|
|
||||||
|
subprocess.check_call(['iwctl', '-p', 'password',
|
||||||
|
'station', device.name, 'connect', ssid])
|
||||||
|
|
||||||
|
self.check_connection_success(ssid)
|
||||||
|
|
||||||
|
def test_connection_failure(self):
|
||||||
|
ssid = 'ssidPassphrase'
|
||||||
|
|
||||||
|
wd = IWD()
|
||||||
|
|
||||||
|
device = wd.list_devices(1)[0]
|
||||||
|
|
||||||
|
with self.assertRaises(subprocess.CalledProcessError):
|
||||||
|
subprocess.check_call(['iwctl', '-P', 'incorrect_passphrase',
|
||||||
|
'station', device.name, 'connect', ssid])
|
||||||
|
|
||||||
|
def test_invalid_command_line_option(self):
|
||||||
|
ssid = 'ssidPassphrase'
|
||||||
|
|
||||||
|
wd = IWD()
|
||||||
|
|
||||||
|
device = wd.list_devices(1)[0]
|
||||||
|
|
||||||
|
with self.assertRaises(subprocess.CalledProcessError):
|
||||||
|
subprocess.check_call(['iwctl', '-z',
|
||||||
|
'station', device.name, 'connect', ssid])
|
||||||
|
|
||||||
|
def test_invalid_command(self):
|
||||||
|
wd = IWD()
|
||||||
|
|
||||||
|
device = wd.list_devices(1)[0]
|
||||||
|
|
||||||
|
with self.assertRaises(subprocess.CalledProcessError):
|
||||||
|
subprocess.check_call(['iwctl', 'inexistent', 'command'])
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def setUpClass(cls):
|
||||||
|
IWD.copy_to_storage('ssidUNameAndPWord.8021x')
|
||||||
|
IWD.copy_to_storage('ssidPWord.8021x')
|
||||||
|
|
||||||
|
wd = IWD()
|
||||||
|
|
||||||
|
device = wd.list_devices(1)[0]
|
||||||
|
|
||||||
|
condition = 'not obj.scanning'
|
||||||
|
wd.wait_for_object_condition(device, condition)
|
||||||
|
|
||||||
|
device.scan()
|
||||||
|
|
||||||
|
condition = 'not obj.scanning'
|
||||||
|
wd.wait_for_object_condition(device, condition)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def tearDownClass(cls):
|
||||||
|
IWD.clear_storage()
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
unittest.main(exit=True)
|
@ -0,0 +1,4 @@
|
|||||||
|
# Phase 1 users
|
||||||
|
* TTLS
|
||||||
|
# Phase 2
|
||||||
|
"user" TTLS-MSCHAP "password" [2]
|
9
autotests/testClientNonInteractive/hw.conf
Normal file
9
autotests/testClientNonInteractive/hw.conf
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
[SETUP]
|
||||||
|
num_radios=4
|
||||||
|
max_test_exec_interval_sec=40
|
||||||
|
tmpfs_extra_stuff=../misc/certs:eap-user-ttls-mschap.text
|
||||||
|
|
||||||
|
[HOSTAPD]
|
||||||
|
rad0=ssidPassphrase.conf
|
||||||
|
rad1=ssidUNameAndPWord.conf
|
||||||
|
rad2=ssidPWord.conf
|
9
autotests/testClientNonInteractive/ssidPWord.8021x
Normal file
9
autotests/testClientNonInteractive/ssidPWord.8021x
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
[Security]
|
||||||
|
EAP-Method=TTLS
|
||||||
|
EAP-Identity=anonymous
|
||||||
|
EAP-TTLS-Phase2-Method=Tunneled-MSCHAP
|
||||||
|
|
||||||
|
EAP-TTLS-Phase2-Identity=user
|
||||||
|
|
||||||
|
[Settings]
|
||||||
|
Autoconnect=False
|
12
autotests/testClientNonInteractive/ssidPWord.conf
Normal file
12
autotests/testClientNonInteractive/ssidPWord.conf
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
hw_mode=g
|
||||||
|
channel=1
|
||||||
|
ssid=ssidPWord
|
||||||
|
|
||||||
|
wpa=3
|
||||||
|
wpa_key_mgmt=WPA-EAP
|
||||||
|
ieee8021x=1
|
||||||
|
eap_server=1
|
||||||
|
eap_user_file=/tmp/eap-user-ttls-mschap.text
|
||||||
|
ca_cert=/tmp/certs/cert-ca.pem
|
||||||
|
server_cert=/tmp/certs/cert-server.pem
|
||||||
|
private_key=/tmp/certs/cert-server-key.pem
|
7
autotests/testClientNonInteractive/ssidPassphrase.conf
Normal file
7
autotests/testClientNonInteractive/ssidPassphrase.conf
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
hw_mode=g
|
||||||
|
channel=1
|
||||||
|
ssid=ssidPassphrase
|
||||||
|
|
||||||
|
wpa=1
|
||||||
|
wpa_pairwise=TKIP
|
||||||
|
wpa_passphrase=passphrase
|
10
autotests/testClientNonInteractive/ssidUNameAndPWord.8021x
Normal file
10
autotests/testClientNonInteractive/ssidUNameAndPWord.8021x
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
[Security]
|
||||||
|
EAP-Method=TTLS
|
||||||
|
EAP-Identity=anonymous
|
||||||
|
EAP-TTLS-Phase2-Method=Tunneled-MSCHAP
|
||||||
|
|
||||||
|
EAP-TTLS-Phase2-Identity=user
|
||||||
|
#EAP-TTLS-Phase2-Password=password
|
||||||
|
|
||||||
|
[Settings]
|
||||||
|
Autoconnect=False
|
12
autotests/testClientNonInteractive/ssidUNameAndPWord.conf
Normal file
12
autotests/testClientNonInteractive/ssidUNameAndPWord.conf
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
hw_mode=g
|
||||||
|
channel=1
|
||||||
|
ssid=ssidUNameAndPWord
|
||||||
|
|
||||||
|
wpa=3
|
||||||
|
wpa_key_mgmt=WPA-EAP
|
||||||
|
ieee8021x=1
|
||||||
|
eap_server=1
|
||||||
|
eap_user_file=/tmp/eap-user-ttls-mschap.text
|
||||||
|
ca_cert=/tmp/certs/cert-ca.pem
|
||||||
|
server_cert=/tmp/certs/cert-server.pem
|
||||||
|
private_key=/tmp/certs/cert-server-key.pem
|
Loading…
x
Reference in New Issue
Block a user