Tomáš Pecka | f10b930 | 2021-02-23 19:02:02 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2021 CESNET, https://photonics.cesnet.cz/ |
| 3 | * |
| 4 | * Written by Tomáš Pecka <tomas.pecka@cesnet.cz> |
| 5 | * |
| 6 | */ |
| 7 | |
| 8 | #include "trompeloeil_doctest.h" |
| 9 | #include "pretty_printers.h" |
| 10 | #include "system/IETFInterfaces.h" |
| 11 | #include "test_log_setup.h" |
| 12 | #include "test_sysrepo_helpers.h" |
| 13 | #include "tests/mock/system.h" |
| 14 | |
| 15 | TEST_CASE("ietf-interfaces localhost") |
| 16 | { |
| 17 | TEST_SYSREPO_INIT_LOGS; |
| 18 | TEST_SYSREPO_INIT; |
| 19 | TEST_SYSREPO_INIT_CLIENT; |
| 20 | |
| 21 | auto network = std::make_shared<velia::system::IETFInterfaces>(srSess); |
| 22 | |
| 23 | // We didn't came up with some way of mocking netlink. At least check that there is the loopback |
| 24 | // interface with expected values. It is *probably* safe to assume that there is at least the lo device. |
| 25 | REQUIRE(dataFromSysrepo(client, "/ietf-interfaces:interfaces/interface[name='lo']", SR_DS_OPERATIONAL) == std::map<std::string, std::string> { |
| 26 | {"/name", "lo"}, |
| 27 | {"/type", "iana-if-type:softwareLoopback"}, |
| 28 | {"/phys-address", "00:00:00:00:00:00"}, |
| 29 | {"/oper-status", "unknown"}, |
Tomáš Pecka | 0972938 | 2021-03-08 19:36:50 +0100 | [diff] [blame] | 30 | {"/ietf-ip:ipv4", ""}, |
| 31 | {"/ietf-ip:ipv4/address[ip='127.0.0.1']", ""}, |
| 32 | {"/ietf-ip:ipv4/address[ip='127.0.0.1']/ip", "127.0.0.1"}, |
| 33 | {"/ietf-ip:ipv4/address[ip='127.0.0.1']/prefix-length", "8"}, |
| 34 | {"/ietf-ip:ipv6", ""}, |
| 35 | {"/ietf-ip:ipv6/address[ip='::1']", ""}, |
| 36 | {"/ietf-ip:ipv6/address[ip='::1']/ip", "::1"}, |
| 37 | {"/ietf-ip:ipv6/address[ip='::1']/prefix-length", "128"}, |
Tomáš Pecka | 2a4ea7b | 2021-03-30 17:01:37 +0200 | [diff] [blame] | 38 | {"/ietf-ip:ipv6/ietf-ipv6-unicast-routing:ipv6-router-advertisements", ""}, |
| 39 | {"/ietf-ip:ipv6/ietf-ipv6-unicast-routing:ipv6-router-advertisements/prefix-list", ""}, |
Tomáš Pecka | 4413129 | 2021-03-10 12:30:43 +0100 | [diff] [blame] | 40 | {"/statistics", ""}, |
Tomáš Pecka | f10b930 | 2021-02-23 19:02:02 +0100 | [diff] [blame] | 41 | }); |
| 42 | } |