From 81fc7f742bf13ad0413b2305a24ff818134a5bb8 Mon Sep 17 00:00:00 2001 From: Olof hagsand Date: Wed, 2 Sep 2020 15:40:35 +0200 Subject: [PATCH] * Netconf as default namespace has been disabled by default. * Only requests on the form: `...` will be accepted * All replies will be on the form: `...` * Requests such as: `...` will not be accepted. * You can revert this behaviour (to clixon pre-4.6 behaviour) by enabling `CLICON_NAMESPACE_NETCONF_DEFAULT` * This API change is a consequence of: [copy-config's RPC cxobj parameter does not contain namespace #131](https://github.com/clicon/clixon/issues/131) --- CHANGELOG.md | 14 +- apps/backend/backend_client.c | 32 ++--- apps/backend/backend_commit.c | 6 +- apps/backend/backend_main.c | 4 + apps/cli/cli_main.c | 3 + apps/cli/cli_show.c | 6 +- apps/netconf/netconf_main.c | 8 +- apps/netconf/netconf_rpc.c | 43 +++--- apps/restconf/restconf_main_evhtp.c | 3 + apps/restconf/restconf_main_fcgi.c | 2 + apps/restconf/restconf_methods.c | 18 ++- apps/restconf/restconf_methods_post.c | 7 +- apps/restconf/restconf_stream_fcgi.c | 4 +- example/main/example_backend.c | 4 +- example/main/example_netconf.c | 2 +- example/main/example_restconf.c | 2 +- include/clixon_custom.h | 8 -- lib/clixon/clixon_options.h | 2 +- lib/clixon/clixon_xml_nsctx.h | 1 + lib/src/clixon_datastore_write.c | 1 + lib/src/clixon_nacm.c | 3 +- lib/src/clixon_netconf_lib.c | 90 ++++++++++--- lib/src/clixon_proto_client.c | 48 ++++--- lib/src/clixon_xml_nsctx.c | 39 ++++-- test/lib.sh | 7 +- test/test_api.sh | 2 +- test/test_augment.sh | 24 ++-- test/test_choice.sh | 73 +++++----- test/test_cli.sh | 2 +- test/test_cli_multikey.sh | 5 +- test/test_copy_config.sh | 46 +++---- test/test_datastore_repair.sh | 2 +- test/test_feature.sh | 14 +- test/test_identity.sh | 50 +++---- test/test_leaf_default.sh | 24 ++-- test/test_leafref.sh | 32 ++--- test/test_leafref_augment.sh | 26 ++-- test/test_leafref_state.sh | 34 ++--- test/test_minmax.sh | 78 +++++------ test/test_nacm.sh | 4 +- test/test_nacm_credentials.sh | 10 +- test/test_nacm_datanode.sh | 6 +- test/test_nacm_datanode_read.sh | 6 +- test/test_nacm_datanode_write.sh | 6 +- test/test_nacm_module_read.sh | 12 +- test/test_nacm_module_write.sh | 4 +- test/test_nacm_protocol.sh | 16 +-- test/test_nacm_recovery.sh | 10 +- test/test_netconf.sh | 108 +++++++-------- test/test_netconf_filter.sh | 14 +- test/test_netconf_whitespace.sh | 44 +++---- test/test_order.sh | 144 ++++++++++---------- test/test_pattern.sh | 8 +- test/test_perf_netconf.sh | 36 ++--- test/test_perf_restconf.sh | 20 +-- test/test_perf_state.sh | 14 +- test/test_perf_state_only.sh | 8 +- test/test_rpc.sh | 18 +-- test/test_sock.sh | 4 +- test/test_startup.sh | 6 +- test/test_stream.sh | 20 +-- test/test_submodule.sh | 10 +- test/test_transaction.sh | 48 +++---- test/test_transaction_restart.sh | 9 +- test/test_type.sh | 154 +++++++++++----------- test/test_type_range.sh | 19 ++- test/test_unique.sh | 50 +++---- test/test_upgrade_auto.sh | 2 +- test/test_upgrade_failsafe.sh | 4 +- test/test_upgrade_interfaces.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_yang.sh | 70 +++++----- test/test_yang_anydata.sh | 21 ++- test/test_yang_default.sh | 2 +- test/test_yang_extension.sh | 6 +- test/test_yang_load.sh | 48 +++---- test/test_yang_namespace.sh | 11 +- yang/clixon/clixon-config@2020-08-17.yang | 15 ++- 81 files changed, 976 insertions(+), 830 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 32554c40..6472086d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,15 +30,27 @@ Expected: September 2020 Users may have to change how they access the system +* Netconf as default namespace has been disabled by default. + * Only requests on the form: `...` will be accepted + * All replies will be on the form: `...` + * Requests such as: `...` will not be accepted. + * You can revert this behaviour (to clixon pre-4.6 behaviour) by enabling `CLICON_NAMESPACE_NETCONF_DEFAULT` + * This API change is a consequence of: [copy-config's RPC cxobj parameter does not contain namespace #131](https://github.com/clicon/clixon/issues/131) * NACM datanode paths fixed to canonical namespace * The fix of [Cannot create or modify NACM data node access rule with path using JSON encoding #129](https://github.com/clicon/clixon/issues/129) leads that data-node paths, eg `...ex:table/ex:parameter` instance-identifiers are restricted to canonical namespace identifiers for both XML and JSON encoding. That is, if a symbol (such as `table` above) is a symbol in a module with prefix `ex`, another prefix cannot be used, even though defined with a `xmlns:` rule. * New clixon-config@2020-08-17.yang revision - * Added options for Restconf evhtp setting default bind socket address and ports `CLICON_RESTCONF_IPV4_ADDR`, `CLICON_RESTCONF_IPV6_ADDR`, `CLICON_RESTCONF_HTTP_PORT`, `CLICON_RESTCONF_HTTPS_PORT` + * Added options for Restconf evhtp setting default bind socket address and ports `CLICON_RESTCONF_IPV4_ADDR`, `CLICON_RESTCONF_IPV6_ADDR`, `CLICON_RESTCONF_HTTP_PORT`, `CLICON_RESTCONF_HTTPS_PORT`, `CLICON_NAMESPACE_NETCONF_DEFAULT` + +### C/CLI-API changes on existing features + +Developers may need to change their code ### Corrected Bugs * Fixed: [CLI crash if error-info is empty #134](https://github.com/clicon/clixon/issues/134) +* Fixed: [copy-config's RPC cxobj parameter does not contain namespace #131](https://github.com/clicon/clixon/issues/131) + * See also "Netconf as default namespace has been disabled by default" above * Fixed: [Cannot create or modify NACM data node access rule with path using JSON encoding #129](https://github.com/clicon/clixon/issues/129). The evaluation of NACM datanode rule path is assumed to be canonical namespace and cannot be overruled with `xmlns` rules. * Corrected error message for list min/max-value to comply to RFC 7950: a proper path is now returned, previously only the final list symbol was returned. This error-path is also now exposed in the CLI error message correctly. * Example: `/c/a1` diff --git a/apps/backend/backend_client.c b/apps/backend/backend_client.c index e1d94ef6..8a19657b 100644 --- a/apps/backend/backend_client.c +++ b/apps/backend/backend_client.c @@ -430,7 +430,7 @@ client_get_config_only(clicon_handle h, if (nacm_datanode_read(h, xret, xvec, xlen, username, xnacm) < 0) goto done; } - cprintf(cbret, ""); + cprintf(cbret, "", NETCONF_BASE_NAMESPACE); if (xret==NULL) cprintf(cbret, ""); else{ @@ -693,7 +693,7 @@ from_client_edit_config(clicon_handle h, } } assert(cbuf_len(cbret) == 0); - cprintf(cbret, ""); @@ -777,7 +777,7 @@ from_client_copy_config(clicon_handle h, goto ok; } xmldb_modified_set(h, target, 1); /* mark as dirty */ - cprintf(cbret, ""); + cprintf(cbret, "", NETCONF_BASE_NAMESPACE); ok: retval = 0; done: @@ -844,7 +844,7 @@ from_client_delete_config(clicon_handle h, goto ok; } xmldb_modified_set(h, target, 1); /* mark as dirty */ - cprintf(cbret, ""); + cprintf(cbret, "", NETCONF_BASE_NAMESPACE); ok: retval = 0; done: @@ -914,7 +914,7 @@ from_client_lock(clicon_handle h, } if (xmldb_lock(h, db, id) < 0) goto done; - cprintf(cbret, ""); + cprintf(cbret, "", NETCONF_BASE_NAMESPACE); ok: retval = 0; done: @@ -985,7 +985,7 @@ from_client_unlock(clicon_handle h, } else{ xmldb_unlock(h, db); - if (cprintf(cbret, "") < 0) + if (cprintf(cbret, "", NETCONF_BASE_NAMESPACE) < 0) goto done; } ok: @@ -1178,7 +1178,7 @@ from_client_get(clicon_handle h, if (nacm_datanode_read(h, xret, xvec, xlen, username, xnacm) < 0) goto done; } - cprintf(cbret, ""); /* OK */ + cprintf(cbret, "", NETCONF_BASE_NAMESPACE); /* OK */ if (xret==NULL) cprintf(cbret, ""); else{ @@ -1227,7 +1227,7 @@ from_client_close_session(clicon_handle h, xmldb_unlock_all(h, id); stream_ss_delete_all(h, ce_event_cb, (void*)ce); - cprintf(cbret, ""); + cprintf(cbret, "", NETCONF_BASE_NAMESPACE); return 0; } @@ -1279,7 +1279,7 @@ from_client_kill_session(clicon_handle h, } if (xmldb_islocked(h, db) == id) xmldb_unlock(h, db); - cprintf(cbret, ""); + cprintf(cbret, "", NETCONF_BASE_NAMESPACE); ok: retval = 0; done: @@ -1377,7 +1377,7 @@ from_client_create_subscription(clicon_handle h, if (stream_replay_trigger(h, stream, ce_event_cb, (void*)ce) < 0) goto done; } - cprintf(cbret, ""); + cprintf(cbret, "", NETCONF_BASE_NAMESPACE); ok: retval = 0; done: @@ -1416,7 +1416,7 @@ from_client_debug(clicon_handle h, clicon_debug_init(level, NULL); /* 0: dont debug, 1:debug */ setlogmask(LOG_UPTO(level?LOG_DEBUG:LOG_INFO)); /* for syslog */ clicon_log(LOG_NOTICE, "%s debug:%d", __FUNCTION__, clicon_debug_get()); - cprintf(cbret, ""); + cprintf(cbret, "", NETCONF_BASE_NAMESPACE); ok: retval = 0; done: @@ -1439,7 +1439,7 @@ from_client_ping(clicon_handle h, void *arg, void *regarg) { - cprintf(cbret, ""); + cprintf(cbret, "", NETCONF_BASE_NAMESPACE); return 0; } @@ -1462,7 +1462,7 @@ from_client_stats(clicon_handle h, int retval = -1; uint64_t nr; - cprintf(cbret, ""); + cprintf(cbret, "", NETCONF_BASE_NAMESPACE); nr=0; xml_stats_global(&nr); cprintf(cbret, "%" PRIu64 "", nr); @@ -1516,7 +1516,7 @@ from_client_restart_plugin(clicon_handle h, if (ret == 0) goto ok; /* cbret set */ } - cprintf(cbret, ""); + cprintf(cbret, "", NETCONF_BASE_NAMESPACE); ok: retval = 0; done: @@ -1525,7 +1525,6 @@ from_client_restart_plugin(clicon_handle h, return retval; } - /*! * @retval 0 OK * @retval -1 Error @@ -1546,7 +1545,8 @@ from_client_hello(clicon_handle h, } id++; clicon_session_id_set(h, id); - cprintf(cbret, "%u", id); + cprintf(cbret, "%u", + NETCONF_BASE_NAMESPACE, id); retval = 0; done: return retval; diff --git a/apps/backend/backend_commit.c b/apps/backend/backend_commit.c index cf020906..57514d19 100644 --- a/apps/backend/backend_commit.c +++ b/apps/backend/backend_commit.c @@ -680,7 +680,7 @@ from_client_commit(clicon_handle h, goto ok; } if (ret == 1) - cprintf(cbret, ""); + cprintf(cbret, "", NETCONF_BASE_NAMESPACE); ok: retval = 0; done: @@ -732,7 +732,7 @@ from_client_discard_changes(clicon_handle h, goto ok; } xmldb_modified_set(h, "candidate", 0); /* reset dirty bit */ - cprintf(cbret, ""); + cprintf(cbret, "", NETCONF_BASE_NAMESPACE); ok: retval = 0; done: @@ -829,7 +829,7 @@ from_client_validate(clicon_handle h, goto done; goto ok; } - cprintf(cbret, ""); + cprintf(cbret, "", NETCONF_BASE_NAMESPACE); /* Call plugin transaction end callbacks */ plugin_transaction_end_all(h, td); ok: diff --git a/apps/backend/backend_main.c b/apps/backend/backend_main.c index c5b1ef70..2dd7ff2a 100644 --- a/apps/backend/backend_main.c +++ b/apps/backend/backend_main.c @@ -697,6 +697,7 @@ main(int argc, clicon_configfile(h)); goto done; } + /* Treat unknown XML as anydata */ if (clicon_option_bool(h, "CLICON_YANG_UNKNOWN_ANYDATA") == 1) xml_bind_yang_unknown_anydata(1); @@ -712,6 +713,9 @@ main(int argc, if (xmldb_connect(h) < 0) goto done; + /* Set default namespace according to CLICON_NAMESPACE_NETCONF_DEFAULT */ + xml_nsctx_namespace_netconf_default(h); + /* Add (hardcoded) netconf features in case ietf-netconf loaded here * Otherwise it is loaded in netconf_module_load below */ diff --git a/apps/cli/cli_main.c b/apps/cli/cli_main.c index bfcd0d39..f335a18f 100644 --- a/apps/cli/cli_main.c +++ b/apps/cli/cli_main.c @@ -595,6 +595,9 @@ main(int argc, if (netconf_module_features(h) < 0) goto done; + /* Set default namespace according to CLICON_NAMESPACE_NETCONF_DEFAULT */ + xml_nsctx_namespace_netconf_default(h); + /* Treat unknwon XML as anydata */ if (clicon_option_bool(h, "CLICON_YANG_UNKNOWN_ANYDATA") == 1) xml_bind_yang_unknown_anydata(1); diff --git a/apps/cli/cli_show.c b/apps/cli/cli_show.c index 9c230aae..cae26d0e 100644 --- a/apps/cli/cli_show.c +++ b/apps/cli/cli_show.c @@ -525,7 +525,8 @@ cli_show_config1(clicon_handle h, xml2cli_cb(stdout, xc, prefix, gt, cligen_output); /* cli syntax */ break; case FORMAT_NETCONF: - cligen_output(stdout, "\n"); + cligen_output(stdout, "\n", + NETCONF_BASE_NAMESPACE); xc = NULL; /* Dont print xt itself */ while ((xc = xml_child_each(xt, xc, -1)) != NULL) clicon_xml2file_cb(stdout, xc, 2, 1, cligen_output); @@ -774,7 +775,8 @@ cli_show_auto1(clicon_handle h, xml2cli_cb(stdout, xp, prefix, gt, cligen_output); /* cli syntax */ break; case FORMAT_NETCONF: - fprintf(stdout, "\n"); + fprintf(stdout, "\n", + NETCONF_BASE_NAMESPACE); clicon_xml2file(stdout, xp, 2, 1); fprintf(stdout, "]]>]]>\n"); break; diff --git a/apps/netconf/netconf_main.c b/apps/netconf/netconf_main.c index e620b1ff..1f5f4aae 100644 --- a/apps/netconf/netconf_main.c +++ b/apps/netconf/netconf_main.c @@ -192,6 +192,9 @@ netconf_input_packet(clicon_handle h, * includes any "xmlns" attributes. */ while ((xa = xml_child_each(xrpc, xa, CX_ATTR)) != NULL){ + /* If attribute already exists, dont copy it */ + if (xml_find_type(xc, NULL, xml_name(xa), CX_ATTR) != NULL) + continue; if ((xa2 = xml_dup(xa)) ==NULL) goto done; if (xml_addsub(xc, xa2) < 0) @@ -522,12 +525,15 @@ main(int argc, cligen_bufthreshold = clicon_option_int(h, "CLICON_CLI_BUF_THRESHOLD"); cbuf_alloc_set(cligen_buflen, cligen_bufthreshold); + /* Set default namespace according to CLICON_NAMESPACE_NETCONF_DEFAULT */ + xml_nsctx_namespace_netconf_default(h); + /* Add (hardcoded) netconf features in case ietf-netconf loaded here * Otherwise it is loaded in netconf_module_load below */ if (netconf_module_features(h) < 0) goto done; - + /* Create top-level yang spec and store as option */ if ((yspec = yspec_new()) == NULL) goto done; diff --git a/apps/netconf/netconf_rpc.c b/apps/netconf/netconf_rpc.c index f0e29cd7..e1e2ccf5 100644 --- a/apps/netconf/netconf_rpc.c +++ b/apps/netconf/netconf_rpc.c @@ -93,12 +93,14 @@ netconf_get_config_subtree(clicon_handle h, if ((xdata = xpath_first(*xret, NULL, "/rpc-reply/data")) == NULL) goto ok; if (xml_filter(xfilter, xdata) < 0){ - clixon_xml_parse_va(YB_NONE, NULL, xret, NULL, "" + clixon_xml_parse_va(YB_NONE, NULL, xret, NULL, "" "operation-failed" - "applicatio" + "application" "error" "filtering" - ""); + "", + NETCONF_BASE_NAMESPACE + ); } ok: retval = 0; @@ -180,13 +182,14 @@ netconf_get_config(clicon_handle h, goto done; } else{ - clixon_xml_parse_va(YB_NONE, NULL, xret, NULL, "" + clixon_xml_parse_va(YB_NONE, NULL, xret, NULL, "" "operation-failed" "applicatio" "error" "filter type not supported" "type" - ""); + "", + NETCONF_BASE_NAMESPACE); } retval = 0; done: @@ -245,11 +248,12 @@ get_edit_opts(cxobj *xn, retval = 1; /* hunky dory */ return retval; parerr: /* parameter error, xret set */ - clixon_xml_parse_va(YB_NONE, NULL, xret, NULL, "" + clixon_xml_parse_va(YB_NONE, NULL, xret, NULL, "" "invalid-value" "protocol" "error" - ""); + "", + NETCONF_BASE_NAMESPACE); return 0; } @@ -322,11 +326,12 @@ netconf_edit_config(clicon_handle h, * (implement the features before removing these checks) */ if (testopt!=TEST_THEN_SET || erropt!=STOP_ON_ERROR){ - clixon_xml_parse_va(YB_NONE, NULL, xret, NULL, "" + clixon_xml_parse_va(YB_NONE, NULL, xret, NULL, "" "operation-not-supported" "protocol" "error" - ""); + "", + NETCONF_BASE_NAMESPACE); goto ok; } if (clicon_rpc_netconf_xml(h, xml_parent(xn), xret, NULL) < 0) @@ -377,13 +382,14 @@ netconf_get(clicon_handle h, goto done; } else{ - clixon_xml_parse_va(YB_NONE, NULL, xret, NULL, "" + clixon_xml_parse_va(YB_NONE, NULL, xret, NULL, "" "operation-failed" "applicatio" "error" "filter type not supported" "type" - ""); + "", + NETCONF_BASE_NAMESPACE); } retval = 0; done: @@ -505,13 +511,14 @@ netconf_create_subscription(clicon_handle h, if ((xfilter = xpath_first(xn, NULL, "//filter")) != NULL){ if ((ftype = xml_find_value(xfilter, "type")) != NULL){ if (strcmp(ftype, "xpath") != 0){ - clixon_xml_parse_va(YB_NONE, NULL, xret, NULL, "" + clixon_xml_parse_va(YB_NONE, NULL, xret, NULL, "" "operation-failed" "application" "error" "only xpath filter type supported" "type" - ""); + "", + NETCONF_BASE_NAMESPACE); goto ok; } } @@ -580,13 +587,14 @@ netconf_application_rpc(clicon_handle h, if (ys_module_by_xml(yspec, xn, &ymod) < 0) goto done; if (ymod == NULL){ - clixon_xml_parse_va(YB_NONE, NULL, xret, NULL, "" + clixon_xml_parse_va(YB_NONE, NULL, xret, NULL, "" "operation-failed" "rpc" "error" "%s" "Not recognized module" - "", xml_name(xn)); + "", + NETCONF_BASE_NAMESPACE, xml_name(xn)); goto ok; } yrpc = yang_find(ymod, Y_RPC, xml_name(xn)); @@ -717,13 +725,14 @@ netconf_rpc_dispatch(clicon_handle h, if ((retval = netconf_application_rpc(h, xe, xret)) < 0) goto done; if (retval == 0){ /* not handled by callback */ - clixon_xml_parse_va(YB_NONE, NULL, xret, NULL, "" + clixon_xml_parse_va(YB_NONE, NULL, xret, NULL, "" "operation-failed" "rpc" "error" "%s" "Not recognized" - "", xml_name(xe)); + "", + NETCONF_BASE_NAMESPACE, xml_name(xe)); goto done; } } diff --git a/apps/restconf/restconf_main_evhtp.c b/apps/restconf/restconf_main_evhtp.c index 327b0acc..4145d034 100644 --- a/apps/restconf/restconf_main_evhtp.c +++ b/apps/restconf/restconf_main_evhtp.c @@ -763,6 +763,9 @@ main(int argc, clicon_err(OE_DAEMON, EINVAL, "Restconf bind port is 0"); goto done; } + /* Set default namespace according to CLICON_NAMESPACE_NETCONF_DEFAULT */ + xml_nsctx_namespace_netconf_default(h); + /* Check server ssl certs */ if (use_ssl){ /* Init evhtp ssl config struct */ diff --git a/apps/restconf/restconf_main_fcgi.c b/apps/restconf/restconf_main_fcgi.c index 9ef98816..646e01da 100644 --- a/apps/restconf/restconf_main_fcgi.c +++ b/apps/restconf/restconf_main_fcgi.c @@ -325,6 +325,8 @@ main(int argc, cligen_bufthreshold = clicon_option_int(h, "CLICON_CLI_BUF_THRESHOLD"); cbuf_alloc_set(cligen_buflen, cligen_bufthreshold); + /* Set default namespace according to CLICON_NAMESPACE_NETCONF_DEFAULT */ + xml_nsctx_namespace_netconf_default(h); /* Add (hardcoded) netconf features in case ietf-netconf loaded here * Otherwise it is loaded in netconf_module_load below diff --git a/apps/restconf/restconf_methods.c b/apps/restconf/restconf_methods.c index c1389940..d2f38022 100644 --- a/apps/restconf/restconf_methods.c +++ b/apps/restconf/restconf_methods.c @@ -570,12 +570,18 @@ api_data_write(clicon_handle h, goto done; /* If we already have that default namespace, remove it in child */ if ((xa = xml_find_type(xdata, NULL, "xmlns", CX_ATTR)) != NULL){ - if (xml2ns(xparent, NULL, &namespace) < 0) + if (xml2ns(xparent, NULL, &namespace) < 0){ + clicon_debug(1, "%s G done", __FUNCTION__); goto done; + } + if (namespace == NULL){ + clicon_log_xml(LOG_DEBUG, xparent, "%s xparent:", __FUNCTION__); + /* XXX */ + } /* Set xmlns="" default namespace attribute (if diff from default) */ - if (strcmp(namespace, xml_value(xa))==0) + if (namespace && strcmp(namespace, xml_value(xa))==0) xml_purge(xa); - } + } } /* For internal XML protocol: add username attribute for access control */ @@ -583,7 +589,8 @@ api_data_write(clicon_handle h, /* Create text buffer for transfer to backend */ if ((cbx = cbuf_new()) == NULL) goto done; - cprintf(cbx, "", + cprintf(cbx, "", + NETCONF_BASE_NAMESPACE, username?username:"", NETCONF_BASE_PREFIX, NETCONF_BASE_NAMESPACE); /* bind nc to netconf namespace */ @@ -819,7 +826,8 @@ api_data_delete(clicon_handle h, /* For internal XML protocol: add username attribute for access control */ username = clicon_username_get(h); - cprintf(cbx, "", + cprintf(cbx, "", + NETCONF_BASE_NAMESPACE, username?username:"", NETCONF_BASE_PREFIX, NETCONF_BASE_NAMESPACE); /* bind nc to netconf namespace */ diff --git a/apps/restconf/restconf_methods_post.c b/apps/restconf/restconf_methods_post.c index 0b06e295..ca66f8bc 100644 --- a/apps/restconf/restconf_methods_post.c +++ b/apps/restconf/restconf_methods_post.c @@ -369,7 +369,8 @@ api_data_post(clicon_handle h, /* For internal XML protocol: add username attribute for access control */ username = clicon_username_get(h); - cprintf(cbx, "", + cprintf(cbx, "", + NETCONF_BASE_NAMESPACE, username?username:"", NETCONF_BASE_PREFIX, NETCONF_BASE_NAMESPACE); /* bind nc to netconf namespace */ @@ -632,6 +633,10 @@ api_operations_post_output(clicon_handle h, if (clicon_debug_get()) clicon_log_xml(LOG_DEBUG, xoutput, "%s xoutput:", __FUNCTION__); #endif + /* Remove original netconf default namespace. Somewhat unsure what "output" belongs to? */ + if ((xa = xml_find_type(xoutput, NULL, "xmlns", CX_ATTR)) != NULL) + if (xml_purge(xa) < 0) + goto done; /* Sanity check of outgoing XML * For now, skip outgoing checks. diff --git a/apps/restconf/restconf_stream_fcgi.c b/apps/restconf/restconf_stream_fcgi.c index 5a6dd800..e281af0f 100644 --- a/apps/restconf/restconf_stream_fcgi.c +++ b/apps/restconf/restconf_stream_fcgi.c @@ -266,8 +266,8 @@ restconf_stream(clicon_handle h, clicon_err(OE_XML, errno, "cbuf_new"); goto done; } - cprintf(cb, "%s", - EVENT_RFC5277_NAMESPACE, name); + cprintf(cb, "%s", + NETCONF_BASE_NAMESPACE, EVENT_RFC5277_NAMESPACE, name); /* Print all fields */ for (i=0; i"); + cprintf(cbret, "", NETCONF_BASE_NAMESPACE); return 0; } @@ -279,7 +279,7 @@ example_rpc(clicon_handle h, /* Clicon handle */ clicon_err(OE_XML, ENOENT, "No namespace given in rpc %s", xml_name(xe)); goto done; } - cprintf(cbret, ""); + cprintf(cbret, "", NETCONF_BASE_NAMESPACE); if (!xml_child_nr_type(xe, CX_ELMNT)) cprintf(cbret, ""); else while ((x = xml_child_each(xe, x, CX_ELMNT)) != NULL) { diff --git a/example/main/example_netconf.c b/example/main/example_netconf.c index b48491ae..f0e742cd 100644 --- a/example/main/example_netconf.c +++ b/example/main/example_netconf.c @@ -79,7 +79,7 @@ netconf_client_rpc(clicon_handle h, clicon_err(OE_XML, ENOENT, "No namespace given in rpc %s", xml_name(xe)); goto done; } - cprintf(cbret, ""); + cprintf(cbret, "", NETCONF_BASE_NAMESPACE); if (!xml_child_nr_type(xe, CX_ELMNT)) cprintf(cbret, ""); else while ((x = xml_child_each(xe, x, CX_ELMNT)) != NULL) { diff --git a/example/main/example_restconf.c b/example/main/example_restconf.c index 89802b7a..5fdc435f 100644 --- a/example/main/example_restconf.c +++ b/example/main/example_restconf.c @@ -337,7 +337,7 @@ restconf_client_rpc(clicon_handle h, clicon_err(OE_XML, ENOENT, "No namespace given in rpc %s", xml_name(xe)); goto done; } - cprintf(cbret, ""); + cprintf(cbret, "", NETCONF_BASE_NAMESPACE); if (!xml_child_nr_type(xe, CX_ELMNT)) cprintf(cbret, ""); else while ((x = xml_child_each(xe, x, CX_ELMNT)) != NULL) { diff --git a/include/clixon_custom.h b/include/clixon_custom.h index 865b3358..3db197f5 100644 --- a/include/clixon_custom.h +++ b/include/clixon_custom.h @@ -47,14 +47,6 @@ */ #undef RPC_USERNAME_ASSERT -/* If rpc call does not have a namespace (eg using xmlns) then use the default - * NETCONF namespace (see rfc6241 3.1) - * Undefine it if you want to ensure strict namespace assignment on all netconf and - * XML statements. - * The base namespace is defined as NETCONF_BASE_NAMESPACE - */ -#define USE_NETCONF_NS_AS_DEFAULT - /*! Tag for wrong handling of identityref prefixes (XML encoding) * See https://github.com/clicon/clixon/issues/90 * Instead of using generic xmlns prefix bindings, the module's own prefix diff --git a/lib/clixon/clixon_options.h b/lib/clixon/clixon_options.h index 4830d849..1f20937c 100644 --- a/lib/clixon/clixon_options.h +++ b/lib/clixon/clixon_options.h @@ -142,7 +142,7 @@ int clicon_option_int(clicon_handle h, const char *name); int clicon_option_int_set(clicon_handle h, const char *name, int val); /* Option values gixen as bool, default false */ -int clicon_option_bool(clicon_handle h, const char *name); +int clicon_option_bool(clicon_handle h, const char *name); int clicon_option_bool_set(clicon_handle h, const char *name, int val); /* Delete a single option via handle */ diff --git a/lib/clixon/clixon_xml_nsctx.h b/lib/clixon/clixon_xml_nsctx.h index b3f34d1d..a13f766a 100644 --- a/lib/clixon/clixon_xml_nsctx.h +++ b/lib/clixon/clixon_xml_nsctx.h @@ -48,6 +48,7 @@ /* * Prototypes */ +int xml_nsctx_namespace_netconf_default(clicon_handle h); cvec *xml_nsctx_init(char *prefix, char *ns); int xml_nsctx_free(cvec *nsc); char *xml_nsctx_get(cvec *nsc, char *prefix); diff --git a/lib/src/clixon_datastore_write.c b/lib/src/clixon_datastore_write.c index 6c70ee7b..0badffe9 100644 --- a/lib/src/clixon_datastore_write.c +++ b/lib/src/clixon_datastore_write.c @@ -704,6 +704,7 @@ text_modify(clicon_handle h, /*! Modify a top-level base tree x0 with modification tree x1 * @param[in] h Clicon handle * @param[in] x0 Base xml tree (can be NULL in add scenarios) + * @param[in] x0t * @param[in] x1 XML tree which modifies base * @param[in] x1t Request root node (nacm needs this) * @param[in] yspec Top-level yang spec (if y is NULL) diff --git a/lib/src/clixon_nacm.c b/lib/src/clixon_nacm.c index ffc081e0..1a3965f7 100644 --- a/lib/src/clixon_nacm.c +++ b/lib/src/clixon_nacm.c @@ -546,7 +546,8 @@ nacm_data_write_xrule_xml(cxobj *xn, if (strcmp(module_pattern, "*") != 0){ if (ys_module_by_xml(yspec, xn, &ymod) < 0) goto done; - if (strcmp(yang_argument_get(ymod), module_pattern) != 0) + /* ymod is NULL (xn is "config") Can this breach the NACM rule? */ + if (ymod && strcmp(yang_argument_get(ymod), module_pattern) != 0) goto nomatch; } action = xml_find_body(xrule, "action"); /* mandatory */ diff --git a/lib/src/clixon_netconf_lib.c b/lib/src/clixon_netconf_lib.c index d9862987..e0a0fa5b 100644 --- a/lib/src/clixon_netconf_lib.c +++ b/lib/src/clixon_netconf_lib.c @@ -88,10 +88,11 @@ netconf_in_use(cbuf *cb, int retval = -1; char *encstr = NULL; - if (cprintf(cb, "" + if (cprintf(cb, "" "%s" "in-use" "error", + NETCONF_BASE_NAMESPACE, type) <0) goto err; if (message){ @@ -127,13 +128,18 @@ netconf_invalid_value_xml(cxobj **xret, int retval =-1; cxobj *xerr = NULL; char *encstr = NULL; - + cxobj *xa; + if (*xret == NULL){ if ((*xret = xml_new("rpc-reply", NULL, CX_ELMNT)) == NULL) goto done; } else if (xml_name_set(*xret, "rpc-reply") < 0) goto done; + if ((xa = xml_new("xmlns", *xret, CX_ATTR)) == NULL) + goto done; + if (xml_value_set(xa, NETCONF_BASE_NAMESPACE) < 0) + goto done; if ((xerr = xml_new("rpc-error", *xret, CX_ELMNT)) == NULL) goto done; if (clixon_xml_parse_va(YB_NONE, NULL, &xerr, NULL, @@ -197,10 +203,11 @@ netconf_too_big(cbuf *cb, int retval = -1; char *encstr = NULL; - if (cprintf(cb, "" + if (cprintf(cb, "" "%s" "too-big" "error", + NETCONF_BASE_NAMESPACE, type) <0) goto err; if (message){ @@ -238,12 +245,12 @@ netconf_missing_attribute(cbuf *cb, int retval = -1; char *encstr = NULL; - if (cprintf(cb, "" + if (cprintf(cb, "" "%s" "missing-attribute" "%s" "error", - type, info) <0) + NETCONF_BASE_NAMESPACE, type, info) <0) goto err; if (message){ if (xml_chardata_encode(&encstr, "%s", message) < 0) @@ -308,6 +315,7 @@ netconf_bad_attribute_xml(cxobj **xret, int retval = -1; cxobj *xerr = NULL; char *encstr = NULL; + cxobj *xa; if (*xret == NULL){ if ((*xret = xml_new("rpc-reply", NULL, CX_ELMNT)) == NULL) @@ -315,6 +323,10 @@ netconf_bad_attribute_xml(cxobj **xret, } else if (xml_name_set(*xret, "rpc-reply") < 0) goto done; + if ((xa = xml_new("xmlns", *xret, CX_ATTR)) == NULL) + goto done; + if (xml_value_set(xa, NETCONF_BASE_NAMESPACE) < 0) + goto done; if ((xerr = xml_new("rpc-error", *xret, CX_ELMNT)) == NULL) goto done; if (clixon_xml_parse_va(YB_NONE, NULL, &xerr, NULL, "%s" @@ -354,12 +366,12 @@ netconf_unknown_attribute(cbuf *cb, int retval = -1; char *encstr = NULL; - if (cprintf(cb, "" + if (cprintf(cb, "" "%s" "unknown-attribute" "%s" "error", - type, info) <0) + NETCONF_BASE_NAMESPACE, type, info) <0) goto err; if (message){ if (xml_chardata_encode(&encstr, "%s", message) < 0) @@ -397,13 +409,19 @@ netconf_common_xml(cxobj **xret, int retval =-1; cxobj *xerr; char *encstr = NULL; + cxobj *xa; if (*xret == NULL){ if ((*xret = xml_new("rpc-reply", NULL, CX_ELMNT)) == NULL) goto done; + if ((xa = xml_new("xmlns", *xret, CX_ATTR)) == NULL) + goto done; + if (xml_value_set(xa, NETCONF_BASE_NAMESPACE) < 0) + goto done; } else if (xml_name_set(*xret, "rpc-reply") < 0) goto done; + if ((xerr = xml_new("rpc-error", *xret, CX_ELMNT)) == NULL) goto done; if (clixon_xml_parse_va(YB_NONE, NULL, &xerr, NULL, "%s" @@ -647,6 +665,7 @@ netconf_access_denied_xml(cxobj **xret, int retval =-1; cxobj *xerr; char *encstr = NULL; + cxobj *xa; if (*xret == NULL){ if ((*xret = xml_new("rpc-reply", NULL, CX_ELMNT)) == NULL) @@ -654,6 +673,10 @@ netconf_access_denied_xml(cxobj **xret, } else if (xml_name_set(*xret, "rpc-reply") < 0) goto done; + if ((xa = xml_new("xmlns", *xret, CX_ATTR)) == NULL) + goto done; + if (xml_value_set(xa, NETCONF_BASE_NAMESPACE) < 0) + goto done; if ((xerr = xml_new("rpc-error", *xret, CX_ELMNT)) == NULL) goto done; if (clixon_xml_parse_va(YB_NONE, NULL, &xerr, NULL, "%s" @@ -690,12 +713,12 @@ netconf_lock_denied(cbuf *cb, int retval = -1; char *encstr = NULL; - if (cprintf(cb, "" + if (cprintf(cb, "" "protocol" "lock-denied" "%s" "error", - info) <0) + NETCONF_BASE_NAMESPACE, info) <0) goto err; if (message){ if (xml_chardata_encode(&encstr, "%s", message) < 0) @@ -730,11 +753,11 @@ netconf_resource_denied(cbuf *cb, int retval = -1; char *encstr = NULL; - if (cprintf(cb, "" + if (cprintf(cb, "" "%s" "resource-denied" "error", - type) <0) + NETCONF_BASE_NAMESPACE, type) <0) goto err; if (message){ if (xml_chardata_encode(&encstr, "%s", message) < 0) @@ -770,11 +793,11 @@ netconf_rollback_failed(cbuf *cb, int retval = -1; char *encstr = NULL; - if (cprintf(cb, "" + if (cprintf(cb, "" "%s" "rollback-failed" "error", - type) <0) + NETCONF_BASE_NAMESPACE, type) <0) goto err; if (message){ if (xml_chardata_encode(&encstr, "%s", message) < 0) @@ -809,10 +832,11 @@ netconf_data_exists(cbuf *cb, int retval = -1; char *encstr = NULL; - if (cprintf(cb, "" + if (cprintf(cb, "" "application" "data-exists" - "error") <0) + "error", + NETCONF_BASE_NAMESPACE) <0) goto err; if (message){ if (xml_chardata_encode(&encstr, "%s", message) < 0) @@ -877,6 +901,7 @@ netconf_data_missing_xml(cxobj **xret, int retval = -1; char *encstr = NULL; cxobj *xerr; + cxobj *xa; if (*xret == NULL){ if ((*xret = xml_new("rpc-reply", NULL, CX_ELMNT)) == NULL) @@ -884,6 +909,10 @@ netconf_data_missing_xml(cxobj **xret, } else if (xml_name_set(*xret, "rpc-reply") < 0) goto done; + if ((xa = xml_new("xmlns", *xret, CX_ATTR)) == NULL) + goto done; + if (xml_value_set(xa, NETCONF_BASE_NAMESPACE) < 0) + goto done; if ((xerr = xml_new("rpc-error", *xret, CX_ELMNT)) == NULL) goto done; if (clixon_xml_parse_va(YB_NONE, NULL, &xerr, NULL, @@ -929,11 +958,11 @@ netconf_operation_not_supported(cbuf *cb, int retval = -1; char *encstr = NULL; - if (cprintf(cb, "" + if (cprintf(cb, "" "%s" "operation-not-supported" "error", - type) <0) + NETCONF_BASE_NAMESPACE, type) <0) goto err; if (message){ if (xml_chardata_encode(&encstr, "%s", message) < 0) @@ -1005,6 +1034,7 @@ netconf_operation_failed_xml(cxobj **xret, int retval =-1; cxobj *xerr; char *encstr = NULL; + cxobj *xa; if (*xret == NULL){ if ((*xret = xml_new("rpc-reply", NULL, CX_ELMNT)) == NULL) @@ -1012,6 +1042,10 @@ netconf_operation_failed_xml(cxobj **xret, } else if (xml_name_set(*xret, "rpc-reply") < 0) goto done; + if ((xa = xml_new("xmlns", *xret, CX_ATTR)) == NULL) + goto done; + if (xml_value_set(xa, NETCONF_BASE_NAMESPACE) < 0) + goto done; if ((xerr = xml_new("rpc-error", *xret, CX_ELMNT)) == NULL) goto done; if (clixon_xml_parse_va(YB_NONE, NULL, &xerr, NULL, "%s" @@ -1084,6 +1118,7 @@ netconf_malformed_message_xml(cxobj **xret, int retval =-1; cxobj *xerr; char *encstr = NULL; + cxobj *xa; if (*xret == NULL){ if ((*xret = xml_new("rpc-reply", NULL, CX_ELMNT)) == NULL) @@ -1091,6 +1126,10 @@ netconf_malformed_message_xml(cxobj **xret, } else if (xml_name_set(*xret, "rpc-reply") < 0) goto done; + if ((xa = xml_new("xmlns", *xret, CX_ATTR)) == NULL) + goto done; + if (xml_value_set(xa, NETCONF_BASE_NAMESPACE) < 0) + goto done; if ((xerr = xml_new("rpc-error", *xret, CX_ELMNT)) == NULL) goto done; if (clixon_xml_parse_va(YB_NONE, NULL, &xerr, NULL, "rpc" @@ -1131,6 +1170,7 @@ netconf_data_not_unique_xml(cxobj **xret, cxobj *xerr; cxobj *xinfo; cbuf *cb = NULL; + cxobj *xa; if (*xret == NULL){ if ((*xret = xml_new("rpc-reply", NULL, CX_ELMNT)) == NULL) @@ -1138,6 +1178,10 @@ netconf_data_not_unique_xml(cxobj **xret, } else if (xml_name_set(*xret, "rpc-reply") < 0) goto done; + if ((xa = xml_new("xmlns", *xret, CX_ATTR)) == NULL) + goto done; + if (xml_value_set(xa, NETCONF_BASE_NAMESPACE) < 0) + goto done; if ((xerr = xml_new("rpc-error", *xret, CX_ELMNT)) == NULL) goto done; if (clixon_xml_parse_va(YB_NONE, NULL, &xerr, NULL, @@ -1190,6 +1234,7 @@ netconf_minmax_elements_xml(cxobj **xret, cxobj *xerr; char *path = NULL; cbuf *cb = NULL; + cxobj *xa; if (*xret == NULL){ if ((*xret = xml_new("rpc-reply", NULL, CX_ELMNT)) == NULL) @@ -1197,6 +1242,10 @@ netconf_minmax_elements_xml(cxobj **xret, } else if (xml_name_set(*xret, "rpc-reply") < 0) goto done; + if ((xa = xml_new("xmlns", *xret, CX_ATTR)) == NULL) + goto done; + if (xml_value_set(xa, NETCONF_BASE_NAMESPACE) < 0) + goto done; if ((xerr = xml_new("rpc-error", *xret, CX_ELMNT)) == NULL) goto done; if ((cb = cbuf_new()) == NULL){ @@ -1396,9 +1445,10 @@ netconf_err2cb(cxobj *xerr, cprintf(cberr, "%s ", xml_body(x)); if ((x=xpath_first(xerr, NULL, "//error-message"))!=NULL) cprintf(cberr, "%s ", xml_body(x)); - if ((x=xpath_first(xerr, NULL, "//error-info"))!=NULL && - xml_child_nr(x) > 0) - clicon_xml2cbuf(cberr, xml_child_i(x,0), 0, 0, -1); + if ((x=xpath_first(xerr, NULL, "//error-info")) != NULL && + xml_child_nr(x) > 0){ + clicon_xml2cbuf(cberr, xml_child_i(x, 0), 0, 0, -1); + } if ((x=xpath_first(xerr, NULL, "//error-app-tag"))!=NULL) cprintf(cberr, ": %s ", xml_body(x)); if ((x=xpath_first(xerr, NULL, "//error-path"))!=NULL) diff --git a/lib/src/clixon_proto_client.c b/lib/src/clixon_proto_client.c index aae2b758..e87f93fd 100644 --- a/lib/src/clixon_proto_client.c +++ b/lib/src/clixon_proto_client.c @@ -84,7 +84,7 @@ /*! Send internal netconf rpc from client to backend * @param[in] h CLICON handle - * @param[in] msg Encoded message. Deallocate woth free + * @param[in] msg Encoded message. Deallocate with free * @param[out] xret0 Return value from backend as xml tree. Free w xml_free * @param[inout] sock0 If pointer exists, do not close socket to backend on success * and return it here. For keeping a notify socket open @@ -337,7 +337,7 @@ clicon_rpc_get_config(clicon_handle h, goto done; if ((cb = cbuf_new()) == NULL) goto done; - cprintf(cb, "<%s/><%s/>", + "" + "<%s/><%s/>", + NETCONF_BASE_NAMESPACE, username?username:"", db1, db2)) == NULL) goto done; @@ -536,7 +538,9 @@ clicon_rpc_delete_config(clicon_handle h, goto done; username = clicon_username_get(h); if ((msg = clicon_msg_encode(session_id, - "<%s/>none", + "" + "<%s/>none", + NETCONF_BASE_NAMESPACE, username?username:"", db)) == NULL) goto done; if (clicon_rpc_msg(h, msg, &xret, NULL) < 0) @@ -575,7 +579,9 @@ clicon_rpc_lock(clicon_handle h, goto done; username = clicon_username_get(h); if ((msg = clicon_msg_encode(session_id, - "<%s/>", + "" + "<%s/>", + NETCONF_BASE_NAMESPACE, username?username:"", db)) == NULL) goto done; if (clicon_rpc_msg(h, msg, &xret, NULL) < 0) @@ -614,7 +620,10 @@ clicon_rpc_unlock(clicon_handle h, goto done; username = clicon_username_get(h); if ((msg = clicon_msg_encode(session_id, - "<%s/>", username?username:"", db)) == NULL) + "" + "<%s/>", + NETCONF_BASE_NAMESPACE, + username?username:"", db)) == NULL) goto done; if (clicon_rpc_msg(h, msg, &xret, NULL) < 0) goto done; @@ -690,7 +699,7 @@ clicon_rpc_get(clicon_handle h, goto done; if ((cb = cbuf_new()) == NULL) goto done; - cprintf(cb, "", - username?username:"")) == NULL) + "", + NETCONF_BASE_NAMESPACE, username?username:"")) == NULL) goto done; if (clicon_rpc_msg(h, msg, &xret, NULL) < 0) goto done; @@ -820,7 +829,8 @@ clicon_rpc_kill_session(clicon_handle h, goto done; username = clicon_username_get(h); if ((msg = clicon_msg_encode(my_session_id, - "%u", + "%u", + NETCONF_BASE_NAMESPACE, username?username:"", session_id)) == NULL) goto done; if (clicon_rpc_msg(h, msg, &xret, NULL) < 0) @@ -859,7 +869,9 @@ clicon_rpc_validate(clicon_handle h, goto done; username = clicon_username_get(h); if ((msg = clicon_msg_encode(session_id, - "<%s/>", username?username:"", db)) == NULL) + "<%s/>", + NETCONF_BASE_NAMESPACE, + username?username:"", db)) == NULL) goto done; if (clicon_rpc_msg(h, msg, &xret, NULL) < 0) goto done; @@ -895,7 +907,9 @@ clicon_rpc_commit(clicon_handle h) goto done; username = clicon_username_get(h); if ((msg = clicon_msg_encode(session_id, - "", username?username:"")) == NULL) + "", + NETCONF_BASE_NAMESPACE, + username?username:"")) == NULL) goto done; if (clicon_rpc_msg(h, msg, &xret, NULL) < 0) goto done; @@ -931,7 +945,9 @@ clicon_rpc_discard_changes(clicon_handle h) goto done; username = clicon_username_get(h); if ((msg = clicon_msg_encode(session_id, - "", username?username:"")) == NULL) + "", + NETCONF_BASE_NAMESPACE, + username?username:"")) == NULL) goto done; if (clicon_rpc_msg(h, msg, &xret, NULL) < 0) goto done; @@ -975,10 +991,11 @@ clicon_rpc_create_subscription(clicon_handle h, goto done; username = clicon_username_get(h); if ((msg = clicon_msg_encode(session_id, - "" + "" "%s" "" "", + NETCONF_BASE_NAMESPACE, username?username:"", EVENT_RFC5277_NAMESPACE, stream?stream:"", filter?filter:"")) == NULL) @@ -1019,7 +1036,8 @@ clicon_rpc_debug(clicon_handle h, goto done; username = clicon_username_get(h); if ((msg = clicon_msg_encode(session_id, - "%d", + "%d", + NETCONF_BASE_NAMESPACE, username?username:"", CLIXON_LIB_NS, level)) == NULL) diff --git a/lib/src/clixon_xml_nsctx.c b/lib/src/clixon_xml_nsctx.c index aff19498..eac9f8d3 100644 --- a/lib/src/clixon_xml_nsctx.c +++ b/lib/src/clixon_xml_nsctx.c @@ -64,11 +64,34 @@ #include "clixon_hash.h" #include "clixon_handle.h" #include "clixon_log.h" +#include "clixon_options.h" #include "clixon_yang.h" #include "clixon_xml.h" #include "clixon_yang_module.h" #include "clixon_xml_nsctx.h" +/* Undefine if you want to ensure strict namespace assignment on all netconf + * and XML statements according to the standard RFC 6241. + * If defined, top-level rpc calls need not have namespaces (eg using xmlns=) + * since the default NETCONF namespace will be assumed. (This is not standard). + * See rfc6241 3.1: urn:ietf:params:xml:ns:netconf:base:1.0. + */ +static int _USE_NAMESPACE_NETCONF_DEFAULT = 0; + +/*! Set if use internal default namespace mechanism or not + * + * This function shouldnt really be here, it sets a local variable from the value of the + * option CLICON_NAMESPACE_NETCONF_DEFAULT, but the code where it is used is deep in the call + * stack and cannot get the clicon handle currently. + * @param[in] h Clicon handle + */ +int +xml_nsctx_namespace_netconf_default(clicon_handle h) +{ + _USE_NAMESPACE_NETCONF_DEFAULT = clicon_option_bool(h, "CLICON_NAMESPACE_NETCONF_DEFAULT"); + return 0; +} + /*! Create and initialize XML namespace context * @param[in] prefix Namespace prefix, or NULL for default * @param[in] ns Set this namespace. If NULL create empty nsctx @@ -220,12 +243,12 @@ xml_nsctx_node1(cxobj *xn, } } if ((xp = xml_parent(xn)) == NULL){ -#ifdef USE_NETCONF_NS_AS_DEFAULT - /* If not default namespace defined, use the base netconf ns as default */ - if (xml_nsctx_get(nsc, NULL) == NULL) - if (xml_nsctx_add(nsc, NULL, NETCONF_BASE_NAMESPACE) < 0) - goto done; -#endif + if (_USE_NAMESPACE_NETCONF_DEFAULT){ + /* If not default namespace defined, use the base netconf ns as default */ + if (xml_nsctx_get(nsc, NULL) == NULL) + if (xml_nsctx_add(nsc, NULL, NETCONF_BASE_NAMESPACE) < 0) + goto done; + } } else if (xml_nsctx_node1(xp, nsc) < 0) @@ -450,14 +473,12 @@ xml2ns(cxobj *x, goto done; } /* If no parent, return default namespace if defined */ -#ifdef USE_NETCONF_NS_AS_DEFAULT - else{ + else if (_USE_NAMESPACE_NETCONF_DEFAULT){ if (prefix == NULL) ns = NETCONF_BASE_NAMESPACE; else ns = NULL; } -#endif } /* Set default namespace cache (since code is at this point, * no cache was found diff --git a/test/lib.sh b/test/lib.sh index 63f2bafd..a69a61e0 100755 --- a/test/lib.sh +++ b/test/lib.sh @@ -88,6 +88,9 @@ testname= # eg logging to a file: RCLOG="-l f/www-data/restconf.log" : ${RCLOG:=} +# Default netconf namespace statement, typically as placed on top-level ]]>]]>' | $clixon_netconf -qef $cfg 2> /dev/null) + reply=$(echo ']]>]]>' | $clixon_netconf -qef $cfg 2> /dev/null) let i=0; while [[ $reply != "]]>]]>' | clixon_netconf -qef $cfg 2> /dev/null) + reply=$(echo ']]>]]>' | clixon_netconf -qef $cfg 2> /dev/null) let i++; # echo "wait_backend $i" if [ $i -ge $RCWAIT ]; then diff --git a/test/test_api.sh b/test/test_api.sh index bc00d74a..9cc70707 100755 --- a/test/test_api.sh +++ b/test/test_api.sh @@ -167,7 +167,7 @@ trigger_rpc(clicon_handle h, /* Clicon handle */ val = NULL; clicon_debug(1, "%s Method 3: val:%s", __FUNCTION__, val?val:"null"); - cprintf(cbret, ""); + cprintf(cbret, "", NETCONF_BASE_NAMESPACE); retval = 0; done: clicon_debug(1, "%s retval:%d", __FUNCTION__, retval); diff --git a/test/test_augment.sh b/test/test_augment.sh index bd536330..2ae6809f 100755 --- a/test/test_augment.sh +++ b/test/test_augment.sh @@ -181,39 +181,39 @@ fi # mandatory-leaf See RFC7950 Sec 7.17 new "netconf set interface with augmented type and mandatory leaf" -expecteof "$clixon_netconf -qf $cfg" 0 ' - +expecteof "$clixon_netconf -qf $cfg" 0 " + e1 mymod:some-new-iftype true - ]]>]]>' "^]]>]]>$" + ]]>]]>" "^]]>]]>$" new "netconf verify get with refined ports" -expecteof "$clixon_netconf -qf $cfg" 0 ']]>]]>' '^e1mymod:some-new-iftypetrue808080]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^e1mymod:some-new-iftypetrue808080]]>]]>$" new "netconf set identity defined in other" -expecteof "$clixon_netconf -qf $cfg" 0 ' - +expecteof "$clixon_netconf -qf $cfg" 0 " + e2 fddi true if:fddi - ]]>]]>' "^]]>]]>$" + ]]>]]>" "^]]>]]>$" new "netconf validate ok" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" '^]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" new "netconf set identity defined in main" -expecteof "$clixon_netconf -qf $cfg" 0 ' - +expecteof "$clixon_netconf -qf $cfg" 0 " + e3 fddi true mymod:you - ]]>]]>' "^]]>]]>$" + ]]>]]>" "^]]>]]>$" new "netconf commit ok" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" '^]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" # restconf and augment new "restconf get augment json" diff --git a/test/test_choice.sh b/test/test_choice.sh index c24cb561..d69d80af 100755 --- a/test/test_choice.sh +++ b/test/test_choice.sh @@ -132,43 +132,42 @@ fi # First vanilla (protocol) case new "netconf validate empty" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" new "netconf set protocol both udp and tcp" -expecteof "$clixon_netconf -qf $cfg" 0 ']]>]]>' "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" new "netconf validate both udp and tcp fail" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^applicationbad-elementudperrorElement in choice statement already exists]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^applicationbad-elementudperrorElement in choice statement already exists]]>]]>$" new "netconf discard-changes" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" new "netconf set empty protocol" -expecteof "$clixon_netconf -qf $cfg" 0 ']]>]]>' "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" new "netconf validate protocol" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" new "netconf set protocol tcp" -expecteof "$clixon_netconf -qf $cfg" 0 ']]>]]>' "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" new "netconf get protocol tcp" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" '^]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" new "netconf commit protocol tcp" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" new "netconf changing from TCP to UDP (RFC7950 7.9.6)" -expecteof "$clixon_netconf -qf $cfg" 0 ']]>]]>' '^]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" new "netconf get protocol udp" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" '^]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" new "netconf commit protocol udp" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" #-- restconf - new "restconf DELETE whole datastore" expectpart "$(curl $CURLOPTS -X DELETE $RCPROTO://localhost/restconf/data)" 0 "HTTP/1.1 204 No Content" @@ -204,81 +203,81 @@ expectfn "$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 ']]>]]>' "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" new "netconf validate both udp and tcp fail" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^applicationbad-elementudperrorElement in choice statement already exists]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^applicationbad-elementudperrorElement in choice statement already exists]]>]]>$" new "netconf discard-changes" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" new "netconf set shorthand tcp" -expecteof "$clixon_netconf -qf $cfg" 0 ']]>]]>' "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" new "netconf changing from TCP to UDP (RFC7950 7.9.6)" -expecteof "$clixon_netconf -qf $cfg" 0 ']]>]]>' '^]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" new "netconf get shorthand udp" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" '^]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" new "netconf validate shorthand" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" new "netconf discard-changes" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" # Third check mandatory new "netconf set empty mandatory" -expecteof "$clixon_netconf -qf $cfg" 0 ']]>]]>' "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" new "netconf get mandatory empty" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" '^]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" new "netconf validate mandatory" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" '^applicationdata-missingmissing-choicenameerror]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^applicationdata-missingmissing-choicenameerror]]>]]>$" new "netconf set mandatory udp" -expecteof "$clixon_netconf -qf $cfg" 0 ']]>]]>' "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" new "netconf get mandatory udp" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" '^]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" new "netconf validate mandatory" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" new "netconf discard-changes" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" # Choice with multiple items new "netconf choice multiple items first" -expecteof "$clixon_netconf -qf $cfg" 0 ' +expecteof "$clixon_netconf -qf $cfg" 0 " 0 1 2 -]]>]]>' "^]]>]]>$" +]]>]]>" "^]]>]]>$" new "netconf validate multiple ok" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" new "netconf choice multiple items second" -expecteof "$clixon_netconf -qf $cfg" 0 ' +expecteof "$clixon_netconf -qf $cfg" 0 " 0 1 -]]>]]>' "^]]>]]>$" +]]>]]>" "^]]>]]>$" new "netconf validate multiple ok" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" new "netconf choice multiple items mix" -expecteof "$clixon_netconf -qf $cfg" 0 ' +expecteof "$clixon_netconf -qf $cfg" 0 " 0 2 2 -]]>]]>' "^]]>]]>$" +]]>]]>" "^]]>]]>$" new "netconf validate multiple error" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" '^applicationbad-elementmcerrorElement in choice statement already exists]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^applicationbad-elementmcerrorElement in choice statement already exists]]>]]>$" if [ $RC -ne 0 ]; then new "Kill restconf daemon" diff --git a/test/test_cli.sh b/test/test_cli.sh index c033deb7..687a06f2 100755 --- a/test/test_cli.sh +++ b/test/test_cli.sh @@ -123,7 +123,7 @@ new "cli debug reset" expectfn "$clixon_cli -1 -f $cfg -l o debug level 0" 0 "^$" new "cli rpc" -expectpart "$($clixon_cli -1 -f $cfg -l o rpc ipv4)" 0 'ipv442' +expectpart "$($clixon_cli -1 -f $cfg -l o rpc ipv4)" 0 "ipv442" if [ $BE -eq 0 ]; then exit # BE diff --git a/test/test_cli_multikey.sh b/test/test_cli_multikey.sh index 5d57d08b..2c517c8f 100755 --- a/test/test_cli_multikey.sh +++ b/test/test_cli_multikey.sh @@ -104,8 +104,7 @@ new "set 1 v2 again" expectfn "$clixon_cli -1 -f $cfg set ex x a 1 b v2" 0 "" new "show conf" -expecteof "$clixon_netconf -qf $cfg" 0 ']]>]]>' '^1v11v21v32v12v22v3]]>]]>$' - +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^1v11v21v32v12v22v3]]>]]>$" # ordered-by user new "set 1 v1" @@ -124,7 +123,7 @@ new "set 2 v2" expectfn "$clixon_cli -1 -f $cfg set ex y a 2 b v2" 0 "" new "show conf" -expecteof "$clixon_netconf -qf $cfg" 0 ']]>]]>' '^1v11v21v32v12v22v31v12v11v21v32v2]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^1v11v21v32v12v22v31v12v11v21v32v2]]>]]>$" if [ $BE -eq 0 ]; then exit # BE diff --git a/test/test_copy_config.sh b/test/test_copy_config.sh index 8cd20863..0b6954ba 100755 --- a/test/test_copy_config.sh +++ b/test/test_copy_config.sh @@ -77,86 +77,86 @@ if [ $BE -ne 0 ]; then fi new "Add config to candidate" -expecteof "$clixon_netconf -qf $cfg" 0 'eth/0/0ex:ethnone ]]>]]>' "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "eth/0/0ex:ethnone ]]>]]>" "^]]>]]>$" new "netconf commit to running" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" new "Delete candidate" -expecteof "$clixon_netconf -qf $cfg" 0 'eth/0/0ex:ethnone ]]>]]>' '^]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "eth/0/0ex:ethnone ]]>]]>" "^]]>]]>$" # 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 ']]>]]>' '^]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" new "Check startup empty" -expecteof "$clixon_netconf -qf $cfg" 0 ']]>]]>' '^]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" new "copy running->startup" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" new "copy running->candidate" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" # Here startup and candidate have content new "Check candidate content" -expecteof "$clixon_netconf -qf $cfg" 0 ']]>]]>' '^eth/0/0ex:ethtrue]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^eth/0/0ex:ethtrue]]>]]>$" new "Check startup content" -expecteof "$clixon_netconf -qf $cfg" 0 ']]>]]>' '^eth/0/0ex:ethtrue]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^eth/0/0ex:ethtrue]]>]]>$" new "Delete startup" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" # Here startup is empty and candidate has content # test candidate->startup new "Check startup empty" -expecteof "$clixon_netconf -qf $cfg" 0 ']]>]]>' '^]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" new "copy candidate->startup" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" new "Check startup content" -expecteof "$clixon_netconf -qf $cfg" 0 ']]>]]>' '^eth/0/0ex:ethtrue]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^eth/0/0ex:ethtrue]]>]]>$" new "Delete candidate" -expecteof "$clixon_netconf -qf $cfg" 0 'eth/0/0ex:ethnone ]]>]]>' '^]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "eth/0/0ex:ethnone ]]>]]>" "^]]>]]>$" # Here candidate is empty and startup has content # test startup->candidate new "Check candidate empty" -expecteof "$clixon_netconf -qf $cfg" 0 ']]>]]>' '^]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" new "copy startup->candidate" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" new "Check candidate content" -expecteof "$clixon_netconf -qf $cfg" 0 ']]>]]>' '^eth/0/0ex:ethtrue]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^eth/0/0ex:ethtrue]]>]]>$" # Negative test: check copying to running is not allowed new "Delete candidate" -expecteof "$clixon_netconf -qf $cfg" 0 'eth/0/0ex:ethnone ]]>]]>' '^]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "eth/0/0ex:ethnone ]]>]]>" "^]]>]]>$" new "netconf commit to running" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" # Here running is empty new "Check running empty" -expecteof "$clixon_netconf -qf $cfg" 0 ']]>]]>' '^]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" # Add to candidate new "copy startup->candidate" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" if ! $YANG_UNKNOWN_ANYDATA ; then new "copy startup->running not allowed" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^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 "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^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 # Here running is empty new "Check running empty" -expecteof "$clixon_netconf -qf $cfg" 0 ']]>]]>' '^]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" if [ $BE -eq 0 ]; then exit # BE diff --git a/test/test_datastore_repair.sh b/test/test_datastore_repair.sh index 640e9b48..c3a26bbf 100755 --- a/test/test_datastore_repair.sh +++ b/test/test_datastore_repair.sh @@ -98,7 +98,7 @@ testrun(){ fi new "netconf get config" - expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^$AFTER]]>]]>$" + expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^$AFTER]]>]]>$" if [ $BE -ne 0 ]; then new "Kill backend" diff --git a/test/test_feature.sh b/test/test_feature.sh index 7314dfbd..0f64eab0 100755 --- a/test/test_feature.sh +++ b/test/test_feature.sh @@ -131,16 +131,16 @@ testrun() if $enabled; then new "netconf set $node" - expecteof "$clixon_netconf -qf $cfg" 0 "<$node xmlns=\"urn:example:clixon\">foo]]>]]>" "^]]>]]>$" + expecteof "$clixon_netconf -qf $cfg" 0 "<$node xmlns=\"urn:example:clixon\">foo]]>]]>" "^]]>]]>$" new "netconf validate $node" - expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" + expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" else new "netconf set $node, expect fail" - expecteof "$clixon_netconf -qf $cfg" 0 "<$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 "$clixon_netconf -qf $cfg" 0 "<$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 "]]>]]>" "^]]>]]>$" + expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" } new "test params: -f $cfg" @@ -171,7 +171,7 @@ new "cli disabled feature in other module" expectfn "$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 "]]>]]>" "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" # Single if-feature testrun x true @@ -192,13 +192,13 @@ testrun m8 false # reply since the modules change so often new "netconf schema resource, RFC 7895" ret=$($clixon_netconf -qf $cfg<]]>]]> +]]>]]> EOF ) #echo $ret new "netconf modules-state header" -expect='^' +expect="^" match=`echo "$ret" | grep --null -Go "$expect"` if [ -z "$match" ]; then err "$expect" "$ret" diff --git a/test/test_identity.sh b/test/test_identity.sh index a59ef42c..0b7857d6 100755 --- a/test/test_identity.sh +++ b/test/test_identity.sh @@ -166,49 +166,49 @@ if [ $RC -ne 0 ]; then fi new "Set crypto to aes" -expecteof "$clixon_netconf -qf $cfg" 0 'aes]]>]]>' '^]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "aes]]>]]>" "^]]>]]>$" new "netconf validate " -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" new "Set crypto to mc:aes" -expecteof "$clixon_netconf -qf $cfg" 0 'mc:aes]]>]]>' "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "mc:aes]]>]]>" "^]]>]]>$" new "netconf validate" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" new "Set crypto to des:des3" -expecteof "$clixon_netconf -qf $cfg" 0 'des:des3]]>]]>' "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "des:des3]]>]]>" "^]]>]]>$" new "netconf validate" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" new "Set crypto to mc:foo" -expecteof "$clixon_netconf -qf $cfg" 0 'mc:foo]]>]]>' "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "mc:foo]]>]]>" "^]]>]]>$" new "netconf validate" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" new "Set crypto to des:des3 using xmlns" -expecteof "$clixon_netconf -qf $cfg" 0 'des:des3]]>]]>' "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "des:des3]]>]]>" "^]]>]]>$" new "netconf validate" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" if false; then # XXX this is not supported new "Set crypto to x:des3 using xmlns" -expecteof "$clixon_netconf -qf $cfg" 0 'x:des3]]>]]>' "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "x:des3]]>]]>" "^]]>]]>$" new "netconf validate" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" fi # not supported new "Set crypto to foo:bar" -expecteof "$clixon_netconf -qf $cfg" 0 'foo:bar]]>]]>' "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "foo:bar]]>]]>" "^]]>]]>$" new "netconf validate (expect fail)" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^applicationoperation-failederrorIdentityref validation failed, foo:bar not derived from crypto-alg]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^applicationoperation-failederrorIdentityref validation failed, foo:bar not derived from crypto-alg]]>]]>$" new "cli set crypto to mc:aes" expectfn "$clixon_cli -1 -f $cfg -l o set crypto mc:aes" 0 "^$" @@ -229,19 +229,19 @@ new "cli validate" expectfn "$clixon_cli -1 -f $cfg -l o validate" 0 "^$" new "Netconf set acl-type" -expecteof "$clixon_netconf -qf $cfg" 0 'xmc:ipv4-acl-type]]>]]>' '^]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "xmc:ipv4-acl-type]]>]]>" "^]]>]]>$" new "netconf validate " -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" new "Netconf set undefined acl-type" -expecteof "$clixon_netconf -qf $cfg" 0 'xundefined]]>]]>' '^]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "xundefined]]>]]>" "^]]>]]>$" new "netconf validate fail" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" '^applicationoperation-failederrorIdentityref validation failed, undefined not derived from acl-base]]>]]>' +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^applicationoperation-failederrorIdentityref validation failed, undefined not derived from acl-base]]>]]>" new "netconf discard-changes" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" new "CLI set acl-type" expectfn "$clixon_cli -1 -f $cfg -l o set acls acl x type mc:ipv4-acl-type" 0 "^$" @@ -263,7 +263,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 "]]>]]>" "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" # restconf and identities: # 1. set identity in own module with restconf (PUT and POST), read it with restconf and netconf @@ -276,7 +276,7 @@ new "restconf get own identity" expectpart "$(curl $CURLOPTS -X GET $RCPROTO://localhost/restconf/data/example:crypto)" 0 'HTTP/1.1 200 OK' '{"example:crypto":"aes"}' new "netconf get own identity as set by restconf" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" '^aes]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^aes]]>]]>$" new "restconf delete identity" expectpart "$(curl $CURLOPTS -X DELETE $RCPROTO://localhost/restconf/data/example:crypto)" 0 "HTTP/1.1 204 No Content" @@ -297,23 +297,23 @@ new "restconf get other identity" expectpart "$(curl $CURLOPTS -X GET $RCPROTO://localhost/restconf/data/example:crypto)" 0 'HTTP/1.1 200 OK' '{"example:crypto":"example-des:des3"}' new "netconf get other identity" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" '^des:des3]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^des:des3]]>]]>$" new "restconf delete identity" expectpart "$(curl $CURLOPTS -X DELETE $RCPROTO://localhost/restconf/data/example:crypto)" 0 "HTTP/1.1 204 No Content" # 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 'des:des3]]>]]>' "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "des:des3]]>]]>" "^]]>]]>$" new "netconf commit" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" new "restconf get other identity (set by netconf)" expectpart "$(curl $CURLOPTS -X GET $RCPROTO://localhost/restconf/data/example:crypto)" 0 'HTTP/1.1 200 OK' '{"example:crypto":"example-des:des3"}' new "netconf get other identity" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" '^des:des3]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^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 4c3025ea..dcd1bf17 100755 --- a/test/test_leaf_default.sh +++ b/test/test_leaf_default.sh @@ -124,25 +124,25 @@ if [ $BE -ne 0 ]; then fi new "get config" -expecteof "$clixon_netconf -qf $cfg" 0 ']]>]]>' "^$XML]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^$XML]]>]]>$" new "Change default value r1" -expecteof "$clixon_netconf -qf $cfg" 0 '99]]>]]>' "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "99]]>]]>" "^]]>]]>$" new "get config r1" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" '^99]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^99]]>]]>$" new "Remove r1" -expecteof "$clixon_netconf -qf $cfg" 0 '99]]>]]>' "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "99]]>]]>" "^]]>]]>$" new "get config" -expecteof "$clixon_netconf -qf $cfg" 0 ']]>]]>' "^$XML]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^$XML]]>]]>$" new "Set x list element" -expecteof "$clixon_netconf -qf $cfg" 0 'a]]>]]>' "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "a]]>]]>" "^]]>]]>$" new "get config (should contain y/inside+outside)" -expecteof "$clixon_netconf -qf $cfg" 0 ']]>]]>' "^$XMLafalsefalse]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^$XMLafalsefalse]]>]]>$" if [ $BE -ne 0 ]; then new "Kill backend" @@ -179,7 +179,7 @@ fi new "get startup config" # Should have all defaults, except r1 that is set to 99 -expecteof "$clixon_netconf -qf $cfg" 0 ']]>]]>' "^$XML]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^$XML]]>]]>$" # permission kludges sudo chmod 666 $dir/running_db @@ -194,10 +194,10 @@ if [ $? -ne 0 ]; then fi new "Change default value r2" -expecteof "$clixon_netconf -qf $cfg" 0 '88]]>]]>' "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "88]]>]]>" "^]]>]]>$" new "commit" -expecteof "$clixon_netconf -qf $cfg" 0 ']]>]]>' "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" new "Check running no defaults: r1 and r2" # Again, running should have only non-defaults, ie only r1 and r2 @@ -237,7 +237,7 @@ if [ $BE -ne 0 ]; then fi new "get startup config with presence" -expecteof "$clixon_netconf -qf $cfg" 0 ']]>]]>' "^$XML]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^$XML]]>]]>$" new "Kill backend" # Check if premature kill @@ -267,7 +267,7 @@ if [ $BE -ne 0 ]; then fi new "get startup config with list default" -expecteof "$clixon_netconf -qf $cfg" 0 ']]>]]>' "^$XMLafalsefalse]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^$XMLafalsefalse]]>]]>$" new "Kill backend" # Check if premature kill diff --git a/test/test_leafref.sh b/test/test_leafref.sh index a76e53dc..9c22dff8 100755 --- a/test/test_leafref.sh +++ b/test/test_leafref.sh @@ -128,52 +128,52 @@ if [ $BE -ne 0 ]; then fi new "leafref base config" -expecteof "$clixon_netconf -qf $cfg" 0 "$BASEXML]]>]]>" '^]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "$BASEXML]]>]]>" "^]]>]]>$" new "leafref get config" -expecteof "$clixon_netconf -qf $cfg" 0 ']]>]]>' "^$BASEXML]]>]]>" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^$BASEXML]]>]]>" new "leafref base commit" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" new "leafref add non-existing ref" -expecteof "$clixon_netconf -qf $cfg" 0 'eth3
10.0.4.6
]]>]]>' '^]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "eth3
10.0.4.6
]]>]]>" "^]]>]]>$" new "leafref validate" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" '^applicationbad-elementeth3errorLeafref validation failed: No leaf eth3 matching path /if:interfaces/if:interface/if:name]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^applicationbad-elementeth3errorLeafref validation failed: No leaf eth3 matching path /if:interfaces/if:interface/if:name]]>]]>$" #new "leafref wrong ref" -#expecteof "$clixon_netconf -qf $cfg" 0 'eth3
10.0.4.6
]]>]]>' '^]]>]]>$' +#expecteof "$clixon_netconf -qf $cfg" 0 "eth3
10.0.4.6
]]>]]>" "^]]>]]>$" new "leafref discard-changes" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" new "leafref add correct absref" -expecteof "$clixon_netconf -qf $cfg" 0 'eth0]]>]]>' '^]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "eth0]]>]]>" "^]]>]]>$" new "leafref validate (ok)" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^" new "leafref add correct relref" -expecteof "$clixon_netconf -qf $cfg" 0 'eth0]]>]]>' '^]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "eth0]]>]]>" "^]]>]]>$" new "leafref validate (ok)" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^" new "leafref add correct address" -expecteof "$clixon_netconf -qf $cfg" 0 '
192.0.2.1
]]>]]>' '^]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "
192.0.2.1
]]>]]>" "^]]>]]>$" new "leafref validate (ok)" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^" new "leafref delete leaf" -expecteof "$clixon_netconf -qf $cfg" 0 'eth0]]>]]>' '^' +expecteof "$clixon_netconf -qf $cfg" 0 "eth0]]>]]>" "^" new "leafref validate (should fail)" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" '^applicationbad-elementeth0errorLeafref validation failed: No leaf eth0 matching path /if:interfaces/if:interface/if:name]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^applicationbad-elementeth0errorLeafref validation failed: No leaf eth0 matching path /if:interfaces/if:interface/if:name]]>]]>$" new "leafref discard-changes" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" new "cli leafref lo" expectfn "$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 ffdca878..dfb5e640 100755 --- a/test/test_leafref_augment.sh +++ b/test/test_leafref_augment.sh @@ -157,13 +157,13 @@ EOF ) new "leafref augment+leafref config top-level" -expecteof "$clixon_netconf -qf $cfg" 0 "$XML]]>]]>" '^]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "$XML]]>]]>" "^]]>]]>$" new "leafref augment+leafref validate top-level wrong prefix" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^applicationbad-elementxerrorLeafref validation failed: No leaf x matching path /ex:sender/ex:name]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^applicationbad-elementxerrorLeafref validation failed: No leaf x matching path /ex:sender/ex:name]]>]]>$" new "netconf discard-changes" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" # Test top-level, default prefix, correct leafref and typedef path XML=$(cat <$XML
]]>]]>" '^]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "$XML]]>]]>" "^]]>]]>$" new "leafref augment+leafref validate" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" new "netconf discard-changes" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" # Use augment, default prefixes, wrong leafref and typedef path XML=$(cat <$XML]]>]]>" '^]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "$XML]]>]]>" "^]]>]]>$" new "leafref augment+leafref validate wrong ref" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^applicationbad-elementxxxerrorLeafref validation failed: No leaf xxx matching path /ex:sender/ex:name]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^applicationbad-elementxxxerrorLeafref validation failed: No leaf xxx matching path /ex:sender/ex:name]]>]]>$" new "netconf discard-changes" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" # Use augment, default prefixes, correct leafref and in-data path XML=$(cat <$XML]]>]]>" '^]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "$XML]]>]]>" "^]]>]]>$" new "leafref augment+leafref validate in-data" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" new "netconf discard-changes" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" - - +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" if [ $BE -eq 0 ]; then exit # BE diff --git a/test/test_leafref_state.sh b/test/test_leafref_state.sh index 7c2e5b6e..89f73811 100755 --- a/test/test_leafref_state.sh +++ b/test/test_leafref_state.sh @@ -95,40 +95,40 @@ EOF ) new "leafref config sender x" -expecteof "$clixon_netconf -qf $cfg" 0 "$XML]]>]]>" '^]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "$XML]]>]]>" "^]]>]]>$" new "netconf commit" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" # Get path=/, state vs config new "netconf get / config+state" -expecteof "$clixon_netconf -qf $cfg" 0 ']]>]]>' '^xx]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^xx]]>]]>$" new "netconf get / state-only" -expecteof "$clixon_netconf -qf $cfg" 0 ']]>]]>' '^x]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^x]]>]]>$" new "netconf get / config-only" -expecteof "$clixon_netconf -qf $cfg" 0 ']]>]]>' '^x]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^x]]>]]>$" # Get path=/sender-state, state vs config new "netconf get /sender-state config+state" -expecteof "$clixon_netconf -qf $cfg" 0 ']]>]]>' '^x]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^x]]>]]>$" new "netconf get /sender-state state-only" -expecteof "$clixon_netconf -qf $cfg" 0 ']]>]]>' '^x]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^x]]>]]>$" new "netconf get /sender-state config-only" -expecteof "$clixon_netconf -qf $cfg" 0 ']]>]]>' '^]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" # Get path=/sender-config, state vs config new "netconf get /sender-config config+state" -expecteof "$clixon_netconf -qf $cfg" 0 ']]>]]>' '^x]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^x]]>]]>$" new "netconf get /sender-config state-only" -expecteof "$clixon_netconf -qf $cfg" 0 ']]>]]>' '^]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" new "netconf get /sender-config config-only" -expecteof "$clixon_netconf -qf $cfg" 0 ']]>]]>' '^x]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^x]]>]]>$" # Negative tests, # Double xmlns attribute @@ -139,7 +139,7 @@ cat < $fstate EOF new "Merge same tree - check double xmlns attribute" -expecteof "$clixon_netconf -qf $cfg" 0 ']]>]]>' '^x]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^x]]>]]>$" # Back to original cat < $fstate @@ -160,20 +160,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 "$XML]]>]]>" '^]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "$XML]]>]]>" "^]]>]]>$" new "netconf commit" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" # Leafref wrong new "netconf get / config+state should fail" -expecteof "$clixon_netconf -qf $cfg" 0 ']]>]]>' '^applicationoperation-failedxerrorLeafref validation failed: No leaf x matching path /ex:sender-config/ex:name. Internal error, state callback returned invalid XML]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^applicationoperation-failedxerrorLeafref validation failed: No leaf x matching path /ex:sender-config/ex:name. Internal error, state callback returned invalid XML]]>]]>$" new "netconf get / state-only should fail" -expecteof "$clixon_netconf -qf $cfg" 0 ']]>]]>' '^applicationoperation-failedxerrorLeafref validation failed: No leaf x matching path /ex:sender-config/ex:name. Internal error, state callback returned invalid XML]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^applicationoperation-failedxerrorLeafref validation failed: No leaf x matching path /ex:sender-config/ex:name. Internal error, state callback returned invalid XML]]>]]>$" new "netconf get / config-only ok" -expecteof "$clixon_netconf -qf $cfg" 0 ']]>]]>' '^y]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^y]]>]]>$" if [ $BE -eq 0 ]; then exit # BE diff --git a/test/test_minmax.sh b/test/test_minmax.sh index e74eb5b5..2d888f21 100755 --- a/test/test_minmax.sh +++ b/test/test_minmax.sh @@ -118,111 +118,111 @@ if [ $BE -ne 0 ]; then fi new "minmax: minimal" -expecteof "$clixon_netconf -qf $cfg" 0 'replace +expecteof "$clixon_netconf -qf $cfg" 0 "replace 0 0 -]]>]]>' "^]]>]]>$" +]]>]]>" "^]]>]]>$" new "minmax: minimal validate ok" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" new "minmax: maximal" -expecteof "$clixon_netconf -qf $cfg" 0 'replace01unbounded0101unbounded01]]>]]>' '^]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "replace01unbounded0101unbounded01]]>]]>" "^]]>]]>$" new "minmax: validate ok" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" new "minmax: empty" -expecteof "$clixon_netconf -qf $cfg" 0 'replace]]>]]>' '^]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "replace]]>]]>" "^]]>]]>$" -#XXX echo ']]>]]>' |$clixon_netconf -qf $cfg +#XXX echo "]]>]]>" |$clixon_netconf -qf $cfg new "minmax: validate should fail" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" '^protocoloperation-failedtoo-few-elementserror/c/a1]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^protocoloperation-failedtoo-few-elementserror/c/a1]]>]]>$" new "minmax: no list" -expecteof "$clixon_netconf -qf $cfg" 0 'replace0]]>]]>' '^]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "replace0]]>]]>" "^]]>]]>$" new "minmax: validate should fail" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" '^protocoloperation-failedtoo-few-elementserror/c/a1]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^protocoloperation-failedtoo-few-elementserror/c/a1]]>]]>$" new "minmax: no leaf-list" -expecteof "$clixon_netconf -qf $cfg" 0 'replace0]]>]]>' '^]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "replace0]]>]]>" "^]]>]]>$" new "minmax: validate should fail" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" '^protocoloperation-failedtoo-few-elementserror/c/b1]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^protocoloperation-failedtoo-few-elementserror/c/b1]]>]]>$" new "minmax: Too large list" -expecteof "$clixon_netconf -qf $cfg" 0 'replace0120]]>]]>' '^]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "replace0120]]>]]>" "^]]>]]>$" new "minmax: validate should fail" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" '^protocoloperation-failedtoo-many-elementserror/c/a1]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^protocoloperation-failedtoo-many-elementserror/c/a1]]>]]>$" new "minmax: Too large leaf-list" -expecteof "$clixon_netconf -qf $cfg" 0 'replace0012]]>]]>' '^]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "replace0012]]>]]>" "^]]>]]>$" new "minmax: validate should fail" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" '^protocoloperation-failedtoo-many-elementserror/c/b1]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^protocoloperation-failedtoo-many-elementserror/c/b1]]>]]>$" new "netconf discard-changes" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" # With choice c1 new "minmax choice: minimal" -expecteof "$clixon_netconf -qf $cfg" 0 'replace +expecteof "$clixon_netconf -qf $cfg" 0 "replace 0 0 -]]>]]>' "^]]>]]>$" +]]>]]>" "^]]>]]>$" new "minmax choice: minimal validate ok" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" new "minmax choice: many a2" -expecteof "$clixon_netconf -qf $cfg" 0 'replace +expecteof "$clixon_netconf -qf $cfg" 0 "replace 0 1 2 0 -]]>]]>' "^]]>]]>$" +]]>]]>" "^]]>]]>$" new "minmax choice: many a2 validate ok" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" new "minmax choice: too many a1" -expecteof "$clixon_netconf -qf $cfg" 0 'replace +expecteof "$clixon_netconf -qf $cfg" 0 "replace 0 1 2 0 -]]>]]>' "^]]>]]>$" +]]>]]>" "^]]>]]>$" new "minmax choice: too many validate should fail" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" '^protocoloperation-failedtoo-many-elementserror/c2/a1]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^protocoloperation-failedtoo-many-elementserror/c2/a1]]>]]>$" new "netconf discard-changes" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" # top config level new "minmax top level" -expecteof "$clixon_netconf -qf $cfg" 0 'replace - 0 - 1 -]]>]]>' "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "replace + 0 + 1 +]]>]]>" "^]]>]]>$" new "minmax top level ok" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" new "minmax top level too many" -expecteof "$clixon_netconf -qf $cfg" 0 'replace - 0 - 1 - 2 -]]>]]>' "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "replace + 0 + 1 + 2 +]]>]]>" "^]]>]]>$" new "minmax top level too many should fail" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" '^protocoloperation-failedtoo-many-elementserror/b3]]>]]>' +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^protocoloperation-failedtoo-many-elementserror/b3]]>]]>" new "netconf discard-changes" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" if [ $BE -eq 0 ]; then exit # BE diff --git a/test/test_nacm.sh b/test/test_nacm.sh index fe72d5ba..e6307331 100755 --- a/test/test_nacm.sh +++ b/test/test_nacm.sh @@ -146,10 +146,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/1.1 201 Created" new "auth set authentication config" -expecteof "$clixon_netconf -qf $cfg" 0 "$RULES]]>]]>" "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "$RULES]]>]]>" "^]]>]]>$" new "commit it" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" new "auth get (no user: access denied)" expectpart "$(curl $CURLOPTS -X GET -H \"Accept:\ application/yang-data+json\" $RCPROTO://localhost/restconf/data)" 0 "HTTP/1.1 403 Forbidden" '{"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 b0b0189f..46af6330 100755 --- a/test/test_nacm_credentials.sh +++ b/test/test_nacm_credentials.sh @@ -144,19 +144,19 @@ EOF # First push in nacm rules via regular means new "auth set authentication config" -expecteof "$clixon_netconf -qf $cfg" 0 "$RULES]]>]]>" "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "$RULES]]>]]>" "^]]>]]>$" new "enable nacm" - expecteof "$clixon_netconf -qf $cfg" 0 'true]]>]]>' "^]]>]]>$" + expecteof "$clixon_netconf -qf $cfg" 0 "true]]>]]>" "^]]>]]>$" new "commit it" - expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" + expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" # raw socket test if [ -n "$username" ]; then - XML="" + XML="" else - XML="" + XML="" fi new "get-config mode:$mode user:$username $family $precmd" diff --git a/test/test_nacm_datanode.sh b/test/test_nacm_datanode.sh index 96cda8ad..45c1d32c 100755 --- a/test/test_nacm_datanode.sh +++ b/test/test_nacm_datanode.sh @@ -239,13 +239,13 @@ if [ $RC -ne 0 ]; then fi new "auth set authentication config" -expecteof "$clixon_netconf -qf $cfg" 0 "$RULES]]>]]>" "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "$RULES]]>]]>" "^]]>]]>$" new "set app config" -expecteof "$clixon_netconf -qf $cfg" 0 "$CONFIG]]>]]>" "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "$CONFIG]]>]]>" "^]]>]]>$" new "commit it" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" 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/1.1 204 No Content" diff --git a/test/test_nacm_datanode_read.sh b/test/test_nacm_datanode_read.sh index 3b9e915c..bd494be0 100755 --- a/test/test_nacm_datanode_read.sh +++ b/test/test_nacm_datanode_read.sh @@ -244,13 +244,13 @@ if [ $RC -ne 0 ]; then fi new "auth set authentication config" -expecteof "$clixon_netconf -qf $cfg" 0 "$RULES]]>]]>" "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "$RULES]]>]]>" "^]]>]]>$" new "set app config" -expecteof "$clixon_netconf -qf $cfg" 0 "$CONFIG]]>]]>" "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "$CONFIG]]>]]>" "^]]>]]>$" new "commit it" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" 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/1.1 204 No Content" diff --git a/test/test_nacm_datanode_write.sh b/test/test_nacm_datanode_write.sh index 9d0cd2a6..19f53627 100755 --- a/test/test_nacm_datanode_write.sh +++ b/test/test_nacm_datanode_write.sh @@ -240,13 +240,13 @@ if [ $RC -ne 0 ]; then fi new "auth set authentication config" -expecteof "$clixon_netconf -qf $cfg" 0 "$RULES]]>]]>" "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "$RULES]]>]]>" "^]]>]]>$" new "set app config" -expecteof "$clixon_netconf -qf $cfg" 0 "$CONFIG]]>]]>" "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "$CONFIG]]>]]>" "^]]>]]>$" new "commit it" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" 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/1.1 204 No Content" diff --git a/test/test_nacm_module_read.sh b/test/test_nacm_module_read.sh index 4d7a9f2b..745ba850 100755 --- a/test/test_nacm_module_read.sh +++ b/test/test_nacm_module_read.sh @@ -142,10 +142,10 @@ if [ $RC -ne 0 ]; then fi new "auth set authentication config" -expecteof "$clixon_netconf -qf $cfg" 0 "$RULES]]>]]>" "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "$RULES]]>]]>" "^]]>]]>$" new "commit it" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" 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/1.1 204 No Content" @@ -158,7 +158,7 @@ new "admin read ok" expectpart "$(curl -u andy:bar $CURLOPTS -X GET $RCPROTO://localhost/restconf/data/clixon-example:translate)" 0 'HTTP/1.1 200 OK' '{"clixon-example:translate":{"translate":\[{"k":"key42","value":"val42"},{"k":"key43","value":"val43"}\]}}' new "admin read netconf ok" -expecteof "$clixon_netconf -U andy -qf $cfg" 0 ']]>]]>' '^key42val42key43val43]]>]]>$' +expecteof "$clixon_netconf -U andy -qf $cfg" 0 "]]>]]>" "^key42val42key43val43]]>]]>$" new "admin read element ok" expectpart "$(curl -u andy:bar $CURLOPTS -X GET $RCPROTO://localhost/restconf/data/clixon-example:translate/translate=key42/value)" 0 'HTTP/1.1 200 OK' '{"clixon-example:value":"val42"}' @@ -183,7 +183,7 @@ new "limit read ok" expectpart "$(curl -u wilma:bar $CURLOPTS -X GET $RCPROTO://localhost/restconf/data/clixon-example:translate)" 0 'HTTP/1.1 200 OK' '{"clixon-example:translate":{"translate":\[{"k":"key42","value":"val42"},{"k":"key43","value":"val43"}\]}}' new "limit read netconf ok" -expecteof "$clixon_netconf -U wilma -qf $cfg" 0 ']]>]]>' '^key42val42key43val43]]>]]>$' +expecteof "$clixon_netconf -U wilma -qf $cfg" 0 "]]>]]>" "^key42val42key43val43]]>]]>$" new "limit read element ok" expectpart "$(curl -u wilma:bar $CURLOPTS -X GET $RCPROTO://localhost/restconf/data/clixon-example:translate/translate=key42/value)" 0 'HTTP/1.1 200 OK' '{"clixon-example:value":"val42"}' @@ -203,7 +203,7 @@ new "guest read forbidden" expectpart "$(curl -u guest:bar $CURLOPTS -X GET $RCPROTO://localhost/restconf/data/clixon-example:translate)" 0 'HTTP/1.1 403 Forbidden' '{"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 ']]>]]>' '^applicationaccess-deniederrordefault deny]]>]]>$' +expecteof "$clixon_netconf -U guest -qf $cfg" 0 "]]>]]>" "^applicationaccess-deniederrordefault deny]]>]]>$" new "guest read element forbidden" expectpart "$(curl -u guest:bar $CURLOPTS -X GET $RCPROTO://localhost/restconf/data/clixon-example:translate/translate=key42/value)" 0 'HTTP/1.1 403 Forbidden' '{"ietf-restconf:errors":{"error":{"error-type":"application","error-tag":"access-denied","error-severity":"error","error-message":"default deny"}}}' @@ -223,7 +223,7 @@ 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/1.1 200 OK' '{"clixon-example:output":{"x":"78","y":"42"}}' new "admin rpc netconf ok" -expecteof "$clixon_netconf -U andy -qf $cfg" 0 '0]]>]]>' 0 '^042]]>]]>$' +expecteof "$clixon_netconf -U andy -qf $cfg" 0 "0]]>]]>" 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/1.1 200 OK' '{"clixon-example:output":{"x":"42","y":"42"}}' diff --git a/test/test_nacm_module_write.sh b/test/test_nacm_module_write.sh index ecffa7f1..6d2d37c0 100755 --- a/test/test_nacm_module_write.sh +++ b/test/test_nacm_module_write.sh @@ -162,10 +162,10 @@ fi # Set nacm from scratch nacm(){ new "auth set authentication config" - expecteof "$clixon_netconf -qf $cfg" 0 "$RULES]]>]]>" "^]]>]]>$" + expecteof "$clixon_netconf -qf $cfg" 0 "$RULES]]>]]>" "^]]>]]>$" new "commit it" - expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" + expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" 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/1.1 204 No Content" diff --git a/test/test_nacm_protocol.sh b/test/test_nacm_protocol.sh index bc072b75..d4997e6c 100755 --- a/test/test_nacm_protocol.sh +++ b/test/test_nacm_protocol.sh @@ -162,10 +162,10 @@ if [ $RC -ne 0 ]; then fi new "auth set authentication config" -expecteof "$clixon_netconf -qf $cfg" 0 "$RULES]]>]]>" "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "$RULES]]>]]>" "^]]>]]>$" new "commit it" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" 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/1.1 204 No Content" @@ -177,17 +177,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 "44]]>]]>" "^applicationaccess-deniederroraccess denied]]>]]>$" +expecteof "$clixon_netconf -qf $cfg -U wilma" 0 "44]]>]]>" "^applicationaccess-deniederroraccess denied]]>]]>$" new "deny-kill-session: guest fail (netconf)" -expecteof "$clixon_netconf -qf $cfg -U guest" 0 "44]]>]]>" "^applicationaccess-deniederroraccess denied]]>]]>$" +expecteof "$clixon_netconf -qf $cfg -U guest" 0 "44]]>]]>" "^applicationaccess-deniederroraccess denied]]>]]>$" new "deny-kill-session: admin ok (netconf)" -expecteof "$clixon_netconf -qf $cfg -U andy" 0 "44]]>]]>" "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg -U andy" 0 "44]]>]]>" "^]]>]]>$" # Rule 2: deny-delete-config new "deny-delete-config: limited fail (netconf)" -expecteof "$clixon_netconf -qf $cfg -U wilma" 0 "]]>]]>" "^applicationaccess-deniederroraccess denied]]>]]>$" +expecteof "$clixon_netconf -qf $cfg -U wilma" 0 "]]>]]>" "^applicationaccess-deniederroraccess denied]]>]]>$" new "deny-delete-config: guest fail (restconf)" expectpart "$(curl -u guest:bar $CURLOPTS -X DELETE $RCPROTO://localhost/restconf/data)" 0 "HTTP/1.1 403 Forbidden" '{"ietf-restconf:errors":{"error":{"error-type":"application","error-tag":"access-denied","error-severity":"error","error-message":"default deny"}}}' @@ -204,10 +204,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 "$RULES]]>]]>" "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "$RULES]]>]]>" "^]]>]]>$" new "commit it" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" 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/1.1 204 No Content" diff --git a/test/test_nacm_recovery.sh b/test/test_nacm_recovery.sh index fa4fd94e..bf6bfdf3 100755 --- a/test/test_nacm_recovery.sh +++ b/test/test_nacm_recovery.sh @@ -112,23 +112,23 @@ 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 "]]>]]>" "^$DEFAULT]]>]]>$" + expecteof "$prefix$clixon_netconf -qf $cfg -U $pseudo" 0 "]]>]]>" "^$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 "]]>]]>" "^applicationaccess-deniederrorUser $realuser credential not matching NACM user $pseudo]]>]]>$" + expecteof "$prefix$clixon_netconf -qf $cfg -U $pseudo" 0 "]]>]]>" "^applicationaccess-deniederrorUser $realuser credential not matching NACM user $pseudo]]>]]>$" return; fi if $putp; then new "put, expect ok" - expecteof "$prefix$clixon_netconf -qf $cfg -U $pseudo" 0 "$RULES]]>]]>" "]]>]]>" + expecteof "$prefix$clixon_netconf -qf $cfg -U $pseudo" 0 "$RULES]]>]]>" "]]>]]>" new "get rules ok" - expecteof "$prefix$clixon_netconf -qf $cfg -U $pseudo" 0 ']]>]]>' "^$RULES]]>]]>$" + expecteof "$prefix$clixon_netconf -qf $cfg -U $pseudo" 0 "]]>]]>" "^$RULES]]>]]>$" else new "put, expect fail" - expecteof "$prefix$clixon_netconf -qf $cfg -U $pseudo" 0 "$RULES]]>]]>" "^applicationaccess-deniederrordefault deny]]>]]>$" + expecteof "$prefix$clixon_netconf -qf $cfg -U $pseudo" 0 "$RULES]]>]]>" "^applicationaccess-deniederrordefault deny]]>]]>$" fi if [ $RC -ne 0 ]; then new "Kill restconf daemon" diff --git a/test/test_netconf.sh b/test/test_netconf.sh index f93418eb..04fbe0e5 100755 --- a/test/test_netconf.sh +++ b/test/test_netconf.sh @@ -49,179 +49,179 @@ if [ $BE -ne 0 ]; then fi new "netconf hello" -expecteof "$clixon_netconf -f $cfg" 0 ']]>]]>' '^urn:ietf:params:netconf:base:1.0urn:ietf:params:netconf:capability:yang-library:1.0?revision=2016-06-21&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.0urn:ietf:params:netconf:capability:yang-library:1.0?revision=2016-06-21&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 get-config double quotes" -expecteof "$clixon_netconf -qf $cfg" 0 ']]>]]>' '^]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" new "netconf get-config single quotes" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" '^]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" new "Add subtree eth/0/0 using none which should not change anything" -expecteof "$clixon_netconf -qf $cfg" 0 'noneeth/0/0]]>]]>' "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "noneeth/0/0]]>]]>" "^]]>]]>$" new "Check nothing added" -expecteof "$clixon_netconf -qf $cfg" 0 ']]>]]>' '^]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" new "Add subtree eth/0/0 using none and create which should add eth/0/0" -expecteof "$clixon_netconf -qf $cfg" 0 'eth/0/0ex:ethnone ]]>]]>' "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "eth/0/0ex:ethnone ]]>]]>" "^]]>]]>$" # Too many quotes, (single inside double inside single) need to fool bash cat < $tmp # new -]]>]]> +]]>]]> EOF new "Check eth/0/0 added using xpath" -expecteof "$clixon_netconf -qf $cfg" 0 "$(cat $tmp)" '^eth/0/0ex:ethtrue]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "$(cat $tmp)" "^eth/0/0ex:ethtrue]]>]]>$" new "Re-create same eth/0/0 which should generate error" -expecteof "$clixon_netconf -qf $cfg" 0 'eth/0/0ex:ethnone ]]>]]>' '^' +expecteof "$clixon_netconf -qf $cfg" 0 "eth/0/0ex:ethnone ]]>]]>" "^" new "Delete eth/0/0 using none config" -expecteof "$clixon_netconf -qf $cfg" 0 'eth/0/0ex:ethnone ]]>]]>' '^]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "eth/0/0ex:ethnone ]]>]]>" "^]]>]]>$" new "Check deleted eth/0/0 (non-presence container)" -expecteof "$clixon_netconf -qf $cfg" 0 ']]>]]>' '^]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" new "Re-Delete eth/0/0 using none should generate error" -expecteof "$clixon_netconf -qf $cfg" 0 'eth/0/0ex:ethnone ]]>]]>' '^' +expecteof "$clixon_netconf -qf $cfg" 0 "eth/0/0ex:ethnone ]]>]]>" "^" new "Add interface without key" -expecteof "$clixon_netconf -qf $cfg" 0 'ex:ethnone ]]>]]>' '^applicationmissing-elementnameerrorMandatory key]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "ex:ethnone ]]>]]>" "^applicationmissing-elementnameerrorMandatory key]]>]]>$" new "netconf discard-changes" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" new "netconf edit config" -expecteof "$clixon_netconf -qf $cfg" 0 'eth/0/0eth1true9.2.3.424]]>]]>' "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "eth/0/0eth1true9.2.3.424]]>]]>" "^]]>]]>$" # Too many quotes cat < $tmp # new -]]>]]> +]]>]]> EOF new "netconf get config xpath" -expecteof "$clixon_netconf -qf $cfg" 0 "$(cat $tmp)" '^eth1true]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "$(cat $tmp)" "^eth1true]]>]]>$" # Too many quotes cat < $tmp # new -]]>]]> +]]>]]> EOF new "netconf get config xpath parent" -expecteof "$clixon_netconf -qf $cfg" 0 "$(cat $tmp)" '^eth/0/0trueeth1truetruefalse9.2.3.424]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "$(cat $tmp)" "^eth/0/0trueeth1truetruefalse9.2.3.424]]>]]>$" new "netconf validate missing type" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^" new "netconf discard-changes" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" new "netconf get empty config2" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" new "netconf edit extra xml" -expecteof "$clixon_netconf -qf $cfg" 0 ']]>]]>' "^" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^" new "netconf discard-changes" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" new "netconf edit config eth1" -expecteof "$clixon_netconf -qf $cfg" 0 'eth1ex:eth]]>]]>' "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "eth1ex:eth]]>]]>" "^]]>]]>$" new "netconf validate" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" new "netconf commit" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" new "netconf edit config merge eth2" -expecteof "$clixon_netconf -qf $cfg" 0 'eth2ex:ethmerge]]>]]>' "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "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 'eth&t<>]]>]]>' '^]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "eth&t<>]]>]]>" "^]]>]]>$" new "netconf get replaced config" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" '^eth&t<>trueeth1ex:ethtrueeth2ex:ethtrue]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^eth&t<>trueeth1ex:ethtrueeth2ex:ethtrue]]>]]>$" new "cli show configuration eth& - encoding tests" expectfn "$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 'eth/0/0ex:eth]]>]]>' "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "eth/0/0ex:eth]]>]]>" "^]]>]]>$" #new "netconf get CDATA" -#expecteof "$clixon_netconf -qf $cfg" 0 ']]>]]>' 'eth/0/0true]]>]]>' +#expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "eth/0/0true]]>]]>" new "netconf discard-changes" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" new "netconf edit state operation should fail" -expecteof "$clixon_netconf -qf $cfg" 0 'e0up]]>]]>' "^protocolinvalid-valueerrorState data not allowed]]>]]>" +expecteof "$clixon_netconf -qf $cfg" 0 "e0up]]>]]>" "^protocolinvalid-valueerrorState data not allowed]]>]]>" new "netconf get state operation" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" '^eth1ex:ethtrueup42foo]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^eth1ex:ethtrueup42foo]]>]]>$" new "netconf lock" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" new "netconf unlock" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^protocollock-denied0errorUnlock failed, lock is not currently active]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^protocollock-denied0errorUnlock failed, lock is not currently active]]>]]>$" new "netconf lock/unlock" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>]]>]]>" "^]]>]]>]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>]]>]]>" "^]]>]]>]]>]]>$" new "netconf lock/lock" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>]]>]]>" "^]]>]]>protocollock-denied" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>]]>]]>" "^]]>]]>protocollock-denied" new "netconf unlock/unlock" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>]]>]]>" "^protocollock-denied0errorUnlock failed, lock is not currently active]]>]]>protocollock-denied0errorUnlock failed, lock is not currently active]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>]]>]]>" "^protocollock-denied0errorUnlock failed, lock is not currently active]]>]]>protocollock-denied0errorUnlock failed, lock is not currently active]]>]]>$" new "close-session" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" # 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 "44]]>]]>" "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "44]]>]]>" "^]]>]]>$" # modify candidate, then lock, should fail. new "netconf edit config" -expecteof "$clixon_netconf -qf $cfg" 0 'a
]]>]]>' "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "a
]]>]]>" "^]]>]]>$" new "netconf lock: should fail" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^protocollock-denied0errorOperation failed, candidate has already been modified and the changes have not been committed or rolled back (RFC 6241 7.5)]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^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 "]]>]]>" "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" new "netconf lock" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" new "copy startup to candidate" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" new "netconf get startup" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" '^eth1ex:ethtrue]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^eth1ex:ethtrue]]>]]>$" new "netconf delete startup" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" new "netconf check empty startup" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" new "netconf example rpc" -expecteof "$clixon_netconf -qf $cfg" 0 '42]]>]]>' '^4242]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "42]]>]]>" "^4242]]>]]>$" new "netconf empty rpc" -expecteof "$clixon_netconf -qf $cfg" 0 ']]>]]>' "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" new "netconf client-side rpc" -expecteof "$clixon_netconf -qf $cfg" 0 'val42]]>]]>' '^val42]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "val42]]>]]>" "^val42]]>]]>$" new "netconf extra leaf in leaf should fail" -expecteof "$clixon_netconf -qf $cfg" 0 'e0e1]]>]]>' '^applicationunknown-elementnameerrorFailed to find YANG spec of XML node: name with parent: name in namespace: urn:ietf:params:xml:ns:yang:ietf-interfaces]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "e0e1]]>]]>" "^applicationunknown-elementnameerrorFailed to find YANG spec of XML node: name with parent: name in namespace: urn:ietf:params:xml:ns:yang:ietf-interfaces]]>]]>$" if [ $BE -eq 0 ]; then exit # BE diff --git a/test/test_netconf_filter.sh b/test/test_netconf_filter.sh index 8328c2ad..16e8a51e 100755 --- a/test/test_netconf_filter.sh +++ b/test/test_netconf_filter.sh @@ -60,25 +60,25 @@ new "waiting" wait_backend new "Add two entries" -expecteof "$clixon_netconf -qf $cfg" 0 '1122]]>]]>' '^]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "1122]]>]]>" "^]]>]]>$" new "netconf commit" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" new "wrong filter type" -expecteof "$clixon_netconf -qf $cfg" 0 "1]]>]]>" '^operation-failedapplicatioerrorfilter type not supportedtype]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "1]]>]]>" "^operation-failedapplicatioerrorfilter type not supportedtype]]>]]>$" new "get-config subtree one" -expecteof "$clixon_netconf -qf $cfg" 0 "1]]>]]>" '^11]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "1]]>]]>" "^11]]>]]>$" new "get subtree one" -expecteof "$clixon_netconf -qf $cfg" 0 "1]]>]]>" '^11]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "1]]>]]>" "^11]]>]]>$" new "get-config xpath one" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" '^11]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^11]]>]]>$" new "get xpath one" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" '^11]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^11]]>]]>$" if [ $BE -eq 0 ]; then exit # BE diff --git a/test/test_netconf_whitespace.sh b/test/test_netconf_whitespace.sh index c76d1cad..f5fb9d82 100755 --- a/test/test_netconf_whitespace.sh +++ b/test/test_netconf_whitespace.sh @@ -76,66 +76,66 @@ new "waiting" wait_backend new "get startup" -expecteof "$clixon_netconf -qf $cfg" 0 ']]>]]>' '^foo]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^foo]]>]]>$" new "remove" -expecteof "$clixon_netconf -qf $cfg" 0 ']]>]]>' '^]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" new "commit" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" new "add insignificant 'dirty' whitespaces" -expecteof "$clixon_netconf -qf $cfg" 0 ' \t \ foo\n ]]>]]>' '^]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 " \t \ foo\n ]]>]]>" "^]]>]]>$" new "get stripped whitespace" -expecteof "$clixon_netconf -qf $cfg" 0 ']]>]]>' '^foo]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^foo]]>]]>$" new "validate" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" new "netconf discard-changes" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" new "add insignificant 'dirty' whitespaces with prefixes" -expecteof "$clixon_netconf -qf $cfg" 0 ' \t \ foo\n ]]>]]>' '^]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 " \t \ foo\n ]]>]]>" "^]]>]]>$" new "get stripped whitespace" -expecteof "$clixon_netconf -qf $cfg" 0 ']]>]]>' '^foo]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^foo]]>]]>$" new "validate" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" new "netconf discard-changes" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" new "add insignificant 'clean' whitespaces" -expecteof "$clixon_netconf -qf $cfg" 0 ' \n \t ]]>]]>' '^]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 " \n \t ]]>]]>" "^]]>]]>$" new "add more insignificant 'clean' whitespaces" -expecteof "$clixon_netconf -qf $cfg" 0 'foo ]]>]]>' '^]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "foo ]]>]]>" "^]]>]]>$" new "get stripped whitespace" -expecteof "$clixon_netconf -qf $cfg" 0 ']]>]]>' '^foo]]>]]>' +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^foo]]>]]>" new "validate" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" new "netconf discard-changes" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" new "add significant whitespaces" -expecteof "$clixon_netconf -qf $cfg" 0 ' foo - bar ]]>]]>' '^]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 " foo + bar ]]>]]>" "^]]>]]>$" new "get significant whitespace" -expecteof "$clixon_netconf -qf $cfg" 0 ']]>]]>' '^ foo - bar ]]>]]>' +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^ foo + bar ]]>]]>" new "validate" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" new "netconf discard-changes" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" if [ $BE -eq 0 ]; then exit # BE diff --git a/test/test_order.sh b/test/test_order.sh index 8104b517..37b74e9f 100755 --- a/test/test_order.sh +++ b/test/test_order.sh @@ -171,77 +171,77 @@ fi # Eeh I changed that to sortered unless STATE_ORDERED_BY_SYSTEM new "state data (should be ordered: 41,42,43)" cat < $tmp -]]>]]> +]]>]]> EOF -expecteof "$clixon_netconf -qf $cfg" 0 "$(cat $tmp)" '414243]]>]]>' +expecteof "$clixon_netconf -qf $cfg" 0 "$(cat $tmp)" "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 ']]>]]>' '^hejhoppdbcaabcddbarabarcbarbbarabarbbarcbardbar]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^hejhoppdbcaabcddbarabarcbarbbarabarbbarcbardbar]]>]]>$" new "get each ordered-by user leaf-list" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" '^abar]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^abar]]>]]>$" new "get each ordered-by user leaf-list" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" '^abar]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^abar]]>]]>$" new "get each ordered-by user leaf-list" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" '^bbar]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^bbar]]>]]>$" new "get each ordered-by user leaf-list" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" '^bbar]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^bbar]]>]]>$" new "delete candidate" -expecteof "$clixon_netconf -qf $cfg" 0 'none]]>]]>' "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "none]]>]]>" "^]]>]]>$" # LEAF_LISTS new "add two entries (c,b) to leaf-list user order" -expecteof "$clixon_netconf -qf $cfg" 0 'cb]]>]]>' "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "cb]]>]]>" "^]]>]]>$" new "add one entry (a) to leaf-list user order" -expecteof "$clixon_netconf -qf $cfg" 0 'a]]>]]>' "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "a]]>]]>" "^]]>]]>$" new "netconf commit" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" new "add one entry (0) to leaf-list user order after commit" -expecteof "$clixon_netconf -qf $cfg" 0 '0]]>]]>' "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "0]]>]]>" "^]]>]]>$" new "netconf commit" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" new "verify leaf-list user order in running (as entered: c,b,a,0)" -expecteof "$clixon_netconf -qf $cfg" 0 ']]>]]>' '^cba0]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^cba0]]>]]>$" # LISTS new "add two entries to list user order" -expecteof "$clixon_netconf -qf $cfg" 0 'cbarbfoo]]>]]>' "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "cbarbfoo]]>]]>" "^]]>]]>$" new "add one entry to list user order" -expecteof "$clixon_netconf -qf $cfg" 0 'afie]]>]]>' "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "afie]]>]]>" "^]]>]]>$" new "verify list user order (as entered)" -expecteof "$clixon_netconf -qf $cfg" 0 ']]>]]>' '^cbarbfooafie]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^cbarbfooafie]]>]]>$" new "Overwrite existing ordered-by user y2->c" -expecteof "$clixon_netconf -qf $cfg" 0 ' +expecteof "$clixon_netconf -qf $cfg" 0 " cnewc -]]>]]>' +]]>]]>" new "Overwrite existing ordered-by user y2->b" -expecteof "$clixon_netconf -qf $cfg" 0 ' +expecteof "$clixon_netconf -qf $cfg" 0 " bnewb -]]>]]>' +]]>]]>" new "Overwrite existing ordered-by user y2->a" -expecteof "$clixon_netconf -qf $cfg" 0 ' +expecteof "$clixon_netconf -qf $cfg" 0 " anewa -]]>]]>' +]]>]]>" new "Tests for no duplicates." -expecteof "$clixon_netconf -qf $cfg" 0 ']]>]]>' '^cnewcbnewbanewa]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^cnewcbnewbanewa]]>]]>$" #-- order by type rather than strings. # there are three leaf-lists:strings, ints, and decimal64, and two lists: @@ -250,146 +250,146 @@ expecteof "$clixon_netconf -qf $cfg" 0 ' +expecteof "$clixon_netconf -qf $cfg" 0 " 1021 -]]>]]>' "^]]>]]>$" +]]>]]>" "^]]>]]>$" new "check string order (1,10,2)" -expecteof "$clixon_netconf -qf $cfg" 0 ']]>]]>' '^1102]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^1102]]>]]>$" new "put leaf-list int (10,2,1)" -expecteof "$clixon_netconf -qf $cfg" 0 ' +expecteof "$clixon_netconf -qf $cfg" 0 " 1021 -]]>]]>' "^]]>]]>$" +]]>]]>" "^]]>]]>$" new "check leaf-list int order (1,2,10)" -expecteof "$clixon_netconf -qf $cfg" 0 ']]>]]>' '^1210]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^1210]]>]]>$" new "put list int (10,2,1)" -expecteof "$clixon_netconf -qf $cfg" 0 ' +expecteof "$clixon_netconf -qf $cfg" 0 " 1021 -]]>]]>' "^]]>]]>$" +]]>]]>" "^]]>]]>$" new "check list int order (1,2,10)" -expecteof "$clixon_netconf -qf $cfg" 0 ']]>]]>' '^1210]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^1210]]>]]>$" new "put leaf-list decimal64 (10,2,1)" -expecteof "$clixon_netconf -qf $cfg" 0 ' +expecteof "$clixon_netconf -qf $cfg" 0 " 10.02.01.0 -]]>]]>' "^]]>]]>$" +]]>]]>" "^]]>]]>$" new "check leaf-list decimal64 order (1,2,10)" -expecteof "$clixon_netconf -qf $cfg" 0 ']]>]]>' '^1.02.010.0]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^1.02.010.0]]>]]>$" new "put list decimal64 (10,2,1)" -expecteof "$clixon_netconf -qf $cfg" 0 ' +expecteof "$clixon_netconf -qf $cfg" 0 " 10.02.01.0 -]]>]]>' "^]]>]]>$" +]]>]]>" "^]]>]]>$" new "check list decimal64 order (1,2,10)" -expecteof "$clixon_netconf -qf $cfg" 0 ']]>]]>' '^1.02.010.0]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^1.02.010.0]]>]]>$" new "delete candidate" -expecteof "$clixon_netconf -qf $cfg" 0 'none]]>]]>' "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "none]]>]]>" "^]]>]]>$" new "netconf commit" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" # 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 'c]]>]]>' "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "c]]>]]>" "^]]>]]>$" new "add one entry (a) to leaf-list first (with no yang namespace - error)" -expecteof "$clixon_netconf -qf $cfg" 0 'a]]>]]>' '^applicationbad-attributeinserterrorUnresolved attribute prefix (no namespace?)]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "a]]>]]>" "^applicationbad-attributeinserterrorUnresolved attribute prefix (no namespace?)]]>]]>$" new "add one entry (b) to leaf-list first" -expecteof "$clixon_netconf -qf $cfg" 0 'b]]>]]>' "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "b]]>]]>" "^]]>]]>$" new "add one entry (d) to leaf-list last" -expecteof "$clixon_netconf -qf $cfg" 0 'd]]>]]>' "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "d]]>]]>" "^]]>]]>$" new "add one entry (a) to leaf-list first" -expecteof "$clixon_netconf -qf $cfg" 0 'a]]>]]>' "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "a]]>]]>" "^]]>]]>$" new "add one entry (e) to leaf-list last" -expecteof "$clixon_netconf -qf $cfg" 0 'e]]>]]>' "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "e]]>]]>" "^]]>]]>$" new "check ordered-by-user: a,b,c,d,e" -expecteof "$clixon_netconf -qf $cfg" 0 ']]>]]>' '^abcde]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^abcde]]>]]>$" new "move one entry (e) to leaf-list first" -expecteof "$clixon_netconf -qf $cfg" 0 'e]]>]]>' "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "e]]>]]>" "^]]>]]>$" new "check ordered-by-user: e,a,b,c,d" -expecteof "$clixon_netconf -qf $cfg" 0 ']]>]]>' '^eabcd]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^eabcd]]>]]>$" # before and after and value attribute new "add one leaf-list entry 71 before b" -XML="71]]>]]>" -expecteof "$clixon_netconf -qf $cfg" 0 "$XML" "^]]>]]>$" +XML="71]]>]]>" +expecteof "$clixon_netconf -qf $cfg" 0 "$XML" "^]]>]]>$" new "add one entry 42 after b" -XML="42]]>]]>" -expecteof "$clixon_netconf -qf $cfg" 0 "$XML" "^]]>]]>$" +XML="42]]>]]>" +expecteof "$clixon_netconf -qf $cfg" 0 "$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="99]]>]]>" -RES="^protocoloperation-failederrorbad-attribute: value, missing-instance: Q]]>]]>$" +XML="99]]>]]>" +RES="^protocoloperation-failederrorbad-attribute: value, missing-instance: Q]]>]]>$" expecteof "$clixon_netconf -qf $cfg" 0 "$XML" "$RES" new "check ordered-by-user: e,a,71,b,42,c,d" -expecteof "$clixon_netconf -qf $cfg" 0 ']]>]]>' '^ea71b42cd]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^ea71b42cd]]>]]>$" new "delete candidate" -expecteof "$clixon_netconf -qf $cfg" 0 'none]]>]]>' "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "none]]>]]>" "^]]>]]>$" new "netconf commit" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" # 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 'cfoo]]>]]>' "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "cfoo]]>]]>" "^]]>]]>$" new "add one entry (key a) to list first (with no yang namespace - error)" -expecteof "$clixon_netconf -qf $cfg" 0 'afoo]]>]]>' '^applicationbad-attributeinserterrorUnresolved attribute prefix (no namespace?)]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "afoo]]>]]>" "^applicationbad-attributeinserterrorUnresolved attribute prefix (no namespace?)]]>]]>$" new "add one entry (key b) to list first" -expecteof "$clixon_netconf -qf $cfg" 0 'bbar]]>]]>' "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "bbar]]>]]>" "^]]>]]>$" new "add one entry (d) to list last" -expecteof "$clixon_netconf -qf $cfg" 0 'dfie]]>]]>' "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "dfie]]>]]>" "^]]>]]>$" new "add one entry (a) to list first" -expecteof "$clixon_netconf -qf $cfg" 0 'afoo]]>]]>' "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "afoo]]>]]>" "^]]>]]>$" new "add one entry (e) to list last" -expecteof "$clixon_netconf -qf $cfg" 0 'ebar]]>]]>' "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "ebar]]>]]>" "^]]>]]>$" new "check ordered-by-user: a,b,c,d,e" -expecteof "$clixon_netconf -qf $cfg" 0 ']]>]]>' '^afoobbarcfoodfieebar]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^afoobbarcfoodfieebar]]>]]>$" new "move one entry (e) to list first" -expecteof "$clixon_netconf -qf $cfg" 0 'ebar]]>]]>' "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "ebar]]>]]>" "^]]>]]>$" new "check ordered-by-user: e,a,b,c,d" -expecteof "$clixon_netconf -qf $cfg" 0 ']]>]]>' '^ebarafoobbarcfoodfie]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^ebarafoobbarcfoodfie]]>]]>$" # before and after and key attribute new "add one entry 71 before key b" -expecteof "$clixon_netconf -qf $cfg" 0 "71fie]]>]]>" "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "71fie]]>]]>" "^]]>]]>$" new "add one entry 42 after key b" -expecteof "$clixon_netconf -qf $cfg" 0 "42fum]]>]]>" "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "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 "99bar]]>]]>" "^protocoloperation-failederrorbad-attribute: key, missing-instance: Q]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "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 ']]>]]>' '^ebarafoo71fiebbar42fumcfoodfie]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^ebarafoo71fiebbar42fumcfoodfie]]>]]>$" if [ $BE -eq 0 ]; then exit # BE diff --git a/test/test_pattern.sh b/test/test_pattern.sh index ec078bc1..80ada1dc 100755 --- a/test/test_pattern.sh +++ b/test/test_pattern.sh @@ -392,16 +392,16 @@ testrun(){ trunc=$(echo "$str"|cut -c1-15) new "pattern edit $leaf string: $trunc" - expecteof "$clixon_netconf -qf $cfg" 0 "<$leaf>$str]]>]]>" "^]]>]]>$" + expecteof "$clixon_netconf -qf $cfg" 0 "<$leaf>$str]]>]]>" "^]]>]]>$" if $mat; then new "netconf validate expected match" - expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" + expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" else new "netconf validate expected fail" - expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^applicationbad-element$leaferror" + expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^applicationbad-element$leaferror" new "netconf discard-changes" - expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" + expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" fi } diff --git a/test/test_perf_netconf.sh b/test/test_perf_netconf.sh index 3f0ce9d1..d523e4b4 100755 --- a/test/test_perf_netconf.sh +++ b/test/test_perf_netconf.sh @@ -87,7 +87,7 @@ new "waiting" wait_backend new "generate config with $perfnr list entries" -echo -n "" > $fconfig +echo -n "" > $fconfig for (( i=0; i<$perfnr; i++ )); do echo -n "$i$i" >> $fconfig done @@ -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 -qf $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 -qf $cfg" 0 "]]>]]>" "^]]>]]>$" 2>&1 | awk '/real/ {print $2}' # Now commit it again from candidate (validation takes time when # comparing to existing) @@ -118,13 +118,13 @@ expecteof "time -p $clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>" + echo "]]>]]>" done | $clixon_netconf -qf $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 "]]>]]>" | $clixon_netconf -qf $cfg > /dev/null; + echo "]]>]]>" | $clixon_netconf -qf $cfg > /dev/null; done } 2>&1 | awk '/real/ {print $2}' @@ -132,63 +132,63 @@ 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 "]]>]]>" + echo "]]>]]>" done | $clixon_netconf -qf $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 "$rnd$rnd]]>]]>" + echo "$rnd$rnd]]>]]>" done | $clixon_netconf -qf $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 "]]>]]>" '^00112233' 2>&1 | awk '/real/ {print $2}' +expecteof "time -p $clixon_netconf -qf $cfg" 0 "]]>]]>" "^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 "]]>]]>" "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" new "netconf delete $perfreq small config" { time -p for (( i=0; i<$perfreq; i++ )); do rnd=$(( ( RANDOM % $perfnr ) )) - echo "$rnd]]>]]>" + echo "$rnd]]>]]>" done | $clixon_netconf -qf $cfg > /dev/null; } 2>&1 | awk '/real/ {print $2}' #new "netconf discard-changes" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" # Now do leaf-lists istead of leafs #new "generate leaf-list config" -echo -n "replace" > $fconfig2 +echo -n "replace" > $fconfig2 for (( i=0; i<$perfnr; i++ )); do echo -n "$i" >> $fconfig2 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 -qf $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 -qf $cfg" 0 "]]>]]>" "^]]>]]>$" 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 "$rnd]]>]]>" + echo "$rnd]]>]]>" done | $clixon_netconf -qf $cfg > /dev/null; } 2>&1 | awk '/real/ {print $2}' new "netconf add small leaf-list config" -expecteof "time -p $clixon_netconf -qf $cfg" 0 'x]]>]]>' "^]]>]]>$" 2>&1 | awk '/real/ {print $2}' +expecteof "time -p $clixon_netconf -qf $cfg" 0 "x]]>]]>" "^]]>]]>$" 2>&1 | awk '/real/ {print $2}' new "netconf commit small leaf-list config" -expecteof "time -p $clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" 2>&1 | awk '/real/ {print $2}' +expecteof "time -p $clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" 2>&1 | awk '/real/ {print $2}' new "netconf get large leaf-list config" -expecteof "time -p $clixon_netconf -qf $cfg" 0 "]]>]]>" '^01' 2>&1 | awk '/real/ {print $2}' +expecteof "time -p $clixon_netconf -qf $cfg" 0 "]]>]]>" "^01" 2>&1 | awk '/real/ {print $2}' if [ $BE -eq 0 ]; then exit # BE diff --git a/test/test_perf_restconf.sh b/test/test_perf_restconf.sh index b121351a..49dc2c3a 100755 --- a/test/test_perf_restconf.sh +++ b/test/test_perf_restconf.sh @@ -109,13 +109,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 -qf $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 -qf $cfg" 0 "]]>]]>" "^]]>]]>$" 2>&1 | awk '/real/ {print $2}' # RESTCONF get new "restconf get $perfreq small config 1 key index" @@ -147,7 +147,7 @@ new "cli delete $perfreq small config" done } 2>&1 | awk '/real/ {print $2}' #new "netconf discard-changes" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" # XXX This takes time # 18.69 without startup feature @@ -161,32 +161,32 @@ done > /dev/null; } 2>&1 | awk '/real/ {print $2}' # Now do leaf-lists istead of leafs #new "generate leaf-list config" -echo -n "replace" > $fconfig2 +echo -n "replace" > $fconfig2 for (( i=0; i<$perfnr; i++ )); do echo -n "$i" >> $fconfig2 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 -qf $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 -qf $cfg" 0 "]]>]]>" "^]]>]]>$" 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 "$rnd]]>]]>" + echo "$rnd]]>]]>" done | $clixon_netconf -qf $cfg > /dev/null; } 2>&1 | awk '/real/ {print $2}' new "netconf add small leaf-list config" -expecteof "time -p $clixon_netconf -qf $cfg" 0 'x]]>]]>' "^]]>]]>$" 2>&1 | awk '/real/ {print $2}' +expecteof "time -p $clixon_netconf -qf $cfg" 0 "x]]>]]>" "^]]>]]>$" 2>&1 | awk '/real/ {print $2}' new "netconf commit small leaf-list config" -expecteof "time -p $clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" 2>&1 | awk '/real/ {print $2}' +expecteof "time -p $clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" 2>&1 | awk '/real/ {print $2}' new "netconf get large leaf-list config" -expecteof "time -p $clixon_netconf -qf $cfg" 0 "]]>]]>" '^01' 2>&1 | awk '/real/ {print $2}' +expecteof "time -p $clixon_netconf -qf $cfg" 0 "]]>]]>" "^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 142d1f52..d4bf232e 100755 --- a/test/test_perf_state.sh +++ b/test/test_perf_state.sh @@ -118,7 +118,7 @@ if [ $RC -ne 0 ]; then fi new "generate 'large' config with $perfnr list entries" -echo -n "foo" > $fconfig +echo -n "foo" > $fconfig for (( i=0; i<$perfnr; i++ )); do echo -n "e$iex:eth" >> $fconfig done @@ -126,25 +126,25 @@ echo "]]>]]>" >> $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 -qf $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 "]]>]]>" "^]]>]]>$" 2>&1 | awk '/real/ {print $2}' +expecteof "time -p $clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" 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="]]>]]>" -expecteof "$clixon_netconf -qf $cfg" 0 "$msg" '^fooe1ex:ethtrueup]]>]]>$' +msg="]]>]]>" +expecteof "$clixon_netconf -qf $cfg" 0 "$msg" "^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 "]]>]]>" + echo "]]>]]>" done | $clixon_netconf -qf $cfg > /dev/null; } 2>&1 | awk '/real/ {print $2}' # RESTCONF get @@ -176,7 +176,7 @@ done } 2>&1 | awk '/real/ {print $2}' # Get config in one large get new "netconf get large config" -{ time -p echo " ]]>]]>" | $clixon_netconf -qf $cfg > /tmp/netconf; } 2>&1 | awk '/real/ {print $2}' +{ time -p echo " ]]>]]>" | $clixon_netconf -qf $cfg > /tmp/netconf; } 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 0a9e57a1..471ed06b 100755 --- a/test/test_perf_state_only.sh +++ b/test/test_perf_state_only.sh @@ -129,14 +129,14 @@ $TIMEFN $clixon_cli -1f $cfg show xpath /interfaces urn:example:clixon 2>&1 > /d # NETCONF get new "netconf get test single req" sel="/ex:interfaces/ex:a[ex:name='foo']/ex:b/ex:interface[ex:name='e1']" -msg="]]>]]>" -time -p expecteof "$clixon_netconf -qf $cfg" 0 "$msg" '^fooe1ex:ethup]]>]]>$' +msg="]]>]]>" +time -p expecteof "$clixon_netconf -qf $cfg" 0 "$msg" "^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 "]]>]]>" + echo "]]>]]>" done | $clixon_netconf -qf $cfg > /dev/null; } 2>&1 | awk '/real/ {print $2}' # RESTCONF get @@ -170,7 +170,7 @@ fi # Get config in one large get new "netconf get large config" -{ time -p echo " ]]>]]>" | $clixon_netconf -qf $cfg > /tmp/netconf; } 2>&1 | awk '/real/ {print $2}' +{ time -p echo " ]]>]]>" | $clixon_netconf -qf $cfg > /tmp/netconf; } 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_rpc.sh b/test/test_rpc.sh index 2bd881a7..4cbff92a 100755 --- a/test/test_rpc.sh +++ b/test/test_rpc.sh @@ -69,7 +69,7 @@ if [ -z "$match" ]; then fi new "netconf empty rpc" -expecteof "$clixon_netconf -qf $cfg" 0 ']]>]]>' '^]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" 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/1.1 200 OK' 'Content-Type: application/yang-data+json' '{"clixon-example:output":{"x":"0","y":"42"}}' @@ -97,7 +97,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/1.1 400 Bad Reques' 'rpcmalformed-messageerrorxml_parse: line 0: syntax error: at or before: "' new "netconf example rpc" -expecteof "$clixon_netconf -qf $cfg" 0 '0]]>]]>' '^042]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "0]]>]]>" "^042]]>]]>$" # 2. Then error cases # @@ -136,28 +136,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/1.1 400 Bad Request' '{"ietf-restconf:errors":{"error":{"error-type":"application","error-tag":"missing-element","error-info":{"bad-element":"target"},"error-severity":"error","error-message":"Mandatory variable"}}} ' new "netconf kill-session missing session-id mandatory" -expecteof "$clixon_netconf -qf $cfg" 0 ']]>]]>' '^applicationmissing-elementsession-iderrorMandatory variable]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^applicationmissing-elementsession-iderrorMandatory variable]]>]]>$" new "netconf edit-config ok" -expecteof "$clixon_netconf -qf $cfg" 0 ']]>]]>' "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" if ! $YANG_UNKNOWN_ANYDATA ; then new "netconf edit-config extra arg: should fail" -expecteof "$clixon_netconf -qf $cfg" 0 ']]>]]>' "^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 "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^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 ']]>]]>' '^applicationdata-missingmissing-choiceconfig-targeterror]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^applicationdata-missingmissing-choiceconfig-targeterror]]>]]>$" new "netconf edit-config missing target: should fail" -expecteof "$clixon_netconf -qf $cfg" 0 ']]>]]>' '^applicationmissing-elementtargeterrorMandatory variable]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^applicationmissing-elementtargeterrorMandatory variable]]>]]>$" new "netconf edit-config missing config: should fail" -expecteof "$clixon_netconf -qf $cfg" 0 ']]>]]>' '^applicationdata-missingmissing-choiceedit-contenterror]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^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 "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^applicationunknown-elementgeterrorUnrecognized RPC (wrong namespace?)]]>]]>$" new "restconf wrong rpc: should fail" expectpart "$(curl $CURLOPTS -X POST -H "Content-Type: application/yang-data+json" u $RCPROTO://localhost/restconf/operations/clixon-foo:get)" 0 'HTTP/1.1 412 Precondition Failed' '{"ietf-restconf:errors":{"error":{"error-type":"protocol","error-tag":"operation-failed","error-severity":"error","error-message":"yang module not found"}}}' diff --git a/test/test_sock.sh b/test/test_sock.sh index ba92de51..b04fcd1a 100755 --- a/test/test_sock.sh +++ b/test/test_sock.sh @@ -64,10 +64,10 @@ EOF expectfn "$clixon_cli -1f $cfg show version" 0 "$version." new "hello session-id 2" - expecteof "$clixon_util_socket -a $family -s $sock -D $DBG" 0 "" "3" + expecteof "$clixon_util_socket -a $family -s $sock -D $DBG" 0 "" "3" new "hello session-id 2" - expecteof "$clixon_util_socket -a $family -s $sock -D $DBG" 0 "" "4" + expecteof "$clixon_util_socket -a $family -s $sock -D $DBG" 0 "" "4" if [ $BE -ne 0 ]; then new "Kill backend" diff --git a/test/test_startup.sh b/test/test_startup.sh index b197d683..6d32bae0 100755 --- a/test/test_startup.sh +++ b/test/test_startup.sh @@ -90,13 +90,13 @@ testrun(){ sleep $BETIMEOUT fi new "Startup test for $mode mode, check running" - expecteof "$clixon_netconf -qf $cfg" 0 ']]>]]>' "^$exprun]]>]]>$" + expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^$exprun]]>]]>$" new "Startup test for $mode mode, check candidate" - expecteof "$clixon_netconf -qf $cfg" 0 ']]>]]>' "^$exprun]]>]]>$" + expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^$exprun]]>]]>$" new "Startup test for $mode mode, check startup is untouched" - expecteof "$clixon_netconf -qf $cfg" 0 ']]>]]>' "^$sdb]]>]]>$" + expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^$sdb]]>]]>$" new "Kill backend" # Check if premature kill diff --git a/test/test_stream.sh b/test/test_stream.sh index 2017bbfc..0876ebe8 100755 --- a/test/test_stream.sh +++ b/test/test_stream.sh @@ -139,35 +139,35 @@ fi 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 ']]>]]>' 'EXAMPLEExample event streamtrue]]>]]>' +expecteof "$clixon_netconf -D $DBG -qf $cfg" 0 "]]>]]>" "EXAMPLEExample event streamtrue]]>]]>" new "netconf event stream discovery RFC8040 Sec 6.2" -expecteof "$clixon_netconf -D $DBG -qf $cfg" 0 ']]>]]>' 'EXAMPLEExample event streamtruexmlhttps://localhost/streams/EXAMPLE]]>]]>' +expecteof "$clixon_netconf -D $DBG -qf $cfg" 0 "]]>]]>" "EXAMPLEExample event streamtruexmlhttps://localhost/streams/EXAMPLE]]>]]>" # # 1.2 Netconf stream subscription new "netconf EXAMPLE subscription" -expectwait "$clixon_netconf -D $DBG -qf $cfg" 'EXAMPLE]]>]]>' '^]]>]]>20' $NCWAIT +expectwait "$clixon_netconf -D $DBG -qf $cfg" "EXAMPLE]]>]]>" "^]]>]]>20" $NCWAIT new "netconf subscription with empty startTime" -expecteof "$clixon_netconf -D $DBG -qf $cfg" 0 'EXAMPLE]]>]]>' '^applicationbad-elementstartTimeerrorregexp match fail:' +expecteof "$clixon_netconf -D $DBG -qf $cfg" 0 "EXAMPLE]]>]]>" "^applicationbad-elementstartTimeerrorregexp match fail:" new "netconf EXAMPLE subscription with simple filter" -expectwait "$clixon_netconf -D $DBG -qf $cfg" 'EXAMPLE]]>]]>' '^]]>]]>20' $NCWAIT +expectwait "$clixon_netconf -D $DBG -qf $cfg" "EXAMPLE]]>]]>" "^]]>]]>20" $NCWAIT new "netconf EXAMPLE subscription with filter classifier" -expectwait "$clixon_netconf -D $DBG -qf $cfg" "EXAMPLE]]>]]>" '^]]>]]>20' $NCWAIT +expectwait "$clixon_netconf -D $DBG -qf $cfg" "EXAMPLE]]>]]>" "^]]>]]>20" $NCWAIT new "netconf NONEXIST subscription" -expectwait "$clixon_netconf -D $DBG -qf $cfg" 'NONEXIST]]>]]>' '^applicationinvalid-valueerrorNo such stream]]>]]>$' $NCWAIT +expectwait "$clixon_netconf -D $DBG -qf $cfg" "NONEXIST]]>]]>" "^applicationinvalid-valueerrorNo such stream]]>]]>$" $NCWAIT new "netconf EXAMPLE subscription with wrong date" -expectwait "$clixon_netconf -D $DBG -qf $cfg" 'EXAMPLEkallekaka]]>]]>' '^applicationbad-elementstartTimeerrorregexp match fail:' 0 +expectwait "$clixon_netconf -D $DBG -qf $cfg" "EXAMPLEkallekaka]]>]]>" "^applicationbad-elementstartTimeerrorregexp match fail:" 0 #new "netconf EXAMPLE subscription with replay" #NOW=$(date +"%Y-%m-%dT%H:%M:%S") #sleep 10 -#expectwait "$clixon_netconf -D $DBG -qf $cfg" "EXAMPLE$NOW]]>]]>" '^]]>]]>20' 10 +#expectwait "$clixon_netconf -D $DBG -qf $cfg" "EXAMPLE$NOW]]>]]>" "^]]>]]>20" 10 sleep 1 # @@ -187,7 +187,7 @@ sleep 1 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 'applicationinvalid-valueerrorNo such stream' 2 # 2a) start subscription 8s - expect 1-2 notifications new "2a) start subscriptions 8s - expect 1-2 notifications" diff --git a/test/test_submodule.sh b/test/test_submodule.sh index 39285517..b22c4848 100755 --- a/test/test_submodule.sh +++ b/test/test_submodule.sh @@ -173,7 +173,7 @@ if [ $RC -ne 0 ]; then fi new "netconfig edit main module" -expecteof "$clixon_netconf -qf $cfg" 0 '
foofoo
]]>]]>' "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "
foofoo
]]>]]>" "^]]>]]>$" new "cli edit main" expectfn "$clixon_cli -1f $cfg set main x bar" 0 "" @@ -182,7 +182,7 @@ new "cli edit main ext" expectfn "$clixon_cli -1f $cfg set main ext bar" 0 "" new "netconfig edit sub1" -expecteof "$clixon_netconf -qf $cfg" 0 'foofoo]]>]]>' "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "foofoo]]>]]>" "^]]>]]>$" new "cli edit sub1" expectfn "$clixon_cli -1f $cfg set sub1 x bar" 0 "" @@ -191,7 +191,7 @@ new "cli edit sub1 ext" expectfn "$clixon_cli -1f $cfg set sub1 ext1 bar" 0 "" new "netconfig edit sub2 module" -expecteof "$clixon_netconf -qf $cfg" 0 'foofoo]]>]]>' "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "foofoo]]>]]>" "^]]>]]>$" new "cli edit sub2" expectfn "$clixon_cli -1f $cfg set sub2 x fum" 0 "" @@ -200,10 +200,10 @@ new "cli edit sub2 ext" expectfn "$clixon_cli -1f $cfg set sub2 ext2 fum" 0 "" new "netconf submodule validate" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" new "netconf discard-changes" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" # Now same with restconf new "restconf edit main" diff --git a/test/test_transaction.sh b/test/test_transaction.sh index 8da5157b..4da86e4d 100755 --- a/test/test_transaction.sh +++ b/test/test_transaction.sh @@ -128,10 +128,10 @@ fi let nr=0 new "Basic transaction to add top-level x" -expecteof "$clixon_netconf -qf $cfg" 0 "$nr]]>]]>" '^]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "$nr]]>]]>" "^]]>]]>$" new "Commit base" -expecteof "$clixon_netconf -qf $cfg" 0 ']]>]]>' '^]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" let line=14 # Skipping basic transaction @@ -139,10 +139,10 @@ let line=14 # Skipping basic transaction let nr++ let line new "1. Validate-only transaction" -expecteof "$clixon_netconf -qf $cfg" 0 "$nr]]>]]>" '^]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "$nr]]>]]>" "^]]>]]>$" new "Validate-only validate" -expecteof "$clixon_netconf -qf $cfg" 0 ']]>]]>' '^]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" xml="$nr" for op in begin validate complete end; do @@ -153,15 +153,15 @@ for op in begin validate complete end; do done new "Validate-only discard-changes" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" # 2. Commit transaction let nr++ new "2. Commit transaction config" -expecteof "$clixon_netconf -qf $cfg" 0 "$nr]]>]]>" '^]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "$nr]]>]]>" "^]]>]]>$" new "Commit transaction: commit" -expecteof "$clixon_netconf -qf $cfg" 0 ']]>]]>' '^]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" xml="$nr" for op in begin validate complete commit commit_done end; do @@ -174,13 +174,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 "$nr9999]]>]]>" '^]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "$nr9999]]>]]>" "^]]>]]>$" new "Validate system-error validate (should fail)" -expecteof "$clixon_netconf -qf $cfg" 0 ']]>]]>' '^applicationbad-elementberrorNumber 9999 out of range: 0 - 100]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^applicationbad-elementberrorNumber 9999 out of range: 0 - 100]]>]]>$" new "Validate system-error discard-changes" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" for op in begin abort; do checklog "$nr main_$op add: $nr9999" $line @@ -192,13 +192,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 "$errnr]]>]]>" '^]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "$errnr]]>]]>" "^]]>]]>$" new "Validate user-error validate (should fail)" -expecteof "$clixon_netconf -qf $cfg" 0 ']]>]]>' '^applicationoperation-failederrorUser error]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^applicationoperation-failederrorUser error]]>]]>$" new "Validate user-error discard-changes" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" for op in begin validate; do checklog "$nr main_$op add: $errnr" $line @@ -219,13 +219,13 @@ done # in nacm/transaction example test module let nr++ new "5. Commit user-error ($errnr is invalid)" -expecteof "$clixon_netconf -qf $cfg" 0 "$errnr]]>]]>" '^]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "$errnr]]>]]>" "^]]>]]>$" new "Commit user-error commit" -expecteof "$clixon_netconf -qf $cfg" 0 ']]>]]>' '^applicationoperation-failederrorUser error]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^applicationoperation-failederrorUser error]]>]]>$" new "Commit user-error discard-changes" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" for op in begin validate complete commit ; do checklog "$nr main_$op add: $errnr" $line @@ -248,19 +248,19 @@ done let nr++ let base=nr new "Add base $base entry" -expecteof "$clixon_netconf -qf $cfg" 0 "$base00
]]>]]>" '^]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "$base00]]>]]>" "^]]>]]>$" new "netconf commit base" -expecteof "$clixon_netconf -qf $cfg" 0 ']]>]]>' '^]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" #Ignore let line+=12 let nr++ new "6. netconf mixed change: change b, del c, add d" -expecteof "$clixon_netconf -qf $cfg" 0 "$base420]]>]]>" '^]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "$base420]]>]]>" "^]]>]]>$" new "netconf commit change" -expecteof "$clixon_netconf -qf $cfg" 0 ']]>]]>' '^]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" # Check complete transaction $nr: for op in begin validate complete commit commit_done; do @@ -284,19 +284,19 @@ let line+=3 # skip nacm let nr++ let base=nr new "Add base $base entry" -expecteof "$clixon_netconf -qf $cfg" 0 "$base1
]]>]]>" '^]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "$base1]]>]]>" "^]]>]]>$" new "netconf commit base" -expecteof "$clixon_netconf -qf $cfg" 0 ']]>]]>' '^]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" 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 "$base11]]>]]>" '^]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "$base11]]>]]>" "^]]>]]>$" new "netconf commit base" -expecteof "$clixon_netconf -qf $cfg" 0 ']]>]]>' '^]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" # check complete for op in begin validate complete commit commit_done end; do diff --git a/test/test_transaction_restart.sh b/test/test_transaction_restart.sh index 2bba4752..8ae307b0 100755 --- a/test/test_transaction_restart.sh +++ b/test/test_transaction_restart.sh @@ -7,7 +7,6 @@ # Magic line must be first in script (see README.md) s="$_" ; . ./lib.sh || if [ "$s" = $0 ]; then exit 0; else return 0; fi - APPNAME=example cfg=$dir/conf_yang.xml @@ -106,17 +105,17 @@ fi let nr=0 new "Basic transaction to add top-level x" -expecteof "$clixon_netconf -qf $cfg" 0 "$nr
]]>]]>" '^]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "$nr
]]>]]>" "^]]>]]>$" new "Commit base" -expecteof "$clixon_netconf -qf $cfg" 0 ']]>]]>' '^]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" 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 'example_backend_nacm]]>]]>' '^]]>]]>' +expecteof "$clixon_netconf -qf $cfg" 0 "example_backend_nacm]]>]]>" "^]]>]]>" # Now analyze log: # all transactions come from nacm plugin only. @@ -130,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 'xxx]]>]]>' '^applicationbad-elementpluginerrorNo such plugin]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "xxx]]>]]>" "^applicationbad-elementpluginerrorNo such plugin]]>]]>$" if [ $BE -eq 0 ]; then exit # BE diff --git a/test/test_type.sh b/test/test_type.sh index 0e30b050..056a52c6 100755 --- a/test/test_type.sh +++ b/test/test_type.sh @@ -252,16 +252,16 @@ EOF expectfn "$clixon_cli -1f $cfg -l o set c talle 9xx" 255 '^CLI syntax error: "set c talle 9xx": regexp match fail: 9xx does not match \[a-z\]\[0-9\]\*$' new "netconf discard-changes" - expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" + expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" new "netconf set transitive string error" - expecteof "$clixon_netconf -qf $cfg" 0 '9xx]]>]]>' "^]]>]]>" + expecteof "$clixon_netconf -qf $cfg" 0 "9xx]]>]]>" "^]]>]]>" new "netconf validate should fail" - expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" 'applicationbad-elementtalleerrorregexp match fail:' + expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "applicationbad-elementtalleerrorregexp match fail:" new "netconf discard-changes" - expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" + expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" new "cli set transitive union int (ulle should accept 4.44|bounded|unbounded)" expectfn "$clixon_cli -1f $cfg -l o set c ulle 33" 0 '^$' @@ -282,13 +282,13 @@ EOF expectfn "$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 '55]]>]]>' "^]]>]]>" + expecteof "$clixon_netconf -qf $cfg" 0 "55]]>]]>" "^]]>]]>" new "netconf validate should fail" - expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^applicationbad-elementulleerror'55' does not match enumeration]]>]]>$" + expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^applicationbad-elementulleerror'55' does not match enumeration]]>]]>$" new "netconf discard-changes" - expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" + expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" #----------- @@ -314,19 +314,19 @@ EOF expectfn "$clixon_cli -1f $cfg -l o -l o commit" 0 '^$' new "netconf validate ok" - expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" + expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" new "netconf set ab wrong" - expecteof "$clixon_netconf -qf $cfg" 0 'a.b& c.d]]>]]>' "^]]>]]>$" + expecteof "$clixon_netconf -qf $cfg" 0 "a.b& c.d]]>]]>" "^]]>]]>$" new "netconf validate" - expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^" + expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^" new "netconf discard-changes" - expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" + expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" new "netconf commit" - expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" + expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" new "cli enum value" expectfn "$clixon_cli -1f $cfg -l o set status down" 0 '^$' @@ -339,7 +339,7 @@ EOF #expectfn "$clixon_cli -1f $cfg -l o set mbits \"create read\"" 0 '^$' new "netconf bits two values" - expecteof "$clixon_netconf -qf $cfg" 0 'create read]]>]]>' "^]]>]]>$" + expecteof "$clixon_netconf -qf $cfg" 0 "create read]]>]]>" "^]]>]]>$" new "cli bits validate" expectfn "$clixon_cli -1f $cfg -l o validate" 0 '^$' @@ -347,13 +347,13 @@ EOF #-------- num0 empty value new "netconf num0 no value" - expecteof "$clixon_netconf -qf $cfg" 0 ']]>]]>' "^]]>]]>$" + expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" new "netconf validate no value wrong" - expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" 'applicationbad-elementnum0errorInvalid NULL value]]>]]>' + expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "applicationbad-elementnum0errorInvalid NULL value]]>]]>" new "netconf discard-changes" - expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" + expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" #-------- num1 single range (1) @@ -367,13 +367,13 @@ EOF expectfn "$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 '-1]]>]]>' "^]]>]]>$" + expecteof "$clixon_netconf -qf $cfg" 0 "-1]]>]]>" "^]]>]]>$" new "netconf validate num1 -1 wrong" - expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" '^applicationbad-elementnum1errorNumber -1 out of range: 1 - 1]]>]]>$' + expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^applicationbad-elementnum1errorNumber -1 out of range: 1 - 1]]>]]>$" new "netconf discard-changes" - expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" + expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" #-------- num2 range and blanks @@ -387,25 +387,25 @@ EOF expectfn "$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 '3]]>]]>' "^]]>]]>$" + expecteof "$clixon_netconf -qf $cfg" 0 "3]]>]]>" "^]]>]]>$" new "netconf validate num2 3 fail" - expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" '^applicationbad-elementnum2errorNumber 3 out of range: 4 - 4000]]>]]>$' + expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^applicationbad-elementnum2errorNumber 3 out of range: 4 - 4000]]>]]>$" new "netconf range set num2 1000 ok" - expecteof "$clixon_netconf -qf $cfg" 0 '1000]]>]]>' "^]]>]]>$" + expecteof "$clixon_netconf -qf $cfg" 0 "1000]]>]]>" "^]]>]]>$" new "netconf validate num2 1000 ok" - expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" '^]]>]]>$' + expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" new "netconf range set num2 5000 fail" - expecteof "$clixon_netconf -qf $cfg" 0 '5000]]>]]>' "^]]>]]>$" + expecteof "$clixon_netconf -qf $cfg" 0 "5000]]>]]>" "^]]>]]>$" new "netconf validate num2 5000 fail" - expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" '^applicationbad-elementnum2errorNumber 5000 out of range: 4 - 4000]]>]]>$' + expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^applicationbad-elementnum2errorNumber 5000 out of range: 4 - 4000]]>]]>$" new "netconf discard-changes" - expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" + expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" #-------- num3 min max range @@ -419,13 +419,13 @@ EOF expectfn "$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 '260]]>]]>' "^]]>]]>$" + expecteof "$clixon_netconf -qf $cfg" 0 "260]]>]]>" "^]]>]]>$" new "netconf validate num3 260 fail" - expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" '^applicationbad-elementnum3errorNumber 260 out of range: 0 - 255]]>]]>$' + expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^applicationbad-elementnum3errorNumber 260 out of range: 0 - 255]]>]]>$" new "netconf discard-changes" - expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" + expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" #-------- num4 multiple ranges 1..2 | 42..50 @@ -445,25 +445,25 @@ EOF expectfn "$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 '42]]>]]>' "^]]>]]>$" + expecteof "$clixon_netconf -qf $cfg" 0 "42]]>]]>" "^]]>]]>$" new "netconf validate num4 OK" - expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" '^]]>]]>$' + expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" new "netconf range set num4 multiple 20" - expecteof "$clixon_netconf -qf $cfg" 0 '42]]>]]>' "^]]>]]>$" + expecteof "$clixon_netconf -qf $cfg" 0 "42]]>]]>" "^]]>]]>$" new "netconf validate num4 fail" - expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" '^]]>]]>$' + expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" new "netconf range set num4 multiple 42" - expecteof "$clixon_netconf -qf $cfg" 0 '42]]>]]>' "^]]>]]>$" + expecteof "$clixon_netconf -qf $cfg" 0 "42]]>]]>" "^]]>]]>$" new "netconf validate num4 fail" - expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" '^]]>]]>$' + expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" new "netconf discard-changes" - expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" + expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" #-------- 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? @@ -480,44 +480,44 @@ EOF expectfn "$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 "]]>]]>" "^]]>]]>$" + expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" # Same with netconf new "netconf range dec64 -3.59" - expecteof "$clixon_netconf -qf $cfg" 0 '-3.59]]>]]>' "^]]>]]>$" + expecteof "$clixon_netconf -qf $cfg" 0 "-3.59]]>]]>" "^]]>]]>$" new "netconf range dec64 -3.59 validate fail" - expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" '^applicationbad-elementdecerrorNumber -3.590 out of range' + expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^applicationbad-elementdecerrorNumber -3.590 out of range" new "netconf range dec64 -3.5" - expecteof "$clixon_netconf -qf $cfg" 0 '-3.500]]>]]>' "^]]>]]>$" + expecteof "$clixon_netconf -qf $cfg" 0 "-3.500]]>]]>" "^]]>]]>$" new "netconf range dec64 -3.5 validate ok" - expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" '^]]>]]>$' + expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" new "netconf range dec64 -2" - expecteof "$clixon_netconf -qf $cfg" 0 '-2]]>]]>' "^]]>]]>$" + expecteof "$clixon_netconf -qf $cfg" 0 "-2]]>]]>" "^]]>]]>$" new "netconf range dec64 -2 validate fail" - expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" '^applicationbad-elementdecerrorNumber -2.000 out of range' + expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^applicationbad-elementdecerrorNumber -2.000 out of range" new "netconf range dec64 -0.001" - expecteof "$clixon_netconf -qf $cfg" 0 '-0.001]]>]]>' "^]]>]]>$" + expecteof "$clixon_netconf -qf $cfg" 0 "-0.001]]>]]>" "^]]>]]>$" new "netconf range dec64 -0.001 validate fail" - expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" '^applicationbad-elementdecerrorNumber -0.001 out of range' + expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^applicationbad-elementdecerrorNumber -0.001 out of range" new "netconf range dec64 0.0" - expecteof "$clixon_netconf -qf $cfg" 0 '0.0]]>]]>' "^]]>]]>$" + expecteof "$clixon_netconf -qf $cfg" 0 "0.0]]>]]>" "^]]>]]>$" new "netconf range dec64 0.0 validate ok" - expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" '^]]>]]>$' + expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" new "netconf range dec64 +0.001" - expecteof "$clixon_netconf -qf $cfg" 0 '+0.001]]>]]>' "^]]>]]>$" + expecteof "$clixon_netconf -qf $cfg" 0 "+0.001]]>]]>" "^]]>]]>$" new "netconf range dec64 +0.001 validate fail" - expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" '^applicationbad-elementdecerrorNumber 0.001 out of range' + expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^applicationbad-elementdecerrorNumber 0.001 out of range" #----------------string ranges--------------------- #-------- len1 single range (2) @@ -531,13 +531,13 @@ EOF expectfn "$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 "]]>]]>" "^]]>]]>$" + expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" new "netconf length set len1 1" - expecteof "$clixon_netconf -qf $cfg" 0 'x]]>]]>' "^]]>]]>$" + expecteof "$clixon_netconf -qf $cfg" 0 "x]]>]]>" "^]]>]]>$" new "netconf validate len1 1 wrong" - expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" '^applicationbad-elementlen1errorString length 1 out of range: 2 - 2]]>]]>$' + expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^applicationbad-elementlen1errorString length 1 out of range: 2 - 2]]>]]>$" #-------- len2 range and blanks @@ -548,7 +548,7 @@ EOF expectfn "$clixon_cli -1f $cfg -l o set len2 hejhophdsakjhkjsadhkjsahdkjsad" 0 '^$' new "netconf discard-changes" - expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" + expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" #-------- len3 min max range @@ -585,75 +585,75 @@ EOF expectfn "$clixon_cli -1f $cfg -l o set word4 ab%3" 255 '^CLI syntax error: "set word4 ab%3": regexp match fail: ab%3 does not match' new "netconf pattern \w" - expecteof "$clixon_netconf -qf $cfg" 0 'aXG9]]>]]>' "^]]>]]>$" + expecteof "$clixon_netconf -qf $cfg" 0 "aXG9]]>]]>" "^]]>]]>$" new "netconf pattern \w valid" - expecteof "$clixon_netconf -qf $cfg" 0 ']]>]]>' "^]]>]]>$" + expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" new "netconf pattern \w error" - expecteof "$clixon_netconf -qf $cfg" 0 'ab%d3]]>]]>' "^]]>]]>$" + expecteof "$clixon_netconf -qf $cfg" 0 "ab%d3]]>]]>" "^]]>]]>$" new "netconf pattern \w invalid" - expecteof "$clixon_netconf -qf $cfg" 0 ']]>]]>' '^applicationbad-elementword4errorregexp match fail:' + expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^applicationbad-elementword4errorregexp match fail:" new "netconf discard-changes" - expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" + expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" #------ Mandatory new "netconf set container w/o mandatory leaf" - expecteof "$clixon_netconf -qf $cfg" 0 ']]>]]>' "^]]>]]>" + expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>" new "netconf validate should fail" - expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" 'applicationmissing-elementmanerrorMandatory variable]]>]]>' + expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "applicationmissing-elementmanerrorMandatory variable]]>]]>" new "netconf set container with mandatory leaf" - expecteof "$clixon_netconf -qf $cfg" 0 'foo]]>]]>' "^]]>]]>" + expecteof "$clixon_netconf -qf $cfg" 0 "foo]]>]]>" "^]]>]]>" new "netconf commit" - expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" + expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" new "netconf delete mandatory variable" - expecteof "$clixon_netconf -qf $cfg" 0 'foonone]]>]]>' '^]]>]]>$' + expecteof "$clixon_netconf -qf $cfg" 0 "foonone]]>]]>" "^]]>]]>$" new "get mandatory" - expecteof "$clixon_netconf -qf $cfg" 0 ']]>]]>' '^]]>]]>$' + expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" new "netconf validate should fail" - expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" '^protocolmissing-elementmanerrorMay not remove mandatory variable]]>]]>$' + expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^protocolmissing-elementmanerrorMay not remove mandatory variable]]>]]>$" new "netconf discard-changes" - expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" + expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" #------ minus new "type with minus" - expecteof "$clixon_netconf -qf $cfg" 0 'my-name]]>]]>' "^]]>]]>$" + expecteof "$clixon_netconf -qf $cfg" 0 "my-name]]>]]>" "^]]>]]>$" new "validate minus" - expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" + expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" #new "cli type with minus" - #expectfn "$clixon_cli -1f $cfg -l o set name my-name" 0 '^$' + #expectfn "$clixon_cli -1f $cfg -l o set name my-name" 0 "^$" #------ cli truth-values: true/on/enable false/off/disable new "cli truth: true" - expectfn "$clixon_cli -1f $cfg -l o set bool true" 0 '^$' + expectfn "$clixon_cli -1f $cfg -l o set bool true" 0 "^$" new "cli truth: false" - expectfn "$clixon_cli -1f $cfg -l o set bool false" 0 '^$' + expectfn "$clixon_cli -1f $cfg -l o set bool false" 0 "^$" new "cli truth: on" - expectfn "$clixon_cli -1f $cfg -l o set bool on" 0 '^$' + expectfn "$clixon_cli -1f $cfg -l o set bool on" 0 "^$" new "cli verify on translates to true" - expectfn "$clixon_cli -1f $cfg -l o show conf" 0 'bool true;' + expectfn "$clixon_cli -1f $cfg -l o show conf" 0 "bool true;" new "cli truth: off" - expectfn "$clixon_cli -1f $cfg -l o set bool off" 0 '^$' + expectfn "$clixon_cli -1f $cfg -l o set bool off" 0 "^$" new "cli verify off translates to false" - expectfn "$clixon_cli -1f $cfg -l o show conf" 0 'bool false;' + expectfn "$clixon_cli -1f $cfg -l o show conf" 0 "bool false;" new "cli truth: enable" - expectfn "$clixon_cli -1f $cfg -l o set bool enable" 0 '^$' + expectfn "$clixon_cli -1f $cfg -l o set bool enable" 0 "^$" new "cli truth: disable" - expectfn "$clixon_cli -1f $cfg -l o set bool disable" 0 '^$' + expectfn "$clixon_cli -1f $cfg -l o set bool disable" 0 "^$" new "cli truth: wrong" expectfn "$clixon_cli -1f $cfg -l o set bool wrong" 255 "'wrong' is not a boolean value" diff --git a/test/test_type_range.sh b/test/test_type_range.sh index c6dc66bc..e530b2c9 100755 --- a/test/test_type_range.sh +++ b/test/test_type_range.sh @@ -203,14 +203,14 @@ testbuiltin(){ new "Netconf set invalid $t leaf" echo "$clixon_netconf -qf $cfg" - echo "$val]]>]]>" - expecteof "$clixon_netconf -qf $cfg" 0 "$val]]>]]>" "^]]>]]>$" + echo "$val]]>]]>" + expecteof "$clixon_netconf -qf $cfg" 0 "$val]]>]]>" "^]]>]]>$" new "netconf validate invalid range" - expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^applicationbad-elementr$terror$errmsg]]>]]>$" + expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^applicationbad-elementr$terror$errmsg]]>]]>$" new "discard" - expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" + expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" } # Type explicit typed range tests. @@ -255,22 +255,21 @@ testrange(){ expectfn "$clixon_cli -1f $cfg -l o set l$t $eval" 255 "$errmsg" new "discard" - expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" + expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" new "Netconf set invalid $t leaf" - expecteof "$clixon_netconf -qf $cfg" 0 "$eval]]>]]>" "^]]>]]>$" + expecteof "$clixon_netconf -qf $cfg" 0 "$eval]]>]]>" "^]]>]]>$" new "netconf get config" - expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^$eval]]>]]>$" + expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^$eval]]>]]>$" new "netconf validate invalid range" - expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^applicationbad-elementl$terror$errmsg]]>]]>$" + expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^applicationbad-elementl$terror$errmsg]]>]]>$" new "discard" - expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" + expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" } - if [ $BE -ne 0 ]; then new "kill old backend" sudo clixon_backend -zf $cfg diff --git a/test/test_unique.sh b/test/test_unique.sh index 5b983e0b..caf66609 100755 --- a/test/test_unique.sh +++ b/test/test_unique.sh @@ -96,7 +96,7 @@ fi # RFC test two-field caes new "Add not valid example" -expecteof "$clixon_netconf -qf $cfg" 0 'replace +expecteof "$clixon_netconf -qf $cfg" 0 "replace smtp 192.0.2.1 25 @@ -106,16 +106,16 @@ expecteof "$clixon_netconf -qf $cfg" 0 '192.0.2.1 25 -]]>]]>' "^]]>]]>$" +]]>]]>" "^]]>]]>$" new "netconf validate (should fail)" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" '^protocoloperation-faileddata-not-uniqueerror192.0.2.125]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^protocoloperation-faileddata-not-uniqueerror192.0.2.125]]>]]>$" new "netconf discard-changes" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" new "Add valid example" -expecteof "$clixon_netconf -qf $cfg" 0 'replace +expecteof "$clixon_netconf -qf $cfg" 0 "replace smtp 192.0.2.1 25 @@ -128,31 +128,31 @@ expecteof "$clixon_netconf -qf $cfg" 0 'ftp 192.0.2.1 -]]>]]>' "^]]>]]>$" +]]>]]>" "^]]>]]>$" new "netconf validate ok" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" new "make it invalid by adding port to ftp entry" -expecteof "$clixon_netconf -qf $cfg" 0 'noneftp25 -]]>]]>' "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "noneftp25 +]]>]]>" "^]]>]]>$" new "netconf validate (should fail)" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" '^protocoloperation-faileddata-not-uniqueerror192.0.2.125]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^protocoloperation-faileddata-not-uniqueerror192.0.2.125]]>]]>$" new "make it valid by deleting port from smtp entry" -expecteof "$clixon_netconf -qf $cfg" 0 'nonesmtp25 -]]>]]>' '^]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "nonesmtp25 +]]>]]>" "^]]>]]>$" new "netconf validate ok" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" new "netconf discard-changes" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" # Then test single-field case new "Add not valid example" -expecteof "$clixon_netconf -qf $cfg" 0 'replace +expecteof "$clixon_netconf -qf $cfg" 0 "replace smtp 192.0.2.1 @@ -160,26 +160,26 @@ expecteof "$clixon_netconf -qf $cfg" 0 'http 192.0.2.1 -]]>]]>' "^]]>]]>$" +
]]>]]>" "^]]>]]>$" new "netconf validate (should fail)" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" '^protocoloperation-faileddata-not-uniqueerror192.0.2.1]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^protocoloperation-faileddata-not-uniqueerror192.0.2.1]]>]]>$" new "make valid by replacing IP of http entry" -expecteof "$clixon_netconf -qf $cfg" 0 'nonehttp178.23.34.1 -]]>]]>' "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "nonehttp178.23.34.1 +]]>]]>" "^]]>]]>$" new "netconf validate ok" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" new "netconf discard-changes" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" # Then test composite case (detect duplicates among other elements) # and also unordered new "Add not valid example" -expecteof "$clixon_netconf -qf $cfg" 0 'replace +expecteof "$clixon_netconf -qf $cfg" 0 "replace other smtp @@ -201,13 +201,13 @@ expecteof "$clixon_netconf -qf $cfg" 0 '192.0.2.1 25 -]]>]]>' "^]]>]]>$" +]]>]]>" "^]]>]]>$" new "netconf validate (should fail)" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" '^protocoloperation-faileddata-not-uniqueerror192.0.2.125]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^protocoloperation-faileddata-not-uniqueerror192.0.2.125]]>]]>$" new "netconf discard-changes" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" if [ $BE -eq 0 ]; then exit # BE diff --git a/test/test_upgrade_auto.sh b/test/test_upgrade_auto.sh index f1cff706..1f46c0a6 100755 --- a/test/test_upgrade_auto.sh +++ b/test/test_upgrade_auto.sh @@ -270,7 +270,7 @@ if [ $RC -ne 0 ]; then fi new "Check running db content" -expecteof "$clixon_netconf -qf $cfg" 0 ']]>]]>' "^$XML]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^$XML]]>]]>$" if [ $RC -ne 0 ]; then new "Kill restconf daemon" diff --git a/test/test_upgrade_failsafe.sh b/test/test_upgrade_failsafe.sh index 37116572..893283e6 100755 --- a/test/test_upgrade_failsafe.sh +++ b/test/test_upgrade_failsafe.sh @@ -274,12 +274,12 @@ runtest(){ fi new "Check running db content" - expecteof "$clixon_netconf -qf $cfg" 0 ']]>]]>' "^$exprun]]>]]>$" + expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^$exprun]]>]]>$" # If given check startup db XML if [ -n "$expstart" ]; then new "Check startup db content" - expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^$expstart]]>]]>$" + expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^$expstart]]>]]>$" fi if [ $BE -ne 0 ]; then diff --git a/test/test_upgrade_interfaces.sh b/test/test_upgrade_interfaces.sh index 5c25aafa..d19ab181 100755 --- a/test/test_upgrade_interfaces.sh +++ b/test/test_upgrade_interfaces.sh @@ -280,7 +280,7 @@ testrun(){ wait_restconf new "Check running db content" - expecteof "$clixon_netconf -qf $cfg" 0 ']]>]]>' "^$runxml]]>]]>$" + expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^$runxml]]>]]>$" new "Kill restconf daemon" stop_restconf diff --git a/test/test_upgrade_repair.sh b/test/test_upgrade_repair.sh index 8ec0f860..02b8abc8 100755 --- a/test/test_upgrade_repair.sh +++ b/test/test_upgrade_repair.sh @@ -128,26 +128,26 @@ if [ $RC -ne 0 ]; then fi new "Check running db content is failsafe" -expecteof "$clixon_netconf -qf $cfg" 0 ']]>]]>' "^$SAMEXML]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^$SAMEXML]]>]]>$" new "copy startup->candidate" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" new "Check candidate db content is startup" -expecteof "$clixon_netconf -qf $cfg" 0 ']]>]]>' "^$OLDXML$SAMEXML]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^$OLDXML$SAMEXML]]>]]>$" # Note you cannot edit invalid XML since a0 lacks namespace new "Put new version into candidate" -expecteof "$clixon_netconf -qf $cfg" 0 "$NEWXML$SAMEXML]]>]]>" "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "$NEWXML$SAMEXML]]>]]>" "^]]>]]>$" new "Check candidate db content is updated" -expecteof "$clixon_netconf -qf $cfg" 0 ']]>]]>' "^$SAMEXML$NEWXML]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^$SAMEXML$NEWXML]]>]]>$" new "commit to running" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" new "Check running db content is updated" -expecteof "$clixon_netconf -qf $cfg" 0 ']]>]]>' "^$SAMEXML$NEWXML]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^$SAMEXML$NEWXML]]>]]>$" if [ $RC -ne 0 ]; then new "Kill restconf daemon" diff --git a/test/test_upgrade_simple.sh b/test/test_upgrade_simple.sh index e7874a74..ab0b21a1 100755 --- a/test/test_upgrade_simple.sh +++ b/test/test_upgrade_simple.sh @@ -64,10 +64,10 @@ if [ $BE -ne 0 ]; then fi new "add hello world (with modstate)" -expecteof "$clixon_netconf -qf $cfg" 0 ']]>]]>' "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" new "netconf commit" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" new "Kill backend" # Check if premature kill @@ -112,7 +112,7 @@ if [ $BE -ne 0 ]; then fi new "netconf get config" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" '^]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" new "Kill backend" # Check if premature kill diff --git a/test/test_when_must.sh b/test/test_when_must.sh index 14d1483a..9fb8fe78 100755 --- a/test/test_when_must.sh +++ b/test/test_when_must.sh @@ -105,40 +105,40 @@ if [ $BE -ne 0 ]; then fi new "when: add static route" -expecteof "$clixon_netconf -qf $cfg" 0 'staticr1]]>]]>' "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "staticr1]]>]]>" "^]]>]]>$" new "when: validate ok" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" new "when: add direct route" -expecteof "$clixon_netconf -qf $cfg" 0 'directr2]]>]]>' "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "directr2]]>]]>" "^]]>]]>$" new "when get config" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" '^directr2staticr1]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^directr2staticr1]]>]]>$" new "when: validate fail" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^applicationoperation-failederrorwhen xpath validation failed]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^applicationoperation-failederrorwhen xpath validation failed]]>]]>$" new "when: discard-changes" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" new "must: add interface" -expecteof "$clixon_netconf -qf $cfg" 0 'ethernet1500]]>]]>' "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "ethernet1500]]>]]>" "^]]>]]>$" new "must: validate ok" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" new "must: add atm interface" -expecteof "$clixon_netconf -qf $cfg" 0 'atm32]]>]]>' "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "atm32]]>]]>" "^]]>]]>$" new "must: atm validate fail" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^applicationoperation-failederrorAn ATM MTU must be 64 .. 17966]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^applicationoperation-failederrorAn ATM MTU must be 64 .. 17966]]>]]>$" new "must: add eth interface" -expecteof "$clixon_netconf -qf $cfg" 0 'ethernet989]]>]]>' "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "ethernet989]]>]]>" "^]]>]]>$" new "must: eth validate fail" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^applicationoperation-failederrorAn Ethernet MTU must be 1500]]>]]>" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^applicationoperation-failederrorAn Ethernet MTU must be 1500]]>]]>" if [ $BE -eq 0 ]; then exit # BE diff --git a/test/test_with_default.sh b/test/test_with_default.sh index 9fb1adea..32517ca3 100755 --- a/test/test_with_default.sh +++ b/test/test_with_default.sh @@ -96,10 +96,10 @@ TRIM='defaultnotset$XML]]>]]>" "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "$XML]]>]]>" "^]]>]]>$" new "Check config (Clixon supports explicit)" -expecteof "$clixon_netconf -qf $cfg" 0 ']]>]]>' "^$EXPLICIT]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^$EXPLICIT]]>]]>$" if [ $BE -eq 0 ]; then exit # BE diff --git a/test/test_yang.sh b/test/test_yang.sh index 4effae0a..87288a95 100755 --- a/test/test_yang.sh +++ b/test/test_yang.sh @@ -160,16 +160,16 @@ new "cli defined extension" expectfn "$clixon_cli -1f $cfg show version" 0 "$version." new "empty values in leaf-list" -expecteof "$clixon_netconf -qf $cfg" 0 'a]]>]]>' "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "a]]>]]>" "^]]>]]>$" new "empty values in leaf-list2" -expecteof "$clixon_netconf -qf $cfg" 0 ']]>]]>' "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" new "netconf get config" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" '^a]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^a]]>]]>$" new "netconf discard-changes" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" #new "cli not defined extension" #new "netconf not defined extension" @@ -178,32 +178,32 @@ expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^< #expectfn "$clixon_cli -1f $cfg -y $fyangerr show version" 0 "Yang error: Extension ex:not-defined not found" new "netconf schema resource, RFC 7895" -expecteof "$clixon_netconf -qf $cfg" 0 ']]>]]>' 'ietf-yang-types2013-07-15urn:ietf:params:xml:ns:yang:ietf-yang-typesimplement' +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "ietf-yang-types2013-07-15urn:ietf:params:xml:ns:yang:ietf-yang-typesimplement" new "netconf edit config" -expecteof "$clixon_netconf -qf $cfg" 0 '125one]]>]]>' "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "125one]]>]]>" "^]]>]]>$" new "netconf commit" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" # text empty type in running new "netconf commit 2nd" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" new "netconf get config xpath" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" '^125one]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^125one]]>]]>$" new "netconf edit leaf-list" -expecteof "$clixon_netconf -qf $cfg" 0 'hejhopp]]>]]>' "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "hejhopp]]>]]>" "^]]>]]>$" new "netconf get leaf-list" -expecteof "$clixon_netconf -qf $cfg" 0 ']]>]]>' '^hejhopp]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^hejhopp]]>]]>$" new "netconf get leaf-list path" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^hejhopp]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^hejhopp]]>]]>$" new "netconf get (should be some)" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" '^125one' +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^125one" new "cli set leaf-list" expectfn "$clixon_cli -1f $cfg set x f e foo" 0 "" @@ -212,72 +212,72 @@ new "cli show leaf-list" expectfn "$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 '42]]>]]>' '^protocolinvalid-valueerrorState data not allowed]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "42]]>]]>" "^protocolinvalid-valueerrorState data not allowed]]>]]>$" new "netconf set presence and not present" -expecteof "$clixon_netconf -qf $cfg" 0 ']]>]]>' "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" new "netconf get presence only" -expecteof "$clixon_netconf -qf $cfg" 0 ']]>]]>' '^]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" new "netconf get presence only" -expecteof "$clixon_netconf -qf $cfg" 0 ']]>]]>' "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" new "netconf discard-changes" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" new "netconf anyxml" -expecteof "$clixon_netconf -qf $cfg" 0 ']]>]]>' "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" new "netconf validate anyxml" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" new "netconf delete candidate" -expecteof "$clixon_netconf -qf $cfg" 0 'none]]>]]>' "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "none]]>]]>" "^]]>]]>$" # Check 3-keys new "netconf add one 3-key entry" -expecteof "$clixon_netconf -qf $cfg" 0 '111one]]>]]>' "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "111one]]>]]>" "^]]>]]>$" new "netconf check add one 3-key" -expecteof "$clixon_netconf -qf $cfg" 0 ']]>]]>' '111one]]>]]>' +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "111one]]>]]>" new "netconf add another (with same 1st key)" -expecteof "$clixon_netconf -qf $cfg" 0 '121two]]>]]>' "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "121two]]>]]>" "^]]>]]>$" new "netconf check add another" -expecteof "$clixon_netconf -qf $cfg" 0 ']]>]]>' '111one121two]]>]]>' +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "111one121two]]>]]>" new "netconf replace first" -expecteof "$clixon_netconf -qf $cfg" 0 '111replace]]>]]>' "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "111replace]]>]]>" "^]]>]]>$" new "netconf check replace" -expecteof "$clixon_netconf -qf $cfg" 0 ']]>]]>' '111replace121two]]>]]>' +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "111replace121two]]>]]>" new "netconf delete first" -expecteof "$clixon_netconf -qf $cfg" 0 '111]]>]]>' "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "111]]>]]>" "^]]>]]>$" new "netconf check delete" -expecteof "$clixon_netconf -qf $cfg" 0 ']]>]]>' '121two]]>]]>' +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "121two]]>]]>" # clear db for next test new "netconf delete candidate" -expecteof "$clixon_netconf -qf $cfg" 0 'none]]>]]>' "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "none]]>]]>" "^]]>]]>$" new "netconf commit empty candidate" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" new "netconfig config submodule" -expecteof "$clixon_netconf -qf $cfg" 0 'afoo]]>]]>' "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "afoo]]>]]>" "^]]>]]>$" new "netconf submodule get config" -expecteof "$clixon_netconf -qf $cfg -D 1 -l s" 0 ']]>]]>' '^afoo]]>]]>$' +expecteof "$clixon_netconf -qf $cfg -D 1 -l s" 0 "]]>]]>" "^afoo]]>]]>$" new "netconf submodule validate" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" new "netconf submodule discard-changes" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" if [ "$BE" -eq 0 ]; then exit # BE diff --git a/test/test_yang_anydata.sh b/test/test_yang_anydata.sh index 9685a5d1..89796d6f 100755 --- a/test/test_yang_anydata.sh +++ b/test/test_yang_anydata.sh @@ -189,20 +189,20 @@ EOF if ! $startup; then # If not startup, add xml using netconf new "Put anydata" - expecteof "$clixon_netconf -qf $cfg -D $DBG" 0 "$XMLA]]>]]>" "]]>]]>" + expecteof "$clixon_netconf -qf $cfg -D $DBG" 0 "$XMLA]]>]]>" "]]>]]>" new "Put unknown" - expecteof "$clixon_netconf -qf $cfg -D $DBG" 0 "$XMLU]]>]]>" "$unknownreply" + expecteof "$clixon_netconf -qf $cfg -D $DBG" 0 "$XMLU]]>]]>" "$unknownreply" new "commit" - expecteof "$clixon_netconf -qf $cfg -D $DBG" 0 "]]>]]>" "]]>]]>" + expecteof "$clixon_netconf -qf $cfg -D $DBG" 0 "]]>]]>" "]]>]]>" fi new "Get candidate" - expecteof "$clixon_netconf -qf $cfg" 0 ']]>]]>' "^$XML]]>]]>$" + expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^$XML]]>]]>$" new "Get running" - expecteof "$clixon_netconf -qf $cfg" 0 ']]>]]>' "^$XML]]>]]>$" + expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^$XML]]>]]>$" # Add other functions, (based on previous errors), eg cli show config, cli commit. new "cli show configuration" @@ -211,7 +211,6 @@ EOF new "cli commit" expectpart "$($clixon_cli -1 -f $cfg commit)" 0 "^$" - new "restconf get config" expectpart "$(curl $CURLOPTS -X GET -H "Accept: application/yang-data+xml" $RCPROTO://localhost/restconf/data?content=config)" 0 "HTTP/1.1 200 OK" "$XML" @@ -219,7 +218,7 @@ EOF echo "$STATE1" > $fstate new "Get state (positive test)" - expecteof "$clixon_netconf -qf $cfg" 0 ']]>]]>' "^$STATE1]]>]]>" + expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^$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/1.1 200 OK" "$STATE1" @@ -228,7 +227,7 @@ EOF echo "$STATE0" > $fstate new "Get state (negative test)" - expecteof "$clixon_netconf -qf $cfg" 0 ']]>]]>' "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: example_backend" + expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "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: 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/1.1 412 Precondition Failed" "operation-failedu5" @@ -237,13 +236,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 ']]>]]>' 'operation-not-supported' + expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "operation-not-supported" new "anydata RPC" - expecteof "$clixon_netconf -qf $cfg" 0 '88]]>]]>' 'operation-not-supported' + expecteof "$clixon_netconf -qf $cfg" 0 "88]]>]]>" "operation-not-supported" new "unknown RPC" - expecteof "$clixon_netconf -qf $cfg" 0 '88]]>]]>' 'unknown-element' + expecteof "$clixon_netconf -qf $cfg" 0 "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 51eeaa55..534e04b0 100755 --- a/test/test_yang_default.sh +++ b/test/test_yang_default.sh @@ -108,7 +108,7 @@ testrun(){ fi new "check running defaults" - expecteof "$clixon_netconf -qf $cfg" 0 ']]>]]>' '^0foo42]]>]]>$' + expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^0foo42]]>]]>$" if [ $BE -ne 0 ]; then # Bring your own backend new "Kill backend" diff --git a/test/test_yang_extension.sh b/test/test_yang_extension.sh index dc47d434..a6577e2c 100755 --- a/test/test_yang_extension.sh +++ b/test/test_yang_extension.sh @@ -102,13 +102,13 @@ fi # The main example implements ex:e4 new "Add extension foo (not implemented)" -expecteof "$clixon_netconf -qf $cfg -D $DBG" 0 'a string]]>]]>' '^applicationunknown-elementfooerror' +expecteof "$clixon_netconf -qf $cfg -D $DBG" 0 "a string]]>]]>" "^applicationunknown-elementfooerror" new "Add extension bar (is implemented)" -expecteof "$clixon_netconf -qf $cfg -D $DBG" 0 'a string]]>]]>' '^]]>]]>' +expecteof "$clixon_netconf -qf $cfg -D $DBG" 0 "a string]]>]]>" "^]]>]]>" new "netconf get config" -expecteof "$clixon_netconf -qf $cfg -D $DBG" 0 "]]>]]>" '^a string]]>]]>$' +expecteof "$clixon_netconf -qf $cfg -D $DBG" 0 "]]>]]>" "^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 756b08e2..2d3ec4ae 100755 --- a/test/test_yang_load.sh +++ b/test/test_yang_load.sh @@ -88,13 +88,13 @@ if [ $BE -ne 0 ]; then fi new "1. Set newex" -expecteof "$clixon_netconf -qf $cfg" 0 'str]]>]]>' '^]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "str]]>]]>" "^]]>]]>$" new "Set oldex should fail (since oldex is in old revision and only the new is loaded)" -expecteof "$clixon_netconf -qf $cfg" 0 'str]]>]]>' '^applicationunknown-elementoldexerrorFailed to find YANG spec of XML node: oldex with parent: config in namespace: urn:example:clixon]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "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 'str]]>]]>' '^applicationunknown-elementothererrorFailed to find YANG spec of XML node: other with parent: config in namespace: urn:example:clixon2]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "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" @@ -136,13 +136,13 @@ if [ $BE -ne 0 ]; then fi new "Set oldex" -expecteof "$clixon_netconf -qf $cfg" 0 'str]]>]]>' '^]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "str]]>]]>" "^]]>]]>$" new "Set newex should fail" -expecteof "$clixon_netconf -qf $cfg" 0 'str]]>]]>' '^applicationunknown-elementnewexerrorFailed to find YANG spec of XML node: newex with parent: config in namespace: urn:example:clixon]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "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 'str]]>]]>' '^applicationunknown-elementothererrorFailed to find YANG spec of XML node: other with parent: config in namespace: urn:example:clixon2]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "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" @@ -180,13 +180,13 @@ if [ $BE -ne 0 ]; then fi new "Set newex" -expecteof "$clixon_netconf -qf $cfg" 0 'str]]>]]>' '^]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "str]]>]]>" "^]]>]]>$" new "Set oldex should fail" -expecteof "$clixon_netconf -qf $cfg" 0 'str]]>]]>' '^applicationunknown-elementoldexerrorFailed to find YANG spec of XML node: oldex with parent: config in namespace: urn:example:clixon]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "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 'str]]>]]>' '^applicationunknown-elementothererrorFailed to find YANG spec of XML node: other with parent: config in namespace: urn:example:clixon2]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "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" @@ -224,13 +224,13 @@ if [ $BE -ne 0 ]; then fi new "Set oldex" -expecteof "$clixon_netconf -qf $cfg" 0 'str]]>]]>' '^]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "str]]>]]>" "^]]>]]>$" new "Set newex should fail" -expecteof "$clixon_netconf -qf $cfg" 0 'str]]>]]>' '^applicationunknown-elementnewexerrorFailed to find YANG spec of XML node: newex with parent: config in namespace: urn:example:clixon]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "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 'str]]>]]>' '^applicationunknown-elementothererrorFailed to find YANG spec of XML node: other with parent: config in namespace: urn:example:clixon2]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "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" @@ -268,13 +268,13 @@ if [ $BE -ne 0 ]; then fi new "Set newex" -expecteof "$clixon_netconf -qf $cfg" 0 'str]]>]]>' '^]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "str]]>]]>" "^]]>]]>$" new "Set oldex should fail" -expecteof "$clixon_netconf -qf $cfg" 0 'str]]>]]>' '^applicationunknown-elementoldexerrorFailed to find YANG spec of XML node: oldex with parent: config in namespace: urn:example:clixon]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "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 'str]]>]]>' '^]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "str]]>]]>" "^]]>]]>$" if [ $BE -ne 0 ]; then new "Kill backend" @@ -313,13 +313,13 @@ if [ $BE -ne 0 ]; then wait_backend fi new "Set oldex" -expecteof "$clixon_netconf -qf $cfg" 0 'str]]>]]>' '^]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "str]]>]]>" "^]]>]]>$" new "Set newex should fail" -expecteof "$clixon_netconf -qf $cfg" 0 'str]]>]]>' '^applicationunknown-elementnewexerrorFailed to find YANG spec of XML node: newex with parent: config in namespace: urn:example:clixon]]>]]>' +expecteof "$clixon_netconf -qf $cfg" 0 "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 'str]]>]]>' '^]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "str]]>]]>" "^]]>]]>$" if [ $BE -ne 0 ]; then new "Kill backend" @@ -359,13 +359,13 @@ if [ $BE -ne 0 ]; then fi new "Set oldex" -expecteof "$clixon_netconf -qf $cfg" 0 'str]]>]]>' '^]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "str]]>]]>" "^]]>]]>$" new "Set newex should fail" -expecteof "$clixon_netconf -qf $cfg" 0 'str]]>]]>' '^applicationunknown-elementnewexerrorFailed to find YANG spec of XML node: newex with parent: config in namespace: urn:example:clixon]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "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 'str]]>]]>' '^]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "str]]>]]>" "^]]>]]>$" if [ $BE -ne 0 ]; then new "Kill backend" @@ -405,13 +405,13 @@ if [ $BE -ne 0 ]; then fi new "Set oldex" -expecteof "$clixon_netconf -qf $cfg" 0 'str]]>]]>' '^]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "str]]>]]>" "^]]>]]>$" new "Set newex should fail" -expecteof "$clixon_netconf -qf $cfg" 0 'str]]>]]>' '^applicationunknown-elementnewexerrorFailed to find YANG spec of XML node: newex with parent: config in namespace: urn:example:clixon]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "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 'str]]>]]>' '^applicationunknown-elementothererrorFailed to find YANG spec of XML node: other with parent: config in namespace: urn:example:clixon2]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "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 e2e33326..0f16a66e 100755 --- a/test/test_yang_namespace.sh +++ b/test/test_yang_namespace.sh @@ -30,7 +30,6 @@ cat < $cfg EOF - cat < $fyang1 module example1{ yang-version 1.1; @@ -90,19 +89,19 @@ if [ $RC -ne 0 ]; then fi new "netconf set x in example1" -expecteof "$clixon_netconf -qf $cfg" 0 '42]]>]]>' '^]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "42]]>]]>" "^]]>]]>$" new "netconf get config example1" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" '^42]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^42]]>]]>$" new "netconf set x in example2" -expecteof "$clixon_netconf -qf $cfg" 0 '99]]>]]>' '^]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "99]]>]]>" "^]]>]]>$" new "netconf get config example1 and example2" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" '^4299]]>]]>$' +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^4299]]>]]>$" new "netconf discard-changes" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" 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/1.1 201 Created" diff --git a/yang/clixon/clixon-config@2020-08-17.yang b/yang/clixon/clixon-config@2020-08-17.yang index 18a1b935..892eea70 100644 --- a/yang/clixon/clixon-config@2020-08-17.yang +++ b/yang/clixon/clixon-config@2020-08-17.yang @@ -45,7 +45,8 @@ module clixon-config { revision 2020-08-17 { description "Added: CLICON_RESTCONF_IPV4_ADDR, CLICON_RESTCONF_IPV6_ADDR, - CLICON_RESTCONF_HTTP_PORT, CLICON_RESTCONF_HTTPS_PORT"; + CLICON_RESTCONF_HTTP_PORT, CLICON_RESTCONF_HTTPS_PORT + CLICON_NAMESPACE_NETCONF_DEFAULT"; } revision 2020-06-17 { description @@ -835,5 +836,17 @@ module clixon-config { data to store before dropping. 0 means no retention"; } + leaf CLICON_NAMESPACE_NETCONF_DEFAULT { + type boolean; + default false; + description + "Undefine if you want to ensure strict namespace assignment on all netconf + and XML statements according to the standard RFC 6241. + If defined, top-level rpc calls need not have namespaces (eg using xmlns=) + since the default NETCONF namespace will be assumed. (This is not standard). + See rfc6241 3.1: urn:ietf:params:xml:ns:netconf:base:1.0."; + + } } + }