From 2ca43e2451c072fc1354360d4cab341184a70c37 Mon Sep 17 00:00:00 2001 From: Razvan Becheriu Date: Fri, 20 Jun 2025 16:44:36 +0300 Subject: [PATCH] [#3907] use strict format for clients in yang --- src/lib/yang/translator_control_socket.cc | 26 +++++++++++++------ .../modules/hashes/kea-types@2025-06-25.hash | 2 +- .../yang/modules/kea-types@2025-06-25.yang | 25 +++++++++++++++--- 3 files changed, 41 insertions(+), 12 deletions(-) diff --git a/src/lib/yang/translator_control_socket.cc b/src/lib/yang/translator_control_socket.cc index e6bc9f7536..b1b9c3b116 100644 --- a/src/lib/yang/translator_control_socket.cc +++ b/src/lib/yang/translator_control_socket.cc @@ -89,12 +89,11 @@ TranslatorControlSocket::getControlSocketKea(DataNode const& data_node) { checkAndGetDivergingLeaf(authentication, node, "type", "auth-type"); checkAndGetLeaf(authentication, node, "realm"); checkAndGetLeaf(authentication, node, "directory"); - checkAndGetAndJsonifyLeaf(authentication, node, "clients"); checkAndGetAndJsonifyLeaf(authentication, node, "user-context"); - // ConstElementPtr clients = getControlSocketAuthenticationClients(node); - // if (clients) { - // authentication->set("clients", clients); - // } + ConstElementPtr clients = getControlSocketAuthenticationClients(node); + if (clients) { + authentication->set("clients", clients); + } return (authentication); }); ConstElementPtr headers = getControlSocketHttpHeaders(data_node); @@ -135,6 +134,18 @@ TranslatorControlSocket::getControlSocketAuthenticationClient(DataNode const& da getMandatoryLeaf(result, data_node, "user-file"); getMandatoryLeaf(result, data_node, "password-file"); checkAndGetAndJsonifyLeaf(result, data_node, "user-context"); + if (result->get("user") && result->get("user")->stringValue().empty()) { + result->remove("user"); + } + if (result->get("password") && result->get("password")->stringValue().empty()) { + result->remove("password"); + } + if (result->get("user-file") && result->get("user-file")->stringValue().empty()) { + result->remove("user-file"); + } + if (result->get("password-file") && result->get("password-file")->stringValue().empty()) { + result->remove("password-file"); + } return (result->empty() ? ElementPtr() : result); } @@ -239,9 +250,8 @@ TranslatorControlSocket::setControlSocketKea(string const& xpath, checkAndSetLeaf(authentication, xpath + "/authentication", "realm", LeafBaseType::String); checkAndSetLeaf(authentication, xpath + "/authentication", "directory", LeafBaseType::String); checkAndSetUserContext(authentication, xpath + "/authentication"); - checkAndStringifyAndSetLeaf(authentication, xpath + "/authentication", "clients"); - // ConstElementPtr clients = authentication->get("clients"); - // setControlSocketAuthenticationClients(xpath + "/authentication/clients", clients); + ConstElementPtr clients = authentication->get("clients"); + setControlSocketAuthenticationClients(xpath + "/authentication/clients", clients); } ConstElementPtr http_headers = elem->get("http-headers"); if (http_headers && !http_headers->empty()) { diff --git a/src/share/yang/modules/hashes/kea-types@2025-06-25.hash b/src/share/yang/modules/hashes/kea-types@2025-06-25.hash index c0feac4534..c708553205 100644 --- a/src/share/yang/modules/hashes/kea-types@2025-06-25.hash +++ b/src/share/yang/modules/hashes/kea-types@2025-06-25.hash @@ -1 +1 @@ -7880835d105232e5575e324ec4db82481e7c07157adfe6028f4ec0949be1718f +b5f9e40815ea19641d64eefaf4acd429526e5f58c7ac8154fa89cd6c0033722e diff --git a/src/share/yang/modules/kea-types@2025-06-25.yang b/src/share/yang/modules/kea-types@2025-06-25.yang index 13a35ca53a..639baef170 100644 --- a/src/share/yang/modules/kea-types@2025-06-25.yang +++ b/src/share/yang/modules/kea-types@2025-06-25.yang @@ -138,9 +138,28 @@ module kea-types { grouping clients { description "HTTP client authentication."; - leaf clients { - type string; - description "Clients (JSON value)."; + list clients { + leaf user { + type string; + description "HTTP user."; + } + leaf password { + type string; + description "HTTP password."; + } + leaf user-file { + type string; + description "HTTP user file."; + } + leaf password-file { + type string; + description "HTTP password file."; + } + leaf user-context { + type user-context; + description "Logger user context."; + } + key "user password user-file password-file"; } } -- 2.47.3