diff options
author | Daniil Baturin <daniil@vyos.io> | 2022-07-24 17:33:09 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-24 17:33:09 +0100 |
commit | 4168e03721b2a9595de4090fddf1280d39ccce4c (patch) | |
tree | 8d91f6363eaed85980eb2a85e67457f699b4b8c0 /smoketest | |
parent | 91efb252a73af6f8531a196bda147dca3b0978eb (diff) | |
parent | a5580f2fc6f76026a0e72561bf797d03fee40a8c (diff) | |
download | vyos-1x-4168e03721b2a9595de4090fddf1280d39ccce4c.tar.gz vyos-1x-4168e03721b2a9595de4090fddf1280d39ccce4c.zip |
Merge pull request #1416 from sever-sever/T2763-eq
snmp: T2763: Add protocol TCP for service SNMP
Diffstat (limited to 'smoketest')
-rwxr-xr-x | smoketest/scripts/cli/test_service_snmp.py | 47 |
1 files changed, 46 insertions, 1 deletions
diff --git a/smoketest/scripts/cli/test_service_snmp.py b/smoketest/scripts/cli/test_service_snmp.py index 00754e668..864097771 100755 --- a/smoketest/scripts/cli/test_service_snmp.py +++ b/smoketest/scripts/cli/test_service_snmp.py @@ -1,6 +1,6 @@ #!/usr/bin/env python3 # -# Copyright (C) 2019-2020 VyOS maintainers and contributors +# Copyright (C) 2019-2022 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 @@ -94,6 +94,51 @@ class TestSNMPService(VyOSUnitTestSHIM.TestCase): self.assertTrue(process_named_running(PROCESS_NAME)) self.cli_delete(['interfaces', 'dummy', dummy_if]) + def test_snmp_tcp(self): + dummy_if = 'dum123' + dummy_addr = '100.64.0.1/32' + self.cli_set(['interfaces', 'dummy', dummy_if, 'address', dummy_addr]) + + # Check if SNMP can be configured and service runs + clients = ['192.0.2.1', '2001:db8::1'] + networks = ['192.0.2.128/25', '2001:db8:babe::/48'] + listen = ['127.0.0.1', '::1', address_from_cidr(dummy_addr)] + port = '2325' + + for auth in ['ro', 'rw']: + community = 'VyOS' + auth + self.cli_set(base_path + ['community', community, 'authorization', auth]) + for client in clients: + self.cli_set(base_path + ['community', community, 'client', client]) + for network in networks: + self.cli_set(base_path + ['community', community, 'network', network]) + + for addr in listen: + self.cli_set(base_path + ['listen-address', addr, 'port', port]) + + self.cli_set(base_path + ['contact', 'maintainers@vyos.io']) + self.cli_set(base_path + ['location', 'qemu']) + self.cli_set(base_path + ['protocol', 'tcp']) + + self.cli_commit() + + # verify listen address, it will be returned as + # ['unix:/run/snmpd.socket,tcp:127.0.0.1:161,tcp6:[::1]:161'] + # thus we need to transfor this into a proper list + config = get_config_value('agentaddress') + expected = 'unix:/run/snmpd.socket' + self.assertIn(expected, config) + + for addr in listen: + if is_ipv4(addr): + expected = f'tcp:{addr}:{port}' + else: + expected = f'tcp6:[{addr}]:{port}' + self.assertIn(expected, config) + + # Check for running process + self.assertTrue(process_named_running(PROCESS_NAME)) + self.cli_delete(['interfaces', 'dummy', dummy_if]) def test_snmpv3_sha(self): # Check if SNMPv3 can be configured with SHA authentication |