blob: 1497f491fe8cba2d9b1b51b2f0ff712c7a1a23fe [file] [log] [blame]
Tomáš Peckaf10b9302021-02-23 19:02:02 +01001/*
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
15TEST_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áš Pecka09729382021-03-08 19:36:50 +010030 {"/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áš Pecka2a4ea7b2021-03-30 17:01:37 +020038 {"/ietf-ip:ipv6/ietf-ipv6-unicast-routing:ipv6-router-advertisements", ""},
39 {"/ietf-ip:ipv6/ietf-ipv6-unicast-routing:ipv6-router-advertisements/prefix-list", ""},
Tomáš Pecka44131292021-03-10 12:30:43 +010040 {"/statistics", ""},
Tomáš Peckaf10b9302021-02-23 19:02:02 +010041 });
42}