From 70f0d321325f3a7d9966c11c39dfb2ef6ecea97e Mon Sep 17 00:00:00 2001 From: Christian Poessinger Date: Tue, 4 Feb 2020 18:11:16 +0100 Subject: snmp: add testcase for SNMPv3 --- scripts/cli/test_service_snmp.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'scripts/cli/test_service_snmp.py') diff --git a/scripts/cli/test_service_snmp.py b/scripts/cli/test_service_snmp.py index cca39f7c6..04db860f6 100755 --- a/scripts/cli/test_service_snmp.py +++ b/scripts/cli/test_service_snmp.py @@ -82,6 +82,29 @@ 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): + self.session.commit() + + self.session.set(base_path + ['v3', 'view', 'default', 'oid', '1']) + self.session.set(base_path + ['v3', 'group', 'default', 'view', 'default']) + self.session.commit() + + # create user + for authpriv in ['auth', 'privacy']: + self.session.set(base_path + ['v3', 'user', 'vyos', authpriv, 'plaintext-key', 'vyos1234']) + self.session.set(base_path + ['v3', 'user', 'vyos', 'group', 'default']) + + # TODO: read in config file and check values + + # Check for running process + self.assertTrue("snmpd" in (p.name() for p in process_iter())) + if __name__ == '__main__': unittest.main() -- cgit v1.2.3