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.
This commit is contained in:
Olof hagsand 2020-11-18 13:51:15 +01:00
parent daaf3f17df
commit 9016dde319
41 changed files with 218 additions and 134 deletions

View file

@ -601,7 +601,7 @@ main(int argc,
extraxml_file = optarg; extraxml_file = optarg;
break; break;
case 'U': /* config user (for socket and drop privileges) */ 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; goto done;
if (clicon_option_add(h, "CLICON_BACKEND_PRIVILEGES", "drop_permanent") < 0) if (clicon_option_add(h, "CLICON_BACKEND_PRIVILEGES", "drop_permanent") < 0)
goto done; goto done;

View file

@ -551,8 +551,6 @@ main(int argc,
goto done; goto done;
break; break;
case 'U': /* Clixon 'pseudo' user */ case 'U': /* Clixon 'pseudo' user */
if (!strlen(optarg))
usage(h, argv[0]);
if (clicon_username_set(h, optarg) < 0) if (clicon_username_set(h, optarg) < 0)
goto done; goto done;
break; break;

View file

@ -56,6 +56,7 @@
#include <time.h> #include <time.h>
#include <limits.h> #include <limits.h>
#include <signal.h> #include <signal.h>
#include <pwd.h>
#include <sys/time.h> #include <sys/time.h>
#include <sys/wait.h> #include <sys/wait.h>
#include <assert.h> #include <assert.h>
@ -1102,6 +1103,7 @@ restconf_config_backend(clicon_handle h,
cxobj *xconfig = NULL; cxobj *xconfig = NULL;
cxobj *xerr = NULL; cxobj *xerr = NULL;
uint32_t id = 0; /* Session id, to poll backend up */ uint32_t id = 0; /* Session id, to poll backend up */
struct passwd *pw;
/* Set default namespace according to CLICON_NAMESPACE_NETCONF_DEFAULT */ /* Set default namespace according to CLICON_NAMESPACE_NETCONF_DEFAULT */
xml_nsctx_namespace_netconf_default(h); 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) if ((nsc = xml_nsctx_init(NULL, "https://clicon.org/restconf")) == NULL)
goto done; 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; goto done;
if ((xerr = xpath_first(xconfig, NULL, "/rpc-error")) != NULL){ if ((xerr = xpath_first(xconfig, NULL, "/rpc-error")) != NULL){
clixon_netconf_error(xerr, "Get backend restconf config", NULL); clixon_netconf_error(xerr, "Get backend restconf config", NULL);

View file

@ -303,11 +303,11 @@ inserts in as a proper yang statement in the example module.
## Systemd ## 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 ## 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. as a docker container.
## Plugins ## Plugins

View file

@ -17,6 +17,7 @@
<CLICON_CLI_LINESCROLLING>0</CLICON_CLI_LINESCROLLING> <CLICON_CLI_LINESCROLLING>0</CLICON_CLI_LINESCROLLING>
<CLICON_STARTUP_MODE>init</CLICON_STARTUP_MODE> <CLICON_STARTUP_MODE>init</CLICON_STARTUP_MODE>
<CLICON_NACM_MODE>disabled</CLICON_NACM_MODE> <CLICON_NACM_MODE>disabled</CLICON_NACM_MODE>
<CLICON_STREAM_DISCOVERY_RFC5277>true</CLICON_STREAM_DISCOVERY_RFC5277>
<CLICON_MODULE_LIBRARY_RFC7895>false</CLICON_MODULE_LIBRARY_RFC7895> <CLICON_MODULE_LIBRARY_RFC7895>false</CLICON_MODULE_LIBRARY_RFC7895>
<CLICON_RESTCONF_IPV4_ADDR>127.0.0.1</CLICON_RESTCONF_IPV4_ADDR> <CLICON_RESTCONF_IPV4_ADDR>127.0.0.1</CLICON_RESTCONF_IPV4_ADDR>
<CLICON_RESTCONF_IPV6_ADDR>::1</CLICON_RESTCONF_IPV6_ADDR> <CLICON_RESTCONF_IPV6_ADDR>::1</CLICON_RESTCONF_IPV6_ADDR>

View file

@ -9,6 +9,7 @@ NGROUPS=$(cat <<EOF
<groups> <groups>
<group> <group>
<name>admin</name> <name>admin</name>
<user-name>root</user-name>
<user-name>admin</user-name> <user-name>admin</user-name>
<user-name>andy</user-name> <user-name>andy</user-name>
<user-name>$USER</user-name> <user-name>$USER</user-name>

View file

@ -1,18 +0,0 @@
#!/usr/bin/env bash
# Create restconf backend config with a single socket
# ipv4 no-ssl
RESTCONFIG=$(cat <<EOF
<restconf xmlns="https://clicon.org/restconf">
<ssl-enable>false</ssl-enable>
<auth-type>password</auth-type>
<socket><namespace>default</namespace><address>0.0.0.0</address><port>80</port><ssl>false</ssl></socket>
</restconf>
EOF
)
new "netconf edit config"
expecteof "$clixon_netconf -qf $cfg" 0 "<rpc $DEFAULTNS><edit-config><target><candidate/></target><config>$RESTCONFIG</config></edit-config></rpc>]]>]]>" "^<rpc-reply $DEFAULTNS><ok/></rpc-reply>]]>]]>$"
new "netconf commit"
expecteof "$clixon_netconf -qf $cfg" 0 "<rpc $DEFAULTNS><commit/></rpc>]]>]]>" "^<rpc-reply $DEFAULTNS><ok/></rpc-reply>]]>]]>$"

26
test/restconfig.sh Normal file
View file

@ -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 <<EOF
<restconf xmlns="https://clicon.org/restconf">
<ssl-enable>false</ssl-enable>
<auth-type>password</auth-type>
<socket><namespace>default</namespace><address>0.0.0.0</address><port>80</port><ssl>false</ssl></socket>
</restconf>
EOF
)
# Install the config above on a backend
restconfigrun()
{
new "netconf edit config"
expecteof "$clixon_netconf -qf $cfg" 0 "<rpc $DEFAULTNS><edit-config><target><candidate/></target><config>$RESTCONFIG</config></edit-config></rpc>]]>]]>" "^<rpc-reply $DEFAULTNS><ok/></rpc-reply>]]>]]>$"
new "netconf commit"
expecteof "$clixon_netconf -qf $cfg" 0 "<rpc $DEFAULTNS><commit/></rpc>]]>]]>" "^<rpc-reply $DEFAULTNS><ok/></rpc-reply>]]>]]>$"
}

View file

@ -213,7 +213,7 @@ new "compile $cfile"
# -I /usr/local_include for eg freebsd # -I /usr/local_include for eg freebsd
expectpart "$($CC -g -Wall -rdynamic -fPIC -shared -I/usr/local/include $cfile -o $sofile)" 0 "" 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 if [ $BE -ne 0 ]; then
new "kill old backend" new "kill old backend"
@ -228,8 +228,11 @@ if [ $BE -ne 0 ]; then
new "waiting" new "waiting"
wait_backend wait_backend
# Load restconf config # Load restconf config for evhtp backend config
. ./restconf_config.sh if [ "${WITH_RESTCONF}" = "evhtp" ]; then
. ./restconfig.sh
restconfigrun
fi
if [ $RC -ne 0 ]; then if [ $RC -ne 0 ]; then
new "kill old restconf daemon" new "kill old restconf daemon"

View file

@ -167,8 +167,11 @@ fi
new "waiting" new "waiting"
wait_backend wait_backend
# Load restconf config # Load restconf config for evhtp backend config
. ./restconf_config.sh if [ "${WITH_RESTCONF}" = "evhtp" ]; then
. ./restconfig.sh
restconfigrun
fi
if [ $RC -ne 0 ]; then if [ $RC -ne 0 ]; then

View file

@ -119,8 +119,11 @@ fi
new "waiting" new "waiting"
wait_backend wait_backend
# Load restconf config # Load restconf config for evhtp backend config
. ./restconf_config.sh if [ "${WITH_RESTCONF}" = "evhtp" ]; then
. ./restconfig.sh
restconfigrun
fi
if [ $RC -ne 0 ]; then if [ $RC -ne 0 ]; then
new "kill old restconf daemon" new "kill old restconf daemon"

View file

@ -154,8 +154,11 @@ fi
new "waiting" new "waiting"
wait_backend wait_backend
# Load restconf config # Load restconf config for evhtp backend config
. ./restconf_config.sh if [ "${WITH_RESTCONF}" = "evhtp" ]; then
. ./restconfig.sh
restconfigrun
fi
if [ $RC -ne 0 ]; then if [ $RC -ne 0 ]; then
new "kill old restconf daemon" new "kill old restconf daemon"

View file

@ -132,7 +132,7 @@ if [ $RC -ne 0 ]; then
stop_restconf_pre stop_restconf_pre
new "start restconf daemon (-a is enable basic authentication)" 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"
wait_restconf wait_restconf

View file

@ -144,7 +144,7 @@ EOF
# First push in nacm rules via regular means # First push in nacm rules via regular means
new "auth set authentication config" new "auth set authentication config"
expecteof "$clixon_netconf -qf $cfg" 0 "<rpc $DEFAULTNS><edit-config><target><candidate/></target><config>$RULES</config></edit-config></rpc>]]>]]>" "^<rpc-reply $DEFAULTNS><ok/></rpc-reply>]]>]]>$" expecteof "$clixon_netconf -qf $cfg" 0 "<rpc $DEFAULTNS><edit-config><target><candidate/></target><config>$RULES</config></edit-config></rpc>]]>]]>" "^<rpc-reply $DEFAULTNS><ok/></rpc-reply>]]>]]>$"
new "enable nacm" new "enable nacm"
expecteof "$clixon_netconf -qf $cfg" 0 "<rpc $DEFAULTNS><edit-config><target><candidate/></target><config><nacm xmlns=\"urn:ietf:params:xml:ns:yang:ietf-netconf-acm\"><enable-nacm>true</enable-nacm></nacm></config></edit-config></rpc>]]>]]>" "^<rpc-reply $DEFAULTNS><ok/></rpc-reply>]]>]]>$" expecteof "$clixon_netconf -qf $cfg" 0 "<rpc $DEFAULTNS><edit-config><target><candidate/></target><config><nacm xmlns=\"urn:ietf:params:xml:ns:yang:ietf-netconf-acm\"><enable-nacm>true</enable-nacm></nacm></config></edit-config></rpc>]]>]]>" "^<rpc-reply $DEFAULTNS><ok/></rpc-reply>]]>]]>$"

View file

@ -227,6 +227,22 @@ fi
new "waiting" new "waiting"
wait_backend wait_backend
new "auth set authentication config"
expecteof "$clixon_netconf -qf $cfg" 0 "<rpc $DEFAULTNS><edit-config><target><candidate/></target><config>$RULES</config></edit-config></rpc>]]>]]>" "^<rpc-reply $DEFAULTNS><ok/></rpc-reply>]]>]]>$"
new "set app config"
expecteof "$clixon_netconf -qf $cfg" 0 "<rpc $DEFAULTNS><edit-config><target><candidate/></target><config>$CONFIG</config></edit-config></rpc>]]>]]>" "^<rpc-reply $DEFAULTNS><ok/></rpc-reply>]]>]]>$"
new "commit it"
expecteof "$clixon_netconf -qf $cfg" 0 "<rpc $DEFAULTNS><commit/></rpc>]]>]]>" "^<rpc-reply $DEFAULTNS><ok/></rpc-reply>]]>]]>$"
# 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 if [ $RC -ne 0 ]; then
new "kill old restconf daemon" new "kill old restconf daemon"
stop_restconf_pre stop_restconf_pre
@ -238,15 +254,6 @@ if [ $RC -ne 0 ]; then
wait_restconf wait_restconf
fi fi
new "auth set authentication config"
expecteof "$clixon_netconf -qf $cfg" 0 "<rpc $DEFAULTNS><edit-config><target><candidate/></target><config>$RULES</config></edit-config></rpc>]]>]]>" "^<rpc-reply $DEFAULTNS><ok/></rpc-reply>]]>]]>$"
new "set app config"
expecteof "$clixon_netconf -qf $cfg" 0 "<rpc $DEFAULTNS><edit-config><target><candidate/></target><config>$CONFIG</config></edit-config></rpc>]]>]]>" "^<rpc-reply $DEFAULTNS><ok/></rpc-reply>]]>]]>$"
new "commit it"
expecteof "$clixon_netconf -qf $cfg" 0 "<rpc $DEFAULTNS><commit/></rpc>]]>]]>" "^<rpc-reply $DEFAULTNS><ok/></rpc-reply>]]>]]>$"
new "enable nacm" 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" 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"

View file

@ -26,13 +26,13 @@ cat <<EOF > $cfg
<CLICON_YANG_MAIN_FILE>$fyang</CLICON_YANG_MAIN_FILE> <CLICON_YANG_MAIN_FILE>$fyang</CLICON_YANG_MAIN_FILE>
<CLICON_FEATURE>ietf-netconf:startup</CLICON_FEATURE> <CLICON_FEATURE>ietf-netconf:startup</CLICON_FEATURE>
<CLICON_CLISPEC_DIR>/usr/local/lib/$APPNAME/clispec</CLICON_CLISPEC_DIR> <CLICON_CLISPEC_DIR>/usr/local/lib/$APPNAME/clispec</CLICON_CLISPEC_DIR>
<CLICON_RESTCONF_DIR>/usr/local/lib/$APPNAME/restconf</CLICON_RESTCONF_DIR>
<CLICON_CLI_DIR>/usr/local/lib/$APPNAME/cli</CLICON_CLI_DIR> <CLICON_CLI_DIR>/usr/local/lib/$APPNAME/cli</CLICON_CLI_DIR>
<CLICON_CLI_MODE>$APPNAME</CLICON_CLI_MODE> <CLICON_CLI_MODE>$APPNAME</CLICON_CLI_MODE>
<CLICON_SOCK>/usr/local/var/$APPNAME/$APPNAME.sock</CLICON_SOCK> <CLICON_SOCK>/usr/local/var/$APPNAME/$APPNAME.sock</CLICON_SOCK>
<CLICON_BACKEND_DIR>/usr/local/lib/$APPNAME/backend</CLICON_BACKEND_DIR> <CLICON_BACKEND_DIR>/usr/local/lib/$APPNAME/backend</CLICON_BACKEND_DIR>
<CLICON_BACKEND_PIDFILE>/usr/local/var/$APPNAME/$APPNAME.pidfile</CLICON_BACKEND_PIDFILE> <CLICON_BACKEND_PIDFILE>/usr/local/var/$APPNAME/$APPNAME.pidfile</CLICON_BACKEND_PIDFILE>
<CLICON_XMLDB_DIR>$dir</CLICON_XMLDB_DIR> <CLICON_XMLDB_DIR>$dir</CLICON_XMLDB_DIR>
<CLICON_RESTCONF_DIR>/usr/local/lib/$APPNAME/restconf</CLICON_RESTCONF_DIR>
<CLICON_RESTCONF_PRETTY>false</CLICON_RESTCONF_PRETTY> <CLICON_RESTCONF_PRETTY>false</CLICON_RESTCONF_PRETTY>
<CLICON_NACM_MODE>internal</CLICON_NACM_MODE> <CLICON_NACM_MODE>internal</CLICON_NACM_MODE>
<CLICON_NACM_CREDENTIALS>none</CLICON_NACM_CREDENTIALS> <CLICON_NACM_CREDENTIALS>none</CLICON_NACM_CREDENTIALS>
@ -106,7 +106,7 @@ if [ $RC -ne 0 ]; then
stop_restconf_pre stop_restconf_pre
new "start restconf daemon (-a is enable basic authentication)" 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"
wait_restconf wait_restconf

View file

@ -232,6 +232,23 @@ fi
new "waiting" new "waiting"
wait_backend wait_backend
new "auth set authentication config"
expecteof "$clixon_netconf -qf $cfg" 0 "<rpc $DEFAULTNS><edit-config><target><candidate/></target><config>$RULES</config></edit-config></rpc>]]>]]>" "^<rpc-reply $DEFAULTNS><ok/></rpc-reply>]]>]]>$"
new "set app config"
expecteof "$clixon_netconf -qf $cfg" 0 "<rpc $DEFAULTNS><edit-config><target><candidate/></target><config>$CONFIG</config></edit-config></rpc>]]>]]>" "^<rpc-reply $DEFAULTNS><ok/></rpc-reply>]]>]]>$"
new "commit it"
expecteof "$clixon_netconf -qf $cfg" 0 "<rpc $DEFAULTNS><commit/></rpc>]]>]]>" "^<rpc-reply $DEFAULTNS><ok/></rpc-reply>]]>]]>$"
# 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 if [ $RC -ne 0 ]; then
new "kill old restconf daemon" new "kill old restconf daemon"
stop_restconf_pre stop_restconf_pre
@ -243,15 +260,6 @@ if [ $RC -ne 0 ]; then
wait_restconf wait_restconf
fi fi
new "auth set authentication config"
expecteof "$clixon_netconf -qf $cfg" 0 "<rpc $DEFAULTNS><edit-config><target><candidate/></target><config>$RULES</config></edit-config></rpc>]]>]]>" "^<rpc-reply $DEFAULTNS><ok/></rpc-reply>]]>]]>$"
new "set app config"
expecteof "$clixon_netconf -qf $cfg" 0 "<rpc $DEFAULTNS><edit-config><target><candidate/></target><config>$CONFIG</config></edit-config></rpc>]]>]]>" "^<rpc-reply $DEFAULTNS><ok/></rpc-reply>]]>]]>$"
new "commit it"
expecteof "$clixon_netconf -qf $cfg" 0 "<rpc $DEFAULTNS><commit/></rpc>]]>]]>" "^<rpc-reply $DEFAULTNS><ok/></rpc-reply>]]>]]>$"
new "enable nacm" 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" 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"

View file

@ -228,6 +228,22 @@ fi
new "waiting" new "waiting"
wait_backend wait_backend
new "auth set authentication config"
expecteof "$clixon_netconf -qf $cfg" 0 "<rpc $DEFAULTNS><edit-config><target><candidate/></target><config>$RULES</config></edit-config></rpc>]]>]]>" "^<rpc-reply $DEFAULTNS><ok/></rpc-reply>]]>]]>$"
new "set app config"
expecteof "$clixon_netconf -qf $cfg" 0 "<rpc $DEFAULTNS><edit-config><target><candidate/></target><config>$CONFIG</config></edit-config></rpc>]]>]]>" "^<rpc-reply $DEFAULTNS><ok/></rpc-reply>]]>]]>$"
new "commit it"
expecteof "$clixon_netconf -qf $cfg" 0 "<rpc $DEFAULTNS><commit/></rpc>]]>]]>" "^<rpc-reply $DEFAULTNS><ok/></rpc-reply>]]>]]>$"
# 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 if [ $RC -ne 0 ]; then
new "kill old restconf daemon" new "kill old restconf daemon"
stop_restconf_pre stop_restconf_pre
@ -239,15 +255,6 @@ if [ $RC -ne 0 ]; then
wait_restconf wait_restconf
fi fi
new "auth set authentication config"
expecteof "$clixon_netconf -qf $cfg" 0 "<rpc $DEFAULTNS><edit-config><target><candidate/></target><config>$RULES</config></edit-config></rpc>]]>]]>" "^<rpc-reply $DEFAULTNS><ok/></rpc-reply>]]>]]>$"
new "set app config"
expecteof "$clixon_netconf -qf $cfg" 0 "<rpc $DEFAULTNS><edit-config><target><candidate/></target><config>$CONFIG</config></edit-config></rpc>]]>]]>" "^<rpc-reply $DEFAULTNS><ok/></rpc-reply>]]>]]>$"
new "commit it"
expecteof "$clixon_netconf -qf $cfg" 0 "<rpc $DEFAULTNS><commit/></rpc>]]>]]>" "^<rpc-reply $DEFAULTNS><ok/></rpc-reply>]]>]]>$"
new "enable nacm" 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" 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"

View file

@ -110,8 +110,9 @@ EOF
new "kill old restconf daemon" new "kill old restconf daemon"
stop_restconf_pre stop_restconf_pre
# Cannot use CLICON_RESTCONF_CONFIG=true because of bootstrap problem
new "start restconf daemon (-a is enable basic authentication)" 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"
wait_restconf wait_restconf

View file

@ -143,6 +143,12 @@ if [ $BE -ne 0 ]; then
start_backend -s init -f $cfg -- -s start_backend -s init -f $cfg -- -s
fi fi
# Load restconf config for evhtp backend config
if [ "${WITH_RESTCONF}" = "evhtp" ]; then
. ./restconfig.sh
restconfigrun
fi
new "waiting" new "waiting"
wait_backend 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"}}}' 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" 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" 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" 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" new "cli rpc as admin"
expectfn "$clixon_cli -1 -U andy -l o -f $cfg rpc ipv4" 0 '<x xmlns="urn:example:clixon">ipv4</x><y xmlns="urn:example:clixon">42</y>' expectfn "$clixon_cli -1 -U andy -l o -f $cfg rpc ipv4" 0 '<x xmlns="urn:example:clixon">ipv4</x><y xmlns="urn:example:clixon">42</y>'

View file

@ -129,6 +129,18 @@ fi
new "waiting" new "waiting"
wait_backend wait_backend
new "auth set authentication config"
expecteof "$clixon_netconf -qf $cfg" 0 "<rpc $DEFAULTNS><edit-config><target><candidate/></target><config>$RULES</config></edit-config></rpc>]]>]]>" "^<rpc-reply $DEFAULTNS><ok/></rpc-reply>]]>]]>$"
new "commit it"
expecteof "$clixon_netconf -qf $cfg" 0 "<rpc $DEFAULTNS><commit/></rpc>]]>]]>" "^<rpc-reply $DEFAULTNS><ok/></rpc-reply>]]>]]>$"
# Load restconf config for evhtp backend config
if [ "${WITH_RESTCONF}" = "evhtp" ]; then
. ./restconfig.sh
restconfigrun
fi
if [ $RC -ne 0 ]; then if [ $RC -ne 0 ]; then
new "kill old restconf daemon" new "kill old restconf daemon"
stop_restconf_pre stop_restconf_pre
@ -140,12 +152,6 @@ if [ $RC -ne 0 ]; then
wait_restconf wait_restconf
fi fi
new "auth set authentication config"
expecteof "$clixon_netconf -qf $cfg" 0 "<rpc $DEFAULTNS><edit-config><target><candidate/></target><config>$RULES</config></edit-config></rpc>]]>]]>" "^<rpc-reply $DEFAULTNS><ok/></rpc-reply>]]>]]>$"
new "commit it"
expecteof "$clixon_netconf -qf $cfg" 0 "<rpc $DEFAULTNS><commit/></rpc>]]>]]>" "^<rpc-reply $DEFAULTNS><ok/></rpc-reply>]]>]]>$"
new "enable nacm" 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" 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"

View file

@ -153,7 +153,7 @@ if [ $RC -ne 0 ]; then
stop_restconf_pre stop_restconf_pre
new "start restconf daemon (-a is enable basic authentication)" 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"
wait_restconf wait_restconf

View file

@ -149,6 +149,19 @@ fi
new "waiting" new "waiting"
wait_backend wait_backend
new "auth set authentication config"
expecteof "$clixon_netconf -qf $cfg" 0 "<rpc $DEFAULTNS><edit-config><target><candidate/></target><config>$RULES</config></edit-config></rpc>]]>]]>" "^<rpc-reply $DEFAULTNS><ok/></rpc-reply>]]>]]>$"
new "commit it"
expecteof "$clixon_netconf -qf $cfg" 0 "<rpc $DEFAULTNS><commit/></rpc>]]>]]>" "^<rpc-reply $DEFAULTNS><ok/></rpc-reply>]]>]]>$"
# Load restconf config for evhtp backend config
if [ "${WITH_RESTCONF}" = "evhtp" ]; then
. ./restconfig.sh
restconfigrun
fi
if [ $RC -ne 0 ]; then if [ $RC -ne 0 ]; then
new "kill old restconf daemon" new "kill old restconf daemon"
@ -161,12 +174,6 @@ if [ $RC -ne 0 ]; then
wait_restconf wait_restconf
fi fi
new "auth set authentication config"
expecteof "$clixon_netconf -qf $cfg" 0 "<rpc $DEFAULTNS><edit-config><target><candidate/></target><config>$RULES</config></edit-config></rpc>]]>]]>" "^<rpc-reply $DEFAULTNS><ok/></rpc-reply>]]>]]>$"
new "commit it"
expecteof "$clixon_netconf -qf $cfg" 0 "<rpc $DEFAULTNS><commit/></rpc>]]>]]>" "^<rpc-reply $DEFAULTNS><ok/></rpc-reply>]]>]]>$"
new "enable nacm" 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" 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"

View file

@ -103,7 +103,7 @@ EOF
stop_restconf_pre stop_restconf_pre
new "start restconf daemon (-a is enable basic authentication)" 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"
wait_restconf wait_restconf

View file

@ -87,6 +87,12 @@ fi
new "waiting" new "waiting"
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 if [ $RC -ne 0 ]; then
new "kill old restconf daemon" new "kill old restconf daemon"
stop_restconf_pre stop_restconf_pre

View file

@ -108,6 +108,12 @@ fi
new "waiting" new "waiting"
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 if [ $RC -ne 0 ]; then
new "kill old restconf daemon" new "kill old restconf daemon"
stop_restconf_pre stop_restconf_pre

View file

@ -108,6 +108,12 @@ if [ $BE -ne 0 ]; then
wait_backend wait_backend
fi fi
# Load restconf config for evhtp backend config
if [ "${WITH_RESTCONF}" = "evhtp" ]; then
. ./restconfig.sh
restconfigrun
fi
if [ $RC -ne 0 ]; then if [ $RC -ne 0 ]; then
new "kill old restconf daemon" new "kill old restconf daemon"

View file

@ -84,6 +84,12 @@ fi
new "waiting" new "waiting"
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 if [ $RC -ne 0 ]; then
new "kill old restconf daemon" new "kill old restconf daemon"
stop_restconf_pre stop_restconf_pre

View file

@ -168,6 +168,12 @@ fi
new "waiting" new "waiting"
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 if [ $RC -ne 0 ]; then
new "kill old restconf daemon" new "kill old restconf daemon"
stop_restconf_pre stop_restconf_pre

View file

@ -77,6 +77,12 @@ fi
new "waiting" new "waiting"
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 if [ $RC -ne 0 ]; then
new "kill old restconf daemon" new "kill old restconf daemon"
stop_restconf_pre stop_restconf_pre

View file

@ -80,6 +80,12 @@ fi
new "waiting" new "waiting"
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 if [ $RC -ne 0 ]; then
new "kill old restconf daemon" new "kill old restconf daemon"
stop_restconf_pre stop_restconf_pre

View file

@ -69,6 +69,7 @@ NACM0="<nacm xmlns=\"urn:ietf:params:xml:ns:yang:ietf-netconf-acm\">
</rule-list> </rule-list>
</nacm> </nacm>
" "
cat<<EOF > $startupdb cat<<EOF > $startupdb
<config> <config>
$NACM0 $NACM0
@ -115,9 +116,9 @@ if [ $RC -ne 0 ]; then
stop_restconf_pre stop_restconf_pre
new "start restconf daemon (-a is enable basic authentication)" 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 wait_restconf
fi fi
@ -172,7 +173,7 @@ if [ $RC -ne 0 ]; then
stop_restconf_pre stop_restconf_pre
new "start restconf daemon (-a is enable basic authentication)" 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"
wait_restconf wait_restconf

View file

@ -64,6 +64,12 @@ testrun(){
new "waiting" new "waiting"
wait_backend wait_backend
# Load restconf config for evhtp backend config
if [ "${WITH_RESTCONF}" = "evhtp" ]; then
. ./restconfig.sh
restconfigrun
fi
new "kill old restconf daemon" new "kill old restconf daemon"
stop_restconf_pre stop_restconf_pre

View file

@ -45,6 +45,12 @@ fi
new "waiting" new "waiting"
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 if [ $RC -ne 0 ]; then
new "kill old restconf daemon" new "kill old restconf daemon"
stop_restconf_pre stop_restconf_pre

View file

@ -161,6 +161,12 @@ fi
new "wait backend" new "wait backend"
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 if [ $RC -ne 0 ]; then
new "kill old restconf daemon" new "kill old restconf daemon"
stop_restconf_pre 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' 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" 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 if [ $RC -ne 0 ]; then
new "Kill restconf daemon" new "Kill restconf daemon"

View file

@ -258,25 +258,9 @@ fi
new "waiting" new "waiting"
wait_backend 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" new "Check running db content"
expecteof "$clixon_netconf -qf $cfg" 0 "<rpc $DEFAULTNS><get-config><source><running/></source></get-config></rpc>]]>]]>" "^<rpc-reply $DEFAULTNS><data>$XML</data></rpc-reply>]]>]]>$" expecteof "$clixon_netconf -qf $cfg" 0 "<rpc $DEFAULTNS><get-config><source><running/></source></get-config></rpc>]]>]]>" "^<rpc-reply $DEFAULTNS><data>$XML</data></rpc-reply>]]>]]>$"
if [ $RC -ne 0 ]; then
new "Kill restconf daemon"
stop_restconf
fi
if [ $BE -ne 0 ]; then if [ $BE -ne 0 ]; then
new "Kill backend" new "Kill backend"
# Check if premature kill # Check if premature kill

View file

@ -270,21 +270,9 @@ testrun(){
new "waiting" new "waiting"
wait_backend 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" new "Check running db content"
expecteof "$clixon_netconf -qf $cfg" 0 "<rpc $DEFAULTNS><get-config><source><running/></source></get-config></rpc>]]>]]>" "^<rpc-reply $DEFAULTNS><data>$runxml</data></rpc-reply>]]>]]>$" expecteof "$clixon_netconf -qf $cfg" 0 "<rpc $DEFAULTNS><get-config><source><running/></source></get-config></rpc>]]>]]>" "^<rpc-reply $DEFAULTNS><data>$runxml</data></rpc-reply>]]>]]>$"
new "Kill restconf daemon"
stop_restconf
if [ $BE -ne 0 ]; then if [ $BE -ne 0 ]; then
new "Kill backend" new "Kill backend"
# Check if premature kill # Check if premature kill

View file

@ -116,17 +116,6 @@ fi
new "waiting" new "waiting"
wait_backend 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" new "Check running db content is failsafe"
expecteof "$clixon_netconf -qf $cfg" 0 "<rpc $DEFAULTNS><get-config><source><running/></source></get-config></rpc>]]>]]>" "^<rpc-reply $DEFAULTNS><data>$SAMEXML</data></rpc-reply>]]>]]>$" expecteof "$clixon_netconf -qf $cfg" 0 "<rpc $DEFAULTNS><get-config><source><running/></source></get-config></rpc>]]>]]>" "^<rpc-reply $DEFAULTNS><data>$SAMEXML</data></rpc-reply>]]>]]>$"
@ -149,11 +138,6 @@ expecteof "$clixon_netconf -qf $cfg" 0 "<rpc $DEFAULTNS><commit/></rpc>]]>]]>" "
new "Check running db content is updated" new "Check running db content is updated"
expecteof "$clixon_netconf -qf $cfg" 0 "<rpc $DEFAULTNS><get-config><source><running/></source></get-config></rpc>]]>]]>" "^<rpc-reply $DEFAULTNS><data>$SAMEXML$NEWXML</data></rpc-reply>]]>]]>$" expecteof "$clixon_netconf -qf $cfg" 0 "<rpc $DEFAULTNS><get-config><source><running/></source></get-config></rpc>]]>]]>" "^<rpc-reply $DEFAULTNS><data>$SAMEXML$NEWXML</data></rpc-reply>]]>]]>$"
if [ $RC -ne 0 ]; then
new "Kill restconf daemon"
stop_restconf
fi
if [ $BE -ne 0 ]; then if [ $BE -ne 0 ]; then
new "Kill backend" new "Kill backend"
# Check if premature kill # Check if premature kill

View file

@ -175,18 +175,18 @@ EOF
new "waiting" new "waiting"
wait_backend wait_backend
fi fi
if [ $RC -ne 0 ]; then if [ $RC -ne 0 ]; then
new "kill old restconf daemon" new "kill old restconf daemon"
stop_restconf_pre stop_restconf_pre
new "start restconf daemon" new "start restconf daemon"
start_restconf -f $cfg start_restconf -f $cfg -o CLICON_RESTCONF_CONFIG=false
fi fi
new "wait restconf" new "wait restconf"
wait_restconf wait_restconf
if ! $startup; then # If not startup, add xml using netconf if ! $startup; then # If not startup, add xml using netconf
new "Put anydata" new "Put anydata"
expecteof "$clixon_netconf -qf $cfg -D $DBG" 0 "<rpc $DEFAULTNS><edit-config><target><candidate/></target><config>$XMLA</config></edit-config></rpc>]]>]]>" "<rpc-reply $DEFAULTNS><ok/></rpc-reply>]]>]]>" expecteof "$clixon_netconf -qf $cfg -D $DBG" 0 "<rpc $DEFAULTNS><edit-config><target><candidate/></target><config>$XMLA</config></edit-config></rpc>]]>]]>" "<rpc-reply $DEFAULTNS><ok/></rpc-reply>]]>]]>"

View file

@ -82,7 +82,7 @@ if [ $RC -ne 0 ]; then
stop_restconf_pre stop_restconf_pre
new "start restconf daemon" new "start restconf daemon"
start_restconf -f $cfg start_restconf -f $cfg -o CLICON_RESTCONF_CONFIG=false
new "waiting" new "waiting"
wait_restconf wait_restconf

View file

@ -440,7 +440,6 @@ module clixon-config {
} }
leaf CLICON_RESTCONF_IPV6_ADDR { leaf CLICON_RESTCONF_IPV6_ADDR {
type string; type string;
default "::";
description description
"RESTCONF IPv6 socket binding address. "RESTCONF IPv6 socket binding address.
Applies to native http by config option --with-restconf=evhtp. Applies to native http by config option --with-restconf=evhtp.