From 0518980ab8319b708d9ff64aaacc2e2fd8d0a911 Mon Sep 17 00:00:00 2001 From: Pieprzycki Piotr Date: Fri, 11 Nov 2016 23:35:51 +0100 Subject: [PATCH] unit tests, fix returned data --- napalm_vyos/vyos.py | 128 ++++++++++-------- test/unit/TestDriver.py | 80 ----------- test/unit/TestVyOSDriver.py | 37 +++++ test/unit/conftest.py | 56 ++++++++ .../normal/expected_result.json | 1 + .../test_get_arp_table/normal/show_arp.text | 5 + .../normal/expected_result.json | 1 + .../show_ip_bgp_neighbors_10_0_12_1.text | 43 ++++++ .../normal/show_ip_bgp_summary.text | 9 ++ .../normal/expected_result.json | 1 + .../test_get_environment/normal/free.text | 4 + .../test_get_environment/normal/vmstat.text | 3 + .../normal/expected_result.json | 1 + .../normal/expected_result.json | 1 + .../normal/show_interfaces.text | 9 ++ .../normal/expected_result.json | 1 + .../normal/show_interfaces_detail.txt | 37 +++++ .../normal/expected_result.json | 1 + .../normal/expected_result.json | 1 + .../test_get_ntp_peers/normal/ntpq.text | 5 + .../normal/expected_result.json | 1 + .../test_get_ntp_stats/normal/ntpq.text | 5 + .../normal/expected_result.json | 1 + .../normal/expected_result.json | 1 + .../test_ping/normal/expected_result.json | 1 + ...g_8.8.8.8_timeout_2_size_100_repeat_5.text | 10 ++ test/unit/skeleton/initial.conf | 1 - test/unit/skeleton/merge_good.conf | 1 - test/unit/skeleton/merge_good.diff | 1 - test/unit/skeleton/merge_typo.conf | 2 - test/unit/skeleton/new_good.conf | 1 - test/unit/skeleton/new_good.diff | 1 - test/unit/skeleton/new_typo.conf | 2 - test/unit/test_getters.py | 11 ++ test/unit/vyos/initial.conf | 127 +++++++++++++++++ test/unit/vyos/merge_good.conf | 1 + test/unit/vyos/merge_good.diff | 4 + test/unit/vyos/merge_typo.conf | 1 + .../{skeleton => vyos}/mock_data/.placeholder | 0 test/unit/vyos/new_good.conf | 127 +++++++++++++++++ test/unit/vyos/new_good.diff | 4 + test/unit/vyos/new_typo.conf | 128 ++++++++++++++++++ 42 files changed, 713 insertions(+), 142 deletions(-) delete mode 100644 test/unit/TestDriver.py create mode 100644 test/unit/TestVyOSDriver.py create mode 100644 test/unit/conftest.py create mode 100644 test/unit/mocked_data/test_get_arp_table/normal/expected_result.json create mode 100644 test/unit/mocked_data/test_get_arp_table/normal/show_arp.text create mode 100644 test/unit/mocked_data/test_get_bgp_neighbors/normal/expected_result.json create mode 100644 test/unit/mocked_data/test_get_bgp_neighbors/normal/show_ip_bgp_neighbors_10_0_12_1.text create mode 100644 test/unit/mocked_data/test_get_bgp_neighbors/normal/show_ip_bgp_summary.text create mode 100644 test/unit/mocked_data/test_get_environment/normal/expected_result.json create mode 100644 test/unit/mocked_data/test_get_environment/normal/free.text create mode 100644 test/unit/mocked_data/test_get_environment/normal/vmstat.text create mode 100644 test/unit/mocked_data/test_get_facts/normal/expected_result.json create mode 100644 test/unit/mocked_data/test_get_interfaces/normal/expected_result.json create mode 100644 test/unit/mocked_data/test_get_interfaces/normal/show_interfaces.text create mode 100644 test/unit/mocked_data/test_get_interfaces_counters/normal/expected_result.json create mode 100644 test/unit/mocked_data/test_get_interfaces_counters/normal/show_interfaces_detail.txt create mode 100644 test/unit/mocked_data/test_get_interfaces_ip/normal/expected_result.json create mode 100644 test/unit/mocked_data/test_get_ntp_peers/normal/expected_result.json create mode 100644 test/unit/mocked_data/test_get_ntp_peers/normal/ntpq.text create mode 100644 test/unit/mocked_data/test_get_ntp_stats/normal/expected_result.json create mode 100644 test/unit/mocked_data/test_get_ntp_stats/normal/ntpq.text create mode 100644 test/unit/mocked_data/test_get_snmp_information/normal/expected_result.json create mode 100644 test/unit/mocked_data/test_get_users/normal/expected_result.json create mode 100644 test/unit/mocked_data/test_ping/normal/expected_result.json create mode 100644 test/unit/mocked_data/test_ping/normal/ping_8.8.8.8_timeout_2_size_100_repeat_5.text delete mode 100644 test/unit/skeleton/initial.conf delete mode 100644 test/unit/skeleton/merge_good.conf delete mode 100644 test/unit/skeleton/merge_good.diff delete mode 100644 test/unit/skeleton/merge_typo.conf delete mode 100644 test/unit/skeleton/new_good.conf delete mode 100644 test/unit/skeleton/new_good.diff delete mode 100644 test/unit/skeleton/new_typo.conf create mode 100644 test/unit/test_getters.py create mode 100644 test/unit/vyos/initial.conf create mode 100644 test/unit/vyos/merge_good.conf create mode 100644 test/unit/vyos/merge_good.diff create mode 100644 test/unit/vyos/merge_typo.conf rename test/unit/{skeleton => vyos}/mock_data/.placeholder (100%) create mode 100644 test/unit/vyos/new_good.conf create mode 100644 test/unit/vyos/new_good.diff create mode 100644 test/unit/vyos/new_typo.conf diff --git a/napalm_vyos/vyos.py b/napalm_vyos/vyos.py index 608491d..2cda003 100644 --- a/napalm_vyos/vyos.py +++ b/napalm_vyos/vyos.py @@ -211,21 +211,27 @@ class VyOSDriver(NetworkDriver): environment = { "fans": { - "status": None + "invalid": { + "status": False + } }, "temperature": { - "temperature": None, - "is_alert" : None, - "is_critical": None + "invalid" : { + "temperature": 0.0, + "is_alert" : False, + "is_critical": False + } }, "power": { - "status" : None, - "capacity": None, - "output" : None + "invalid" : { + "status" : True, + "capacity": 0.0, + "output" : 0.0 + } }, "cpu": { "0": { - "%usage": cpu + "%usage": float(cpu) }, }, "memory": { @@ -273,20 +279,28 @@ class VyOSDriver(NetworkDriver): for iface_name in ifaces_detail: description = self._get_value("description", ifaces_detail[iface_name]) + if description is None: + description = "" speed = self._get_value("speed", ifaces_detail[iface_name]) + if speed is None: + speed = 0 + if speed == "auto": + speed = 0 hw_id = self._get_value("hw-id", ifaces_detail[iface_name]) + if hw_id is None: + hw_id = "00:00:00:00:00:00" is_up = (iface_state[iface_name]["Link"] == "u") is_enabled = (iface_state[iface_name]["State"] == "u") iface_dict.update({ iface_name: { - "is_up" : is_up, - "is_enabled" : is_enabled, - "description" : description, - "last_flapped" : -1, - "speed" : speed, - "mac_address" : hw_id + "is_up" : bool(is_up), + "is_enabled" : bool(is_enabled), + "description" : unicode(description), + "last_flapped" : float(-1), + "speed" : int(speed), + "mac_address" : unicode(hw_id) } }) @@ -328,16 +342,18 @@ class VyOSDriver(NetworkDriver): # ["10.129.2.254", "ether", "00:50:56:97:af:b1", "C", "eth0"] # [u'10.0.12.33', u'(incomplete)', u'eth1'] if "incomplete" in line[1]: - macaddr=None + macaddr=unicode("00:00:00:00:00:00") else: macaddr=unicode(line[2]) - arp_table.append({ - "interface" : unicode(line[-1]), - "mac" : macaddr, - "ip" : unicode(line[0]), - "age" : None - }) + arp_table.append( + { + 'interface': unicode(line[-1]), + 'mac': macaddr, + 'ip': unicode(line[0]), + 'age': 0.0 + } + ) return arp_table @@ -370,10 +386,10 @@ class VyOSDriver(NetworkDriver): ntp_stats.append({ "remote" : unicode(ip), "referenceid" : unicode(refid), - "synchronized": synchronized, + "synchronized": bool(synchronized), "stratum" : int(st), "type" : unicode(t), - "when" : int(when), + "when" : unicode(when), "hostpoll" : int(hostpoll), "reachability": int(reachability), "delay" : float(delay), @@ -472,20 +488,20 @@ class VyOSDriver(NetworkDriver): bgp_neighbor_data["global"]["peers"].setdefault(peer_id, {}) peer_dict = { - "description": "", - "is_enabled" : is_enabled, - "local_as" : local_as, - "is_up" : is_up, + "description": unicode(""), + "is_enabled" : bool(is_enabled), + "local_as" : int(local_as), + "is_up" : bool(is_up), "remote_id" : unicode(remote_rid), - "uptime" : self._bgp_time_conversion(up_time), + "uptime" : int(self._bgp_time_conversion(up_time)), "remote_as" : int(remote_as) } af_dict = dict() af_dict[address_family] = { - "sent_prefixes" : None, + "sent_prefixes" : int(-1), "accepted_prefixes": int(accepted_prefixes), - "received_prefixes": received_prefixes + "received_prefixes": int(received_prefixes) } peer_dict["address_family"] = af_dict @@ -555,22 +571,22 @@ class VyOSDriver(NetworkDriver): rx_octets = i[0] rx_unicast_packets = i[1] rx_multicast_packets = i[5] - rx_broadcast_packets = None + rx_broadcast_packets = -1 else: counters.update({ interfaces[j / 2]: { - "tx_errors" : i[2], - "tx_discards" : i[3], - "tx_octets" : i[0], - "tx_unicast_packets" : i[1], - "tx_multicast_packets": None, - "tx_broadcast_packets": None, - "rx_errors" : rx_errors, - "rx_discards" : rx_discards, - "rx_octets" : rx_octets, - "rx_unicast_packets" : rx_unicast_packets, - "rx_multicast_packets": rx_multicast_packets, - "rx_broadcast_packets": rx_broadcast_packets + "tx_errors" : int(i[2]), + "tx_discards" : int(i[3]), + "tx_octets" : int(i[0]), + "tx_unicast_packets" : int(i[1]), + "tx_multicast_packets": int(-1), + "tx_broadcast_packets": int(-1), + "rx_errors" : int(rx_errors), + "rx_discards" : int(rx_discards), + "rx_octets" : int(rx_octets), + "rx_unicast_packets" : int(rx_unicast_packets), + "rx_multicast_packets": int(rx_multicast_packets), + "rx_broadcast_packets": int(rx_broadcast_packets) } }) j += 1 @@ -593,14 +609,15 @@ class VyOSDriver(NetworkDriver): for i in config["service"]["snmp"]["community"]: snmp["community"].update({ i: { - "acl": None, - "mode": config["service"]["snmp"]["community"][i]["authorization"] + "acl": unicode(""), + "mode": unicode(config["service"]["snmp"]["community"][i]["authorization"]) } }) snmp.update({ - "contact": config["service"]["snmp"]["contact"], - "location": config["service"]["snmp"]["location"] + "chassis_id": unicode(""), + "contact": unicode(config["service"]["snmp"]["contact"]), + "location": unicode(config["service"]["snmp"]["location"]) }) return snmp @@ -635,7 +652,7 @@ class VyOSDriver(NetworkDriver): if "domain-name" in config["system"]: fqdn = config["system"]["domain-name"] else: - fqdn = None + fqdn = "" iface_list = list() for iface_type in config["interfaces"]: @@ -644,7 +661,7 @@ class VyOSDriver(NetworkDriver): facts = { "uptime" : int(uptime), - "vendor" : "VyOS", + "vendor" : unicode("VyOS"), "os_version" : unicode(version), "serial_number" : unicode(snumber), "model" : unicode(hwmodel), @@ -701,7 +718,7 @@ class VyOSDriver(NetworkDriver): if ip_ver not in ifaces_ip[iface_name]: ifaces_ip[iface_name][ip_ver] = dict() - ifaces_ip[iface_name][ip_ver][ip_addr] = { "prefix_length": mask } + ifaces_ip[iface_name][ip_ver][ip_addr] = { "prefix_length": int(mask) } return ifaces_ip @@ -794,23 +811,28 @@ class VyOSDriver(NetworkDriver): # 'rtt_info' example: # ["0.307/0.396/0.480/0.061"] rtt_info = output_ping.split("\n")[-1] - match = re.search("([\d\.]+)/([\d\.]+)/([\d\.]+)/[\d\.]+", rtt_info) + match = re.search("([\d\.]+)/([\d\.]+)/([\d\.]+)/([\d\.]+)", rtt_info) if match is not None: rtt_min = float(match.group(1)) rtt_avg = float(match.group(2)) + rtt_max = float(match.group(3)) + rtt_stddev = float(match.group(4)) else: rtt_min = None rtt_avg = None + rtt_max = None + rtt_stddev = None ping_result["success"] = dict() ping_result["success"] = { "probes_sent": sent, "packet_loss": lost, "rtt_min" : rtt_min, + "rtt_max" : rtt_max, "rtt_avg" : rtt_avg, - "rtt_stdev" : None, - "results" : {"ip_address": destination, "rtt": rtt_avg} + "rtt_stddev" : rtt_stddev, + "results" : [{"ip_address": destination, "rtt": rtt_avg}] } return ping_result diff --git a/test/unit/TestDriver.py b/test/unit/TestDriver.py deleted file mode 100644 index cbef7f1..0000000 --- a/test/unit/TestDriver.py +++ /dev/null @@ -1,80 +0,0 @@ -# Copyright 2016 Dravetech AB. All rights reserved. -# -# The contents of this file are licensed under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with the -# License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations under -# the License. - -"""Tests.""" - -import unittest - -from napalm_skeleton import skeleton -from napalm_base.test.base import TestConfigNetworkDriver, TestGettersNetworkDriver -import json - - -class TestConfigDriver(unittest.TestCase, TestConfigNetworkDriver): - """Group of tests that test Configuration related methods.""" - - @classmethod - def setUpClass(cls): - """Run before starting the tests.""" - hostname = '127.0.0.1' - username = 'vagrant' - password = 'vagrant' - cls.vendor = 'skeleton' - - optional_args = {'port': 12443, } - cls.device = skeleton.SkeletonDriver(hostname, username, password, timeout=60, - optional_args=optional_args) - cls.device.open() - - cls.device.load_replace_candidate(filename='%s/initial.conf' % cls.vendor) - cls.device.commit_config() - - -class TestGetterDriver(unittest.TestCase, TestGettersNetworkDriver): - """Group of tests that test getters.""" - - @classmethod - def setUpClass(cls): - """Run before starting the tests.""" - cls.mock = True - - hostname = '127.0.0.1' - username = 'vagrant' - password = 'vagrant' - cls.vendor = 'skeleton' - - optional_args = {'port': 12443, } - cls.device = skeleton.SkeletonDriver(hostname, username, password, timeout=60, - optional_args=optional_args) - - if cls.mock: - cls.device.device = FakeDevice() - else: - cls.device.open() - - -class FakeDevice: - """Test double.""" - - @staticmethod - def read_json_file(filename): - """Return the content of a file with content formatted as json.""" - with open(filename) as data_file: - return json.load(data_file) - - @staticmethod - def read_txt_file(filename): - """Return the content of a file.""" - with open(filename) as data_file: - return data_file.read() diff --git a/test/unit/TestVyOSDriver.py b/test/unit/TestVyOSDriver.py new file mode 100644 index 0000000..d5ed8a7 --- /dev/null +++ b/test/unit/TestVyOSDriver.py @@ -0,0 +1,37 @@ +# Copyright 2015 Spotify AB. All rights reserved. +# +# The contents of this file are licensed under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with the +# License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations under +# the License. + +import unittest + +from napalm_vyos import vyos +from napalm_base.test.base import TestConfigNetworkDriver + + +class TestConfigVyOSDriver(unittest.TestCase, TestConfigNetworkDriver): + + @classmethod + def setUpClass(cls): + hostname = '127.0.0.1' + username = 'vagrant' + password = 'vagrant' + cls.vendor = 'vyos' + cls.port = '2200' + + optional_args = {'port': '2200' } + cls.device = vyos.VyOSDriver(hostname, username, password, + timeout=60, optional_args=optional_args) + cls.device.open() + + cls.device.load_replace_candidate(filename='%s/initial.conf' % cls.vendor) + cls.device.commit_config() diff --git a/test/unit/conftest.py b/test/unit/conftest.py new file mode 100644 index 0000000..8358f78 --- /dev/null +++ b/test/unit/conftest.py @@ -0,0 +1,56 @@ +"""Test fixtures.""" +from builtins import super + +import pytest +from napalm_base.test import conftest as parent_conftest + +from napalm_base.test.double import BaseTestDouble + +from napalm_vyos import vyos + + +@pytest.fixture(scope='class') +def set_device_parameters(request): + """Set up the class.""" + def fin(): + request.cls.device.close() + request.addfinalizer(fin) + + request.cls.driver = vyos.VyOSDriver + request.cls.patched_driver = PatchedVyOSDriver + request.cls.vendor = 'vyos' + parent_conftest.set_device_parameters(request) + + +def pytest_generate_tests(metafunc): + """Generate test cases dynamically.""" + parent_conftest.pytest_generate_tests(metafunc, __file__) + + +class PatchedVyOSDriver(vyos.VyOSDriver): + """Patched VyOS Driver.""" + + def __init__(self, hostname, username, password, timeout=60, optional_args=None): + super().__init__(hostname, username, password, timeout, optional_args) + + self.patched_attrs = ['device'] + self.device = FakeVyOSDevice() + + +class FakeVyOSDevice(BaseTestDouble): + """VyOS device test double.""" + + def run_commands(self, command_list, encoding='json'): + """Fake run_commands.""" + result = list() + + for command in command_list: + filename = '{}.{}'.format(self.sanitize_text(command), encoding) + full_path = self.find_file(filename) + + if encoding == 'json': + result.append(self.read_json_file(full_path)) + else: + result.append({'output': self.read_txt_file(full_path)}) + + return result diff --git a/test/unit/mocked_data/test_get_arp_table/normal/expected_result.json b/test/unit/mocked_data/test_get_arp_table/normal/expected_result.json new file mode 100644 index 0000000..f031bd9 --- /dev/null +++ b/test/unit/mocked_data/test_get_arp_table/normal/expected_result.json @@ -0,0 +1 @@ +[{"interface": "eth1", "ip": "10.0.12.33", "mac": "00:00:00:00:00:00", "age": 0.0}, {"interface": "eth1", "ip": "10.0.12.1", "mac": "08:00:27:60:0f:ee", "age": 0.0}, {"interface": "eth0", "ip": "10.0.2.2", "mac": "52:54:00:12:35:02", "age": 0.0}] diff --git a/test/unit/mocked_data/test_get_arp_table/normal/show_arp.text b/test/unit/mocked_data/test_get_arp_table/normal/show_arp.text new file mode 100644 index 0000000..6e5efde --- /dev/null +++ b/test/unit/mocked_data/test_get_arp_table/normal/show_arp.text @@ -0,0 +1,5 @@ +Address HWtype HWaddress Flags Mask Iface +10.0.12.33 (incomplete) eth1 +10.0.12.1 ether 08:00:27:60:0f:ee C eth1 +10.0.2.2 ether 52:54:00:12:35:02 C eth0 +10.0.2.3 ether 52:54:00:12:35:03 C eth0 diff --git a/test/unit/mocked_data/test_get_bgp_neighbors/normal/expected_result.json b/test/unit/mocked_data/test_get_bgp_neighbors/normal/expected_result.json new file mode 100644 index 0000000..75c97a6 --- /dev/null +++ b/test/unit/mocked_data/test_get_bgp_neighbors/normal/expected_result.json @@ -0,0 +1 @@ +{"global": {"router_id": "10.2.2.2", "peers": {"10.0.12.1": {"is_enabled": true, "uptime": 864000, "remote_as": 65001, "description": "", "remote_id": "10.1.1.1", "local_as": 65002, "is_up": true, "address_family": {"ipv4": {"sent_prefixes": -1, "accepted_prefixes": 4, "received_prefixes": 4}}}}}} diff --git a/test/unit/mocked_data/test_get_bgp_neighbors/normal/show_ip_bgp_neighbors_10_0_12_1.text b/test/unit/mocked_data/test_get_bgp_neighbors/normal/show_ip_bgp_neighbors_10_0_12_1.text new file mode 100644 index 0000000..6f12f68 --- /dev/null +++ b/test/unit/mocked_data/test_get_bgp_neighbors/normal/show_ip_bgp_neighbors_10_0_12_1.text @@ -0,0 +1,43 @@ +BGP neighbor is 10.0.12.1, remote AS 65001, local AS 65002, external link + BGP version 4, remote router ID 10.1.1.1 + BGP state = Established, up for 01w3d00h + Last read 03:39:29, hold time is 90, keepalive interval is 30 seconds + Neighbor capabilities: + 4 Byte AS: advertised and received + Route refresh: advertised and received(old & new) + Address family IPv4 Unicast: advertised and received + Graceful Restart Capabilty: received + Remote Restart timer is 120 seconds + Address families by peer: + none + Graceful restart informations: + End-of-RIB send: IPv4 Unicast + End-of-RIB received: + Message statistics: + Inq depth is 0 + Outq depth is 0 + Sent Rcvd + Opens: 2 2 + Notifications: 1 0 + Updates: 4 2 + Keepalives: 33375 36937 + Route Refresh: 0 0 + Capability: 0 0 + Total: 33382 36941 + Minimum time between advertisement runs is 30 seconds + + For address family: IPv4 Unicast + Community attribute sent to this neighbor(both) + Outbound path policy configured + Route map for outgoing advertisements is *EXPORT-POLICY + 4 accepted prefixes + + Connections established 2; dropped 1 + Last reset 01w3d00h, due to User reset +Local host: 10.0.12.2, Local port: 33945 +Foreign host: 10.0.12.1, Foreign port: 179 +Nexthop: 10.0.12.2 +Nexthop global: fe80::a00:27ff:fe41:d5f8 +Nexthop local: :: +BGP connection: non shared network +Read thread: on Write thread: off diff --git a/test/unit/mocked_data/test_get_bgp_neighbors/normal/show_ip_bgp_summary.text b/test/unit/mocked_data/test_get_bgp_neighbors/normal/show_ip_bgp_summary.text new file mode 100644 index 0000000..25c5a56 --- /dev/null +++ b/test/unit/mocked_data/test_get_bgp_neighbors/normal/show_ip_bgp_summary.text @@ -0,0 +1,9 @@ +BGP router identifier 10.2.2.2, local AS number 65002 +IPv4 Unicast - max multipaths: ebgp 1 ibgp 1 +RIB entries 9, using 864 bytes of memory +Peers 1, using 4560 bytes of memory + +Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd +10.0.12.1 4 65001 36938 33380 0 0 0 01w3d00h 4 + +Total number of neighbors 1 diff --git a/test/unit/mocked_data/test_get_environment/normal/expected_result.json b/test/unit/mocked_data/test_get_environment/normal/expected_result.json new file mode 100644 index 0000000..54abd07 --- /dev/null +++ b/test/unit/mocked_data/test_get_environment/normal/expected_result.json @@ -0,0 +1 @@ +{"fans": {"invalid": {"status": false}}, "memory": {"available_ram": 250112, "used_ram": 228668}, "temperature": {"invalid": {"is_alert": false, "temperature": 0.0, "is_critical": false}}, "power": {"invalid": {"status": true, "output": 0.0, "capacity": 0.0}}, "cpu": {"0": {"%usage": 1.0}}} diff --git a/test/unit/mocked_data/test_get_environment/normal/free.text b/test/unit/mocked_data/test_get_environment/normal/free.text new file mode 100644 index 0000000..dbf0df6 --- /dev/null +++ b/test/unit/mocked_data/test_get_environment/normal/free.text @@ -0,0 +1,4 @@ + total used free shared buffers cached +Mem: 250112 222708 27404 0 45144 93184 +-/+ buffers/cache: 84380 165732 +Swap: 0 0 0 diff --git a/test/unit/mocked_data/test_get_environment/normal/vmstat.text b/test/unit/mocked_data/test_get_environment/normal/vmstat.text new file mode 100644 index 0000000..81d1eb9 --- /dev/null +++ b/test/unit/mocked_data/test_get_environment/normal/vmstat.text @@ -0,0 +1,3 @@ +procs -----------memory---------- ---swap-- -----io---- -system-- ----cpu---- + r b swpd free buff cache si so bi bo in cs us sy id wa + 0 0 0 27460 45136 93184 0 0 0 0 15 24 0 0 99 0 diff --git a/test/unit/mocked_data/test_get_facts/normal/expected_result.json b/test/unit/mocked_data/test_get_facts/normal/expected_result.json new file mode 100644 index 0000000..0b4cd05 --- /dev/null +++ b/test/unit/mocked_data/test_get_facts/normal/expected_result.json @@ -0,0 +1 @@ +{"os_version": "1.1.7", "uptime": 1043562, "interface_list": ["eth1", "eth0", "lo"], "vendor": "VyOS", "serial_number": "0", "model": "VirtualBox", "hostname": "vyos2", "fqdn": ""} diff --git a/test/unit/mocked_data/test_get_interfaces/normal/expected_result.json b/test/unit/mocked_data/test_get_interfaces/normal/expected_result.json new file mode 100644 index 0000000..7846df5 --- /dev/null +++ b/test/unit/mocked_data/test_get_interfaces/normal/expected_result.json @@ -0,0 +1 @@ +{"lo": {"is_enabled": true, "description": "", "last_flapped": -1.0, "is_up": true, "mac_address": "00:00:00:00:00:00", "speed": 0}, "eth1": {"is_enabled": true, "description": "", "last_flapped": -1.0, "is_up": true, "mac_address": "08:00:27:41:d5:f8", "speed": 0}, "eth0": {"is_enabled": true, "description": "", "last_flapped": -1.0, "is_up": true, "mac_address": "08:00:27:c5:c9:67", "speed": 0}} diff --git a/test/unit/mocked_data/test_get_interfaces/normal/show_interfaces.text b/test/unit/mocked_data/test_get_interfaces/normal/show_interfaces.text new file mode 100644 index 0000000..de8f866 --- /dev/null +++ b/test/unit/mocked_data/test_get_interfaces/normal/show_interfaces.text @@ -0,0 +1,9 @@ +Codes: S - State, L - Link, u - Up, D - Down, A - Admin Down +Interface IP Address S/L Description +--------- ---------- --- ----------- +eth0 10.0.2.15/24 u/u +eth1 10.0.12.2/24 u/u +lo 127.0.0.1/8 u/u + 10.2.2.2/32 + 8.8.8.8/32 + ::1/128 diff --git a/test/unit/mocked_data/test_get_interfaces_counters/normal/expected_result.json b/test/unit/mocked_data/test_get_interfaces_counters/normal/expected_result.json new file mode 100644 index 0000000..d47db80 --- /dev/null +++ b/test/unit/mocked_data/test_get_interfaces_counters/normal/expected_result.json @@ -0,0 +1 @@ +{"eth1": {"tx_discards": 0, "tx_unicast_packets": 1124144, "rx_broadcast_packets": -1, "rx_discards": 0, "tx_multicast_packets": -1, "tx_octets": 128843591, "tx_errors": 0, "rx_octets": 128902602, "rx_errors": 0, "tx_broadcast_packets": -1, "rx_multicast_packets": 0, "rx_unicast_packets": 1123974}, "eth0": {"tx_discards": 0, "tx_unicast_packets": 1228025, "rx_broadcast_packets": -1, "rx_discards": 0, "tx_multicast_packets": -1, "tx_octets": 341284276, "tx_errors": 0, "rx_octets": 136039132, "rx_errors": 0, "tx_broadcast_packets": -1, "rx_multicast_packets": 0, "rx_unicast_packets": 1231464}} diff --git a/test/unit/mocked_data/test_get_interfaces_counters/normal/show_interfaces_detail.txt b/test/unit/mocked_data/test_get_interfaces_counters/normal/show_interfaces_detail.txt new file mode 100644 index 0000000..c7357a2 --- /dev/null +++ b/test/unit/mocked_data/test_get_interfaces_counters/normal/show_interfaces_detail.txt @@ -0,0 +1,37 @@ +eth0: mtu 1500 qdisc pfifo_fast state UP group default qlen 1000 + link/ether 08:00:27:c5:c9:67 brd ff:ff:ff:ff:ff:ff + inet 10.0.2.15/24 brd 10.0.2.255 scope global eth0 + valid_lft forever preferred_lft forever + inet6 fe80::a00:27ff:fec5:c967/64 scope link + valid_lft forever preferred_lft forever + + RX: bytes packets errors dropped overrun mcast + 136000952 1231123 0 0 0 0 + TX: bytes packets errors dropped carrier collisions + 341194779 1227696 0 0 0 0 +eth1: mtu 1500 qdisc pfifo_fast state UP group default qlen 1000 + link/ether 08:00:27:41:d5:f8 brd ff:ff:ff:ff:ff:ff + inet 10.0.12.2/24 brd 10.0.12.255 scope global eth1 + valid_lft forever preferred_lft forever + inet6 fe80::a00:27ff:fe41:d5f8/64 scope link + valid_lft forever preferred_lft forever + + RX: bytes packets errors dropped overrun mcast + 128872155 1123706 0 0 0 0 + TX: bytes packets errors dropped carrier collisions + 128813163 1123876 0 0 0 0 +lo: mtu 65536 qdisc noqueue state UNKNOWN group default + link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 + inet 127.0.0.1/8 scope host lo + valid_lft forever preferred_lft forever + inet 10.2.2.2/32 scope global lo + valid_lft forever preferred_lft forever + inet 8.8.8.8/32 scope global lo + valid_lft forever preferred_lft forever + inet6 ::1/128 scope host + valid_lft forever preferred_lft forever + + RX: bytes packets errors dropped overrun mcast + 75048164 1249364 0 0 0 0 + TX: bytes packets errors dropped carrier collisions + 75048164 1249364 0 0 0 0 diff --git a/test/unit/mocked_data/test_get_interfaces_ip/normal/expected_result.json b/test/unit/mocked_data/test_get_interfaces_ip/normal/expected_result.json new file mode 100644 index 0000000..467ce1c --- /dev/null +++ b/test/unit/mocked_data/test_get_interfaces_ip/normal/expected_result.json @@ -0,0 +1 @@ +{"lo": {"ipv4": {"8.8.8.8": {"prefix_length": 32}, "127.0.0.1": {"prefix_length": 8}, "10.2.2.2": {"prefix_length": 32}}}, "eth1": {"ipv4": {"10.0.12.2": {"prefix_length": 24}}}, "eth0": {"ipv4": {"10.0.2.15": {"prefix_length": 24}}}} diff --git a/test/unit/mocked_data/test_get_ntp_peers/normal/expected_result.json b/test/unit/mocked_data/test_get_ntp_peers/normal/expected_result.json new file mode 100644 index 0000000..73db329 --- /dev/null +++ b/test/unit/mocked_data/test_get_ntp_peers/normal/expected_result.json @@ -0,0 +1 @@ +{"31.216.56.5": {}, "46.175.224.7": {}, "91.212.242.21": {}} diff --git a/test/unit/mocked_data/test_get_ntp_peers/normal/ntpq.text b/test/unit/mocked_data/test_get_ntp_peers/normal/ntpq.text new file mode 100644 index 0000000..54d7b61 --- /dev/null +++ b/test/unit/mocked_data/test_get_ntp_peers/normal/ntpq.text @@ -0,0 +1,5 @@ + remote refid st t when poll reach delay offset jitter +============================================================================== + 31.216.56.5 .INIT. 16 u - 1024 0 0.000 0.000 0.000 + 46.175.224.7 .INIT. 16 u - 1024 0 0.000 0.000 0.000 + 91.212.242.21 .INIT. 16 u - 1024 0 0.000 0.000 0.000 diff --git a/test/unit/mocked_data/test_get_ntp_stats/normal/expected_result.json b/test/unit/mocked_data/test_get_ntp_stats/normal/expected_result.json new file mode 100644 index 0000000..9ab64f8 --- /dev/null +++ b/test/unit/mocked_data/test_get_ntp_stats/normal/expected_result.json @@ -0,0 +1 @@ +[{"jitter": 0.0, "synchronized": false, "offset": 0.0, "referenceid": ".INIT.", "remote": "31.216.56.5", "reachability": 0, "when": "0", "delay": 0.0, "hostpoll": 1024, "stratum": 16, "type": "u"}, {"jitter": 0.0, "synchronized": false, "offset": 0.0, "referenceid": ".INIT.", "remote": "46.175.224.7", "reachability": 0, "when": "0", "delay": 0.0, "hostpoll": 1024, "stratum": 16, "type": "u"}, {"jitter": 0.0, "synchronized": false, "offset": 0.0, "referenceid": ".INIT.", "remote": "91.212.242.21", "reachability": 0, "when": "0", "delay": 0.0, "hostpoll": 1024, "stratum": 16, "type": "u"}] diff --git a/test/unit/mocked_data/test_get_ntp_stats/normal/ntpq.text b/test/unit/mocked_data/test_get_ntp_stats/normal/ntpq.text new file mode 100644 index 0000000..54d7b61 --- /dev/null +++ b/test/unit/mocked_data/test_get_ntp_stats/normal/ntpq.text @@ -0,0 +1,5 @@ + remote refid st t when poll reach delay offset jitter +============================================================================== + 31.216.56.5 .INIT. 16 u - 1024 0 0.000 0.000 0.000 + 46.175.224.7 .INIT. 16 u - 1024 0 0.000 0.000 0.000 + 91.212.242.21 .INIT. 16 u - 1024 0 0.000 0.000 0.000 diff --git a/test/unit/mocked_data/test_get_snmp_information/normal/expected_result.json b/test/unit/mocked_data/test_get_snmp_information/normal/expected_result.json new file mode 100644 index 0000000..1e0d111 --- /dev/null +++ b/test/unit/mocked_data/test_get_snmp_information/normal/expected_result.json @@ -0,0 +1 @@ +{"contact": "admin@foo.corp", "location": "PL,Krakow", "community": {"commro": {"mode": "ro", "acl": ""}}, "chassis_id": ""} diff --git a/test/unit/mocked_data/test_get_users/normal/expected_result.json b/test/unit/mocked_data/test_get_users/normal/expected_result.json new file mode 100644 index 0000000..e4734d0 --- /dev/null +++ b/test/unit/mocked_data/test_get_users/normal/expected_result.json @@ -0,0 +1 @@ +{"vagrant": {"password": "$6$fcHhBu3T$WLmiu6/txlEfWK5uh4mKE8v7qocuftsoAN1oHqPIIoogXAX8zS.SKhB105EExYU6yBy4cKHUD/Q6Mm7CUbVTr.", "sshkeys": ["AAAAB3NzaC1yc2EAAAABIwAAAQEA6NF8iallvQVp22WDkTkyrtvp9eWW6A8YVr+kz4TjGYe7gHzIw+niNltGEFHzD8+v1I2YJ6oXevct1YeS0o9HZyN1Q9qgCgzUFtdOKLv6IedplqoPkcmF0aYet2PkEDo3MlTBckFXPITAMzF8dJSIFo9D8HfdOV0IAdx4O7PtixWKn5y2hMNG0zQPyUecp4pzC6kivAIhyfHilFR61RGL+GPXQ2MWZWFYbAGjyiYJnAmCP3NOTd0jMZEnDkbUvxhMmBYSdETk1rRgm+R4LOzFUGaHqHDLKLX+FIPKcF96hrucXzcWyLbIbEgE98OHlnVYCzRdK8jlqm8tehUc9c9WhQ=="], "level": 15}, "vyos": {"password": "$1$yHIMnG/J$aWDkd3oDYSYps8twB5vpw1", "sshkeys": [], "level": 15}} diff --git a/test/unit/mocked_data/test_ping/normal/expected_result.json b/test/unit/mocked_data/test_ping/normal/expected_result.json new file mode 100644 index 0000000..0621797 --- /dev/null +++ b/test/unit/mocked_data/test_ping/normal/expected_result.json @@ -0,0 +1 @@ +{"success": {"packet_loss": 0, "rtt_stddev": 0.123, "rtt_min": 0.086, "results": [{"rtt": 0.175, "ip_address": "8.8.8.8"}], "rtt_avg": 0.175, "rtt_max": 0.417, "probes_sent": 5}} diff --git a/test/unit/mocked_data/test_ping/normal/ping_8.8.8.8_timeout_2_size_100_repeat_5.text b/test/unit/mocked_data/test_ping/normal/ping_8.8.8.8_timeout_2_size_100_repeat_5.text new file mode 100644 index 0000000..cd80b9d --- /dev/null +++ b/test/unit/mocked_data/test_ping/normal/ping_8.8.8.8_timeout_2_size_100_repeat_5.text @@ -0,0 +1,10 @@ +PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data. +64 bytes from 8.8.8.8: icmp_req=1 ttl=64 time=0.112 ms +64 bytes from 8.8.8.8: icmp_req=2 ttl=64 time=0.114 ms +64 bytes from 8.8.8.8: icmp_req=3 ttl=64 time=0.136 ms +64 bytes from 8.8.8.8: icmp_req=4 ttl=64 time=0.112 ms +64 bytes from 8.8.8.8: icmp_req=5 ttl=64 time=0.112 ms + +--- 8.8.8.8 ping statistics --- +5 packets transmitted, 5 received, 0% packet loss, time 4006ms +rtt min/avg/max/mdev = 0.112/0.117/0.136/0.011 ms diff --git a/test/unit/skeleton/initial.conf b/test/unit/skeleton/initial.conf deleted file mode 100644 index 859698e..0000000 --- a/test/unit/skeleton/initial.conf +++ /dev/null @@ -1 +0,0 @@ -Initial configuration diff --git a/test/unit/skeleton/merge_good.conf b/test/unit/skeleton/merge_good.conf deleted file mode 100644 index 89ef127..0000000 --- a/test/unit/skeleton/merge_good.conf +++ /dev/null @@ -1 +0,0 @@ -Some changes that will be merged while testing diff --git a/test/unit/skeleton/merge_good.diff b/test/unit/skeleton/merge_good.diff deleted file mode 100644 index 2b6918c..0000000 --- a/test/unit/skeleton/merge_good.diff +++ /dev/null @@ -1 +0,0 @@ -The diff when merging `merged_good.conf` diff --git a/test/unit/skeleton/merge_typo.conf b/test/unit/skeleton/merge_typo.conf deleted file mode 100644 index da7e876..0000000 --- a/test/unit/skeleton/merge_typo.conf +++ /dev/null @@ -1,2 +0,0 @@ -Some changes that will be merge while testing. Should contain a typo or something that triggers -an error during the load/commmit phase diff --git a/test/unit/skeleton/new_good.conf b/test/unit/skeleton/new_good.conf deleted file mode 100644 index e142fa9..0000000 --- a/test/unit/skeleton/new_good.conf +++ /dev/null @@ -1 +0,0 @@ -A full new configuration. It will be used to test the replace operation diff --git a/test/unit/skeleton/new_good.diff b/test/unit/skeleton/new_good.diff deleted file mode 100644 index a313d37..0000000 --- a/test/unit/skeleton/new_good.diff +++ /dev/null @@ -1 +0,0 @@ -A diff between `initial.conf` and `new_good.conf` diff --git a/test/unit/skeleton/new_typo.conf b/test/unit/skeleton/new_typo.conf deleted file mode 100644 index b97f25f..0000000 --- a/test/unit/skeleton/new_typo.conf +++ /dev/null @@ -1,2 +0,0 @@ -A full new configuration. However, it should contain a typo or something that triggers an error -during commit/load phase. diff --git a/test/unit/test_getters.py b/test/unit/test_getters.py new file mode 100644 index 0000000..6509001 --- /dev/null +++ b/test/unit/test_getters.py @@ -0,0 +1,11 @@ +"""Tests for getters.""" + +from napalm_base.test.getters import BaseTestGetters + + +import pytest + + +@pytest.mark.usefixtures("set_device_parameters") +class TestGetter(BaseTestGetters): + """Test get_* methods.""" diff --git a/test/unit/vyos/initial.conf b/test/unit/vyos/initial.conf new file mode 100644 index 0000000..c9ebf05 --- /dev/null +++ b/test/unit/vyos/initial.conf @@ -0,0 +1,127 @@ +interfaces { + ethernet eth0 { + address dhcp + } + ethernet eth1 { + address 10.0.12.2/24 + } + loopback lo { + address 10.2.2.2/32 + address 8.8.8.8/32 + } +} +policy { + prefix-list EXPORT { + rule 1 { + action permit + prefix 172.16.2.0/24 + } + rule 65535 { + action permit + prefix 10.2.2.2/32 + } + } + route-map EXPORT-POLICY { + rule 1 { + action permit + match { + ip { + address { + prefix-list EXPORT + } + } + } + } + } +} +protocols { + bgp 65002 { + neighbor 10.0.12.1 { + remote-as 65001 + route-map { + export EXPORT-POLICY + } + } + redistribute { + connected { + route-map EXPORT-POLICY + } + } + } +} +service { + snmp { + community commro { + authorization ro + } + contact admin@foo.corp + location PL,Krakow + } + ssh { + disable-host-validation + port 22 + } +} +system { + config-management { + commit-revisions 20 + } + host-name vyos2 + login { + banner { + pre-login "My banner for all devices" + } + user vagrant { + authentication { + encrypted-password $6$fcHhBu3T$WLmiu6/txlEfWK5uh4mKE8v7qocuftsoAN1oHqPIIoogXAX8zS.SKhB105EExYU6yBy4cKHUD/Q6Mm7CUbVTr. + plaintext-password "" + public-keys vagrant { + key AAAAB3NzaC1yc2EAAAABIwAAAQEA6NF8iallvQVp22WDkTkyrtvp9eWW6A8YVr+kz4TjGYe7gHzIw+niNltGEFHzD8+v1I2YJ6oXevct1YeS0o9HZyN1Q9qgCgzUFtdOKLv6IedplqoPkcmF0aYet2PkEDo3MlTBckFXPITAMzF8dJSIFo9D8HfdOV0IAdx4O7PtixWKn5y2hMNG0zQPyUecp4pzC6kivAIhyfHilFR61RGL+GPXQ2MWZWFYbAGjyiYJnAmCP3NOTd0jMZEnDkbUvxhMmBYSdETk1rRgm+R4LOzFUGaHqHDLKLX+FIPKcF96hrucXzcWyLbIbEgE98OHlnVYCzRdK8jlqm8tehUc9c9WhQ== + type ssh-rsa + } + } + level admin + } + user vyos { + authentication { + encrypted-password $1$yHIMnG/J$aWDkd3oDYSYps8twB5vpw1 + plaintext-password "" + } + level admin + } + } + ntp { + server 0.pool.ntp.org { + } + server 1.pool.ntp.org { + } + server 2.pool.ntp.org { + } + } + package { + auto-sync 1 + repository community { + components main + distribution helium + password "" + url http://packages.vyos.net/vyos + username "" + } + } + syslog { + global { + facility all { + level notice + } + facility protocols { + level debug + } + } + } + time-zone UTC +} + + +/* Warning: Do not remove the following line. */ +/* === vyatta-config-version: "cluster@1:config-management@1:conntrack-sync@1:conntrack@1:cron@1:dhcp-relay@1:dhcp-server@4:firewall@5:ipsec@4:nat@4:qos@1:quagga@2:system@6:vrrp@1:wanloadbalance@3:webgui@1:webproxy@1:zone-policy@1" === */ +/* Release version: VyOS 1.1.7 */ diff --git a/test/unit/vyos/merge_good.conf b/test/unit/vyos/merge_good.conf new file mode 100644 index 0000000..99c7180 --- /dev/null +++ b/test/unit/vyos/merge_good.conf @@ -0,0 +1 @@ +set system login banner pre-login "aaaa" diff --git a/test/unit/vyos/merge_good.diff b/test/unit/vyos/merge_good.diff new file mode 100644 index 0000000..e9bf967 --- /dev/null +++ b/test/unit/vyos/merge_good.diff @@ -0,0 +1,4 @@ +[edit system login banner] +>pre-login aaaa +[edit] + diff --git a/test/unit/vyos/merge_typo.conf b/test/unit/vyos/merge_typo.conf new file mode 100644 index 0000000..fd06c7c --- /dev/null +++ b/test/unit/vyos/merge_typo.conf @@ -0,0 +1 @@ +set cc system login banner pre-login "aaaa" diff --git a/test/unit/skeleton/mock_data/.placeholder b/test/unit/vyos/mock_data/.placeholder similarity index 100% rename from test/unit/skeleton/mock_data/.placeholder rename to test/unit/vyos/mock_data/.placeholder diff --git a/test/unit/vyos/new_good.conf b/test/unit/vyos/new_good.conf new file mode 100644 index 0000000..0fcbd8c --- /dev/null +++ b/test/unit/vyos/new_good.conf @@ -0,0 +1,127 @@ +interfaces { + ethernet eth0 { + address dhcp + } + ethernet eth1 { + address 10.0.12.2/24 + } + loopback lo { + address 10.2.2.2/32 + address 8.8.8.8/32 + } +} +policy { + prefix-list EXPORT { + rule 1 { + action permit + prefix 172.16.2.0/24 + } + rule 65535 { + action permit + prefix 10.2.2.2/32 + } + } + route-map EXPORT-POLICY { + rule 1 { + action permit + match { + ip { + address { + prefix-list EXPORT + } + } + } + } + } +} +protocols { + bgp 65002 { + neighbor 10.0.12.1 { + remote-as 65001 + route-map { + export EXPORT-POLICY + } + } + redistribute { + connected { + route-map EXPORT-POLICY + } + } + } +} +service { + snmp { + community commro { + authorization ro + } + contact admin@foo.corp + location PL,Krakow + } + ssh { + disable-host-validation + port 22 + } +} +system { + config-management { + commit-revisions 20 + } + host-name vyos2 + login { + banner { + pre-login "My new banner for all devices" + } + user vagrant { + authentication { + encrypted-password $6$fcHhBu3T$WLmiu6/txlEfWK5uh4mKE8v7qocuftsoAN1oHqPIIoogXAX8zS.SKhB105EExYU6yBy4cKHUD/Q6Mm7CUbVTr. + plaintext-password "" + public-keys vagrant { + key AAAAB3NzaC1yc2EAAAABIwAAAQEA6NF8iallvQVp22WDkTkyrtvp9eWW6A8YVr+kz4TjGYe7gHzIw+niNltGEFHzD8+v1I2YJ6oXevct1YeS0o9HZyN1Q9qgCgzUFtdOKLv6IedplqoPkcmF0aYet2PkEDo3MlTBckFXPITAMzF8dJSIFo9D8HfdOV0IAdx4O7PtixWKn5y2hMNG0zQPyUecp4pzC6kivAIhyfHilFR61RGL+GPXQ2MWZWFYbAGjyiYJnAmCP3NOTd0jMZEnDkbUvxhMmBYSdETk1rRgm+R4LOzFUGaHqHDLKLX+FIPKcF96hrucXzcWyLbIbEgE98OHlnVYCzRdK8jlqm8tehUc9c9WhQ== + type ssh-rsa + } + } + level admin + } + user vyos { + authentication { + encrypted-password $1$yHIMnG/J$aWDkd3oDYSYps8twB5vpw1 + plaintext-password "" + } + level admin + } + } + ntp { + server 0.pool.ntp.org { + } + server 1.pool.ntp.org { + } + server 2.pool.ntp.org { + } + } + package { + auto-sync 1 + repository community { + components main + distribution helium + password "" + url http://packages.vyos.net/vyos + username "" + } + } + syslog { + global { + facility all { + level notice + } + facility protocols { + level debug + } + } + } + time-zone UTC +} + + +/* Warning: Do not remove the following line. */ +/* === vyatta-config-version: "cluster@1:config-management@1:conntrack-sync@1:conntrack@1:cron@1:dhcp-relay@1:dhcp-server@4:firewall@5:ipsec@4:nat@4:qos@1:quagga@2:system@6:vrrp@1:wanloadbalance@3:webgui@1:webproxy@1:zone-policy@1" === */ +/* Release version: VyOS 1.1.7 */ diff --git a/test/unit/vyos/new_good.diff b/test/unit/vyos/new_good.diff new file mode 100644 index 0000000..46d4b36 --- /dev/null +++ b/test/unit/vyos/new_good.diff @@ -0,0 +1,4 @@ +[edit system login banner] +>pre-login "My new banner for all devices" +[edit] + diff --git a/test/unit/vyos/new_typo.conf b/test/unit/vyos/new_typo.conf new file mode 100644 index 0000000..8ca4496 --- /dev/null +++ b/test/unit/vyos/new_typo.conf @@ -0,0 +1,128 @@ +{ +interfaces { + ethernet eth0 { + address dhcp + } + ethernet eth1 { + address 10.0.12.2/24 + } + loopback lo { + address 10.2.2.2/32 + address 8.8.8.8/32 + } +} +policy { + prefix-list EXPORT { + rule 1 { + action permit + prefix 172.16.2.0/24 + } + rule 65535 { + action permit + prefix 10.2.2.2/32 + } + } + route-map EXPORT-POLICY { + rule 1 { + action permit + match { + ip { + address { + prefix-list EXPORT + } + } + } + } + } +} +protocols { + bgp 65002 { + neighbor 10.0.12.1 { + remote-as 65001 + route-map { + export EXPORT-POLICY + } + } + redistribute { + connected { + route-map EXPORT-POLICY + } + } + } +} +service { + snmp { + community commro { + authorization ro + } + contact admin@foo.corp + location PL,Krakow + } + ssh { + disable-host-validation + port 22 + } +} +system { + config-management { + commit-revisions 20 + } + host-name vyos2 + login { + banner { + pre-login "My new banner for all devices" + } + user vagrant { + authentication { + encrypted-password $6$fcHhBu3T$WLmiu6/txlEfWK5uh4mKE8v7qocuftsoAN1oHqPIIoogXAX8zS.SKhB105EExYU6yBy4cKHUD/Q6Mm7CUbVTr. + plaintext-password "" + public-keys vagrant { + key AAAAB3NzaC1yc2EAAAABIwAAAQEA6NF8iallvQVp22WDkTkyrtvp9eWW6A8YVr+kz4TjGYe7gHzIw+niNltGEFHzD8+v1I2YJ6oXevct1YeS0o9HZyN1Q9qgCgzUFtdOKLv6IedplqoPkcmF0aYet2PkEDo3MlTBckFXPITAMzF8dJSIFo9D8HfdOV0IAdx4O7PtixWKn5y2hMNG0zQPyUecp4pzC6kivAIhyfHilFR61RGL+GPXQ2MWZWFYbAGjyiYJnAmCP3NOTd0jMZEnDkbUvxhMmBYSdETk1rRgm+R4LOzFUGaHqHDLKLX+FIPKcF96hrucXzcWyLbIbEgE98OHlnVYCzRdK8jlqm8tehUc9c9WhQ== + type ssh-rsa + } + } + level admin + } + user vyos { + authentication { + encrypted-password $1$yHIMnG/J$aWDkd3oDYSYps8twB5vpw1 + plaintext-password "" + } + level admin + } + } + ntp { + server 0.pool.ntp.org { + } + server 1.pool.ntp.org { + } + server 2.pool.ntp.org { + } + } + package { + auto-sync 1 + repository community { + components main + distribution helium + password "" + url http://packages.vyos.net/vyos + username "" + } + } + syslog { + global { + facility all { + level notice + } + facility protocols { + level debug + } + } + } + time-zone UTC +} + + +/* Warning: Do not remove the following line. */ +/* === vyatta-config-version: "cluster@1:config-management@1:conntrack-sync@1:conntrack@1:cron@1:dhcp-relay@1:dhcp-server@4:firewall@5:ipsec@4:nat@4:qos@1:quagga@2:system@6:vrrp@1:wanloadbalance@3:webgui@1:webproxy@1:zone-policy@1" === */ +/* Release version: VyOS 1.1.7 */