summaryrefslogtreecommitdiff
path: root/smoketest/scripts/cli/test_interfaces_wireless.py
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2020-11-03 19:56:20 +0100
committerChristian Poessinger <christian@poessinger.com>2020-11-03 19:56:20 +0100
commit620271eca13b3535472243f98bca766ed6ec19ed (patch)
treefe34254922c1deb9521f20b3ab4a578721a34813 /smoketest/scripts/cli/test_interfaces_wireless.py
parent0ec4ad03abb952fbc817df4bbaaf4ab05fbc9753 (diff)
parent01e3d935a34f38e48364724da1cad7cbbb18576e (diff)
downloadvyos-1x-620271eca13b3535472243f98bca766ed6ec19ed.tar.gz
vyos-1x-620271eca13b3535472243f98bca766ed6ec19ed.zip
Merge branch 'wifi-wpa3' of github.com:c-po/vyos-1x into current
* 'wifi-wpa3' of github.com:c-po/vyos-1x: wireless: T3042: move wifi-regulatory-domain into individual interface definition wireless: T2653: reset wireless priority to crux state wireless: T3034: add WPA3 support wireless: T3043: rename "wpa mode both" to "wpa+wpa2" ifconfig: T2985: fix wireless-bridge creation
Diffstat (limited to 'smoketest/scripts/cli/test_interfaces_wireless.py')
-rwxr-xr-xsmoketest/scripts/cli/test_interfaces_wireless.py80
1 files changed, 76 insertions, 4 deletions
diff --git a/smoketest/scripts/cli/test_interfaces_wireless.py b/smoketest/scripts/cli/test_interfaces_wireless.py
index 0e93b6432..65cf127ce 100755
--- a/smoketest/scripts/cli/test_interfaces_wireless.py
+++ b/smoketest/scripts/cli/test_interfaces_wireless.py
@@ -18,14 +18,16 @@ import os
import re
import unittest
+from vyos.configsession import ConfigSessionError
from base_interfaces_test import BasicInterfaceTest
+
from vyos.util import process_named_running
from vyos.util import check_kmod
from vyos.util import read_file
def get_config_value(interface, key):
tmp = read_file(f'/run/hostapd/{interface}.conf')
- tmp = re.findall(r'\n?{}=+(.*)'.format(key), tmp)
+ tmp = re.findall(f'{key}=+(.*)', tmp)
return tmp[0]
class WirelessInterfaceTest(BasicInterfaceTest.BaseTest):
@@ -36,15 +38,14 @@ class WirelessInterfaceTest(BasicInterfaceTest.BaseTest):
self._options = {
'wlan0': ['physical-device phy0', 'ssid VyOS-WIFI-0',
'type station', 'address 192.0.2.1/30'],
- 'wlan1': ['physical-device phy0', 'ssid VyOS-WIFI-1',
+ 'wlan1': ['physical-device phy0', 'ssid VyOS-WIFI-1', 'country-code SE',
'type access-point', 'address 192.0.2.5/30', 'channel 0'],
'wlan10': ['physical-device phy1', 'ssid VyOS-WIFI-2',
'type station', 'address 192.0.2.9/30'],
- 'wlan11': ['physical-device phy1', 'ssid VyOS-WIFI-3',
+ 'wlan11': ['physical-device phy1', 'ssid VyOS-WIFI-3', 'country-code SE',
'type access-point', 'address 192.0.2.13/30', 'channel 0'],
}
self._interfaces = list(self._options)
- self.session.set(['system', 'wifi-regulatory-domain', 'SE'])
def test_add_address_single(self):
""" derived method to check if member interfaces are enslaved properly """
@@ -73,6 +74,7 @@ class WirelessInterfaceTest(BasicInterfaceTest.BaseTest):
self.session.set(self._base_path + [interface, 'ssid', ssid])
self.session.set(self._base_path + [interface, 'type', 'access-point'])
self.session.set(self._base_path + [interface, 'channel', channel])
+ self.session.set(self._base_path + [interface, 'country-code', 'SE'])
# auto-powersave is special
self.session.set(self._base_path + [interface, 'capabilities', 'ht', 'auto-powersave'])
@@ -114,6 +116,8 @@ class WirelessInterfaceTest(BasicInterfaceTest.BaseTest):
#
# Validate Config
#
+ tmp = get_config_value(interface, 'interface')
+ self.assertEqual(interface, tmp)
# ssid
tmp = get_config_value(interface, 'ssid')
@@ -138,6 +142,74 @@ class WirelessInterfaceTest(BasicInterfaceTest.BaseTest):
# Check for running process
self.assertTrue(process_named_running('hostapd'))
+ def test_hostapd_wpa_config(self):
+ """ Check if hostapd config is properly generated """
+
+ # Only set the hostapd (access-point) options
+ interface = 'wlan0'
+ phy = 'phy0'
+ ssid = 'ssid'
+ channel = '0'
+ wpa_key = 'VyOSVyOSVyOS'
+ mode = 'n'
+ country = 'DE'
+
+ self.session.set(self._base_path + [interface, 'physical-device', phy])
+ self.session.set(self._base_path + [interface, 'type', 'access-point'])
+ self.session.set(self._base_path + [interface, 'mode', mode])
+
+ # SSID must be set
+ with self.assertRaises(ConfigSessionError):
+ self.session.commit()
+ self.session.set(self._base_path + [interface, 'ssid', ssid])
+
+ # Channel must be set
+ with self.assertRaises(ConfigSessionError):
+ self.session.commit()
+ self.session.set(self._base_path + [interface, 'channel', channel])
+
+ # Country-Code must be set
+ with self.assertRaises(ConfigSessionError):
+ self.session.commit()
+ self.session.set(self._base_path + [interface, 'country-code', country])
+
+ self.session.set(self._base_path + [interface, 'security', 'wpa', 'mode', 'wpa2'])
+ self.session.set(self._base_path + [interface, 'security', 'wpa', 'passphrase', wpa_key])
+
+ self.session.commit()
+
+ #
+ # Validate Config
+ #
+ tmp = get_config_value(interface, 'interface')
+ self.assertEqual(interface, tmp)
+
+ tmp = get_config_value(interface, 'hw_mode')
+ # rewrite special mode
+ if mode == 'n': mode = 'g'
+ self.assertEqual(mode, tmp)
+
+ # WPA key
+ tmp = get_config_value(interface, 'wpa')
+ self.assertEqual('2', tmp)
+ tmp = get_config_value(interface, 'wpa_passphrase')
+ self.assertEqual(wpa_key, tmp)
+
+ # SSID
+ tmp = get_config_value(interface, 'ssid')
+ self.assertEqual(ssid, tmp)
+
+ # channel
+ tmp = get_config_value(interface, 'channel')
+ self.assertEqual(channel, tmp)
+
+ # Country code
+ tmp = get_config_value(interface, 'country_code')
+ self.assertEqual(country, tmp)
+
+ # Check for running process
+ self.assertTrue(process_named_running('hostapd'))
+
if __name__ == '__main__':
check_kmod('mac80211_hwsim')
unittest.main()