- Added newline after restconf evhtp GET reply
This commit is contained in:
parent
3e054fedc3
commit
1a2e074539
4 changed files with 63 additions and 19 deletions
|
|
@ -162,17 +162,16 @@ restconf_reply_send(void *req0,
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* If body, add a content-length header */
|
/* 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)
|
if (restconf_reply_header(req, "Content-Length", "%d", cbuf_len(cb)) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
|
}
|
||||||
/* create evbuffer* : bufferevent_write_buffer/ drain,
|
/* create evbuffer* : bufferevent_write_buffer/ drain,
|
||||||
ie send everything , except body */
|
ie send everything , except body */
|
||||||
evhtp_send_reply_start(req, req->status);
|
evhtp_send_reply_start(req, req->status);
|
||||||
|
|
||||||
/* Write a body if cbuf is nonzero */
|
/* Write a body if cbuf is nonzero */
|
||||||
if (cb != NULL && cbuf_len(cb)){
|
if (cb != NULL && cbuf_len(cb)){
|
||||||
|
|
||||||
/* Suboptimal, copy from cbuf to evbuffer */
|
/* Suboptimal, copy from cbuf to evbuffer */
|
||||||
if ((eb = evbuffer_new()) == NULL){
|
if ((eb = evbuffer_new()) == NULL){
|
||||||
clicon_err(OE_CFG, errno, "evbuffer_new");
|
clicon_err(OE_CFG, errno, "evbuffer_new");
|
||||||
|
|
|
||||||
|
|
@ -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_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_CHANGE 0x08 /* Node is changed (commits) or child changed rec */
|
||||||
#define XML_FLAG_NONE 0x10 /* Node is added as NONE */
|
#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
|
* Prototypes
|
||||||
|
|
|
||||||
|
|
@ -149,18 +149,35 @@ if [ $BE -ne 0 ]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
new "get startup config"
|
new "get startup config"
|
||||||
|
# Should have all defaults, except r1 that is set to 99
|
||||||
expecteof "$clixon_netconf -qf $cfg" 0 '<rpc><get-config><source><candidate/></source></get-config></rpc>]]>]]>' "^<rpc-reply><data>$XML</data></rpc-reply>]]>]]>$"
|
expecteof "$clixon_netconf -qf $cfg" 0 '<rpc><get-config><source><candidate/></source></get-config></rpc>]]>]]>' "^<rpc-reply><data>$XML</data></rpc-reply>]]>]]>$"
|
||||||
|
|
||||||
# permission kludges
|
# permission kludges
|
||||||
sudo chmod 666 $dir/running_db
|
sudo chmod 666 $dir/running_db
|
||||||
new "Check running no defaults"
|
new "Check running no defaults: r1 only"
|
||||||
echo "SXML:$SXML"
|
# Running should have only non-defaults, ie only r1 that is set to 99
|
||||||
ret=$(diff $dir/running_db <(echo "<config>
|
|
||||||
|
moreret=$(diff $dir/running_db <(echo "<config>
|
||||||
$SXML
|
$SXML
|
||||||
</config>"))
|
</config>"))
|
||||||
#echo "ret:$ret"
|
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
err "<config>$SXML</config>" "$ret"
|
err "<config>$SXML</config>" "$moreret"
|
||||||
|
fi
|
||||||
|
|
||||||
|
new "Change default value r2"
|
||||||
|
expecteof "$clixon_netconf -qf $cfg" 0 '<rpc><edit-config><target><candidate/></target><config><r2 xmlns="urn:example:clixon">88</r2></config></edit-config></rpc>]]>]]>' "^<rpc-reply><ok/></rpc-reply>]]>]]>$"
|
||||||
|
|
||||||
|
new "commit"
|
||||||
|
expecteof "$clixon_netconf -qf $cfg" 0 '<rpc><commit/></rpc>]]>]]>' "^<rpc-reply><ok/></rpc-reply>]]>]]>$"
|
||||||
|
|
||||||
|
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 "<config>
|
||||||
|
$SXML
|
||||||
|
<r2 xmlns=\"urn:example:clixon\">88</r2>
|
||||||
|
</config>"))
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
err "<config>$SXML<r2 xmlns=\"urn:example:clixon\">88</r2></config>" "$moreret"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
new "Kill backend"
|
new "Kill backend"
|
||||||
|
|
|
||||||
|
|
@ -23,16 +23,13 @@ cat <<EOF > $cfg
|
||||||
<CLICON_RESTCONF_PRETTY>false</CLICON_RESTCONF_PRETTY>
|
<CLICON_RESTCONF_PRETTY>false</CLICON_RESTCONF_PRETTY>
|
||||||
<CLICON_RESTCONF_DIR>/usr/local/lib/$APPNAME/restconf</CLICON_RESTCONF_DIR>
|
<CLICON_RESTCONF_DIR>/usr/local/lib/$APPNAME/restconf</CLICON_RESTCONF_DIR>
|
||||||
<CLICON_BACKEND_PIDFILE>$dir/restconf.pidfile</CLICON_BACKEND_PIDFILE>
|
<CLICON_BACKEND_PIDFILE>$dir/restconf.pidfile</CLICON_BACKEND_PIDFILE>
|
||||||
<CLICON_XMLDB_DIR>/usr/local/var/$APPNAME</CLICON_XMLDB_DIR>
|
|
||||||
<CLICON_XMLDB_DIR>$dir</CLICON_XMLDB_DIR>
|
<CLICON_XMLDB_DIR>$dir</CLICON_XMLDB_DIR>
|
||||||
<CLICON_NACM_MODE>internal</CLICON_NACM_MODE>
|
<CLICON_NACM_MODE>internal</CLICON_NACM_MODE>
|
||||||
<CLICON_NACM_DISABLED_ON_EMPTY>true</CLICON_NACM_DISABLED_ON_EMPTY>
|
<CLICON_NACM_DISABLED_ON_EMPTY>true</CLICON_NACM_DISABLED_ON_EMPTY>
|
||||||
</clixon-config>
|
</clixon-config>
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
cat<<EOF > $startupdb
|
NACM0="<nacm xmlns=\"urn:ietf:params:xml:ns:yang:ietf-netconf-acm\">
|
||||||
<config>
|
|
||||||
<nacm xmlns="urn:ietf:params:xml:ns:yang:ietf-netconf-acm">
|
|
||||||
<enable-nacm>true</enable-nacm>
|
<enable-nacm>true</enable-nacm>
|
||||||
<read-default>deny</read-default>
|
<read-default>deny</read-default>
|
||||||
<write-default>deny</write-default>
|
<write-default>deny</write-default>
|
||||||
|
|
@ -71,6 +68,10 @@ cat<<EOF > $startupdb
|
||||||
</rule>
|
</rule>
|
||||||
</rule-list>
|
</rule-list>
|
||||||
</nacm>
|
</nacm>
|
||||||
|
"
|
||||||
|
cat<<EOF > $startupdb
|
||||||
|
<config>
|
||||||
|
$NACM0
|
||||||
</config>
|
</config>
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
|
|
@ -94,7 +95,6 @@ EOF
|
||||||
. ./jukebox.sh
|
. ./jukebox.sh
|
||||||
|
|
||||||
new "test params: -s startup -f $cfg"
|
new "test params: -s startup -f $cfg"
|
||||||
|
|
||||||
if [ $BE -ne 0 ]; then
|
if [ $BE -ne 0 ]; then
|
||||||
new "kill old backend"
|
new "kill old backend"
|
||||||
sudo clixon_backend -zf $cfg
|
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'
|
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"
|
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<<EOF > $startupdb
|
||||||
|
<config>
|
||||||
|
$NACM0
|
||||||
|
</config>
|
||||||
|
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
|
# 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"
|
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"
|
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"
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue