From 9016dde3197a6f29ca0a18ebed7088b22c959b55 Mon Sep 17 00:00:00 2001 From: Olof hagsand Date: Wed, 18 Nov 2020 13:51:15 +0100 Subject: [PATCH] Modify tests so they all work with evhtp and backend config, eg that CLICON_RESTCONF_CONFIG is default true. Note that some tests are forced to CLICON_RESTCONF_CONFIG is false due to test complexities. --- apps/backend/backend_main.c | 2 +- apps/cli/cli_main.c | 2 -- apps/restconf/restconf_main_evhtp.c | 8 ++++++- example/main/README.md | 4 ++-- example/main/example.xml | 1 + test/nacm.sh | 1 + test/restconf_config.sh | 18 ---------------- test/restconfig.sh | 26 +++++++++++++++++++++++ test/test_api.sh | 9 +++++--- test/test_augment.sh | 7 ++++-- test/test_choice.sh | 7 ++++-- test/test_identity.sh | 7 ++++-- test/test_nacm.sh | 2 +- test/test_nacm_credentials.sh | 2 +- test/test_nacm_datanode.sh | 25 ++++++++++++++-------- test/test_nacm_datanode_paths.sh | 4 ++-- test/test_nacm_datanode_read.sh | 26 +++++++++++++++-------- test/test_nacm_datanode_write.sh | 25 ++++++++++++++-------- test/test_nacm_default.sh | 3 ++- test/test_nacm_ext.sh | 12 ++++++++--- test/test_nacm_module_read.sh | 18 ++++++++++------ test/test_nacm_module_write.sh | 2 +- test/test_nacm_protocol.sh | 19 +++++++++++------ test/test_nacm_recovery.sh | 2 +- test/test_perf_restconf.sh | 6 ++++++ test/test_perf_state.sh | 6 ++++++ test/test_perf_state_only.sh | 6 ++++++ test/test_restconf2.sh | 6 ++++++ test/test_restconf_err.sh | 6 ++++++ test/test_restconf_jukebox.sh | 6 ++++++ test/test_restconf_listkey.sh | 6 ++++++ test/test_restconf_patch.sh | 7 +++--- test/test_restconf_startup.sh | 6 ++++++ test/test_rpc.sh | 6 ++++++ test/test_submodule.sh | 8 ++++++- test/test_upgrade_auto.sh | 16 -------------- test/test_upgrade_interfaces.sh | 12 ----------- test/test_upgrade_repair.sh | 16 -------------- test/test_yang_anydata.sh | 4 ++-- test/test_yang_namespace.sh | 2 +- yang/clixon/clixon-config@2020-11-03.yang | 1 - 41 files changed, 218 insertions(+), 134 deletions(-) delete mode 100644 test/restconf_config.sh create mode 100644 test/restconfig.sh diff --git a/apps/backend/backend_main.c b/apps/backend/backend_main.c index 1dec9a1e..e31c9ccd 100644 --- a/apps/backend/backend_main.c +++ b/apps/backend/backend_main.c @@ -601,7 +601,7 @@ main(int argc, extraxml_file = optarg; break; case 'U': /* config user (for socket and drop privileges) */ - if (clicon_option_add(h, "CLICON_USER", optarg) < 0) + if (clicon_username_set(h, optarg) < 0) goto done; if (clicon_option_add(h, "CLICON_BACKEND_PRIVILEGES", "drop_permanent") < 0) goto done; diff --git a/apps/cli/cli_main.c b/apps/cli/cli_main.c index 558e35db..a612c842 100644 --- a/apps/cli/cli_main.c +++ b/apps/cli/cli_main.c @@ -551,8 +551,6 @@ main(int argc, goto done; break; case 'U': /* Clixon 'pseudo' user */ - if (!strlen(optarg)) - usage(h, argv[0]); if (clicon_username_set(h, optarg) < 0) goto done; break; diff --git a/apps/restconf/restconf_main_evhtp.c b/apps/restconf/restconf_main_evhtp.c index 27077497..3aeef378 100644 --- a/apps/restconf/restconf_main_evhtp.c +++ b/apps/restconf/restconf_main_evhtp.c @@ -56,6 +56,7 @@ #include #include #include +#include #include #include #include @@ -1102,6 +1103,7 @@ restconf_config_backend(clicon_handle h, cxobj *xconfig = NULL; cxobj *xerr = NULL; uint32_t id = 0; /* Session id, to poll backend up */ + struct passwd *pw; /* Set default namespace according to CLICON_NAMESPACE_NETCONF_DEFAULT */ xml_nsctx_namespace_netconf_default(h); @@ -1205,7 +1207,11 @@ restconf_config_backend(clicon_handle h, } if ((nsc = xml_nsctx_init(NULL, "https://clicon.org/restconf")) == NULL) goto done; - if (clicon_rpc_get_config(h, NULL, "running", "/restconf", nsc, &xconfig) < 0) + if ((pw = getpwuid(getuid())) == NULL){ + clicon_err(OE_UNIX, errno, "getpwuid"); + goto done; + } + if (clicon_rpc_get_config(h, pw->pw_name, "running", "/restconf", nsc, &xconfig) < 0) goto done; if ((xerr = xpath_first(xconfig, NULL, "/rpc-error")) != NULL){ clixon_netconf_error(xerr, "Get backend restconf config", NULL); diff --git a/example/main/README.md b/example/main/README.md index 02218476..0d469884 100644 --- a/example/main/README.md +++ b/example/main/README.md @@ -303,11 +303,11 @@ inserts in as a proper yang statement in the example module. ## Systemd -Example systemd files for backend and restconf daemons are found under the systemd directory. Install them under /etc/systemd/system for example. +Example systemd files for backend and restconf daemons are found under the [systemd](systemd) directory. Install them under /etc/systemd/system for example. ## Docker -See [../../docker/system] for instructions on how to build this example +See [docker](../../docker/system) for instructions on how to build this example as a docker container. ## Plugins diff --git a/example/main/example.xml b/example/main/example.xml index 92748cf7..c5c59bbf 100644 --- a/example/main/example.xml +++ b/example/main/example.xml @@ -17,6 +17,7 @@ 0 init disabled + true false 127.0.0.1 ::1 diff --git a/test/nacm.sh b/test/nacm.sh index 1f7f943f..3952fba2 100755 --- a/test/nacm.sh +++ b/test/nacm.sh @@ -9,6 +9,7 @@ NGROUPS=$(cat < admin + root admin andy $USER diff --git a/test/restconf_config.sh b/test/restconf_config.sh deleted file mode 100644 index a0b85c8e..00000000 --- a/test/restconf_config.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/usr/bin/env bash -# Create restconf backend config with a single socket -# ipv4 no-ssl - -RESTCONFIG=$(cat < - false - password - default
0.0.0.0
80false
- -EOF -) - -new "netconf edit config" -expecteof "$clixon_netconf -qf $cfg" 0 "$RESTCONFIG]]>]]>" "^]]>]]>$" - -new "netconf commit" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" diff --git a/test/restconfig.sh b/test/restconfig.sh new file mode 100644 index 00000000..cf80f27e --- /dev/null +++ b/test/restconfig.sh @@ -0,0 +1,26 @@ +#!/usr/bin/env bash +# Create restconf backend config with a single socket +# ipv4 no-ssl +# The script defines a VARIABLE containing XML config +# This is either inserted into the startup db, or installed in the backend using the +# restconfigrun() function. +# The config relies on clixon-restconf.yang being loaded. + +RESTCONFIG=$(cat < + false + password + default
0.0.0.0
80false
+ +EOF +) + +# Install the config above on a backend +restconfigrun() +{ + new "netconf edit config" + expecteof "$clixon_netconf -qf $cfg" 0 "$RESTCONFIG]]>]]>" "^]]>]]>$" + + new "netconf commit" + expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" +} diff --git a/test/test_api.sh b/test/test_api.sh index c407f37b..8fcebfdb 100755 --- a/test/test_api.sh +++ b/test/test_api.sh @@ -213,7 +213,7 @@ new "compile $cfile" # -I /usr/local_include for eg freebsd expectpart "$($CC -g -Wall -rdynamic -fPIC -shared -I/usr/local/include $cfile -o $sofile)" 0 "" -new "test params: -s running -f $cfg" +new "test params: -s init -f $cfg" if [ $BE -ne 0 ]; then new "kill old backend" @@ -228,8 +228,11 @@ if [ $BE -ne 0 ]; then new "waiting" wait_backend -# Load restconf config -. ./restconf_config.sh +# Load restconf config for evhtp backend config +if [ "${WITH_RESTCONF}" = "evhtp" ]; then + . ./restconfig.sh + restconfigrun +fi if [ $RC -ne 0 ]; then new "kill old restconf daemon" diff --git a/test/test_augment.sh b/test/test_augment.sh index 09096472..2491fd68 100755 --- a/test/test_augment.sh +++ b/test/test_augment.sh @@ -167,8 +167,11 @@ fi new "waiting" wait_backend -# Load restconf config -. ./restconf_config.sh +# Load restconf config for evhtp backend config +if [ "${WITH_RESTCONF}" = "evhtp" ]; then + . ./restconfig.sh + restconfigrun +fi if [ $RC -ne 0 ]; then diff --git a/test/test_choice.sh b/test/test_choice.sh index 4bdf8b7e..19e98a3e 100755 --- a/test/test_choice.sh +++ b/test/test_choice.sh @@ -119,8 +119,11 @@ fi new "waiting" wait_backend -# Load restconf config -. ./restconf_config.sh +# Load restconf config for evhtp backend config +if [ "${WITH_RESTCONF}" = "evhtp" ]; then + . ./restconfig.sh + restconfigrun +fi if [ $RC -ne 0 ]; then new "kill old restconf daemon" diff --git a/test/test_identity.sh b/test/test_identity.sh index 3e44bc39..4921c287 100755 --- a/test/test_identity.sh +++ b/test/test_identity.sh @@ -154,8 +154,11 @@ fi new "waiting" wait_backend -# Load restconf config -. ./restconf_config.sh +# Load restconf config for evhtp backend config +if [ "${WITH_RESTCONF}" = "evhtp" ]; then + . ./restconfig.sh + restconfigrun +fi if [ $RC -ne 0 ]; then new "kill old restconf daemon" diff --git a/test/test_nacm.sh b/test/test_nacm.sh index e6307331..d2f40477 100755 --- a/test/test_nacm.sh +++ b/test/test_nacm.sh @@ -132,7 +132,7 @@ if [ $RC -ne 0 ]; then stop_restconf_pre new "start restconf daemon (-a is enable basic authentication)" - start_restconf -f $cfg -- -a + start_restconf -f $cfg -o CLICON_RESTCONF_CONFIG=false -- -a new "waiting" wait_restconf diff --git a/test/test_nacm_credentials.sh b/test/test_nacm_credentials.sh index 46af6330..88a8af73 100755 --- a/test/test_nacm_credentials.sh +++ b/test/test_nacm_credentials.sh @@ -144,7 +144,7 @@ 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]]>]]>" "^]]>]]>$" diff --git a/test/test_nacm_datanode.sh b/test/test_nacm_datanode.sh index 45c1d32c..1803813d 100755 --- a/test/test_nacm_datanode.sh +++ b/test/test_nacm_datanode.sh @@ -227,6 +227,22 @@ fi new "waiting" wait_backend +new "auth set authentication config" +expecteof "$clixon_netconf -qf $cfg" 0 "$RULES]]>]]>" "^]]>]]>$" + +new "set app config" +expecteof "$clixon_netconf -qf $cfg" 0 "$CONFIG]]>]]>" "^]]>]]>$" + +new "commit it" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" + +# Load restconf config for evhtp backend config +# NACM is disabled by RULES +if [ "${WITH_RESTCONF}" = "evhtp" ]; then + . ./restconfig.sh + restconfigrun +fi + if [ $RC -ne 0 ]; then new "kill old restconf daemon" stop_restconf_pre @@ -238,15 +254,6 @@ if [ $RC -ne 0 ]; then wait_restconf fi -new "auth set authentication config" -expecteof "$clixon_netconf -qf $cfg" 0 "$RULES]]>]]>" "^]]>]]>$" - -new "set app config" -expecteof "$clixon_netconf -qf $cfg" 0 "$CONFIG]]>]]>" "^]]>]]>$" - -new "commit it" -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_paths.sh b/test/test_nacm_datanode_paths.sh index 5520da82..e35f7429 100755 --- a/test/test_nacm_datanode_paths.sh +++ b/test/test_nacm_datanode_paths.sh @@ -26,13 +26,13 @@ cat < $cfg $fyang ietf-netconf:startup /usr/local/lib/$APPNAME/clispec - /usr/local/lib/$APPNAME/restconf /usr/local/lib/$APPNAME/cli $APPNAME /usr/local/var/$APPNAME/$APPNAME.sock /usr/local/lib/$APPNAME/backend /usr/local/var/$APPNAME/$APPNAME.pidfile $dir + /usr/local/lib/$APPNAME/restconf false internal none @@ -106,7 +106,7 @@ if [ $RC -ne 0 ]; then stop_restconf_pre new "start restconf daemon (-a is enable basic authentication)" - start_restconf -f $cfg -- -a + start_restconf -f $cfg -o CLICON_RESTCONF_CONFIG=false -- -a new "waiting" wait_restconf diff --git a/test/test_nacm_datanode_read.sh b/test/test_nacm_datanode_read.sh index bd494be0..d3a78bc4 100755 --- a/test/test_nacm_datanode_read.sh +++ b/test/test_nacm_datanode_read.sh @@ -232,6 +232,23 @@ fi new "waiting" wait_backend + +new "auth set authentication config" +expecteof "$clixon_netconf -qf $cfg" 0 "$RULES]]>]]>" "^]]>]]>$" + +new "set app config" +expecteof "$clixon_netconf -qf $cfg" 0 "$CONFIG]]>]]>" "^]]>]]>$" + +new "commit it" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" + +# Load restconf config for evhtp backend config +# Must be done before restconf started NACM is disabled +if [ "${WITH_RESTCONF}" = "evhtp" ]; then + . ./restconfig.sh + restconfigrun +fi + if [ $RC -ne 0 ]; then new "kill old restconf daemon" stop_restconf_pre @@ -243,15 +260,6 @@ if [ $RC -ne 0 ]; then wait_restconf fi -new "auth set authentication config" -expecteof "$clixon_netconf -qf $cfg" 0 "$RULES]]>]]>" "^]]>]]>$" - -new "set app config" -expecteof "$clixon_netconf -qf $cfg" 0 "$CONFIG]]>]]>" "^]]>]]>$" - -new "commit it" -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 19f53627..5e504c36 100755 --- a/test/test_nacm_datanode_write.sh +++ b/test/test_nacm_datanode_write.sh @@ -228,6 +228,22 @@ fi new "waiting" wait_backend +new "auth set authentication config" +expecteof "$clixon_netconf -qf $cfg" 0 "$RULES]]>]]>" "^]]>]]>$" + +new "set app config" +expecteof "$clixon_netconf -qf $cfg" 0 "$CONFIG]]>]]>" "^]]>]]>$" + +new "commit it" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" + +# Load restconf config for evhtp backend config +# Must be done before restconf but after first config +if [ "${WITH_RESTCONF}" = "evhtp" ]; then + . ./restconfig.sh + restconfigrun +fi + if [ $RC -ne 0 ]; then new "kill old restconf daemon" stop_restconf_pre @@ -239,15 +255,6 @@ if [ $RC -ne 0 ]; then wait_restconf fi -new "auth set authentication config" -expecteof "$clixon_netconf -qf $cfg" 0 "$RULES]]>]]>" "^]]>]]>$" - -new "set app config" -expecteof "$clixon_netconf -qf $cfg" 0 "$CONFIG]]>]]>" "^]]>]]>$" - -new "commit it" -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_default.sh b/test/test_nacm_default.sh index 650df4f5..91c4eb04 100755 --- a/test/test_nacm_default.sh +++ b/test/test_nacm_default.sh @@ -110,8 +110,9 @@ EOF new "kill old restconf daemon" stop_restconf_pre + # Cannot use CLICON_RESTCONF_CONFIG=true because of bootstrap problem new "start restconf daemon (-a is enable basic authentication)" - start_restconf -f $cfg -- -a + start_restconf -f $cfg -o CLICON_RESTCONF_CONFIG=false -- -a new "waiting" wait_restconf diff --git a/test/test_nacm_ext.sh b/test/test_nacm_ext.sh index 19c5a60c..9c2ab00b 100755 --- a/test/test_nacm_ext.sh +++ b/test/test_nacm_ext.sh @@ -143,6 +143,12 @@ if [ $BE -ne 0 ]; then start_backend -s init -f $cfg -- -s fi +# Load restconf config for evhtp backend config +if [ "${WITH_RESTCONF}" = "evhtp" ]; then + . ./restconfig.sh + restconfigrun +fi + new "waiting" wait_backend @@ -191,13 +197,13 @@ new "guest edit nacm" expectpart "$(curl -u guest:bar $CURLOPTS -X PUT -H "Content-Type: application/yang-data+json" -d '{"nacm-example:x": 3}' $RCPROTO://localhost/restconf/data/nacm-example:x)" 0 "HTTP/1.1 403 Forbidden" '{"ietf-restconf:errors":{"error":{"error-type":"application","error-tag":"access-denied","error-severity":"error","error-message":"access denied"}}}' new "cli show conf as admin" -expectfn "$clixon_cli -1 -U andy -l o -f $cfg show conf" 0 "^x 1;$" +expectpart "$($clixon_cli -1 -U andy -l o -f $cfg show conf)" 0 "x 1;" new "cli show conf as limited" -expectfn "$clixon_cli -1 -U wilma -l o -f $cfg show conf" 0 "^x 1;$" +expectpart "$($clixon_cli -1 -U wilma -l o -f $cfg show conf)" 0 "x 1;" new "cli show conf as guest" -expectfn "$clixon_cli -1 -U guest -l o -f $cfg show conf" 255 "application access-denied" +expectpart "$($clixon_cli -1 -U guest -l o -f $cfg show conf)" 255 "application access-denied" new "cli rpc as admin" expectfn "$clixon_cli -1 -U andy -l o -f $cfg rpc ipv4" 0 'ipv442' diff --git a/test/test_nacm_module_read.sh b/test/test_nacm_module_read.sh index 88a10c91..851b46e5 100755 --- a/test/test_nacm_module_read.sh +++ b/test/test_nacm_module_read.sh @@ -129,6 +129,18 @@ fi new "waiting" wait_backend +new "auth set authentication config" +expecteof "$clixon_netconf -qf $cfg" 0 "$RULES]]>]]>" "^]]>]]>$" + +new "commit it" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" + +# Load restconf config for evhtp backend config +if [ "${WITH_RESTCONF}" = "evhtp" ]; then + . ./restconfig.sh + restconfigrun +fi + if [ $RC -ne 0 ]; then new "kill old restconf daemon" stop_restconf_pre @@ -140,12 +152,6 @@ if [ $RC -ne 0 ]; then wait_restconf fi -new "auth set authentication config" -expecteof "$clixon_netconf -qf $cfg" 0 "$RULES]]>]]>" "^]]>]]>$" - -new "commit it" -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_write.sh b/test/test_nacm_module_write.sh index f9e65823..f39fb05a 100755 --- a/test/test_nacm_module_write.sh +++ b/test/test_nacm_module_write.sh @@ -153,7 +153,7 @@ if [ $RC -ne 0 ]; then stop_restconf_pre new "start restconf daemon (-a is enable basic authentication)" - start_restconf -f $cfg -- -a + start_restconf -f $cfg -o CLICON_RESTCONF_CONFIG=false -- -a new "waiting" wait_restconf diff --git a/test/test_nacm_protocol.sh b/test/test_nacm_protocol.sh index d4997e6c..3487a1d9 100755 --- a/test/test_nacm_protocol.sh +++ b/test/test_nacm_protocol.sh @@ -149,6 +149,19 @@ fi new "waiting" wait_backend + +new "auth set authentication config" +expecteof "$clixon_netconf -qf $cfg" 0 "$RULES]]>]]>" "^]]>]]>$" + +new "commit it" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" + +# Load restconf config for evhtp backend config +if [ "${WITH_RESTCONF}" = "evhtp" ]; then + . ./restconfig.sh + restconfigrun +fi + if [ $RC -ne 0 ]; then new "kill old restconf daemon" @@ -161,12 +174,6 @@ if [ $RC -ne 0 ]; then wait_restconf fi -new "auth set authentication config" -expecteof "$clixon_netconf -qf $cfg" 0 "$RULES]]>]]>" "^]]>]]>$" - -new "commit it" -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 bf6bfdf3..e3f2053d 100755 --- a/test/test_nacm_recovery.sh +++ b/test/test_nacm_recovery.sh @@ -103,7 +103,7 @@ EOF stop_restconf_pre new "start restconf daemon (-a is enable basic authentication)" - start_restconf -f $cfg -- -a + start_restconf -f $cfg -o CLICON_RESTCONF_CONFIG=false -- -a new "waiting" wait_restconf diff --git a/test/test_perf_restconf.sh b/test/test_perf_restconf.sh index e6d3c58c..97f19cc7 100755 --- a/test/test_perf_restconf.sh +++ b/test/test_perf_restconf.sh @@ -87,6 +87,12 @@ fi new "waiting" wait_backend +# Load restconf config for evhtp backend config +if [ "${WITH_RESTCONF}" = "evhtp" ]; then + . ./restconfig.sh + restconfigrun +fi + if [ $RC -ne 0 ]; then new "kill old restconf daemon" stop_restconf_pre diff --git a/test/test_perf_state.sh b/test/test_perf_state.sh index 6c93787b..1adb883c 100755 --- a/test/test_perf_state.sh +++ b/test/test_perf_state.sh @@ -108,6 +108,12 @@ fi new "waiting" wait_backend +# Load restconf config for evhtp backend config +if [ "${WITH_RESTCONF}" = "evhtp" ]; then + . ./restconfig.sh + restconfigrun +fi + if [ $RC -ne 0 ]; then new "kill old restconf daemon" stop_restconf_pre diff --git a/test/test_perf_state_only.sh b/test/test_perf_state_only.sh index 66ae3b18..19b4c302 100755 --- a/test/test_perf_state_only.sh +++ b/test/test_perf_state_only.sh @@ -108,6 +108,12 @@ if [ $BE -ne 0 ]; then wait_backend fi +# Load restconf config for evhtp backend config +if [ "${WITH_RESTCONF}" = "evhtp" ]; then + . ./restconfig.sh + restconfigrun +fi + if [ $RC -ne 0 ]; then new "kill old restconf daemon" diff --git a/test/test_restconf2.sh b/test/test_restconf2.sh index f8a563dc..5c1fc2c2 100755 --- a/test/test_restconf2.sh +++ b/test/test_restconf2.sh @@ -84,6 +84,12 @@ fi new "waiting" wait_backend +# Load restconf config for evhtp backend config +if [ "${WITH_RESTCONF}" = "evhtp" ]; then + . ./restconfig.sh + restconfigrun +fi + if [ $RC -ne 0 ]; then new "kill old restconf daemon" stop_restconf_pre diff --git a/test/test_restconf_err.sh b/test/test_restconf_err.sh index 4264a0d4..ee91afee 100755 --- a/test/test_restconf_err.sh +++ b/test/test_restconf_err.sh @@ -168,6 +168,12 @@ fi new "waiting" wait_backend +# Load restconf config for evhtp backend config +if [ "${WITH_RESTCONF}" = "evhtp" ]; then + . ./restconfig.sh + restconfigrun +fi + if [ $RC -ne 0 ]; then new "kill old restconf daemon" stop_restconf_pre diff --git a/test/test_restconf_jukebox.sh b/test/test_restconf_jukebox.sh index 5f9009ff..e24b864c 100755 --- a/test/test_restconf_jukebox.sh +++ b/test/test_restconf_jukebox.sh @@ -77,6 +77,12 @@ fi new "waiting" wait_backend +# Load restconf config for evhtp backend config +if [ "${WITH_RESTCONF}" = "evhtp" ]; then + . ./restconfig.sh + restconfigrun +fi + if [ $RC -ne 0 ]; then new "kill old restconf daemon" stop_restconf_pre diff --git a/test/test_restconf_listkey.sh b/test/test_restconf_listkey.sh index b8d8fcef..942d52fb 100755 --- a/test/test_restconf_listkey.sh +++ b/test/test_restconf_listkey.sh @@ -80,6 +80,12 @@ fi new "waiting" wait_backend +# Load restconf config for evhtp backend config +if [ "${WITH_RESTCONF}" = "evhtp" ]; then + . ./restconfig.sh + restconfigrun +fi + if [ $RC -ne 0 ]; then new "kill old restconf daemon" stop_restconf_pre diff --git a/test/test_restconf_patch.sh b/test/test_restconf_patch.sh index 7a69e514..9bbd6fb1 100755 --- a/test/test_restconf_patch.sh +++ b/test/test_restconf_patch.sh @@ -69,6 +69,7 @@ NACM0=" " + cat< $startupdb $NACM0 @@ -115,9 +116,9 @@ if [ $RC -ne 0 ]; then stop_restconf_pre new "start restconf daemon (-a is enable basic authentication)" - start_restconf -f $cfg -- -a + start_restconf -f $cfg -o CLICON_RESTCONF_CONFIG=false -- -a - new "waiting" + new "waiting restconf" wait_restconf fi @@ -172,7 +173,7 @@ if [ $RC -ne 0 ]; then stop_restconf_pre new "start restconf daemon (-a is enable basic authentication)" - start_restconf -f $cfg -- -a + start_restconf -f $cfg -o CLICON_RESTCONF_CONFIG=false -- -a new "waiting" wait_restconf diff --git a/test/test_restconf_startup.sh b/test/test_restconf_startup.sh index 7b45d1d5..8601be57 100755 --- a/test/test_restconf_startup.sh +++ b/test/test_restconf_startup.sh @@ -64,6 +64,12 @@ testrun(){ new "waiting" wait_backend + # Load restconf config for evhtp backend config + if [ "${WITH_RESTCONF}" = "evhtp" ]; then + . ./restconfig.sh + restconfigrun + fi + new "kill old restconf daemon" stop_restconf_pre diff --git a/test/test_rpc.sh b/test/test_rpc.sh index 7ccf6339..d6e20a90 100755 --- a/test/test_rpc.sh +++ b/test/test_rpc.sh @@ -45,6 +45,12 @@ fi new "waiting" wait_backend +# Load restconf config for evhtp backend config +if [ "${WITH_RESTCONF}" = "evhtp" ]; then + . ./restconfig.sh + restconfigrun +fi + if [ $RC -ne 0 ]; then new "kill old restconf daemon" stop_restconf_pre diff --git a/test/test_submodule.sh b/test/test_submodule.sh index b22c4848..09e15917 100755 --- a/test/test_submodule.sh +++ b/test/test_submodule.sh @@ -161,6 +161,12 @@ fi new "wait backend" wait_backend +# Load restconf config for evhtp backend config +if [ "${WITH_RESTCONF}" = "evhtp" ]; then + . ./restconfig.sh + restconfigrun +fi + if [ $RC -ne 0 ]; then new "kill old restconf daemon" stop_restconf_pre @@ -216,7 +222,7 @@ new "restconf edit sub2" expectpart "$(curl $CURLOPTS -X POST -H "Content-Type: application/yang-data+json" $RCPROTO://localhost/restconf/data -d '{"main:sub2":{"x":"foo","ext2":"foo"}}')" 0 'HTTP/1.1 201 Created' new "restconf check main/sub1/sub2 contents" -expectpart "$(curl $CURLOPTS -X GET $RCPROTO://localhost/restconf/data?content=config)" 0 'HTTP/1.1 200 OK' '{"data":{"main:main":{"ext":"foo","x":"foo"},"main:sub1":{"ext1":"foo","x":"foo"},"main:sub2":{"ext2":"foo","x":"foo"}}}' +expectpart "$(curl $CURLOPTS -X GET $RCPROTO://localhost/restconf/data?content=config)" 0 'HTTP/1.1 200 OK' '{"data":{"main:main":{"ext":"foo","x":"foo"},"main:sub1":{"ext1":"foo","x":"foo"},"main:sub2":{"ext2":"foo","x":"foo"}' if [ $RC -ne 0 ]; then new "Kill restconf daemon" diff --git a/test/test_upgrade_auto.sh b/test/test_upgrade_auto.sh index 1f46c0a6..a93266cd 100755 --- a/test/test_upgrade_auto.sh +++ b/test/test_upgrade_auto.sh @@ -258,25 +258,9 @@ fi new "waiting" wait_backend -if [ $RC -ne 0 ]; then - new "kill old restconf daemon" - stop_restconf_pre - - new "start restconf daemon" - start_restconf -f $cfg - - new "waiting" - wait_restconf -fi - new "Check running db content" expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^$XML]]>]]>$" -if [ $RC -ne 0 ]; then - new "Kill restconf daemon" - stop_restconf -fi - if [ $BE -ne 0 ]; then new "Kill backend" # Check if premature kill diff --git a/test/test_upgrade_interfaces.sh b/test/test_upgrade_interfaces.sh index d19ab181..d577dda9 100755 --- a/test/test_upgrade_interfaces.sh +++ b/test/test_upgrade_interfaces.sh @@ -270,21 +270,9 @@ testrun(){ new "waiting" wait_backend - new "kill old restconf daemon" - stop_restconf_pre - - new "start restconf daemon" - start_restconf -f $cfg - - new "waiting" - wait_restconf - new "Check running db content" expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^$runxml]]>]]>$" - new "Kill restconf daemon" - stop_restconf - if [ $BE -ne 0 ]; then new "Kill backend" # Check if premature kill diff --git a/test/test_upgrade_repair.sh b/test/test_upgrade_repair.sh index 02b8abc8..bb97ccbe 100755 --- a/test/test_upgrade_repair.sh +++ b/test/test_upgrade_repair.sh @@ -116,17 +116,6 @@ fi new "waiting" wait_backend -if [ $RC -ne 0 ]; then - new "kill old restconf daemon" - stop_restconf_pre - - new "start restconf daemon" - start_restconf -f $cfg - - new "waiting" - wait_restconf -fi - new "Check running db content is failsafe" expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^$SAMEXML]]>]]>$" @@ -149,11 +138,6 @@ expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" " new "Check running db content is updated" expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^$SAMEXML$NEWXML]]>]]>$" -if [ $RC -ne 0 ]; then - new "Kill restconf daemon" - stop_restconf -fi - if [ $BE -ne 0 ]; then new "Kill backend" # Check if premature kill diff --git a/test/test_yang_anydata.sh b/test/test_yang_anydata.sh index ba18261d..823bf761 100755 --- a/test/test_yang_anydata.sh +++ b/test/test_yang_anydata.sh @@ -175,18 +175,18 @@ EOF new "waiting" wait_backend fi + if [ $RC -ne 0 ]; then new "kill old restconf daemon" stop_restconf_pre new "start restconf daemon" - start_restconf -f $cfg + start_restconf -f $cfg -o CLICON_RESTCONF_CONFIG=false fi new "wait restconf" wait_restconf - if ! $startup; then # If not startup, add xml using netconf new "Put anydata" expecteof "$clixon_netconf -qf $cfg -D $DBG" 0 "$XMLA]]>]]>" "]]>]]>" diff --git a/test/test_yang_namespace.sh b/test/test_yang_namespace.sh index 0f16a66e..5b07c149 100755 --- a/test/test_yang_namespace.sh +++ b/test/test_yang_namespace.sh @@ -82,7 +82,7 @@ if [ $RC -ne 0 ]; then stop_restconf_pre new "start restconf daemon" - start_restconf -f $cfg + start_restconf -f $cfg -o CLICON_RESTCONF_CONFIG=false new "waiting" wait_restconf diff --git a/yang/clixon/clixon-config@2020-11-03.yang b/yang/clixon/clixon-config@2020-11-03.yang index dbc12fc4..fbdd86cd 100644 --- a/yang/clixon/clixon-config@2020-11-03.yang +++ b/yang/clixon/clixon-config@2020-11-03.yang @@ -440,7 +440,6 @@ module clixon-config { } leaf CLICON_RESTCONF_IPV6_ADDR { type string; - default "::"; description "RESTCONF IPv6 socket binding address. Applies to native http by config option --with-restconf=evhtp.