- Restconf native http/1 to http/2 upgrade (non-tls)
This commit is contained in:
parent
b711faade9
commit
4f513385e9
17 changed files with 286 additions and 122 deletions
|
|
@ -39,7 +39,8 @@
|
|||
# --with-restconf=native Integration with embedded web server libevhtp
|
||||
WITH_RESTCONF=@with_restconf@ # native, fcgi or ""
|
||||
|
||||
WITH_HTTP2=@with_http2@ # true if nghttp2 is enabled, otherwise false
|
||||
HAVE_LIBNGHTTP2=@HAVE_LIBNGHTTP2@
|
||||
HAVE_LIBEVHTP=@HAVE_LIBEVHTP@
|
||||
|
||||
# This is for libxml2 XSD regex engine
|
||||
# Note this only enables the compiling of the code. In order to actually
|
||||
|
|
|
|||
11
test/lib.sh
11
test/lib.sh
|
|
@ -100,14 +100,19 @@ DEFAULTHELLO="<?xml version=\"1.0\" encoding=\"UTF-8\"?><hello $DEFAULTNS><capab
|
|||
# -k : insecure
|
||||
: ${CURLOPTS:="-Ssik"}
|
||||
# Set HTTP version 1.1 or 2
|
||||
if ${WITH_HTTP2}; then
|
||||
CURLOPTS="${CURLOPTS} --http2-prior-knowledge"
|
||||
if ${HAVE_LIBNGHTTP2}; then
|
||||
HVER=2
|
||||
if ${HAVE_LIBEVHTP}; then
|
||||
# This is if evhtp is enabled (unset proto=HTTP_2 in restconf_accept_client)
|
||||
CURLOPTS="${CURLOPTS} --http2"
|
||||
else
|
||||
# This is if evhtp is disabled (set proto=HTTP_2 in restconf_accept_client)
|
||||
CURLOPTS="${CURLOPTS} --http2-prior-knowledge"
|
||||
fi
|
||||
else
|
||||
HVER=1.1
|
||||
fi
|
||||
|
||||
|
||||
# Wait after daemons (backend/restconf) start. See mem.sh for valgrind
|
||||
if [ "$(uname -m)" = "armv7l" ]; then
|
||||
: ${DEMWAIT:=8}
|
||||
|
|
|
|||
|
|
@ -143,8 +143,16 @@ sed -i '/Transfer-Encoding:/d' $foutput
|
|||
sed -i '/Connection:/d' $foutput
|
||||
|
||||
# Create a file to compare with
|
||||
if ${WITH_HTTP2}; then
|
||||
echo "HTTP/$HVER 200
" > $ftest
|
||||
if ${HAVE_LIBNGHTTP2}; then
|
||||
if ${HAVE_LIBEVHTP}; then
|
||||
# Add 101 switch protocols for http 1->2 upgrade
|
||||
echo "HTTP/1.1 101 Switching Protocols
" > $ftest
|
||||
echo "Upgrade: h2c
" >> $ftest
|
||||
echo "
" >> $ftest
|
||||
echo "HTTP/$HVER 200
" >> $ftest
|
||||
else
|
||||
echo "HTTP/$HVER 200
" > $ftest
|
||||
fi
|
||||
else
|
||||
echo "HTTP/$HVER 200 OK
" > $ftest
|
||||
fi
|
||||
|
|
@ -157,6 +165,7 @@ echo "</data>
" >> $ftest
|
|||
|
||||
ret=$(diff -i $ftest $foutput)
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "$ret"
|
||||
err1 "Matching running-db with $fconfigonly"
|
||||
fi
|
||||
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ if [ "${WITH_RESTCONF}" = "native" ]; then
|
|||
# Create server certs and CA
|
||||
cacerts $cakey $cacert
|
||||
servercerts $cakey $cacert $srvkey $srvcert
|
||||
USEBACKEND=true
|
||||
USEBACKEND=false
|
||||
else
|
||||
# Define default restconfig config: RESTCONFIG
|
||||
RESTCONFIG=$(restconf_config none false)
|
||||
|
|
@ -169,9 +169,10 @@ function testrun()
|
|||
wait_restconf
|
||||
|
||||
new "restconf root discovery. RFC 8040 3.1 (xml+xrd)"
|
||||
echo "curl $CURLOPTS -X GET $proto://$addr/.well-known/host-meta"
|
||||
expectpart "$(curl $CURLOPTS -X GET $proto://$addr/.well-known/host-meta)" 0 "HTTP/$HVER 200" "<XRD xmlns='http://docs.oasis-open.org/ns/xri/xrd-1.0'>" "<Link rel='restconf' href='/restconf'/>" "</XRD>"
|
||||
|
||||
if ! ${WITH_HTTP2}; then # http/2
|
||||
if ! ${HAVE_LIBNGHTTP2}; then # http/2
|
||||
|
||||
if [ "${WITH_RESTCONF}" = "native" ]; then # XXX does not work with nginx
|
||||
new "restconf GET http/1.0 - returns 1.0"
|
||||
|
|
@ -244,7 +245,7 @@ function testrun()
|
|||
|
||||
new "restconf HEAD. RFC 8040 4.2"
|
||||
expectpart "$(curl $CURLOPTS --head -H "Accept: application/yang-data+json" $proto://$addr/restconf/data)" 0 "HTTP/$HVER 200" "Content-Type: application/yang-data+json"
|
||||
|
||||
|
||||
new "restconf empty rpc JSON"
|
||||
expectpart "$(curl $CURLOPTS -X POST -H "Content-Type: application/yang-data+json" -d {\"clixon-example:input\":null} $proto://$addr/restconf/operations/clixon-example:empty)" 0 "HTTP/$HVER 204"
|
||||
|
||||
|
|
|
|||
|
|
@ -196,7 +196,7 @@ expectpart "$(curl $CURLOPTS -X GET -H 'Accept: application/yang-data+xml' $RCPR
|
|||
# But leave it here for debugging where netcat works properly
|
||||
# Alt try something like:
|
||||
# printf "Hello World!" | (exec 3<>/dev/tcp/127.0.0.1/80; cat >&3; cat <&3; exec 3<&-)
|
||||
if [ false -a ! ${WITH_HTTP2} ] ; then
|
||||
if [ false -a ! ${HAVE_LIBNGHTTP2} ] ; then
|
||||
# Look for netcat or nc for direct socket http calls
|
||||
if [ -n "$(type netcat 2> /dev/null)" ]; then
|
||||
netcat="netcat -w 1" # -N works on evhtp but not fcgi
|
||||
|
|
|
|||
|
|
@ -174,10 +174,9 @@ EOF
|
|||
new "start backend -s init -f $cfg -- -sS $fstate"
|
||||
start_backend -s init -f $cfg -- -sS $fstate
|
||||
fi
|
||||
|
||||
new "waiting"
|
||||
wait_backend
|
||||
fi
|
||||
new "wait backend"
|
||||
wait_backend
|
||||
|
||||
if [ $RC -ne 0 ]; then
|
||||
new "kill old restconf daemon"
|
||||
|
|
@ -216,8 +215,8 @@ EOF
|
|||
|
||||
new "restconf get config"
|
||||
expectpart "$(curl $CURLOPTS -X GET -H "Accept: application/yang-data+xml" $RCPROTO://localhost/restconf/data?content=config)" 0 "HTTP/$HVER 200" "$XML"
|
||||
|
||||
# Save partial state in state file with unknown removed (positive test)
|
||||
|
||||
new "Save partial state with unknowns removed in state file $fstate"
|
||||
echo "$STATE1" > $fstate
|
||||
|
||||
new "Get state (positive test)"
|
||||
|
|
@ -226,7 +225,7 @@ EOF
|
|||
new "restconf get state(positive)"
|
||||
expectpart "$(curl $CURLOPTS -X GET -H "Accept: application/yang-data+xml" $RCPROTO://localhost/restconf/data?content=nonconfig)" 0 "HTTP/$HVER 200" "$STATE1"
|
||||
|
||||
# full state with unknowns
|
||||
new "Save full state with unknowns in state file $fstate"
|
||||
echo "$STATE0" > $fstate
|
||||
|
||||
new "Get state (negative test)"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue