* Reworked evhtp restconf config to only use clixon-restconf.yang and marked local restconf options as obsolete
* Extended clicon-config with clixon-restconf for local config * Removed obsolete CLICON_TRANSACTION_MOD
This commit is contained in:
parent
3d10c3bfcb
commit
0b948248e4
42 changed files with 308 additions and 887 deletions
|
|
@ -99,15 +99,22 @@ For example, in FreeBSD, add:
|
|||
|
||||
## https
|
||||
|
||||
For fcgi/nginx you need to setup https in the nginx config file, independently of clixon.
|
||||
|
||||
If you use evhtp with `configure --with-restconf=evhtp`, you can prepend the tests with RCPROTO=https which will run all restconf tests with SSL https and server certs.
|
||||
|
||||
Ensure the server keys are in order, as follows.
|
||||
|
||||
If you already have server certs, ensure CLICON_SSL_SERVER_CERT and CLICON_SSL_SERVER_KEY points to them.
|
||||
If you already have server certs, ensure the RESTCONF variable in lib.sh points to them, by default the config is
|
||||
```
|
||||
<server-cert-path>/etc/ssl/certs/clixon-server-crt.pem</server-cert-path>
|
||||
<server-key-path>/etc/ssl/private/clixon-server-key.pem</server-key-path>
|
||||
<server-ca-cert-path>/etc/ssl/certs/clixon-ca-crt.pem</server-ca-cert-path>
|
||||
```
|
||||
|
||||
If you do not have them, generate self-signed certs, eg as follows:
|
||||
```
|
||||
openssl req -x509 -nodes -newkey rsa:4096 -keyout /etc/ssl/private/clixon-server-key.pem -out /etc/ssl/certs/clixon-server-crt.pem -days 365
|
||||
```
|
||||
|
||||
There are also client-cert tests, eg test_ssl*.sh
|
||||
There are also client-cert tests, eg `test_ssl_certs.sh`
|
||||
|
|
|
|||
18
test/lib.sh
18
test/lib.sh
|
|
@ -176,6 +176,15 @@ if [ ! -d $dir ]; then
|
|||
mkdir $dir
|
||||
fi
|
||||
|
||||
# Default restconf configuration: http IPv4
|
||||
# Can be placed in clixon-config
|
||||
# Note that https clause assumes there exists certs and keys in /etc/ssl,...
|
||||
if [ $RCPROTO = http ]; then
|
||||
RESTCONFIG="<restconf><auth-type>password</auth-type><socket><namespace>default</namespace><address>0.0.0.0</address><port>80</port><ssl>false</ssl></socket></restconf>"
|
||||
else
|
||||
RESTCONFIG="<restconf><auth-type>password</auth-type><server-cert-path>/etc/ssl/certs/clixon-server-crt.pem</server-cert-path><server-key-path>/etc/ssl/private/clixon-server-key.pem</server-key-path><server-ca-cert-path>/etc/ssl/certs/clixon-ca-crt.pem</server-ca-cert-path><socket><namespace>default</namespace><address>0.0.0.0</address><port>443</port><ssl>true</ssl></socket></restconf>"
|
||||
fi
|
||||
|
||||
# Some tests may set owner of testdir to something strange and quit, need
|
||||
# to reset to me
|
||||
if [ ! -G $dir ]; then
|
||||
|
|
@ -278,13 +287,8 @@ wait_backend(){
|
|||
# @see wait_restconf
|
||||
start_restconf(){
|
||||
# Start in background
|
||||
if [ $RCPROTO = https -a "${WITH_RESTCONF}" = "evhtp" ]; then
|
||||
EXTRA="-s" # server certs ONLY evhtp
|
||||
else
|
||||
EXTRA=
|
||||
fi
|
||||
echo "sudo -u $wwwstartuser -s $clixon_restconf $RCLOG -D $DBG $EXTRA $*"
|
||||
sudo -u $wwwstartuser -s $clixon_restconf $RCLOG -D $DBG $EXTRA $* &
|
||||
echo "sudo -u $wwwstartuser -s $clixon_restconf $RCLOG -D $DBG $*"
|
||||
sudo -u $wwwstartuser -s $clixon_restconf $RCLOG -D $DBG $* &
|
||||
if [ $? -ne 0 ]; then
|
||||
err
|
||||
fi
|
||||
|
|
|
|||
|
|
@ -1,25 +0,0 @@
|
|||
#!/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">
|
||||
<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>]]>]]>$"
|
||||
}
|
||||
|
|
@ -39,6 +39,7 @@ cat <<EOF > $cfg
|
|||
<CLICON_BACKEND_PIDFILE>/usr/local/var/$APPNAME/$APPNAME.pidfile</CLICON_BACKEND_PIDFILE>
|
||||
<CLICON_XMLDB_DIR>$dir</CLICON_XMLDB_DIR>
|
||||
<CLICON_XMLDB_FORMAT>$format</CLICON_XMLDB_FORMAT>
|
||||
$RESTCONFIG
|
||||
</clixon-config>
|
||||
EOF
|
||||
|
||||
|
|
@ -228,12 +229,6 @@ if [ $BE -ne 0 ]; then
|
|||
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
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@ cat <<EOF > $cfg
|
|||
<CLICON_RESTCONF_PRETTY>false</CLICON_RESTCONF_PRETTY>
|
||||
<CLICON_XMLDB_DIR>/usr/local/var/$APPNAME</CLICON_XMLDB_DIR>
|
||||
<CLICON_MODULE_LIBRARY_RFC7895>true</CLICON_MODULE_LIBRARY_RFC7895>
|
||||
$RESTCONFIG
|
||||
</clixon-config>
|
||||
EOF
|
||||
|
||||
|
|
@ -167,12 +168,6 @@ 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"
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ cat <<EOF > $cfg
|
|||
<CLICON_RESTCONF_PRETTY>false</CLICON_RESTCONF_PRETTY>
|
||||
<CLICON_BACKEND_PIDFILE>/usr/local/var/$APPNAME/$APPNAME.pidfile</CLICON_BACKEND_PIDFILE>
|
||||
<CLICON_XMLDB_DIR>/usr/local/var/$APPNAME</CLICON_XMLDB_DIR>
|
||||
$RESTCONFIG
|
||||
</clixon-config>
|
||||
EOF
|
||||
|
||||
|
|
@ -119,12 +120,6 @@ 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
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ cat <<EOF > $cfg
|
|||
<CLICON_SOCK>/usr/local/var/$APPNAME/$APPNAME.sock</CLICON_SOCK>
|
||||
<CLICON_BACKEND_PIDFILE>/usr/local/var/$APPNAME/$APPNAME.pidfile</CLICON_BACKEND_PIDFILE>
|
||||
<CLICON_XMLDB_DIR>/usr/local/var/$APPNAME</CLICON_XMLDB_DIR>
|
||||
$RESTCONFIG
|
||||
</clixon-config>
|
||||
EOF
|
||||
|
||||
|
|
@ -154,12 +155,6 @@ 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
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ cat <<EOF > $cfg
|
|||
<CLICON_RESTCONF_PRETTY>false</CLICON_RESTCONF_PRETTY>
|
||||
<CLICON_NACM_MODE>internal</CLICON_NACM_MODE>
|
||||
<CLICON_NACM_DISABLED_ON_EMPTY>true</CLICON_NACM_DISABLED_ON_EMPTY>
|
||||
$RESTCONFIG
|
||||
</clixon-config>
|
||||
EOF
|
||||
|
||||
|
|
@ -132,7 +133,7 @@ if [ $RC -ne 0 ]; then
|
|||
stop_restconf_pre
|
||||
|
||||
new "start restconf daemon (-a is enable basic authentication)"
|
||||
start_restconf -f $cfg -o CLICON_RESTCONF_CONFIG=false -- -a
|
||||
start_restconf -f $cfg -- -a
|
||||
|
||||
new "waiting"
|
||||
wait_restconf
|
||||
|
|
|
|||
|
|
@ -63,6 +63,7 @@ cat <<EOF > $cfg
|
|||
<CLICON_RESTCONF_PRETTY>false</CLICON_RESTCONF_PRETTY>
|
||||
<CLICON_NACM_MODE>internal</CLICON_NACM_MODE>
|
||||
<CLICON_NACM_DISABLED_ON_EMPTY>true</CLICON_NACM_DISABLED_ON_EMPTY>
|
||||
$RESTCONFIG
|
||||
</clixon-config>
|
||||
EOF
|
||||
|
||||
|
|
@ -227,22 +228,6 @@ fi
|
|||
new "waiting"
|
||||
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
|
||||
new "kill old restconf daemon"
|
||||
stop_restconf_pre
|
||||
|
|
@ -254,6 +239,16 @@ if [ $RC -ne 0 ]; then
|
|||
wait_restconf
|
||||
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"
|
||||
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"
|
||||
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@ cat <<EOF > $cfg
|
|||
<CLICON_RESTCONF_PRETTY>false</CLICON_RESTCONF_PRETTY>
|
||||
<CLICON_NACM_MODE>internal</CLICON_NACM_MODE>
|
||||
<CLICON_NACM_CREDENTIALS>none</CLICON_NACM_CREDENTIALS>
|
||||
$RESTCONFIG
|
||||
</clixon-config>
|
||||
EOF
|
||||
|
||||
|
|
@ -106,7 +107,7 @@ if [ $RC -ne 0 ]; then
|
|||
stop_restconf_pre
|
||||
|
||||
new "start restconf daemon (-a is enable basic authentication)"
|
||||
start_restconf -f $cfg -o CLICON_RESTCONF_CONFIG=false -- -a
|
||||
start_restconf -f $cfg -- -a
|
||||
|
||||
new "waiting"
|
||||
wait_restconf
|
||||
|
|
|
|||
|
|
@ -43,6 +43,7 @@ cat <<EOF > $cfg
|
|||
<CLICON_RESTCONF_PRETTY>false</CLICON_RESTCONF_PRETTY>
|
||||
<CLICON_NACM_MODE>internal</CLICON_NACM_MODE>
|
||||
<CLICON_NACM_DISABLED_ON_EMPTY>true</CLICON_NACM_DISABLED_ON_EMPTY>
|
||||
$RESTCONFIG
|
||||
</clixon-config>
|
||||
EOF
|
||||
|
||||
|
|
@ -232,23 +233,6 @@ fi
|
|||
new "waiting"
|
||||
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
|
||||
new "kill old restconf daemon"
|
||||
stop_restconf_pre
|
||||
|
|
@ -260,6 +244,16 @@ if [ $RC -ne 0 ]; then
|
|||
wait_restconf
|
||||
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"
|
||||
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"
|
||||
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@ cat <<EOF > $cfg
|
|||
<CLICON_RESTCONF_PRETTY>false</CLICON_RESTCONF_PRETTY>
|
||||
<CLICON_NACM_MODE>internal</CLICON_NACM_MODE>
|
||||
<CLICON_NACM_DISABLED_ON_EMPTY>true</CLICON_NACM_DISABLED_ON_EMPTY>
|
||||
$RESTCONFIG
|
||||
</clixon-config>
|
||||
EOF
|
||||
|
||||
|
|
@ -228,22 +229,6 @@ fi
|
|||
new "waiting"
|
||||
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
|
||||
new "kill old restconf daemon"
|
||||
stop_restconf_pre
|
||||
|
|
@ -255,6 +240,16 @@ if [ $RC -ne 0 ]; then
|
|||
wait_restconf
|
||||
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"
|
||||
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"
|
||||
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ cat <<EOF > $cfg
|
|||
<CLICON_NACM_MODE>internal</CLICON_NACM_MODE>
|
||||
<CLICON_NACM_DISABLED_ON_EMPTY>true</CLICON_NACM_DISABLED_ON_EMPTY>
|
||||
<CLICON_XMLDB_FORMAT>$format</CLICON_XMLDB_FORMAT>
|
||||
$RESTCONFIG
|
||||
</clixon-config>
|
||||
EOF
|
||||
|
||||
|
|
@ -110,9 +111,8 @@ 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 -o CLICON_RESTCONF_CONFIG=false -- -a
|
||||
start_restconf -f $cfg -- -a
|
||||
|
||||
new "waiting"
|
||||
wait_restconf
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@ cat <<EOF > $cfg
|
|||
<CLICON_NACM_MODE>external</CLICON_NACM_MODE>
|
||||
<CLICON_NACM_FILE>$nacmfile</CLICON_NACM_FILE>
|
||||
<CLICON_NACM_CREDENTIALS>none</CLICON_NACM_CREDENTIALS>
|
||||
$RESTCONFIG
|
||||
</clixon-config>
|
||||
EOF
|
||||
|
||||
|
|
@ -146,12 +147,6 @@ 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
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@ cat <<EOF > $cfg
|
|||
<CLICON_NACM_MODE>internal</CLICON_NACM_MODE>
|
||||
<CLICON_NACM_CREDENTIALS>none</CLICON_NACM_CREDENTIALS>
|
||||
<CLICON_NACM_DISABLED_ON_EMPTY>true</CLICON_NACM_DISABLED_ON_EMPTY>
|
||||
$RESTCONFIG
|
||||
</clixon-config>
|
||||
EOF
|
||||
|
||||
|
|
@ -129,18 +130,6 @@ fi
|
|||
new "waiting"
|
||||
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
|
||||
new "kill old restconf daemon"
|
||||
stop_restconf_pre
|
||||
|
|
@ -152,6 +141,13 @@ if [ $RC -ne 0 ]; then
|
|||
wait_restconf
|
||||
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"
|
||||
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"
|
||||
|
||||
|
|
|
|||
|
|
@ -49,6 +49,7 @@ cat <<EOF > $cfg
|
|||
<CLICON_RESTCONF_PRETTY>false</CLICON_RESTCONF_PRETTY>
|
||||
<CLICON_NACM_MODE>internal</CLICON_NACM_MODE>
|
||||
<CLICON_NACM_DISABLED_ON_EMPTY>true</CLICON_NACM_DISABLED_ON_EMPTY>
|
||||
$RESTCONFIG
|
||||
</clixon-config>
|
||||
EOF
|
||||
|
||||
|
|
@ -153,7 +154,7 @@ if [ $RC -ne 0 ]; then
|
|||
stop_restconf_pre
|
||||
|
||||
new "start restconf daemon (-a is enable basic authentication)"
|
||||
start_restconf -f $cfg -o CLICON_RESTCONF_CONFIG=false -- -a
|
||||
start_restconf -f $cfg -- -a
|
||||
|
||||
new "waiting"
|
||||
wait_restconf
|
||||
|
|
|
|||
|
|
@ -53,6 +53,7 @@ cat <<EOF > $cfg
|
|||
<CLICON_NACM_MODE>internal</CLICON_NACM_MODE>
|
||||
<CLICON_NACM_CREDENTIALS>none</CLICON_NACM_CREDENTIALS>
|
||||
<CLICON_NACM_DISABLED_ON_EMPTY>true</CLICON_NACM_DISABLED_ON_EMPTY>
|
||||
$RESTCONFIG
|
||||
</clixon-config>
|
||||
EOF
|
||||
|
||||
|
|
@ -149,19 +150,6 @@ fi
|
|||
new "waiting"
|
||||
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
|
||||
|
||||
new "kill old restconf daemon"
|
||||
|
|
@ -174,6 +162,13 @@ if [ $RC -ne 0 ]; then
|
|||
wait_restconf
|
||||
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"
|
||||
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"
|
||||
|
||||
|
|
|
|||
|
|
@ -85,6 +85,7 @@ cat <<EOF > $cfg
|
|||
<CLICON_NACM_RECOVERY_USER>$recovery</CLICON_NACM_RECOVERY_USER>
|
||||
<CLICON_NACM_MODE>internal</CLICON_NACM_MODE>
|
||||
<CLICON_NACM_CREDENTIALS>$cred</CLICON_NACM_CREDENTIALS>
|
||||
$RESTCONFIG
|
||||
</clixon-config>
|
||||
EOF
|
||||
if [ $BE -ne 0 ]; then
|
||||
|
|
@ -103,7 +104,7 @@ EOF
|
|||
stop_restconf_pre
|
||||
|
||||
new "start restconf daemon (-a is enable basic authentication)"
|
||||
start_restconf -f $cfg -o CLICON_RESTCONF_CONFIG=false -- -a
|
||||
start_restconf -f $cfg -- -a
|
||||
|
||||
new "waiting"
|
||||
wait_restconf
|
||||
|
|
|
|||
|
|
@ -69,6 +69,7 @@ cat <<EOF > $cfg
|
|||
<CLICON_CLISPEC_DIR>/usr/local/lib/example/clispec</CLICON_CLISPEC_DIR>
|
||||
<CLICON_CLI_LINESCROLLING>0</CLICON_CLI_LINESCROLLING>
|
||||
<CLICON_FEATURE>ietf-netconf:startup</CLICON_FEATURE>
|
||||
$RESTCONFIG
|
||||
</clixon-config>
|
||||
EOF
|
||||
|
||||
|
|
@ -87,12 +88,6 @@ 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
|
||||
|
|
|
|||
|
|
@ -47,6 +47,7 @@ cat <<EOF > $cfg
|
|||
<CLICON_CLISPEC_DIR>/usr/local/lib/example/clispec</CLICON_CLISPEC_DIR>
|
||||
<CLICON_CLI_LINESCROLLING>0</CLICON_CLI_LINESCROLLING>
|
||||
<CLICON_FEATURE>ietf-netconf:startup</CLICON_FEATURE>
|
||||
$RESTCONFIG
|
||||
</clixon-config>
|
||||
EOF
|
||||
|
||||
|
|
@ -108,12 +109,6 @@ 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
|
||||
|
|
|
|||
|
|
@ -46,6 +46,7 @@ cat <<EOF > $cfg
|
|||
<CLICON_CLI_DIR>/usr/local/lib/example/cli</CLICON_CLI_DIR>
|
||||
<CLICON_CLISPEC_DIR>/usr/local/lib/example/clispec</CLICON_CLISPEC_DIR>
|
||||
<CLICON_FEATURE>ietf-netconf:startup</CLICON_FEATURE>
|
||||
$RESTCONFIG
|
||||
</clixon-config>
|
||||
EOF
|
||||
|
||||
|
|
@ -108,12 +109,6 @@ 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"
|
||||
|
|
|
|||
|
|
@ -39,6 +39,7 @@ cat <<EOF > $cfg
|
|||
<CLICON_BACKEND_PIDFILE>/usr/local/var/$APPNAME/$APPNAME.pidfile</CLICON_BACKEND_PIDFILE>
|
||||
<CLICON_XMLDB_DIR>/usr/local/var/$APPNAME</CLICON_XMLDB_DIR>
|
||||
<CLICON_MODULE_LIBRARY_RFC7895>true</CLICON_MODULE_LIBRARY_RFC7895>
|
||||
</clixon-config>
|
||||
EOF
|
||||
|
||||
if [ "${WITH_RESTCONF}" = "evhtp" ]; then
|
||||
|
|
@ -50,23 +51,8 @@ if [ "${WITH_RESTCONF}" = "evhtp" ]; then
|
|||
cacert=$certdir/ca_cert.pem
|
||||
test -d $certdir || mkdir $certdir
|
||||
. ./certs.sh
|
||||
cat <<EOF >> $cfg
|
||||
<CLICON_SSL_SERVER_CERT>$srvcert</CLICON_SSL_SERVER_CERT>
|
||||
<CLICON_SSL_SERVER_KEY>$srvkey</CLICON_SSL_SERVER_KEY>
|
||||
<CLICON_SSL_CA_CERT>$srvcert</CLICON_SSL_CA_CERT>
|
||||
EOF
|
||||
fi
|
||||
|
||||
if $IPv6; then
|
||||
cat <<EOF >> $cfg
|
||||
<CLICON_RESTCONF_IPV6_ADDR>::</CLICON_RESTCONF_IPV6_ADDR>
|
||||
EOF
|
||||
fi
|
||||
|
||||
cat <<EOF >> $cfg
|
||||
</clixon-config>
|
||||
EOF
|
||||
|
||||
# This is a fixed 'state' implemented in routing_backend. It is assumed to be always there
|
||||
state='{"clixon-example:state":{"op":\["41","42","43"\]}'
|
||||
|
||||
|
|
@ -93,7 +79,8 @@ else
|
|||
<server-cert-path>$srvcert</server-cert-path>
|
||||
<server-key-path>$srvkey</server-key-path>
|
||||
<server-ca-cert-path>$cakey</server-ca-cert-path>
|
||||
<socket><namespace>default</namespace><address>0.0.0.0</address><port>80</port><ssl>false</ssl></socket>
|
||||
<socket><namespace>default</namespace><address>0.0.0.0</address><port>80</port><ssl>false</ssl></sock
|
||||
et>
|
||||
<socket><namespace>default</namespace><address>0.0.0.0</address><port>443</port><ssl>true</ssl></socket>
|
||||
</restconf>
|
||||
EOF
|
||||
|
|
@ -108,12 +95,10 @@ testrun()
|
|||
{
|
||||
proto=$1 # http/https
|
||||
addr=$2 # 127.0.0.1/::1
|
||||
config=$3 # local/backend
|
||||
|
||||
RCPROTO=$proto # for start/wait of restconf
|
||||
echo "proto:$proto"
|
||||
echo "addr:$addr"
|
||||
echo "config:$config"
|
||||
|
||||
new "test params: -f $cfg -- -s"
|
||||
if [ $BE -ne 0 ]; then
|
||||
|
|
@ -131,26 +116,19 @@ testrun()
|
|||
new "wait backend"
|
||||
wait_backend
|
||||
|
||||
if [ $config = backend ] ; then # Create a backend config
|
||||
# restconf backend config
|
||||
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 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>]]>]]>$"
|
||||
fi
|
||||
new "netconf commit"
|
||||
expecteof "$clixon_netconf -qf $cfg" 0 "<rpc $DEFAULTNS><commit/></rpc>]]>]]>" "^<rpc-reply $DEFAULTNS><ok/></rpc-reply>]]>]]>$"
|
||||
|
||||
if [ $RC -ne 0 ]; then
|
||||
new "kill old restconf daemon"
|
||||
stop_restconf_pre
|
||||
|
||||
if [ $config = backend ] ; then # Add -b option
|
||||
new "start restconf daemon -o CLICON_RESTCONF_CONFIG=true"
|
||||
start_restconf -f $cfg -o CLICON_RESTCONF_CONFIG=true
|
||||
else
|
||||
new "start restconf daemon -o CLICON_RESTCONF_CONFIG=false"
|
||||
start_restconf -f $cfg -o CLICON_RESTCONF_CONFIG=false
|
||||
fi
|
||||
new "start restconf daemon ZZZ"
|
||||
echo "cfg:$cfg"
|
||||
start_restconf -f $cfg
|
||||
fi
|
||||
new "wait restconf"
|
||||
wait_restconf
|
||||
|
|
@ -396,16 +374,8 @@ for proto in $protos; do
|
|||
addrs="$addrs \[::1\]"
|
||||
fi
|
||||
for addr in $addrs; do
|
||||
configs="local"
|
||||
if [ "${WITH_RESTCONF}" = "evhtp" ]; then
|
||||
# backend config retrieval only implemented for evhtp
|
||||
configs="$configs backend"
|
||||
fi
|
||||
echo "configs:$configs"
|
||||
for config in $configs; do
|
||||
new "restconf test: proto:$proto addr:$addr config:$config"
|
||||
testrun $proto $addr $config
|
||||
done
|
||||
new "restconf test: proto:$proto addr:$addr config:$config"
|
||||
testrun $proto $addr
|
||||
done
|
||||
done
|
||||
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ cat <<EOF > $cfg
|
|||
<CLICON_SOCK>/usr/local/var/$APPNAME/$APPNAME.sock</CLICON_SOCK>
|
||||
<CLICON_BACKEND_PIDFILE>$dir/restconf.pidfile</CLICON_BACKEND_PIDFILE>
|
||||
<CLICON_XMLDB_DIR>/usr/local/var/$APPNAME</CLICON_XMLDB_DIR>
|
||||
$RESTCONFIG
|
||||
</clixon-config>
|
||||
EOF
|
||||
|
||||
|
|
@ -84,12 +85,6 @@ 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
|
||||
|
|
|
|||
|
|
@ -46,6 +46,7 @@ cat <<EOF > $cfg
|
|||
<CLICON_CLISPEC_DIR>/usr/local/lib/$APPNAME/clispec</CLICON_CLISPEC_DIR>
|
||||
<CLICON_CLI_DIR>/usr/local/lib/$APPNAME/cli</CLICON_CLI_DIR>
|
||||
<CLICON_CLI_MODE>$APPNAME</CLICON_CLI_MODE>
|
||||
$RESTCONFIG
|
||||
</clixon-config>
|
||||
EOF
|
||||
|
||||
|
|
@ -168,12 +169,6 @@ 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
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@ cat <<EOF > $cfg
|
|||
<CLICON_BACKEND_PIDFILE>$dir/restconf.pidfile</CLICON_BACKEND_PIDFILE>
|
||||
<CLICON_XMLDB_DIR>/usr/local/var/$APPNAME</CLICON_XMLDB_DIR>
|
||||
<CLICON_STREAM_DISCOVERY_RFC8040>true</CLICON_STREAM_DISCOVERY_RFC8040>
|
||||
$RESTCONFIG
|
||||
</clixon-config>
|
||||
EOF
|
||||
|
||||
|
|
@ -77,12 +78,6 @@ 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
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ cat <<EOF > $cfg
|
|||
<CLICON_SOCK>/usr/local/var/$APPNAME/$APPNAME.sock</CLICON_SOCK>
|
||||
<CLICON_BACKEND_PIDFILE>$dir/restconf.pidfile</CLICON_BACKEND_PIDFILE>
|
||||
<CLICON_XMLDB_DIR>/usr/local/var/$APPNAME</CLICON_XMLDB_DIR>
|
||||
$RESTCONFIG
|
||||
</clixon-config>
|
||||
EOF
|
||||
|
||||
|
|
@ -80,12 +81,6 @@ 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
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ cat <<EOF > $cfg
|
|||
<CLICON_XMLDB_DIR>$dir</CLICON_XMLDB_DIR>
|
||||
<CLICON_NACM_MODE>internal</CLICON_NACM_MODE>
|
||||
<CLICON_NACM_DISABLED_ON_EMPTY>true</CLICON_NACM_DISABLED_ON_EMPTY>
|
||||
$RESTCONFIG
|
||||
</clixon-config>
|
||||
EOF
|
||||
|
||||
|
|
@ -116,7 +117,7 @@ if [ $RC -ne 0 ]; then
|
|||
stop_restconf_pre
|
||||
|
||||
new "start restconf daemon (-a is enable basic authentication)"
|
||||
start_restconf -f $cfg -o CLICON_RESTCONF_CONFIG=false -- -a
|
||||
start_restconf -f $cfg -- -a
|
||||
|
||||
new "waiting restconf"
|
||||
wait_restconf
|
||||
|
|
@ -173,7 +174,7 @@ if [ $RC -ne 0 ]; then
|
|||
stop_restconf_pre
|
||||
|
||||
new "start restconf daemon (-a is enable basic authentication)"
|
||||
start_restconf -f $cfg -o CLICON_RESTCONF_CONFIG=false -- -a
|
||||
start_restconf -f $cfg -- -a
|
||||
|
||||
new "waiting"
|
||||
wait_restconf
|
||||
|
|
|
|||
|
|
@ -44,6 +44,7 @@ cat <<EOF > $cfg
|
|||
<CLICON_SOCK>/usr/local/var/$APPNAME/$APPNAME.sock</CLICON_SOCK>
|
||||
<CLICON_BACKEND_PIDFILE>/usr/local/var/$APPNAME/$APPNAME.pidfile</CLICON_BACKEND_PIDFILE>
|
||||
<CLICON_XMLDB_DIR>$dir</CLICON_XMLDB_DIR>
|
||||
$RESTCONFIG
|
||||
</clixon-config>
|
||||
EOF
|
||||
|
||||
|
|
@ -64,12 +65,6 @@ 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
|
||||
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ cat <<EOF > $cfg
|
|||
<CLICON_SOCK>/usr/local/var/$APPNAME/$APPNAME.sock</CLICON_SOCK>
|
||||
<CLICON_BACKEND_PIDFILE>/usr/local/var/$APPNAME/$APPNAME.pidfile</CLICON_BACKEND_PIDFILE>
|
||||
<CLICON_XMLDB_DIR>/usr/local/var/$APPNAME</CLICON_XMLDB_DIR>
|
||||
$RESTCONFIG
|
||||
</clixon-config>
|
||||
EOF
|
||||
|
||||
|
|
@ -45,12 +46,6 @@ 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
|
||||
|
|
|
|||
|
|
@ -43,42 +43,6 @@ fi
|
|||
test -d $certdir || mkdir $certdir
|
||||
|
||||
# Use yang in example
|
||||
|
||||
# Get config from backend?
|
||||
cat <<EOF > $cfg
|
||||
<clixon-config xmlns="http://clicon.org/config">
|
||||
<CLICON_CONFIGFILE>$cfg</CLICON_CONFIGFILE>
|
||||
<CLICON_FEATURE>ietf-netconf:startup</CLICON_FEATURE>
|
||||
<CLICON_YANG_DIR>/usr/local/share/clixon</CLICON_YANG_DIR>
|
||||
<CLICON_YANG_DIR>$IETFRFC</CLICON_YANG_DIR>
|
||||
<CLICON_YANG_MAIN_FILE>$fyang</CLICON_YANG_MAIN_FILE>
|
||||
<CLICON_CLISPEC_DIR>/usr/local/lib/$APPNAME/clispec</CLICON_CLISPEC_DIR>
|
||||
<CLICON_BACKEND_DIR>/usr/local/lib/$APPNAME/backend</CLICON_BACKEND_DIR>
|
||||
<CLICON_BACKEND_REGEXP>example_backend.so$</CLICON_BACKEND_REGEXP>
|
||||
<CLICON_RESTCONF_DIR>/usr/local/lib/$APPNAME/restconf</CLICON_RESTCONF_DIR>
|
||||
<CLICON_RESTCONF_PRETTY>false</CLICON_RESTCONF_PRETTY>
|
||||
<CLICON_CLI_DIR>/usr/local/lib/$APPNAME/cli</CLICON_CLI_DIR>
|
||||
<CLICON_CLI_MODE>$APPNAME</CLICON_CLI_MODE>
|
||||
<CLICON_SOCK>/usr/local/var/$APPNAME/$APPNAME.sock</CLICON_SOCK>
|
||||
<CLICON_BACKEND_PIDFILE>/usr/local/var/$APPNAME/$APPNAME.pidfile</CLICON_BACKEND_PIDFILE>
|
||||
<CLICON_XMLDB_DIR>$dir</CLICON_XMLDB_DIR>
|
||||
<CLICON_MODULE_LIBRARY_RFC7895>true</CLICON_MODULE_LIBRARY_RFC7895>
|
||||
<CLICON_NACM_MODE>internal</CLICON_NACM_MODE>
|
||||
<CLICON_SSL_SERVER_CERT>$srvcert</CLICON_SSL_SERVER_CERT>
|
||||
<CLICON_SSL_SERVER_KEY>$srvkey</CLICON_SSL_SERVER_KEY>
|
||||
<CLICON_SSL_CA_CERT>$cacert</CLICON_SSL_CA_CERT>
|
||||
EOF
|
||||
|
||||
if $IPv6; then
|
||||
cat <<EOF >> $cfg
|
||||
<CLICON_RESTCONF_IPV6_ADDR>::</CLICON_RESTCONF_IPV6_ADDR>
|
||||
EOF
|
||||
fi
|
||||
|
||||
cat <<EOF >> $cfg
|
||||
</clixon-config>
|
||||
EOF
|
||||
|
||||
cat <<EOF > $fyang
|
||||
module example{
|
||||
yang-version 1.1;
|
||||
|
|
@ -155,44 +119,49 @@ EOF
|
|||
|
||||
fi # genkeys
|
||||
|
||||
# Set a clixon-restconf config
|
||||
ssl=true
|
||||
port=443
|
||||
authtype=client-certificate
|
||||
# Write local config
|
||||
cat <<EOF > $cfg
|
||||
<clixon-config xmlns="http://clicon.org/config">
|
||||
<CLICON_CONFIGFILE>$cfg</CLICON_CONFIGFILE>
|
||||
<CLICON_FEATURE>ietf-netconf:startup</CLICON_FEATURE>
|
||||
<CLICON_YANG_DIR>/usr/local/share/clixon</CLICON_YANG_DIR>
|
||||
<CLICON_YANG_DIR>$IETFRFC</CLICON_YANG_DIR>
|
||||
<CLICON_YANG_MAIN_FILE>$fyang</CLICON_YANG_MAIN_FILE>
|
||||
<CLICON_CLISPEC_DIR>/usr/local/lib/$APPNAME/clispec</CLICON_CLISPEC_DIR>
|
||||
<CLICON_BACKEND_DIR>/usr/local/lib/$APPNAME/backend</CLICON_BACKEND_DIR>
|
||||
<CLICON_BACKEND_REGEXP>example_backend.so$</CLICON_BACKEND_REGEXP>
|
||||
<CLICON_RESTCONF_DIR>/usr/local/lib/$APPNAME/restconf</CLICON_RESTCONF_DIR>
|
||||
<CLICON_RESTCONF_PRETTY>false</CLICON_RESTCONF_PRETTY>
|
||||
<CLICON_CLI_DIR>/usr/local/lib/$APPNAME/cli</CLICON_CLI_DIR>
|
||||
<CLICON_CLI_MODE>$APPNAME</CLICON_CLI_MODE>
|
||||
<CLICON_SOCK>/usr/local/var/$APPNAME/$APPNAME.sock</CLICON_SOCK>
|
||||
<CLICON_BACKEND_PIDFILE>/usr/local/var/$APPNAME/$APPNAME.pidfile</CLICON_BACKEND_PIDFILE>
|
||||
<CLICON_XMLDB_DIR>$dir</CLICON_XMLDB_DIR>
|
||||
<CLICON_MODULE_LIBRARY_RFC7895>true</CLICON_MODULE_LIBRARY_RFC7895>
|
||||
<CLICON_NACM_MODE>internal</CLICON_NACM_MODE>
|
||||
<restconf>
|
||||
<auth-type>client-certificate</auth-type>
|
||||
<server-cert-path>$srvcert</server-cert-path>
|
||||
<server-key-path>$srvkey</server-key-path>
|
||||
<server-ca-cert-path>$cacert</server-ca-cert-path>
|
||||
<socket>
|
||||
<namespace>default</namespace>
|
||||
<address>0.0.0.0</address>
|
||||
<port>443</port>
|
||||
<ssl>true</ssl>
|
||||
</socket>
|
||||
</restconf>
|
||||
</clixon-config>
|
||||
EOF
|
||||
|
||||
# Run with and without getting config from backend
|
||||
# arg 1: false: local config; true: use config backend
|
||||
# Run The test, ssl config is in local config
|
||||
testrun()
|
||||
{
|
||||
USEBACKEND=$1
|
||||
|
||||
# Startup DB with proper NACM config
|
||||
if $USEBACKEND; then
|
||||
cat <<EOF > $dir/startup_db
|
||||
<config>
|
||||
<restconf xmlns="https://clicon.org/restconf">
|
||||
<auth-type>$authtype</auth-type>
|
||||
<server-cert-path>$srvcert</server-cert-path>
|
||||
<server-key-path>$srvkey</server-key-path>
|
||||
<server-ca-cert-path>$cacert</server-ca-cert-path>
|
||||
|
||||
<socket>
|
||||
<namespace>default</namespace>
|
||||
<address>0.0.0.0</address>
|
||||
<port>$port</port>
|
||||
<ssl>$ssl</ssl>
|
||||
</socket>
|
||||
</restconf>
|
||||
$RULES
|
||||
</config>
|
||||
EOF
|
||||
else
|
||||
cat <<EOF > $dir/startup_db
|
||||
cat <<EOF > $dir/startup_db
|
||||
<config>
|
||||
$RULES
|
||||
</config>
|
||||
EOF
|
||||
fi
|
||||
if [ $BE -ne 0 ]; then
|
||||
new "kill old backend"
|
||||
sudo clixon_backend -zf $cfg
|
||||
|
|
@ -211,13 +180,8 @@ EOF
|
|||
if [ $RC -ne 0 ]; then
|
||||
new "kill old restconf daemon"
|
||||
stop_restconf_pre
|
||||
if $USEBACKEND; then
|
||||
new "start restconf daemon -b -- -s"
|
||||
start_restconf -f $cfg -o CLICON_RESTCONF_CONFIG=true -- -s
|
||||
else
|
||||
new "start restconf daemon -s -c -- -s"
|
||||
start_restconf -f $cfg -s -c -o CLICON_RESTCONF_CONFIG=false -- -s
|
||||
fi
|
||||
new "start restconf daemon -s -c -- -s"
|
||||
start_restconf -f $cfg -- -s
|
||||
fi
|
||||
|
||||
new "wait for restconf"
|
||||
|
|
@ -254,11 +218,8 @@ EOF
|
|||
fi
|
||||
}
|
||||
|
||||
new "Use local restconf config"
|
||||
testrun false
|
||||
|
||||
new "Get restconf config from backend"
|
||||
testrun true
|
||||
new "Run test"
|
||||
testrun
|
||||
|
||||
rm -rf $dir
|
||||
|
||||
|
|
|
|||
|
|
@ -43,6 +43,7 @@ cat <<EOF > $cfg
|
|||
<CLICON_RESTCONF_PRETTY>false</CLICON_RESTCONF_PRETTY>
|
||||
<CLICON_XMLDB_DIR>/usr/local/var/$APPNAME</CLICON_XMLDB_DIR>
|
||||
<CLICON_MODULE_LIBRARY_RFC7895>false</CLICON_MODULE_LIBRARY_RFC7895>
|
||||
$RESTCONFIG
|
||||
</clixon-config>
|
||||
EOF
|
||||
|
||||
|
|
@ -161,12 +162,6 @@ 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
|
||||
|
|
|
|||
|
|
@ -145,6 +145,7 @@ testrun()
|
|||
<CLICON_RESTCONF_PRETTY>false</CLICON_RESTCONF_PRETTY>
|
||||
<CLICON_YANG_UNKNOWN_ANYDATA>$unknown</CLICON_YANG_UNKNOWN_ANYDATA>
|
||||
$F
|
||||
$RESTCONFIG
|
||||
</clixon-config>
|
||||
EOF
|
||||
|
||||
|
|
@ -181,7 +182,7 @@ EOF
|
|||
stop_restconf_pre
|
||||
|
||||
new "start restconf daemon"
|
||||
start_restconf -f $cfg -o CLICON_RESTCONF_CONFIG=false
|
||||
start_restconf -f $cfg
|
||||
|
||||
fi
|
||||
new "wait restconf"
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ cat <<EOF > $cfg
|
|||
<CLICON_BACKEND_PIDFILE>/usr/local/var/$APPNAME/$APPNAME.pidfile</CLICON_BACKEND_PIDFILE>
|
||||
<CLICON_XMLDB_DIR>/usr/local/var/$APPNAME</CLICON_XMLDB_DIR>
|
||||
<CLICON_MODULE_LIBRARY_RFC7895>true</CLICON_MODULE_LIBRARY_RFC7895>
|
||||
$RESTCONFIG
|
||||
</clixon-config>
|
||||
EOF
|
||||
|
||||
|
|
@ -82,7 +83,7 @@ if [ $RC -ne 0 ]; then
|
|||
stop_restconf_pre
|
||||
|
||||
new "start restconf daemon"
|
||||
start_restconf -f $cfg -o CLICON_RESTCONF_CONFIG=false
|
||||
start_restconf -f $cfg
|
||||
|
||||
new "waiting"
|
||||
wait_restconf
|
||||
|
|
@ -116,7 +117,6 @@ expectpart "$(curl $CURLOPTS -X POST -H "Content-Type: application/yang-data+jso
|
|||
#new "restconf get config example1"
|
||||
#expectpart "$(curl $CURLOPTS -X GET $RCPROTO://localhost/restconf/data/example1:x)" 0 "HTTP/1.1 200 OK" '{"example1:x":42}'
|
||||
|
||||
|
||||
# XXX GET ../example2:x is translated to select=/x which gets both example1&2
|
||||
#new "restconf get config example2"
|
||||
#expectpart "$(curl $CURLOPTS -X GET $RCPROTO://localhost/restconf/data/example2:x)" 0 "HTTP/1.1 200 OK" '{"example2:x":{"y":42}}'
|
||||
|
|
@ -134,20 +134,20 @@ if [ $RC -ne 0 ]; then
|
|||
stop_restconf
|
||||
fi
|
||||
|
||||
if [ $BE -eq 0 ]; then
|
||||
exit # BE
|
||||
fi
|
||||
new "Kill backend"
|
||||
# Check if premature kill
|
||||
pid=$(pgrep -u root -f clixon_backend)
|
||||
if [ -z "$pid" ]; then
|
||||
err "backend already dead"
|
||||
fi
|
||||
# kill backend
|
||||
sudo clixon_backend -z -f $cfg
|
||||
if [ $? -ne 0 ]; then
|
||||
err "kill backend"
|
||||
fi
|
||||
sudo pkill -u root -f clixon_backend
|
||||
if [ $BE -ne 0 ]; then
|
||||
new "Kill backend"
|
||||
# Check if premature kill
|
||||
pid=$(pgrep -u root -f clixon_backend)
|
||||
if [ -z "$pid" ]; then
|
||||
err "backend already dead"
|
||||
fi
|
||||
# kill backend
|
||||
sudo clixon_backend -z -f $cfg
|
||||
|
||||
rm -rf $dir
|
||||
if [ $? -ne 0 ]; then
|
||||
err "kill backend"
|
||||
fi
|
||||
sudo pkill -u root -f clixon_backend
|
||||
fi
|
||||
|
||||
#rm -rf $dir
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue