diff --git a/CHANGELOG.md b/CHANGELOG.md index 29fa8183..0ab8428e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -72,6 +72,8 @@ Developers may need to change their code ### Corrected Bugs +* Added message-id attributes in error and hello replies + * See [namespace prefix nc is not supported in full #154](https://github.com/clicon/clixon/issues/154) * Fixed [Clixon backend generates wrong XML on empty string value #144](https://github.com/clicon/clixon/issues/144) ## 4.8.0 diff --git a/apps/backend/backend_client.c b/apps/backend/backend_client.c index 14d2f1aa..f974d37a 100644 --- a/apps/backend/backend_client.c +++ b/apps/backend/backend_client.c @@ -1553,6 +1553,7 @@ from_client_hello(clicon_handle h, { int retval = -1; uint32_t id; + char *msgid; if (clicon_session_id_get(h, &id) < 0){ clicon_err(OE_NETCONF, ENOENT, "session_id not set"); @@ -1560,8 +1561,12 @@ from_client_hello(clicon_handle h, } id++; clicon_session_id_set(h, id); - cprintf(cbret, "%u", - NETCONF_BASE_NAMESPACE, id); + if ((msgid = xml_find_value(x, "message-id")) != NULL) + cprintf(cbret, "%u", + NETCONF_BASE_NAMESPACE, msgid, id); + else + cprintf(cbret, "%u", + NETCONF_BASE_NAMESPACE, id); retval = 0; done: return retval; diff --git a/apps/restconf/restconf_main_evhtp.c b/apps/restconf/restconf_main_evhtp.c index 2720c73f..d178955f 100644 --- a/apps/restconf/restconf_main_evhtp.c +++ b/apps/restconf/restconf_main_evhtp.c @@ -1108,7 +1108,10 @@ restconf_config(clicon_handle h, /* Add netconf yang spec, used as internal protocol */ if (netconf_module_load(h) < 0) goto done; - + /* Clixon restconf daemon config */ + if (yang_spec_parse_module(h, "clixon-restconf", NULL, yspec)< 0) + goto done; + /* Add system modules */ if (clicon_option_bool(h, "CLICON_STREAM_DISCOVERY_RFC8040") && yang_spec_parse_module(h, "ietf-restconf-monitoring", NULL, yspec)< 0) @@ -1148,7 +1151,7 @@ restconf_config(clicon_handle h, sleep(1); continue; } - // clicon_err(OE_UNIX, errno, "clicon_session_id_get"); + clicon_err(OE_UNIX, errno, "clicon_session_id_get"); goto done; } clicon_session_id_set(h, id); diff --git a/example/main/clixon-example@2020-03-11.yang b/example/main/clixon-example@2020-03-11.yang index 0e03ccc3..58435d0c 100644 --- a/example/main/clixon-example@2020-03-11.yang +++ b/example/main/clixon-example@2020-03-11.yang @@ -29,7 +29,6 @@ module clixon-example { import ietf-datastores { prefix ds; } - /* Example interface type for tests, local callbacks, etc */ identity eth { base if:interface-type; @@ -90,7 +89,6 @@ module clixon-example { ex:e4 arg1{ uses bar; } - /* Example notification as used in RFC 5277 and RFC 8040 */ notification event { description "Example notification event."; diff --git a/example/main/example_backend.c b/example/main/example_backend.c index 1044f3c0..b7a21ffd 100644 --- a/example/main/example_backend.c +++ b/example/main/example_backend.c @@ -297,14 +297,21 @@ example_rpc(clicon_handle h, /* Clicon handle */ { int retval = -1; cxobj *x = NULL; + cxobj *xp; char *namespace; + char *msgid; /* get namespace from rpc name, return back in each output parameter */ if ((namespace = xml_find_type_value(xe, NULL, "xmlns", CX_ATTR)) == NULL){ clicon_err(OE_XML, ENOENT, "No namespace given in rpc %s", xml_name(xe)); goto done; } - cprintf(cbret, "", NETCONF_BASE_NAMESPACE); + cprintf(cbret, "", msgid); + } + cprintf(cbret, ">"); if (!xml_child_nr_type(xe, CX_ELMNT)) cprintf(cbret, ""); else while ((x = xml_child_each(xe, x, CX_ELMNT)) != NULL) { diff --git a/example/main/example_cli.c b/example/main/example_cli.c index 9d98ac7d..89fdcd85 100644 --- a/example/main/example_cli.c +++ b/example/main/example_cli.c @@ -101,7 +101,7 @@ example_client_rpc(clicon_handle h, cva = cvec_find(cvv, "a"); /* get a cligen variable from vector */ /* Create XML for example netconf RPC */ if (clixon_xml_parse_va(YB_NONE, NULL, &xtop, NULL, - "" + "" "%s", NETCONF_BASE_NAMESPACE, clicon_username_get(h), diff --git a/lib/clixon/clixon_xml_io.h b/lib/clixon/clixon_xml_io.h index 63217d60..fcebaa4d 100644 --- a/lib/clixon/clixon_xml_io.h +++ b/lib/clixon/clixon_xml_io.h @@ -60,5 +60,6 @@ int clixon_xml_parse_va(yang_bind yb, yang_stmt *yspec, cxobj **xt, cxobj **xerr int clixon_xml_parse_va(yang_bind yb, yang_stmt *yspec, cxobj **xt, cxobj **xerr, const char *format, ...); #endif +int clixon_xml_attr_copy(cxobj *xin, cxobj *xout, char *name); #endif /* _CLIXON_XML_IO_H_ */ diff --git a/lib/src/clixon_netconf_lib.c b/lib/src/clixon_netconf_lib.c index c2093424..197ba0df 100644 --- a/lib/src/clixon_netconf_lib.c +++ b/lib/src/clixon_netconf_lib.c @@ -1379,9 +1379,6 @@ netconf_module_load(clicon_handle h) if (clicon_option_bool(h, "CLICON_XML_CHANGELOG")) if (yang_spec_parse_module(h, "clixon-xml-changelog", NULL, yspec)< 0) goto done; - /* Clixon restconf daemon */ - if (yang_spec_parse_module(h, "clixon-restconf", NULL, yspec)< 0) - goto done; retval = 0; done: return retval; @@ -1538,7 +1535,7 @@ netconf_hello_server(clicon_handle h, module_set_id = clicon_option_str(h, "CLICON_MODULE_SET_ID"); - cprintf(cb, "", NETCONF_BASE_NAMESPACE); + cprintf(cb, "", NETCONF_BASE_NAMESPACE, 42); cprintf(cb, ""); cprintf(cb, "urn:ietf:params:netconf:base:1.0"); /* Check if RFC7895 loaded and revision found */ diff --git a/lib/src/clixon_proto_client.c b/lib/src/clixon_proto_client.c index d6312136..8d7b4758 100644 --- a/lib/src/clixon_proto_client.c +++ b/lib/src/clixon_proto_client.c @@ -790,8 +790,8 @@ clicon_rpc_close_session(clicon_handle h) goto done; username = clicon_username_get(h); if ((msg = clicon_msg_encode(session_id, - "", - NETCONF_BASE_NAMESPACE, username?username:"")) == NULL) + "", + NETCONF_BASE_NAMESPACE, username?username:"", 42)) == NULL) goto done; if (clicon_rpc_msg(h, msg, &xret, NULL) < 0) goto done; @@ -1084,7 +1084,7 @@ clicon_hello_req(clicon_handle h, int ret; username = clicon_username_get(h); - if ((msg = clicon_msg_encode(0, "urn:ietf:params:netconf:base:1.0", + if ((msg = clicon_msg_encode(0, "urn:ietf:params:netconf:base:1.0", username?username:"", NETCONF_BASE_NAMESPACE)) == NULL) goto done; @@ -1111,5 +1111,3 @@ clicon_hello_req(clicon_handle h, xml_free(xret); return retval; } - - diff --git a/lib/src/clixon_validate.c b/lib/src/clixon_validate.c index 520eb426..fa9bec6f 100644 --- a/lib/src/clixon_validate.c +++ b/lib/src/clixon_validate.c @@ -72,6 +72,7 @@ #include "clixon_netconf_lib.h" #include "clixon_options.h" #include "clixon_xml_nsctx.h" +#include "clixon_xml_io.h" #include "clixon_xpath_ctx.h" #include "clixon_xpath.h" #include "clixon_yang_module.h" @@ -332,6 +333,7 @@ xml_yang_validate_rpc(clicon_handle h, cxobj *xn; /* rpc name */ char *rpcprefix; char *namespace = NULL; + int ret; if (strcmp(xml_name(xrpc), "rpc")){ clicon_err(OE_XML, EINVAL, "Expected RPC"); @@ -357,10 +359,14 @@ xml_yang_validate_rpc(clicon_handle h, goto done; goto fail; } - if ((retval = xml_yang_validate_all(h, xn, xret)) < 1) + if ((ret = xml_yang_validate_all(h, xn, xret)) < 0) goto done; /* error or validation fail */ - if ((retval = xml_yang_validate_add(h, xn, xret)) < 1) + if (ret == 0) + goto fail; + if ((ret = xml_yang_validate_add(h, xn, xret)) < 0) goto done; /* error or validation fail */ + if (ret == 0) + goto fail; if (xml_default_recurse(xn, 0) < 0) goto done; } @@ -369,6 +375,8 @@ xml_yang_validate_rpc(clicon_handle h, done: return retval; fail: + if (xret && *xret && clixon_xml_attr_copy(xrpc, *xret, "message-id") < 0) + goto done; retval = 0; goto done; } diff --git a/lib/src/clixon_xml_io.c b/lib/src/clixon_xml_io.c index 2d48f08f..2fef4436 100644 --- a/lib/src/clixon_xml_io.c +++ b/lib/src/clixon_xml_io.c @@ -526,8 +526,11 @@ _xml_parse(const char *str, case YB_RPC: if ((ret = xml_bind_yang_rpc(x, yspec, xerr)) < 0) goto done; - if (ret == 0) + if (ret == 0){ /* Add message-id */ + if (*xerr && clixon_xml_attr_copy(x, *xerr, "message-id") < 0) + goto done; failed++; + } break; } /* switch */ } @@ -769,3 +772,38 @@ clixon_xml_parse_va(yang_bind yb, return retval; } +/*! Copy an attribute value(eg message-id) from one xml (eg rpc input) to another xml (eg rpc outgoing) + * @param[in] xin Get attr value from this XML + * @param[in] xout Set attr value to this XML + * @param[in] name Attribute name + * @retval 0 OK + * @retval -1 Error + * Alternative is to use: char *val = xml_find_value(x, name); + * @code + * if (clixon_xml_attr_copy(xin, xout, "message-id") < 0) + * err; + * @endcode + */ +int +clixon_xml_attr_copy(cxobj *xin, + cxobj *xout, + char *name) +{ + int retval = -1; + char *msgid; + cxobj *xa; + + if (xin == NULL || xout == NULL){ + clicon_err(OE_XML, EINVAL, "xin or xout NULL"); + goto done; + } + if ((msgid = xml_find_value(xin, "message-id")) != NULL){ + if ((xa = xml_new("message-id", xout, CX_ATTR)) == NULL) + goto done; + if (xml_value_set(xa, msgid) < 0) + goto done; + } + retval = 0; + done: + return retval; +} diff --git a/test/lib.sh b/test/lib.sh index 0cdba570..d0484268 100755 --- a/test/lib.sh +++ b/test/lib.sh @@ -82,7 +82,9 @@ testname= : ${RCLOG:=} # Default netconf namespace statement, typically as placed on top-level /dev/null 2>&1 ; then @@ -295,7 +296,7 @@ wait_backend(){ reply=$(echo ']]>]]>' | clixon_netconf -qef $cfg 2> /dev/null) echo "reply:$reply" let i++; - echo "wait_backend $i" +# echo "wait_backend $i" if [ $i -ge $DEMLOOP ]; then err "backend timeout $DEMWAIT seconds" fi diff --git a/test/test_choice.sh b/test/test_choice.sh index a1a960da..ca438f3f 100755 --- a/test/test_choice.sh +++ b/test/test_choice.sh @@ -160,7 +160,7 @@ new "netconf commit protocol tcp" expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" new "netconf changing from TCP to UDP (RFC7950 7.9.6)" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" new "netconf get protocol udp" expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^" @@ -216,7 +216,7 @@ new "netconf set shorthand tcp" expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" new "netconf changing from TCP to UDP (RFC7950 7.9.6)" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" new "netconf get shorthand udp" expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" diff --git a/test/test_cli.sh b/test/test_cli.sh index 0ee51e2a..52d41609 100755 --- a/test/test_cli.sh +++ b/test/test_cli.sh @@ -123,7 +123,8 @@ new "cli debug reset" expectfn "$clixon_cli -1 -f $cfg -l o debug level 0" 0 "^$" new "cli rpc" -expectpart "$($clixon_cli -1 -f $cfg -l o rpc ipv4)" 0 "ipv442" +# We dont know which message-id the cli app uses +expectpart "$($clixon_cli -1 -f $cfg -l o rpc ipv4)" 0 "ipv442" if [ $BE -eq 0 ]; then exit # BE diff --git a/test/test_copy_config.sh b/test/test_copy_config.sh index 0b6954ba..ec2f144b 100755 --- a/test/test_copy_config.sh +++ b/test/test_copy_config.sh @@ -88,10 +88,10 @@ expecteof "$clixon_netconf -qf $cfg" 0 "startup and running->candidate new "Check candidate empty" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" new "Check startup empty" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" new "copy running->startup" expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" @@ -101,10 +101,10 @@ expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^eth/0/0ex:ethtrue]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^eth/0/0ex:ethtrue]]>]]>$" new "Check startup content" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^eth/0/0ex:ethtrue]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^eth/0/0ex:ethtrue]]>]]>$" new "Delete startup" expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" @@ -112,13 +112,13 @@ expecteof "$clixon_netconf -qf $cfg" 0 "< # Here startup is empty and candidate has content # test candidate->startup new "Check startup empty" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" new "copy candidate->startup" expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" new "Check startup content" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^eth/0/0ex:ethtrue]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^eth/0/0ex:ethtrue]]>]]>$" new "Delete candidate" expecteof "$clixon_netconf -qf $cfg" 0 "eth/0/0ex:ethnone ]]>]]>" "^]]>]]>$" @@ -126,13 +126,13 @@ expecteof "$clixon_netconf -qf $cfg" 0 "candidate new "Check candidate empty" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" new "copy startup->candidate" expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" new "Check candidate content" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^eth/0/0ex:ethtrue]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^eth/0/0ex:ethtrue]]>]]>$" # Negative test: check copying to running is not allowed new "Delete candidate" @@ -143,7 +143,7 @@ expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" " # Here running is empty new "Check running empty" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" # Add to candidate new "copy startup->candidate" @@ -156,7 +156,7 @@ fi # Here running is empty new "Check running empty" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" if [ $BE -eq 0 ]; then exit # BE diff --git a/test/test_netconf.sh b/test/test_netconf.sh index d1397296..b8c78ba0 100755 --- a/test/test_netconf.sh +++ b/test/test_netconf.sh @@ -59,10 +59,10 @@ expecteof "$clixon_netconf -qf $cfg" 0 "This is not XML]]>]]>" 'urn:ietf:params:netconf:base:1.0]]>]]>" 'rpcmalformed-messageerrorMore than one message in netconf rpc frame]]>]]>' +expecteof "$clixon_netconf -qf $cfg" 0 "urn:ietf:params:netconf:base:1.0]]>]]>" 'rpcmalformed-messageerrorMore than one message in netconf rpc frame]]>]]>' new "Frame with unknown message" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" '^protocolunknown-elementxxxerrorUnrecognized netconf operation]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^protocolunknown-elementxxxerrorUnrecognized netconf operation]]>]]>$" # Hello new "Netconf snd hello with xmldecl" @@ -78,22 +78,22 @@ new "netconf snd + rcv hello" expecteof "$clixon_netconf -f $cfg" 0 "urn:ietf:params:netconf:base:1.0]]>]]>" "^urn:ietf:params:netconf:base:1.0urn:ietf:params:netconf:capability:yang-library:1.0?revision=2019-01-04&module-set-id=42urn:ietf:params:netconf:capability:candidate:1.0urn:ietf:params:netconf:capability:validate:1.1urn:ietf:params:netconf:capability:startup:1.0urn:ietf:params:netconf:capability:xpath:1.0urn:ietf:params:netconf:capability:notification:1.0[0-9]*]]>]]>$" new "netconf rcv hello, disable RFC7895/ietf-yang-library" -expecteof "$clixon_netconf -f $cfg -o CLICON_MODULE_LIBRARY_RFC7895=0" 0 "]]>]]>" "^urn:ietf:params:netconf:base:1.0urn:ietf:params:netconf:capability:candidate:1.0urn:ietf:params:netconf:capability:validate:1.1urn:ietf:params:netconf:capability:startup:1.0urn:ietf:params:netconf:capability:xpath:1.0urn:ietf:params:netconf:capability:notification:1.0[0-9]*]]>]]>]]>]]>$" +expecteof "$clixon_netconf -f $cfg -o CLICON_MODULE_LIBRARY_RFC7895=0" 0 "]]>]]>" "^urn:ietf:params:netconf:base:1.0urn:ietf:params:netconf:capability:candidate:1.0urn:ietf:params:netconf:capability:validate:1.1urn:ietf:params:netconf:capability:startup:1.0urn:ietf:params:netconf:capability:xpath:1.0urn:ietf:params:netconf:capability:notification:1.0[0-9]*]]>]]>]]>]]>$" new "netconf get-config prefix" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" new "netconf get-config double quotes" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" new "netconf get-config single quotes" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" new "Add subtree eth/0/0 using none which should not change anything" expecteof "$clixon_netconf -qf $cfg" 0 "noneeth/0/0]]>]]>" "^]]>]]>$" new "Check nothing added" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" new "Add subtree eth/0/0 using none and create which should add eth/0/0" expecteof "$clixon_netconf -qf $cfg" 0 "eth/0/0ex:ethnone ]]>]]>" "^]]>]]>$" @@ -113,7 +113,7 @@ new "Delete eth/0/0 using none config" expecteof "$clixon_netconf -qf $cfg" 0 "eth/0/0ex:ethnone ]]>]]>" "^]]>]]>$" new "Check deleted eth/0/0 (non-presence container)" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" new "Re-Delete eth/0/0 using none should generate error" expecteof "$clixon_netconf -qf $cfg" 0 "eth/0/0ex:ethnone ]]>]]>" "^" diff --git a/test/test_restconf.sh b/test/test_restconf.sh index 09f4615a..067090a5 100755 --- a/test/test_restconf.sh +++ b/test/test_restconf.sh @@ -22,12 +22,16 @@ APPNAME=example cfg=$dir/conf.xml +# clixon-example and clixon-restconf is used, copy here +cp ../example/main/clixon-example@2020-03-11.yang $dir/ +cp ../yang/clixon/clixon-restconf@2020-10-30.yang $dir/ + cat < $cfg $cfg /usr/local/share/clixon $IETFRFC - clixon-example + $dir /usr/local/lib/$APPNAME/clispec /usr/local/lib/$APPNAME/backend example_backend.so$ @@ -136,19 +140,19 @@ testrun() expectpart "$(curl $CURLOPTS -X GET $proto://$addr/.well-known/host-meta)" 0 'HTTP/1.1 200 OK' "" "" "" new "restconf get restconf resource. RFC 8040 3.3 (json)" -expectpart "$(curl $CURLOPTS -X GET -H "Accept: application/yang-data+json" $proto://$addr/restconf)" 0 'HTTP/1.1 200 OK' '{"ietf-restconf:restconf":{"data":{},"operations":{},"yang-library-version":"2019-01-04"}}' + expectpart "$(curl $CURLOPTS -X GET -H "Accept: application/yang-data+json" $proto://$addr/restconf)" 0 'HTTP/1.1 200 OK' '{"ietf-restconf:restconf":{"data":{},"operations":{},"yang-library-version":"2019-01-04"}}' -new "restconf get restconf resource. RFC 8040 3.3 (xml)" -# Get XML instead of JSON? -expectpart "$(curl $CURLOPTS -X GET -H 'Accept: application/yang-data+xml' $proto://$addr/restconf)" 0 'HTTP/1.1 200 OK' '2019-01-04' + new "restconf get restconf resource. RFC 8040 3.3 (xml)" + # Get XML instead of JSON? + expectpart "$(curl $CURLOPTS -X GET -H 'Accept: application/yang-data+xml' $proto://$addr/restconf)" 0 'HTTP/1.1 200 OK' '2019-01-04' # Should be alphabetically ordered new "restconf get restconf/operations. RFC8040 3.3.2 (json)" - expectpart "$(curl $CURLOPTS -X GET $proto://$addr/restconf/operations)" 0 'HTTP/1.1 200 OK' '{"operations":{"clixon-example:client-rpc":\[null\],"clixon-example:empty":\[null\],"clixon-example:optional":\[null\],"clixon-example:example":\[null\],"clixon-lib:debug":\[null\],"clixon-lib:ping":\[null\],"clixon-lib:stats":\[null\],"clixon-lib:restart-plugin":\[null\],"ietf-netconf:get-config":\[null\],"ietf-netconf:edit-config":\[null\],"ietf-netconf:copy-config":\[null\],"ietf-netconf:delete-config":\[null\],"ietf-netconf:lock":\[null\],"ietf-netconf:unlock":\[null\],"ietf-netconf:get":\[null\],"ietf-netconf:close-session":\[null\],"ietf-netconf:kill-session":\[null\],"ietf-netconf:commit":\[null\],"ietf-netconf:discard-changes":\[null\],"ietf-netconf:validate":\[null\]' + expectpart "$(curl $CURLOPTS -X GET $proto://$addr/restconf/operations)" 0 'HTTP/1.1 200 OK' '{"operations":{"clixon-example:client-rpc":\[null\],"clixon-example:empty":\[null\],"clixon-example:optional":\[null\],"clixon-example:example":\[null\]' '"clixon-lib:debug":\[null\],"clixon-lib:ping":\[null\],"clixon-lib:stats":\[null\],"clixon-lib:restart-plugin":\[null\],"ietf-netconf:get-config":\[null\],"ietf-netconf:edit-config":\[null\],"ietf-netconf:copy-config":\[null\],"ietf-netconf:delete-config":\[null\],"ietf-netconf:lock":\[null\],"ietf-netconf:unlock":\[null\],"ietf-netconf:get":\[null\],"ietf-netconf:close-session":\[null\],"ietf-netconf:kill-session":\[null\],"ietf-netconf:commit":\[null\],"ietf-netconf:discard-changes":\[null\],"ietf-netconf:validate":\[null\]' new "restconf get restconf/operations. RFC8040 3.3.2 (xml)" ret=$(curl $CURLOPTS -X GET -H "Accept: application/yang-data+xml" $proto://$addr/restconf/operations) - expect='' + expect='' match=`echo $ret | grep --null -Eo "$expect"` if [ -z "$match" ]; then err "$expect" "$ret" diff --git a/test/test_rpc.sh b/test/test_rpc.sh index 07c11a36..3bbd3242 100755 --- a/test/test_rpc.sh +++ b/test/test_rpc.sh @@ -158,7 +158,7 @@ expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^applicationunknown-elementgeterrorUnrecognized RPC (wrong namespace?)]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^applicationunknown-elementgeterrorUnrecognized RPC (wrong namespace?)]]>]]>$" 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"}}}' diff --git a/test/test_sock.sh b/test/test_sock.sh index b04fcd1a..578bcd9b 100755 --- a/test/test_sock.sh +++ b/test/test_sock.sh @@ -55,10 +55,10 @@ EOF fi new "start backend -s init -f $cfg" start_backend -s init -f $cfg - fi - new "waiting" - wait_backend + new "wait backend" + wait_backend + fi new "$clixon_cli -1f $cfg show version" expectfn "$clixon_cli -1f $cfg show version" 0 "$version." diff --git a/test/test_yang_default.sh b/test/test_yang_default.sh index 534e04b0..fc08ad09 100755 --- a/test/test_yang_default.sh +++ b/test/test_yang_default.sh @@ -108,7 +108,7 @@ testrun(){ fi new "check running defaults" - expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^0foo42]]>]]>$" + expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^0foo42]]>]]>$" if [ $BE -ne 0 ]; then # Bring your own backend new "Kill backend"