Skip to content

Commit

Permalink
T6199: start validating smoketests against real CLI defaultValues
Browse files Browse the repository at this point in the history
Use vyos.xml_ref.default_value to query XML default values and take them into
account when validating properly applied defaults in individual smoketests
instead of using hardcoded values like 443 for https port.
  • Loading branch information
c-po committed Apr 6, 2024
1 parent 7178630 commit 6b43219
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
4 changes: 3 additions & 1 deletion smoketest/scripts/cli/test_interfaces_wireless.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
from vyos.utils.process import process_named_running
from vyos.utils.kernel import check_kmod
from vyos.utils.file import read_file
from vyos.xml_ref import default_value

def get_config_value(interface, key):
tmp = read_file(f'/run/hostapd/{interface}.conf')
Expand Down Expand Up @@ -127,7 +128,8 @@ def test_wireless_hostapd_config(self):

# channel
tmp = get_config_value(interface, 'channel')
self.assertEqual('0', tmp) # default is channel 0
cli_default = default_value(self._base_path + [interface, 'channel'])
self.assertEqual(cli_default, tmp)

# auto-powersave is special
tmp = get_config_value(interface, 'uapsd_advertisement_enabled')
Expand Down
6 changes: 2 additions & 4 deletions smoketest/scripts/cli/test_service_https.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
from vyos.utils.file import write_file
from vyos.utils.process import call
from vyos.utils.process import process_named_running
from vyos.xml_ref import default_value

from vyos.configsession import ConfigSessionError

Expand Down Expand Up @@ -147,10 +148,8 @@ def test_api_incomplete_key(self):

@ignore_warning(InsecureRequestWarning)
def test_api_auth(self):
vhost_id = 'example'
address = '127.0.0.1'
port = '443' # default value
name = 'localhost'
port = default_value(base_path + ['port'])

key = 'MySuperSecretVyOS'
self.cli_set(base_path + ['api', 'keys', 'id', 'key-01', 'key', key])
Expand Down Expand Up @@ -420,7 +419,6 @@ def test_api_config_file_load_http(self):
url = f'https://{address}/config-file'
url_config = f'https://{address}/configure'
headers = {}
tmp_file = 'tmp-config.boot'

self.cli_set(base_path + ['api', 'keys', 'id', 'key-01', 'key', key])
self.cli_commit()
Expand Down
10 changes: 6 additions & 4 deletions smoketest/scripts/cli/test_service_ssh.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env python3
#
# Copyright (C) 2019-2022 VyOS maintainers and contributors
# Copyright (C) 2019-2024 VyOS maintainers and contributors
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 or later as
Expand Down Expand Up @@ -28,6 +28,7 @@
from vyos.utils.process import is_systemd_service_running
from vyos.utils.process import process_named_running
from vyos.utils.file import read_file
from vyos.xml_ref import default_value

PROCESS_NAME = 'sshd'
SSHD_CONF = '/run/sshd/sshd_config'
Expand Down Expand Up @@ -78,9 +79,10 @@ def test_ssh_default(self):
# commit changes
self.cli_commit()

# Check configured port
port = get_config_value('Port')[0]
self.assertEqual('22', port) # default value
# Check configured port agains CLI default value
port = get_config_value('Port')
cli_default = default_value(base_path + ['port'])
self.assertEqual(port, cli_default)

def test_ssh_single_listen_address(self):
# Check if SSH service can be configured and runs
Expand Down

0 comments on commit 6b43219

Please sign in to comment.