Test: pass tests for disable-http1 and disable-nghttp2

This commit is contained in:
Olof hagsand 2022-09-04 15:05:06 +02:00
parent 5e2643c382
commit f6a964eab6
6 changed files with 39 additions and 16 deletions

View file

@ -15,6 +15,11 @@
# - The tests runs through both (if compiled with native)
# See also test_restconf_op.sh
# See test_restconf_rpc.sh for cases when CLICON_BACKEND_RESTCONF_PROCESS is set
#
# Note, for tests: "Wrong proto=http on https port, expect bad reques"
# there was an effort to return an HTTP error on HTTPS socket, but it breaks other
# error cases, more stable is to just close the socket, but
# curl gets an error code instead.
# Magic line must be first in script (see README.md)
s="$_" ; . ./lib.sh || if [ "$s" = $0 ]; then exit 0; else return 0; fi
@ -207,9 +212,6 @@ function testrun()
else # see (1) http to https port in restconf_main_native.c
new "Wrong proto=http on https port, expect bad request"
expectpart "$(curl $CURLOPTS -X GET http://$addr:443/.well-known/host-meta 2>&1)" 56 "Connection reset by peer"
# An effort to return an HTTP error on HTTPS socket, but it breaks other
# error cases, more stable is to just close the socket, but
# curl gets an error code instead, see ^
# expectpart "$(curl $CURLOPTS -X GET http://$addr:443/.well-known/host-meta)" 0 "HTTP/" "400"
fi
@ -262,7 +264,7 @@ function testrun()
expectpart "$(curl $CURLOPTS -X GET https://$addr:80/.well-known/host-meta 2>&1)" 35 #"wrong version number" # dependent on curl version
else # see (1) http to https port in restconf_main_native.c
new "Wrong proto=http on https port, expect bad request"
expectpart "$(curl $CURLOPTS -X GET http://$addr:443/.well-known/host-meta)" "16 52 55" --not-- 'HTTP'
expectpart "$(curl $CURLOPTS -X GET http://$addr:443/.well-known/host-meta)" "16 52 55 56" --not-- 'HTTP'
fi
else #------------------------------------------------------- HTTP/1 only
@ -303,8 +305,8 @@ function testrun()
expectpart "$(curl $CURLOPTS -X GET https://$addr:80/.well-known/host-meta 2>&1)" 35 #"wrong version number" # dependent on curl version
else # see (1) http to https port in restconf_main_native.c
new "Wrong proto=http on https port, expect bad request"
expectpart "$(curl $CURLOPTS -X GET http://$addr:443/.well-known/host-meta)" 0 "HTTP/" "400"
# expectpart "$(curl $CURLOPTS -X GET http://$addr:443/.well-known/host-meta 2>&1)" 56 "Connection reset by peer"
expectpart "$(curl $CURLOPTS -X GET http://$addr:443/.well-known/host-meta 2>&1)" 56 "Connection reset by peer"
# expectpart "$(curl $CURLOPTS -X GET http://$addr:443/.well-known/host-meta)" 0 "HTTP/" "400"
fi
fi # HTTP/2

View file

@ -17,9 +17,26 @@ APPNAME=example
# Only works with native
if [ "${WITH_RESTCONF}" != "native" ]; then
rm -rf $dir
if [ "$s" = $0 ]; then exit 0; else return 0; fi # skip
fi
if ! ${HAVE_HTTP1}; then
echo "...skipped: Must run with http/1"
rm -rf $dir
if [ "$s" = $0 ]; then exit 0; else return 0; fi
fi
# Callhome stream is HTTP/1.1, other communication is HTTP/2
HVERCH=1.1
if [ ${HAVE_LIBNGHTTP2} = true ]; then
# Pin to http/1
HAVE_LIBNGHTTP2=false
CURLOPTS="${CURLOPTS} --http1.1"
HVER=2
else
HVER=1.1
fi
: ${clixon_restconf_callhome_client:=clixon_restconf_callhome_client}
cfg=$dir/conf_yang.xml
@ -39,9 +56,6 @@ srvcert=$certdir/srv_cert.pem
users="andy" # generate certs for some users
RCPROTO=https
# Callhome stream is HTTP/1.1, other communication is HTTP/2
HVER=2
HVERCH=1.1
test -d $certdir || mkdir $certdir
@ -293,7 +307,7 @@ wait_restconf
new "restconf Add init data"
expectpart "$(curl $CURLOPTS --key $certdir/andy.key --cert $certdir/andy.crt -X POST -H "Accept: application/yang-data+json" -H "Content-Type: application/yang-data+json" -d '{"clixon-example:table":{"parameter":{"name":"x","value":"foo"}}}' $RCPROTO://127.0.0.1/restconf/data)" 0 "HTTP/$HVER 201"
expectpart "$(curl $CURLOPTS --key $certdir/andy.key --cert $certdir/andy.crt -X POST -H "Accept: application/yang-data+json" -H "Content-Type: application/yang-data+json" -d '{"clixon-example:table":{"parameter":{"name":"x","value":"foo"}}}' $RCPROTO://127.0.0.1/restconf/data)" 0 "HTTP/$HVER 201"
t0=$(date +"%s")
new "Send GET via callhome persistence client port 4336"

View file

@ -19,6 +19,7 @@ s="$_" ; . ./lib.sh || if [ "$s" = $0 ]; then exit 0; else return 0; fi
# Only works with native and https
if [ "${WITH_RESTCONF}" != "native" ]; then
rm -rf $dir
if [ "$s" = $0 ]; then exit 0; else return 0; fi # skip
fi
@ -30,6 +31,7 @@ fyang=$dir/clixon-example.yang
# If nmap not installed just quietly quit
if [ ! -n "$(type nmap 2> /dev/null)" ]; then
rm -rf $dir
if [ "$s" = $0 ]; then exit 0; else return 0; fi # skip
fi

View file

@ -9,6 +9,7 @@ s="$_" ; . ./lib.sh || if [ "$s" = $0 ]; then exit 0; else return 0; fi
# Only works with native and https
if [ "${WITH_RESTCONF}" != "native" ]; then
rm -rf $dir
if [ "$s" = $0 ]; then exit 0; else return 0; fi # skip
fi

View file

@ -8,9 +8,11 @@
s="$_" ; . ./lib.sh || if [ "$s" = $0 ]; then exit 0; else return 0; fi
# Enable if YANG_PATCH
echo "...skipped: YANG_PATCH JSON NYI"
rm -rf $dir
if [ -z "${CLIXON_YANG_PATCH}" -a "$s" = $0 ]; then exit 0; else return 0; fi
if true; then
echo "...skipped: YANG_PATCH JSON NYI"
rm -rf $dir
if [ -z "${CLIXON_YANG_PATCH}" -a "$s" = $0 ]; then exit 0; else return 0; fi
fi
APPNAME=example

View file

@ -7,9 +7,11 @@
# Magic line must be first in script (see README.md)
s="$_" ; . ./lib.sh || if [ "$s" = $0 ]; then exit 0; else return 0; fi
echo "...skipped: YANG_PATCH XML NYI"
rm -rf $dir
if [ -z "${CLIXON_YANG_PATCH}" -a "$s" = $0 ]; then exit 0; else return 0; fi
if true; then
echo "...skipped: YANG_PATCH XML NYI"
rm -rf $dir
if [ -z "${CLIXON_YANG_PATCH}" -a "$s" = $0 ]; then exit 0; else return 0; fi
fi
APPNAME=example