\r\n in restconf code and tests
This commit is contained in:
parent
ba3ca7e07f
commit
835674bbe0
7 changed files with 66 additions and 42 deletions
|
|
@ -212,7 +212,7 @@ api_well_known(clicon_handle h,
|
||||||
FCGX_SetExitStatus(200, r->out); /* OK */
|
FCGX_SetExitStatus(200, r->out); /* OK */
|
||||||
FCGX_FPrintF(r->out, "<XRD xmlns='http://docs.oasis-open.org/ns/xri/xrd-1.0'>\n");
|
FCGX_FPrintF(r->out, "<XRD xmlns='http://docs.oasis-open.org/ns/xri/xrd-1.0'>\n");
|
||||||
FCGX_FPrintF(r->out, " <Link rel='restconf' href='/restconf'/>\n");
|
FCGX_FPrintF(r->out, " <Link rel='restconf' href='/restconf'/>\n");
|
||||||
FCGX_FPrintF(r->out, "</XRD>\n");
|
FCGX_FPrintF(r->out, "</XRD>\r\n");
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -260,7 +260,7 @@ api_root(clicon_handle h,
|
||||||
if (xml2json_cbuf(cb, xt, pretty) < 0)
|
if (xml2json_cbuf(cb, xt, pretty) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
FCGX_FPrintF(r->out, "%s", cb?cbuf_get(cb):"");
|
FCGX_FPrintF(r->out, "%s", cb?cbuf_get(cb):"");
|
||||||
FCGX_FPrintF(r->out, "\n\n");
|
FCGX_FPrintF(r->out, "\r\n\r\n");
|
||||||
retval = 0;
|
retval = 0;
|
||||||
done:
|
done:
|
||||||
if (cb)
|
if (cb)
|
||||||
|
|
|
||||||
|
|
@ -189,12 +189,12 @@ api_return_err(clicon_handle h,
|
||||||
if (pretty){
|
if (pretty){
|
||||||
FCGX_FPrintF(r->out, " <errors xmlns=\"urn:ietf:params:xml:ns:yang:ietf-restconf\">\n", cbuf_get(cb));
|
FCGX_FPrintF(r->out, " <errors xmlns=\"urn:ietf:params:xml:ns:yang:ietf-restconf\">\n", cbuf_get(cb));
|
||||||
FCGX_FPrintF(r->out, "%s", cbuf_get(cb));
|
FCGX_FPrintF(r->out, "%s", cbuf_get(cb));
|
||||||
FCGX_FPrintF(r->out, " </errors>\n");
|
FCGX_FPrintF(r->out, " </errors>\r\n");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
FCGX_FPrintF(r->out, "<errors xmlns=\"urn:ietf:params:xml:ns:yang:ietf-restconf\">", cbuf_get(cb));
|
FCGX_FPrintF(r->out, "<errors xmlns=\"urn:ietf:params:xml:ns:yang:ietf-restconf\">", cbuf_get(cb));
|
||||||
FCGX_FPrintF(r->out, "%s", cbuf_get(cb));
|
FCGX_FPrintF(r->out, "%s", cbuf_get(cb));
|
||||||
FCGX_FPrintF(r->out, "</errors>\n");
|
FCGX_FPrintF(r->out, "</errors>\r\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
|
|
@ -202,13 +202,13 @@ api_return_err(clicon_handle h,
|
||||||
FCGX_FPrintF(r->out, "{\n");
|
FCGX_FPrintF(r->out, "{\n");
|
||||||
FCGX_FPrintF(r->out, " \"ietf-restconf:errors\" : %s\n",
|
FCGX_FPrintF(r->out, " \"ietf-restconf:errors\" : %s\n",
|
||||||
cbuf_get(cb));
|
cbuf_get(cb));
|
||||||
FCGX_FPrintF(r->out, "}\n");
|
FCGX_FPrintF(r->out, "}\r\n");
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
FCGX_FPrintF(r->out, "{");
|
FCGX_FPrintF(r->out, "{");
|
||||||
FCGX_FPrintF(r->out, "\"ietf-restconf:errors\" : ");
|
FCGX_FPrintF(r->out, "\"ietf-restconf:errors\" : ");
|
||||||
FCGX_FPrintF(r->out, "%s", cbuf_get(cb));
|
FCGX_FPrintF(r->out, "%s", cbuf_get(cb));
|
||||||
FCGX_FPrintF(r->out, "}\n");
|
FCGX_FPrintF(r->out, "}\r\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ok:
|
ok:
|
||||||
|
|
@ -234,6 +234,7 @@ api_return_err(clicon_handle h,
|
||||||
* @code
|
* @code
|
||||||
* curl -G http://localhost/restconf/data/interfaces/interface=eth0
|
* curl -G http://localhost/restconf/data/interfaces/interface=eth0
|
||||||
* @endcode
|
* @endcode
|
||||||
|
* See RFC8040 Sec 4.2 and 4.3
|
||||||
* XXX: cant find a way to use Accept request field to choose Content-Type
|
* XXX: cant find a way to use Accept request field to choose Content-Type
|
||||||
* I would like to support both xml and json.
|
* I would like to support both xml and json.
|
||||||
* Request may contain
|
* Request may contain
|
||||||
|
|
@ -337,10 +338,9 @@ api_data_get2(clicon_handle h,
|
||||||
if (xml2json_cbuf_vec(cbx, xvec, xlen, pretty) < 0)
|
if (xml2json_cbuf_vec(cbx, xvec, xlen, pretty) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
clicon_debug(1, "%s cbuf:%s", __FUNCTION__, cbuf_get(cbx));
|
clicon_debug(1, "%s cbuf:%s", __FUNCTION__, cbuf_get(cbx));
|
||||||
FCGX_FPrintF(r->out, "%s", cbx?cbuf_get(cbx):"");
|
FCGX_FPrintF(r->out, "%s", cbx?cbuf_get(cbx):"");
|
||||||
FCGX_FPrintF(r->out, "\n\n");
|
FCGX_FPrintF(r->out, "\r\n\r\n");
|
||||||
ok:
|
ok:
|
||||||
retval = 0;
|
retval = 0;
|
||||||
done:
|
done:
|
||||||
|
|
@ -437,6 +437,8 @@ api_data_get(clicon_handle h,
|
||||||
* @param[in] parse_xml Set to 0 for JSON and 1 for XML for input data
|
* @param[in] parse_xml Set to 0 for JSON and 1 for XML for input data
|
||||||
|
|
||||||
* @note restconf POST is mapped to edit-config create.
|
* @note restconf POST is mapped to edit-config create.
|
||||||
|
* See RFC8040 Sec 4.4.1
|
||||||
|
|
||||||
POST:
|
POST:
|
||||||
target resource type is datastore --> create a top-level resource
|
target resource type is datastore --> create a top-level resource
|
||||||
target resource type is data resource --> create child resource
|
target resource type is data resource --> create child resource
|
||||||
|
|
@ -520,7 +522,7 @@ api_data_post(clicon_handle h,
|
||||||
badrequest(r);
|
badrequest(r);
|
||||||
goto ok;
|
goto ok;
|
||||||
}
|
}
|
||||||
/* The message-body MUST contain exactly one instance of the
|
/* 4.4.1: The message-body MUST contain exactly one instance of the
|
||||||
* expected data resource.
|
* expected data resource.
|
||||||
*/
|
*/
|
||||||
if (xml_child_nr(xdata) != 1){
|
if (xml_child_nr(xdata) != 1){
|
||||||
|
|
@ -649,6 +651,7 @@ match_list_keys(yang_stmt *y,
|
||||||
* @param[in] parse_xml Set to 0 for JSON and 1 for XML for input data
|
* @param[in] parse_xml Set to 0 for JSON and 1 for XML for input data
|
||||||
|
|
||||||
* @note restconf PUT is mapped to edit-config replace.
|
* @note restconf PUT is mapped to edit-config replace.
|
||||||
|
* See RFC8040 Sec 4.5
|
||||||
* @example
|
* @example
|
||||||
curl -X PUT -d '{"enabled":"false"}' http://127.0.0.1/restconf/data/interfaces/interface=eth1
|
curl -X PUT -d '{"enabled":"false"}' http://127.0.0.1/restconf/data/interfaces/interface=eth1
|
||||||
*
|
*
|
||||||
|
|
@ -823,6 +826,7 @@ api_data_put(clicon_handle h,
|
||||||
* @param[in] data Stream input data
|
* @param[in] data Stream input data
|
||||||
* @param[in] username Authenticated user
|
* @param[in] username Authenticated user
|
||||||
* Netconf: <edit-config> (nc:operation="merge")
|
* Netconf: <edit-config> (nc:operation="merge")
|
||||||
|
* See RFC8040 Sec 4.6
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
api_data_patch(clicon_handle h,
|
api_data_patch(clicon_handle h,
|
||||||
|
|
@ -846,6 +850,7 @@ api_data_patch(clicon_handle h,
|
||||||
* @param[in] username Authenticated user
|
* @param[in] username Authenticated user
|
||||||
* @param[in] pretty Set to 1 for pretty-printed xml/json output
|
* @param[in] pretty Set to 1 for pretty-printed xml/json output
|
||||||
* @param[in] use_xml Set to 0 for JSON and 1 for XML
|
* @param[in] use_xml Set to 0 for JSON and 1 for XML
|
||||||
|
* See RFC 8040 Sec 4.7
|
||||||
* Example:
|
* Example:
|
||||||
* curl -X DELETE http://127.0.0.1/restconf/data/interfaces/interface=eth0
|
* curl -X DELETE http://127.0.0.1/restconf/data/interfaces/interface=eth0
|
||||||
* Netconf: <edit-config> (nc:operation="delete")
|
* Netconf: <edit-config> (nc:operation="delete")
|
||||||
|
|
@ -1020,9 +1025,9 @@ api_operations_get(clicon_handle h,
|
||||||
clicon_debug(1, "%s ret:%s", __FUNCTION__, cbuf_get(cbx));
|
clicon_debug(1, "%s ret:%s", __FUNCTION__, cbuf_get(cbx));
|
||||||
FCGX_SetExitStatus(200, r->out); /* OK */
|
FCGX_SetExitStatus(200, r->out); /* OK */
|
||||||
FCGX_FPrintF(r->out, "Content-Type: application/yang-data+%s\r\n", use_xml?"xml":"json");
|
FCGX_FPrintF(r->out, "Content-Type: application/yang-data+%s\r\n", use_xml?"xml":"json");
|
||||||
FCGX_FPrintF(r->out, "\n");
|
FCGX_FPrintF(r->out, "\r\n");
|
||||||
FCGX_FPrintF(r->out, "%s", cbx?cbuf_get(cbx):"");
|
FCGX_FPrintF(r->out, "%s", cbx?cbuf_get(cbx):"");
|
||||||
FCGX_FPrintF(r->out, "\n\n");
|
FCGX_FPrintF(r->out, "\r\n\r\n");
|
||||||
// ok:
|
// ok:
|
||||||
retval = 0;
|
retval = 0;
|
||||||
done:
|
done:
|
||||||
|
|
@ -1046,7 +1051,7 @@ api_operations_get(clicon_handle h,
|
||||||
* @param[in] pretty Set to 1 for pretty-printed xml/json output
|
* @param[in] pretty Set to 1 for pretty-printed xml/json output
|
||||||
* @param[in] use_xml Set to 0 for JSON and 1 for XML for output data
|
* @param[in] use_xml Set to 0 for JSON and 1 for XML for output data
|
||||||
* @param[in] parse_xml Set to 0 for JSON and 1 for XML for input data
|
* @param[in] parse_xml Set to 0 for JSON and 1 for XML for input data
|
||||||
|
* See RFC 8040 Sec 3.6 / 4.4.2
|
||||||
* @note We map post to edit-config create.
|
* @note We map post to edit-config create.
|
||||||
POST {+restconf}/operations/<operation>
|
POST {+restconf}/operations/<operation>
|
||||||
*/
|
*/
|
||||||
|
|
@ -1193,7 +1198,7 @@ api_operations_post(clicon_handle h,
|
||||||
goto done;
|
goto done;
|
||||||
clicon_debug(1, "%s xoutput:%s", __FUNCTION__, cbuf_get(cbx));
|
clicon_debug(1, "%s xoutput:%s", __FUNCTION__, cbuf_get(cbx));
|
||||||
FCGX_FPrintF(r->out, "%s", cbx?cbuf_get(cbx):"");
|
FCGX_FPrintF(r->out, "%s", cbx?cbuf_get(cbx):"");
|
||||||
FCGX_FPrintF(r->out, "\n\n");
|
FCGX_FPrintF(r->out, "\r\n\r\n");
|
||||||
}
|
}
|
||||||
ok:
|
ok:
|
||||||
retval = 0;
|
retval = 0;
|
||||||
|
|
|
||||||
10
doc/FAQ.md
10
doc/FAQ.md
|
|
@ -83,11 +83,11 @@ configuration file is installed at /usr/local/etc/routing.xml. The
|
||||||
YANG specification for the configuration file is clixon-config.yang.
|
YANG specification for the configuration file is clixon-config.yang.
|
||||||
|
|
||||||
You can change where CLixon looks for the configuration FILE as follows:
|
You can change where CLixon looks for the configuration FILE as follows:
|
||||||
# Provide -f FILE option when starting a program (eg clixon_backend -f FILE)
|
- Provide -f FILE option when starting a program (eg clixon_backend -f FILE)
|
||||||
# Provide --with-configfile=FILE when configuring
|
- Provide --with-configfile=FILE when configuring
|
||||||
# Provide --with-sysconfig=<dir> when configuring, then FILE is <dir>/clixon.xml
|
- Provide --with-sysconfig=<dir> when configuring, then FILE is <dir>/clixon.xml
|
||||||
# Provide --sysconfig=<dir> when configuring then FILE is <dir>/etc/clixon.xml
|
- Provide --sysconfig=<dir> when configuring then FILE is <dir>/etc/clixon.xml
|
||||||
# FILE is /usr/local/etc/clixon.xml
|
- FILE is /usr/local/etc/clixon.xml
|
||||||
|
|
||||||
## Can I run Clixon as docker containers?
|
## Can I run Clixon as docker containers?
|
||||||
Yes, the example works as docker containers as well. backend and cli needs a
|
Yes, the example works as docker containers as well. backend and cli needs a
|
||||||
|
|
|
||||||
|
|
@ -73,12 +73,16 @@ typedef int (plgstart_t)(clicon_handle, int, char **); /* Plugin start */
|
||||||
#define PLUGIN_EXIT "plugin_exit"
|
#define PLUGIN_EXIT "plugin_exit"
|
||||||
typedef int (plgexit_t)(clicon_handle); /* Plugin exit */
|
typedef int (plgexit_t)(clicon_handle); /* Plugin exit */
|
||||||
|
|
||||||
/*! Called by restconf
|
/*! Called by restconf to ceck credentials and return username
|
||||||
* Returns 0 if credentials OK, -1 if failed
|
|
||||||
*/
|
*/
|
||||||
#define PLUGIN_CREDENTIALS "plugin_credentials"
|
#define PLUGIN_CREDENTIALS "plugin_credentials"
|
||||||
|
|
||||||
/* Plugin credentials
|
/* Plugin credentials
|
||||||
* username should be freed after use
|
* @param[in] Clicon handle
|
||||||
|
* @param[in] void*, eg Fastcgihandle request restconf
|
||||||
|
* @param[out] username should be freed after use
|
||||||
|
* @retval 0 if credentials OK
|
||||||
|
* @retval -1 credentials not OK
|
||||||
*/
|
*/
|
||||||
typedef int (plgcredentials_t)(clicon_handle, void *, char **username);
|
typedef int (plgcredentials_t)(clicon_handle, void *, char **username);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -50,12 +50,14 @@ new(){
|
||||||
expectfn(){
|
expectfn(){
|
||||||
cmd=$1
|
cmd=$1
|
||||||
expect=$2
|
expect=$2
|
||||||
|
|
||||||
if [ $# = 3 ]; then
|
if [ $# = 3 ]; then
|
||||||
expect2=$3
|
expect2=$3
|
||||||
else
|
else
|
||||||
expect2=
|
expect2=
|
||||||
fi
|
fi
|
||||||
ret=`$cmd`
|
ret=$($cmd)
|
||||||
|
|
||||||
# if [ $? -ne 0 ]; then
|
# if [ $? -ne 0 ]; then
|
||||||
# err "wrong args"
|
# err "wrong args"
|
||||||
# fi
|
# fi
|
||||||
|
|
@ -84,6 +86,7 @@ expectfn(){
|
||||||
expecteq2(){
|
expecteq2(){
|
||||||
ret=$1
|
ret=$1
|
||||||
expect=$2
|
expect=$2
|
||||||
|
|
||||||
# Match if both are empty string
|
# Match if both are empty string
|
||||||
if [ -z "$ret" -a -z "$expect" ]; then
|
if [ -z "$ret" -a -z "$expect" ]; then
|
||||||
return
|
return
|
||||||
|
|
|
||||||
|
|
@ -81,17 +81,20 @@ new "restconf tests"
|
||||||
new "restconf root discovery. RFC 8040 3.1 (xml+xrd)"
|
new "restconf root discovery. RFC 8040 3.1 (xml+xrd)"
|
||||||
expecteq2 "$(curl -s -X GET http://localhost/.well-known/host-meta)" "<XRD xmlns='http://docs.oasis-open.org/ns/xri/xrd-1.0'>
|
expecteq2 "$(curl -s -X GET http://localhost/.well-known/host-meta)" "<XRD xmlns='http://docs.oasis-open.org/ns/xri/xrd-1.0'>
|
||||||
<Link rel='restconf' href='/restconf'/>
|
<Link rel='restconf' href='/restconf'/>
|
||||||
</XRD>"
|
</XRD>
"
|
||||||
|
|
||||||
new "restconf get restconf resource. RFC 8040 3.3 (json)"
|
new "restconf get restconf resource. RFC 8040 3.3 (json)"
|
||||||
expecteq2 "$(curl -sG http://localhost/restconf)" '{"restconf": {"data": null,"operations": null,"yang-library-version": "2016-06-21"}}'
|
expecteq2 "$(curl -sG http://localhost/restconf)" '{"restconf": {"data": null,"operations": null,"yang-library-version": "2016-06-21"}}
|
||||||
|
'
|
||||||
|
|
||||||
new "restconf get restconf resource. RFC 8040 3.3 (xml)"
|
new "restconf get restconf resource. RFC 8040 3.3 (xml)"
|
||||||
# Get XML instead of JSON?
|
# Get XML instead of JSON?
|
||||||
expecteq2 $(curl -s -H "Accept: application/yang-data+xml" -G http://localhost/restconf) '<restconf><data/><operations/><yang-library-version>2016-06-21</yang-library-version></restconf>'
|
expecteq2 "$(curl -s -H 'Accept: application/yang-data+xml' -G http://localhost/restconf)" '<restconf><data/><operations/><yang-library-version>2016-06-21</yang-library-version></restconf>
|
||||||
|
'
|
||||||
|
|
||||||
new "restconf get restconf/operations. RFC8040 3.3.2"
|
new "restconf get restconf/operations. RFC8040 3.3.2 (json)"
|
||||||
expecteq2 "$(curl -sG http://localhost/restconf/operations)" '{"operations": {"ex:empty": null,"ex:input": null,"ex:output": null,"rt:fib-route": null,"rt:route-count": null}}'
|
expecteq2 "$(curl -sG http://localhost/restconf/operations)" '{"operations": {"ex:empty": null,"ex:input": null,"ex:output": null,"rt:fib-route": null,"rt:route-count": null}}
|
||||||
|
'
|
||||||
|
|
||||||
new "restconf get restconf/operations. RFC8040 3.3.2 (xml)"
|
new "restconf get restconf/operations. RFC8040 3.3.2 (xml)"
|
||||||
ret=$(curl -s -H "Accept: application/yang-data+xml" -G http://localhost/restconf/operations)
|
ret=$(curl -s -H "Accept: application/yang-data+xml" -G http://localhost/restconf/operations)
|
||||||
|
|
@ -120,10 +123,12 @@ expectfn "curl -s -I http://localhost/restconf/data" "HTTP/1.1 200 OK"
|
||||||
#Content-Type: application/yang-data+json"
|
#Content-Type: application/yang-data+json"
|
||||||
|
|
||||||
new "restconf empty rpc"
|
new "restconf empty rpc"
|
||||||
expecteq2 "$(curl -s -X POST -d {\"input\":{\"name\":\"\"}} http://localhost/restconf/operations/ex:empty)" '{"output": null}'
|
expecteq2 "$(curl -s -X POST -d {\"input\":{\"name\":\"\"}} http://localhost/restconf/operations/ex:empty)" '{"output": null}
|
||||||
|
'
|
||||||
|
|
||||||
new "restconf get empty config + state json"
|
new "restconf get empty config + state json"
|
||||||
expecteq2 "$(curl -sSG http://localhost/restconf/data)" '{"data": {"interfaces-state": {"interface": [{"name": "eth0","type": "eth","if-index": 42}]}}}'
|
expecteq2 "$(curl -sSG http://localhost/restconf/data)" '{"data": {"interfaces-state": {"interface": [{"name": "eth0","type": "eth","if-index": 42}]}}}
|
||||||
|
'
|
||||||
|
|
||||||
new "restconf get empty config + state xml"
|
new "restconf get empty config + state xml"
|
||||||
ret=$(curl -s -H "Accept: application/yang-data+xml" -G http://localhost/restconf/data)
|
ret=$(curl -s -H "Accept: application/yang-data+xml" -G http://localhost/restconf/data)
|
||||||
|
|
@ -134,7 +139,8 @@ if [ -z "$match" ]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
new "restconf get data/interfaces-state/interface=eth0 json"
|
new "restconf get data/interfaces-state/interface=eth0 json"
|
||||||
expecteq2 "$(curl -s -G http://localhost/restconf/data/interfaces-state/interface=eth0)" '{"interface": [{"name": "eth0","type": "eth","if-index": 42}]}'
|
expecteq2 "$(curl -s -G http://localhost/restconf/data/interfaces-state/interface=eth0)" '{"interface": [{"name": "eth0","type": "eth","if-index": 42}]}
|
||||||
|
'
|
||||||
|
|
||||||
new "restconf get state operation eth0 xml"
|
new "restconf get state operation eth0 xml"
|
||||||
# Cant get shell macros to work, inline matching from lib.sh
|
# Cant get shell macros to work, inline matching from lib.sh
|
||||||
|
|
@ -146,7 +152,8 @@ if [ -z "$match" ]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
new "restconf get state operation eth0 type json"
|
new "restconf get state operation eth0 type json"
|
||||||
expecteq2 "$(curl -s -G http://localhost/restconf/data/interfaces-state/interface=eth0/type)" '{"type": "eth"}'
|
expecteq2 "$(curl -s -G http://localhost/restconf/data/interfaces-state/interface=eth0/type)" '{"type": "eth"}
|
||||||
|
'
|
||||||
|
|
||||||
new "restconf get state operation eth0 type xml"
|
new "restconf get state operation eth0 type xml"
|
||||||
# Cant get shell macros to work, inline matching from lib.sh
|
# Cant get shell macros to work, inline matching from lib.sh
|
||||||
|
|
@ -158,7 +165,8 @@ if [ -z "$match" ]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
new "restconf GET datastore"
|
new "restconf GET datastore"
|
||||||
expecteq2 "$(curl -s -X GET http://localhost/restconf/data)" '{"data": {"interfaces-state": {"interface": [{"name": "eth0","type": "eth","if-index": 42}]}}}'
|
expecteq2 "$(curl -s -X GET http://localhost/restconf/data)" '{"data": {"interfaces-state": {"interface": [{"name": "eth0","type": "eth","if-index": 42}]}}}
|
||||||
|
'
|
||||||
|
|
||||||
# Exact match
|
# Exact match
|
||||||
new "restconf Add subtree to datastore using POST"
|
new "restconf Add subtree to datastore using POST"
|
||||||
|
|
@ -171,8 +179,8 @@ expectfn 'curl -s -X POST -d {"interfaces":{"interface":{"name":"eth/0/0","type"
|
||||||
#expecteq2 "$(curl -s -X POST -d {\"interfaces\":{\"interface\":{\"name\":\"eth/0/0\",\"type\":\"eth\",\"enabled\":true}}} http://localhost/restconf/data)" '{"ietf-restconf:errors" : {"error": {"error-tag": "data-exists","error-type": "application","error-severity": "error","error-message": "Data already exists; cannot create new resource"}}}'
|
#expecteq2 "$(curl -s -X POST -d {\"interfaces\":{\"interface\":{\"name\":\"eth/0/0\",\"type\":\"eth\",\"enabled\":true}}} http://localhost/restconf/data)" '{"ietf-restconf:errors" : {"error": {"error-tag": "data-exists","error-type": "application","error-severity": "error","error-message": "Data already exists; cannot create new resource"}}}'
|
||||||
|
|
||||||
new "restconf Check interfaces eth/0/0 added"
|
new "restconf Check interfaces eth/0/0 added"
|
||||||
expectfn "curl -s -G http://localhost/restconf/data" '{"interfaces": {"interface": \[{"name": "eth/0/0","type": "eth","enabled": true}\]},"interfaces-state": {"interface": \[{"name": "eth0","type": "eth","if-index": 42}\]}}
|
expectfn "curl -s -G http://localhost/restconf/data" '{"interfaces": {"interface": \[{"name": "eth/0/0","type": "eth","enabled": true}\]},"interfaces-state": {"interface": \[{"name": "eth0","type": "eth","if-index": 42}\]}}
|
||||||
$'
|
'
|
||||||
|
|
||||||
new "restconf delete interfaces"
|
new "restconf delete interfaces"
|
||||||
expecteq2 $(curl -s -X DELETE http://localhost/restconf/data/interfaces) ""
|
expecteq2 $(curl -s -X DELETE http://localhost/restconf/data/interfaces) ""
|
||||||
|
|
@ -186,10 +194,11 @@ expectfn 'curl -s -X POST -d {"interface":{"name":"eth/0/0","type":"eth","enable
|
||||||
#expecteq2 "$(curl -s -X POST -d '{"interface":{"name":"eth/0/0","type\":"eth","enabled":true}}' http://localhost/restconf/data/interfaces)" ""
|
#expecteq2 "$(curl -s -X POST -d '{"interface":{"name":"eth/0/0","type\":"eth","enabled":true}}' http://localhost/restconf/data/interfaces)" ""
|
||||||
|
|
||||||
new "restconf Check eth/0/0 added"
|
new "restconf Check eth/0/0 added"
|
||||||
expecteq 'curl -s -G http://localhost/restconf/data' '{"data": {"interfaces": {"interface": [{"name": "eth/0/0","type": "eth","enabled": true}]},"interfaces-state": {"interface": [{"name": "eth0","type": "eth","if-index": 42}]}}}'
|
expecteq 'curl -s -G http://localhost/restconf/data' '{"data": {"interfaces": {"interface": [{"name": "eth/0/0","type": "eth","enabled": true}]},"interfaces-state": {"interface": [{"name": "eth0","type": "eth","if-index": 42}]}}}
|
||||||
|
'
|
||||||
|
|
||||||
new "restconf Re-post eth/0/0 which should generate error"
|
new "restconf Re-post eth/0/0 which should generate error"
|
||||||
expecteq 'curl -s -X POST -d {"interface":{"name":"eth/0/0","type":"eth","enabled":true}} http://localhost/restconf/data/interfaces' '{"ietf-restconf:errors" : {"error": {"error-tag": "data-exists","error-type": "application","error-severity": "error","error-message": "Data already exists; cannot create new resource"}}}'
|
expecteq 'curl -s -X POST -d {"interface":{"name":"eth/0/0","type":"eth","enabled":true}} http://localhost/restconf/data/interfaces' '{"ietf-restconf:errors" : {"error": {"error-tag": "data-exists","error-type": "application","error-severity": "error","error-message": "Data already exists; cannot create new resource"}}}
'
|
||||||
|
|
||||||
new "Add leaf description using POST"
|
new "Add leaf description using POST"
|
||||||
expecteq 'curl -s -X POST -d {"description":"The-first-interface"} http://localhost/restconf/data/interfaces/interface=eth%2f0%2f0' ""
|
expecteq 'curl -s -X POST -d {"description":"The-first-interface"} http://localhost/restconf/data/interfaces/interface=eth%2f0%2f0' ""
|
||||||
|
|
@ -198,7 +207,8 @@ new "Add nothing using POST"
|
||||||
expectfn 'curl -s -X POST http://localhost/restconf/data/interfaces/interface=eth%2f0%2f0' "data is in some way badly formed"
|
expectfn 'curl -s -X POST http://localhost/restconf/data/interfaces/interface=eth%2f0%2f0' "data is in some way badly formed"
|
||||||
|
|
||||||
new "restconf Check description added"
|
new "restconf Check description added"
|
||||||
expecteq "curl -s -G http://localhost/restconf/data" '{"data": {"interfaces": {"interface": [{"name": "eth/0/0","description": "The-first-interface","type": "eth","enabled": true}]},"interfaces-state": {"interface": [{"name": "eth0","type": "eth","if-index": 42}]}}}'
|
expecteq "curl -s -G http://localhost/restconf/data" '{"data": {"interfaces": {"interface": [{"name": "eth/0/0","description": "The-first-interface","type": "eth","enabled": true}]},"interfaces-state": {"interface": [{"name": "eth0","type": "eth","if-index": 42}]}}}
|
||||||
|
'
|
||||||
|
|
||||||
new "restconf delete eth/0/0"
|
new "restconf delete eth/0/0"
|
||||||
expecteq 'curl -s -X DELETE http://localhost/restconf/data/interfaces/interface=eth%2f0%2f0' ""
|
expecteq 'curl -s -X DELETE http://localhost/restconf/data/interfaces/interface=eth%2f0%2f0' ""
|
||||||
|
|
@ -207,16 +217,18 @@ new "Check deleted eth/0/0"
|
||||||
expectfn 'curl -s -G http://localhost/restconf/data' $state
|
expectfn 'curl -s -G http://localhost/restconf/data' $state
|
||||||
|
|
||||||
new "restconf Re-Delete eth/0/0 using none should generate error"
|
new "restconf Re-Delete eth/0/0 using none should generate error"
|
||||||
expecteq 'curl -s -X DELETE http://localhost/restconf/data/interfaces/interface=eth%2f0%2f0' '{"ietf-restconf:errors" : {"error": {"error-tag": "data-missing","error-type": "application","error-severity": "error","error-message": "Data does not exist; cannot delete resource"}}}'
|
expecteq 'curl -s -X DELETE http://localhost/restconf/data/interfaces/interface=eth%2f0%2f0' '{"ietf-restconf:errors" : {"error": {"error-tag": "data-missing","error-type": "application","error-severity": "error","error-message": "Data does not exist; cannot delete resource"}}}
'
|
||||||
|
|
||||||
new "restconf Add subtree eth/0/0 using PUT"
|
new "restconf Add subtree eth/0/0 using PUT"
|
||||||
expecteq 'curl -s -X PUT -d {"interface":{"name":"eth/0/0","type":"eth","enabled":true}} http://localhost/restconf/data/interfaces/interface=eth%2f0%2f0' ""
|
expecteq 'curl -s -X PUT -d {"interface":{"name":"eth/0/0","type":"eth","enabled":true}} http://localhost/restconf/data/interfaces/interface=eth%2f0%2f0' ""
|
||||||
|
|
||||||
new "restconf get subtree"
|
new "restconf get subtree"
|
||||||
expecteq 'curl -s -G http://localhost/restconf/data' '{"data": {"interfaces": {"interface": [{"name": "eth/0/0","type": "eth","enabled": true}]},"interfaces-state": {"interface": [{"name": "eth0","type": "eth","if-index": 42}]}}}'
|
expecteq 'curl -s -G http://localhost/restconf/data' '{"data": {"interfaces": {"interface": [{"name": "eth/0/0","type": "eth","enabled": true}]},"interfaces-state": {"interface": [{"name": "eth0","type": "eth","if-index": 42}]}}}
|
||||||
|
'
|
||||||
|
|
||||||
new "restconf rpc using POST json"
|
new "restconf rpc using POST json"
|
||||||
expecteq 'curl -s -X POST -d {"input":{"routing-instance-name":"ipv4"}} http://localhost/restconf/operations/rt:fib-route' '{"output": {"route": {"address-family": "ipv4","next-hop": {"next-hop-list": "2.3.4.5"}}}}'
|
expecteq 'curl -s -X POST -d {"input":{"routing-instance-name":"ipv4"}} http://localhost/restconf/operations/rt:fib-route' '{"output": {"route": {"address-family": "ipv4","next-hop": {"next-hop-list": "2.3.4.5"}}}}
|
||||||
|
'
|
||||||
|
|
||||||
new "restconf rpc using POST xml"
|
new "restconf rpc using POST xml"
|
||||||
ret=$(curl -s -X POST -H "Accept: application/yang-data+xml" -d '{"input":{"routing-instance-name":"ipv4"}}' http://localhost/restconf/operations/rt:fib-route)
|
ret=$(curl -s -X POST -H "Accept: application/yang-data+xml" -d '{"input":{"routing-instance-name":"ipv4"}}' http://localhost/restconf/operations/rt:fib-route)
|
||||||
|
|
|
||||||
|
|
@ -84,10 +84,10 @@ new "restconf POST interface"
|
||||||
expectfn 'curl -s -X POST -d {"interface":{"name":"TEST","type":"eth0"}} http://localhost/restconf/data/cont1' ""
|
expectfn 'curl -s -X POST -d {"interface":{"name":"TEST","type":"eth0"}} http://localhost/restconf/data/cont1' ""
|
||||||
|
|
||||||
new "restconf POST again"
|
new "restconf POST again"
|
||||||
expecteq 'curl -s -X POST -d {"interface":{"name":"TEST","type":"eth0"}} http://localhost/restconf/data/cont1' '{"ietf-restconf:errors" : {"error": {"error-tag": "data-exists","error-type": "application","error-severity": "error","error-message": "Data already exists; cannot create new resource"}}}'
|
expecteq 'curl -s -X POST -d {"interface":{"name":"TEST","type":"eth0"}} http://localhost/restconf/data/cont1' '{"ietf-restconf:errors" : {"error": {"error-tag": "data-exists","error-type": "application","error-severity": "error","error-message": "Data already exists; cannot create new resource"}}}
'
|
||||||
|
|
||||||
new "restconf POST from top"
|
new "restconf POST from top"
|
||||||
expecteq 'curl -s -X POST -d {"cont1":{"interface":{"name":"TEST","type":"eth0"}}} http://localhost/restconf/data' '{"ietf-restconf:errors" : {"error": {"error-tag": "data-exists","error-type": "application","error-severity": "error","error-message": "Data already exists; cannot create new resource"}}}'
|
expecteq 'curl -s -X POST -d {"cont1":{"interface":{"name":"TEST","type":"eth0"}}} http://localhost/restconf/data' '{"ietf-restconf:errors" : {"error": {"error-tag": "data-exists","error-type": "application","error-severity": "error","error-message": "Data already exists; cannot create new resource"}}}
'
|
||||||
|
|
||||||
new "restconf DELETE"
|
new "restconf DELETE"
|
||||||
expectfn 'curl -s -X DELETE http://localhost/restconf/data/cont1' ""
|
expectfn 'curl -s -X DELETE http://localhost/restconf/data/cont1' ""
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue