summaryrefslogtreecommitdiff
path: root/smoketest
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2020-10-30 09:11:36 +0100
committerChristian Poessinger <christian@poessinger.com>2020-10-30 09:11:38 +0100
commit55941ffa0ff519a8c96e623fa4c9cf64f7be4d99 (patch)
tree41bf11317a6e472de564025b3af3cb3c698eb526 /smoketest
parenta1327d2b970d4ca387a42d0e931d412cf1a5a102 (diff)
downloadvyos-1x-55941ffa0ff519a8c96e623fa4c9cf64f7be4d99.tar.gz
vyos-1x-55941ffa0ff519a8c96e623fa4c9cf64f7be4d99.zip
smoketest: ssh: add bond to vrf testcase
Bind sshd to given VRF and check if it really runs in the VRF context.
Diffstat (limited to 'smoketest')
-rwxr-xr-xsmoketest/scripts/cli/test_service_ssh.py32
1 files changed, 31 insertions, 1 deletions
diff --git a/smoketest/scripts/cli/test_service_ssh.py b/smoketest/scripts/cli/test_service_ssh.py
index 0cd00ccce..ea70d8e03 100755
--- a/smoketest/scripts/cli/test_service_ssh.py
+++ b/smoketest/scripts/cli/test_service_ssh.py
@@ -20,12 +20,14 @@ import unittest
from vyos.configsession import ConfigSession
from vyos.configsession import ConfigSessionError
-from vyos.util import read_file
+from vyos.util import cmd
from vyos.util import process_named_running
+from vyos.util import read_file
PROCESS_NAME = 'sshd'
SSHD_CONF = '/run/ssh/sshd_config'
base_path = ['service', 'ssh']
+vrf = 'ssh-test'
def get_config_value(key):
tmp = read_file(SSHD_CONF)
@@ -44,6 +46,8 @@ class TestServiceSSH(unittest.TestCase):
self.session.delete(base_path)
# restore "plain" SSH access
self.session.set(base_path)
+ # delete VRF
+ self.session.delete(['vrf', 'name', vrf])
self.session.commit()
del self.session
@@ -129,5 +133,31 @@ class TestServiceSSH(unittest.TestCase):
# Check for running process
self.assertTrue(process_named_running(PROCESS_NAME))
+ def test_ssh_vrf(self):
+ """ Check if SSH service can be bound to given VRF """
+ port = '22'
+ self.session.set(base_path + ['port', port])
+ self.session.set(base_path + ['vrf', vrf])
+
+ # VRF does yet not exist - an error must be thrown
+ with self.assertRaises(ConfigSessionError):
+ self.session.commit()
+
+ self.session.set(['vrf', 'name', vrf, 'table', '1001'])
+
+ # commit changes
+ self.session.commit()
+
+ # Check configured port
+ tmp = get_config_value('Port')
+ self.assertIn(port, tmp)
+
+ # Check for running process
+ self.assertTrue(process_named_running(PROCESS_NAME))
+
+ # Check for process in VRF
+ tmp = cmd(f'ip vrf pids {vrf}')
+ self.assertIn(PROCESS_NAME, tmp)
+
if __name__ == '__main__':
unittest.main()