2
0
mirror of https://gitlab.isc.org/isc-projects/kea synced 2025-08-30 13:37:55 +00:00

[#3931] addressed reviw comments

This commit is contained in:
Razvan Becheriu
2025-07-24 13:32:18 +03:00
committed by Andrei Pavel
parent 3797f803d6
commit 7d2198977e
4 changed files with 20 additions and 9 deletions

View File

@@ -0,0 +1,3 @@
[func]* andrei, razvan
Updated kea-netconf to libyang and sysrepo version 3.
(Gitlab #3931)

View File

@@ -35,6 +35,7 @@ private:
void cleanUp() { void cleanUp() {
Session session(sysrepo::Connection{}.sessionStart()); Session session(sysrepo::Connection{}.sessionStart());
session.switchDatastore(sysrepo::Datastore::Candidate); session.switchDatastore(sysrepo::Datastore::Candidate);
// remove the 'if' statement when a fix is provided in sysrepo branch.
if (session.getData("/keatest-module:container/list")) { if (session.getData("/keatest-module:container/list")) {
session.deleteItem("/keatest-module:container/list"); session.deleteItem("/keatest-module:container/list");
} }
@@ -844,7 +845,7 @@ TEST_F(TranslatorTest, container) {
// Container with no data apparently throws. // Container with no data apparently throws.
EXPECT_THROW_MSG(element = translator.getItemFromAbsoluteXpath("/keatest-module:container"), NotImplemented, EXPECT_THROW_MSG(element = translator.getItemFromAbsoluteXpath("/keatest-module:container"), NotImplemented,
"getting node of type 1 not supported, xpath is '/keatest-module:container'"); "getting node of type container not supported, xpath is '/keatest-module:container'");
EXPECT_FALSE(element); EXPECT_FALSE(element);
element.reset(); element.reset();
@@ -860,12 +861,19 @@ TEST_F(TranslatorTest, container) {
element.reset(); element.reset();
EXPECT_THROW_MSG( EXPECT_THROW_MSG(
element = translator.getItemFromAbsoluteXpath("/keatest-module:container"), NotImplemented, element = translator.getItemFromAbsoluteXpath("/keatest-module:container"), NotImplemented,
"getting node of type 1 not supported, xpath is '/keatest-module:container'"); "getting node of type container not supported, xpath is '/keatest-module:container'");
EXPECT_FALSE(element); EXPECT_FALSE(element);
element.reset(); element.reset();
optional<DataNode> const& container(translator.findXPath("/keatest-module:container")); optional<DataNode> const& container(translator.findXPath("/keatest-module:container"));
EXPECT_THROW_MSG(element = translator.getItemFromAbsoluteXpath(
"/keatest-module:container/list[key1='key1'][key2='key2']"),
NotImplemented,
"getting node of type list not supported, xpath is "
"'/keatest-module:container/list[key1='key1'][key2='key2']'");
EXPECT_FALSE(element);
element.reset();
try { try {
libyang::Set<libyang::DataNode> const& nodes((*container).findXPath("/keatest-module:container/list")); libyang::Set<libyang::DataNode> const& nodes(container->findXPath("/keatest-module:container/list"));
element = isc::data::Element::createList(); element = isc::data::Element::createList();
for (libyang::DataNode const& i : nodes) { for (libyang::DataNode const& i : nodes) {
ElementPtr result = Element::createMap(); ElementPtr result = Element::createMap();
@@ -878,7 +886,7 @@ TEST_F(TranslatorTest, container) {
ADD_FAILURE() << "failed to retrieve keatest-module:container/list[key1='key1][key2='key2']. error: " << ex.what(); ADD_FAILURE() << "failed to retrieve keatest-module:container/list[key1='key1][key2='key2']. error: " << ex.what();
} }
ASSERT_TRUE(element); ASSERT_TRUE(element);
ASSERT_EQ("[ { \"key1\": \"key1\", \"key2\": \"key2\", \"leaf\": \"Leaf value\" } ]", element->str()); EXPECT_EQ("[ { \"key1\": \"key1\", \"key2\": \"key2\", \"leaf\": \"Leaf value\" } ]", element->str());
} }
// Test YANG list retrieval. // Test YANG list retrieval.
@@ -902,12 +910,12 @@ TEST_F(TranslatorTest, list) {
element.reset(); element.reset();
EXPECT_THROW_MSG( EXPECT_THROW_MSG(
element = translator.getItemFromAbsoluteXpath("/keatest-module:container/list"), NotImplemented, element = translator.getItemFromAbsoluteXpath("/keatest-module:container/list"), NotImplemented,
"getting node of type 16 not supported, xpath is '/keatest-module:container/list'"); "getting node of type list not supported, xpath is '/keatest-module:container/list'");
EXPECT_FALSE(element); EXPECT_FALSE(element);
element.reset(); element.reset();
EXPECT_THROW_MSG(element = translator.getItemFromAbsoluteXpath( EXPECT_THROW_MSG(element = translator.getItemFromAbsoluteXpath(
"/keatest-module:container/list[key1='key1'][key2='key2']"), NotImplemented, "/keatest-module:container/list[key1='key1'][key2='key2']"), NotImplemented,
"getting node of type 16 not supported, xpath is " "getting node of type list not supported, xpath is "
"'/keatest-module:container/list[key1='key1'][key2='key2']'"); "'/keatest-module:container/list[key1='key1'][key2='key2']'");
EXPECT_FALSE(element); EXPECT_FALSE(element);
} }

View File

@@ -252,7 +252,7 @@ operator<<(ostream& os, LeafBaseType type) {
os << "unknown"; os << "unknown";
break; break;
default: default:
isc_throw(BadValue, "unsupported type " << int(type)); isc_throw(BadValue, "unsupported type " << type);
} }
return (os); return (os);
} }

View File

@@ -1,4 +1,4 @@
// Copyright (C) 2018-2024 Internet Systems Consortium, Inc. ("ISC") // Copyright (C) 2018-2025 Internet Systems Consortium, Inc. ("ISC")
// //
// This Source Code Form is subject to the terms of the Mozilla Public // This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this // License, v. 2.0. If a copy of the MPL was not distributed with this
@@ -175,7 +175,7 @@ Translator::getItem(DataNode const& data_node,
return result; return result;
} else { } else {
isc_throw(NotImplemented, "getting node of type " isc_throw(NotImplemented, "getting node of type "
<< int(node_type) << " not supported, xpath is '" << xpath << node_type << " not supported, xpath is '" << xpath
<< "'"); << "'");
} }