diff --git a/apps/restconf/restconf_api_evhtp.c b/apps/restconf/restconf_api_evhtp.c index c300a991..2673d159 100644 --- a/apps/restconf/restconf_api_evhtp.c +++ b/apps/restconf/restconf_api_evhtp.c @@ -162,17 +162,16 @@ restconf_reply_send(void *req0, #endif /* If body, add a content-length header */ - if (cb != NULL && cbuf_len(cb)) + if (cb != NULL && cbuf_len(cb)){ + cprintf(cb, "\r\n"); if (restconf_reply_header(req, "Content-Length", "%d", cbuf_len(cb)) < 0) goto done; - + } /* create evbuffer* : bufferevent_write_buffer/ drain, ie send everything , except body */ evhtp_send_reply_start(req, req->status); - /* Write a body if cbuf is nonzero */ if (cb != NULL && cbuf_len(cb)){ - /* Suboptimal, copy from cbuf to evbuffer */ if ((eb = evbuffer_new()) == NULL){ clicon_err(OE_CFG, errno, "evbuffer_new"); diff --git a/lib/clixon/clixon_xml.h b/lib/clixon/clixon_xml.h index 5358e842..8a40173c 100644 --- a/lib/clixon/clixon_xml.h +++ b/lib/clixon/clixon_xml.h @@ -146,7 +146,7 @@ typedef struct clixon_xml_vec clixon_xvec; /* struct defined in clicon_xml_vec.c #define XML_FLAG_DEL 0x04 /* Node is deleted (commits) or parent deleted rec */ #define XML_FLAG_CHANGE 0x08 /* Node is changed (commits) or child changed rec */ #define XML_FLAG_NONE 0x10 /* Node is added as NONE */ -#define XML_FLAG_DEFAULT 0x20 /* Added as default value @see xml_default */ +#define XML_FLAG_DEFAULT 0x20 /* Added when a value is set as default @see xml_default */ /* * Prototypes diff --git a/test/test_leaf_default.sh b/test/test_leaf_default.sh index 87ad2f9c..1f816e38 100755 --- a/test/test_leaf_default.sh +++ b/test/test_leaf_default.sh @@ -149,18 +149,35 @@ if [ $BE -ne 0 ]; then fi new "get startup config" +# Should have all defaults, except r1 that is set to 99 expecteof "$clixon_netconf -qf $cfg" 0 ']]>]]>' "^$XML]]>]]>$" # permission kludges sudo chmod 666 $dir/running_db -new "Check running no defaults" -echo "SXML:$SXML" -ret=$(diff $dir/running_db <(echo " +new "Check running no defaults: r1 only" +# Running should have only non-defaults, ie only r1 that is set to 99 + +moreret=$(diff $dir/running_db <(echo " $SXML ")) -#echo "ret:$ret" if [ $? -ne 0 ]; then - err "$SXML" "$ret" + err "$SXML" "$moreret" +fi + +new "Change default value r2" +expecteof "$clixon_netconf -qf $cfg" 0 '88]]>]]>' "^]]>]]>$" + +new "commit" +expecteof "$clixon_netconf -qf $cfg" 0 ']]>]]>' "^]]>]]>$" + +new "Check running no defaults: r1 and r2" +# Again, running should have only non-defaults, ie only r1 and r2 +moreret=$(diff $dir/running_db <(echo " + $SXML + 88 +")) +if [ $? -ne 0 ]; then + err "$SXML88" "$moreret" fi new "Kill backend" diff --git a/test/test_restconf_patch.sh b/test/test_restconf_patch.sh index 0c31fe14..7a69e514 100755 --- a/test/test_restconf_patch.sh +++ b/test/test_restconf_patch.sh @@ -23,16 +23,13 @@ cat < $cfg false /usr/local/lib/$APPNAME/restconf $dir/restconf.pidfile - /usr/local/var/$APPNAME $dir internal true EOF -cat< $startupdb - - +NACM0=" true deny deny @@ -71,6 +68,10 @@ cat< $startupdb +" +cat< $startupdb + + $NACM0 EOF @@ -94,7 +95,6 @@ EOF . ./jukebox.sh new "test params: -s startup -f $cfg" - if [ $BE -ne 0 ]; then new "kill old backend" sudo clixon_backend -zf $cfg @@ -146,11 +146,39 @@ expectpart "$(curl -u wilma:bar $CURLOPTS -X PATCH -H 'Content-Type: application new 'user is authorized' expectpart "$(curl -u andy:bar $CURLOPTS -X PATCH -H 'Content-Type: application/yang-data+json' $RCPROTO://localhost/restconf/data/example-jukebox:jukebox/library/artist=Clash -d '{"example-jukebox:artist":{"name":"Clash","album":{"name":"London Calling"}}}')" 0 "HTTP/1.1 204 No Content" +# Restart +cat< $startupdb + + $NACM0 + +EOF +if [ $BE -ne 0 ]; then + new "kill old backend" + sudo clixon_backend -zf $cfg + if [ $? -ne 0 ]; then + err + fi + sudo pkill -f clixon_backend # to be sure + + new "start backend -s startup -f $cfg" + start_backend -s startup -f $cfg +fi + +new "waiting" +wait_backend + +if [ $RC -ne 0 ]; then + new "kill old restconf daemon" + stop_restconf_pre + + new "start restconf daemon (-a is enable basic authentication)" + start_restconf -f $cfg -- -a + + new "waiting" + wait_restconf +fi + # 4.6.1. Plain Patch - -new "restconf DELETE whole datastore" -expectpart "$(curl -u andy:bar $CURLOPTS -X DELETE $RCPROTO://localhost/restconf/data)" 0 "HTTP/1.1 204 No Content" - new "Create album London Calling with PUT" expectpart "$(curl -u andy:bar $CURLOPTS -X PUT -H 'Content-Type: application/yang-data+json' $RCPROTO://localhost/restconf/data/example-jukebox:jukebox/library/artist=Clash/album=London%20Calling -d '{"example-jukebox:album":{"name":"London Calling"}}')" 0 "HTTP/1.1 201 Created"