summaryrefslogtreecommitdiff
path: root/smoketest/scripts/cli/test_service_ssh.py
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2020-09-01 07:35:07 +0200
committerChristian Poessinger <christian@poessinger.com>2020-09-01 07:35:07 +0200
commit0952b62baf878a9d4abcfc777beaa19c1cf9e47b (patch)
tree4df2cf3ca51f353c2f0eb196c6852df784b4e775 /smoketest/scripts/cli/test_service_ssh.py
parenta84a7e0327078e7fbf6d84a340080af82610000f (diff)
downloadvyos-1x-0952b62baf878a9d4abcfc777beaa19c1cf9e47b.tar.gz
vyos-1x-0952b62baf878a9d4abcfc777beaa19c1cf9e47b.zip
T2636: ssh: add smoketest for XML defaultValue node
Diffstat (limited to 'smoketest/scripts/cli/test_service_ssh.py')
-rwxr-xr-xsmoketest/scripts/cli/test_service_ssh.py22
1 files changed, 20 insertions, 2 deletions
diff --git a/smoketest/scripts/cli/test_service_ssh.py b/smoketest/scripts/cli/test_service_ssh.py
index 3ee498f3d..1038b8775 100755
--- a/smoketest/scripts/cli/test_service_ssh.py
+++ b/smoketest/scripts/cli/test_service_ssh.py
@@ -30,6 +30,9 @@ def get_config_value(key):
tmp = re.findall(r'\n?{}\s+(.*)'.format(key), tmp)
return tmp
+def is_service_running():
+ return 'sshd' in (p.name() for p in process_iter())
+
class TestServiceSSH(unittest.TestCase):
def setUp(self):
self.session = ConfigSession(os.getpid())
@@ -46,6 +49,21 @@ class TestServiceSSH(unittest.TestCase):
self.session.commit()
del self.session
+ def test_ssh_default(self):
+ """ Check if SSH service runs with default settings - used for checking
+ behavior of <defaultValue> in XML definition """
+ self.session.set(base_path)
+
+ # commit changes
+ self.session.commit()
+
+ # Check configured port
+ port = get_config_value('Port')[0]
+ self.assertEqual('22', port)
+
+ # Check for running process
+ self.assertTrue(is_service_running())
+
def test_ssh_single(self):
""" Check if SSH service can be configured and runs """
self.session.set(base_path + ['port', '1234'])
@@ -83,7 +101,7 @@ class TestServiceSSH(unittest.TestCase):
self.assertTrue("100" in keepalive)
# Check for running process
- self.assertTrue("sshd" in (p.name() for p in process_iter()))
+ self.assertTrue(is_service_running())
def test_ssh_multi(self):
""" Check if SSH service can be configured and runs with multiple
@@ -110,7 +128,7 @@ class TestServiceSSH(unittest.TestCase):
self.assertIn(address, tmp)
# Check for running process
- self.assertTrue("sshd" in (p.name() for p in process_iter()))
+ self.assertTrue(is_service_running())
if __name__ == '__main__':
unittest.main()