* Checked yang binding validity which lead to:
* Changed and enhanced several `bad-element` error replies to `unknown-element` with more detailed error-message.
This commit is contained in:
parent
b56c0220c9
commit
57b104bc25
21 changed files with 106 additions and 70 deletions
|
|
@ -51,9 +51,11 @@ Expected: July 2020
|
||||||
* CLICON_SSL_CA_CERT
|
* CLICON_SSL_CA_CERT
|
||||||
|
|
||||||
* Restconf FCGI (eg via nginx) have changed reply message syntax slightly as follows (due to refactoring and common code with evhtp):
|
* Restconf FCGI (eg via nginx) have changed reply message syntax slightly as follows (due to refactoring and common code with evhtp):
|
||||||
* Bodies in error reyruns including html code have been removed
|
* Bodies in error retuns including html code have been removed
|
||||||
* Some (extra) CRLF:s have been removed
|
* Some (extra) CRLF:s have been removed
|
||||||
|
|
||||||
|
* Changed and enhanced several `bad-element` error replies to `unknown-element` with more detailed error-message.
|
||||||
|
|
||||||
### C/CLI-API changes on existing features (For developers)
|
### C/CLI-API changes on existing features (For developers)
|
||||||
|
|
||||||
* Changed module-specific upgrade API, not backward compatible. The API has been simplified which means more has to be done by the programmer.
|
* Changed module-specific upgrade API, not backward compatible. The API has been simplified which means more has to be done by the programmer.
|
||||||
|
|
|
||||||
|
|
@ -624,8 +624,13 @@ from_client_edit_config(clicon_handle h,
|
||||||
xml_spec_set(xc, NULL);
|
xml_spec_set(xc, NULL);
|
||||||
/* Populate XML with Yang spec (why not do this in parser?)
|
/* Populate XML with Yang spec (why not do this in parser?)
|
||||||
*/
|
*/
|
||||||
if (xml_bind_yang(xc, YB_MODULE, yspec, NULL) < 0)
|
if ((ret = xml_bind_yang(xc, YB_MODULE, yspec, &xret)) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
|
if (ret == 0){
|
||||||
|
if (clicon_xml2cbuf(cbret, xret, 0, 0, -1) < 0)
|
||||||
|
goto done;
|
||||||
|
goto ok;
|
||||||
|
}
|
||||||
/* Maybe validate xml here as in text_modify_top? */
|
/* Maybe validate xml here as in text_modify_top? */
|
||||||
if (xml_apply(xc, CX_ELMNT, xml_non_config_data, &non_config) < 0)
|
if (xml_apply(xc, CX_ELMNT, xml_non_config_data, &non_config) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
|
|
|
||||||
|
|
@ -217,8 +217,13 @@ startup_common(clicon_handle h,
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
/* After upgrading, XML tree needs to be sorted and yang spec populated */
|
/* After upgrading, XML tree needs to be sorted and yang spec populated */
|
||||||
if (xml_bind_yang(xt, YB_MODULE, yspec, NULL) < 0)
|
if ((ret = xml_bind_yang(xt, YB_MODULE, yspec, &xret)) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
|
if (ret == 0){
|
||||||
|
if (clicon_xml2cbuf(cbret, xret, 0, 0, -1) < 0)
|
||||||
|
goto done;
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
if (xml_sort_recurse(xt) < 0)
|
if (xml_sort_recurse(xt) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
/* Handcraft transition with with only add tree */
|
/* Handcraft transition with with only add tree */
|
||||||
|
|
|
||||||
|
|
@ -149,9 +149,10 @@ netconf_input_packet(clicon_handle h,
|
||||||
free(str0);
|
free(str0);
|
||||||
if ((xrpc=xpath_first(xreq, NULL, "//rpc")) != NULL){
|
if ((xrpc=xpath_first(xreq, NULL, "//rpc")) != NULL){
|
||||||
isrpc++;
|
isrpc++;
|
||||||
if (xml_bind_yang_rpc(xrpc, yspec, NULL) < 0)
|
if ((ret = xml_bind_yang_rpc(xrpc, yspec, &xret)) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
if ((ret = xml_yang_validate_rpc(h, xrpc, &xret)) < 0)
|
if (ret > 0 &&
|
||||||
|
(ret = xml_yang_validate_rpc(h, xrpc, &xret)) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
if (ret == 0){
|
if (ret == 0){
|
||||||
clicon_xml2cbuf(cbret, xret, 0, 0, -1);
|
clicon_xml2cbuf(cbret, xret, 0, 0, -1);
|
||||||
|
|
|
||||||
|
|
@ -535,6 +535,7 @@ netconf_create_subscription(clicon_handle h,
|
||||||
*
|
*
|
||||||
* This may either be local client-side or backend. If backend send as netconf
|
* This may either be local client-side or backend. If backend send as netconf
|
||||||
* RPC.
|
* RPC.
|
||||||
|
* Assume already bound and validated.
|
||||||
* @param[in] h clicon handle
|
* @param[in] h clicon handle
|
||||||
* @param[in] xn Sub-tree (under xorig) at child of rpc: <rpc><xn></rpc>.
|
* @param[in] xn Sub-tree (under xorig) at child of rpc: <rpc><xn></rpc>.
|
||||||
* @param[out] xret Return XML, error or OK
|
* @param[out] xret Return XML, error or OK
|
||||||
|
|
@ -542,6 +543,7 @@ netconf_create_subscription(clicon_handle h,
|
||||||
* @retval -1 Error
|
* @retval -1 Error
|
||||||
* @retval 0 OK, not found handler.
|
* @retval 0 OK, not found handler.
|
||||||
* @retval 1 OK, handler called
|
* @retval 1 OK, handler called
|
||||||
|
* @see netconf_input_packet Assume bind and validation made there
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
netconf_application_rpc(clicon_handle h,
|
netconf_application_rpc(clicon_handle h,
|
||||||
|
|
@ -552,7 +554,6 @@ netconf_application_rpc(clicon_handle h,
|
||||||
yang_stmt *yspec = NULL; /* application yspec */
|
yang_stmt *yspec = NULL; /* application yspec */
|
||||||
yang_stmt *yrpc = NULL;
|
yang_stmt *yrpc = NULL;
|
||||||
yang_stmt *ymod = NULL;
|
yang_stmt *ymod = NULL;
|
||||||
yang_stmt *yinput;
|
|
||||||
yang_stmt *youtput;
|
yang_stmt *youtput;
|
||||||
cxobj *xoutput;
|
cxobj *xoutput;
|
||||||
cxobj *xerr = NULL;
|
cxobj *xerr = NULL;
|
||||||
|
|
@ -591,22 +592,7 @@ netconf_application_rpc(clicon_handle h,
|
||||||
yrpc = yang_find(ymod, Y_RPC, xml_name(xn));
|
yrpc = yang_find(ymod, Y_RPC, xml_name(xn));
|
||||||
/* Check if found */
|
/* Check if found */
|
||||||
if (yrpc != NULL){
|
if (yrpc != NULL){
|
||||||
/* 1. Check xn arguments with input statement. */
|
/* No need to check xn arguments with input statement since already bound and validated. */
|
||||||
if ((yinput = yang_find(yrpc, Y_INPUT, NULL)) != NULL){
|
|
||||||
xml_spec_set(xn, yinput); /* needed for xml_bind_yang */
|
|
||||||
if (xml_bind_yang(xn, YB_MODULE, yspec, NULL) < 0)
|
|
||||||
goto done;
|
|
||||||
if ((ret = xml_yang_validate_all_top(h, xn, &xerr)) < 0)
|
|
||||||
goto done;
|
|
||||||
if (ret > 0 && (ret = xml_yang_validate_add(h, xn, &xerr)) < 0)
|
|
||||||
goto done;
|
|
||||||
if (ret == 0){
|
|
||||||
if (clicon_xml2cbuf(cbret, xerr, 0, 0, -1) < 0)
|
|
||||||
goto done;
|
|
||||||
netconf_output_encap(1, cbret, "rpc-error");
|
|
||||||
goto ok;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/* Look for local (client-side) netconf plugins. */
|
/* Look for local (client-side) netconf plugins. */
|
||||||
if ((ret = rpc_callback_call(h, xn, cbret, NULL)) < 0)
|
if ((ret = rpc_callback_call(h, xn, cbret, NULL)) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
|
|
@ -626,9 +612,9 @@ netconf_application_rpc(clicon_handle h,
|
||||||
if ((youtput = yang_find(yrpc, Y_OUTPUT, NULL)) != NULL){
|
if ((youtput = yang_find(yrpc, Y_OUTPUT, NULL)) != NULL){
|
||||||
xoutput=xpath_first(*xret, NULL, "/");
|
xoutput=xpath_first(*xret, NULL, "/");
|
||||||
xml_spec_set(xoutput, youtput); /* needed for xml_bind_yang */
|
xml_spec_set(xoutput, youtput); /* needed for xml_bind_yang */
|
||||||
if (xml_bind_yang(xoutput, YB_MODULE, yspec, NULL) < 0)
|
if ((ret = xml_bind_yang(xoutput, YB_MODULE, yspec, &xerr)) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
if ((ret = xml_yang_validate_all_top(h, xoutput, &xerr)) < 0)
|
if (ret > 0 && (ret = xml_yang_validate_all_top(h, xoutput, &xerr)) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
if (ret > 0 && (ret = xml_yang_validate_add(h, xoutput, &xerr)) < 0)
|
if (ret > 0 && (ret = xml_yang_validate_add(h, xoutput, &xerr)) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
|
|
|
||||||
|
|
@ -670,9 +670,9 @@ api_operations_post_output(clicon_handle h,
|
||||||
if (youtput != NULL){
|
if (youtput != NULL){
|
||||||
xml_spec_set(xoutput, youtput); /* needed for xml_bind_yang */
|
xml_spec_set(xoutput, youtput); /* needed for xml_bind_yang */
|
||||||
#ifdef notyet
|
#ifdef notyet
|
||||||
if (xml_bind_yang(xoutput, YB_MODULE, yspec, NULL) < 0)
|
if ((ret = xml_bind_yang(xoutput, YB_MODULE, yspec, &xerr)) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
if ((ret = xml_yang_validate_all(xoutput, &xerr)) < 0)
|
if (ret > 0 && (ret = xml_yang_validate_all(xoutput, &xerr)) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
if (ret == 1 &&
|
if (ret == 1 &&
|
||||||
(ret = xml_yang_validate_add(h, xoutput, &xerr)) < 0)
|
(ret = xml_yang_validate_add(h, xoutput, &xerr)) < 0)
|
||||||
|
|
|
||||||
|
|
@ -184,7 +184,7 @@ populate_self_parent(cxobj *xt,
|
||||||
if (ns)
|
if (ns)
|
||||||
cprintf(cb, " in namespace: %s", ns);
|
cprintf(cb, " in namespace: %s", ns);
|
||||||
if (xerr &&
|
if (xerr &&
|
||||||
netconf_bad_element_xml(xerr, "application", name, cbuf_get(cb)) < 0)
|
netconf_unknown_element_xml(xerr, "application", name, cbuf_get(cb)) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
@ -251,15 +251,26 @@ populate_self_top(cxobj *xt,
|
||||||
}
|
}
|
||||||
if (ys_module_by_xml(yspec, xt, &ymod) < 0)
|
if (ys_module_by_xml(yspec, xt, &ymod) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
/* ymod is "real" module, name may belong to included submodule */
|
|
||||||
if (ymod == NULL){
|
|
||||||
if (xerr &&
|
|
||||||
netconf_bad_element_xml(xerr, "application", name, "No such yang module") < 0)
|
|
||||||
goto done;
|
|
||||||
goto fail;
|
|
||||||
}
|
|
||||||
if (xml2ns(xt, xml_prefix(xt), &ns) < 0)
|
if (xml2ns(xt, xml_prefix(xt), &ns) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
|
/* ymod is "real" module, name may belong to included submodule */
|
||||||
|
if (ymod == NULL){
|
||||||
|
if (xerr){
|
||||||
|
if ((cb = cbuf_new()) == NULL){
|
||||||
|
clicon_err(OE_UNIX, errno, "cbuf_new");
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
cprintf(cb, "Failed to find YANG spec of XML node: %s", name);
|
||||||
|
if ((xp = xml_parent(xt)) != NULL)
|
||||||
|
cprintf(cb, " with parent: %s", xml_name(xp));
|
||||||
|
if (ns)
|
||||||
|
cprintf(cb, " in namespace: %s", ns);
|
||||||
|
if (netconf_unknown_element_xml(xerr, "application", name, cbuf_get(cb)) < 0)
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
|
||||||
if ((y = yang_find_schemanode(ymod, name)) == NULL){ /* also rpc */
|
if ((y = yang_find_schemanode(ymod, name)) == NULL){ /* also rpc */
|
||||||
if (_yang_unknown_anydata){
|
if (_yang_unknown_anydata){
|
||||||
/* Add dummy Y_ANYDATA yang stmt, see ysp_add */
|
/* Add dummy Y_ANYDATA yang stmt, see ysp_add */
|
||||||
|
|
@ -279,7 +290,7 @@ populate_self_top(cxobj *xt,
|
||||||
if (ns)
|
if (ns)
|
||||||
cprintf(cb, " in namespace: %s", ns);
|
cprintf(cb, " in namespace: %s", ns);
|
||||||
if (xerr &&
|
if (xerr &&
|
||||||
netconf_bad_element_xml(xerr, "application", name, cbuf_get(cb)) < 0)
|
netconf_unknown_element_xml(xerr, "application", name, cbuf_get(cb)) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
@ -320,7 +331,8 @@ populate_self_top(cxobj *xt,
|
||||||
* @retval 0 Partial or no yang assigment made (at least one failed) and xerr set
|
* @retval 0 Partial or no yang assigment made (at least one failed) and xerr set
|
||||||
* @retval -1 Error
|
* @retval -1 Error
|
||||||
* @code
|
* @code
|
||||||
* if (xml_bind_yang(x, YB_MODULE, yspec, NULL) < 0)
|
* cxobj *xerr = NULL;
|
||||||
|
* if (xml_bind_yang(x, YB_MODULE, yspec, &xerr) < 0)
|
||||||
* err;
|
* err;
|
||||||
* @endcode
|
* @endcode
|
||||||
* @note For subs to anyxml nodes will not have spec set
|
* @note For subs to anyxml nodes will not have spec set
|
||||||
|
|
|
||||||
|
|
@ -514,6 +514,7 @@ xpath_parse(const char *xpath,
|
||||||
}
|
}
|
||||||
xpath_parse_exit(&xpy);
|
xpath_parse_exit(&xpy);
|
||||||
xpath_scan_exit(&xpy);
|
xpath_scan_exit(&xpy);
|
||||||
|
if (xptree)
|
||||||
*xptree = xpy.xpy_top;
|
*xptree = xpy.xpy_top;
|
||||||
retval = 0;
|
retval = 0;
|
||||||
done:
|
done:
|
||||||
|
|
|
||||||
|
|
@ -129,6 +129,7 @@ fi
|
||||||
BUSER=clicon
|
BUSER=clicon
|
||||||
|
|
||||||
# If set, unknown XML is treated as ANYDATA
|
# If set, unknown XML is treated as ANYDATA
|
||||||
|
# This would only happen if you set option YANG_UNKNOWN_ANYDATA to something else than default
|
||||||
: ${YANG_UNKNOWN_ANYDATA:=false}
|
: ${YANG_UNKNOWN_ANYDATA:=false}
|
||||||
|
|
||||||
# Follow the binary programs that can be parametrized (eg with valgrind)
|
# Follow the binary programs that can be parametrized (eg with valgrind)
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,8 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
# Tests cpp compatibility with clixon
|
# Tests C++ compatibility with clixon
|
||||||
|
# The test compiles a c++ backend plugin, installs it and starts the backend, and then runs
|
||||||
|
# an RPC example.
|
||||||
|
# The RPC example is the "example" RPC in clixon-example.yang
|
||||||
|
|
||||||
# Magic line must be first in script (see README.md)
|
# Magic line must be first in script (see README.md)
|
||||||
s="$_" ; . ./lib.sh || if [ "$s" = $0 ]; then exit 0; else return 0; fi
|
s="$_" ; . ./lib.sh || if [ "$s" = $0 ]; then exit 0; else return 0; fi
|
||||||
|
|
|
||||||
|
|
@ -149,8 +149,8 @@ expecteof "$clixon_netconf -qf $cfg" 0 '<rpc message-id="101"><get-config><sourc
|
||||||
new "copy startup->candidate"
|
new "copy startup->candidate"
|
||||||
expecteof "$clixon_netconf -qf $cfg" 0 "<rpc><copy-config><target><candidate/></target><source><startup/></source></copy-config></rpc>]]>]]>" "^<rpc-reply><ok/></rpc-reply>]]>]]>$"
|
expecteof "$clixon_netconf -qf $cfg" 0 "<rpc><copy-config><target><candidate/></target><source><startup/></source></copy-config></rpc>]]>]]>" "^<rpc-reply><ok/></rpc-reply>]]>]]>$"
|
||||||
|
|
||||||
new "copy startup->running not allowed"
|
|
||||||
if ! $YANG_UNKNOWN_ANYDATA ; then
|
if ! $YANG_UNKNOWN_ANYDATA ; then
|
||||||
|
new "copy startup->running not allowed"
|
||||||
expecteof "$clixon_netconf -qf $cfg" 0 "<rpc><copy-config><target><running/></target><source><startup/></source></copy-config></rpc>]]>]]>" "^<rpc-reply><rpc-error><error-type>application</error-type><error-tag>unknown-element</error-tag><error-info><bad-element>running</bad-element></error-info><error-severity>error</error-severity><error-message>Failed to find YANG spec of XML node: running with parent: target in namespace: urn:ietf:params:xml:ns:netconf:base:1.0</error-message></rpc-error></rpc-reply>]]>]]>$"
|
expecteof "$clixon_netconf -qf $cfg" 0 "<rpc><copy-config><target><running/></target><source><startup/></source></copy-config></rpc>]]>]]>" "^<rpc-reply><rpc-error><error-type>application</error-type><error-tag>unknown-element</error-tag><error-info><bad-element>running</bad-element></error-info><error-severity>error</error-severity><error-message>Failed to find YANG spec of XML node: running with parent: target in namespace: urn:ietf:params:xml:ns:netconf:base:1.0</error-message></rpc-error></rpc-reply>]]>]]>$"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -109,7 +109,7 @@ new "netconf validate enabled feature"
|
||||||
expecteof "$clixon_netconf -qf $cfg" 0 "<rpc><validate><source><candidate/></source></validate></rpc>]]>]]>" "^<rpc-reply><ok/></rpc-reply>]]>]]>$"
|
expecteof "$clixon_netconf -qf $cfg" 0 "<rpc><validate><source><candidate/></source></validate></rpc>]]>]]>" "^<rpc-reply><ok/></rpc-reply>]]>]]>$"
|
||||||
|
|
||||||
new "netconf disabled feature"
|
new "netconf disabled feature"
|
||||||
expecteof "$clixon_netconf -qf $cfg" 0 '<rpc><edit-config><target><candidate/></target><config><y xmlns="urn:example:clixon">foo</y></config></edit-config></rpc>]]>]]>' '^<rpc-reply><rpc-error><error-type>application</error-type><error-tag>unknown-element</error-tag><error-info><bad-element>y</bad-element></error-info><error-severity>error</error-severity><error-message>Unassigned yang spec</error-message></rpc-error></rpc-reply>]]>]]>$'
|
expecteof "$clixon_netconf -qf $cfg" 0 '<rpc><edit-config><target><candidate/></target><config><y xmlns="urn:example:clixon">foo</y></config></edit-config></rpc>]]>]]>' '^<rpc-reply><rpc-error><error-type>application</error-type><error-tag>unknown-element</error-tag><error-info><bad-element>y</bad-element></error-info><error-severity>error</error-severity><error-message>Failed to find YANG spec of XML node: y with parent: config in namespace: urn:example:clixon</error-message></rpc-error></rpc-reply>]]>]]>$'
|
||||||
|
|
||||||
# This test has been broken up into all different modules instead of one large
|
# This test has been broken up into all different modules instead of one large
|
||||||
# reply since the modules change so often
|
# reply since the modules change so often
|
||||||
|
|
|
||||||
|
|
@ -284,7 +284,7 @@ expectpart "$(curl $CURLOPTS -X DELETE $RCPROTO://localhost/restconf/data/exampl
|
||||||
# 2. set identity in other module with restconf , read it with restconf and netconf
|
# 2. set identity in other module with restconf , read it with restconf and netconf
|
||||||
if ! $YANG_UNKNOWN_ANYDATA ; then
|
if ! $YANG_UNKNOWN_ANYDATA ; then
|
||||||
new "restconf add POST instead of PUT (should fail)"
|
new "restconf add POST instead of PUT (should fail)"
|
||||||
expectpart "$(curl $CURLOPTS -X POST -H "Content-Type: application/yang-data+json" $RCPROTO://localhost/restconf/data/example:crypto -d '{"example:crypto":"example-des:des3"}')" 0 'HTTP/1.1 400 Bad Request' '{"ietf-restconf:errors":{"error":{"error-type":"application","error-tag":"bad-element","error-info":{"bad-element":"crypto"},"error-severity":"error","error-message":"Failed to find YANG spec of XML node: crypto with parent: crypto in namespace: urn:example:my-crypto"}}}'
|
expectpart "$(curl $CURLOPTS -X POST -H "Content-Type: application/yang-data+json" $RCPROTO://localhost/restconf/data/example:crypto -d '{"example:crypto":"example-des:des3"}')" 0 'HTTP/1.1 400 Bad Request' '{"ietf-restconf:errors":{"error":{"error-type":"application","error-tag":"unknown-element","error-info":{"bad-element":"crypto"},"error-severity":"error","error-message":"Failed to find YANG spec of XML node: crypto with parent: crypto in namespace: urn:example:my-crypto"}}}'
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Alternative error:
|
# Alternative error:
|
||||||
|
|
|
||||||
|
|
@ -202,7 +202,7 @@ new "netconf client-side rpc"
|
||||||
expecteof "$clixon_netconf -qf $cfg" 0 '<rpc><client-rpc xmlns="urn:example:clixon"><x>val42</x></client-rpc></rpc>]]>]]>' '^<rpc-reply><x xmlns="urn:example:clixon">val42</x></rpc-reply>]]>]]>$'
|
expecteof "$clixon_netconf -qf $cfg" 0 '<rpc><client-rpc xmlns="urn:example:clixon"><x>val42</x></client-rpc></rpc>]]>]]>' '^<rpc-reply><x xmlns="urn:example:clixon">val42</x></rpc-reply>]]>]]>$'
|
||||||
|
|
||||||
new "netconf extra leaf in leaf should fail"
|
new "netconf extra leaf in leaf should fail"
|
||||||
expecteof "$clixon_netconf -qf $cfg" 0 '<rpc><edit-config><target><candidate/></target><config><interfaces xmlns="urn:ietf:params:xml:ns:yang:ietf-interfaces"><interface><name>e0<name>e1</name></name></interface></interfaces></config></edit-config></rpc>]]>]]>' '^<rpc-reply><rpc-error><error-type>application</error-type><error-tag>unknown-element</error-tag><error-info><bad-element>name</bad-element></error-info><error-severity>error</error-severity><error-message>Leaf contains sub-element</error-message></rpc-error></rpc-reply>]]>]]>$'
|
expecteof "$clixon_netconf -qf $cfg" 0 '<rpc><edit-config><target><candidate/></target><config><interfaces xmlns="urn:ietf:params:xml:ns:yang:ietf-interfaces"><interface><name>e0<name>e1</name></name></interface></interfaces></config></edit-config></rpc>]]>]]>' '^<rpc-reply><rpc-error><error-type>application</error-type><error-tag>unknown-element</error-tag><error-info><bad-element>name</bad-element></error-info><error-severity>error</error-severity><error-message>Failed to find YANG spec of XML node: name with parent: name in namespace: urn:ietf:params:xml:ns:yang:ietf-interfaces</error-message></rpc-error></rpc-reply>]]>]]>$'
|
||||||
|
|
||||||
if [ $BE -eq 0 ]; then
|
if [ $BE -eq 0 ]; then
|
||||||
exit # BE
|
exit # BE
|
||||||
|
|
|
||||||
|
|
@ -231,7 +231,7 @@ expectpart "$(curl $CURLOPTS -X POST -H "Content-Type: application/yang-data+jso
|
||||||
|
|
||||||
if ! $YANG_UNKNOWN_ANYDATA ; then
|
if ! $YANG_UNKNOWN_ANYDATA ; then
|
||||||
new "restconf rpc using POST json wrong"
|
new "restconf rpc using POST json wrong"
|
||||||
expectpart "$(curl $CURLOPTS -X POST -H "Content-Type: application/yang-data+json" -d '{"clixon-example:input":{"wrongelement":"ipv4"}}' $RCPROTO://localhost/restconf/operations/clixon-example:example)" 0 'HTTP/1.1 400 Bad Request' '{"ietf-restconf:errors":{"error":{"error-type":"application","error-tag":"bad-element","error-info":{"bad-element":"wrongelement"},"error-severity":"error","error-message":"Failed to find YANG spec of XML node: wrongelement with parent: example in namespace: urn:example:clixon"}}}'
|
expectpart "$(curl $CURLOPTS -X POST -H "Content-Type: application/yang-data+json" -d '{"clixon-example:input":{"wrongelement":"ipv4"}}' $RCPROTO://localhost/restconf/operations/clixon-example:example)" 0 'HTTP/1.1 400 Bad Request' '{"ietf-restconf:errors":{"error":{"error-type":"application","error-tag":"unknown-element","error-info":{"bad-element":"wrongelement"},"error-severity":"error","error-message":"Failed to find YANG spec of XML node: wrongelement with parent: example in namespace: urn:example:clixon"}}}'
|
||||||
fi
|
fi
|
||||||
|
|
||||||
new "restconf rpc non-existing rpc without namespace"
|
new "restconf rpc non-existing rpc without namespace"
|
||||||
|
|
|
||||||
|
|
@ -216,7 +216,7 @@ expectpart "$(curl $CURLOPTS -X GET $RCPROTO://localhost/restconf/data/augment:r
|
||||||
#----------------------------------------------
|
#----------------------------------------------
|
||||||
# Also generate an invalid state XML. This should generate an "Internal" error and the name of the
|
# Also generate an invalid state XML. This should generate an "Internal" error and the name of the
|
||||||
new "restconf GET failed state"
|
new "restconf GET failed state"
|
||||||
expectpart "$(curl $CURLOPTS -X GET -H 'Accept: application/yang-data+xml' $RCPROTO://localhost/restconf/data?content=nonconfig)" 0 '412 Precondition Failed' '<errors xmlns="urn:ietf:params:xml:ns:yang:ietf-restconf"><error><error-type>application</error-type><error-tag>operation-failed</error-tag><error-info><bad-element>mystate</bad-element></error-info><error-severity>error</error-severity><error-message>No such yang module. Internal error, state callback returned invalid XML: example_backend</error-message></error></errors>'
|
expectpart "$(curl $CURLOPTS -X GET -H 'Accept: application/yang-data+xml' $RCPROTO://localhost/restconf/data?content=nonconfig)" 0 '412 Precondition Failed' '<errors xmlns="urn:ietf:params:xml:ns:yang:ietf-restconf"><error><error-type>application</error-type><error-tag>operation-failed</error-tag><error-info><bad-element>mystate</bad-element></error-info><error-severity>error</error-severity><error-message>Failed to find YANG spec of XML node: mystate with parent: top in namespace: urn:example:foobar. Internal error, state callback returned invalid XML: example_backend</error-message></error></errors>'
|
||||||
|
|
||||||
if [ $RC -ne 0 ]; then
|
if [ $RC -ne 0 ]; then
|
||||||
new "Kill restconf daemon"
|
new "Kill restconf daemon"
|
||||||
|
|
|
||||||
|
|
@ -126,7 +126,7 @@ expectpart "$(curl $CURLOPTS -X POST -H "Content-Type: application/yang-data+jso
|
||||||
|
|
||||||
new "restconf add extra w/o yang: should fail"
|
new "restconf add extra w/o yang: should fail"
|
||||||
if ! $YANG_UNKNOWN_ANYDATA ; then
|
if ! $YANG_UNKNOWN_ANYDATA ; then
|
||||||
expectpart "$(curl $CURLOPTS -X POST -H "Content-Type: application/yang-data+json" -d '{"clixon-example:input":{"x":"0","extra":"0"}}' $RCPROTO://localhost/restconf/operations/clixon-example:example)" 0 'HTTP/1.1 400 Bad Request' '{"ietf-restconf:errors":{"error":{"error-type":"application","error-tag":"bad-element","error-info":{"bad-element":"extra"},"error-severity":"error","error-message":"Failed to find YANG spec of XML node: extra with parent: example in namespace: urn:example:clixon"}}}'
|
expectpart "$(curl $CURLOPTS -X POST -H "Content-Type: application/yang-data+json" -d '{"clixon-example:input":{"x":"0","extra":"0"}}' $RCPROTO://localhost/restconf/operations/clixon-example:example)" 0 'HTTP/1.1 400 Bad Request' '{"ietf-restconf:errors":{"error":{"error-type":"application","error-tag":"unknown-element","error-info":{"bad-element":"extra"},"error-severity":"error","error-message":"Failed to find YANG spec of XML node: extra with parent: example in namespace: urn:example:clixon"}}}'
|
||||||
fi
|
fi
|
||||||
|
|
||||||
new "restconf wrong method"
|
new "restconf wrong method"
|
||||||
|
|
@ -157,7 +157,7 @@ expecteof "$clixon_netconf -qf $cfg" 0 '<rpc><edit-config xmlns="urn:ietf:params
|
||||||
|
|
||||||
# Negative errors (namespace/module missing)
|
# Negative errors (namespace/module missing)
|
||||||
new "netconf wrong rpc namespace: should fail"
|
new "netconf wrong rpc namespace: should fail"
|
||||||
expecteof "$clixon_netconf -qf $cfg" 0 '<rpc xmlns="urn:example:xxx"><get/></rpc>]]>]]>' '^<rpc-reply><rpc-error><error-type>application</error-type><error-tag>unknown-element</error-tag><error-info><bad-element>get</bad-element></error-info><error-severity>error</error-severity></rpc-error></rpc-reply>]]>]]>$'
|
expecteof "$clixon_netconf -qf $cfg" 0 '<rpc xmlns="urn:example:xxx"><get/></rpc>]]>]]>' '^<rpc-reply><rpc-error><error-type>application</error-type><error-tag>unknown-element</error-tag><error-info><bad-element>get</bad-element></error-info><error-severity>error</error-severity><error-message>Unrecognized RPC (wrong namespace?)</error-message></rpc-error></rpc-reply>]]>]]>$'
|
||||||
|
|
||||||
new "restconf wrong rpc: should fail"
|
new "restconf wrong rpc: should fail"
|
||||||
expectpart "$(curl $CURLOPTS -X POST -H "Content-Type: application/yang-data+json" u $RCPROTO://localhost/restconf/operations/clixon-foo:get)" 0 'HTTP/1.1 412 Precondition Failed' '{"ietf-restconf:errors":{"error":{"error-type":"protocol","error-tag":"operation-failed","error-severity":"error","error-message":"yang module not found"}}}'
|
expectpart "$(curl $CURLOPTS -X POST -H "Content-Type: application/yang-data+json" u $RCPROTO://localhost/restconf/operations/clixon-foo:get)" 0 'HTTP/1.1 412 Precondition Failed' '{"ietf-restconf:errors":{"error":{"error-type":"protocol","error-tag":"operation-failed","error-severity":"error","error-message":"yang module not found"}}}'
|
||||||
|
|
|
||||||
|
|
@ -113,12 +113,12 @@ testrun()
|
||||||
XML="$XMLA$XMLU"
|
XML="$XMLA$XMLU"
|
||||||
else
|
else
|
||||||
XML="$XMLA"
|
XML="$XMLA"
|
||||||
unknownreply="<rpc-reply><rpc-error><error-type>application</error-type><error-tag>unknown-element</error-tag><error-info><bad-element>u1</bad-element></error-info><error-severity>error</error-severity><error-message>Unassigned yang spec</error-message></rpc-error></rpc-reply>]]>]]>"
|
unknownreply="<rpc-error><error-type>application</error-type><error-tag>unknown-element</error-tag><error-info><bad-element>u1</bad-element></error-info><error-severity>error</error-severity><error-message>Failed to find YANG spec of XML node: u1 with parent: config in namespace: urn:example:unknown</error-message></rpc-error>"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
XML="$XMLA"
|
XML="$XMLA"
|
||||||
unknownreply="<rpc-reply><rpc-error><error-type>application</error-type><error-tag>unknown
|
unknownreply="<rpc-error><error-type>application</error-type><error-tag>unknown
|
||||||
-element</error-tag><error-info><bad-element>u1</bad-element></error-info><error-severity>error</error-severity><error-message>Unassigned yang spec</error-message></rpc-error></rpc-reply>]]>]]>"
|
-element</error-tag><error-info><bad-element>u1</bad-element></error-info><error-severity>error</error-severity><error-message>Failed to find YANG spec of XML node: u1 with parent: config in namespace: urn:example:unknown</error-message></rpc-error>"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if $startup; then # get config from startup
|
if $startup; then # get config from startup
|
||||||
|
|
@ -265,16 +265,16 @@ EOF
|
||||||
|
|
||||||
new "test params: -f $cfg"
|
new "test params: -f $cfg"
|
||||||
|
|
||||||
new "no startup, dont treat unknown as anydata"
|
new "no startup, dont treat unknown as anydata----"
|
||||||
testrun false false
|
testrun false false
|
||||||
|
|
||||||
new "startup, dont treat unknown as anydata"
|
new "startup, dont treat unknown as anydata----"
|
||||||
testrun true false
|
testrun true false
|
||||||
|
|
||||||
new "no startup, treat unknown as anydata"
|
new "no startup, treat unknown as anydata----"
|
||||||
testrun false true
|
testrun false true
|
||||||
|
|
||||||
new "startup, treat unknown as anydata"
|
new "startup, treat unknown as anydata----"
|
||||||
testrun true true
|
testrun true true
|
||||||
|
|
||||||
rm -rf $dir
|
rm -rf $dir
|
||||||
|
|
|
||||||
|
|
@ -91,10 +91,10 @@ new "1. Set newex"
|
||||||
expecteof "$clixon_netconf -qf $cfg" 0 '<rpc><edit-config><target><candidate/></target><config><newex xmlns="urn:example:clixon">str</newex></config></edit-config></rpc>]]>]]>' '^<rpc-reply><ok/></rpc-reply>]]>]]>$'
|
expecteof "$clixon_netconf -qf $cfg" 0 '<rpc><edit-config><target><candidate/></target><config><newex xmlns="urn:example:clixon">str</newex></config></edit-config></rpc>]]>]]>' '^<rpc-reply><ok/></rpc-reply>]]>]]>$'
|
||||||
|
|
||||||
new "Set oldex should fail (since oldex is in old revision and only the new is loaded)"
|
new "Set oldex should fail (since oldex is in old revision and only the new is loaded)"
|
||||||
expecteof "$clixon_netconf -qf $cfg" 0 '<rpc><edit-config><target><candidate/></target><config><oldex xmlns="urn:example:clixon">str</oldex></config></edit-config></rpc>]]>]]>' '^<rpc-reply><rpc-error><error-type>application</error-type><error-tag>unknown-element</error-tag><error-info><bad-element>oldex</bad-element></error-info><error-severity>error</error-severity><error-message>Unassigned yang spec</error-message></rpc-error></rpc-reply>]]>]]>$'
|
expecteof "$clixon_netconf -qf $cfg" 0 '<rpc><edit-config><target><candidate/></target><config><oldex xmlns="urn:example:clixon">str</oldex></config></edit-config></rpc>]]>]]>' '^<rpc-reply><rpc-error><error-type>application</error-type><error-tag>unknown-element</error-tag><error-info><bad-element>oldex</bad-element></error-info><error-severity>error</error-severity><error-message>Failed to find YANG spec of XML node: oldex with parent: config in namespace: urn:example:clixon</error-message></rpc-error></rpc-reply>]]>]]>$'
|
||||||
|
|
||||||
new "Set other should fail"
|
new "Set other should fail"
|
||||||
expecteof "$clixon_netconf -qf $cfg" 0 '<rpc><edit-config><target><candidate/></target><config><other xmlns="urn:example:clixon2">str</other></config></edit-config></rpc>]]>]]>' '^<rpc-reply><rpc-error><error-type>application</error-type><error-tag>unknown-element</error-tag><error-info><bad-element>other</bad-element></error-info><error-severity>error</error-severity><error-message>Unassigned yang spec</error-message></rpc-error></rpc-reply>]]>]]>$'
|
expecteof "$clixon_netconf -qf $cfg" 0 '<rpc><edit-config><target><candidate/></target><config><other xmlns="urn:example:clixon2">str</other></config></edit-config></rpc>]]>]]>' '^<rpc-reply><rpc-error><error-type>application</error-type><error-tag>unknown-element</error-tag><error-info><bad-element>other</bad-element></error-info><error-severity>error</error-severity><error-message>Failed to find YANG spec of XML node: other with parent: config in namespace: urn:example:clixon2</error-message></rpc-error></rpc-reply>]]>]]>$'
|
||||||
|
|
||||||
if [ $BE -ne 0 ]; then
|
if [ $BE -ne 0 ]; then
|
||||||
new "Kill backend"
|
new "Kill backend"
|
||||||
|
|
@ -139,10 +139,10 @@ new "Set oldex"
|
||||||
expecteof "$clixon_netconf -qf $cfg" 0 '<rpc><edit-config><target><candidate/></target><config><oldex xmlns="urn:example:clixon">str</oldex></config></edit-config></rpc>]]>]]>' '^<rpc-reply><ok/></rpc-reply>]]>]]>$'
|
expecteof "$clixon_netconf -qf $cfg" 0 '<rpc><edit-config><target><candidate/></target><config><oldex xmlns="urn:example:clixon">str</oldex></config></edit-config></rpc>]]>]]>' '^<rpc-reply><ok/></rpc-reply>]]>]]>$'
|
||||||
|
|
||||||
new "Set newex should fail"
|
new "Set newex should fail"
|
||||||
expecteof "$clixon_netconf -qf $cfg" 0 '<rpc><edit-config><target><candidate/></target><config><newex xmlns="urn:example:clixon">str</newex></config></edit-config></rpc>]]>]]>' '^<rpc-reply><rpc-error><error-type>application</error-type><error-tag>unknown-element</error-tag><error-info><bad-element>newex</bad-element></error-info><error-severity>error</error-severity><error-message>Unassigned yang spec</error-message></rpc-error></rpc-reply>]]>]]>$'
|
expecteof "$clixon_netconf -qf $cfg" 0 '<rpc><edit-config><target><candidate/></target><config><newex xmlns="urn:example:clixon">str</newex></config></edit-config></rpc>]]>]]>' '^<rpc-reply><rpc-error><error-type>application</error-type><error-tag>unknown-element</error-tag><error-info><bad-element>newex</bad-element></error-info><error-severity>error</error-severity><error-message>Failed to find YANG spec of XML node: newex with parent: config in namespace: urn:example:clixon</error-message></rpc-error></rpc-reply>]]>]]>$'
|
||||||
|
|
||||||
new "Set other should fail"
|
new "Set other should fail"
|
||||||
expecteof "$clixon_netconf -qf $cfg" 0 '<rpc><edit-config><target><candidate/></target><config><other xmlns="urn:example:clixon2">str</other></config></edit-config></rpc>]]>]]>' '^<rpc-reply><rpc-error><error-type>application</error-type><error-tag>unknown-element</error-tag><error-info><bad-element>other</bad-element></error-info><error-severity>error</error-severity><error-message>Unassigned yang spec</error-message></rpc-error></rpc-reply>]]>]]>$'
|
expecteof "$clixon_netconf -qf $cfg" 0 '<rpc><edit-config><target><candidate/></target><config><other xmlns="urn:example:clixon2">str</other></config></edit-config></rpc>]]>]]>' '^<rpc-reply><rpc-error><error-type>application</error-type><error-tag>unknown-element</error-tag><error-info><bad-element>other</bad-element></error-info><error-severity>error</error-severity><error-message>Failed to find YANG spec of XML node: other with parent: config in namespace: urn:example:clixon2</error-message></rpc-error></rpc-reply>]]>]]>$'
|
||||||
|
|
||||||
if [ $BE -ne 0 ]; then
|
if [ $BE -ne 0 ]; then
|
||||||
new "Kill backend"
|
new "Kill backend"
|
||||||
|
|
@ -183,10 +183,10 @@ new "Set newex"
|
||||||
expecteof "$clixon_netconf -qf $cfg" 0 '<rpc><edit-config><target><candidate/></target><config><newex xmlns="urn:example:clixon">str</newex></config></edit-config></rpc>]]>]]>' '^<rpc-reply><ok/></rpc-reply>]]>]]>$'
|
expecteof "$clixon_netconf -qf $cfg" 0 '<rpc><edit-config><target><candidate/></target><config><newex xmlns="urn:example:clixon">str</newex></config></edit-config></rpc>]]>]]>' '^<rpc-reply><ok/></rpc-reply>]]>]]>$'
|
||||||
|
|
||||||
new "Set oldex should fail"
|
new "Set oldex should fail"
|
||||||
expecteof "$clixon_netconf -qf $cfg" 0 '<rpc><edit-config><target><candidate/></target><config><oldex xmlns="urn:example:clixon">str</oldex></config></edit-config></rpc>]]>]]>' '^<rpc-reply><rpc-error><error-type>application</error-type><error-tag>unknown-element</error-tag><error-info><bad-element>oldex</bad-element></error-info><error-severity>error</error-severity><error-message>Unassigned yang spec</error-message></rpc-error></rpc-reply>]]>]]>$'
|
expecteof "$clixon_netconf -qf $cfg" 0 '<rpc><edit-config><target><candidate/></target><config><oldex xmlns="urn:example:clixon">str</oldex></config></edit-config></rpc>]]>]]>' '^<rpc-reply><rpc-error><error-type>application</error-type><error-tag>unknown-element</error-tag><error-info><bad-element>oldex</bad-element></error-info><error-severity>error</error-severity><error-message>Failed to find YANG spec of XML node: oldex with parent: config in namespace: urn:example:clixon</error-message></rpc-error></rpc-reply>]]>]]>$'
|
||||||
|
|
||||||
new "Set other should fail"
|
new "Set other should fail"
|
||||||
expecteof "$clixon_netconf -qf $cfg" 0 '<rpc><edit-config><target><candidate/></target><config><other xmlns="urn:example:clixon2">str</other></config></edit-config></rpc>]]>]]>' '^<rpc-reply><rpc-error><error-type>application</error-type><error-tag>unknown-element</error-tag><error-info><bad-element>other</bad-element></error-info><error-severity>error</error-severity><error-message>Unassigned yang spec</error-message></rpc-error></rpc-reply>]]>]]>$'
|
expecteof "$clixon_netconf -qf $cfg" 0 '<rpc><edit-config><target><candidate/></target><config><other xmlns="urn:example:clixon2">str</other></config></edit-config></rpc>]]>]]>' '^<rpc-reply><rpc-error><error-type>application</error-type><error-tag>unknown-element</error-tag><error-info><bad-element>other</bad-element></error-info><error-severity>error</error-severity><error-message>Failed to find YANG spec of XML node: other with parent: config in namespace: urn:example:clixon2</error-message></rpc-error></rpc-reply>]]>]]>$'
|
||||||
|
|
||||||
if [ $BE -ne 0 ]; then
|
if [ $BE -ne 0 ]; then
|
||||||
new "Kill backend"
|
new "Kill backend"
|
||||||
|
|
@ -227,10 +227,10 @@ new "Set oldex"
|
||||||
expecteof "$clixon_netconf -qf $cfg" 0 '<rpc><edit-config><target><candidate/></target><config><oldex xmlns="urn:example:clixon">str</oldex></config></edit-config></rpc>]]>]]>' '^<rpc-reply><ok/></rpc-reply>]]>]]>$'
|
expecteof "$clixon_netconf -qf $cfg" 0 '<rpc><edit-config><target><candidate/></target><config><oldex xmlns="urn:example:clixon">str</oldex></config></edit-config></rpc>]]>]]>' '^<rpc-reply><ok/></rpc-reply>]]>]]>$'
|
||||||
|
|
||||||
new "Set newex should fail"
|
new "Set newex should fail"
|
||||||
expecteof "$clixon_netconf -qf $cfg" 0 '<rpc><edit-config><target><candidate/></target><config><newex xmlns="urn:example:clixon">str</newex></config></edit-config></rpc>]]>]]>' '^<rpc-reply><rpc-error><error-type>application</error-type><error-tag>unknown-element</error-tag><error-info><bad-element>newex</bad-element></error-info><error-severity>error</error-severity><error-message>Unassigned yang spec</error-message></rpc-error></rpc-reply>]]>]]>$'
|
expecteof "$clixon_netconf -qf $cfg" 0 '<rpc><edit-config><target><candidate/></target><config><newex xmlns="urn:example:clixon">str</newex></config></edit-config></rpc>]]>]]>' '^<rpc-reply><rpc-error><error-type>application</error-type><error-tag>unknown-element</error-tag><error-info><bad-element>newex</bad-element></error-info><error-severity>error</error-severity><error-message>Failed to find YANG spec of XML node: newex with parent: config in namespace: urn:example:clixon</error-message></rpc-error></rpc-reply>]]>]]>$'
|
||||||
|
|
||||||
new "Set other should fail"
|
new "Set other should fail"
|
||||||
expecteof "$clixon_netconf -qf $cfg" 0 '<rpc><edit-config><target><candidate/></target><config><other xmlns="urn:example:clixon2">str</other></config></edit-config></rpc>]]>]]>' '^<rpc-reply><rpc-error><error-type>application</error-type><error-tag>unknown-element</error-tag><error-info><bad-element>other</bad-element></error-info><error-severity>error</error-severity><error-message>Unassigned yang spec</error-message></rpc-error></rpc-reply>]]>]]>$'
|
expecteof "$clixon_netconf -qf $cfg" 0 '<rpc><edit-config><target><candidate/></target><config><other xmlns="urn:example:clixon2">str</other></config></edit-config></rpc>]]>]]>' '^<rpc-reply><rpc-error><error-type>application</error-type><error-tag>unknown-element</error-tag><error-info><bad-element>other</bad-element></error-info><error-severity>error</error-severity><error-message>Failed to find YANG spec of XML node: other with parent: config in namespace: urn:example:clixon2</error-message></rpc-error></rpc-reply>]]>]]>$'
|
||||||
|
|
||||||
if [ $BE -ne 0 ]; then
|
if [ $BE -ne 0 ]; then
|
||||||
new "Kill backend"
|
new "Kill backend"
|
||||||
|
|
@ -271,7 +271,7 @@ new "Set newex"
|
||||||
expecteof "$clixon_netconf -qf $cfg" 0 '<rpc><edit-config><target><candidate/></target><config><newex xmlns="urn:example:clixon">str</newex></config></edit-config></rpc>]]>]]>' '^<rpc-reply><ok/></rpc-reply>]]>]]>$'
|
expecteof "$clixon_netconf -qf $cfg" 0 '<rpc><edit-config><target><candidate/></target><config><newex xmlns="urn:example:clixon">str</newex></config></edit-config></rpc>]]>]]>' '^<rpc-reply><ok/></rpc-reply>]]>]]>$'
|
||||||
|
|
||||||
new "Set oldex should fail"
|
new "Set oldex should fail"
|
||||||
expecteof "$clixon_netconf -qf $cfg" 0 '<rpc><edit-config><target><candidate/></target><config><oldex xmlns="urn:example:clixon">str</oldex></config></edit-config></rpc>]]>]]>' '^<rpc-reply><rpc-error><error-type>application</error-type><error-tag>unknown-element</error-tag><error-info><bad-element>oldex</bad-element></error-info><error-severity>error</error-severity><error-message>Unassigned yang spec</error-message></rpc-error></rpc-reply>]]>]]>$'
|
expecteof "$clixon_netconf -qf $cfg" 0 '<rpc><edit-config><target><candidate/></target><config><oldex xmlns="urn:example:clixon">str</oldex></config></edit-config></rpc>]]>]]>' '^<rpc-reply><rpc-error><error-type>application</error-type><error-tag>unknown-element</error-tag><error-info><bad-element>oldex</bad-element></error-info><error-severity>error</error-severity><error-message>Failed to find YANG spec of XML node: oldex with parent: config in namespace: urn:example:clixon</error-message></rpc-error></rpc-reply>]]>]]>$'
|
||||||
|
|
||||||
new "Set other"
|
new "Set other"
|
||||||
expecteof "$clixon_netconf -qf $cfg" 0 '<rpc><edit-config><target><candidate/></target><config><other xmlns="urn:example:clixon2">str</other></config></edit-config></rpc>]]>]]>' '^<rpc-reply><ok/></rpc-reply>]]>]]>$'
|
expecteof "$clixon_netconf -qf $cfg" 0 '<rpc><edit-config><target><candidate/></target><config><other xmlns="urn:example:clixon2">str</other></config></edit-config></rpc>]]>]]>' '^<rpc-reply><ok/></rpc-reply>]]>]]>$'
|
||||||
|
|
@ -316,7 +316,7 @@ new "Set oldex"
|
||||||
expecteof "$clixon_netconf -qf $cfg" 0 '<rpc><edit-config><target><candidate/></target><config><oldex xmlns="urn:example:clixon">str</oldex></config></edit-config></rpc>]]>]]>' '^<rpc-reply><ok/></rpc-reply>]]>]]>$'
|
expecteof "$clixon_netconf -qf $cfg" 0 '<rpc><edit-config><target><candidate/></target><config><oldex xmlns="urn:example:clixon">str</oldex></config></edit-config></rpc>]]>]]>' '^<rpc-reply><ok/></rpc-reply>]]>]]>$'
|
||||||
|
|
||||||
new "Set newex should fail"
|
new "Set newex should fail"
|
||||||
expecteof "$clixon_netconf -qf $cfg" 0 '<rpc><edit-config><target><candidate/></target><config><newex xmlns="urn:example:clixon">str</newex></config></edit-config></rpc>]]>]]>' '^<rpc-reply><rpc-error><error-type>application</error-type><error-tag>unknown-element</error-tag><error-info><bad-element>newex</bad-element></error-info><error-severity>error</error-severity><error-message>Unassigned yang spec</error-message></rpc-error></rpc-reply>]]>]]>'
|
expecteof "$clixon_netconf -qf $cfg" 0 '<rpc><edit-config><target><candidate/></target><config><newex xmlns="urn:example:clixon">str</newex></config></edit-config></rpc>]]>]]>' '^<rpc-reply><rpc-error><error-type>application</error-type><error-tag>unknown-element</error-tag><error-info><bad-element>newex</bad-element></error-info><error-severity>error</error-severity><error-message>Failed to find YANG spec of XML node: newex with parent: config in namespace: urn:example:clixon</error-message></rpc-error></rpc-reply>]]>]]>'
|
||||||
|
|
||||||
new "Set other"
|
new "Set other"
|
||||||
expecteof "$clixon_netconf -qf $cfg" 0 '<rpc><edit-config><target><candidate/></target><config><other xmlns="urn:example:clixon2">str</other></config></edit-config></rpc>]]>]]>' '^<rpc-reply><ok/></rpc-reply>]]>]]>$'
|
expecteof "$clixon_netconf -qf $cfg" 0 '<rpc><edit-config><target><candidate/></target><config><other xmlns="urn:example:clixon2">str</other></config></edit-config></rpc>]]>]]>' '^<rpc-reply><ok/></rpc-reply>]]>]]>$'
|
||||||
|
|
@ -362,7 +362,7 @@ new "Set oldex"
|
||||||
expecteof "$clixon_netconf -qf $cfg" 0 '<rpc><edit-config><target><candidate/></target><config><oldex xmlns="urn:example:clixon">str</oldex></config></edit-config></rpc>]]>]]>' '^<rpc-reply><ok/></rpc-reply>]]>]]>$'
|
expecteof "$clixon_netconf -qf $cfg" 0 '<rpc><edit-config><target><candidate/></target><config><oldex xmlns="urn:example:clixon">str</oldex></config></edit-config></rpc>]]>]]>' '^<rpc-reply><ok/></rpc-reply>]]>]]>$'
|
||||||
|
|
||||||
new "Set newex should fail"
|
new "Set newex should fail"
|
||||||
expecteof "$clixon_netconf -qf $cfg" 0 '<rpc><edit-config><target><candidate/></target><config><newex xmlns="urn:example:clixon">str</newex></config></edit-config></rpc>]]>]]>' '^<rpc-reply><rpc-error><error-type>application</error-type><error-tag>unknown-element</error-tag><error-info><bad-element>newex</bad-element></error-info><error-severity>error</error-severity><error-message>Unassigned yang spec</error-message></rpc-error></rpc-reply>]]>]]>$'
|
expecteof "$clixon_netconf -qf $cfg" 0 '<rpc><edit-config><target><candidate/></target><config><newex xmlns="urn:example:clixon">str</newex></config></edit-config></rpc>]]>]]>' '^<rpc-reply><rpc-error><error-type>application</error-type><error-tag>unknown-element</error-tag><error-info><bad-element>newex</bad-element></error-info><error-severity>error</error-severity><error-message>Failed to find YANG spec of XML node: newex with parent: config in namespace: urn:example:clixon</error-message></rpc-error></rpc-reply>]]>]]>$'
|
||||||
|
|
||||||
new "Set other"
|
new "Set other"
|
||||||
expecteof "$clixon_netconf -qf $cfg" 0 '<rpc><edit-config><target><candidate/></target><config><other xmlns="urn:example:clixon2">str</other></config></edit-config></rpc>]]>]]>' '^<rpc-reply><ok/></rpc-reply>]]>]]>$'
|
expecteof "$clixon_netconf -qf $cfg" 0 '<rpc><edit-config><target><candidate/></target><config><other xmlns="urn:example:clixon2">str</other></config></edit-config></rpc>]]>]]>' '^<rpc-reply><ok/></rpc-reply>]]>]]>$'
|
||||||
|
|
@ -408,10 +408,10 @@ new "Set oldex"
|
||||||
expecteof "$clixon_netconf -qf $cfg" 0 '<rpc><edit-config><target><candidate/></target><config><oldex xmlns="urn:example:clixon">str</oldex></config></edit-config></rpc>]]>]]>' '^<rpc-reply><ok/></rpc-reply>]]>]]>$'
|
expecteof "$clixon_netconf -qf $cfg" 0 '<rpc><edit-config><target><candidate/></target><config><oldex xmlns="urn:example:clixon">str</oldex></config></edit-config></rpc>]]>]]>' '^<rpc-reply><ok/></rpc-reply>]]>]]>$'
|
||||||
|
|
||||||
new "Set newex should fail"
|
new "Set newex should fail"
|
||||||
expecteof "$clixon_netconf -qf $cfg" 0 '<rpc><edit-config><target><candidate/></target><config><newex xmlns="urn:example:clixon">str</newex></config></edit-config></rpc>]]>]]>' '^<rpc-reply><rpc-error><error-type>application</error-type><error-tag>unknown-element</error-tag><error-info><bad-element>newex</bad-element></error-info><error-severity>error</error-severity><error-message>Unassigned yang spec</error-message></rpc-error></rpc-reply>]]>]]>$'
|
expecteof "$clixon_netconf -qf $cfg" 0 '<rpc><edit-config><target><candidate/></target><config><newex xmlns="urn:example:clixon">str</newex></config></edit-config></rpc>]]>]]>' '^<rpc-reply><rpc-error><error-type>application</error-type><error-tag>unknown-element</error-tag><error-info><bad-element>newex</bad-element></error-info><error-severity>error</error-severity><error-message>Failed to find YANG spec of XML node: newex with parent: config in namespace: urn:example:clixon</error-message></rpc-error></rpc-reply>]]>]]>$'
|
||||||
|
|
||||||
new "Set other should fail"
|
new "Set other should fail"
|
||||||
expecteof "$clixon_netconf -qf $cfg" 0 '<rpc><edit-config><target><candidate/></target><config><other xmlns="urn:example:clixon2">str</other></config></edit-config></rpc>]]>]]>' '^<rpc-reply><rpc-error><error-type>application</error-type><error-tag>unknown-element</error-tag><error-info><bad-element>other</bad-element></error-info><error-severity>error</error-severity><error-message>Unassigned yang spec</error-message></rpc-error></rpc-reply>]]>]]>$'
|
expecteof "$clixon_netconf -qf $cfg" 0 '<rpc><edit-config><target><candidate/></target><config><other xmlns="urn:example:clixon2">str</other></config></edit-config></rpc>]]>]]>' '^<rpc-reply><rpc-error><error-type>application</error-type><error-tag>unknown-element</error-tag><error-info><bad-element>other</bad-element></error-info><error-severity>error</error-severity><error-message>Failed to find YANG spec of XML node: other with parent: config in namespace: urn:example:clixon2</error-message></rpc-error></rpc-reply>]]>]]>$'
|
||||||
|
|
||||||
if [ $BE -ne 0 ]; then
|
if [ $BE -ne 0 ]; then
|
||||||
new "Kill backend"
|
new "Kill backend"
|
||||||
|
|
|
||||||
|
|
@ -223,8 +223,18 @@ main(int argc,
|
||||||
/* Validate XML as well */
|
/* Validate XML as well */
|
||||||
if (yang_file_dir){
|
if (yang_file_dir){
|
||||||
/* Populate */
|
/* Populate */
|
||||||
if (xml_bind_yang(x, YB_MODULE, yspec, NULL) < 0)
|
if ((ret = xml_bind_yang(x, YB_MODULE, yspec, &xerr)) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
|
if (ret == 0){
|
||||||
|
if ((cb = cbuf_new()) ==NULL){
|
||||||
|
clicon_err(OE_XML, errno, "cbuf_new");
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
if (netconf_err2cb(xerr, cb) < 0)
|
||||||
|
goto done;
|
||||||
|
fprintf(stderr, "xml validation error: %s\n", cbuf_get(cb));
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
/* sort */
|
/* sort */
|
||||||
if (xml_sort_recurse(x) < 0)
|
if (xml_sort_recurse(x) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
|
|
|
||||||
|
|
@ -291,8 +291,18 @@ main(int argc,
|
||||||
/* Validate XML as well */
|
/* Validate XML as well */
|
||||||
if (yang_file_dir){
|
if (yang_file_dir){
|
||||||
/* Populate */
|
/* Populate */
|
||||||
if (xml_bind_yang(x0, YB_MODULE, yspec, NULL) < 0)
|
if ((ret = xml_bind_yang(x0, YB_MODULE, yspec, &xerr)) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
|
if (ret == 0){
|
||||||
|
if ((cb = cbuf_new()) ==NULL){
|
||||||
|
clicon_err(OE_XML, errno, "cbuf_new");
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
if (netconf_err2cb(xerr, cbret) < 0)
|
||||||
|
goto done;
|
||||||
|
fprintf(stderr, "xml validation error: %s\n", cbuf_get(cbret));
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
/* Sort */
|
/* Sort */
|
||||||
if (xml_sort_recurse(x0) < 0)
|
if (xml_sort_recurse(x0) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue