diff options
Diffstat (limited to 'scripts/cli')
-rwxr-xr-x | scripts/cli/test_interfaces.py | 9 | ||||
-rwxr-xr-x | scripts/cli/test_service_snmp.py | 16 | ||||
-rwxr-xr-x | scripts/cli/test_system_login.py | 11 | ||||
-rwxr-xr-x | scripts/cli/test_system_nameserver.py | 8 |
4 files changed, 24 insertions, 20 deletions
diff --git a/scripts/cli/test_interfaces.py b/scripts/cli/test_interfaces.py index 6bbacc585..ad8e653ce 100755 --- a/scripts/cli/test_interfaces.py +++ b/scripts/cli/test_interfaces.py @@ -16,9 +16,9 @@ import os import unittest -import vyos.config -import vyos.configsession +from vyos.config import Config +from vyos.configsession import ConfigSession, ConfigSessionError from netifaces import ifaddresses, AF_INET, AF_INET6 from vyos.validate import is_intf_addr_assigned, is_ipv6_link_local from vyos.interfaces import list_interfaces_of_type @@ -26,9 +26,9 @@ from vyos.interfaces import list_interfaces_of_type class BasicInterfaceTest: class BaseTest(unittest.TestCase): def setUp(self): - self.session = vyos.configsession.ConfigSession(os.getpid()) + self.session = ConfigSession(os.getpid()) env = self.session.get_session_env() - self.config = vyos.config.Config(session_env=env) + self.config = Config(session_env=env) self._test_addr = ['192.0.2.1/25', '2001:db8:1::ffff/64'] def tearDown(self): @@ -136,6 +136,7 @@ class BridgeInterfaceTest(BasicInterfaceTest.BaseTest): for intf in self._interfaces: self.session.delete(self._base_path + [intf, 'member']) + self.session.commit() diff --git a/scripts/cli/test_service_snmp.py b/scripts/cli/test_service_snmp.py index 04db860f6..5fd5eafcc 100755 --- a/scripts/cli/test_service_snmp.py +++ b/scripts/cli/test_service_snmp.py @@ -21,29 +21,30 @@ import unittest from vyos.validate import is_ipv4 from psutil import process_iter -import vyos.config -import vyos.configsession +from vyos.config import Config +from vyos.configsession import ConfigSession, ConfigSessionError import vyos.util as util SNMPD_CONF = '/etc/snmp/snmpd.conf' - base_path = ['service', 'snmp'] def get_config_value(key): tmp = util.read_file(SNMPD_CONF) return re.findall(r'\n?{}\s+(.*)'.format(key), tmp) -class TestSystemNameServer(unittest.TestCase): +class TestSNMPService(unittest.TestCase): def setUp(self): - self.session = vyos.configsession.ConfigSession(os.getpid()) + self.session = ConfigSession(os.getpid()) env = self.session.get_session_env() - self.config = vyos.config.Config(session_env=env) + self.config = Config(session_env=env) def tearDown(self): # Delete SNNP configuration self.session.delete(base_path) self.session.commit() + del self.session + def test_snmp(self): """ Check if SNMP can be configured and service runs """ clients = ['192.0.2.1', '2001:db8::1'] @@ -82,13 +83,14 @@ class TestSystemNameServer(unittest.TestCase): # Check for running process self.assertTrue("snmpd" in (p.name() for p in process_iter())) + def test_snmpv3(self): """ Check if SNMPv3 can be configured and service runs""" self.session.set(base_path + ['v3', 'engineid', '0xaffedeadbeef']) self.session.set(base_path + ['v3', 'group', 'default', 'mode', 'ro']) # check validate() - a view must be created before this can be comitted - with self.assertRaises(vyos.configsession.ConfigSessionError): + with self.assertRaises(ConfigSessionError): self.session.commit() self.session.set(base_path + ['v3', 'view', 'default', 'oid', '1']) diff --git a/scripts/cli/test_system_login.py b/scripts/cli/test_system_login.py index b14b52603..aa26b3bec 100755 --- a/scripts/cli/test_system_login.py +++ b/scripts/cli/test_system_login.py @@ -18,18 +18,18 @@ import os import re import unittest -import vyos.config -import vyos.configsession +from vyos.config import Config +from vyos.configsession import ConfigSession, ConfigSessionError import vyos.util as util base_path = ['system', 'login'] users = ['vyos1', 'vyos2'] -class TestSystemLoginServer(unittest.TestCase): +class TestSystemLogin(unittest.TestCase): def setUp(self): - self.session = vyos.configsession.ConfigSession(os.getpid()) + self.session = ConfigSession(os.getpid()) env = self.session.get_session_env() - self.config = vyos.config.Config(session_env=env) + self.config = Config(session_env=env) def tearDown(self): # Delete SNNP configuration @@ -40,6 +40,7 @@ class TestSystemLoginServer(unittest.TestCase): def test_user(self): """ Check if user can be created and we can SSH to localhost """ + self.session.set(['service', 'ssh', 'port', '22']) for user in users: name = "VyOS Roxx " + user diff --git a/scripts/cli/test_system_nameserver.py b/scripts/cli/test_system_nameserver.py index a07ad31ad..eba8acd80 100755 --- a/scripts/cli/test_system_nameserver.py +++ b/scripts/cli/test_system_nameserver.py @@ -18,8 +18,8 @@ import os import re import unittest -import vyos.config -import vyos.configsession +from vyos.config import Config +from vyos.configsession import ConfigSession, ConfigSessionError import vyos.util as util RESOLV_CONF = '/etc/resolv.conf' @@ -33,9 +33,9 @@ def get_name_servers(): class TestSystemNameServer(unittest.TestCase): def setUp(self): - self.session = vyos.configsession.ConfigSession(os.getpid()) + self.session = ConfigSession(os.getpid()) env = self.session.get_session_env() - self.config = vyos.config.Config(session_env=env) + self.config = Config(session_env=env) # Delete existing name servers self.session.delete(base_path) |