From 9771feebf37ce2b03b3383efa14394abc3ceb2d9 Mon Sep 17 00:00:00 2001 From: Jan-Olof Carlson Date: Wed, 10 Aug 2022 15:27:14 +0000 Subject: [PATCH] RFC6243 with-defaults=trim test cases and implementation added --- lib/src/clixon_netconf_lib.c | 2 +- test/test_yang_with_defaults.sh | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/lib/src/clixon_netconf_lib.c b/lib/src/clixon_netconf_lib.c index 9a7d0194..97d81b1d 100644 --- a/lib/src/clixon_netconf_lib.c +++ b/lib/src/clixon_netconf_lib.c @@ -1725,7 +1725,7 @@ netconf_hello_server(clicon_handle h, cprintf(cb, "urn:ietf:params:netconf:capability:xpath:1.0"); cprintf(cb, "urn:ietf:params:netconf:capability:notification:1.0"); /* rfc6243 with-defaults capability modes */ - cprintf(cb, "urn:ietf:params:netconf:capability:with-defaults:1.0?basic-mode=explicit"); + cprintf(cb, "urn:ietf:params:netconf:capability:with-defaults:1.0?basic-mode=report-all&also-supported=explicit,trim"); cprintf(cb, ""); if (session_id) cprintf(cb, "%lu", (long unsigned int)session_id); diff --git a/test/test_yang_with_defaults.sh b/test/test_yang_with_defaults.sh index c6633ff8..bef0921b 100755 --- a/test/test_yang_with_defaults.sh +++ b/test/test_yang_with_defaults.sh @@ -172,7 +172,7 @@ wait_restconf new "rfc4243 4.3. Capability Identifier" expecteof "$clixon_netconf -ef $cfg" 0 "$DEFAULTHELLO" \ -"urn:ietf:params:netconf:capability:with-defaults:1.0?basic-mode=explicit" +"urn:ietf:params:netconf:capability:with-defaults:1.0?basic-mode=report-all&also-supported=explicit,trim" new "rfc6243 3.1. 'report-all' Retrieval Mode" expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" \ @@ -377,6 +377,20 @@ expectpart "$(curl $CURLOPTS -X GET -H 'Accept: application/yang-data+xml' $RCPR "Cache-Control: no-cache" \ 'eth1ok' +new "rfc8040 B.3.9. RESTONF with-defaults parameter = trim" +expectpart "$(curl $CURLOPTS -X GET -H 'Accept: application/yang-data+json' $RCPROTO://localhost/restconf/data/example:interfaces/interface=eth1?with-defaults=trim)" \ +0 \ +"HTTP/$HVER 200" \ +"Content-Type: application/yang-data+json" \ +"Cache-Control: no-cache" \ +'{"example:interface":\[{"name":"eth1"}\]}' +expectpart "$(curl $CURLOPTS -X GET -H 'Accept: application/yang-data+xml' $RCPROTO://localhost/restconf/data/example:interfaces/interface=eth1?with-defaults=trim)" \ +0 \ +"HTTP/$HVER 200" \ +"Content-Type: application/yang-data+xml" \ +"Cache-Control: no-cache" \ +'eth1' + if [ $RC -ne 0 ]; then new "Kill restconf daemon"