From c038c9a27fd16f60bdc0f01ba1e36eb07e1d7937 Mon Sep 17 00:00:00 2001 From: Olof hagsand Date: Sun, 27 Mar 2022 17:39:24 +0200 Subject: [PATCH] * Implementation of "chunked framing" according to RFC6242 for Netconf 1.1. * First hello is 1.0 EOM framing, then successing rpc is chunked framing * See * [Netconf framing](https://github.com/clicon/clixon/issues/50), and * [Clixon does not switch to chunked framing after NETCONF 1.1 is negotiated](https://github.com/clicon/clixon/issues/314) * C: * Moved netconf framing code from netconf application to clixon lib * Test: * New expecteof_netconf and adjusted other expect scripts to handle NETCONF 1.1 framing --- CHANGELOG.md | 22 +- apps/netconf/Makefile.in | 4 - apps/netconf/clixon_netconf.h | 3 - apps/netconf/netconf_filter.c | 1 - apps/netconf/netconf_main.c | 220 +++++++++++------- apps/netconf/netconf_rpc.c | 13 +- apps/netconf/netconf_rpc.h | 3 +- lib/clixon/clixon_netconf_lib.h | 30 ++- lib/src/clixon_client.c | 3 + lib/src/clixon_event.c | 3 +- lib/src/clixon_json.c | 2 +- lib/src/clixon_netconf_lib.c | 287 ++++++++++++++++++++++-- lib/src/clixon_proto.c | 8 +- lib/src/clixon_proto_client.c | 29 ++- test/lib.sh | 247 ++++++++++++++++---- test/test_augment.sh | 24 +- test/test_augment_state.sh | 10 +- test/test_augment_trans.sh | 7 +- test/test_autocli_strict_expand.sh | 8 +- test/test_c++.sh | 2 +- test/test_choice.sh | 72 +++--- test/test_cli_leafref.sh | 2 +- test/test_cli_multikey.sh | 4 +- test/test_client.sh | 4 + test/test_copy_config.sh | 46 ++-- test/test_datastore_repair.sh | 2 +- test/test_debug.sh | 6 +- test/test_feature.sh | 13 +- test/test_helloworld.sh | 15 +- test/test_identity.sh | 52 ++--- test/test_leaf_default.sh | 28 +-- test/test_leafref.sh | 32 +-- test/test_leafref_augment.sh | 18 +- test/test_leafref_state.sh | 50 ++--- test/test_leafref_union.sh | 39 ++-- test/test_minmax.sh | 78 +++---- test/test_nacm.sh | 4 +- test/test_nacm_credentials.sh | 8 +- test/test_nacm_datanode.sh | 7 +- test/test_nacm_datanode_read.sh | 7 +- test/test_nacm_datanode_write.sh | 7 +- test/test_nacm_module_read.sh | 17 +- test/test_nacm_module_write.sh | 4 +- test/test_nacm_protocol.sh | 16 +- test/test_nacm_recovery.sh | 11 +- test/test_netconf.sh | 170 +++++++------- test/test_netconf_filter.sh | 36 +-- test/test_netconf_framing.sh | 25 ++- test/test_netconf_hello.sh | 43 ++-- test/test_netconf_notifications.sh | 16 +- test/test_netconf_ssh_callhome.sh | 14 +- test/test_netconf_whitespace.sh | 44 ++-- test/test_openconfig_interfaces.sh | 2 +- test/test_order.sh | 152 ++++++------- test/test_pagination_draft.sh | 12 +- test/test_pagination_state.sh | 8 +- test/test_pattern.sh | 8 +- test/test_perf_cli.sh | 8 +- test/test_perf_mem.sh | 3 +- test/test_perf_netconf.sh | 87 ++++--- test/test_perf_restconf.sh | 10 +- test/test_perf_restconf_ssl.sh | 12 +- test/test_perf_state.sh | 30 ++- test/test_perf_state_only.sh | 13 +- test/test_restconf.sh | 4 +- test/test_restconf_internal.sh | 30 ++- test/test_restconf_internal_usecases.sh | 39 ++-- test/test_restconf_netns.sh | 4 +- test/test_restconf_notifications.sh | 2 +- test/test_rpc.sh | 40 ++-- test/test_startup.sh | 6 +- test/test_submodule.sh | 12 +- test/test_transaction.sh | 56 ++--- test/test_transaction_restart.sh | 8 +- test/test_type.sh | 136 +++++------ test/test_type_range.sh | 16 +- test/test_unique.sh | 50 ++--- test/test_unique_descendant.sh | 60 ++--- test/test_upgrade_auto.sh | 2 +- test/test_upgrade_failsafe.sh | 4 +- test/test_upgrade_interfaces.sh | 2 +- test/test_upgrade_interfaces_rfc7895.sh | 2 +- test/test_upgrade_repair.sh | 14 +- test/test_upgrade_simple.sh | 6 +- test/test_when_must.sh | 24 +- test/test_with_default.sh | 4 +- test/test_xpath_functions.sh | 42 ++-- test/test_yang.sh | 72 +++--- test/test_yang_anydata.sh | 20 +- test/test_yang_default.sh | 20 +- test/test_yang_deviation.sh | 26 +-- test/test_yang_extension.sh | 6 +- test/test_yang_load.sh | 48 ++-- test/test_yang_namespace.sh | 10 +- test/test_yang_when.sh | 40 ++-- 95 files changed, 1758 insertions(+), 1208 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 68c191e4..5595587f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -37,13 +37,25 @@ ## 5.7.0 Expected: May 2022 +### New features + +* Implementation of "chunked framing" according to RFC6242 for Netconf 1.1. + * First hello is 1.0 EOM framing, then successing rpc is chunked framing + * See + * [Netconf framing](https://github.com/clicon/clixon/issues/50), and + * [Clixon does not switch to chunked framing after NETCONF 1.1 is negotiated](https://github.com/clicon/clixon/issues/314) + +### + ### API changes on existing protocol/config features Users may have to change how they access the system -* Netconf: Disabled default announcing of Netconf 1.1, instead only announce 1.0 - * See [Clixon does not switch to chunked framing after NETCONF 1.1 is negotiated](https://github.com/clicon/clixon/issues/314) - * To enable Netconf 1.1, set `NETCONF_1_1_ANNOUNCE` +* Netconf: Usage of chunked framing" + * To keep existing end-of-message encoding, set `CLICON_NETCONF_BASE_CAPABILITY` to `0` +* New `clixon-config@2022-03-21.yang` revision + * Added option: + * `CLICON_NETCONF_BASE_CAPABILITY` * Netconf data-not-unique info changed to return schema nodes instead of XML for RFC7950 compliance * CLI reconnects to backend if backend restarts with a warning * Note that edits to the candidate database or locks will be lost @@ -53,8 +65,8 @@ Users may have to change how they access the system ### Minor features * YANG unique: added single descendant node ids as special case - * This means that two variants are supported: - * unique "a b c", ie multiple direct chidlren +c * This means that two variants are supported: + * unique "a b c", ie multiple direct children * unique "a/b/c", ie single descendants * RFC 7950 Sec 7.8.3 is somewhat unclear * The combination is not supported diff --git a/apps/netconf/Makefile.in b/apps/netconf/Makefile.in index ea400817..5ad26ef5 100644 --- a/apps/netconf/Makefile.in +++ b/apps/netconf/Makefile.in @@ -87,10 +87,6 @@ APPSRC += netconf_rpc.c APPSRC += netconf_filter.c APPOBJ = $(APPSRC:.c=.o) -# Accessible from plugin -LIBSRC = netconf_lib.c - - LIBOBJ = $(LIBSRC:.c=.o) # Name of lib diff --git a/apps/netconf/clixon_netconf.h b/apps/netconf/clixon_netconf.h index 1c522d1a..576d5408 100644 --- a/apps/netconf/clixon_netconf.h +++ b/apps/netconf/clixon_netconf.h @@ -45,9 +45,6 @@ * Prototypes * (Duplicated. Also in netconf_*.h) */ -int netconf_output(int s, cbuf *xf, char *msg); -int netconf_output_encap(int s, cbuf *xf, char *msg); - int netconf_xpath(cxobj *xsearch, cxobj *xfilter, cbuf *xf, cbuf *xf_err, diff --git a/apps/netconf/netconf_filter.c b/apps/netconf/netconf_filter.c index 45c029a2..57f43345 100644 --- a/apps/netconf/netconf_filter.c +++ b/apps/netconf/netconf_filter.c @@ -63,7 +63,6 @@ #include #include "netconf_rpc.h" -#include "netconf_lib.h" #include "netconf_filter.h" /* xf specifices a filter, and xn is an xml tree. diff --git a/apps/netconf/netconf_main.c b/apps/netconf/netconf_main.c index 951133da..bde8cda4 100644 --- a/apps/netconf/netconf_main.c +++ b/apps/netconf/netconf_main.c @@ -66,8 +66,7 @@ /* clicon */ #include -#include "clixon_netconf.h" -#include "netconf_lib.h" +//#include "clixon_netconf.h" #include "netconf_rpc.h" /* Command line options to be passed to getopt(3) */ @@ -122,10 +121,12 @@ netconf_add_request_attr(cxobj *xrpc, /*! Process netconf hello message * A server receiving a message with a element MUST * terminate the NETCONF session. + * @param[out] eof Request termination */ static int netconf_hello_msg(clicon_handle h, - cxobj *xn) + cxobj *xn, + int *eof) { int retval = -1; cvec *nsc = NULL; // namespace context @@ -133,19 +134,18 @@ netconf_hello_msg(clicon_handle h, size_t veclen; cxobj *x; cxobj *xcap; - int foundbase; + int foundbase_10 = 0; + int foundbase_11 = 0; char *body; _netconf_hello_nr++; if (xml_find_type(xn, NULL, "session-id", CX_ELMNT) != NULL) { clicon_err(OE_XML, errno, "Server received hello with session-id from client, terminating (see RFC 6241 Sec 8.1"); - cc_closed++; goto done; } if (xpath_vec(xn, nsc, "capabilities/capability", &vec, &veclen) < 0) goto done; /* Each peer MUST send at least the base NETCONF capability, "urn:ietf:params:netconf:base:1.1"*/ - foundbase=0; if ((xcap = xml_find_type(xn, NULL, "capabilities", CX_ELMNT)) != NULL) { x = NULL; while ((x = xml_child_each(xcap, x, CX_ELMNT)) != NULL) { @@ -156,15 +156,17 @@ netconf_hello_msg(clicon_handle h, /* When comparing protocol version capability URIs, only the base part is used, in the * event any parameters are encoded at the end of the URI string. */ if (strncmp(body, NETCONF_BASE_CAPABILITY_1_0, strlen(NETCONF_BASE_CAPABILITY_1_0)) == 0) /* RFC 4741 */ - foundbase++; - else if (strncmp(body, NETCONF_BASE_CAPABILITY_1_1, strlen(NETCONF_BASE_CAPABILITY_1_1)) == 0) /* RFC 6241 */ - foundbase++; + foundbase_10++; + else if (strncmp(body, NETCONF_BASE_CAPABILITY_1_1, strlen(NETCONF_BASE_CAPABILITY_1_1)) == 0 && + clicon_option_int(h, "CLICON_NETCONF_BASE_CAPABILITY") > 0){ /* RFC 6241 */ + foundbase_11++; + clicon_option_int_set(h, "netconf-framing", NETCONF_SSH_CHUNKED); /* enable chunked enc */ + } } } - if (foundbase == 0){ - clicon_err(OE_XML, errno, "Server received hello without netconf base capability %s, terminating (see RFC 6241 Sec 8.1", - NETCONF_BASE_CAPABILITY_1_1); - cc_closed++; + if (foundbase_10 == 0 && foundbase_11 == 0){ + clicon_err(OE_XML, errno, "Server received hello without matching netconf base capability, terminating (see RFC 6241 Sec 8.1"); + *eof = 1; goto done; } retval = 0; @@ -175,23 +177,27 @@ netconf_hello_msg(clicon_handle h, } /*! Process incoming Netconf RPC netconf message - * @param[in] h Clicon handle + * @param[in] h Clixon handle * @param[in] xreq XML tree containing netconf RPC message * @param[in] yspec YANG spec + * @param[out] eof Set to 1 if pending close socket * @retval 0 OK * @retval -1 Error */ -int +static int netconf_rpc_message(clicon_handle h, cxobj *xrpc, - yang_stmt *yspec) + yang_stmt *yspec, + int *eof) { int retval = -1; cxobj *xret = NULL; /* Return (out) */ int ret; cbuf *cbret = NULL; cxobj *xc; + netconf_framing_type framing; + framing = clicon_option_int(h, "netconf-framing"); if (_netconf_hello_nr == 0 && clicon_option_bool(h, "CLICON_NETCONF_HELLO_OPTIONAL") == 0){ if (netconf_operation_failed_xml(&xret, "rpc", "Client must send an hello element before any RPC")< 0) @@ -204,8 +210,11 @@ netconf_rpc_message(clicon_handle h, goto done; } clicon_xml2cbuf(cbret, xret, 0, 0, -1); - netconf_output_encap(1, cbret, "rpc-error"); - cc_closed++; + if (netconf_output_encap(framing, cbret) < 0) + goto done; + if (netconf_output(1, cbret, "rpc-error") < 0) + goto done; + *eof = 1; goto ok; } if ((ret = xml_bind_yang_rpc(xrpc, yspec, &xret)) < 0) @@ -221,11 +230,13 @@ netconf_rpc_message(clicon_handle h, goto done; } clicon_xml2cbuf(cbret, xret, 0, 0, -1); - if (netconf_output_encap(1, cbret, "rpc-error") < 0) + if (netconf_output_encap(framing, cbret) < 0) + goto done; + if (netconf_output(1, cbret, "rpc-error") < 0) goto done; goto ok; } - if (netconf_rpc_dispatch(h, xrpc, &xret) < 0){ + if (netconf_rpc_dispatch(h, xrpc, &xret, eof) < 0){ goto done; } /* Is there a return message in xret? */ @@ -239,7 +250,9 @@ netconf_rpc_message(clicon_handle h, goto done; } clicon_xml2cbuf(cbret, xret, 0, 0, -1); - if (netconf_output_encap(1, cbret, "rpc-error") < 0) + if (netconf_output_encap(framing, cbret) < 0) + goto done; + if (netconf_output(1, cbret, "rpc-error") < 0) goto done; goto ok; } @@ -252,7 +265,9 @@ netconf_rpc_message(clicon_handle h, goto done; } clicon_xml2cbuf(cbret, xml_child_i(xret,0), 0, 0, -1); - if (netconf_output_encap(1, cbret, "rpc-reply") < 0) + if (netconf_output_encap(framing, cbret) < 0) + goto done; + if (netconf_output(1, cbret, "rpc-reply") < 0) goto done; } ok: @@ -267,16 +282,18 @@ netconf_rpc_message(clicon_handle h, /*! Process incoming a single netconf message parsed as XML * Identify what netconf message it is - * @param[in] h Clicon handle + * @param[in] h Clixon handle * @param[in] xreq XML tree containing netconf * @param[in] yspec YANG spec + * @param[out] eof Set to 1 if pending close socket * @retval 0 OK * @retval -1 Error */ static int netconf_input_packet(clicon_handle h, cxobj *xreq, - yang_stmt *yspec) + yang_stmt *yspec, + int *eof) { int retval = -1; cbuf *cbret = NULL; @@ -284,10 +301,12 @@ netconf_input_packet(clicon_handle h, char *rpcprefix; char *namespace = NULL; cxobj *xret = NULL; - + netconf_framing_type framing; + clicon_debug(1, "%s", __FUNCTION__); rpcname = xml_name(xreq); rpcprefix = xml_prefix(xreq); + framing = clicon_option_int(h, "netconf-framing"); if (xml2ns(xreq, rpcprefix, &namespace) < 0) goto done; if (strcmp(rpcname, "rpc") == 0){ @@ -302,25 +321,28 @@ netconf_input_packet(clicon_handle h, goto done; } clicon_xml2cbuf(cbret, xret, 0, 0, -1); - netconf_output_encap(1, cbret, "rpc-error"); + if (netconf_output_encap(framing, cbret) < 0) + goto done; + if (netconf_output(1, cbret, "rpc-error") < 0) + goto done; goto ok; } - if (netconf_rpc_message(h, xreq, yspec) < 0) + if (netconf_rpc_message(h, xreq, yspec, eof) < 0) goto done; } else if (strcmp(rpcname, "hello") == 0){ /* Only accept resolved NETCONF base namespace -> terminate*/ if (namespace == NULL || strcmp(namespace, NETCONF_BASE_NAMESPACE) != 0){ - cc_closed++; + *eof = 1; clicon_err(OE_XML, EFAULT, "No appropriate namespace associated with namespace:%s", namespace); goto done; } - if (netconf_hello_msg(h, xreq) < 0) + if (netconf_hello_msg(h, xreq, eof) < 0) goto done; } else{ /* Shouldnt happen should be caught by yang bind check in netconf_input_frame */ - cc_closed++; + *eof = 1; clicon_err(OE_NETCONF, 0, "Unrecognized netconf operation %s", rpcname); goto done; } @@ -334,8 +356,9 @@ netconf_input_packet(clicon_handle h, /*! Process incoming frame, ie a char message framed by ]]>]]> * Parse string to xml, check only one netconf message within a frame - * @param[in] h Clicon handle + * @param[in] h Clixon handle * @param[in] cb Packet buffer + * @param[out] eof Set to 1 if pending close socket * @retval 0 OK * @retval -1 Fatal error * @note there are errors detected here prior to whether you know what kind if message it is, and @@ -352,7 +375,8 @@ netconf_input_packet(clicon_handle h, */ static int netconf_input_frame(clicon_handle h, - cbuf *cb) + cbuf *cb, + int *eof) { int retval = -1; char *str = NULL; @@ -362,9 +386,11 @@ netconf_input_frame(clicon_handle h, cbuf *cbret = NULL; yang_stmt *yspec; int ret; - + netconf_framing_type framing; + clicon_debug(1, "%s", __FUNCTION__); clicon_debug(2, "%s: \"%s\"", __FUNCTION__, cbuf_get(cb)); + framing = clicon_option_int(h, "netconf-framing"); yspec = clicon_dbspec_yang(h); if ((str = strdup(cbuf_get(cb))) == NULL){ clicon_err(OE_UNIX, errno, "strdup"); @@ -378,7 +404,10 @@ netconf_input_frame(clicon_handle h, } if (netconf_operation_failed(cbret, "rpc", "Empty XML")< 0) goto done; - netconf_output_encap(1, cbret, "rpc-error"); + if (netconf_output_encap(framing, cbret) < 0) + goto done; + if (netconf_output(1, cbret, "rpc-error") < 0) + goto done; goto ok; } /* Parse incoming XML message */ @@ -389,7 +418,10 @@ netconf_input_frame(clicon_handle h, } if (netconf_operation_failed(cbret, "rpc", clicon_err_reason)< 0) goto done; - netconf_output_encap(1, cbret, "rpc-error"); + if (netconf_output_encap(framing, cbret) < 0) + goto done; + if (netconf_output(1, cbret, "rpc-error") < 0) + goto done; goto ok; } if (ret == 0){ @@ -402,7 +434,10 @@ netconf_input_frame(clicon_handle h, goto done; } clicon_xml2cbuf(cbret, xret, 0, 0, -1); - netconf_output_encap(1, cbret, "rpc-error"); + if (netconf_output_encap(framing, cbret) < 0) + goto done; + if (netconf_output(1, cbret, "rpc-error") < 0) + goto done; goto ok; } /* Check for empty frame (no mesaages), return empty message, not clear from RFC what to do */ @@ -411,7 +446,10 @@ netconf_input_frame(clicon_handle h, clicon_err(OE_UNIX, errno, "cbuf_new"); goto done; } - netconf_output_encap(1, cbret, "rpc-error"); + if (netconf_output_encap(framing, cbret) < 0) + goto done; + if (netconf_output(1, cbret, "rpc-error") < 0) + goto done; goto ok; } /* Check for multi-messages in frame */ @@ -422,14 +460,17 @@ netconf_input_frame(clicon_handle h, } if (netconf_malformed_message(cbret, "More than one message in netconf rpc frame")< 0) goto done; - netconf_output_encap(1, cbret, "rpc-error"); + if (netconf_output_encap(framing, cbret) < 0) + goto done; + if (netconf_output(1, cbret, "rpc-error") < 0) + goto done; goto ok; } if ((xreq = xml_child_i_type(xtop, 0, CX_ELMNT)) == NULL){ /* Shouldnt happen */ clicon_err(OE_XML, EFAULT, "No xml req (shouldnt happen)"); goto done; } - if (netconf_input_packet(h, xreq, yspec) < 0) + if (netconf_input_packet(h, xreq, yspec, eof) < 0) goto done; ok: retval = 0; @@ -447,7 +488,7 @@ netconf_input_frame(clicon_handle h, /*! Get netconf message: detect end-of-msg * @param[in] s Socket where input arrived. read from this. - * @param[in] arg Clicon handle. + * @param[in] arg Clixon handle. * This routine continuously reads until no more data on s. There could * be risk of starvation, but the netconf client does little else than * read data so I do not see a danger of true starvation here. @@ -460,17 +501,20 @@ static int netconf_input_cb(int s, void *arg) { - int retval = -1; - clicon_handle h = arg; - unsigned char buf[BUFSIZ]; /* from stdio.h, typically 8K */ - int i; - int len; - cbuf *cb=NULL; - int xml_state = 0; - int poll; - clicon_hash_t *cdat = clicon_data(h); /* Save cbuf between calls if not done */ - size_t cdatlen = 0; + int retval = -1; + unsigned char buf[BUFSIZ]; /* from stdio.h, typically 8K */ + clicon_handle h = arg; + cbuf *cb=NULL; void *ptr; + size_t cdatlen = 0; + clicon_hash_t *cdat = clicon_data(h); /* Save cbuf between calls if not done */ + int poll; + int frame_state = 0; + int i; + int len; + size_t frame_size; + int ret; + int eof = 0; /* Set to 1 if pending close socket */ if ((ptr = clicon_hash_value(cdat, NETCONF_HASH_BUF, &cdatlen)) != NULL){ if (cdatlen != sizeof(cb)){ @@ -498,28 +542,51 @@ netconf_input_cb(int s, } } /* read */ if (len == 0){ /* EOF */ - cc_closed++; + clicon_debug(1, "%s len==0, closing", __FUNCTION__); + clixon_event_unreg_fd(s, netconf_input_cb); close(s); - retval = 0; - goto done; + clixon_exit_set(1); + goto ok; } for (i=0; i]]>", - buf[i], - &xml_state)) { - /* OK, we have an xml string from a client */ - /* Remove trailer */ - *(((char*)cbuf_get(cb)) + cbuf_len(cb) - strlen("]]>]]>")) = '\0'; - if (netconf_input_frame(h, cb) < 0 && - !ignore_packet_errors) // default is to ignore errors - goto done; - if (cc_closed){ + if (clicon_option_int(h, "netconf-framing") == NETCONF_SSH_CHUNKED){ + /* Track chunked framing defined in RFC6242 */ + if ((ret = netconf_input_chunked_framing(buf[i], &frame_state, &frame_size)) < 0) + goto done; + switch (ret){ + case 1: /* chunk-data */ + cprintf(cb, "%c", buf[i]); + break; + case 2: /* end-of-data */ + /* Somewhat complex error-handling: + * Ignore packet errors, UNLESS an explicit termination request (eof) + */ + if (netconf_input_frame(h, cb, &eof) < 0 && + !ignore_packet_errors) + goto done; + if (eof) + goto done; + cbuf_reset(cb); + break; + default: break; } - cbuf_reset(cb); + } + else{ + cprintf(cb, "%c", buf[i]); + if (detect_endtag("]]>]]>", buf[i], &frame_state)){ + /* OK, we have an xml string from a client */ + /* Remove trailer */ + *(((char*)cbuf_get(cb)) + cbuf_len(cb) - strlen("]]>]]>")) = '\0'; + if (netconf_input_frame(h, cb, &eof) < 0 && + !ignore_packet_errors) // default is to ignore errors + goto done; + if (eof) + goto done; + cbuf_reset(cb); + } } } /* poll==1 if more, poll==0 if none */ @@ -535,17 +602,16 @@ netconf_input_cb(int s, break; } } /* while */ + ok: retval = 0; - done: + done: if (cb) cbuf_free(cb); - if (cc_closed) - retval = -1; return retval; } /*! Send netconf hello message - * @param[in] h Clicon handle + * @param[in] h Clixon handle * @param[in] s File descriptor to write on (eg 1 - stdout) */ static int @@ -555,13 +621,17 @@ send_hello(clicon_handle h, { int retval = -1; cbuf *cb; - + netconf_framing_type framing; + if ((cb = cbuf_new()) == NULL){ clicon_log(LOG_ERR, "%s: cbuf_new", __FUNCTION__); goto done; } if (netconf_hello_server(h, cb, id) < 0) goto done; + framing = clicon_option_int(h, "netconf-framing"); + if (netconf_output_encap(framing, cb) < 0) + goto done; if (netconf_output(s, cb, "hello") < 0) goto done; retval = 0; @@ -584,7 +654,6 @@ netconf_terminate(clicon_handle h) /* Delete all plugins, and RPC callbacks */ clixon_plugin_module_exit(h); - clicon_rpc_close_session(h); if ((yspec = clicon_dbspec_yang(h)) != NULL) ys_free(yspec); @@ -628,7 +697,7 @@ timeout_fn(int s, } /*! Usage help routine - * @param[in] h Clicon handle + * @param[in] h Clixon handle * @param[in] argv0 command line */ static void @@ -642,8 +711,8 @@ usage(clicon_handle h, "\t-f \tConfiguration file (mandatory)\n" "\t-E \tExtra configuration file directory\n" "\t-l (e|o|s|f) Log on std(e)rr, std(o)ut, (s)yslog(default), (f)ile\n" - "\t-q\t\tQuiet mode, do not send hello message\n" - "\t-H \t\tDo not expect hello message from server.\n" + "\t-q\t\tServer does not send hello message on startup\n" + "\t-H \t\tServer does not expect hello message from client.\n" "\t-a UNIX|IPv4|IPv6 Internal backend socket family\n" "\t-u \tInternal socket domain path or IP addr (see -a)\n" "\t-d \tSpecify netconf plugin directory dir (default: %s)\n" @@ -687,7 +756,7 @@ main(int argc, /* In the startup, logs to stderr & debug flag set later */ clicon_log_init(__PROGRAM__, LOG_INFO, logdst); - /* Set username to clicon handle. Use in all communication to backend */ + /* Set username to clixon handle. Use in all communication to backend */ if ((pw = getpwuid(getuid())) == NULL){ clicon_err(OE_UNIX, errno, "getpwuid"); goto done; @@ -922,6 +991,7 @@ main(int argc, done: if (ignore_packet_errors) retval = 0; + clixon_exit_set(1); /* This is to disable resend mechanism in close-session */ netconf_terminate(h); clicon_log_init(__PROGRAM__, LOG_INFO, 0); /* Log on syslog no stderr */ clicon_log(LOG_NOTICE, "%s: %u Terminated", __PROGRAM__, getpid()); diff --git a/apps/netconf/netconf_rpc.c b/apps/netconf/netconf_rpc.c index 5d6c92c4..33fe9065 100644 --- a/apps/netconf/netconf_rpc.c +++ b/apps/netconf/netconf_rpc.c @@ -70,8 +70,6 @@ /* clicon */ #include -#include "clixon_netconf.h" -#include "netconf_lib.h" #include "netconf_filter.h" #include "netconf_rpc.h" @@ -486,15 +484,18 @@ netconf_notification_cb(int s, if (clicon_xml2cbuf(cb, xn, 0, 0, -1) < 0) goto done; /* Send it to listening client on stdout */ - if (netconf_output_encap(1, cb, "notification") < 0){ + if (netconf_output_encap(clicon_option_int(h, "netconf-framing"), cb) < 0){ cbuf_free(cb); goto done; } + if (netconf_output(1, cb, "notification") < 0) + goto done; fflush(stdout); cbuf_free(cb); ok: retval = 0; done: + clicon_debug(1, "%s %d", __FUNCTION__, retval); if (nsc) xml_nsctx_free(nsc); if (xt != NULL) @@ -680,13 +681,15 @@ netconf_application_rpc(clicon_handle h, * @param[in] h clicon handle * @param[in] xn Sub-tree (under xorig) at ... level. * @param[out] xret Return XML, error or OK + * @param[out] eof Set to 1 if pending close socket * @retval 0 OK, can also be netconf error * @retval -1 Error, fatal */ int netconf_rpc_dispatch(clicon_handle h, cxobj *xn, - cxobj **xret) + cxobj **xret, + int *eof) { int retval = -1; cxobj *xe; @@ -735,7 +738,7 @@ netconf_rpc_dispatch(clicon_handle h, goto done; } else if (strcmp(xml_name(xe), "close-session") == 0){ - cc_closed++; + *eof = 1; /* Pending close */ if (clicon_rpc_netconf_xml(h, xml_parent(xe), xret, NULL) < 0) goto done; } diff --git a/apps/netconf/netconf_rpc.h b/apps/netconf/netconf_rpc.h index 057760dd..e4f3a416 100644 --- a/apps/netconf/netconf_rpc.h +++ b/apps/netconf/netconf_rpc.h @@ -45,6 +45,7 @@ int netconf_rpc_dispatch(clicon_handle h, cxobj *xn, - cxobj **xret); + cxobj **xret, + int *eof); #endif /* _NETCONF_RPC_H_ */ diff --git a/lib/clixon/clixon_netconf_lib.h b/lib/clixon/clixon_netconf_lib.h index 04961dc2..fed507cf 100644 --- a/lib/clixon/clixon_netconf_lib.h +++ b/lib/clixon/clixon_netconf_lib.h @@ -83,6 +83,30 @@ enum netconf_content{ }; typedef enum netconf_content netconf_content; +enum target_type{ /* netconf */ + RUNNING, + CANDIDATE +}; + +enum test_option{ /* edit-config */ + SET, + TEST_THEN_SET, + TEST_ONLY +}; + +enum error_option{ /* edit-config */ + STOP_ON_ERROR, + CONTINUE_ON_ERROR +}; + +/* NETCONF framing + */ +enum framing_type{ + NETCONF_SSH_EOM, /* RFC 4742, RFC 6242 hello msg (end-of-msg: ]]>]]>)*/ + NETCONF_SSH_CHUNKED, /* RFC 6242 Chunked framing */ +}; +typedef enum framing_type netconf_framing_type; + /* * Macros */ @@ -142,6 +166,10 @@ int clixon_netconf_error_fn(const char *fn, const int line, cxobj *xerr, const c int clixon_netconf_internal_error(cxobj *xerr, char *msg, char *arg); int netconf_parse_uint32(char *name, char *valstr, char *defaultstr, uint32_t defaultval, cbuf *cbret, uint32_t *value); int netconf_parse_uint32_xml(char *name, char *valstr, char *defaultstr, uint32_t defaultval, cxobj **xerr, uint32_t *value); - +int netconf_framing_preamble(netconf_framing_type framing, cbuf *cb); +int netconf_framing_postamble(netconf_framing_type framing, cbuf *cb); +int netconf_output(int s, cbuf *xf, char *msg); +int netconf_output_encap(netconf_framing_type framing, cbuf *cb); +int netconf_input_chunked_framing(char ch, int *state, size_t *size); #endif /* _CLIXON_NETCONF_LIB_H */ diff --git a/lib/src/clixon_client.c b/lib/src/clixon_client.c index ee2612ae..a5588a85 100644 --- a/lib/src/clixon_client.c +++ b/lib/src/clixon_client.c @@ -226,6 +226,7 @@ clixon_client_hello(int sock) cprintf(msg, "", NETCONF_BASE_NAMESPACE); cprintf(msg, "%s", NETCONF_BASE_CAPABILITY_1_1); cprintf(msg, ""); + cprintf(msg, "]]>]]>"); if (clicon_msg_send1(sock, msg) < 0) goto done; retval = 0; @@ -444,6 +445,8 @@ clixon_client_get_xdata(int sock, cprintf(msg, "/>"); } cprintf(msg, ""); + if (netconf_output_encap(NETCONF_SSH_CHUNKED, msg) < 0) + goto done; if (clicon_rpc1(sock, msg, msgret, &eof) < 0) goto done; if (eof){ diff --git a/lib/src/clixon_event.c b/lib/src/clixon_event.c index 75543d8b..6af59560 100644 --- a/lib/src/clixon_event.c +++ b/lib/src/clixon_event.c @@ -426,7 +426,6 @@ clixon_event_loop(clicon_handle h) if ((*e->e_fn)(e->e_fd, e->e_arg) < 0){ clicon_debug(1, "%s Error in: %s", __FUNCTION__, e->e_string); goto err; - } if (_ee_unreg){ _ee_unreg = 0; @@ -440,6 +439,8 @@ clixon_event_loop(clicon_handle h) clicon_debug(1, "%s err", __FUNCTION__); break; } + if (clixon_exit_get() == 1) + retval = 0; clicon_debug(1, "%s done:%d", __FUNCTION__, retval); return retval; } diff --git a/lib/src/clixon_json.c b/lib/src/clixon_json.c index e6ac5cbf..592f6e7c 100644 --- a/lib/src/clixon_json.c +++ b/lib/src/clixon_json.c @@ -1462,7 +1462,7 @@ _json_parse(char *str, /*! Parse string containing JSON and return an XML tree * * @param[in] str String containing JSON - * @param[in] rfc7951 Do sanity checks according to RFC 7951 JSON Encoding of Data Modeled with YANG + * @param[in] rfc7951 Do sanity checks according to RFC 7951 JSON Encoding of Data Modeled with YANG * @param[in] yb How to bind yang to XML top-level when parsing * @param[in] yspec Yang specification, mandatory to make module->xmlns translation * @param[in,out] xt Top object, if not exists, on success it is created with name 'top' diff --git a/lib/src/clixon_netconf_lib.c b/lib/src/clixon_netconf_lib.c index c65d594d..decd8e93 100644 --- a/lib/src/clixon_netconf_lib.c +++ b/lib/src/clixon_netconf_lib.c @@ -1515,7 +1515,6 @@ netconf_module_load(clicon_handle h) /* Load restconf yang. Note this is also a part of clixon-config */ if (yang_spec_parse_module(h, "clixon-restconf", NULL, yspec)< 0) goto done; -#if 1 /* XXX: Both the following settings are because clicon-handle is not part of all API * functions * Treat unknown XML as anydata */ @@ -1524,13 +1523,21 @@ netconf_module_load(clicon_handle h) /* Make message-id attribute optional */ if (clicon_option_bool(h, "CLICON_NETCONF_MESSAGE_ID_OPTIONAL") == 1) xml_bind_netconf_message_id_optional(1); -#endif /* Load ietf list pagination */ if (yang_spec_parse_module(h, "ietf-list-pagination", NULL, yspec)< 0) goto done; /* Load ietf list pagination netconf */ if (yang_spec_parse_module(h, "ietf-list-pagination-nc", NULL, yspec)< 0) goto done; + /* Framing: If hello protocol skipped, set framing direct, ie fix chunked framing if NETCONF-1.1 + * But start with default: RFC 4741 EOM ]]>]]> + * For now this only applies to external protocol + */ + clicon_option_int_set(h, "netconf-framing", NETCONF_SSH_EOM); + if (clicon_option_bool(h, "CLICON_NETCONF_HELLO_OPTIONAL")){ + if (clicon_option_int(h, "CLICON_NETCONF_BASE_CAPABILITY") > 0) /* RFC 6241 */ + clicon_option_int_set(h, "netconf-framing", NETCONF_SSH_CHUNKED); + } retval = 0; done: return retval; @@ -1694,7 +1701,8 @@ netconf_hello_server(clicon_handle h, /* Each peer MUST send at least the base NETCONF capability, "urn:ietf:params:netconf:base:1.1" * RFC 6241 Sec 8.1 */ - cprintf(cb, "%s", NETCONF_BASE_CAPABILITY_1_1); + if (clicon_option_int(h, "CLICON_NETCONF_BASE_CAPABILITY") > 0) /* RFC 6241 */ + cprintf(cb, "%s", NETCONF_BASE_CAPABILITY_1_1); } /* A peer MAY include capabilities for previous NETCONF versions, to indicate that it supports multiple protocol versions. */ @@ -1716,7 +1724,6 @@ netconf_hello_server(clicon_handle h, if (session_id) cprintf(cb, "%lu", (long unsigned int)session_id); cprintf(cb, ""); - cprintf(cb, "]]>]]>"); retval = 0; done: if (encstr) @@ -1724,22 +1731,6 @@ netconf_hello_server(clicon_handle h, return retval; } -int -netconf_hello_req(clicon_handle h, - cbuf *cb) -{ - int retval = -1; - - cprintf(cb, "", NETCONF_BASE_NAMESPACE); - cprintf(cb, ""); - cprintf(cb, "%s", NETCONF_BASE_CAPABILITY_1_1); - cprintf(cb, ""); - cprintf(cb, ""); - cprintf(cb, "]]>]]>"); - retval = 0; - return retval; -} - /*! Generate textual error log from Netconf error message * * Get a text error message from netconf error message and generate error on the form: @@ -1931,3 +1922,259 @@ netconf_parse_uint32_xml(char *name, retval = 0; goto done; } + +/*! Add netconf xml postamble of message. I.e, xml after the body of the message. + * + * @param[in] framing Netconf framing + * @param[in,out] cb Netconf packet (cligen buffer) + * XXX: copies body + */ +int +netconf_framing_preamble(netconf_framing_type framing, + cbuf *cb) +{ + int retval = -1; + char *body = NULL; + + switch (framing){ + case NETCONF_SSH_EOM: + break; + case NETCONF_SSH_CHUNKED: + if ((body = strdup(cbuf_get(cb))) == NULL){ + clicon_err(OE_UNIX, errno, "strdup"); + goto done; + } + cbuf_reset(cb); + cprintf(cb, "\n#%zu\n", strlen(body)); /* Add RFC6242 chunked-end */ + cbuf_append_str(cb, body); + break; + } + retval = 0; + done: + if (body) + free(body); + return retval; +} + +/*! Add netconf xml postamble of message. I.e, xml after the body of the message. + * + * @param[in] framing Netconf framing + * @param[in,out] cb Netconf packet (cligen buffer) + */ +int +netconf_framing_postamble(netconf_framing_type framing, + cbuf *cb) +{ + switch (framing){ + case NETCONF_SSH_EOM: + cprintf(cb, "]]>]]>"); /* Add RFC4742 end-of-message marker */ + break; + case NETCONF_SSH_CHUNKED: + cprintf(cb, "\n##\n"); /* Add RFC6242 chunked-end */ + break; + } + return 0; +} + +/*! Send netconf message from cbuf on socket + * @param[in] s + * @param[in] cb Cligen buffer that contains the XML message + * @param[in] msg Only for debug + * @retval 0 OK + * @retval -1 Error + * @see netconf_output_encap for function with encapsulation + */ +int +netconf_output(int s, + cbuf *cb, + char *msg) +{ + int retval = -1; + char *buf = cbuf_get(cb); + int len = cbuf_len(cb); + + clicon_debug(1, "SEND %s", msg); + if (clicon_debug_get() > 1){ /* XXX: below only works to stderr, clicon_debug may log to syslog */ + cxobj *xt = NULL; + if (clixon_xml_parse_string(buf, YB_NONE, NULL, &xt, NULL) == 0){ + clicon_xml2file(stderr, xml_child_i(xt, 0), 0, 0); + fprintf(stderr, "\n"); + xml_free(xt); + } + } + if (write(s, buf, len) < 0){ + if (errno == EPIPE) + ; + else + clicon_log(LOG_ERR, "%s: write: %s", __FUNCTION__, strerror(errno)); + goto done; + } + retval = 0; + done: + return retval; +} + +/*! Encapsulate and send outgoing netconf packet as cbuf on socket + * + * @param[in] h Clixon handle + * @param[in] cb Cligen buffer that contains the XML message + * @retval 0 OK + * @retval -1 Error + * @note Assumes "cb" contains valid XML + * @see netconf_output without encapsulation + * @see netconf_hello_msg where framing is set + */ +int +netconf_output_encap(netconf_framing_type framing, + cbuf *cb) +{ + int retval = -1; + + if (netconf_framing_preamble(framing, cb) < 0) + goto done; + if (netconf_framing_postamble(framing, cb) < 0) + goto done; + retval = 0; + done: + return retval; +} + +/*! Track chunked framing defined in RFC6242 + * + * The function works by calling sequentially each received char and using + * two state variables: state and size + * The function traverses the states 0-7, where state 4 also uses countdown of size + * The function returns one of four results: framing/control; chunk-data; end-of-frame; or error + * Anything not conforming is returned as error. + * Possibly one should accept whitespaces between frames? + * RFC6242 Sec 4.2 + * = + end-of-chunks + * = LF HASH LF + * Example: \n#4\n + * data + * = LF HASH HASH LF + * Example: \n##\n + * = [1-9][0-9]* + * + * State: 0 No frame (begin/ended) + * 1 \n received + * 2 # received + * 3 read [1-9] + * 4 read chunk-size read: chunk-data + * @param[in] ch New input character + * @param[in,out] state State machine state + * @param[in,out] size Remaining expecting chunk bytes. + * @retval -1 Error + * @retval 0 Framing char, not data + * @retval 1 Chunk-data + * @retval 2 End-of-frame + * Example: + C: \n#4\n + C: \n + C: \n + C: + C: \n##\n + */ +int +netconf_input_chunked_framing(char ch, + int *state, + size_t *size) +{ + int retval = 0; + + clicon_debug(1, "%s ch:%c(%d) state:%d size:%lu", __FUNCTION__, ch, ch, *state, *size); + switch (*state){ + case 0: + if (ch == '\n'){ + (*state)++; + break; + } + clicon_err(OE_NETCONF, 0, "NETCONF framing error chunk-start: expected \\n but received %c (state:%d)", ch, *state); + goto err; + break; + case 1: + case 5: + if (ch == '#'){ + (*state)++; + break; + } + clicon_err(OE_NETCONF, 0, "NETCONF framing error: expected # but received %c (state:%d)", ch, *state); + goto err; + break; + case 2: + if (ch == '#'){ + (*state) = 0; + retval = 2; /* end of frame (empty data) */ + break; + } + else if (ch >= '1' && ch <= '9'){ /* first num */ + (*state)++; + *size = ch-'0'; + break; + } + clicon_err(OE_NETCONF, 0, "NETCONF framing error chunk-start: expected 1-9 or # but received %c (state:%d)", ch, *state); + goto err; + break; + case 3: + if (ch >= '0' && ch <= '9'){ /* other nums */ + *size = (*size)*10 + ch-'0'; + break; + } + else if (ch == '\n'){ + (*state)++; + break; + } + clicon_err(OE_NETCONF, 0, "NETCONF framing error chunk-size: expected 0-9 or \\n but received %c (state:%d)", ch, *state); + goto err; + break; + case 4: + if (*size > 0){ /* chunk-data */ + (*size)--; + retval = 1; /* chunk-data */ + break; + } + else if (*size == 0 && ch == '\n'){ + (*state)++; + break; + } + clicon_err(OE_NETCONF, 0, "NETCONF framing error chunk-end: expected \\n but received %c (state:%d)", ch, *state); + goto err; + break; + case 6: + if (ch == '#'){ + (*state)++; + break; + } + else if (ch >= '1' && ch <= '9'){ /* first num */ + *state=3; + *size = ch-'0'; + break; + } + clicon_err(OE_NETCONF, 0, "NETCONF framing error: expected # but received %c (state:%d)", ch, *state); + goto err; + break; + case 7: + if (ch == '\n'){ + (*state) = 0; + retval = 2; /* end of frame */ + break; + } + clicon_err(OE_NETCONF, 0, "NETCONF framing error chunk-end: expected \\n but received %c (state:%d)", ch, *state); + goto err; + break; + default: + clicon_err(OE_NETCONF, 0, "NETCONF framing error %c , invalid state:%d", ch, *state); + goto err; + break; + } + done: + return retval; + err: + *state = 0; + retval = -1; /* Error */ + goto done; +} diff --git a/lib/src/clixon_proto.c b/lib/src/clixon_proto.c index 9adfccd1..099e3acb 100644 --- a/lib/src/clixon_proto.c +++ b/lib/src/clixon_proto.c @@ -75,6 +75,7 @@ #include "clixon_sig.h" #include "clixon_xml.h" #include "clixon_xml_io.h" +#include "clixon_netconf_lib.h" #include "clixon_options.h" #include "clixon_proto.h" @@ -427,7 +428,7 @@ clicon_msg_rcv(int s, /*! Receive a message using plain NETCONF * * @param[in] s socket (unix or inet) to communicate with backend - * @param[out] cb1 cligen buf struct containing the incoming message + * @param[out] cb cligen buf struct containing the incoming message * @param[out] eof Set if eof encountered * @see netconf_input_cb() * @see clicon_msg_rcv using IPC message struct @@ -499,7 +500,6 @@ clicon_msg_send1(int s, { int retval = -1; - cprintf(cb, "]]>]]>"); if (atomicio((ssize_t (*)(int, void *, size_t))write, s, cbuf_get(cb), cbuf_len(cb)+1) < 0){ clicon_err(OE_CFG, errno, "atomicio"); @@ -667,6 +667,10 @@ clicon_rpc1(int sock, int retval = -1; clicon_debug(1, "%s", __FUNCTION__); + if (netconf_framing_preamble(NETCONF_SSH_CHUNKED, msg) < 0) + goto done; + if (netconf_framing_postamble(NETCONF_SSH_CHUNKED, msg) < 0) + goto done; if (clicon_msg_send1(sock, msg) < 0) goto done; if (clicon_msg_rcv1(sock, msgret, eof) < 0) diff --git a/lib/src/clixon_proto_client.c b/lib/src/clixon_proto_client.c index 00dd01ea..5a37d44f 100644 --- a/lib/src/clixon_proto_client.c +++ b/lib/src/clixon_proto_client.c @@ -73,6 +73,7 @@ #include "clixon_xpath.h" #include "clixon_proto.h" #include "clixon_err.h" +#include "clixon_event.h" #include "clixon_stream.h" #include "clixon_err_string.h" #include "clixon_xml_nsctx.h" @@ -187,7 +188,7 @@ clicon_rpc_msg(clicon_handle h, #endif clicon_debug(1, "%s request:%s", __FUNCTION__, msg->op_body); /* Create a socket and connect to it, either UNIX, IPv4 or IPv6 per config options */ - if (clicon_rpc_msg_once(h, msg, &retdata, &eof, NULL) < 0) + if (clicon_rpc_msg_once(h, msg, &retdata, &eof, &s) < 0) goto done; if (eof){ /* 2. check socket shutdown AFTER rpc */ @@ -195,17 +196,20 @@ clicon_rpc_msg(clicon_handle h, s = -1; clicon_client_socket_set(h, -1); #ifdef PROTO_RESTART_RECONNECT - if (clicon_rpc_msg_once(h, msg, &retdata, &eof, NULL) < 0) - goto done; - if (eof){ - close(s); - s = -1; - clicon_client_socket_set(h, -1); - clicon_err(OE_PROTO, ESHUTDOWN, "Unexpected close of CLICON_SOCK. Clixon backend daemon may have crashed."); - goto done; + if (!clixon_exit_get()) { /* May be part of termination */ + if (clicon_rpc_msg_once(h, msg, &retdata, &eof, NULL) < 0) + goto done; + if (eof){ + close(s); + s = -1; + clicon_client_socket_set(h, -1); + + clicon_err(OE_PROTO, ESHUTDOWN, "Unexpected close of CLICON_SOCK. Clixon backend daemon may have crashed."); + goto done; + } + /* To disable this restart, unset PROTO_RESTART_RECONNECT */ + clicon_log(LOG_WARNING, "The backend was probably restarted and the client has reconnected to the backend. Any locks or candidate edits are lost."); } - /* To disable this restart, unset PROTO_RESTART_RECONNECT */ - clicon_log(LOG_WARNING, "The backend was probably restarted and the client has reconnected to the backend. Any locks or candidate edits are lost."); #else clicon_err(OE_PROTO, ESHUTDOWN, "Unexpected close of CLICON_SOCK. Clixon backend daemon may have crashed."); goto done; @@ -269,6 +273,9 @@ clicon_rpc_msg_persistent(clicon_handle h, close(s); s = -1; clicon_client_socket_set(h, -1); + /* Note here one could try a restart as done in clicon_rpc_msg, but seems not + * right since if backend is restarted, the notification stream is gone. + */ clicon_err(OE_PROTO, ESHUTDOWN, "Unexpected close of CLICON_SOCK. Clixon backend daemon may have crashed."); goto done; } diff --git a/test/lib.sh b/test/lib.sh index 5cc8359a..65227afe 100755 --- a/test/lib.sh +++ b/test/lib.sh @@ -8,6 +8,7 @@ # The functions are somewhat wildgrown, a little too many: # - expectpart # - expecteof +# - expecteof_netconf # - expecteofx # - expecteofeq # - expecteof_file @@ -91,7 +92,7 @@ DEFAULTONLY="xmlns=\"$BASENS\"" DEFAULTNS="$DEFAULTONLY message-id=\"42\"" # Minimal hello message as a prelude to netconf rpcs -DEFAULTHELLO="urn:ietf:params:netconf:base:1.1]]>]]>" +DEFAULTHELLO="urn:ietf:params:netconf:base:1.0urn:ietf:params:netconf:base:1.1]]>]]>" # Options passed to curl calls # -s : silent @@ -354,6 +355,35 @@ function checkvalgrind(){ fi } +# Check if two RFC6242 NETCONF frames are equal +# Since they use \n you cannot just use = +function chunked_equal() +{ + echo "1:$1" + echo "2:$2" + if [ "$1" == "$2" ]; then + return 0 + else + return 255 + fi +} + +# Given a string, add RFC6242 chunked franing around it +# Args: +# 0: string +function chunked_framing() +{ + str=$1 + length=${#str} + echo -n " +#${length} +" + echo -n "$str" + echo -n " +## +" +} + # Start backend with all varargs. # If valgrindtest == 2, start valgrind function start_backend(){ @@ -383,9 +413,12 @@ function stop_backend(){ # Wait for restconf to stop sending 502 Bad Gateway function wait_backend(){ - reply=$(echo "]]>]]>" | $clixon_netconf -qef $cfg 2> /dev/null) + freq=$(chunked_framing "") + reply=$(echo "$freq" | $clixon_netconf -qHef $cfg) +# freply=$(chunked_framing "") +# chunked_equal "$reply" "$freply" let i=0; - while [[ $reply != "]]>]]>" | clixon_netconf -qef $cfg 2> /dev/null) @@ -554,23 +587,25 @@ function expectpart(){ positive=true; let i=0; for exp in "$@"; do - if [ "$exp" == "--not--" ]; then - positive=false; - elif [ $i -gt 1 ]; then + if [ $i -gt 1 ]; then + if [ "$exp" == "--not--" ]; then + positive=false; + else # echo "echo \"$ret\" | grep --null -o \"$exp"\" - match=$(echo "$ret" | grep --null -i -o "$exp") #-i ignore case XXX -EZo: -E cant handle {} - r=$? - if $positive; then - if [ $r != 0 ]; then - err "$exp" "$ret" - fi - else - if [ $r == 0 ]; then - err "not $exp" "$ret" - fi - fi - fi - let i++; + match=$(echo "$ret" | grep --null -i -o "$exp") #-i ignore case XXX -EZo: -E cant handle {} + r=$? + if $positive; then + if [ $r != 0 ]; then + err "$exp" "$ret" + fi + else + if [ $r == 0 ]; then + err "not $exp" "$ret" + fi + fi + fi + fi + let i++; done # if [[ "$ret" != "$expect" ]]; then # err "$expect" "$ret" @@ -595,14 +630,14 @@ function expecteof(){ expecterr=$5 # Do while read stuff ret=$($cmd 2> $errfile < /tmp/flag + echo timeout > $dir/expectwaitresult ret="" - sleep $wait | cat <(echo $input) -| $cmd | while [ 1 ] ; do + sleep $wait | cat <(echo "$input1$inputenc") -| $cmd | while [ 1 ] ; do read -t 20 r -# echo "r:$r" +# echo "r:<$r>" + if [ -z "$r" ]; then + sleep 1 + continue + fi # Append $r to $ret ret="$ret$r" - match=$(echo "$ret" | grep -Eo "$expect"); - if [ -z "$match" ]; then - echo error > /tmp/flag - err "$expect" "$ret" - else - echo ok > /tmp/flag # only this is OK - break; +# echo "ret:$ret" + let i=0; + positive=true; + let ok=0 + let fail=0 + for exp in "$@"; do + if [ $i -gt 4 ]; then +# echo "i:$i" +# echo "exp:$exp" + if [ "$exp" == "--not--" ]; then + positive=false; + else + match=$(echo "$ret" | grep --null -i -o "$exp") +# match=$(echo "$ret" | grep -Eo "$exp"); + r=$? + if $positive; then + if [ $r != 0 ]; then +# echo "fail: $exp" + let fail++ + break + fi + else + if [ $r == 0 ]; then +# echo "fail: $exp" + let fail++ + break + fi + fi + fi + fi + let i++; + done # for exp +# echo "fail:$fail" + if [ $fail -eq 0 ]; then +# echo ok + echo ok > $dir/expectwaitresult + # break + exit 0 fi done -# cat /tmp/flag - if [ $(cat /tmp/flag) != "ok" ]; then -# err "ok" $(cat /tmp/flag) -# cat /tmp/flag +# cat $dir/expectwaitresult + if [ $(cat $dir/expectwaitresult) != "ok" ]; then + err "ok" "$(cat $dir/expectwaitresult)" + cat $dir/expectwaitresult exit -1 fi } @@ -845,8 +1000,8 @@ function cacerts() echo "cacerts function: Expected: cakey cacert" exit 1 fi - cakey=$1 - cacert=$2 + local cakey=$1 + local cacert=$2 tmpdir=$dir/tmpcertdir diff --git a/test/test_augment.sh b/test/test_augment.sh index ed808cd6..fa3b17aa 100755 --- a/test/test_augment.sh +++ b/test/test_augment.sh @@ -229,39 +229,39 @@ wait_restconf # mandatory-leaf See RFC7950 Sec 7.17 new "netconf set interface with augmented type and mandatory leaf" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" " e1 mymod:some-new-iftype true - ]]>]]>" "^]]>]]>$" + " "" "" new "netconf verify get with refined ports" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^e1mymod:some-new-iftypetrue808080" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "e1mymod:some-new-iftypetrue808080" "" new "netconf set identity defined in other" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" " e2 mymod:some-new-iftype true if:fddi - ]]>]]>" "^]]>]]>$" + " "" "" new "netconf validate ok" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "netconf set identity defined in main" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" " e3 mymod:some-new-iftype true mymod:you - ]]>]]>" "^]]>]]>$" + " "" "" new "netconf commit ok" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" # restconf and augment new "restconf get augment json" @@ -309,13 +309,13 @@ expectpart "$(curl $CURLOPTS -X DELETE $RCPROTO://localhost/restconf/data/ietf-i # augmented lists XML="22nisse44kalle" new "netconf PUT augmented list" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOmerge$XML]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "merge$XML" "" "" new "netconf commit" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "netconf get config" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "$XML]]>]]>" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "$XML" JSON='{"ietf-interfaces:interfaces":{"example-augment:ports":[{"id":22,"str":"foo"},{"id":44,"str":"bar"}]}}' diff --git a/test/test_augment_state.sh b/test/test_augment_state.sh index 00f1c73b..fa8c4fd5 100755 --- a/test/test_augment_state.sh +++ b/test/test_augment_state.sh @@ -123,13 +123,13 @@ function testrun() new "get config" if [ -z "$config" ]; then - expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" + expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "^$" else - expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^$config]]>]]>$" + expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "^$config$" fi new "get state" - expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^$state]]>]]>$" + expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "^$state$" } new "test params: -f $cfg" @@ -214,10 +214,10 @@ EOF ) new "Add config" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO$CONFIG]]>]]>" "^]]>]]>" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "$CONFIG" "" "" new "netconf commit" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" testrun "$CONFIG" "$EXPSTATE" diff --git a/test/test_augment_trans.sh b/test/test_augment_trans.sh index 75699a87..a0aa53d2 100755 --- a/test/test_augment_trans.sh +++ b/test/test_augment_trans.sh @@ -112,16 +112,15 @@ fi new "waiting" wait_backend - new "get-config empty" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "^$" if false; then new "Add config" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO<>]]>]]>" "^]]>]]>" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "<>" "^" new "netconf commit" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "^$" fi diff --git a/test/test_autocli_strict_expand.sh b/test/test_autocli_strict_expand.sh index e239d489..c7ff5e06 100755 --- a/test/test_autocli_strict_expand.sh +++ b/test/test_autocli_strict_expand.sh @@ -110,10 +110,10 @@ wait_backend # The list new "Add three list options" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOmergeopta42optb43optc44
]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "mergeopta42optb43optc44
" "" "" new "netconf commit" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "${DEFAULTHELLO}" "" "" "" new "show config" expectpart "$($clixon_cli -1 -f $cfg show conf)" 0 "opta42optb43optc44
" @@ -126,10 +126,10 @@ expectpart "$(echo "set table parameter " | $clixon_cli -f $cfg 2>&1)" 0 opta o # Leafs new "Add leafs" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOmergeopta424344
]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "mergeopta424344
" "" "" new "netconf commit" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "show config leafs" expectpart "$($clixon_cli -1 -f $cfg show conf)" 0 "opta424344optb43optc44
" diff --git a/test/test_c++.sh b/test/test_c++.sh index 713ecdf4..59698821 100755 --- a/test/test_c++.sh +++ b/test/test_c++.sh @@ -190,7 +190,7 @@ new "wait backend" wait_backend new "Netconf runtime test" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO0]]>]]>" "^042]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "0" "" "042" if [ $BE -ne 0 ]; then new "Kill backend" diff --git a/test/test_choice.sh b/test/test_choice.sh index 78c62dc1..a0b0008b 100755 --- a/test/test_choice.sh +++ b/test/test_choice.sh @@ -135,40 +135,40 @@ fi # First vanilla (protocol) case new "netconf validate empty" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "netconf set protocol both udp and tcp" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "netconf validate both udp and tcp fail" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^applicationbad-elementudperrorElement in choice statement already exists]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "applicationbad-elementudperrorElement in choice statement already exists" new "netconf discard-changes" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "netconf set empty protocol" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "netconf validate protocol" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "netconf set protocol tcp" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "netconf get protocol tcp" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "netconf commit protocol tcp" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "netconf changing from TCP to UDP (RFC7950 7.9.6)" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "$" "" new "netconf get protocol udp" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "netconf commit protocol udp" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" #-- restconf new "restconf DELETE whole datastore" @@ -206,81 +206,81 @@ expectpart "$($clixon_cli -1 -f $cfg -l o commit)" 0 "^$" # Second shorthand (no case) new "netconf set protocol both udp and tcp" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "netconf validate both udp and tcp fail" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^applicationbad-elementudperrorElement in choice statement already exists]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "applicationbad-elementudperrorElement in choice statement already exists" new "netconf discard-changes" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "netconf set shorthand tcp" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "netconf changing from TCP to UDP (RFC7950 7.9.6)" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "netconf get shorthand udp" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "netconf validate shorthand" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "netconf discard-changes" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" # Third check mandatory new "netconf set empty mandatory" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "netconf get mandatory empty" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "netconf validate mandatory" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^applicationdata-missingmissing-choicenameerror]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "applicationdata-missingmissing-choicenameerror" new "netconf set mandatory udp" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "netconf get mandatory udp" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "netconf validate mandatory" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "netconf discard-changes" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" # Choice with multiple items new "netconf choice multiple items first" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" " 0 1 2 -]]>]]>" "^]]>]]>$" +" "" "" new "netconf validate multiple ok" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "netconf choice multiple items second" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" " 0 1 -]]>]]>" "^]]>]]>$" +" "" "" new "netconf validate multiple ok" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "netconf choice multiple items mix" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" " 0 2 2 -]]>]]>" "^]]>]]>$" +" "" "" new "netconf validate multiple error" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^applicationbad-elementmcerrorElement in choice statement already exists]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "applicationbad-elementmcerrorElement in choice statement already exists" if [ $RC -ne 0 ]; then new "Kill restconf daemon" diff --git a/test/test_cli_leafref.sh b/test/test_cli_leafref.sh index 85f36448..a54e811b 100755 --- a/test/test_cli_leafref.sh +++ b/test/test_cli_leafref.sh @@ -207,7 +207,7 @@ expectpart "$($clixon_cli -1 -l o -f $cfg set leafrefs leafref str)" 255 "'str' # Make a netconf request to set wrong type to fail in validate new "netconf set leafref str wrong type" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOstrmerge]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "strmerge" "" "" new "cli validate" expectpart "$($clixon_cli -1 -f $cfg -l o validate)" 255 "'str' is not a number name" diff --git a/test/test_cli_multikey.sh b/test/test_cli_multikey.sh index a7f9e277..5078a1c3 100755 --- a/test/test_cli_multikey.sh +++ b/test/test_cli_multikey.sh @@ -104,7 +104,7 @@ new "set 1 v2 again" expectpart "$($clixon_cli -1 -f $cfg set ex x a 1 b v2)" 0 "" new "show conf" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^1v11v21v32v12v22v3]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "1v11v21v32v12v22v3" # ordered-by user new "set 1 v1" @@ -123,7 +123,7 @@ new "set 2 v2" expectpart "$($clixon_cli -1 -f $cfg set ex y a 2 b v2)" 0 "" new "show conf" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^1v11v21v32v12v22v31v12v11v21v32v2]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "1v11v21v32v12v22v31v12v11v21v32v2" if [ $BE -ne 0 ]; then new "Kill backend" diff --git a/test/test_client.sh b/test/test_client.sh index 54f5380a..eb7efb32 100755 --- a/test/test_client.sh +++ b/test/test_client.sh @@ -2,6 +2,9 @@ # Advanced Client api test # Compile and run a client # INSTALLFLSAGS="" +# Why test only over external NETCONF? ie CLIXON_CLIENT_NETCONF +# there is also CLIXON_CLIENT_IPC, /* Internal IPC API, only experimental use */ +# CLIXON_CLIENT_SSH /* NYI External Netconf over SSH */ # Magic line must be first in script (see README.md) s="$_" ; . ./lib.sh || if [ "$s" = $0 ]; then exit 0; else return 0; fi @@ -119,6 +122,7 @@ if [ "$LINKAGE" = static ]; then else COMPILE="$CC ${CFLAGS} -I/usr/local/include $cfile -o $app -L /usr/local/lib -lclixon" fi + echo "COMPILE:$COMPILE" expectpart "$($COMPILE)" 0 "" diff --git a/test/test_copy_config.sh b/test/test_copy_config.sh index e694ffc1..12d7b749 100755 --- a/test/test_copy_config.sh +++ b/test/test_copy_config.sh @@ -129,81 +129,81 @@ new "wait restconf" wait_restconf new "Add config to candidate" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOeth/0/0if:fddinone ]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "eth/0/0if:fddinone " "" "" new "netconf commit to running" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "Delete candidate" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOeth/0/0if:fddinone ]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "eth/0/0if:fddinone " "" "" # Here startup and candidate are empty, only running has content # test running->startup and running->candidate new "Check candidate empty" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "Check startup empty" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "copy running->startup" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "copy running->candidate" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" # Here startup and candidate have content new "Check candidate content" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^eth/0/0if:fdditrue]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "eth/0/0if:fdditrue" new "Check startup content" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^eth/0/0if:fdditrue]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "eth/0/0if:fdditrue" new "Delete startup" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" # Here startup is empty and candidate has content # test candidate->startup new "Check startup empty" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "copy candidate->startup" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "Check startup content" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^eth/0/0if:fdditrue]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "eth/0/0if:fdditrue" new "Delete candidate" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOeth/0/0if:fddinone ]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "eth/0/0if:fddinone " "" "" # Here candidate is empty and startup has content # test startup->candidate new "Check candidate empty" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "copy startup->candidate" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "Check candidate content" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^eth/0/0if:fdditrue]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "eth/0/0if:fdditrue" # Negative test: check copying to running is not allowed new "Delete candidate" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOeth/0/0if:fddinone ]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "eth/0/0if:fddinone " "" "" new "netconf commit to running" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" # Here running is empty new "Check running empty" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" # Add to candidate new "copy startup->candidate" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" if ! $YANG_UNKNOWN_ANYDATA ; then new "copy startup->running not allowed" - expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^applicationunknown-elementrunningerrorFailed to find YANG spec of XML node: running with parent: target in namespace: urn:ietf:params:xml:ns:netconf:base:1.0]]>]]>$" + expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "applicationunknown-elementrunningerrorFailed to find YANG spec of XML node: running with parent: target in namespace: urn:ietf:params:xml:ns:netconf:base:1.0" fi # restconf copy @@ -215,7 +215,7 @@ expectpart "$(curl $CURLOPTS -X POST -H "Content-Type: application/yang-data+xml # Here running is empty new "Check running empty" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" if [ $RC -ne 0 ]; then new "Kill restconf daemon" diff --git a/test/test_datastore_repair.sh b/test/test_datastore_repair.sh index 2fba0ebc..045638ec 100755 --- a/test/test_datastore_repair.sh +++ b/test/test_datastore_repair.sh @@ -99,7 +99,7 @@ function testrun(){ wait_backend new "netconf get config" - expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^$AFTER]]>]]>$" + expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "$AFTER" if [ $BE -ne 0 ]; then new "Kill backend" diff --git a/test/test_debug.sh b/test/test_debug.sh index a2642949..0ace72bf 100755 --- a/test/test_debug.sh +++ b/test/test_debug.sh @@ -77,16 +77,16 @@ new "wait restconf" wait_restconf new "Set backend debug using netconf" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO1]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "1" "" "" new "Set backend debug using restconf" expectpart "$(curl $CURLOPTS -X POST -H 'Content-Type: application/yang-data+json' $RCPROTO://localhost/restconf/operations/clixon-lib:debug -d '{"clixon-lib:input":{"level":1}}')" 0 "HTTP/$HVER 204" new "Set restconf debug using netconf" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO1]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "1" "" "" new "netconf commit" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "Set restconf debug using restconf" expectpart "$(curl $CURLOPTS -X PUT -H 'Content-Type: application/yang-data+json' $RCPROTO://localhost/restconf/data/clixon-restconf:restconf/debug -d '{"clixon-restconf:debug":1}')" 0 "HTTP/$HVER 204" diff --git a/test/test_feature.sh b/test/test_feature.sh index e6e28f8e..3d6869e1 100755 --- a/test/test_feature.sh +++ b/test/test_feature.sh @@ -130,16 +130,16 @@ function testrun() if $enabled; then new "netconf set $node" - expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO<$node xmlns=\"urn:example:clixon\">foo]]>]]>" "^]]>]]>$" + expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "<$node xmlns=\"urn:example:clixon\">foo" "" "" new "netconf validate $node" - expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" + expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" else new "netconf set $node, expect fail" - expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO<$node xmlns=\"urn:example:clixon\">foo]]>]]>" "^applicationunknown-element$nodeerrorFailed to find YANG spec of XML node: $node with parent: config in namespace: urn:example:clixon]]>]]>$" + expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "<$node xmlns=\"urn:example:clixon\">foo" "" "applicationunknown-element$nodeerrorFailed to find YANG spec of XML node: $node with parent: config in namespace: urn:example:clixon" fi new "netconf discard-changes" - expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" + expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" } new "test params: -f $cfg" @@ -170,7 +170,7 @@ new "cli disabled feature in other module" expectpart "$($clixon_cli -1f $cfg -l o set routing ribs rib default-rib false)" 255 "CLI syntax error: \"set routing ribs rib default-rib false\": Unknown command" new "netconf discard-changes" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" # Single if-feature testrun x true @@ -190,8 +190,9 @@ testrun m8 false # This test has been broken up into all different modules instead of one large # reply since the modules change so often new "netconf schema resource, RFC 7895" +rpc=$(chunked_framing "") ret=$($clixon_netconf -qf $cfg<]]>]]> +$DEFAULTHELLO$rpc EOF ) #echo $ret diff --git a/test/test_helloworld.sh b/test/test_helloworld.sh index 805281c4..b211298e 100755 --- a/test/test_helloworld.sh +++ b/test/test_helloworld.sh @@ -138,21 +138,24 @@ if [ "$ret" != "hello world;" ]; then fi new "netconf edit-config" -ret=$(echo "$DEFAULTHELLO]]>]]>" | $clixon_netconf -qf $cfg) +rpc=$(chunked_framing "") +ret=$(echo "$DEFAULTHELLO$rpc" | $clixon_netconf -qf $cfg) if [ $? -ne 0 ]; then err 0 $r fi -if [ "$ret" != "]]>]]>" ]; then - err "$ret" "]]>]]>" +reply=$(chunked_framing "") +if [ "$ret" != "$reply" ]; then + err "$ret" "$reply" fi new "netconf commit" -ret=$(echo "$DEFAULTHELLO]]>]]>" | $clixon_netconf -qf $cfg) +rpc=$(chunked_framing "") +ret=$(echo "$DEFAULTHELLO$rpc" | $clixon_netconf -qf $cfg) if [ $? -ne 0 ]; then err 0 $r fi -if [ "$ret" != "]]>]]>" ]; then - err "$ret" "]]>]]>" +if [ "$ret" != "$reply" ]; then + err "$ret" "$reply" fi new "restconf GET" diff --git a/test/test_identity.sh b/test/test_identity.sh index 8576d729..1bbdd540 100755 --- a/test/test_identity.sh +++ b/test/test_identity.sh @@ -209,49 +209,49 @@ new "wait restconf" wait_restconf new "Set crypto to aes" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOaes]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "aes" "" "" new "netconf validate " -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "Set crypto to mc:aes" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOmc:aes]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "mc:aes" "" "" new "netconf validate" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "Set crypto to des:des3" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOdes:des3]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "des:des3" "" "" new "netconf validate" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "Set crypto to mc:foo" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOmc:foo]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "mc:foo" "" "" new "netconf validate" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "Set crypto to des:des3 using xmlns" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOdes:des3]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "des:des3" "" "" new "netconf validate" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" if false; then # XXX this is not supported new "Set crypto to x:des3 using xmlns" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOx:des3]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "x:des3" "" "" new "netconf validate" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" fi # not supported new "Set crypto to foo:bar" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOfoo:bar]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "foo:bar" "" "" new "netconf validate (expect fail)" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^applicationoperation-failederrorIdentityref validation failed, foo:bar not derived from crypto-alg in example-crypto-base.yang:[0-9]*]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "applicationoperation-failederrorIdentityref validation failed, foo:bar not derived from crypto-alg in example-crypto-base.yang:[0-9]*" "" new "cli set crypto to mc:aes" expectpart "$($clixon_cli -1 -f $cfg -l o set crypto mc:aes)" 0 "^$" @@ -272,19 +272,19 @@ new "cli validate" expectpart "$($clixon_cli -1 -f $cfg -l o validate)" 0 "^$" new "Netconf set acl-type" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOxmc:ipv4-acl-type]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "xmc:ipv4-acl-type" "" "" new "netconf validate " -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "Netconf set undefined acl-type" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOxundefined]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "xundefined" "" "" new "netconf validate fail" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^applicationoperation-failederrorIdentityref validation failed, undefined not derived from acl-base in example-my-crypto.yang:[0-9]*]]>]]>" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "applicationoperation-failederrorIdentityref validation failed, undefined not derived from acl-base in example-my-crypto.yang:[0-9]*" "" new "netconf discard-changes" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "CLI set acl-type" expectpart "$($clixon_cli -1 -f $cfg -l o set acls acl x type mc:ipv4-acl-type)" 0 "^$" @@ -306,7 +306,7 @@ new "cli validate empty" expectpart "$($clixon_cli -1 -f $cfg -l o validate)" 255 "Validate failed. Edit and try again or discard changes: application operation-failed Identityref validation failed, undefined not derived from acl-base" new "netconf discard-changes" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" # Special case sub-module new "auto-cli cli expansion submodule identity" @@ -325,7 +325,7 @@ new "cli validate wrong id (expect fail)" expectpart "$($clixon_cli -1 -f $cfg -l o validate 2>&1)" 255 "Identityref validation failed, ee:foo not derived from extra-base" new "netconf discard-changes" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" # restconf and identities: # 1. set identity in own module with restconf (PUT and POST), read it with restconf and netconf @@ -338,7 +338,7 @@ new "restconf get own identity" expectpart "$(curl $CURLOPTS -X GET $RCPROTO://localhost/restconf/data/example-my-crypto:crypto)" 0 "HTTP/$HVER 200" '{"example-my-crypto:crypto":"aes"}' new "netconf get own identity as set by restconf" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^aes" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "aes" "" new "restconf delete identity" expectpart "$(curl $CURLOPTS -X DELETE $RCPROTO://localhost/restconf/data/example-my-crypto:crypto)" 0 "HTTP/$HVER 204" @@ -359,23 +359,23 @@ new "restconf get other identity" expectpart "$(curl $CURLOPTS -X GET $RCPROTO://localhost/restconf/data/example-my-crypto:crypto)" 0 "HTTP/$HVER 200" '{"example-my-crypto:crypto":"example-des:des3"}' new "netconf get other identity" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^des:des3" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "]]>]]>" "des:des3" "" new "restconf delete identity" expectpart "$(curl $CURLOPTS -X DELETE $RCPROTO://localhost/restconf/data/example-my-crypto:crypto)" 0 "HTTP/$HVER 204" # 3. set identity in other module with netconf, read it with restconf and netconf new "netconf set other identity" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOdes:des3]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "des:des3" "" "" new "netconf commit" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "restconf get other identity (set by netconf)" expectpart "$(curl $CURLOPTS -X GET $RCPROTO://localhost/restconf/data/example-my-crypto:crypto)" 0 "HTTP/$HVER 200" '{"example-my-crypto:crypto":"example-des:des3"}' new "netconf get other identity" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^des:des3" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "des:des3" "" if [ $RC -ne 0 ]; then new "Kill restconf daemon" diff --git a/test/test_leaf_default.sh b/test/test_leaf_default.sh index de41bfee..745c5e1c 100755 --- a/test/test_leaf_default.sh +++ b/test/test_leaf_default.sh @@ -136,32 +136,32 @@ new "wait backend" wait_backend new "get config" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^$XML]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "$XML" new "Change default value r1" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO99]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "99" "" "" new "get config r1" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^99]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "99" new "Remove r1" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO99]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "99" "" "" new "get config" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^$XML]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "$XML" new "Set x list element" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOa]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "a" "" "" new "get config (should contain y/inside+outside)" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^$XMLafalsefalse]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "$XMLafalsefalse" # Set s3 leaf to 99 triggering when condition for default values new "Set s3 to 99" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO99]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "99" "" "" new "get config np3 with npleaf and npext" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^99319899]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "99319899" if [ $BE -ne 0 ]; then new "Kill backend" @@ -198,7 +198,7 @@ wait_backend new "get startup config" # Should have all defaults, except r1 that is set to 99 -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^$XML]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "$XML" # permission kludges sudo chmod 666 $dir/running_db @@ -213,10 +213,10 @@ if [ $? -ne 0 ]; then fi new "Change default value r2" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO88]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "88" "" "" new "commit" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "Check running no defaults: r1 and r2" # Again, running should have only non-defaults, ie only r1 and r2 @@ -258,7 +258,7 @@ new "wait backend" wait_backend new "get startup config with presence" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^$XML]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "$XML" if [ $BE -ne 0 ]; then new "Kill backend" @@ -290,7 +290,7 @@ new "wait backend" wait_backend new "get startup config with list default" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^$XMLafalsefalse]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "$XMLafalsefalse" if [ $BE -ne 0 ]; then new "Kill backend" diff --git a/test/test_leafref.sh b/test/test_leafref.sh index c9d5089b..0d80d5cf 100755 --- a/test/test_leafref.sh +++ b/test/test_leafref.sh @@ -133,52 +133,52 @@ new "wait backend" wait_backend new "leafref base config" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO$BASEXML]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "$BASEXML" "" "" new "leafref get config" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^$BASEXML]]>]]>" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "$BASEXML" "" new "leafref base commit" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "leafref add non-existing ref" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOeth3
10.0.4.6
]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "eth3
10.0.4.6
" "" "" new "leafref validate" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^applicationbad-elementeth3errorLeafref validation failed: No leaf eth3 matching path /if:interfaces/if:interface/if:name in example.yang:[0-9]*]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "applicationbad-elementeth3errorLeafref validation failed: No leaf eth3 matching path /if:interfaces/if:interface/if:name in example.yang:[0-9]*" "" #new "leafref wrong ref" -#expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOeth3
10.0.4.6
]]>]]>" "^]]>]]>$" +#expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "eth3
10.0.4.6
" "" "" new "leafref discard-changes" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "leafref add correct absref" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOeth0]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "eth0" "" "" new "leafref validate (ok)" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "leafref add correct relref" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOeth0]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "eth0]]>]]>" "" "" new "leafref validate (ok)" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "leafref add correct address" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO
192.0.2.1
]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "
192.0.2.1
" "" "" new "leafref validate (ok)" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "leafref delete leaf" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOeth0]]>]]>" "^" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "eth0" "" "" new "leafref validate (should fail)" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^applicationbad-elementeth0errorLeafref validation failed: No leaf eth0 matching path /if:interfaces/if:interface/if:name in example.yang:[0-9]*]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "applicationbad-elementeth0errorLeafref validation failed: No leaf eth0 matching path /if:interfaces/if:interface/if:name in example.yang:[0-9]*" "" new "leafref discard-changes" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "cli leafref lo" expectpart "$($clixon_cli -1f $cfg -l o set default-address absname lo)" 0 "^$" diff --git a/test/test_leafref_augment.sh b/test/test_leafref_augment.sh index cd6d1f88..9afae28a 100755 --- a/test/test_leafref_augment.sh +++ b/test/test_leafref_augment.sh @@ -179,13 +179,13 @@ EOF ) new "leafref augment+leafref config" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO$XML]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "$XML" "" "" new "leafref augment+leafref validate" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "netconf discard-changes" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" # Use augment, default prefixes, wrong leafref and typedef path XML=$(cat <$XML]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "$XML" "" "" new "leafref augment+leafref validate wrong ref" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^applicationbad-elementxxxerrorLeafref validation failed: No leaf xxx matching path /ex:sender/ex:name in augment.yang:[0-9]*]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "applicationbad-elementxxxerrorLeafref validation failed: No leaf xxx matching path /ex:sender/ex:name in augment.yang:[0-9]*" "" new "netconf discard-changes" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" # Use augment, default prefixes, correct leafref and in-data path XML=$(cat <$XML]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "$XML" "" "" new "leafref augment+leafref validate in-data" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "netconf discard-changes" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" if [ $BE -ne 0 ]; then diff --git a/test/test_leafref_state.sh b/test/test_leafref_state.sh index f586bad1..e0f1f2ee 100755 --- a/test/test_leafref_state.sh +++ b/test/test_leafref_state.sh @@ -128,40 +128,40 @@ EOF ) new "leafref config sender x" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO$XML]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "$XML" "" "" new "netconf commit" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" # Get path=/, state vs config new "netconf get / config+state" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^xx]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "xx" new "netconf get / state-only" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^x]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "x" new "netconf get / config-only" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^x]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "x" # Get path=/sender-state, state vs config new "netconf get /sender-state config+state" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^x]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "x" new "netconf get /sender-state state-only" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^x]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "x" new "netconf get /sender-state config-only" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" # Get path=/sender-config, state vs config new "netconf get /sender-config config+state" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^x]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "x" new "netconf get /sender-config state-only" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "netconf get /sender-config config-only" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^x]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "x" # Negative tests, # Double xmlns attribute @@ -172,7 +172,7 @@ cat < $fstate EOF new "Merge same tree - check double xmlns attribute" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^x]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "x" # Back to original cat < $fstate @@ -193,20 +193,20 @@ EOF ) # Negative tests, start with remove x and and add y instead new "leafref config delete sender x add y" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO$XML]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "$XML" "" "" new "netconf commit" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" # Leafref wrong internal: state references x but config contains only y new "netconf get / config+state should fail" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^applicationoperation-failedxerrorLeafref validation failed: No leaf x matching path /ex:sender-config/ex:name in leafref.yang:[0-9]*. Internal error, state callback returned invalid XML]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "applicationoperation-failedxerrorLeafref validation failed: No leaf x matching path /ex:sender-config/ex:name in leafref.yang:[0-9]*. Internal error, state callback returned invalid XML" "" new "netconf get / state-only should fail" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^applicationoperation-failedxerrorLeafref validation failed: No leaf x matching path /ex:sender-config/ex:name in leafref.yang:[0-9]*. Internal error, state callback returned invalid XML]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "applicationoperation-failedxerrorLeafref validation failed: No leaf x matching path /ex:sender-config/ex:name in leafref.yang:[0-9]*. Internal error, state callback returned invalid XML" "" new "netconf get / config-only ok" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^y]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "y" if [ $BE -ne 0 ]; then new "Kill backend" @@ -251,17 +251,17 @@ cat < $fstate EOF new "leafref config sender x" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO$XML]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "$XML" "" "" new "netconf commit" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" # Leafref wrong internal: state references x but config contains only y new "netconf get / config+state wrong state xml but no validation" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "yx]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "yx" new "netconf get / state-only wrong state xml but no validation" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^x]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "x" if [ $BE -ne 0 ]; then new "Kill backend" @@ -306,17 +306,17 @@ cat < $fstate EOF new "leafref config sender x" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO$XML]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "$XML" "" "" new "netconf commit" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" # Leafref wrong internal: state references x but config contains only y new "netconf get / config+state wrong state xml but no validation" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "yx]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "yx" new "netconf get / state-only wrong state xml but no validation" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^x]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "x" if [ $BE -ne 0 ]; then new "Kill backend" diff --git a/test/test_leafref_union.sh b/test/test_leafref_union.sh index 53011261..c2f2c6f7 100755 --- a/test/test_leafref_union.sh +++ b/test/test_leafref_union.sh @@ -113,60 +113,61 @@ new "wait backend" wait_backend new "netconf set x,y leafs" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO4299merge ]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "4299merge " "" "" new "netconf commit x,y" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "netconf set union 42" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO42none]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "42none" "" "" new "netconf validate ok" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "netconf check config" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^429942]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "429942" new "netconf set union 66" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO66none]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "66none" "" "" new "netconf validate not ok" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^applicationbad-element66errorLeafref validation failed: No leaf 66 matching path ../y" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "applicationbad-element66errorLeafref validation failed: No leaf 66 matching path ../y" "" new "netconf discard-changes" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "]]>]]>" "" "" new "netconf set union id saab" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOex:saabnone]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "ex:saabnone" "" "" + new "netconf validate ok" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "netconf set union idref zzz" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOex:zzznone]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "ex:zzznone" "" "" new "netconf validate idref not ok" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^applicationoperation-failederrorIdentityref validation failed" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "applicationoperation-failederrorIdentityref validation failed" "" new "netconf discard-changes" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "]]>]]>" "" "" new "netconf set union id des" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOex:desnone]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "ex:desnone" "" "" new "netconf validate ok" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "netconf set union x=42" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO42none]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "42none" "" "" new "netconf validate ok" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "netconf set union 99" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO99none]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "99none" "" "" new "netconf validate not ok" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^applicationbad-element99errorLeafref validation failed" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "applicationbad-element99errorLeafref validation failed" "" if [ $BE -ne 0 ]; then new "Kill backend" diff --git a/test/test_minmax.sh b/test/test_minmax.sh index 36098df9..cf1da8a1 100755 --- a/test/test_minmax.sh +++ b/test/test_minmax.sh @@ -117,132 +117,132 @@ new "wait backend" wait_backend new "minmax: minimal: 1x a1,b1 (should be [1:2]" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOreplace +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "replace 0 0 -]]>]]>" "^]]>]]>$" +" "" "" new "minmax: minimal validate ok" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "minmax: maximal: 2x a1,b1" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOreplace01unbounded0101unbounded101]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "replace01unbounded0101unbounded101" "" "" new "minmax: validate ok" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "minmax: replace with 0x a1,b1" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOreplace]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "replace" "" "" #XXX echo "$DEFAULTHELLO]]>]]>" |$clixon_netconf -qf $cfg new "minmax: validate should fail" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^protocoloperation-failedtoo-few-elementserror/c/a1]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "protocoloperation-failedtoo-few-elementserror/c/a1" new "minmax: no list" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOreplace0]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "replace0" "" "" new "minmax: validate should fail" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^protocoloperation-failedtoo-few-elementserror/c/a1]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "protocoloperation-failedtoo-few-elementserror/c/a1" new "minmax: no leaf-list" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOreplace0]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "replace0" "" "" new "minmax: validate should fail" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^protocoloperation-failedtoo-few-elementserror/c/b1]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "protocoloperation-failedtoo-few-elementserror/c/b1" new "minmax: Too large list" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOreplace0120]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "replace0120" "" "" new "minmax: validate should fail" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^protocoloperation-failedtoo-many-elementserror/c/a1]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "protocoloperation-failedtoo-many-elementserror/c/a1" new "minmax: Too large leaf-list" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOreplace0012]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "replace0012" "" "" new "minmax: validate should fail" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^protocoloperation-failedtoo-many-elementserror/c/b1]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "protocoloperation-failedtoo-many-elementserror/c/b1" new "netconf discard-changes" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" # With choice c1 new "minmax choice: minimal" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOreplace +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "replace 0 0 -]]>]]>" "^]]>]]>$" +" "" "" new "minmax choice: minimal validate ok" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "minmax choice: many a2" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOreplace +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "replace 0 1 2 0 -]]>]]>" "^]]>]]>$" +" "" "" new "minmax choice: many a2 validate ok" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "minmax choice: too many a1" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOreplace +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "replace 0 1 2 0 -]]>]]>" "^]]>]]>$" +" "" "" new "minmax choice: too many validate should fail" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^protocoloperation-failedtoo-many-elementserror/c2/a1]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "protocoloperation-failedtoo-many-elementserror/c2/a1" new "netconf discard-changes" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" # top config level new "minmax top level" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOreplace +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "replace 0 1 -]]>]]>" "^]]>]]>$" +" "" "" new "minmax top level ok" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "minmax top level too many" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOreplace +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "replace 0 1 2 -]]>]]>" "^]]>]]>$" +" "" "" new "minmax top level too many should fail" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^protocoloperation-failedtoo-many-elementserror/b3]]>]]>" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "protocoloperation-failedtoo-many-elementserror/b3" new "netconf discard-changes" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" # Above only tests on candidate -> empty running # Also need to do commit tests when running has elements and candidate has fewer new "Set maximal: 2x a1,b1" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOreplace0110]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "replace0110" "" "" new "netconf commit" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "minmax: delete to minimal: 1x a1,b1" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOnone11]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "none11" "" "" new "minmax: commit minimal list" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "minmax: delete to no list" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOnone00]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "none00" "" "" new "minmax: validate should fail empty list" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^protocoloperation-failedtoo-few-elementserror/c/a1]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "protocoloperation-failedtoo-few-elementserror/c/a1" if [ $BE -ne 0 ]; then new "Kill backend" diff --git a/test/test_nacm.sh b/test/test_nacm.sh index 794b9bd6..963a5cd0 100755 --- a/test/test_nacm.sh +++ b/test/test_nacm.sh @@ -145,10 +145,10 @@ new "disable nacm" expectpart "$(curl -u andy:bar $CURLOPTS -X PUT -H "Content-Type: application/yang-data+json" -d '{"ietf-netconf-acm:enable-nacm": false}' $RCPROTO://localhost/restconf/data/ietf-netconf-acm:nacm/enable-nacm)" 0 "HTTP/$HVER 201" new "auth set authentication config" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO$RULES]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "$RULES" "" "" new "commit it" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "auth get (no user: access denied)" expectpart "$(curl $CURLOPTS -X GET -H "Accept: application/yang-data+json" $RCPROTO://localhost/restconf/data)" 0 "HTTP/$HVER 401" '{"ietf-restconf:errors":{"error":{"error-type":"protocol","error-tag":"access-denied","error-severity":"error","error-message":"The requested URL was unauthorized"}}} ' diff --git a/test/test_nacm_credentials.sh b/test/test_nacm_credentials.sh index 9c093d55..937adc69 100755 --- a/test/test_nacm_credentials.sh +++ b/test/test_nacm_credentials.sh @@ -140,13 +140,13 @@ EOF # First push in nacm rules via regular means new "auth set authentication config" - expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO$RULES]]>]]>" "^]]>]]>$" + expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "$RULES" "" "" new "enable nacm" - expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOtrue]]>]]>" "^]]>]]>$" + expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "true" "" "" new "commit it" - expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" + expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" # raw socket test if [ -n "$username" ]; then @@ -156,7 +156,7 @@ EOF fi new "get-config mode:$mode user:$username $family $precmd" - expecteof "$precmd $clixon_util_socket -a $family -s $sock -D $DBG" 0 "$XML" "$ex" + expecteof_netconf "$precmd $clixon_util_socket -a $family -s $sock -D $DBG" 0 "" "$XML" "$ex" if [ $BE -ne 0 ]; then # Bring your own backend new "Kill backend" diff --git a/test/test_nacm_datanode.sh b/test/test_nacm_datanode.sh index 9a91d845..4ff4d6e8 100755 --- a/test/test_nacm_datanode.sh +++ b/test/test_nacm_datanode.sh @@ -241,14 +241,13 @@ new "wait restconf" wait_restconf new "auth set authentication config" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO$RULES]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "$RULES" "" "" new "set app config" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO$CONFIG]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "$CONFIG" "" "" new "commit it" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" - +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "enable nacm" expectpart "$(curl -u andy:bar $CURLOPTS -X PUT -H "Content-Type: application/yang-data+json" -d '{"ietf-netconf-acm:enable-nacm": true}' $RCPROTO://localhost/restconf/data/ietf-netconf-acm:nacm/enable-nacm)" 0 "HTTP/$HVER 204" diff --git a/test/test_nacm_datanode_read.sh b/test/test_nacm_datanode_read.sh index 113e4b1f..002e672c 100755 --- a/test/test_nacm_datanode_read.sh +++ b/test/test_nacm_datanode_read.sh @@ -246,14 +246,13 @@ new "wait restconf" wait_restconf new "auth set authentication config" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO$RULES]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "$RULES" "" "" new "set app config" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO$CONFIG]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "$CONFIG" "" "" new "commit it" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" - +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "enable nacm" expectpart "$(curl -u andy:bar $CURLOPTS -X PUT -H "Content-Type: application/yang-data+json" -d '{"ietf-netconf-acm:enable-nacm": true}' $RCPROTO://localhost/restconf/data/ietf-netconf-acm:nacm/enable-nacm)" 0 "HTTP/$HVER 204" diff --git a/test/test_nacm_datanode_write.sh b/test/test_nacm_datanode_write.sh index de0a2ac3..be66222b 100755 --- a/test/test_nacm_datanode_write.sh +++ b/test/test_nacm_datanode_write.sh @@ -242,14 +242,13 @@ new "wait restconf" wait_restconf new "auth set authentication config" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO$RULES]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "$RULES" "" "" new "set app config" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO$CONFIG]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "$CONFIG" "" "" new "commit it" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" - +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "enable nacm" expectpart "$(curl -u andy:bar $CURLOPTS -X PUT -H "Content-Type: application/yang-data+json" -d '{"ietf-netconf-acm:enable-nacm": true}' $RCPROTO://localhost/restconf/data/ietf-netconf-acm:nacm/enable-nacm)" 0 "HTTP/$HVER 204" diff --git a/test/test_nacm_module_read.sh b/test/test_nacm_module_read.sh index 9d1659c3..42e3f9e2 100755 --- a/test/test_nacm_module_read.sh +++ b/test/test_nacm_module_read.sh @@ -199,11 +199,10 @@ new "wait restconf" wait_restconf new "auth set authentication config" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO$RULES]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "$RULES" "" "" new "commit it" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" - +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "enable nacm" expectpart "$(curl -u andy:bar $CURLOPTS -X PUT -H "Content-Type: application/yang-data+json" -d '{"ietf-netconf-acm:enable-nacm": true}' $RCPROTO://localhost/restconf/data/ietf-netconf-acm:nacm/enable-nacm)" 0 "HTTP/$HVER 204" @@ -216,7 +215,7 @@ new "admin read ok" expectpart "$(curl -u andy:bar $CURLOPTS -X GET $RCPROTO://localhost/restconf/data/clixon-example:table)" 0 "HTTP/$HVER 200" '{"clixon-example:table":{"parameter":\[{"name":"key42","value":"val42"},{"name":"key43","value":"val43"}\]}}' new "admin read netconf ok" -expecteof "$clixon_netconf -U andy -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^key42val42key43val43
]]>]]>$" +expecteof_netconf "$clixon_netconf -U andy -qf $cfg" 0 "$DEFAULTHELLO" "" "" "key42val42key43val43
" new "admin read element ok" expectpart "$(curl -u andy:bar $CURLOPTS -X GET $RCPROTO://localhost/restconf/data/clixon-example:table/parameter=key42/value)" 0 "HTTP/$HVER 200" '{"clixon-example:value":"val42"}' @@ -241,7 +240,7 @@ new "limit read ok" expectpart "$(curl -u wilma:bar $CURLOPTS -X GET $RCPROTO://localhost/restconf/data/clixon-example:table)" 0 "HTTP/$HVER 200" '{"clixon-example:table":{"parameter":\[{"name":"key42","value":"val42"},{"name":"key43","value":"val43"}\]}}' new "limit read netconf ok" -expecteof "$clixon_netconf -U wilma -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^key42val42key43val43
]]>]]>$" +expecteof_netconf "$clixon_netconf -U wilma -qf $cfg" 0 "$DEFAULTHELLO" "" "" "key42val42key43val43
" new "limit read element ok" expectpart "$(curl -u wilma:bar $CURLOPTS -X GET $RCPROTO://localhost/restconf/data/clixon-example:table/parameter=key42/value)" 0 "HTTP/$HVER 200" '{"clixon-example:value":"val42"}' @@ -261,7 +260,7 @@ new "guest read forbidden" expectpart "$(curl -u guest:bar $CURLOPTS -X GET $RCPROTO://localhost/restconf/data/clixon-example:table)" 0 "HTTP/$HVER 403" '{"ietf-restconf:errors":{"error":{"error-type":"application","error-tag":"access-denied","error-severity":"error","error-message":"default deny"}}}' new "guest read netconf fail" -expecteof "$clixon_netconf -U guest -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^applicationaccess-deniederrordefault deny]]>]]>$" +expecteof_netconf "$clixon_netconf -U guest -qf $cfg" 0 "$DEFAULTHELLO" "" "" "applicationaccess-deniederrordefault deny" new "guest read element forbidden" expectpart "$(curl -u guest:bar $CURLOPTS -X GET $RCPROTO://localhost/restconf/data/clixon-example:table/parameter=key42/value)" 0 "HTTP/$HVER 403" '{"ietf-restconf:errors":{"error":{"error-type":"application","error-tag":"access-denied","error-severity":"error","error-message":"default deny"}}}' @@ -281,19 +280,19 @@ new "admin rpc ok" expectpart "$(curl -u andy:bar $CURLOPTS -X POST -H "Content-Type: application/yang-data+json" -d '{"clixon-example:input":{"x":"78"}}' $RCPROTO://localhost/restconf/operations/clixon-example:example)" 0 "HTTP/$HVER 200" '{"clixon-example:output":{"x":"78","y":"42"}}' new "admin rpc netconf ok" -expecteof "$clixon_netconf -U andy -qf $cfg" 0 "$DEFAULTHELLO0]]>]]>" "^042]]>]]>$" +expecteof_netconf "$clixon_netconf -U andy -qf $cfg" 0 "$DEFAULTHELLO" "0" "" "042" new "limit rpc ok" expectpart "$(curl -u wilma:bar $CURLOPTS -X POST $RCPROTO://localhost/restconf/operations/clixon-example:example -H "Content-Type: application/yang-data+json" -d '{"clixon-example:input":{"x":42}}' )" 0 "HTTP/$HVER 200" '{"clixon-example:output":{"x":"42","y":"42"}}' new "limit rpc netconf ok" -expecteof "$clixon_netconf -U wilma -qf $cfg" 0 "$DEFAULTHELLO0]]>]]>" "^042]]>]]>$" +expecteof_netconf "$clixon_netconf -U wilma -qf $cfg" 0 "$DEFAULTHELLO" "0" "" "042" new "guest rpc fail" expectpart "$(curl -u guest:bar $CURLOPTS -X POST $RCPROTO://localhost/restconf/operations/clixon-example:example -H "Content-Type: application/yang-data+json" -d '{"clixon-example:input":{"x":42}}' )" 0 "HTTP/$HVER 403" '{"ietf-restconf:errors":{"error":{"error-type":"application","error-tag":"access-denied","error-severity":"error","error-message":"access denied"}}}' new "guest rpc netconf fail" -expecteof "$clixon_netconf -U guest -qf $cfg" 0 "$DEFAULTHELLO0]]>]]>" "^applicationaccess-deniederroraccess denied]]>]]>$" +expecteof_netconf "$clixon_netconf -U guest -qf $cfg" 0 "$DEFAULTHELLO" "0" "" "applicationaccess-deniederroraccess denied" #------------------ Set read-default permit diff --git a/test/test_nacm_module_write.sh b/test/test_nacm_module_write.sh index 90f96335..3fb8832a 100755 --- a/test/test_nacm_module_write.sh +++ b/test/test_nacm_module_write.sh @@ -192,10 +192,10 @@ wait_restconf # Set nacm from scratch function nacm(){ new "auth set authentication config" - expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO$RULES]]>]]>" "^]]>]]>$" + expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "$RULES" "" "" new "commit it" - expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" + expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "enable nacm" expectpart "$(curl -u andy:bar $CURLOPTS -X PUT -H 'Content-Type: application/yang-data+json' -d '{"ietf-netconf-acm:enable-nacm":true}' $RCPROTO://localhost/restconf/data/ietf-netconf-acm:nacm/enable-nacm)" 0 "HTTP/$HVER 204" diff --git a/test/test_nacm_protocol.sh b/test/test_nacm_protocol.sh index ac7f7e2b..f37d911f 100755 --- a/test/test_nacm_protocol.sh +++ b/test/test_nacm_protocol.sh @@ -161,10 +161,10 @@ new "wait restconf" wait_restconf new "auth set authentication config" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO$RULES]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "$RULES" "" "" new "commit it" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "enable nacm" expectpart "$(curl -u andy:bar $CURLOPTS -X PUT -H "Content-Type: application/yang-data+json" -d '{"ietf-netconf-acm:enable-nacm": true}' $RCPROTO://localhost/restconf/data/ietf-netconf-acm:nacm/enable-nacm)" 0 "HTTP/$HVER 204" @@ -176,17 +176,17 @@ expectpart "$(curl -u andy:bar $CURLOPTS -X GET $RCPROTO://localhost/restconf/da # Rule 1: deny-kill-session new "deny-kill-session: limited fail (netconf)" -expecteof "$clixon_netconf -qf $cfg -U wilma" 0 "$DEFAULTHELLO44]]>]]>" "^applicationaccess-deniederroraccess denied]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg -U wilma" 0 "$DEFAULTHELLO" "44" "" "applicationaccess-deniederroraccess denied" new "deny-kill-session: guest fail (netconf)" -expecteof "$clixon_netconf -qf $cfg -U guest" 0 "$DEFAULTHELLO44]]>]]>" "^applicationaccess-deniederroraccess denied]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg -U guest" 0 "$DEFAULTHELLO" "44" "" "applicationaccess-deniederroraccess denied" new "deny-kill-session: admin ok (netconf)" -expecteof "$clixon_netconf -qf $cfg -U andy" 0 "$DEFAULTHELLO44]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg -U andy" 0 "$DEFAULTHELLO" "44" "" "" # Rule 2: deny-delete-config new "deny-delete-config: limited fail (netconf)" -expecteof "$clixon_netconf -qf $cfg -U wilma" 0 "$DEFAULTHELLO]]>]]>" "^applicationaccess-deniederroraccess denied]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg -U wilma" 0 "$DEFAULTHELLO" "" "" "applicationaccess-deniederroraccess denied" new "deny-delete-config: guest fail (restconf)" expectpart "$(curl -u guest:bar $CURLOPTS -X DELETE $RCPROTO://localhost/restconf/data)" 0 "HTTP/$HVER 403" '{"ietf-restconf:errors":{"error":{"error-type":"application","error-tag":"access-denied","error-severity":"error","error-message":"default deny"}}}' @@ -203,10 +203,10 @@ expectpart "$(curl -u andy:bar $CURLOPTS -X DELETE $RCPROTO://localhost/restconf # Here the whole config is gone so we need to start again new "auth set authentication config (restart)" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO$RULES]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "$RULES" "" "" new "commit it" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "enable nacm" expectpart "$(curl -u andy:bar $CURLOPTS -X PUT -H "Content-Type: application/yang-data+json" -d '{"ietf-netconf-acm:enable-nacm": true}' $RCPROTO://localhost/restconf/data/ietf-netconf-acm:nacm/enable-nacm)" 0 "HTTP/$HVER 204" diff --git a/test/test_nacm_recovery.sh b/test/test_nacm_recovery.sh index 80e0fe1c..c8c242ba 100755 --- a/test/test_nacm_recovery.sh +++ b/test/test_nacm_recovery.sh @@ -112,23 +112,22 @@ EOF if $getp; then # default is read allowed so this should always succeed. new "get startup default ok" - expecteof "$prefix$clixon_netconf -qf $cfg -U $pseudo" 0 "$DEFAULTHELLO]]>]]>" "^$DEFAULT]]>]]>$" + expecteof_netconf "$prefix$clixon_netconf -qf $cfg -U $pseudo" 0 "$DEFAULTHELLO" "" "" "$DEFAULT" # This would normally not work except in recovery situations else new "get startup not ok" - expecteof "$prefix$clixon_netconf -qf $cfg -U $pseudo" 0 "$DEFAULTHELLO]]>]]>" "^applicationaccess-deniederrorUser $realuser credential not matching NACM user $pseudo]]>]]>$" + expecteof_netconf "$prefix$clixon_netconf -qf $cfg -U $pseudo" 0 "$DEFAULTHELLO" "" "" "applicationaccess-deniederrorUser $realuser credential not matching NACM user $pseudo" fi if $putp; then new "put, expect ok" - expecteof "$prefix$clixon_netconf -qf $cfg -U $pseudo" 0 "$DEFAULTHELLO$RULES]]>]]>" "]]>]]>" + expecteof_netconf "$prefix$clixon_netconf -qf $cfg -U $pseudo" 0 "$DEFAULTHELLO" "$RULES" "" "" new "get rules ok" - expecteof "$prefix$clixon_netconf -qf $cfg -U $pseudo" 0 "$DEFAULTHELLO]]>]]>" "^$RULES]]>]]>$" + expecteof_netconf "$prefix$clixon_netconf -qf $cfg -U $pseudo" 0 "$DEFAULTHELLO" "" "" "$RULES" else new "put, expect fail" - expecteof "$prefix$clixon_netconf -qf $cfg -U $pseudo" 0 "$DEFAULTHELLO$RULES]]>]]>" "^applicationaccess-deniederror" - # default deny]]>]]>$" + expecteof_netconf "$prefix$clixon_netconf -qf $cfg -U $pseudo" 0 "$DEFAULTHELLO" "$RULES" "applicationaccess-deniederror" "" # default deny" fi if [ $RC -ne 0 ]; then new "Kill restconf daemon" diff --git a/test/test_netconf.sh b/test/test_netconf.sh index 715268c4..5f5d83a3 100755 --- a/test/test_netconf.sh +++ b/test/test_netconf.sh @@ -54,7 +54,7 @@ wait_backend # Framing. with -q to inhibit rcv hello new "Empty frame" -expecteof "$clixon_netconf -qf $cfg" 0 ']]>]]>' 'rpcoperation-failederrorEmpty XML]]>]]>' +expecteof_netconf "$clixon_netconf -qf $cfg" 0 ']]>]]>' "" 'rpcoperation-failederrorEmpty XML]]>]]>' "" if [ $valgrindtest -eq 0 ]; then # Some leakage in lex / error handling difficult to catch new "Frame invalid non-xml" @@ -68,239 +68,249 @@ new "Frame with unknown message" expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^protocolunknown-elementxxxerrorUnrecognized netconf operation]]>]]>$" new "Frame without message-id attribute" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^rpcmissing-attributemessage-iderrorIncoming rpc]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "^rpcmissing-attributemessage-iderrorIncoming rpc$" #urn:ietf:params:netconf:base:1.1 new "netconf rcv hello, disable RFC7895/ietf-yang-library" -expecteof "$clixon_netconf -f $cfg -o CLICON_YANG_LIBRARY=0" 0 "$DEFAULTHELLO]]>]]>" "^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_netconf "$clixon_netconf -f $cfg -o CLICON_YANG_LIBRARY=0" 0 "$DEFAULTHELLO" "" "" "" new "netconf get-config nc prefix" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "netconf get-config xx prefix" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "netconf get-config double quotes" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "netconf get-config single quotes" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "Add subtree eth/0/0 using none which should not change anything" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOnoneeth/0/0]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "noneeth/0/0" "" "" # Trying prefixes new "Add subtree eth/0/0 using nc prefix" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOnoneeth/0/0]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "noneeth/0/0" "" "" new "Add subtree eth/0/0 using xx prefix" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOnoneeth/0/0]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "noneeth/0/0" "" "" new "Check nothing added" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "Add subtree eth/0/0 using none and create which should add eth/0/0" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOeth/0/0ex:ethnone ]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "eth/0/0ex:ethnone " "" "" # Too many quotes, (single inside double inside single) need to fool bash +rpc=$(chunked_framing "") cat < $tmp # new -$DEFAULTHELLO]]>]]> +$DEFAULTHELLO$rpc EOF new "Check eth/0/0 added using xpath" -expecteof "$clixon_netconf -qf $cfg" 0 "$(cat $tmp)" "^eth/0/0ex:ethtrue]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "$rpc" "" "eth/0/0ex:ethtrue" new "Re-create same eth/0/0 which should generate error" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOeth/0/0ex:ethnone ]]>]]>" "^" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "eth/0/0ex:ethnone " "" "" new "Delete eth/0/0 using none config" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOeth/0/0ex:ethnone ]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "eth/0/0ex:ethnone " "" "" new "Check deleted eth/0/0 (non-presence container)" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "Re-Delete eth/0/0 using none should generate error" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOeth/0/0ex:ethnone ]]>]]>" "^" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "eth/0/0ex:ethnone " "" "" new "Add interface without key" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOex:ethnone ]]>]]>" "^applicationmissing-elementnameerrorMandatory key]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "ex:ethnone " "" "applicationmissing-elementnameerrorMandatory key" new "netconf discard-changes" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "netconf discard-changes using xx prefix" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "netconf edit config" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOeth/0/0eth1true9.2.3.424]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "eth/0/0eth1true9.2.3.424" "" "" -# Too many quotes -cat < $tmp # new -$DEFAULTHELLO]]>]]> -EOF +rpc="" new "netconf get config xpath" -expecteof "$clixon_netconf -qf $cfg" 0 "$(cat $tmp)" "^eth1true]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "$rpc" "" "eth1true" -# Too many quotes -cat < $tmp # new -$DEFAULTHELLO]]>]]> -EOF +rpc="" new "netconf get config xpath parent" -expecteof "$clixon_netconf -qf $cfg" 0 "$(cat $tmp)" "^eth/0/0trueeth1truetruefalse9.2.3.424]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "$rpc" "" "eth/0/0trueeth1truetruefalse9.2.3.424" new "netconf validate missing type" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "netconf validate using xx prefix" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "netconf discard-changes" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "netconf get empty config2" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "netconf edit extra xml" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "netconf discard-changes" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "netconf edit config eth1" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOeth1ex:eth]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "eth1ex:eth" "" "" new "netconf validate" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "netconf commit" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "netconf commit using prefix xx" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "netconf edit config merge eth2" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOeth2ex:ethmerge]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "eth2ex:ethmerge" "" "" # Note, the type here is non-existant identityref, fails on validation new "netconf edit ampersand encoding(<&): name:'eth&' type:'t<>'" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOeth&t<>]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "eth&t<>" "" "" new "netconf get replaced config" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^eth&t<>trueeth1ex:ethtrueeth2ex:ethtrue]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "eth&t<>trueeth1ex:ethtrueeth2ex:ethtrue" new "cli show configuration eth& - encoding tests" expectpart "$($clixon_cli -1 -f $cfg show conf cli)" 0 "interfaces interface eth& type t<> interfaces interface eth& enabled true" new "netconf edit CDATA" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOeth/0/0ex:eth]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "eth/0/0ex:eth" "" "" #new "netconf get CDATA" -#expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "eth/0/0true]]>]]>" +#expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "eth/0/0true" new "netconf discard-changes" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "netconf edit state operation should fail" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOe0up]]>]]>" "^applicationbad-elementoper-statuserrormodule ietf-interfaces: state data node unexpected]]>]]>" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "e0up" "" "applicationbad-elementoper-statuserrormodule ietf-interfaces: state data node unexpected" new "netconf get state operation" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^eth1ex:ethtrueup42foo]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "eth1ex:ethtrueup42foo" new "netconf get state operation use prefix xx" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^eth1ex:ethtrueup42foo]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "eth1ex:ethtrueup42foo" new "netconf lock" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "netconf unlock" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^protocollock-denied0errorUnlock failed, lock is not currently active]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "protocollock-denied0errorUnlock failed, lock is not currently active" new "netconf lock using prefix xx" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "netconf unlock using prefix xx" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^protocollock-denied0errorUnlock failed, lock is not currently active]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "protocollock-denied0errorUnlock failed, lock is not currently active" +# send multiple frames +rpc=$(chunked_framing "") +rpc="${rpc} +$(chunked_framing "")" +reply=$(chunked_framing "]]>]]>]]>]]>" "^]]>]]>]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO$rpc" "$reply" +rpc=$(chunked_framing "") +rpc="${rpc} +$(chunked_framing "")" new "netconf lock/unlock/lock" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>]]>]]>]]>]]>" "^]]>]]>]]>]]>]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO$rpc" "$reply" +rpc=$(chunked_framing "") +rpc="${rpc} +$(chunked_framing "")" new "netconf lock/lock" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>]]>]]>" "^]]>]]>protocollock-denied" +expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO$rpc" "protocollock-denied") +rpc="${rpc} +$(chunked_framing "")" new "netconf unlock/unlock" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>]]>]]>" "^protocollock-denied0errorUnlock failed, lock is not currently active]]>]]>protocollock-denied0errorUnlock failed, lock is not currently active]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO$rpc" "protocollock-denied0errorUnlock failed, lock is not currently active" new "close-session" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "close-session using prefix xx" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" # XXX NOTE that this does not actually kill a running session - and may even kill some random process,... new "kill-session" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO44]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "44" "" "" new "kill-session using prefix xx" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO44]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "44" "" "" # modify candidate, then lock, should fail. new "netconf edit config" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOa
]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "a
" "" "" new "netconf lock: should fail" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^protocollock-denied0errorOperation failed, candidate has already been modified and the changes have not been committed or rolled back (RFC 6241 7.5)]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "protocollock-denied0errorOperation failed, candidate has already been modified and the changes have not been committed or rolled back (RFC 6241 7.5)" new "netconf discard-changes" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "netconf lock" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "copy startup to candidate" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "copy startup to candidate using prefix xx" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "netconf get startup" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^eth1ex:ethtrue]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "eth1ex:ethtrue" new "netconf delete startup" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "netconf delete startup using prefix xx" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "netconf check empty startup" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "netconf example rpc" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO42]]>]]>" "^4242]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "42" "" "4242" new "netconf example rpc using prefix xx" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO42]]>]]>" "^4242]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "42" "" "4242" new "netconf empty rpc" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "netconf client-side rpc" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOval42]]>]]>" "^val42]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "val42" "" "val42" new "netconf extra leaf in leaf should fail" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOe0e1]]>]]>" "^applicationunknown-elementnameerrorFailed to find YANG spec of XML node: name with parent: name in namespace: urn:ietf:params:xml:ns:yang:ietf-interfaces]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "e0e1" "" "applicationunknown-elementnameerrorFailed to find YANG spec of XML node: name with parent: name in namespace: urn:ietf:params:xml:ns:yang:ietf-interfaces" # Negative tests new "netconf xpath syntax error (api-path not xpath) should fail" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^applicationoperation-failederrorxpath parser on line 1: syntax error at or before: ',']]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "applicationoperation-failederrorxpath parser on line 1: syntax error at or before: ','" new "netconf wrong xpath should fail" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" if [ $BE -ne 0 ]; then new "Kill backend" diff --git a/test/test_netconf_filter.sh b/test/test_netconf_filter.sh index 8ec28b18..05346d1b 100755 --- a/test/test_netconf_filter.sh +++ b/test/test_netconf_filter.sh @@ -60,58 +60,58 @@ new "waiting" wait_backend new "Add two entries" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO1122]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "1122" "" "" new "netconf commit" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "wrong filter type" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO1]]>]]>" "^operation-failedapplicatioerrorfilter type not supportedtype]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "1" "" "operation-failedapplicatioerrorfilter type not supportedtype" new "get-config subtree one (subtree implicit)" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO1]]>]]>" "^11]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "1" "" "11" new "get subtree one (subtree implicit)" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO1]]>]]>" "^11]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "1" "" "11" new "get-config subtree one" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO1]]>]]>" "^11]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "1" "" "11" new "get subtree one" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO1]]>]]>" "^11]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "1" "" "11" new "get-config xpath one" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^11]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "11" new "get xpath one" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^11]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "11" new "put more entries" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO31345425675]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "31345425675" "" "" new "netconf commit" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "get xpath function not b=1" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^2231345425675]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "2231345425675" new "get xpath function not(b)" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^5]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "5" new "get xpath function contains" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^2242567]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "2242567" new "get xpath function not(contains(fib,2))" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^11313455]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "11313455" new "get xpath function or" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^3134542567]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "3134542567" new "get xpath function and" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^11]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "11" new "get xpath function union" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^115]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "115" if [ $BE -ne 0 ]; then new "Kill backend" diff --git a/test/test_netconf_framing.sh b/test/test_netconf_framing.sh index 85fa9bbc..ddec9ad2 100755 --- a/test/test_netconf_framing.sh +++ b/test/test_netconf_framing.sh @@ -71,9 +71,32 @@ new "wait backend" wait_backend # Hello -new "Netconf 1.0 eom framing" +new "Netconf 1.0 eom framing, edit-config" expecteof "$clixon_netconf -qef $cfg -o CLICON_NETCONF_BASE_CAPABILITY=0" 0 "urn:ietf:params:netconf:base:1.0]]>]]>mergea
]]>]]>$" "^]]>]]>$" +new "Netconf 1.0 eom framing get-config" +expecteof "$clixon_netconf -qef $cfg -o CLICON_NETCONF_BASE_CAPABILITY=0" 0 "urn:ietf:params:netconf:base:1.0]]>]]>]]>]]>$" "^a
]]>]]>$" + +new "Netconf 1.1 eom framing, expect error" +expecteof "$clixon_netconf -qef $cfg -o CLICON_NETCONF_BASE_CAPABILITY=1" 255 "urn:ietf:params:netconf:base:1.1]]>]]>]]>]]>$" "" + +new "Netconf 1.1 chunked framing" +expecteof_netconf "$clixon_netconf -qef $cfg -o CLICON_NETCONF_BASE_CAPABILITY=1" 0 "urn:ietf:params:netconf:base:1.1]]>]]>" "" "" "a
" + +# cant use expecteof_netconf since it relies on a whole frame, here we split into multiple +rpc=$(cat <urn:ietf:params:netconf:base:1.1]]>]]> +#85 + +## +EOF + ) + +new "Netconf 1.1 multi-chunked framing" +expecteof_netconf "$clixon_netconf -qef $cfg -o CLICON_NETCONF_BASE_CAPABILITY=1" 0 "$rpc" "" "" "a
" + if [ $BE -ne 0 ]; then new "Kill backend" # Check if premature kill diff --git a/test/test_netconf_hello.sh b/test/test_netconf_hello.sh index daee14b8..84bf4e56 100755 --- a/test/test_netconf_hello.sh +++ b/test/test_netconf_hello.sh @@ -26,6 +26,7 @@ cat < $cfg /usr/local/lib/$APPNAME/backend example_backend.so$ /usr/local/lib/$APPNAME/netconf + 1 /usr/local/lib/$APPNAME/restconf /usr/local/lib/$APPNAME/cli $APPNAME @@ -62,50 +63,60 @@ wait_backend # Hello new "Netconf snd hello with xmldecl" -expecteof "$clixon_netconf -qf $cfg" 0 "urn:ietf:params:netconf:base:1.1]]>]]>" '^$' +expecteof "$clixon_netconf -qef $cfg" 0 "urn:ietf:params:netconf:base:1.0]]>]]>" '^$' # Hello, lowercase encoding -new "Netconf snd hello with xmldecl (lowercase encoding)" -expecteof "$clixon_netconf -qf $cfg" 0 "urn:ietf:params:netconf:base:1.1]]>]]>" '^$' +new "Netconf snd hello with xmldecl (cap 1.0)" +expecteof "$clixon_netconf -qef $cfg" 0 "urn:ietf:params:netconf:base:1.1]]>]]>" '^$' new "Netconf snd hello without xmldecl" -expecteof "$clixon_netconf -qf $cfg" 0 "urn:ietf:params:netconf:base:1.1]]>]]>" '^$' +expecteof "$clixon_netconf -qef $cfg" 0 "urn:ietf:params:netconf:base:1.1]]>]]>" '^$' -new "Netconf snd hello with RFC 4741 base capability" -expecteof "$clixon_netconf -qf $cfg" 0 "urn:ietf:params:netconf:base:1.0]]>]]>" '^$' +new "Netconf capability: 1.0 + 1.1 -> 1.0" +expecteof "$clixon_netconf -ef $cfg" 0 "urn:ietf:params:netconf:base:1.0]]>]]>" 'urn:ietf:params:netconf:base:1.0' + +new "Netconf capability: 1.1 + 1.1 -> 1.1" +expecteof "$clixon_netconf -ef $cfg" 0 "urn:ietf:params:netconf:base:1.1]]>]]>" 'urn:ietf:params:netconf:base:1.1' + +new "Netconf capability: 1.0 + 1.0 -> 1.0" +expecteof "$clixon_netconf -ef $cfg -o CLICON_NETCONF_BASE_CAPABILITY=0" 0 "urn:ietf:params:netconf:base:1.0]]>]]>" 'urn:ietf:params:netconf:base:1.0' + +new "Netconf capability: 1.1 + 1.0 -> Error" +expecteof "$clixon_netconf -ef $cfg -o CLICON_NETCONF_BASE_CAPABILITY=0" 255 "urn:ietf:params:netconf:base:1.1]]>]]>" 'urn:ietf:params:netconf:base:1.0' new "Netconf snd hello with wrong base capability" -expecteof "$clixon_netconf -qf $cfg" 0 "urn:ietf:params:netconf:base:1.2]]>]]>" '^$' 'Server received hello without netconf base capability urn:ietf:params:netconf:base:1.1' +expecteof "$clixon_netconf -qef $cfg" 255 "urn:ietf:params:netconf:base:1.2]]>]]>" '^$' 'Server received hello without matching netconf base capability' new "Netconf hello with MUST NOT have a session-id, terminate" -expecteof "$clixon_netconf -qf $cfg" 0 "42urn:ietf:params:netconf:base:1.2]]>]]>" '^$' +expecteof "$clixon_netconf -qef $cfg" 255 "42urn:ietf:params:netconf:base:1.2]]>]]>" '^$' # When comparing protocol version capability URIs, only the base part is used, in the event any # parameters are encoded at the end of the URI string. new "Netconf snd hello with base capability with extra arguments" -expecteof "$clixon_netconf -qf $cfg" 0 "urn:ietf:params:netconf:base:1.1?arg=val]]>]]>" '^$' +expecteof "$clixon_netconf -qef $cfg" 0 "urn:ietf:params:netconf:base:1.1?arg=val]]>]]>" '^$' new "Netconf hello with wrong namespace -> terminate" -expecteof "$clixon_netconf -qf $cfg" 0 "urn:ietf:params:netconf:base:1.1]]>]]>" '^$' 2> /dev/null +expecteof "$clixon_netconf -qef $cfg" 255 "urn:ietf:params:netconf:base:1.1]]>]]>" '^$' 2> /dev/null # This is hello - shouldnt really get rpc back? new "Netconf snd hello with wrong prefix" -expecteof "$clixon_netconf -qf $cfg" 0 "urn:ietf:params:netconf:base:1.1]]>]]>" '^$' 2> /dev/null +expecteof "$clixon_netconf -qef $cfg" 255 "urn:ietf:params:netconf:base:1.1]]>]]>" '^$' 2> /dev/null new "Netconf snd hello with prefix" -expecteof "$clixon_netconf -qf $cfg" 0 "urn:ietf:params:netconf:base:1.1]]>]]>" '^$' +expecteof "$clixon_netconf -qef $cfg" 0 "urn:ietf:params:netconf:base:1.1]]>]]>" '^$' new "netconf snd + rcv hello" -expecteof "$clixon_netconf -f $cfg" 0 "urn:ietf:params:netconf:base:1.1]]>]]>" "^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]*]]>]]>$" '^$' +expecteof "$clixon_netconf -f $cfg" 0 "urn:ietf:params:netconf:base:1.1]]>]]>" "^urn:ietf:params:netconf:base:1.1urn: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 snd hello with extra element" -expecteof "$clixon_netconf -qf $cfg" 0 "urn:ietf:params:netconf:base:1.1]]>]]>" '^protocolunknown-elementextra-elementerrorUnrecognized hello/capabilities element]]>]]>$' '^$' +expecteof "$clixon_netconf -qef $cfg" 0 "urn:ietf:params:netconf:base:1.1]]>]]>" '^protocolunknown-elementextra-elementerrorUnrecognized hello/capabilities element]]>]]>$' '^$' new "Netconf send rpc without hello error" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "rpcoperation-failederrorClient must send an hello element before any RPC]]>]]>" '^$' +expecteof "$clixon_netconf -qef $cfg" 255 "]]>]]>" "rpcoperation-failederrorClient must send an hello element before any RPC]]>]]>" '^$' +# same as -H new "Netconf send rpc without hello w CLICON_NETCONF_HELLO_OPTIONAL" -expecteof "$clixon_netconf -qf $cfg -o CLICON_NETCONF_HELLO_OPTIONAL=true" 0 "]]>]]>" "]]>]]>" '^$' +expecteof_netconf "$clixon_netconf -qef $cfg -o CLICON_NETCONF_HELLO_OPTIONAL=true" 0 "" "" "" "" if [ $BE -ne 0 ]; then new "Kill backend" diff --git a/test/test_netconf_notifications.sh b/test/test_netconf_notifications.sh index d5406485..d01fbfaf 100755 --- a/test/test_netconf_notifications.sh +++ b/test/test_netconf_notifications.sh @@ -109,30 +109,30 @@ wait_backend new "1. Netconf RFC5277 stream testing" # 1.1 Stream discovery new "netconf event stream discovery RFC5277 Sec 3.2.5" -expecteof "$clixon_netconf -D $DBG -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "EXAMPLEExample event streamtrue]]>]]>" +expecteof_netconf "$clixon_netconf -D $DBG -qef $cfg" 0 "$DEFAULTHELLO" "" "" "EXAMPLEExample event streamtrue" new "netconf EXAMPLE subscription" -expectwait "$clixon_netconf -D $DBG -qf $cfg" "$DEFAULTHELLOEXAMPLE]]>]]>" "^]]>]]>20" $NCWAIT +expectwait "$clixon_netconf -D $DBG -qef $cfg" 0 "$DEFAULTHELLO" "EXAMPLE" $NCWAIT "" "20" new "netconf subscription with empty startTime" -expecteof "$clixon_netconf -D $DBG -qf $cfg" 0 "$DEFAULTHELLOEXAMPLE]]>]]>" "^applicationbad-elementstartTimeerrorregexp match fail:" +expecteof_netconf "$clixon_netconf -D $DBG -qef $cfg" 0 "$DEFAULTHELLO" "EXAMPLE" "applicationbad-elementstartTimeerrorregexp match fail:" "" new "netconf EXAMPLE subscription with simple filter" -expectwait "$clixon_netconf -D $DBG -qf $cfg" "$DEFAULTHELLOEXAMPLE]]>]]>" "^]]>]]>20" $NCWAIT +expectwait "$clixon_netconf -D $DBG -qef $cfg" 0 "$DEFAULTHELLO" "EXAMPLE" $NCWAIT "" "20" new "netconf EXAMPLE subscription with filter classifier" -expectwait "$clixon_netconf -D $DBG -qf $cfg" "$DEFAULTHELLOEXAMPLE]]>]]>" "^]]>]]>20" $NCWAIT +expectwait "$clixon_netconf -D $DBG -qef $cfg" 0 "$DEFAULTHELLO" "EXAMPLE" $NCWAIT "" "20" new "netconf NONEXIST subscription" -expectwait "$clixon_netconf -D $DBG -qf $cfg" "$DEFAULTHELLONONEXIST]]>]]>" "^applicationinvalid-valueerrorNo such stream]]>]]>$" $NCWAIT +expectwait "$clixon_netconf -D $DBG -qef $cfg" 0 "$DEFAULTHELLO" "NONEXIST" $NCWAIT "applicationinvalid-valueerrorNo such stream" new "netconf EXAMPLE subscription with wrong date" -expectwait "$clixon_netconf -D $DBG -qf $cfg" "$DEFAULTHELLOEXAMPLEkallekaka]]>]]>" "^applicationbad-elementstartTimeerrorregexp match fail:" 0 +expectwait "$clixon_netconf -D $DBG -qef $cfg" 0 "$DEFAULTHELLO" "EXAMPLEkallekaka" 0 "applicationbad-elementstartTimeerrorregexp match fail:" #new "netconf EXAMPLE subscription with replay" #NOW=$(date +"%Y-%m-%dT%H:%M:%S") #sleep 10 -#expectwait "$clixon_netconf -D $DBG -qf $cfg" "$DEFAULTHELLOEXAMPLE$NOW]]>]]>" "^]]>]]>20" 10 +#expectwait "$clixon_netconf -D $DBG -qef $cfg" 0 "$DEFAULTHELLO" "EXAMPLE$NOW" 10 "^]]>]]>20" if [ $BE -ne 0 ]; then new "Kill backend" diff --git a/test/test_netconf_ssh_callhome.sh b/test/test_netconf_ssh_callhome.sh index 6533f0cb..b17f163e 100755 --- a/test/test_netconf_ssh_callhome.sh +++ b/test/test_netconf_ssh_callhome.sh @@ -42,6 +42,7 @@ cat < $cfg /usr/local/lib/$APPNAME/backend example_backend.so$ /usr/local/lib/$APPNAME/netconf + 1 $dir/$APPNAME.sock /usr/local/var/$APPNAME/$APPNAME.pidfile /usr/local/var/$APPNAME @@ -57,15 +58,8 @@ module clixon-example{ EOF cat < $rpccmd -$DEFAULTHELLO - - - - -]]>]]> - - -]]>]]> +$DEFAULTHELLO$(chunked_framing "") +$(chunked_framing "") EOF # Generate temporary ssh keys without passphrase @@ -138,7 +132,7 @@ EOF new "Start Listener client" echo "ssh -s -F $sshcfg -v -i $key -o ProxyUseFdpass=yes -o ProxyCommand=\"clixon_netconf_ssh_callhome_client -a 127.0.0.1\" . netconf" #-F $sshcfg -expectpart "$(ssh -s -F $sshcfg -v -i $key -o ProxyUseFdpass=yes -o ProxyCommand="${clixon_netconf_ssh_callhome_client} -a 127.0.0.1" . netconf < $rpccmd)" 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.02]]>]]>" "]]>]]>" +expectpart "$(ssh -s -F $sshcfg -v -i $key -o ProxyUseFdpass=yes -o ProxyCommand="${clixon_netconf_ssh_callhome_client} -a 127.0.0.1" . netconf < $rpccmd)" 0 "urn:ietf:params:netconf:base:1.1urn: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.02" "" # Wait wait diff --git a/test/test_netconf_whitespace.sh b/test/test_netconf_whitespace.sh index 90484b60..76793223 100755 --- a/test/test_netconf_whitespace.sh +++ b/test/test_netconf_whitespace.sh @@ -77,66 +77,66 @@ new "waiting" wait_backend new "get startup" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^foo]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "foo" new "remove" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "commit" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "add insignificant 'dirty' whitespaces" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO \t \ foo\n ]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" " \t \ foo\n " "" "" new "get stripped whitespace" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^foo]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "foo" new "validate" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "netconf discard-changes" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "add insignificant 'dirty' whitespaces with prefixes" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO \t \ foo\n ]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" " \t \ foo\n " "" "" new "get stripped whitespace" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^foo]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "foo" new "validate" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "netconf discard-changes" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "add insignificant 'clean' whitespaces" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO \n \t ]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" " \n \t " "" "" new "add more insignificant 'clean' whitespaces" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOfoo ]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "foo " "" "" new "get stripped whitespace" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^foo]]>]]>" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "foo" new "validate" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "netconf discard-changes" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "add significant whitespaces" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO foo - bar ]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" " foo + bar " "" "" new "get significant whitespace" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^ foo - bar ]]>]]>" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" " foo + bar " new "validate" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "netconf discard-changes" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" if [ $BE -ne 0 ]; then new "Kill backend" diff --git a/test/test_openconfig_interfaces.sh b/test/test_openconfig_interfaces.sh index 907a81e1..771af6f6 100755 --- a/test/test_openconfig_interfaces.sh +++ b/test/test_openconfig_interfaces.sh @@ -103,7 +103,7 @@ new "$clixon_cli -D $DBG -1f $cfg show version" expectpart "$($clixon_cli -D $DBG -1f $cfg show version)" 0 "${CLIXON_VERSION}" new "$clixon_netconf -qf $cfg" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^eeex:ethfalsetrue00]]>]]>" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "eeex:ethfalsetrue00" new "cli show configuration" expectpart "$($clixon_cli -1 -f $cfg show conf xml)" 0 "^" --not-- "" diff --git a/test/test_order.sh b/test/test_order.sh index a9af1028..71bb12ff 100755 --- a/test/test_order.sh +++ b/test/test_order.sh @@ -215,78 +215,78 @@ wait_backend #new "state data (should be unordered: 42,41,43)" # Eeh I changed that to sortered unless STATE_ORDERED_BY_SYSTEM new "state data (should be ordered: 41,42,43)" -cat < $tmp -$DEFAULTHELLO]]>]]> -EOF -expecteof "$clixon_netconf -qf $cfg" 0 "$(cat $tmp)" "414243]]>]]>" + +rpc=$(chunked_framing "") + +expecteof_netconf "$clixon_netconf -qef $cfg" 0 "$DEFAULTHELLO" "$rpc" "" "414243" # Check as file new "verify running from start, should be: c,l,y0,y1,y2,y3; y1 and y3 sorted." -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^hejhoppdbcaabcddbarabarcbarbbarabarbbarcbardbar]]>]]>$" +expecteof_netconf "$clixon_netconf -qef $cfg" 0 "$DEFAULTHELLO" "" "" "hejhoppdbcaabcddbarabarcbarbbarabarbbarcbardbar" new "get each ordered-by user leaf-list" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^abar]]>]]>$" +expecteof_netconf "$clixon_netconf -qef $cfg" 0 "$DEFAULTHELLO" "" "" "abar" new "get each ordered-by user leaf-list" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^abar]]>]]>$" +expecteof_netconf "$clixon_netconf -qef $cfg" 0 "$DEFAULTHELLO" "" "" "abar" new "get each ordered-by user leaf-list" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^bbar]]>]]>$" +expecteof_netconf "$clixon_netconf -qef $cfg" 0 "$DEFAULTHELLO" "" "" "bbar" new "get each ordered-by user leaf-list" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^bbar]]>]]>$" +expecteof_netconf "$clixon_netconf -qef $cfg" 0 "$DEFAULTHELLO" "" "" "bbar" new "delete candidate" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOnone]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qef $cfg" 0 "$DEFAULTHELLO" "none" "" "" # LEAF_LISTS new "add two entries (c,b) to leaf-list user order" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOcb]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qef $cfg" 0 "$DEFAULTHELLO" "cb" "" "" new "add one entry (a) to leaf-list user order" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOa]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qef $cfg" 0 "$DEFAULTHELLO" "a" "" "" new "netconf commit" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qef $cfg" 0 "$DEFAULTHELLO" "" "" "" new "add one entry (0) to leaf-list user order after commit" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO0]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qef $cfg" 0 "$DEFAULTHELLO" "0" "" "" new "netconf commit" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qef $cfg" 0 "$DEFAULTHELLO" "" "" "" new "verify leaf-list user order in running (as entered: c,b,a,0)" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^cba0]]>]]>$" +expecteof_netconf "$clixon_netconf -qef $cfg" 0 "$DEFAULTHELLO" "" "" "cba0" # LISTS new "add two entries to list user order" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOcbarbfoo]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qef $cfg" 0 "$DEFAULTHELLO" "cbarbfoo" "" "" new "add one entry to list user order" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOafie]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qef $cfg" 0 "$DEFAULTHELLO" "afie" "" "" new "verify list user order (as entered)" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^cbarbfooafie]]>]]>$" +expecteof_netconf "$clixon_netconf -qef $cfg" 0 "$DEFAULTHELLO" "" "" "cbarbfooafie" new "Overwrite existing ordered-by user y2->c" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO +expecteof_netconf "$clixon_netconf -qef $cfg" 0 "$DEFAULTHELLO" " cnewc -]]>]]>" +" new "Overwrite existing ordered-by user y2->b" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO +expecteof_netconf "$clixon_netconf -qef $cfg" 0 "$DEFAULTHELLO" " bnewb -]]>]]>" +" "" "" new "Overwrite existing ordered-by user y2->a" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO +expecteof_netconf "$clixon_netconf -qef $cfg" 0 "$DEFAULTHELLO" " anewa -]]>]]>" +" new "Tests for no duplicates." -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^cnewcbnewbanewa]]>]]>$" +expecteof_netconf "$clixon_netconf -qef $cfg" 0 "$DEFAULTHELLO" "" "" "cnewcbnewbanewa" #-- order by type rather than strings. # there are three leaf-lists:strings, ints, and decimal64, and two lists: @@ -295,154 +295,154 @@ expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO +expecteof_netconf "$clixon_netconf -qef $cfg" 0 "$DEFAULTHELLO" " 1021 -]]>]]>" "^]]>]]>$" +" "" "" new "check string order (1,10,2)" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^1102]]>]]>$" +expecteof_netconf "$clixon_netconf -qef $cfg" 0 "$DEFAULTHELLO" "" "" "1102" for s in int uint; do for t in 8 16 32 64; do type=$s$t new "put leaf-list $type (10,2,1)" - expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO + expecteof_netconf "$clixon_netconf -qef $cfg" 0 "$DEFAULTHELLO" " 1021 -]]>]]>" "^]]>]]>$" +" "" "" new "check leaf-list $type order (1,2,10)" - expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^1210]]>]]>$" + expecteof_netconf "$clixon_netconf -qef $cfg" 0 "$DEFAULTHELLO" "" "" "1210" done done new "netconf validate ints" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qef $cfg" 0 "$DEFAULTHELLO" "" "" "" new "put list int (10,2,1)" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO +expecteof_netconf "$clixon_netconf -qef $cfg" 0 "$DEFAULTHELLO" " 1021 -]]>]]>" "^]]>]]>$" +" "" "" new "check list int order (1,2,10)" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^1210]]>]]>$" +expecteof_netconf "$clixon_netconf -qef $cfg" 0 "$DEFAULTHELLO" "" "" "1210" new "put leaf-list decimal64 (10,2,1)" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO +expecteof_netconf "$clixon_netconf -qef $cfg" 0 "$DEFAULTHELLO" " 10.02.01.0 -]]>]]>" "^]]>]]>$" +" "" "" new "check leaf-list decimal64 order (1,2,10)" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^1.02.010.0]]>]]>$" +expecteof_netconf "$clixon_netconf -qef $cfg" 0 "$DEFAULTHELLO" "" "" "1.02.010.0" new "put list decimal64 (10,2,1)" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO +expecteof_netconf "$clixon_netconf -qef $cfg" 0 "$DEFAULTHELLO" " 10.02.01.0 -]]>]]>" "^]]>]]>$" +" "" "" new "check list decimal64 order (1,2,10)" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^1.02.010.0]]>]]>$" +expecteof_netconf "$clixon_netconf -qef $cfg" 0 "$DEFAULTHELLO" "" "" "1.02.010.0" new "delete candidate" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOnone]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qef $cfg" 0 "$DEFAULTHELLO" "none" "" "" new "netconf commit" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qef $cfg" 0 "$DEFAULTHELLO" "" "" "" # leaf-list ordered-by-user, "insert" and "value" attributes # y0 is leaf-list ordered by user new "add one entry (c) to leaf-list" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOc]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qef $cfg" 0 "$DEFAULTHELLO" "c" "" "" new "add one entry (a) to leaf-list first (with no yang namespace - error)" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOa]]>]]>" "^applicationbad-attributeinserterrorUnresolved attribute prefix (no namespace?)]]>]]>$" +expecteof_netconf "$clixon_netconf -qef $cfg" 0 "$DEFAULTHELLO" "a" "" "applicationbad-attributeinserterrorUnresolved attribute prefix (no namespace?)" new "add one entry (b) to leaf-list first" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOb]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qef $cfg" 0 "$DEFAULTHELLO" "b" "" "" new "add one entry (d) to leaf-list last" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOd]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qef $cfg" 0 "$DEFAULTHELLO" "d" "" "" new "add one entry (a) to leaf-list first" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOa]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qef $cfg" 0 "$DEFAULTHELLO" "a" "" "" new "add one entry (e) to leaf-list last" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOe]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qef $cfg" 0 "$DEFAULTHELLO" "e" "" "" new "check ordered-by-user: a,b,c,d,e" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^abcde]]>]]>$" +expecteof_netconf "$clixon_netconf -qef $cfg" 0 "$DEFAULTHELLO" "" "" "abcde" new "move one entry (e) to leaf-list first" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOe]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qef $cfg" 0 "$DEFAULTHELLO" "e" "" "" new "check ordered-by-user: e,a,b,c,d" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^eabcd]]>]]>$" +expecteof_netconf "$clixon_netconf -qef $cfg" 0 "$DEFAULTHELLO" "" "" "eabcd" # before and after and value attribute new "add one leaf-list entry 71 before b" -XML="$DEFAULTHELLO71]]>]]>" -expecteof "$clixon_netconf -qf $cfg" 0 "$XML" "^]]>]]>$" +XML="71" +expecteof_netconf "$clixon_netconf -qef $cfg" 0 "$DEFAULTHELLO" "$XML" "" "" new "add one entry 42 after b" -XML="$DEFAULTHELLO42]]>]]>" -expecteof "$clixon_netconf -qf $cfg" 0 "$XML" "^]]>]]>$" +XML="42" +expecteof_netconf "$clixon_netconf -qef $cfg" 0 "$DEFAULTHELLO" "$XML" "" "" # XXX actually not right error message, should be as RFC7950 Sec 15.7 new "add one entry 99 after Q (not found, error)" -XML="$DEFAULTHELLO99]]>]]>" -RES="^protocoloperation-failederrorbad-attribute: value, missing-instance: Q]]>]]>$" -expecteof "$clixon_netconf -qf $cfg" 0 "$XML" "$RES" +XML="99" + +expecteof_netconf "$clixon_netconf -qef $cfg" 0 "$DEFAULTHELLO" "$XML" "" "protocoloperation-failederrorbad-attribute: value, missing-instance: Q" new "check ordered-by-user: e,a,71,b,42,c,d" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^ea71b42cd]]>]]>$" +expecteof_netconf "$clixon_netconf -qef $cfg" 0 "$DEFAULTHELLO" "" "" "ea71b42cd" new "delete candidate" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOnone]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qef $cfg" 0 "$DEFAULTHELLO" "none" "" "" new "netconf commit" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qef $cfg" 0 "$DEFAULTHELLO" "" "" "" # list ordered-by-user, "insert" and "value" attributes # y2 is list ordered by user new "add one entry (key c) to list" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOcfoo]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qef $cfg" 0 "$DEFAULTHELLO" "cfoo" "" "" new "add one entry (key a) to list first (with no yang namespace - error)" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOafoo]]>]]>" "^applicationbad-attributeinserterrorUnresolved attribute prefix (no namespace?)]]>]]>$" +expecteof_netconf "$clixon_netconf -qef $cfg" 0 "$DEFAULTHELLO" "afoo" "" "applicationbad-attributeinserterrorUnresolved attribute prefix (no namespace?)" new "add one entry (key b) to list first" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLObbar]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qef $cfg" 0 "$DEFAULTHELLO" "bbar" "" "" new "add one entry (d) to list last" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOdfie]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qef $cfg" 0 "$DEFAULTHELLO" "dfie" "" "" new "add one entry (a) to list first" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOafoo]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qef $cfg" 0 "$DEFAULTHELLO" "afoo" "" "" new "add one entry (e) to list last" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOebar]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qef $cfg" 0 "$DEFAULTHELLO" "ebar" "" "" new "check ordered-by-user: a,b,c,d,e" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^afoobbarcfoodfieebar]]>]]>$" +expecteof_netconf "$clixon_netconf -qef $cfg" 0 "$DEFAULTHELLO" "" "" "afoobbarcfoodfieebar" new "move one entry (e) to list first" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOebar]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qef $cfg" 0 "$DEFAULTHELLO" "ebar" "" "" new "check ordered-by-user: e,a,b,c,d" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^ebarafoobbarcfoodfie]]>]]>$" +expecteof_netconf "$clixon_netconf -qef $cfg" 0 "$DEFAULTHELLO" "" "" "ebarafoobbarcfoodfie" # before and after and key attribute new "add one entry 71 before key b" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO71fie]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qef $cfg" 0 "$DEFAULTHELLO" "71fie" "" "" new "add one entry 42 after key b" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO42fum]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qef $cfg" 0 "$DEFAULTHELLO" "42fum" "" "" # XXX actually not right error message, should be as RFC7950 Sec 15.7 new "add one entry key 99 after Q (not found, error)" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO99bar]]>]]>" "^protocoloperation-failederrorbad-attribute: key, missing-instance: Q]]>]]>$" +expecteof_netconf "$clixon_netconf -qef $cfg" 0 "$DEFAULTHELLO" "99bar" "" "protocoloperation-failederrorbad-attribute: key, missing-instance: Q" new "check ordered-by-user: e,a,71,b,42,c,d" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^ebarafoo71fiebbar42fumcfoodfie]]>]]>$" +expecteof_netconf "$clixon_netconf -qef $cfg" 0 "$DEFAULTHELLO" "" "" "ebarafoo71fiebbar42fumcfoodfie" if [ $BE -ne 0 ]; then new "Kill backend" diff --git a/test/test_pagination_draft.sh b/test/test_pagination_draft.sh index 3d3146a3..3484815e 100755 --- a/test/test_pagination_draft.sh +++ b/test/test_pagination_draft.sh @@ -319,20 +319,20 @@ function testlimit() fi if [ -z "$list" ]; then - reply="]]>]]>$" + reply="" else - reply="alice$xmllist]]>]]>$" + reply="alice$xmllist" fi new "limit=$limit offset=$offset NETCONF get-config" - expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO$limitxmlstr$offsetxmlstr]]>]]>" "$reply" + expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "$limitxmlstr$offsetxmlstr" "" "$reply" if [ -z "$list" ]; then - reply="]]>]]>$" + reply="" else - reply="alice$xmllist]]>]]>$" + reply="alice$xmllist" fi new "limit=$limit offset=$offset NETCONF get" - expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO$limitxmlstr$offsetxmlstr]]>]]>" "$reply" + expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "$limitxmlstr$offsetxmlstr" "" "$reply" if [ -z "$list" ]; then reply="" diff --git a/test/test_pagination_state.sh b/test/test_pagination_state.sh index bcc2b2d5..5a3a2f39 100755 --- a/test/test_pagination_state.sh +++ b/test/test_pagination_state.sh @@ -135,15 +135,15 @@ xpath="$xpath0/es:numbers" testrun_start $xpath new "NETCONF get leaf-list member/numbers 0-10 alice" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO010]]>]]>" "^alice345678]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "010" "" "alice345678" # negative new "NETCONF get container, expect fail" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO010]]>]]>" "^applicationinvalid-valueerrorlist-pagination is enabled but target is not list or leaf-list]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "010" "" "applicationinvalid-valueerrorlist-pagination is enabled but target is not list or leaf-list" xpath="/es:members/es:member[es:member-id='bob']/es:stats/es:numbers" new "NETCONF get leaf-list member/numbers 0-10 bob" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO010]]>]]>" "^bob131415161718]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "010" "" "bob131415161718" testrun_stop @@ -152,7 +152,7 @@ xpath="/es:members/es:member/es:stats/es:numbers" testrun_start $xpath new "NETCONF get leaf-list member/numbers all" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO010]]>]]>" "^alice345678bob13141516]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "010" "" "alice345678bob13141516" testrun_stop diff --git a/test/test_pattern.sh b/test/test_pattern.sh index accecb4d..4da1fa40 100755 --- a/test/test_pattern.sh +++ b/test/test_pattern.sh @@ -400,16 +400,16 @@ function testrun(){ trunc=$(echo "$str"|cut -c1-15) new "pattern edit $leaf string: $trunc" - expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO<$leaf>$str]]>]]>" "^]]>]]>$" + expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "<$leaf>$str" "" "" if $mat; then new "netconf validate expected match" - expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" + expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" else new "netconf validate expected fail" - expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^applicationbad-element$leaferror" + expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "applicationbad-element$leaferror" "" new "netconf discard-changes" - expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" + expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "^" fi } diff --git a/test/test_perf_cli.sh b/test/test_perf_cli.sh index 993a7c9d..a0fd852a 100755 --- a/test/test_perf_cli.sh +++ b/test/test_perf_cli.sh @@ -98,13 +98,13 @@ new "test time exists" expectpart "$(time -p ls)" 0 new "netconf write large config" -expecteof_file "time -p $clixon_netconf -qf $cfg" 0 "$fconfig" "^]]>]]>$" 2>&1 | awk '/real/ {print $2}' +expecteof_file "time -p $clixon_netconf -qef $cfg" 0 "$fconfig" "^]]>]]>$" 2>&1 | awk '/real/ {print $2}' # Here, there are $perfnr entries in candidate # Now commit it from candidate to running new "netconf commit large config" -expecteof "time -p $clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" 2>&1 | awk '/real/ {print $2}' +expecteof "time -p $clixon_netconf -qef $cfg" 0 "]]>]]>" "^]]>]]>$" 2>&1 | awk '/real/ {print $2}' # CLI get. This takes a lot of time because expand_dbvar gets perfnr (eg 100000) entries # and loops over it. @@ -142,10 +142,10 @@ done echo "]]>]]>" >> $fconfig2 new "netconf replace large list-leaf config" -expecteof_file "time -p $clixon_netconf -qf $cfg" 0 "$fconfig2" "^]]>]]>$" 2>&1 | awk '/real/ {print $2}' +expecteof_file "time -p $clixon_netconf -qef $cfg" 0 "$fconfig2" "^]]>]]>$" 2>&1 | awk '/real/ {print $2}' new "netconf commit large leaf-list config" -expecteof "time -p $clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" 2>&1 | awk '/real/ {print $2}' +expecteof "time -p $clixon_netconf -qef $cfg" 0 "]]>]]>" "^]]>]]>$" 2>&1 | awk '/real/ {print $2}' # XXX No leafref cli tests diff --git a/test/test_perf_mem.sh b/test/test_perf_mem.sh index 0f9df80f..e6dd1ec2 100755 --- a/test/test_perf_mem.sh +++ b/test/test_perf_mem.sh @@ -91,7 +91,8 @@ function testrun(){ pid=$(cat $pidfile) new "netconf get stats" - res=$(echo "$DEFAULTHELLO]]>]]>" | $clixon_netconf -qf $cfg) + rpc=$(chunked_framing "") + res=$(echo "$DEFAULTHELLO$rpc" | $clixon_netconf -qef $cfg) # echo "res:$res" err0=$(echo "$res" | $clixon_util_xpath -p "/rpc-reply/rpc-error") err=${err0#"nodeset:"} diff --git a/test/test_perf_netconf.sh b/test/test_perf_netconf.sh index 7186cb6a..cd7d2849 100755 --- a/test/test_perf_netconf.sh +++ b/test/test_perf_netconf.sh @@ -26,9 +26,9 @@ if ! $TIMEFN true; then err "A working time function" "'$TIMEFN' does not work"; APPNAME=example -cfg=$dir/scaling-conf.xml +cfg=$dir/perf-netconf-conf.xml fyang=$dir/scaling.yang -fconfig=$dir/large.xml +fconfig=$dir/large.xml fconfigonly=$dir/config.xml # only config for test ftest=$dir/test.xml fconfig2=$dir/large2.xml # leaf-list @@ -98,30 +98,39 @@ for (( i=0; i<$perfnr; i++ )); do done echo -n "" >> $fconfigonly # No CR -echo -n "$DEFAULTHELLO" > $fconfig -cat $fconfigonly >> $fconfig -echo "]]>]]>" >> $fconfig +rpc="" +rpc+="$(cat $fconfigonly)" +rpc+="" + +echo -n "$DEFAULTHELLO" > $fconfig +echo "$(chunked_framing "$rpc")" >> $fconfig # Now take large config file and write it via netconf to candidate new "test time exists" expectpart "$(time -p ls)" 0 new "netconf write large config" -expecteof_file "time -p $clixon_netconf -qf $cfg" 0 "$fconfig" "^]]>]]>$" 2>&1 | awk '/real/ {print $2}' +expecteof_file "time -p $clixon_netconf -qef $cfg" 0 "$fconfig" "^$" 2>&1 | awk '/real/ {print $2}' # Here, there are $perfnr entries in candidate # Now commit it from candidate to running new "netconf commit large config" -expecteof "time -p $clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" 2>&1 | awk '/real/ {print $2}' +expecteof_netconf "time -p $clixon_netconf -qef $cfg" 0 "$DEFAULTHELLO" "" "" "" 2>&1 | awk '/real/ {print $2}' new "Check running-db contents" -echo "$DEFAULTHELLO]]>]]>" | $clixon_netconf -qf $cfg > $foutput +rpc=$(chunked_framing "") +echo "$DEFAULTHELLO$rpc" | $clixon_netconf -qef $cfg > $foutput + +rpc="" +rpc+="$(cat $fconfigonly)" +rpc+="" +echo "$(chunked_framing "$rpc")" >> $ftest # Create a file to compare with -echo -n "" > $ftest -cat $fconfigonly >> $ftest -echo -n "]]>]]>" >> $ftest +#echo -n "" > $ftest +#cat $fconfigonly >> $ftest +#echo -n "]]>]]>" >> $ftest ret=$(diff $ftest $foutput) if [ $? -ne 0 ]; then @@ -140,13 +149,15 @@ fi new "netconf get $perfreq small config 1 key index" { time -p for (( i=0; i<$perfreq; i++ )); do rnd=$(( ( RANDOM % $perfnr ) )) - echo "$DEFAULTHELLO]]>]]>" -done | $clixon_netconf -qf $cfg > /dev/null; } 2>&1 | awk '/real/ {print $2}' + rpc=$(chunked_framing "") + echo "$rpc" +done | $clixon_netconf -Hqef $cfg > /dev/null; } 2>&1 | awk '/real/ {print $2}' new "netconf get $perfreq small config 1 key index start/stop" { time -p for (( i=0; i<$perfreq; i++ )); do rnd=$(( ( RANDOM % $perfnr ) )) - echo "$DEFAULTHELLO]]>]]>" | $clixon_netconf -qf $cfg > /dev/null; + rpc=$(chunked_framing "") + echo "$DEFAULTHELLO$rpc" | $clixon_netconf -qef $cfg > /dev/null; done } 2>&1 | awk '/real/ {print $2}' @@ -154,63 +165,69 @@ done new "netconf get $perfreq small config 1 key + 1 non-key index" { time -p for (( i=0; i<$perfreq; i++ )); do rnd=$(( ( RANDOM % $perfnr ) )) - echo "$DEFAULTHELLO]]>]]>" -done | $clixon_netconf -qf $cfg > /dev/null; } 2>&1 | awk '/real/ {print $2}' + rpc=$(chunked_framing "") + echo "$rpc" +done | $clixon_netconf -Hqef $cfg > /dev/null; } 2>&1 | awk '/real/ {print $2}' # NETCONF add new "netconf add $perfreq small config" { time -p for (( i=0; i<$perfreq; i++ )); do rnd=$(( ( RANDOM % $perfnr ) )) - echo "$DEFAULTHELLO$rnd$rnd]]>]]>" -done | $clixon_netconf -qf $cfg > /dev/null; } 2>&1 | awk '/real/ {print $2}' + rpc=$(chunked_framing "$rnd$rnd") + echo "$rpc" +done | $clixon_netconf -Hqef $cfg > /dev/null; } 2>&1 | awk '/real/ {print $2}' # Instead of many small entries, get one large in netconf and restconf # cli? new "netconf get large config" -expecteof "time -p $clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^00112233" 2>&1 | awk '/real/ {print $2}' +expecteof_netconf "time -p $clixon_netconf -qef $cfg" 0 "$DEFAULTHELLO" "" "00112233" "" 2>&1 | awk '/real/ {print $2}' # Delete entries (last since entries are removed from db) new "netconf discard-changes" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qef $cfg" 0 "$DEFAULTHELLO" "" "" "" new "netconf delete $perfreq small config" { time -p for (( i=0; i<$perfreq; i++ )); do rnd=$(( ( RANDOM % $perfnr ) )) - echo "$DEFAULTHELLO$rnd]]>]]>" -done | $clixon_netconf -qf $cfg > /dev/null; } 2>&1 | awk '/real/ {print $2}' + rpc=$(chunked_framing "$rnd") + echo "$rpc" +done | $clixon_netconf -Hqef $cfg > /dev/null; } 2>&1 | awk '/real/ {print $2}' #new "netconf discard-changes" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qef $cfg" 0 "$DEFAULTHELLO" "" "" "" # Now do leaf-lists istead of leafs - -#new "generate leaf-list config" -echo -n "$DEFAULTHELLOreplace" > $fconfig2 +new "generate leaf-list config" +rpc="replace" for (( i=0; i<$perfnr; i++ )); do - echo -n "$i" >> $fconfig2 + rpc+="$i" done -echo "]]>]]>" >> $fconfig2 +rpc+="" + +echo -n "$DEFAULTHELLO" > $fconfig2 +echo "$(chunked_framing "$rpc")" >> $fconfig2 new "netconf replace large list-leaf config" -expecteof_file "time -p $clixon_netconf -qf $cfg" 0 "$fconfig2" "^]]>]]>$" 2>&1 | awk '/real/ {print $2}' +expecteof_file "time -p $clixon_netconf -qef $cfg" 0 "$fconfig2" "^$" 2>&1 | awk '/real/ {print $2}' new "netconf commit large leaf-list config" -expecteof "time -p $clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" 2>&1 | awk '/real/ {print $2}' +expecteof_netconf "time -p $clixon_netconf -qef $cfg" 0 "$DEFAULTHELLO" "" "" "" 2>&1 | awk '/real/ {print $2}' new "netconf add $perfreq small leaf-list config" { time -p for (( i=0; i<$perfreq; i++ )); do rnd=$(( ( RANDOM % $perfnr ) )) - echo "$DEFAULTHELLO$rnd]]>]]>" -done | $clixon_netconf -qf $cfg > /dev/null; } 2>&1 | awk '/real/ {print $2}' + rpc=$(chunked_framing "$rnd") + echo "$rpc" +done | $clixon_netconf -Hqef $cfg > /dev/null; } 2>&1 | awk '/real/ {print $2}' new "netconf add small leaf-list config" -expecteof "time -p $clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOx]]>]]>" "^]]>]]>$" 2>&1 | awk '/real/ {print $2}' +expecteof_netconf "time -p $clixon_netconf -qef $cfg" 0 "$DEFAULTHELLO" "x" "" "" 2>&1 | awk '/real/ {print $2}' new "netconf commit small leaf-list config" -expecteof "time -p $clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" 2>&1 | awk '/real/ {print $2}' +expecteof_netconf "time -p $clixon_netconf -qef $cfg" 0 "$DEFAULTHELLO" "" "" "" 2>&1 | awk '/real/ {print $2}' new "netconf get large leaf-list config" -expecteof "time -p $clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^01" 2>&1 | awk '/real/ {print $2}' +expecteof_netconf "time -p $clixon_netconf -qef $cfg" 0 "$DEFAULTHELLO" "" "01" "" if [ $BE -ne 0 ]; then new "Kill backend" diff --git a/test/test_perf_restconf.sh b/test/test_perf_restconf.sh index 7623de7b..fc08aee3 100755 --- a/test/test_perf_restconf.sh +++ b/test/test_perf_restconf.sh @@ -188,7 +188,7 @@ new "cli delete $perfreq small config" done } 2>&1 | awk '/real/ {print $2}' #new "netconf discard-changes" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qef $cfg" 0 "$DEFAULTHELLO" "" "" "" # XXX This takes time # 18.69 without startup feature @@ -213,16 +213,16 @@ new "netconf add $perfreq small leaf-list config" { time -p for (( i=0; i<$perfreq; i++ )); do rnd=$(( ( RANDOM % $perfnr ) )) echo "$DEFAULTHELLO$rnd]]>]]>" -done | $clixon_netconf -qf $cfg > /dev/null; } 2>&1 | awk '/real/ {print $2}' +done | $clixon_netconf -qef $cfg > /dev/null; } 2>&1 | awk '/real/ {print $2}' new "netconf add small leaf-list config" -expecteof "time -p $clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOx]]>]]>" "^]]>]]>$" 2>&1 | awk '/real/ {print $2}' +expecteof "time -p $clixon_netconf -qef $cfg" 0 "$DEFAULTHELLOx]]>]]>" "^]]>]]>$" 2>&1 | awk '/real/ {print $2}' new "netconf commit small leaf-list config" -expecteof "time -p $clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" 2>&1 | awk '/real/ {print $2}' +expecteof "time -p $clixon_netconf -qef $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" 2>&1 | awk '/real/ {print $2}' new "netconf get large leaf-list config" -expecteof "time -p $clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^01" 2>&1 | awk '/real/ {print $2}' +expecteof "time -p $clixon_netconf -qef $cfg" 0 "$DEFAULTHELLO]]>]]>" "^01" 2>&1 | awk '/real/ {print $2}' if [ $RC -ne 0 ]; then new "Kill restconf daemon" diff --git a/test/test_perf_restconf_ssl.sh b/test/test_perf_restconf_ssl.sh index 84bd0b76..94ab0a21 100755 --- a/test/test_perf_restconf_ssl.sh +++ b/test/test_perf_restconf_ssl.sh @@ -203,7 +203,7 @@ new "cli delete $perfreq small config" done } 2>&1 | awk '/real/ {print $2}' #new "netconf discard-changes" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qef $cfg" 0 "$DEFAULTHELLO" "" "" "" # XXX This takes time # 18.69 without startup feature @@ -227,17 +227,17 @@ expectpart "$(time -p curl $CURLOPTS -X PUT -H "Content-Type: application/yang-d new "netconf add $perfreq small leaf-list config" { time -p for (( i=0; i<$perfreq; i++ )); do rnd=$(( ( RANDOM % $perfnr ) )) - echo "$DEFAULTHELLO$rnd]]>]]>" -done | $clixon_netconf -qf $cfg > /dev/null; } 2>&1 | awk '/real/ {print $2}' + rpc=$(chunked_framing "$rnd") +done | $clixon_netconf -Hqf $cfg > /dev/null; } 2>&1 | awk '/real/ {print $2}' new "netconf add small leaf-list config" -expecteof "time -p $clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOx]]>]]>" "^]]>]]>$" 2>&1 | awk '/real/ {print $2}' +expecteof_netconf "time -p $clixon_netconf -qef $cfg" 0 "$DEFAULTHELLO" "x" "" "" 2>&1 | awk '/real/ {print $2}' new "netconf commit small leaf-list config" -expecteof "time -p $clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" 2>&1 | awk '/real/ {print $2}' +expecteof_netconf "time -p $clixon_netconf -qef $cfg" 0 "$DEFAULTHELLO" "" "" "" 2>&1 | awk '/real/ {print $2}' new "netconf get large leaf-list config" -expecteof "time -p $clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^01" 2>&1 | awk '/real/ {print $2}' +expecteof_netconf "time -p $clixon_netconf -qef $cfg" 0 "$DEFAULTHELLO" "" "01" "" 2>&1 | awk '/real/ {print $2}' if [ $RC -ne 0 ]; then new "Kill restconf daemon" diff --git a/test/test_perf_state.sh b/test/test_perf_state.sh index ddef0656..6ef8fc23 100755 --- a/test/test_perf_state.sh +++ b/test/test_perf_state.sh @@ -123,35 +123,42 @@ fi new "wait restconf" wait_restconf -new "generate 'large' config with $perfnr list entries" -echo -n "$DEFAULTHELLOfoo" > $fconfig +rpc="" +rpc+="foo" for (( i=0; i<$perfnr; i++ )); do - echo -n "e$iex:eth" >> $fconfig + rpc+="e$iex:eth" done -echo "]]>]]>" >> $fconfig +rpc+="" +rpc+="$(cat $fconfig)" +rpc+="" +echo foo +echo -n "$DEFAULTHELLO" > $fconfig +echo "$(chunked_framing "$rpc")" >> $fconfig # Now take large config file and write it via netconf to candidate new "netconf write large config" -expecteof_file "time -p $clixon_netconf -qf $cfg" 0 "$fconfig" "^]]>]]>$" 2>&1 | awk '/real/ {print $2}' +expecteof_file "time -p $clixon_netconf -qef $cfg" 0 "$fconfig" "^$" 2>&1 | awk '/real/ {print $2}' # Now commit it from candidate to running new "netconf commit large config" -expecteof "time -p $clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" 2>&1 | awk '/real/ {print $2}' +expecteof_netconf "time -p $clixon_netconf -qef $cfg" 0 "$DEFAULTHELLO" "" "" "" 2>&1 | awk '/real/ {print $2}' # START actual tests # Having a large db, get single entries many times # NETCONF get new "netconf get test single req" sel="/ex:interfaces/ex:a[ex:name='foo']/ex:b/ex:interface[ex:name='e1']" -msg="$DEFAULTHELLO]]>]]>" -expecteof "$clixon_netconf -qf $cfg" 0 "$msg" "^fooe1ex:ethtrueup]]>]]>$" +rpc=$(chunked_framing "") + +expecteof_netconf "$clixon_netconf -qef $cfg" 0 "$DEFAULTHELLO" "$rpc" "" "fooe1ex:ethtrueup" new "netconf get $perfreq single reqs" { time -p for (( i=0; i<$perfreq; i++ )); do rnd=$(( ( RANDOM % $perfnr ) )) sel="/ex:interfaces/ex:a[ex:name='foo']/ex:b/ex:interface[ex:name='e$rnd']" - echo "$DEFAULTHELLO]]>]]>" -done | $clixon_netconf -qf $cfg > /dev/null; } 2>&1 | awk '/real/ {print $2}' + rpc=$(chunked_framing "") + echo "$rpc" +done | $clixon_netconf -Hqef $cfg > /dev/null; } 2>&1 | awk '/real/ {print $2}' # RESTCONF get new "restconf get test single req" @@ -181,7 +188,8 @@ done } 2>&1 | awk '/real/ {print $2}' # Get config in one large get new "netconf get large config" -{ time -p echo "$DEFAULTHELLO ]]>]]>" | $clixon_netconf -qf $cfg > /tmp/netconf; } 2>&1 | awk '/real/ {print $2}' +rpc=$(chunked_framing " ") +{ time -p echo "$DEFAULTHELLO$rpc" | $clixon_netconf -qef $cfg > /dev/null; } 2>&1 | awk '/real/ {print $2}' new "restconf get large config" $TIMEFN curl $CURLOPTS -X GET $RCPROTO://localhost/restconf/data/example:interfaces/a=foo/b 2>&1 | awk '/real/ {print $2}' diff --git a/test/test_perf_state_only.sh b/test/test_perf_state_only.sh index 8ffb2e93..9165f844 100755 --- a/test/test_perf_state_only.sh +++ b/test/test_perf_state_only.sh @@ -128,21 +128,21 @@ new "cli get large config" # baseline on thinkpad i5-3320M CPU @ 2.60GHz and 500K entries: 39.71s $TIMEFN $clixon_cli -1f $cfg show xpath /interfaces urn:example:clixon 2>&1 > /dev/null | awk '/real/ {print $2}' - # START actual tests # Having a large db, get single entries many times # NETCONF get new "netconf get test single req" sel="/ex:interfaces/ex:a[ex:name='foo']/ex:b/ex:interface[ex:name='e1']" -msg="$DEFAULTHELLO]]>]]>" -time -p expecteof "$clixon_netconf -qf $cfg" 0 "$msg" "^fooe1ex:ethup]]>]]>$" +rpc=$(chunked_framing "") +time -p expecteof_netconf "$clixon_netconf -qef $cfg" 0 "$DEFAULTHELLO" "$rpc" "" "fooe1ex:ethup" new "netconf get $perfreq single reqs" { time -p for (( i=0; i<$perfreq; i++ )); do rnd=$(( ( RANDOM % $perfnr ) )) sel="/ex:interfaces/ex:a[ex:name='foo']/ex:b/ex:interface[ex:name='e$rnd']" - echo "$DEFAULTHELLO]]>]]>" -done | $clixon_netconf -qf $cfg > /dev/null; } 2>&1 | awk '/real/ {print $2}' + rpc=$(chunked_framing "") + echo "$rpc" +done | $clixon_netconf -Hqef $cfg > /dev/null; } 2>&1 | awk '/real/ {print $2}' # RESTCONF get #echo "curl $CURLOPTS -X GET $RCPROTO://localhost/restconf/data/example:interfaces/a=foo/b/interface=e1" @@ -175,7 +175,8 @@ fi # Get config in one large get new "netconf get large config" -{ time -p echo "$DEFAULTHELLO ]]>]]>" | $clixon_netconf -qf $cfg > /tmp/netconf; } 2>&1 | awk '/real/ {print $2}' +rpc=$(chunked_framing " ") +{ time -p echo "$DEFAULTHELLO$rpc" | $clixon_netconf -qef $cfg > /dev/null; } 2>&1 | awk '/real/ {print $2}' new "restconf get large config" $TIMEFN curl $CURLOPTS -X GET $RCPROTO://localhost/restconf/data/example:interfaces/a=foo/b 2>&1 | awk '/real/ {print $2}' diff --git a/test/test_restconf.sh b/test/test_restconf.sh index 89bf7268..d2d04137 100755 --- a/test/test_restconf.sh +++ b/test/test_restconf.sh @@ -144,10 +144,10 @@ function testrun() wait_backend new "netconf edit config" - expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO$RESTCONFIG1]]>]]>" "^]]>]]>$" + expecteof_netconf "$clixon_netconf -qef $cfg" 0 "$DEFAULTHELLO" "$RESTCONFIG1" "" "" new "netconf commit" - expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" + expecteof_netconf "$clixon_netconf -qef $cfg" 0 "$DEFAULTHELLO" "" "" "" if [ $RC -ne 0 ]; then new "kill old restconf daemon" diff --git a/test/test_restconf_internal.sh b/test/test_restconf_internal.sh index 908090a1..5b2147ad 100755 --- a/test/test_restconf_internal.sh +++ b/test/test_restconf_internal.sh @@ -97,14 +97,9 @@ function rpcstatus() sleep $DEMSLEEP new "send rpc status" - retx=$($clixon_netconf -qf $cfg< - - restconf - status - -]]>]]> + rpc=$(chunked_framing "restconfstatus") + retx=$($clixon_netconf -qef $cfg<restconf$operation]]>]]>" "^]]>]]>$" + expecteof_netconf "$clixon_netconf -qef $cfg" 0 "$DEFAULTHELLO" "restconf$operation" "" "" sleep $DEMSLEEP } @@ -410,10 +406,10 @@ rpcstatus false stopped if [ $pid -ne 0 ]; then err "Pid" "$pid"; fi new "Enable restconf" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOmergetrue$RESTCONFDBG$LOGDST]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qef $cfg" 0 "$DEFAULTHELLO" "mergetrue$RESTCONFDBG$LOGDST" "" "" new "commit enable" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qef $cfg" 0 "$DEFAULTHELLO" "" "" "" new "16. check status RPC on" rpcstatus true running @@ -454,10 +450,10 @@ if [ $pid2 -ne $pid3 ]; then fi new "Disable restconf" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOmergefalse]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qef $cfg" 0 "$DEFAULTHELLO" "mergefalse" "" "" new "commit disable" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qef $cfg" 0 "$DEFAULTHELLO" "" "" "" sleep $DEMSLEEP @@ -468,10 +464,10 @@ if [ $pid -ne 0 ]; then err "Pid" "$pid"; fi # Negative validation checks of clixon-restconf / socket new "netconf edit config invalid ssl" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOtruedefault
0.0.0.0
80true
]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qef $cfg" 0 "$DEFAULTHELLO" "truedefault
0.0.0.0
80true
" "" "" new "netconf validate should fail" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^applicationoperation-failederrorSSL enabled but server-cert-path not set]]>]]>$" +expecteof_netconf "$clixon_netconf -qef $cfg" 0 "$DEFAULTHELLO" "" "" "applicationoperation-failederrorSSL enabled but server-cert-path not set" # stop backend if [ $BE -ne 0 ]; then diff --git a/test/test_restconf_internal_usecases.sh b/test/test_restconf_internal_usecases.sh index 75bc396e..b6d57da9 100755 --- a/test/test_restconf_internal_usecases.sh +++ b/test/test_restconf_internal_usecases.sh @@ -112,14 +112,9 @@ function rpcstatus() sleep $DEMSLEEP new "send rpc status" - retx=$($clixon_netconf -qf $cfg< - - restconf - status - -]]>]]> + rpc=$(chunked_framing "restconfstatus") + retx=$($clixon_netconf -qef $cfg<$RESTCONFIG1]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qef $cfg" 0 "$DEFAULTHELLO" "$RESTCONFIG1" "" "" new "commit minimal server" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qef $cfg" 0 "$DEFAULTHELLO" "" "" "" new "2. get status, get pid1" rpcstatus true running @@ -211,10 +206,10 @@ RESTCONFIG2=$(cat <$RESTCONFIG2]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qef $cfg" 0 "$DEFAULTHELLO" "$RESTCONFIG2" "" "" new "commit create server" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qef $cfg" 0 "$DEFAULTHELLO" "" "" "" new "4. get status" rpcstatus true running @@ -268,10 +263,10 @@ EOF ) new "Create server with invalid address" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO$RESTCONFIG1]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qef $cfg" 0 "$DEFAULTHELLO" "$RESTCONFIG1" "" "" new "commit invalid server" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qef $cfg" 0 "$DEFAULTHELLO" "" "" "" sleep $DEMSLEEP new "Check zombies" @@ -339,10 +334,10 @@ EOF ) new "Create server" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO$RESTCONFIG1]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qef $cfg" 0 "$DEFAULTHELLO" "$RESTCONFIG1" "" "" new "commit create" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qef $cfg" 0 "$DEFAULTHELLO" "" "" "" new "wait restconf" wait_restconf @@ -359,10 +354,10 @@ expectpart "$(curl $CURLOPTS -X GET -H 'Accept: application/yang-data+xml' $RCPR # remove it new "Delete server" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOnonedefault
0.0.0.0
80
]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qef $cfg" 0 "$DEFAULTHELLO" "nonedefault
0.0.0.0
80
" "" "" new "commit delete" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qef $cfg" 0 "$DEFAULTHELLO" "" "" "" # Here restconf should have been restarted with no listener, the process is up but does not # reply on restconf @@ -434,10 +429,10 @@ EOF ) new "Create server" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO$RESTCONFIG1]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qef $cfg" 0 "$DEFAULTHELLO" "$RESTCONFIG1" "" "" new "commit create" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qef $cfg" 0 "$DEFAULTHELLO" "" "" "" new "wait restconf" wait_restconf diff --git a/test/test_restconf_netns.sh b/test/test_restconf_netns.sh index 48eb61b3..bc73d5bb 100755 --- a/test/test_restconf_netns.sh +++ b/test/test_restconf_netns.sh @@ -190,10 +190,10 @@ new "wait restconf" wait_restconf http # force to http on host ns new "add sample config w netconf" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOa42
]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "a42
" "" "" new "netconf commit" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" # NOTE http/1.1 if ${HAVE_HTTP1}; then diff --git a/test/test_restconf_notifications.sh b/test/test_restconf_notifications.sh index ef27c40a..de5441fa 100755 --- a/test/test_restconf_notifications.sh +++ b/test/test_restconf_notifications.sh @@ -162,7 +162,7 @@ sleep $SLEEP2 new "restconf monitor event nonexist stream" # Note cant use -S or -i here, the former dont know, latter because expectwait cant take # partial returns like expectpart can -expectwait "curl -sk -X GET -H \"Accept: text/event-stream\" -H \"Cache-Control: no-cache\" -H \"Connection: keep-alive\" $RCPROTO://localhost/streams/NOTEXIST" 0 'applicationinvalid-valueerrorNo such stream' 2 +expectwait "curl -sk -X GET -H \"Accept: text/event-stream\" -H \"Cache-Control: no-cache\" -H \"Connection: keep-alive\" $RCPROTO://localhost/streams/NOTEXIST" 0 "" "" 2 'applicationinvalid-valueerrorNo such stream' # 2a) start subscription 8s - expect 1-2 notifications new "2a) start subscriptions 8s - expect 1-2 notifications" diff --git a/test/test_rpc.sh b/test/test_rpc.sh index 63d420bf..ecf52211 100755 --- a/test/test_rpc.sh +++ b/test/test_rpc.sh @@ -223,7 +223,7 @@ if [ -z "$match" ]; then fi new "netconf empty rpc" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qef $cfg" 0 "$DEFAULTHELLO" "" "" "" new "restconf example rpc json/json default - no http media headers" expectpart "$(curl $CURLOPTS -X POST -H "Content-Type: application/yang-data+json" -d '{"clixon-example:input":{"x":0}}' $RCPROTO://localhost/restconf/operations/clixon-example:example)" 0 "HTTP/$HVER 200" 'Content-Type: application/yang-data+json' '{"clixon-example:output":{"x":"0","y":"42"}}' @@ -251,7 +251,7 @@ new "restconf example rpc json in xml encoding (expect fail)" expectpart "$(curl $CURLOPTS -X POST -H 'Content-Type: application/yang-data+xml' -H 'Accept: application/yang-data+xml' -d '{"clixon-example:input":{"x":"0"}}' $RCPROTO://localhost/restconf/operations/clixon-example:example)" 0 "HTTP/$HVER 400" 'rpcmalformed-messageerrorxml_parse: line 0: syntax error: at or before: "' new "netconf example rpc" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO0]]>]]>" "^042]]>]]>$" +expecteof_netconf "$clixon_netconf -qef $cfg" 0 "$DEFAULTHELLO" "0" "" "042" # 2. Then error cases # @@ -290,28 +290,28 @@ new "restconf example missing input" expectpart "$(curl $CURLOPTS -X POST -H "Content-Type: application/yang-data+json" -d '{"clixon-example:input":null}' $RCPROTO://localhost/restconf/operations/ietf-netconf:edit-config)" 0 "HTTP/$HVER 400" '{"ietf-restconf:errors":{"error":{"error-type":"application","error-tag":"missing-element","error-info":{"bad-element":"target"},"error-severity":"error","error-message":"Mandatory variable of edit-config in module ietf-netconf"}}} ' new "netconf kill-session missing session-id mandatory" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^applicationmissing-elementsession-iderrorMandatory variable of kill-session in module ietf-netconf]]>]]>$" +expecteof_netconf "$clixon_netconf -qef $cfg" 0 "$DEFAULTHELLO" "" "" "applicationmissing-elementsession-iderrorMandatory variable of kill-session in module ietf-netconf" new "netconf edit-config ok" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qef $cfg" 0 "$DEFAULTHELLO" "" "" "" if ! $YANG_UNKNOWN_ANYDATA ; then new "netconf edit-config extra arg: should fail" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^applicationunknown-elementextraerrorFailed to find YANG spec of XML node: extra with parent: edit-config in namespace: urn:ietf:params:xml:ns:netconf:base:1.0]]>]]>$" +expecteof_netconf "$clixon_netconf -qef $cfg" 0 "$DEFAULTHELLO" "" "" "applicationunknown-elementextraerrorFailed to find YANG spec of XML node: extra with parent: edit-config in namespace: urn:ietf:params:xml:ns:netconf:base:1.0" fi new "netconf edit-config empty target: should fail" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^applicationdata-missingmissing-choiceconfig-targeterror]]>]]>$" +expecteof_netconf "$clixon_netconf -qef $cfg" 0 "$DEFAULTHELLO" "" "" "applicationdata-missingmissing-choiceconfig-targeterror" new "netconf edit-config missing target: should fail" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^applicationmissing-elementtargeterrorMandatory variable of edit-config in module ietf-netconf]]>]]>$" +expecteof_netconf "$clixon_netconf -qef $cfg" 0 "$DEFAULTHELLO" "" "" "applicationmissing-elementtargeterrorMandatory variable of edit-config in module ietf-netconf" new "netconf edit-config missing config: should fail" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^applicationdata-missingmissing-choiceedit-contenterror]]>]]>$" +expecteof_netconf "$clixon_netconf -qef $cfg" 0 "$DEFAULTHELLO" "" "" "applicationdata-missingmissing-choiceedit-contenterror" # Negative errors (namespace/module missing) new "netconf wrong rpc namespace: should fail" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^applicationunknown-elementgeterrorUnrecognized RPC (wrong namespace?)]]>]]>$" +expecteof_netconf "$clixon_netconf -qef $cfg" 0 "$DEFAULTHELLO" "" "" "applicationunknown-elementgeterrorUnrecognized RPC (wrong namespace?)" new "restconf wrong rpc: should fail" expectpart "$(curl $CURLOPTS -X POST -H "Content-Type: application/yang-data+json" $RCPROTO://localhost/restconf/operations/clixon-foo:get)" 0 "HTTP/$HVER 412" '{"ietf-restconf:errors":{"error":{"error-type":"protocol","error-tag":"operation-failed","error-severity":"error","error-message":"yang module not found"}}}' @@ -320,10 +320,10 @@ expectpart "$(curl $CURLOPTS -X POST -H "Content-Type: application/yang-data+jso LIST='foobarbar' # On docker /fcgi the return is bar,foo,bar -new "netconf example rpc input list without key with non-unique entries" -ret=$($clixon_netconf -qf $cfg <mandatory$LIST]]>]]> +new "netconf example rpc input list without key with non-unique entriesxxx" +rpc=$(chunked_framing "mandatory$LIST") +ret=$($clixon_netconf -qef $cfg <mandatory42" '' 'foobar' "
]]>]]>$"; do +for expect in "mandatory42" '' 'foobar' ""; do new "expect:$expect" match=`echo $ret | grep --null -Eo "$expect"` if [ -z "$match" ]; then @@ -341,24 +341,24 @@ done LIST='bar1foo2' new "netconf example rpc input list with key" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOmandatory$LIST]]>]]>" "^mandatory42$LIST]]>]]>$" +expecteof_netconf "$clixon_netconf -qef $cfg" 0 "$DEFAULTHELLO" "mandatory$LIST" "" "mandatory42$LIST" LIST='bar12' new "netconf example rpc input key list without key (should fail)" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOmandatory$LIST]]>]]>" "^applicationmissing-elementukerrorMandatory key]]>]]>$" +expecteof_netconf "$clixon_netconf -qef $cfg" 0 "$DEFAULTHELLO" "mandatory$LIST" "" "applicationmissing-elementukerrorMandatory key" LIST='bar1bar2' new "netconf example rpc input list with non-unique keys (should fail)" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOmandatory$LIST]]>]]>" "^applicationoperation-faileddata-not-uniqueerroruk]]>]]>$" +expecteof_netconf "$clixon_netconf -qef $cfg" 0 "$DEFAULTHELLO" "mandatory$LIST" "" "applicationoperation-faileddata-not-uniqueerroruk" new "netconf choice ok" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO42xxx]]>]]>" "^4242xxx]]>]]>$" +expecteof_netconf "$clixon_netconf -qef $cfg" 0 "$DEFAULTHELLO" "42xxx" "" "4242xxx" new "netconf choice not-case expect fail" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO42xx]]>]]>" "^applicationbad-elementb1errorElement in choice statement already exists]]>]]>$" +expecteof_netconf "$clixon_netconf -qef $cfg" 0 "$DEFAULTHELLO" "42xx" "" "applicationbad-elementb1errorElement in choice statement already exists" new "netconf choice case expect fail" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO42xx]]>]]>" "^applicationbad-elementb2errorElement in choice statement already exists]]>]]>$" +expecteof_netconf "$clixon_netconf -qef $cfg" 0 "$DEFAULTHELLO" "42xx" "" "applicationbad-elementb2errorElement in choice statement already exists" if [ $RC -ne 0 ]; then new "Kill restconf daemon" diff --git a/test/test_startup.sh b/test/test_startup.sh index b0c12ad8..1eb8918f 100755 --- a/test/test_startup.sh +++ b/test/test_startup.sh @@ -131,13 +131,13 @@ function testrun(){ sleep $BETIMEOUT fi new "Startup test for $mode mode, check running" - expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^$exprun]]>]]>$" + expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "$exprun" new "Startup test for $mode mode, check candidate" - expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^$exprun]]>]]>$" + expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "$exprun" new "Startup test for $mode mode, check startup is untouched" - expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^$sdb]]>]]>$" + expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "$sdb" new "Kill backend" # Check if premature kill diff --git a/test/test_submodule.sh b/test/test_submodule.sh index c9ee7647..674960c3 100755 --- a/test/test_submodule.sh +++ b/test/test_submodule.sh @@ -204,7 +204,7 @@ new "wait restconf" wait_restconf new "netconfig edit main module" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO
foofoo
]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "
foofoo
" "" "" new "cli edit main" expectpart "$($clixon_cli -1f $cfg set main x bar)" 0 "" @@ -213,7 +213,7 @@ new "cli edit main ext" expectpart "$($clixon_cli -1f $cfg set main ext bar)" 0 "" new "netconfig edit sub1" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOfoofoo]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "foofoo" "" "" new "cli edit sub1" expectpart "$($clixon_cli -1f $cfg set sub1 x bar)" 0 "" @@ -222,7 +222,7 @@ new "cli edit sub1 ext" expectpart "$($clixon_cli -1f $cfg set sub1 ext1 bar)" 0 "" new "netconfig edit sub2 module" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOfoofoo]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "foofoo" "" "" new "cli edit sub2" expectpart "$($clixon_cli -1f $cfg set sub2 x fum)" 0 "" @@ -231,10 +231,10 @@ new "cli edit sub2 ext" expectpart "$($clixon_cli -1f $cfg set sub2 ext2 fum)" 0 "" new "netconf submodule validate" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "netconf discard-changes" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" # Now same with restconf new "restconf edit main" @@ -263,7 +263,7 @@ new "restconf edit augment 2" expectpart "$(curl $CURLOPTS -X POST -H "Content-Type: application/yang-data+json" $RCPROTO://localhost/restconf/data/main:sub2 -d '{"main:aug2":"foo"}')" 0 "HTTP/$HVER 201" new "NETCONF get module state" -expecteof "$clixon_netconf -qf $cfg -D $DBG" 0 "$DEFAULTHELLO]]>]]>" "defaultmain2021-03-08urn:example:clixonsub1A" +expecteof_netconf "$clixon_netconf -qf $cfg -D $DBG" 0 "$DEFAULTHELLO" "" "defaultmain2021-03-08urn:example:clixonsub1A" "" new "RESTCONF get module state" expectpart "$(curl $CURLOPTS -X GET -H "Accept: application/yang-data+xml" $RCPROTO://localhost/restconf/data/ietf-yang-library:yang-library/module-set=default/module=main?config=nonconfig)" 0 "HTTP/$HVER 200" "main2021-03-08urn:example:clixonsub1A" diff --git a/test/test_transaction.sh b/test/test_transaction.sh index d6db5691..e12dea40 100755 --- a/test/test_transaction.sh +++ b/test/test_transaction.sh @@ -135,10 +135,10 @@ wait_backend let nr=0 new "Basic transaction to add top-level x" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO$nr]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "$nr" "" "" new "Commit base" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" let line=14 # Skipping basic transaction @@ -146,10 +146,10 @@ let line=14 # Skipping basic transaction let nr++ let line new "1. Validate-only transaction" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO$nr]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "$nr" "" "" new "Validate-only validate" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" xml="$nr" for op in begin validate complete end; do @@ -160,15 +160,15 @@ for op in begin validate complete end; do done new "Validate-only discard-changes" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" # 2. Commit transaction let nr++ new "2. Commit transaction config" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO$nr]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "$nr" "" "" new "Commit transaction: commit" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" xml="$nr" for op in begin validate complete commit commit_done end; do @@ -181,13 +181,13 @@ done # 3. Validate only system-error (invalid type detected by system) let nr++ new "3. Validate system-error config (9999 not in range)" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO$nr9999]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "$nr9999" "" "" new "Validate system-error validate (should fail)" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^applicationbad-elementberrorNumber 9999 out of range: 0 - 100]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "applicationbad-elementberrorNumber 9999 out of range: 0 - 100" new "Validate system-error discard-changes" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" for op in begin abort; do checklog "$nr main_$op add: $nr9999" $line @@ -199,13 +199,13 @@ done # 4. Validate only user-error (invalidation by user callback) let nr++ new "4. Validate user-error config ($errnr is invalid)" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO$errnr]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "$errnr" "" "" new "Validate user-error validate (should fail)" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^applicationoperation-failederrorUser error]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "applicationoperation-failederrorUser error" new "Validate user-error discard-changes" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" for op in begin validate; do checklog "$nr main_$op add: $errnr" $line @@ -226,13 +226,13 @@ done # in nacm/transaction example test module let nr++ new "5. Commit user-error ($errnr is invalid)" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO$errnr]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "$errnr" "" "" new "Commit user-error commit" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^applicationoperation-failederrorUser error]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "applicationoperation-failederrorUser error" new "Commit user-error discard-changes" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" for op in begin validate complete commit ; do checklog "$nr main_$op add: $errnr" $line @@ -255,19 +255,19 @@ done let nr++ let base=nr new "Add base $base entry" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO$base00]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "$base00" "" "" new "netconf commit base" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" #Ignore let line+=12 let nr++ new "6. netconf mixed change: change b, del c, add d" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO$base420]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "$base420" "" "" new "netconf commit change" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" # Check complete transaction $nr: for op in begin validate complete commit commit_done; do @@ -291,19 +291,19 @@ let line+=3 # skip nacm let nr++ let base=nr new "Add base $base entry" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO$base1]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "$base1" "" "" new "netconf commit base" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" let line+=12 # Variant check that only b,c let nr++ new "7. netconf insert b,c between end-points" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO$base11]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "$base11" "" "" new "netconf commit base" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" # check complete for op in begin validate complete commit commit_done end; do @@ -316,17 +316,17 @@ done # Variant check that only b,c new "8. Set first choice" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOtrue]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "true" "" "" new "netconf commit same" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "Set second choice" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOtrue]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "true" "" "" # choice chanmge with same value did not show up in log new "netconf commit second" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" let nr++ let nr++ diff --git a/test/test_transaction_restart.sh b/test/test_transaction_restart.sh index 76ea9c5d..e5e5e208 100755 --- a/test/test_transaction_restart.sh +++ b/test/test_transaction_restart.sh @@ -105,17 +105,17 @@ wait_backend let nr=0 new "Basic transaction to add top-level x" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO$nr
]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "$nr
" "" "" new "Commit base" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" let line=13 # Skipping basic transaction. Sanity check, find one last transaction xml="0
" checklog "$nr nacm_end add: $xml" $line new "Send restart nacm plugin" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOexample_backend_nacm]]>]]>" "^]]>]]>" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "example_backend_nacm" "" "" # Now analyze log: # all transactions come from nacm plugin only. @@ -129,7 +129,7 @@ done # Negative test: restart a plugin that does not exist new "Send restart to nonexistatn plugin expect fail" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOxxx]]>]]>" "^applicationbad-elementpluginerrorNo such plugin]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "xxx" "" "applicationbad-elementpluginerrorNo such plugin" if [ $BE -ne 0 ]; then new "Kill backend" diff --git a/test/test_type.sh b/test/test_type.sh index 2e6fc5cc..a4bf15d3 100755 --- a/test/test_type.sh +++ b/test/test_type.sh @@ -255,16 +255,16 @@ EOF expectpart "$($clixon_cli -1f $cfg -l o set c talle 9xx)" 255 '^CLI syntax error: "set c talle 9xx": "9xx" is invalid input for cli command: talle$' new "netconf discard-changes" - expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" + expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "netconf set transitive string error" - expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO9xx]]>]]>" "^]]>]]>" + expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "9xx" "" "" new "netconf validate should fail" - expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "applicationbad-elementtalleerrorregexp match fail:" + expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "applicationbad-elementtalleerrorregexp match fail:" "" new "netconf discard-changes" - expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" + expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "cli set transitive union int (ulle should accept 4.44|bounded|unbounded)" expectpart "$($clixon_cli -1f $cfg -l o set c ulle 33)" 0 '^$' @@ -285,13 +285,13 @@ EOF expectpart "$($clixon_cli -1f $cfg -l o set c ulle 55)" 255 '^CLI syntax error: "set c ulle 55": Number 55 out of range: 4 - 44$' new "netconf set transitive union error int" - expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO55]]>]]>" "^]]>]]>" + expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "55" "" "" new "netconf validate should fail" - expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^applicationbad-elementulleerror'55' does not match enumeration]]>]]>$" + expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "applicationbad-elementulleerror'55' does not match enumeration" new "netconf discard-changes" - expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" + expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" #----------- @@ -317,19 +317,19 @@ EOF expectpart "$($clixon_cli -1f $cfg -l o -l o commit)" 0 '^$' new "netconf validate ok" - expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" + expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "netconf set ab wrong" - expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOa.b& c.d]]>]]>" "^]]>]]>$" + expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "a.b& c.d" "" "" new "netconf validate" - expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^" + expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "netconf discard-changes" - expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" + expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "netconf commit" - expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" + expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "cli enum value" expectpart "$($clixon_cli -1f $cfg -l o set status down)" 0 '^$' @@ -342,7 +342,7 @@ EOF #expectpart "$($clixon_cli -1f $cfg -l o set mbits \)"create read\"" 0 '^$' new "netconf bits two values" - expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOcreate read]]>]]>" "^]]>]]>$" + expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "create read" "" "" new "cli bits validate" expectpart "$($clixon_cli -1f $cfg -l o validate)" 0 '^$' @@ -350,13 +350,13 @@ EOF #-------- num0 empty value new "netconf num0 no value" - expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" + expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "netconf validate no value wrong" - expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "applicationbad-elementnum0errorInvalid NULL value]]>]]>" + expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "applicationbad-elementnum0errorInvalid NULL value" new "netconf discard-changes" - expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" + expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" #-------- num1 single range (1) @@ -370,13 +370,13 @@ EOF expectpart "$($clixon_cli -1f $cfg -l o set num1 2)" 255 '^CLI syntax error: "set num1 2": Number 2 out of range: 1 - 1$' new "netconf range set num1 -1" - expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO-1]]>]]>" "^]]>]]>$" + expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "-1" "" "" new "netconf validate num1 -1 wrong" - expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^applicationbad-elementnum1errorNumber -1 out of range: 1 - 1]]>]]>$" + expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "applicationbad-elementnum1errorNumber -1 out of range: 1 - 1" new "netconf discard-changes" - expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" + expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" #-------- num2 range and blanks @@ -390,25 +390,25 @@ EOF expectpart "$($clixon_cli -1f $cfg -l o set num2 5000)" 255 '^CLI syntax error: "set num2 5000": Number 5000 out of range: 4 - 4000$' new "netconf range set num2 3 fail" - expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO3]]>]]>" "^]]>]]>$" + expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "3" "" "" new "netconf validate num2 3 fail" - expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^applicationbad-elementnum2errorNumber 3 out of range: 4 - 4000]]>]]>$" + expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "applicationbad-elementnum2errorNumber 3 out of range: 4 - 4000" new "netconf range set num2 1000 ok" - expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO1000]]>]]>" "^]]>]]>$" + expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "1000" "" "" new "netconf validate num2 1000 ok" - expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" + expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "netconf range set num2 5000 fail" - expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO5000]]>]]>" "^]]>]]>$" + expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "5000" "" "" new "netconf validate num2 5000 fail" - expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^applicationbad-elementnum2errorNumber 5000 out of range: 4 - 4000]]>]]>$" + expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "applicationbad-elementnum2errorNumber 5000 out of range: 4 - 4000" new "netconf discard-changes" - expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" + expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" #-------- num3 min max range @@ -422,13 +422,13 @@ EOF expectpart "$($clixon_cli -1f $cfg -l o set num3 -1)" 255 "CLI syntax error:" new "netconf range set num3 260 fail" - expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO260]]>]]>" "^]]>]]>$" + expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "260" "" "" new "netconf validate num3 260 fail" - expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^applicationbad-elementnum3errorNumber 260 out of range: 0 - 255]]>]]>$" + expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "applicationbad-elementnum3errorNumber 260 out of range: 0 - 255" new "netconf discard-changes" - expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" + expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" #-------- num4 multiple ranges 1..2 | 42..50 @@ -448,25 +448,25 @@ EOF expectpart "$($clixon_cli -1f $cfg -l o set num4 99)" 255 '^CLI syntax error: "set num4 99": Number 99 out of range: 1 - 2, 42 - 50$' new "netconf range set num4 multiple 2" - expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO42]]>]]>" "^]]>]]>$" + expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "42" "" "" new "netconf validate num4 OK" - expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" + expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "netconf range set num4 multiple 20" - expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO42]]>]]>" "^]]>]]>$" + expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "42" "" "" new "netconf validate num4 fail" - expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" + expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "netconf range set num4 multiple 42" - expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO42]]>]]>" "^]]>]]>$" + expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "42" "" "" new "netconf validate num4 fail" - expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" + expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "netconf discard-changes" - expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" + expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" #-------- dec64 multiple ranges -3.5..-2.5 | 0.0 | 10.0..20.0 # XXX how to enter negative numbers in bash string and cli -1? @@ -483,44 +483,44 @@ EOF expectpart "$($clixon_cli -1f $cfg -l o set dec 30.0)" 255 '^CLI syntax error: "set dec 30.0": Number 30.000 out of range: -3.500 - -2.500, 0.000 - 0.000, 10.000 - 20.000$' new "dec64 discard-changes" - expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" + expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" # Same with netconf new "netconf range dec64 -3.59" - expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO-3.59]]>]]>" "^]]>]]>$" + expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "-3.59" "" "" new "netconf range dec64 -3.59 validate fail" - expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^applicationbad-elementdecerrorNumber -3.590 out of range" + expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "applicationbad-elementdecerrorNumber -3.590 out of range" "" new "netconf range dec64 -3.5" - expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO-3.500]]>]]>" "^]]>]]>$" + expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "-3.500" "" "" new "netconf range dec64 -3.5 validate ok" - expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" + expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "netconf range dec64 -2" - expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO-2]]>]]>" "^]]>]]>$" + expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "-2" "" "" new "netconf range dec64 -2 validate fail" - expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^applicationbad-elementdecerrorNumber -2.000 out of range" + expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "applicationbad-elementdecerrorNumber -2.000 out of range" "" new "netconf range dec64 -0.001" - expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO-0.001]]>]]>" "^]]>]]>$" + expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "-0.001" "" "" new "netconf range dec64 -0.001 validate fail" - expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^applicationbad-elementdecerrorNumber -0.001 out of range" + expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "applicationbad-elementdecerrorNumber -0.001 out of range" "" new "netconf range dec64 0.0" - expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO0.0]]>]]>" "^]]>]]>$" + expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "0.0" "" "" new "netconf range dec64 0.0 validate ok" - expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" + expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "netconf range dec64 +0.001" - expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO+0.001]]>]]>" "^]]>]]>$" + expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "+0.001" "" "" new "netconf range dec64 +0.001 validate fail" - expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^applicationbad-elementdecerrorNumber 0.001 out of range" + expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "applicationbad-elementdecerrorNumber 0.001 out of range" "" #----------------string ranges--------------------- #-------- len1 single range (2) @@ -534,13 +534,13 @@ EOF expectpart "$($clixon_cli -1f $cfg -l o set len1 hej)" 255 '^CLI syntax error: "set len1 hej": String length 3 out of range: 2 - 2$' new "netconf discard-changes" - expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" + expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "netconf length set len1 1" - expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOx]]>]]>" "^]]>]]>$" + expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "x" "" "" new "netconf validate len1 1 wrong" - expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^applicationbad-elementlen1errorString length 1 out of range: 2 - 2]]>]]>$" + expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "applicationbad-elementlen1errorString length 1 out of range: 2 - 2" #-------- len2 range and blanks @@ -551,7 +551,7 @@ EOF expectpart "$($clixon_cli -1f $cfg -l o set len2 hejhophdsakjhkjsadhkjsahdkjsad)" 0 '^$' new "netconf discard-changes" - expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" + expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" #-------- len3 min max range @@ -588,53 +588,53 @@ EOF expectpart "$($clixon_cli -1f $cfg -l o set word4 ab%3)" 255 '^CLI syntax error: "set word4 ab%3": "ab%3" is invalid input for cli command: word4$' new "netconf pattern \w" - expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOaXG9]]>]]>" "^]]>]]>$" + expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "aXG9" "" "" new "netconf pattern \w valid" - expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" + expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "netconf pattern \w error" - expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOab%d3]]>]]>" "^]]>]]>$" + expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "ab%d3" "" "" new "netconf pattern \w invalid" - expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^applicationbad-elementword4errorregexp match fail:" + expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "applicationbad-elementword4errorregexp match fail:" "" new "netconf discard-changes" - expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" + expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" #------ Mandatory new "netconf set container w/o mandatory leaf" - expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>" + expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "netconf validate should fail" - expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "applicationmissing-elementmanerrorMandatory variable of manc in module example]]>]]>" + expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "applicationmissing-elementmanerrorMandatory variable of manc in module example" new "netconf set container with mandatory leaf" - expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOfoo]]>]]>" "^]]>]]>" + expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "foo" "" "" new "netconf commit" - expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" + expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "netconf delete mandatory variable" - expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOfoonone]]>]]>" "^]]>]]>$" + expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "foonone" "" "" new "get mandatory" - expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" + expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "netconf validate should fail" - expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^protocolmissing-elementmanerrorMandatory variable of manc in module example]]>]]>$" + expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "protocolmissing-elementmanerrorMandatory variable of manc in module example" new "netconf discard-changes" - expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" + expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" #------ minus new "type with minus" - expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOmy-name]]>]]>" "^]]>]]>$" + expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "my-name" "" "" new "validate minus" - expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" + expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" #new "cli type with minus" #expectpart "$($clixon_cli -1f $cfg -l o set name my-name)" 0 "^$" diff --git a/test/test_type_range.sh b/test/test_type_range.sh index 24b121fa..d644df48 100755 --- a/test/test_type_range.sh +++ b/test/test_type_range.sh @@ -201,13 +201,13 @@ function testbuiltin(){ errmsg="Number $val$post out of range: $rmin$post - $rmax$post" new "Netconf set invalid $t leaf" - expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO$val]]>]]>" "^]]>]]>$" + expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "$val" "" "" new "netconf validate invalid range" - expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^applicationbad-elementr$terror$errmsg]]>]]>$" + expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "applicationbad-elementr$terror$errmsg" new "discard" - expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" + expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" } # Type explicit typed range tests. @@ -252,19 +252,19 @@ function testrange(){ expectpart "$($clixon_cli -1f $cfg -l o set l$t $eval)" 255 "$errmsg" new "discard" - expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" + expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "Netconf set invalid $t leaf" - expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO$eval]]>]]>" "^]]>]]>$" + expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "$eval" "" "" new "netconf get config" - expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^$eval]]>]]>$" + expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "$eval" new "netconf validate invalid range" - expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^applicationbad-elementl$terror$errmsg]]>]]>$" + expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "applicationbad-elementl$terror$errmsg" new "discard" - expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" + expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" } if [ $BE -ne 0 ]; then diff --git a/test/test_unique.sh b/test/test_unique.sh index 16bed7fe..ea0c6ff1 100755 --- a/test/test_unique.sh +++ b/test/test_unique.sh @@ -96,7 +96,7 @@ wait_backend # RFC test two-field caes new "Add not valid example" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOreplace +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "replace smtp 192.0.2.1 25 @@ -106,16 +106,16 @@ expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO192.0.2.1 25 -]]>]]>" "^]]>]]>$" +" "" "" new "netconf validate (should fail)" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^applicationoperation-faileddata-not-uniqueerroripport]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "applicationoperation-faileddata-not-uniqueerroripport" new "netconf discard-changes" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "Add valid example" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOreplace +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "replace smtp 192.0.2.1 25 @@ -128,31 +128,31 @@ expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOftp 192.0.2.1 -]]>]]>" "^]]>]]>$" +" "" "" new "netconf validate ok" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "make it invalid by adding port to ftp entry" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOnoneftp25 -]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "noneftp25 +" "" "" new "netconf validate (should fail)" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^applicationoperation-faileddata-not-uniqueerroripport]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "applicationoperation-faileddata-not-uniqueerroripport" new "make it valid by deleting port from smtp entry" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOnonesmtp25 -]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "nonesmtp25 +" "" "" new "netconf validate ok" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "netconf discard-changes" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" # Then test single-field case new "Add not valid example" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOreplace +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "replace smtp 192.0.2.1 @@ -160,26 +160,26 @@ expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOhttp 192.0.2.1 -]]>]]>" "^]]>]]>$" +" "" "" new "netconf validate (should fail)" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^applicationoperation-faileddata-not-uniqueerrorip]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "applicationoperation-faileddata-not-uniqueerrorip" new "make valid by replacing IP of http entry" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOnonehttp178.23.34.1 -]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "nonehttp178.23.34.1 +" "" "" new "netconf validate ok" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "netconf discard-changes" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" # Then test composite case (detect duplicates among other elements) # and also unordered new "Add not valid example" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOreplace +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "replace other smtp @@ -201,13 +201,13 @@ expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO192.0.2.1 25 -]]>]]>" "^]]>]]>$" +" "" "" new "netconf validate (should fail)" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^applicationoperation-faileddata-not-uniqueerroripport]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "applicationoperation-faileddata-not-uniqueerroripport" new "netconf discard-changes" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" if [ $BE -ne 0 ]; then new "Kill backend" diff --git a/test/test_unique_descendant.sh b/test/test_unique_descendant.sh index 4640d712..c042bfb6 100755 --- a/test/test_unique_descendant.sh +++ b/test/test_unique_descendant.sh @@ -68,7 +68,7 @@ new "wait backend" wait_backend RPC=$(cat<replace +replace x afoo @@ -81,73 +81,41 @@ $DEFAULTHELLObfum -]]>]]> + EOF ) -# RFC test two-field caes +# RFC test two-field cases new "Add valid example" -expecteof "$clixon_netconf -qf $cfg" 0 "${RPC}" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qef $cfg" 0 "$DEFAULTHELLO" "${RPC}" "" "" new "netconf validate ok" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qef $cfg" 0 "$DEFAULTHELLO" "" "" "" new "netconf discard-changes" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qef $cfg" 0 "$DEFAULTHELLO" "" "" "" -RPC=$(cat<replace - - x - afoo - bfoo - - - - y - afie - bfum - - -]]>]]> -EOF - ) +rpc="replacexafoobfooyafiebfum" new "Add invalid example" -expecteof "$clixon_netconf -qf $cfg" 0 "${RPC}" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qef $cfg" 0 "$DEFAULTHELLO" "${rpc}" "" "" new "netconf validate same inner (should fail)" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^applicationoperation-faileddata-not-uniqueerrorc/inner/value]]>]]>$" +expecteof_netconf "$clixon_netconf -qef $cfg" 0 "$DEFAULTHELLO" "" "" "applicationoperation-faileddata-not-uniqueerrorc/inner/value" new "netconf discard-changes" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qef $cfg" 0 "$DEFAULTHELLO" "" "" "" -RPC=$(cat<replace - - x - afoo - bbar - - - - y - afie - bbar - - -]]>]]> -EOF - ) +rpc="replacexafoobbaryafiebbar" new "Add invalid example" -expecteof "$clixon_netconf -qf $cfg" 0 "${RPC}" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qef $cfg" 0 "$DEFAULTHELLO" "${rpc}" "" "" new "netconf validate same in different outers (should fail)" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^applicationoperation-faileddata-not-uniqueerrorc/inner/value]]>]]>$" +expecteof_netconf "$clixon_netconf -qef $cfg" 0 "$DEFAULTHELLO" "" "" "applicationoperation-faileddata-not-uniqueerrorc/inner/value" new "netconf discard-changes" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qef $cfg" 0 "$DEFAULTHELLO" "" "" "" if [ $BE -ne 0 ]; then new "Kill backend" diff --git a/test/test_upgrade_auto.sh b/test/test_upgrade_auto.sh index 1256ccaa..69543002 100755 --- a/test/test_upgrade_auto.sh +++ b/test/test_upgrade_auto.sh @@ -262,7 +262,7 @@ new "waiting" wait_backend new "Check running db content" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^$XML]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "^$XML$" if [ $BE -ne 0 ]; then new "Kill backend" diff --git a/test/test_upgrade_failsafe.sh b/test/test_upgrade_failsafe.sh index 95758ff4..e70c6616 100755 --- a/test/test_upgrade_failsafe.sh +++ b/test/test_upgrade_failsafe.sh @@ -291,12 +291,12 @@ runtest(){ wait_backend new "Check running db content" - expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^$exprun]]>]]>$" + expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "$exprun" # If given check startup db XML if [ -n "$expstart" ]; then new "Check startup db content" - expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^$expstart]]>]]>$" + expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "$expstart" fi if [ $BE -ne 0 ]; then diff --git a/test/test_upgrade_interfaces.sh b/test/test_upgrade_interfaces.sh index 950628fb..58aa5d4c 100755 --- a/test/test_upgrade_interfaces.sh +++ b/test/test_upgrade_interfaces.sh @@ -275,7 +275,7 @@ function testrun(){ wait_backend new "Check running db content" - expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^$runxml]]>]]>$" + expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "$runxml" if [ $BE -ne 0 ]; then new "Kill backend" diff --git a/test/test_upgrade_interfaces_rfc7895.sh b/test/test_upgrade_interfaces_rfc7895.sh index c36f7da2..49b72302 100755 --- a/test/test_upgrade_interfaces_rfc7895.sh +++ b/test/test_upgrade_interfaces_rfc7895.sh @@ -272,7 +272,7 @@ function testrun(){ wait_backend new "Check running db content" - expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^$runxml]]>]]>$" + expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "$runxml" if [ $BE -ne 0 ]; then new "Kill backend" diff --git a/test/test_upgrade_repair.sh b/test/test_upgrade_repair.sh index c297dfa6..e83297ad 100755 --- a/test/test_upgrade_repair.sh +++ b/test/test_upgrade_repair.sh @@ -121,26 +121,26 @@ new "waiting" wait_backend new "Check running db content is failsafe" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^$SAMEXML]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "$SAMEXML" new "copy startup->candidate" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "Check candidate db content is startup" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^$OLDXML$SAMEXML]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "$OLDXML$SAMEXML" # Note you cannot edit invalid XML since a0 lacks namespace new "Put new version into candidate" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO$NEWXML$SAMEXML]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "$NEWXML$SAMEXML" "" "" new "Check candidate db content is updated" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^$SAMEXML$NEWXML]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "$SAMEXML$NEWXML" new "commit to running" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "Check running db content is updated" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^$SAMEXML$NEWXML]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "$SAMEXML$NEWXML" if [ $BE -ne 0 ]; then new "Kill backend" diff --git a/test/test_upgrade_simple.sh b/test/test_upgrade_simple.sh index 2a0bc14f..d8682b0f 100755 --- a/test/test_upgrade_simple.sh +++ b/test/test_upgrade_simple.sh @@ -65,10 +65,10 @@ new "wait backend" wait_backend new "add hello world (with modstate)" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "netconf commit" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" # race condition where backend is killed before flushed to disk sleep $DEMSLEEP @@ -117,7 +117,7 @@ if [ $BE -ne 0 ]; then fi new "netconf get config" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" if [ $BE -ne 0 ]; then new "Kill backend" diff --git a/test/test_when_must.sh b/test/test_when_must.sh index aac2d0bb..942a3111 100755 --- a/test/test_when_must.sh +++ b/test/test_when_must.sh @@ -104,40 +104,40 @@ new "wait backend" wait_backend new "when: add static route" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOstaticr1]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "staticr1" "" "" new "when: validate ok" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "when: add direct route" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOdirectr2]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "directr2" "" "" new "when get config" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^directr2staticr1]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "directr2staticr1" new "when: validate fail" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^applicationoperation-failederrorFailed WHEN condition of static-routes in module example (WHEN xpath is ../type='static')]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "applicationoperation-failederrorFailed WHEN condition of static-routes in module example (WHEN xpath is ../type='static')" new "when: discard-changes" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "must: add interface" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOethernet1500]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "ethernet1500" "" "" new "must: validate ok" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "must: add atm interface" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOatm32]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "atm32" "" "" new "must: atm validate fail" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^applicationoperation-failederrorAn ATM MTU must be 64 .. 17966]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "applicationoperation-failederrorAn ATM MTU must be 64 .. 17966" new "must: add eth interface" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOethernet989]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "ethernet989" "" "" new "must: eth validate fail" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^applicationoperation-failederrorAn Ethernet MTU must be 1500]]>]]>" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "applicationoperation-failederrorAn Ethernet MTU must be 1500" if [ $BE -ne 0 ]; then new "Kill backend" diff --git a/test/test_with_default.sh b/test/test_with_default.sh index f7519f2c..6df7836d 100755 --- a/test/test_with_default.sh +++ b/test/test_with_default.sh @@ -95,10 +95,10 @@ TRIM='defaultnotset$XML]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "$XML" "" "" new "Check config (Clixon supports explicit)" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^$EXPLICIT]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "$EXPLICIT" if [ $BE -ne 0 ]; then new "Kill backend" diff --git a/test/test_xpath_functions.sh b/test/test_xpath_functions.sh index 06da8ae0..a6b4cba5 100755 --- a/test/test_xpath_functions.sh +++ b/test/test_xpath_functions.sh @@ -122,70 +122,70 @@ wait_backend # contains new "contains: Set site to foo that validates site OK" -expecteof "$clixon_netconf -qf $cfg -D $DBG" 0 "$DEFAULTHELLOfoo1242]]>]]>" "^]]>]]>" +expecteof_netconf "$clixon_netconf -qf $cfg -D $DBG" 0 "$DEFAULTHELLO" "foo1242" "" "" new "netconf validate OK" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "Set site to fie which invalidates the when contains" -expecteof "$clixon_netconf -qf $cfg -D $DBG" 0 "$DEFAULTHELLOfie]]>]]>" "^]]>]]>" +expecteof_netconf "$clixon_netconf -qf $cfg -D $DBG" 0 "$DEFAULTHELLO" "fie" "" "" new "netconf validate not OK" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^applicationoperation-failederrorFailed WHEN condition of site in module example (WHEN xpath is contains(../../class,'foo') or contains(../../class,'bar'))]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "applicationoperation-failederrorFailed WHEN condition of site in module example (WHEN xpath is contains(../../class,'foo') or contains(../../class,'bar'))" new "netconf discard-changes" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" # derived-from new "derived-from: Set mtu to interface OK on GE" -expecteof "$clixon_netconf -qf $cfg -D $DBG" 0 "$DEFAULTHELLOe0fast-ethernet1500]]>]]>" "^]]>]]>" +expecteof_netconf "$clixon_netconf -qf $cfg -D $DBG" 0 "$DEFAULTHELLO" "e0fast-ethernet1500" "" "" new "netconf validate OK" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "Change type to atm" -expecteof "$clixon_netconf -qf $cfg -D $DBG" 0 "$DEFAULTHELLOe0atm]]>]]>" "^]]>]]>" +expecteof_netconf "$clixon_netconf -qf $cfg -D $DBG" 0 "$DEFAULTHELLO" "e0atm" "" "" new "netconf validate not OK (mtu not allowed)" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^applicationoperation-failederrorFailed WHEN condition of mtu in module example (WHEN xpath is derived-from(type, \"ex:ethernet\"))]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "applicationoperation-failederrorFailed WHEN condition of mtu in module example (WHEN xpath is derived-from(type, \"ex:ethernet\"))" new "Change type to ethernet (self)" -expecteof "$clixon_netconf -qf $cfg -D $DBG" 0 "$DEFAULTHELLOe0ethernet]]>]]>" "^]]>]]>" +expecteof_netconf "$clixon_netconf -qf $cfg -D $DBG" 0 "$DEFAULTHELLO" "e0ethernet" "" "" new "netconf validate not OK (mtu not allowed on self)" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^applicationoperation-failederrorFailed WHEN condition of mtu in module example (WHEN xpath is derived-from(type, \"ex:ethernet\"))]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "applicationoperation-failederrorFailed WHEN condition of mtu in module example (WHEN xpath is derived-from(type, \"ex:ethernet\"))" new "netconf discard-changes" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" # derived-from-or-self new "derived-from-or-self: Set crc to interface OK on GE" -expecteof "$clixon_netconf -qf $cfg -D $DBG" 0 "$DEFAULTHELLOe0fast-ethernet42]]>]]>" "^]]>]]>" +expecteof_netconf "$clixon_netconf -qf $cfg -D $DBG" 0 "$DEFAULTHELLO" "e0fast-ethernet42" "" "" new "netconf validate OK" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "Change type to atm" -expecteof "$clixon_netconf -qf $cfg -D $DBG" 0 "$DEFAULTHELLOe0atm]]>]]>" "^]]>]]>" +expecteof_netconf "$clixon_netconf -qf $cfg -D $DBG" 0 "$DEFAULTHELLO" "e0atm" "" "" new "netconf validate not OK (crc not allowed)" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^applicationoperation-failederrorFailed WHEN condition of crc in module example (WHEN xpath is derived-from-or-self(type, \"ex:ethernet\"))]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "applicationoperation-failederrorFailed WHEN condition of crc in module example (WHEN xpath is derived-from-or-self(type, \"ex:ethernet\"))" new "Change type to ethernet (self)" -expecteof "$clixon_netconf -qf $cfg -D $DBG" 0 "$DEFAULTHELLOe0ethernet]]>]]>" "^]]>]]>" +expecteof_netconf "$clixon_netconf -qf $cfg -D $DBG" 0 "$DEFAULTHELLO" "e0ethernet" "" "" new "netconf validate OK (self)" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "netconf discard-changes" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" # bit-is-set new "Add interfaces with different flags" -expecteof "$clixon_netconf -qf $cfg -D $DBG" 0 "$DEFAULTHELLOe0UPe1UP PROMISCUOUSe2PROMISCUOUS]]>]]>" "^]]>]]>" +expecteof_netconf "$clixon_netconf -qf $cfg -D $DBG" 0 "$DEFAULTHELLO" "e0UPe1UP PROMISCUOUSe2PROMISCUOUS" "" "" new "netconf bit-is-set" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^e1UP PROMISCUOUSe2PROMISCUOUS]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "e1UP PROMISCUOUSe2PROMISCUOUS" if [ $BE -ne 0 ]; then new "Kill backend" diff --git a/test/test_yang.sh b/test/test_yang.sh index d4d39aeb..192fae1f 100755 --- a/test/test_yang.sh +++ b/test/test_yang.sh @@ -184,50 +184,50 @@ new "cli show yang example" expectpart "$($clixon_cli -1f $cfg show yang example)" 0 "revision 2020-12-01" "Added table/parameter/value as the primary data example" new "empty values in leaf-list" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOa]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "a" "" "" new "empty values in leaf-list2" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "netconf get config" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^a]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "a" new "netconf discard-changes" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" #new "cli not defined extension" #new "netconf not defined extension" -#expecteof "$clixon_netconf -qf $cfg -l o" 0 "$YANG" "Extension ex:not-defined not found" +#expecteof_netconf "$clixon_netconf -qf $cfg -l o" 0 "$YANG" "Extension ex:not-defined not found" # This text yields an error, but the test cannot detect the error message yet #expectpart "$($clixon_cli -1f $cfg -y $fyangerr show version)" 0 "Yang error: Extension ex:not-defined not found" new "netconf schema resource, RFC 8525" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "ietf-yang-types2013-07-15urn:ietf:params:xml:ns:yang:ietf-yang-types" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "ietf-yang-types2013-07-15urn:ietf:params:xml:ns:yang:ietf-yang-types" new "netconf edit config" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO125one]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "125one" "" "" new "netconf commit" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" # text empty type in running new "netconf commit 2nd" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "netconf get config xpath" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^125one]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "125one" new "netconf edit leaf-list" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOhejhopp]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "hejhopp" "" "" new "netconf get leaf-list" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^hejhopp]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "hejhopp" new "netconf get leaf-list path" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^hejhopp]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "hejhopp" new "netconf get (should be some)" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^125one" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "125one" "" new "cli set leaf-list" expectpart "$($clixon_cli -1f $cfg set x f e foo)" 0 "" @@ -236,72 +236,72 @@ new "cli show leaf-list" expectpart "$($clixon_cli -1f $cfg show xpath /x/f/e urn:example:clixon)" 0 "foo" new "netconf set state data (not allowed)" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO42]]>]]>" "^applicationbad-elementstateerrormodule example: state data node unexpected]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "42" "" "applicationbad-elementstateerrormodule example: state data node unexpected" new "netconf set presence and not present" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "netconf get presence only" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "netconf get presence only" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "netconf discard-changes" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "netconf anyxml" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "netconf validate anyxml" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "netconf delete candidate" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOnone]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "none" "" "" # Check 3-keys new "netconf add one 3-key entry" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO111one]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "111one" "" "" new "netconf check add one 3-key" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "111one]]>]]>" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "111one" new "netconf add another (with same 1st key)" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO121two]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "121two" "" "" new "netconf check add another" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "111one121two]]>]]>" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "111one121two" new "netconf replace first" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO111replace]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "111replace" "" "" new "netconf check replace" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "111replace121two]]>]]>" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "111replace121two" new "netconf delete first" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO111]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "111" "" "" new "netconf check delete" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "121two]]>]]>" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "121two" # clear db for next test new "netconf delete candidate" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOnone]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "none" "" "" new "netconf commit empty candidate" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "netconfig config submodule" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOafoo]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "afoo" "" "" new "netconf submodule get config" -expecteof "$clixon_netconf -qf $cfg -D 1 -l s" 0 "$DEFAULTHELLO]]>]]>" "^afoo]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg -D 1 -l s" 0 "$DEFAULTHELLO" "" "" "afoo" new "netconf submodule validate" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "netconf submodule discard-changes" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" if [ $BE -ne 0 ]; then new "Kill backend" diff --git a/test/test_yang_anydata.sh b/test/test_yang_anydata.sh index f0c3d292..9403a0ae 100755 --- a/test/test_yang_anydata.sh +++ b/test/test_yang_anydata.sh @@ -190,20 +190,20 @@ EOF if ! $startup; then # If not startup, add xml using netconf new "Put anydata" - expecteof "$clixon_netconf -qf $cfg -D $DBG" 0 "$DEFAULTHELLO$XMLA]]>]]>" "]]>]]>" + expecteof_netconf "$clixon_netconf -qf $cfg -D $DBG" 0 "$DEFAULTHELLO" "$XMLA" "" "" new "Put unknown" - expecteof "$clixon_netconf -qf $cfg -D $DBG" 0 "$DEFAULTHELLO$XMLU]]>]]>" "$unknownreply" + expecteof_netconf "$clixon_netconf -qf $cfg -D $DBG" 0 "$DEFAULTHELLO" "$XMLU" "$unknownreply" new "commit" - expecteof "$clixon_netconf -qf $cfg -D $DBG" 0 "$DEFAULTHELLO]]>]]>" "]]>]]>" + expecteof_netconf "$clixon_netconf -qf $cfg -D $DBG" 0 "$DEFAULTHELLO" "" "" "" fi new "Get candidate" - expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^$XML]]>]]>$" + expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "$XML" new "Get running" - expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^$XML]]>]]>$" + expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "$XML" # Add other functions, (based on previous errors), eg cli show config, cli commit. new "cli show configuration" @@ -219,7 +219,7 @@ EOF echo "$STATE1" > $fstate new "Get state (positive test)" - expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^$STATE1]]>]]>" + expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "$STATE1" new "restconf get state(positive)" expectpart "$(curl $CURLOPTS -X GET -H "Accept: application/yang-data+xml" $RCPROTO://localhost/restconf/data?content=nonconfig)" 0 "HTTP/$HVER 200" "$STATE1" @@ -228,7 +228,7 @@ EOF echo "$STATE0" > $fstate new "Get state (negative test)" - expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "error-message>Failed to find YANG spec of XML node: u5 with parent: sb in namespace: urn:example:unknown. Internal error, state callback returned invalid XML from plugin: example_backend" + expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "error-message>Failed to find YANG spec of XML node: u5 with parent: sb in namespace: urn:example:unknown. Internal error, state callback returned invalid XML from plugin: example_backend" "" new "restconf get state(negative)" expectpart "$(curl $CURLOPTS -X GET -H "Accept: application/yang-data+xml" $RCPROTO://localhost/restconf/data?content=nonconfig)" 0 "HTTP/$HVER 412" "operation-failedu5" @@ -237,13 +237,13 @@ EOF # server. But "unknown-element" as truly unknwon. # (Would need to add a handler to get a proper OK) new "Not supported RPC" - expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "operation-not-supported" + expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "operation-not-supported" "" new "anydata RPC" - expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO88]]>]]>" "operation-not-supported" + expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "88" "operation-not-supported" "" new "unknown RPC" - expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO88]]>]]>" "unknown-element" + expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "88" "unknown-element" "" if [ $RC -ne 0 ]; then new "Kill restconf daemon" diff --git a/test/test_yang_default.sh b/test/test_yang_default.sh index 24946a36..85fb2f8e 100755 --- a/test/test_yang_default.sh +++ b/test/test_yang_default.sh @@ -114,34 +114,34 @@ if [ $? -ne 0 ]; then fi new "check running defaults" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^880foo42]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "880foo42" new "delete existing list element" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO0]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "0" "" "" new "netconf commit" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "set new list element" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO17]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "17" "" "" new "get the list top" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^8817foo42]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "8817foo42" new "get the list xpath /a" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^8817foo42
]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "8817foo42
" new "get the list xpath /a/b" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^17foo42]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "17foo42" new "get the list xpath /a/b/c" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^17]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "17" new "get the list xpath /a/b/c=17" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO17]]>]]>" "^17foo42]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "17" "" "17foo42" new "get the list xpath /a/b/c=17/d1" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO17]]>]]>" "^17foo]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "17" "" "17foo" if [ $BE -ne 0 ]; then # Bring your own backend new "Kill backend" diff --git a/test/test_yang_deviation.sh b/test/test_yang_deviation.sh index 4b4cd6a8..e8023989 100755 --- a/test/test_yang_deviation.sh +++ b/test/test_yang_deviation.sh @@ -95,50 +95,50 @@ function testrun() wait_backend new "Add user bob" - expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLObob]]>]]>" "]]>]]" + expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "bob" "" "" if $mustdate; then # fail since there is neither date or daytime (delete rule) new "netconf validate expect error" - expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^applicationoperation-failederrorFailed MUST xpath 'daytime or time' of 'system' in module example-base]]>]]>$" + expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "applicationoperation-failederrorFailed MUST xpath 'daytime or time' of 'system' in module example-base" else new "netconf validate ok" - expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "]]>]]" + expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" fi new "Add time" - expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "]]>]]" + expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "netconf validate ok" - expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "]]>]]" + expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" if $daytime; then # not-supported rule new "Add example-base daytime - supported" - expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOSept17]]>]]>" "]]>]]" + expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "Sept17" "" "" else # Not supported new "Add example-base daytime - expect error not supported" - expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOSept17]]>]]>" "applicationunknown-elementdaytimeerrorFailed to find YANG spec of XML node: daytime with parent: system in namespace: urn:example:base]]>]]" + expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "Sept17" "" "applicationunknown-elementdaytimeerrorFailed to find YANG spec of XML node: daytime with parent: system in namespace: urn:example:base" fi # daytime supported new "netconf commit" - expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" + expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" if $admindefault; then # add rule new "Get type admin expected" - expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^bobadmin]]>]]>$" + expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "bobadmin" else new "Get type none expected" - expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" + expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" fi # Add 2 name-servers new "Add two name-servers" - expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOaabb]]>]]>" "]]>]]" + expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "aabb" "" "" if $maxel1; then # add two and check if it fails new "netconf validate 2 element fail" - expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^protocoloperation-failedtoo-many-elementserror/system/name-server]]>]]>$" + expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "protocoloperation-failedtoo-many-elementserror/system/name-server" else new "netconf validate 2 elements ok" - expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "]]>]]" + expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" fi if [ "$BE" -ne 0 ]; then diff --git a/test/test_yang_extension.sh b/test/test_yang_extension.sh index 9e911579..54114038 100755 --- a/test/test_yang_extension.sh +++ b/test/test_yang_extension.sh @@ -118,13 +118,13 @@ wait_backend # The main example implements ex:e4 new "Add extension foo (not implemented)" -expecteof "$clixon_netconf -qf $cfg -D $DBG" 0 "$DEFAULTHELLOa string]]>]]>" "^applicationunknown-elementfooerror" +expecteof_netconf "$clixon_netconf -qf $cfg -D $DBG" 0 "$DEFAULTHELLO" "a string" "applicationunknown-elementfooerror" "" new "Add extension bar (is implemented)" -expecteof "$clixon_netconf -qf $cfg -D $DBG" 0 "$DEFAULTHELLOa string]]>]]>" "^]]>]]>" +expecteof_netconf "$clixon_netconf -qf $cfg -D $DBG" 0 "$DEFAULTHELLO" "a string" "" "" new "netconf get config" -expecteof "$clixon_netconf -qf $cfg -D $DBG" 0 "$DEFAULTHELLO]]>]]>" "^a string]]>]]>" +expecteof_netconf "$clixon_netconf -qf $cfg -D $DBG" 0 "$DEFAULTHELLO" "" "" "a string" if [ $BE -ne 0 ]; then new "Kill backend" diff --git a/test/test_yang_load.sh b/test/test_yang_load.sh index 242d2f66..83a480c6 100755 --- a/test/test_yang_load.sh +++ b/test/test_yang_load.sh @@ -87,13 +87,13 @@ new "wait backend" wait_backend new "1. Set newex" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOstr]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "str" "" "" new "Set oldex should fail (since oldex is in old revision and only the new is loaded)" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOstr]]>]]>" "^applicationunknown-elementoldexerrorFailed to find YANG spec of XML node: oldex with parent: config in namespace: urn:example:clixon]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "str" "" "applicationunknown-elementoldexerrorFailed to find YANG spec of XML node: oldex with parent: config in namespace: urn:example:clixon" new "Set other should fail" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOstr]]>]]>" "^applicationunknown-elementothererrorFailed to find YANG spec of XML node: other with parent: config in namespace: urn:example:clixon2]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "str" "" "applicationunknown-elementothererrorFailed to find YANG spec of XML node: other with parent: config in namespace: urn:example:clixon2" if [ $BE -ne 0 ]; then new "Kill backend" @@ -134,13 +134,13 @@ new "wait backend" wait_backend new "Set oldex" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOstr]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "str" "" "" new "Set newex should fail" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOstr]]>]]>" "^applicationunknown-elementnewexerrorFailed to find YANG spec of XML node: newex with parent: config in namespace: urn:example:clixon]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "str" "" "applicationunknown-elementnewexerrorFailed to find YANG spec of XML node: newex with parent: config in namespace: urn:example:clixon" new "Set other should fail" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOstr]]>]]>" "^applicationunknown-elementothererrorFailed to find YANG spec of XML node: other with parent: config in namespace: urn:example:clixon2]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "str" "" "applicationunknown-elementothererrorFailed to find YANG spec of XML node: other with parent: config in namespace: urn:example:clixon2" if [ $BE -ne 0 ]; then new "Kill backend" @@ -177,13 +177,13 @@ new "wait backend" wait_backend new "Set newex" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOstr]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "str" "" "" new "Set oldex should fail" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOstr]]>]]>" "^applicationunknown-elementoldexerrorFailed to find YANG spec of XML node: oldex with parent: config in namespace: urn:example:clixon]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "str" "" "applicationunknown-elementoldexerrorFailed to find YANG spec of XML node: oldex with parent: config in namespace: urn:example:clixon" new "Set other should fail" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOstr]]>]]>" "^applicationunknown-elementothererrorFailed to find YANG spec of XML node: other with parent: config in namespace: urn:example:clixon2]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "str" "" "applicationunknown-elementothererrorFailed to find YANG spec of XML node: other with parent: config in namespace: urn:example:clixon2" if [ $BE -ne 0 ]; then new "Kill backend" @@ -220,13 +220,13 @@ new "wait backend" wait_backend new "Set oldex" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOstr]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "str" "" "" new "Set newex should fail" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOstr]]>]]>" "^applicationunknown-elementnewexerrorFailed to find YANG spec of XML node: newex with parent: config in namespace: urn:example:clixon]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "str" "" "applicationunknown-elementnewexerrorFailed to find YANG spec of XML node: newex with parent: config in namespace: urn:example:clixon" new "Set other should fail" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOstr]]>]]>" "^applicationunknown-elementothererrorFailed to find YANG spec of XML node: other with parent: config in namespace: urn:example:clixon2]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "str" "" "applicationunknown-elementothererrorFailed to find YANG spec of XML node: other with parent: config in namespace: urn:example:clixon2" if [ $BE -ne 0 ]; then new "Kill backend" @@ -263,13 +263,13 @@ new "wait backend" wait_backend new "Set newex" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOstr]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "str" "" "" new "Set oldex should fail" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOstr]]>]]>" "^applicationunknown-elementoldexerrorFailed to find YANG spec of XML node: oldex with parent: config in namespace: urn:example:clixon]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "str" "" "applicationunknown-elementoldexerrorFailed to find YANG spec of XML node: oldex with parent: config in namespace: urn:example:clixon" new "Set other" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOstr]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "str" "" "" if [ $BE -ne 0 ]; then new "Kill backend" @@ -308,13 +308,13 @@ new "wait backend" wait_backend new "Set oldex" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOstr]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "str" "" "" new "Set newex should fail" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOstr]]>]]>" "^applicationunknown-elementnewexerrorFailed to find YANG spec of XML node: newex with parent: config in namespace: urn:example:clixon]]>]]>" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "str" "" "applicationunknown-elementnewexerrorFailed to find YANG spec of XML node: newex with parent: config in namespace: urn:example:clixon" new "Set other" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOstr]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "str" "" "" if [ $BE -ne 0 ]; then new "Kill backend" @@ -353,13 +353,13 @@ new "wait backend" wait_backend new "Set oldex" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOstr]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "str" "" "" new "Set newex should fail" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOstr]]>]]>" "^applicationunknown-elementnewexerrorFailed to find YANG spec of XML node: newex with parent: config in namespace: urn:example:clixon]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "str" "" "applicationunknown-elementnewexerrorFailed to find YANG spec of XML node: newex with parent: config in namespace: urn:example:clixon" new "Set other" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOstr]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "str" "" "" if [ $BE -ne 0 ]; then new "Kill backend" @@ -398,13 +398,13 @@ new "wait backend" wait_backend new "Set oldex" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOstr]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "str" "" "" new "Set newex should fail" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOstr]]>]]>" "^applicationunknown-elementnewexerrorFailed to find YANG spec of XML node: newex with parent: config in namespace: urn:example:clixon]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "str" "" "applicationunknown-elementnewexerrorFailed to find YANG spec of XML node: newex with parent: config in namespace: urn:example:clixon" new "Set other should fail" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOstr]]>]]>" "^applicationunknown-elementothererrorFailed to find YANG spec of XML node: other with parent: config in namespace: urn:example:clixon2]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "str" "" "applicationunknown-elementothererrorFailed to find YANG spec of XML node: other with parent: config in namespace: urn:example:clixon2" if [ $BE -ne 0 ]; then new "Kill backend" diff --git a/test/test_yang_namespace.sh b/test/test_yang_namespace.sh index 0ff9d1a1..d378a28b 100755 --- a/test/test_yang_namespace.sh +++ b/test/test_yang_namespace.sh @@ -88,19 +88,19 @@ new "wait restconf" wait_restconf new "netconf set x in example1" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO42]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "42" "" "" new "netconf get config example1" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^42]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "42" new "netconf set x in example2" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO99]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "99" "" "" new "netconf get config example1 and example2" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^4299]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "4299" new "netconf discard-changes" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "restconf set x in example1" expectpart "$(curl $CURLOPTS -X POST -H "Content-Type: application/yang-data+json" -d '{"example1:x":42}' $RCPROTO://localhost/restconf/data)" 0 "HTTP/$HVER 201" diff --git a/test/test_yang_when.sh b/test/test_yang_when.sh index a449d068..9c528f85 100755 --- a/test/test_yang_when.sh +++ b/test/test_yang_when.sh @@ -85,45 +85,45 @@ function testrun() # no match: name != kalle new "netconf set non-match" - expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOpaul
merge
]]>]]>" "^]]>]]>$" + expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "paul
merge
" "" "" new "netconf get default value not set" - expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^paul
]]>]]>$" + expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "paul
" new "netconf set non-match value expect fail" - expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOpaul42
merge
]]>]]>" "^applicationunknown-elementvalueerrorNode 'value' tagged with 'when' condition 'ex:name = 'kalle'' in module 'example' evaluates to false in edit-config operation (see RFC 7950 Sec 8.3.2)]]>]]>$" + expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "paul42
merge
" "" "applicationunknown-elementvalueerrorNode 'value' tagged with 'when' condition 'ex:name = 'kalle'' in module 'example' evaluates to false in edit-config operation (see RFC 7950 Sec 8.3.2)" new "netconf get value without default" - expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^paul
]]>]]>$" + expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "paul
" new "netconf validate default not set" - expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" + expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "netconf discard non-match" - expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" + expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" # no match: name != kalle full put new "netconf set non-match full" - expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOpaul42
merge
]]>]]>" "^applicationunknown-elementvalueerrorNode 'value' tagged with 'when' condition 'ex:name = 'kalle'' in module 'example' evaluates to false in edit-config operation (see RFC 7950 Sec 8.3.2)]]>]]>$" + expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "paul42
merge
" "" "applicationunknown-elementvalueerrorNode 'value' tagged with 'when' condition 'ex:name = 'kalle'' in module 'example' evaluates to false in edit-config operation (see RFC 7950 Sec 8.3.2)" new "netconf get value empty" - expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" + expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" # match: name = kalle new "netconf set match" - expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOkalle
merge
]]>]]>" "^]]>]]>$" + expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "kalle
merge
" "" "" new "netconf get default value set" - expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^kallefoo
]]>]]>$" + expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "kallefoo
" new "netconf set non-match value expect ok" - expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOkalle42
merge
]]>]]>" "^]]>]]>$" + expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "kalle42
merge
" "" "" new "netconf get value ok" - expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^kalle42
]]>]]>$" + expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "kalle42
" new "netconf validate default set" - expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" + expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" if [ $BE -ne 0 ]; then new "Kill backend" @@ -271,25 +271,25 @@ new "wait backend" wait_backend new "netconf set allow true" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOtruemerge]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "truemerge" "" "" new "netconf commit" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "netconf set value expect OK" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOkalle42
merge
]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "kalle42
merge
" "" "" new "netconf discard-changes" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "netconf set allow false" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOfalsemerge]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "falsemerge" "" "" new "netconf commit" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "netconf set value expect fail" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOkalle42
merge
]]>]]>" "^applicationunknown-elementvalueerrorNode 'value' tagged with 'when' condition '../../ex:allow = 'true'' in module 'example' evaluates to false in edit-config operation (see RFC 7950 Sec 8.3.2)]]>]]>$" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "kalle42
merge
" "" "applicationunknown-elementvalueerrorNode 'value' tagged with 'when' condition '../../ex:allow = 'true'' in module 'example' evaluates to false in edit-config operation (see RFC 7950 Sec 8.3.2)" if [ $BE -ne 0 ]; then new "Kill backend"