test script parameter interfence
This commit is contained in:
parent
70ebfa4d80
commit
dbfd92846c
2 changed files with 44 additions and 46 deletions
|
|
@ -158,7 +158,7 @@ expectwait "$clixon_netconf -qf $cfg" '<rpc><create-subscription xmlns="urn:ietf
|
|||
#NOW=$(date +"%Y-%m-%dT%H:%M:%S")
|
||||
#sleep 10
|
||||
#expectwait "$clixon_netconf -qf $cfg" "<rpc><create-subscription xmlns=\"urn:ietf:params:xml:ns:netmod:notification\"><stream>EXAMPLE</stream><startTime>$NOW</startTime></create-subscription></rpc>]]>]]>" '^<rpc-reply><ok/></rpc-reply>]]>]]><notification xmlns="urn:ietf:params:xml:ns:netconf:notification:1.0"><eventTime>20' 10
|
||||
sleep 2
|
||||
sleep 1
|
||||
|
||||
#
|
||||
# 2. Restconf RFC8040 stream testing
|
||||
|
|
@ -167,11 +167,11 @@ new "2. Restconf RFC8040 stream testing"
|
|||
new "restconf event stream discovery RFC8040 Sec 6.2"
|
||||
expectfn "curl -s -X GET http://localhost/restconf/data/ietf-restconf-monitoring:restconf-state/streams" 0 '{"ietf-restconf-monitoring:streams":{"stream":\[{"name":"EXAMPLE","description":"Example event stream","replay-support":true,"access":\[{"encoding":"xml","location":"https://localhost/streams/EXAMPLE"}\]}\]}'
|
||||
|
||||
sleep 2
|
||||
sleep 1
|
||||
new "restconf subscribe RFC8040 Sec 6.3, get location"
|
||||
expectfn "curl -s -X GET http://localhost/restconf/data/ietf-restconf-monitoring:restconf-state/streams/stream=EXAMPLE/access=xml/location" 0 '{"ietf-restconf-monitoring:location":"https://localhost/streams/EXAMPLE"}'
|
||||
|
||||
sleep 2
|
||||
sleep 1
|
||||
# Restconf stream subscription RFC8040 Sec 6.3
|
||||
# Start Subscription w error
|
||||
new "restconf monitor event nonexist stream"
|
||||
|
|
@ -191,7 +191,7 @@ if [ $nr -lt 1 -o $nr -gt 2 ]; then
|
|||
err 2 "$nr"
|
||||
fi
|
||||
|
||||
sleep 2
|
||||
sleep 1
|
||||
|
||||
# 2b) start subscription 8s - stoptime after 5s - expect 1-2 notifications
|
||||
new "2b) start subscriptions 8s - stoptime after 5s - expect 1-2 notifications"
|
||||
|
|
@ -206,7 +206,7 @@ if [ $nr -lt 1 -o $nr -gt 2 ]; then
|
|||
err 1 "$nr"
|
||||
fi
|
||||
|
||||
sleep 2
|
||||
sleep 1
|
||||
|
||||
# 2c
|
||||
new "2c) start sub 8s - replay from start -8s - expect 3-4 notifications"
|
||||
|
|
@ -221,7 +221,7 @@ if [ $nr -lt 3 -o $nr -gt 4 ]; then
|
|||
err 4 "$nr"
|
||||
fi
|
||||
|
||||
sleep 2
|
||||
sleep 1
|
||||
|
||||
# 2d) start sub 8s - replay from start -8s to stop +4s - expect 3 notifications
|
||||
new "2d) start sub 8s - replay from start -8s to stop +4s - expect 3 notifications"
|
||||
|
|
@ -236,7 +236,7 @@ if [ $nr -lt 4 -o $nr -gt 10 ]; then
|
|||
err 6 "$nr"
|
||||
fi
|
||||
|
||||
sleep 2
|
||||
sleep 1
|
||||
|
||||
# 2e) start sub 8s - replay from -90s w retention 60s - expect 10 notifications
|
||||
new "2e) start sub 8s - replay from -90s w retention 60s - expect 10 notifications"
|
||||
|
|
@ -252,7 +252,7 @@ if [ $nr -lt 9 -o $nr -gt 14 ]; then
|
|||
err 10 "$nr"
|
||||
fi
|
||||
|
||||
sleep 2
|
||||
sleep 1
|
||||
|
||||
# Try parallell
|
||||
# start background job
|
||||
|
|
|
|||
|
|
@ -6,41 +6,39 @@
|
|||
# Magic line must be first in script (see README.md)
|
||||
s="$_" ; . ./lib.sh || if [ "$s" = $0 ]; then exit 0; else return 0; fi
|
||||
|
||||
: ${clixon_util_xml:=clixon_util_xml -o} # -o is output
|
||||
|
||||
sleep 1 # mysterious fail, maybe this helps?
|
||||
: ${clixon_util_xml:="clixon_util_xml"}
|
||||
|
||||
new "xml parse"
|
||||
expecteof "$clixon_util_xml" 0 "<a><b/></a>" "^<a><b/></a>$"
|
||||
expecteof "$clixon_util_xml -o" 0 "<a><b/></a>" "^<a><b/></a>$"
|
||||
|
||||
new "xml parse to json"
|
||||
expecteof "$clixon_util_xml -j" 0 "<a><b/></a>" '{"a":{"b":null}}'
|
||||
expecteof "$clixon_util_xml -oj" 0 "<a><b/></a>" '{"a":{"b":null}}'
|
||||
|
||||
new "xml parse strange names"
|
||||
expecteof "$clixon_util_xml" 0 "<_-><b0.><c-.-._/></b0.></_->" "<_-><b0.><c-.-._/></b0.></_->"
|
||||
expecteof "$clixon_util_xml -o" 0 "<_-><b0.><c-.-._/></b0.></_->" "<_-><b0.><c-.-._/></b0.></_->"
|
||||
|
||||
new "xml parse name errors"
|
||||
expecteof "$clixon_util_xml" 255 "<-a/>" ""
|
||||
expecteof "$clixon_util_xml -o" 255 "<-a/>" ""
|
||||
|
||||
new "xml parse name errors"
|
||||
expecteof "$clixon_util_xml" 255 "<9/>" ""
|
||||
expecteof "$clixon_util_xml -o" 255 "<9/>" ""
|
||||
|
||||
new "xml parse name errors"
|
||||
expecteof "$clixon_util_xml" 255 "<a%/>" ""
|
||||
expecteof "$clixon_util_xml -o" 255 "<a%/>" ""
|
||||
|
||||
LF='
|
||||
'
|
||||
new "xml parse content with CR LF -> LF, CR->LF (see https://www.w3.org/TR/REC-xml/#sec-line-ends)"
|
||||
ret=$(echo "<x>a
b${LF}c
${LF}d</x>" | $clixon_util_xml)
|
||||
ret=$(echo "<x>a
b${LF}c
${LF}d</x>" | $clixon_util_xml -o)
|
||||
if [ "$ret" != "<x>a${LF}b${LF}c${LF}d</x>" ]; then
|
||||
err '<x>a$LFb$LFc</x>' "$ret"
|
||||
fi
|
||||
|
||||
new "xml simple CDATA"
|
||||
expecteofx "$clixon_util_xml" 0 '<a><![CDATA[a text]]></a>' '<a><![CDATA[a text]]></a>'
|
||||
expecteofx "$clixon_util_xml -o" 0 '<a><![CDATA[a text]]></a>' '<a><![CDATA[a text]]></a>'
|
||||
|
||||
new "xml simple CDATA to json"
|
||||
expecteofx "$clixon_util_xml -j" 0 '<a><![CDATA[a text]]></a>' '{"a":"a text"}'
|
||||
expecteofx "$clixon_util_xml -o -j" 0 '<a><![CDATA[a text]]></a>' '{"a":"a text"}'
|
||||
|
||||
new "xml complex CDATA"
|
||||
XML=$(cat <<EOF
|
||||
|
|
@ -57,7 +55,7 @@ XML=$(cat <<EOF
|
|||
EOF
|
||||
)
|
||||
|
||||
expecteof "$clixon_util_xml" 0 "$XML" "^<a><description>An example of escaped CENDs</description><sometext>
|
||||
expecteof "$clixon_util_xml -o" 0 "$XML" "^<a><description>An example of escaped CENDs</description><sometext>
|
||||
<![CDATA[ They're saying \"x < y\" & that \"z > y\" so I guess that means that z > x ]]>
|
||||
</sometext><data><![CDATA[This text contains a CEND ]]]]><![CDATA[>]]></data><alternative><![CDATA[This text contains a CEND ]]]><![CDATA[]>]]></alternative></a>$"
|
||||
|
||||
|
|
@ -66,89 +64,89 @@ JSON=$(cat <<EOF
|
|||
EOF
|
||||
)
|
||||
new "xml complex CDATA to json"
|
||||
expecteofx "$clixon_util_xml -j" 0 "$XML" "$JSON"
|
||||
expecteofx "$clixon_util_xml -oj" 0 "$XML" "$JSON"
|
||||
|
||||
XML=$(cat <<EOF
|
||||
<message>Less than: < , greater than: > ampersand: & </message>
|
||||
EOF
|
||||
)
|
||||
new "xml encode <>&"
|
||||
expecteof "$clixon_util_xml" 0 "$XML" "$XML"
|
||||
expecteof "$clixon_util_xml -o" 0 "$XML" "$XML"
|
||||
|
||||
new "xml encode <>& to json"
|
||||
expecteof "$clixon_util_xml -j" 0 "$XML" '{"message":"Less than: < , greater than: > ampersand: & "}'
|
||||
expecteof "$clixon_util_xml -oj" 0 "$XML" '{"message":"Less than: < , greater than: > ampersand: & "}'
|
||||
|
||||
XML=$(cat <<EOF
|
||||
<message>single-quote character ' represented as ' and double-quote character as "</message>
|
||||
EOF
|
||||
)
|
||||
new "xml single and double quote"
|
||||
expecteof "$clixon_util_xml" 0 "$XML" "<message>single-quote character ' represented as ' and double-quote character as \"</message>"
|
||||
expecteof "$clixon_util_xml -o" 0 "$XML" "<message>single-quote character ' represented as ' and double-quote character as \"</message>"
|
||||
|
||||
JSON=$(cat <<EOF
|
||||
{"message":"single-quote character ' represented as ' and double-quote character as \""}
|
||||
EOF
|
||||
)
|
||||
new "xml single and double quotes to json"
|
||||
expecteofx "$clixon_util_xml -j" 0 "$XML" "$JSON"
|
||||
expecteofx "$clixon_util_xml -oj" 0 "$XML" "$JSON"
|
||||
|
||||
new "xml backspace"
|
||||
expecteofx "$clixon_util_xml" 0 "<a>a\b</a>" "<a>a\b</a>"
|
||||
expecteofx "$clixon_util_xml -o" 0 "<a>a\b</a>" "<a>a\b</a>"
|
||||
|
||||
new "xml backspace to json"
|
||||
expecteofx "$clixon_util_xml -j" 0 "<a>a\b</a>" '{"a":"a\\b"}'
|
||||
expecteofx "$clixon_util_xml -oj" 0 "<a>a\b</a>" '{"a":"a\\b"}'
|
||||
|
||||
new "Double quotes for attributes"
|
||||
expecteof "$clixon_util_xml" 0 '<x a="t"/>' '<x a="t"/>'
|
||||
expecteof "$clixon_util_xml -o" 0 '<x a="t"/>' '<x a="t"/>'
|
||||
|
||||
new "Single quotes for attributes (returns double quotes but at least parses right)"
|
||||
expecteof "$clixon_util_xml" 0 "<x a='t'/>" '<x a="t"/>'
|
||||
expecteof "$clixon_util_xml -o" 0 "<x a='t'/>" '<x a="t"/>'
|
||||
|
||||
new "Mixed quotes"
|
||||
expecteof "$clixon_util_xml" 0 "<x a='t' b=\"q\"/>" '<x a="t" b="q"/>'
|
||||
expecteof "$clixon_util_xml -o" 0 "<x a='t' b=\"q\"/>" '<x a="t" b="q"/>'
|
||||
|
||||
new "XMLdecl version"
|
||||
expecteof "$clixon_util_xml" 0 '<?xml version="1.0"?><a/>' '<a/>'
|
||||
expecteof "$clixon_util_xml -o" 0 '<?xml version="1.0"?><a/>' '<a/>'
|
||||
|
||||
new "XMLdecl version, single quotes"
|
||||
expecteof "$clixon_util_xml" 0 "<?xml version='1.0'?><a/>" '<a/>'
|
||||
expecteof "$clixon_util_xml -o" 0 "<?xml version='1.0'?><a/>" '<a/>'
|
||||
|
||||
new "XMLdecl version no element"
|
||||
expecteof "$clixon_util_xml" 255 '<?xml version="1.0"?>' ''
|
||||
expecteof "$clixon_util_xml -o" 255 '<?xml version="1.0"?>' ''
|
||||
|
||||
new "XMLdecl no version"
|
||||
expecteof "$clixon_util_xml" 255 '<?xml ?><a/>' ''
|
||||
expecteof "$clixon_util_xml -o" 255 '<?xml ?><a/>' ''
|
||||
|
||||
new "XMLdecl misspelled version"
|
||||
expecteof "$clixon_util_xml -l o" 255 '<?xml verion="1.0"?><a/>' ''
|
||||
expecteof "$clixon_util_xml -ol o" 255 '<?xml verion="1.0"?><a/>' ''
|
||||
|
||||
new "XMLdecl version + encoding"
|
||||
expecteof "$clixon_util_xml" 0 '<?xml version="1.0" encoding="UTF-16"?><a/>' '<a/>'
|
||||
expecteof "$clixon_util_xml -o" 0 '<?xml version="1.0" encoding="UTF-16"?><a/>' '<a/>'
|
||||
|
||||
new "XMLdecl version + misspelled encoding"
|
||||
expecteof "$clixon_util_xml -l o" 255 '<?xml version="1.0" encding="UTF-16"?><a/>' 'syntax error: at or before: e'
|
||||
expecteof "$clixon_util_xml -ol o" 255 '<?xml version="1.0" encding="UTF-16"?><a/>' 'syntax error: at or before: e'
|
||||
|
||||
new "XMLdecl version + standalone"
|
||||
expecteof "$clixon_util_xml" 0 '<?xml version="1.0" standalone="yes"?><a/>' '<a/>'
|
||||
expecteof "$clixon_util_xml -o" 0 '<?xml version="1.0" standalone="yes"?><a/>' '<a/>'
|
||||
|
||||
new "PI - Processing instruction empty"
|
||||
expecteof "$clixon_util_xml" 0 '<?foo ?><a/>' '<a/>'
|
||||
expecteof "$clixon_util_xml -o" 0 '<?foo ?><a/>' '<a/>'
|
||||
|
||||
new "PI some content"
|
||||
expecteof "$clixon_util_xml" 0 '<?foo something else ?><a/>' '<a/>'
|
||||
expecteof "$clixon_util_xml -o" 0 '<?foo something else ?><a/>' '<a/>'
|
||||
|
||||
new "prolog element misc*"
|
||||
expecteof "$clixon_util_xml" 0 '<?foo something ?><a/><?bar more stuff ?><!-- a comment-->' '<a/>'
|
||||
expecteof "$clixon_util_xml -o" 0 '<?foo something ?><a/><?bar more stuff ?><!-- a comment-->' '<a/>'
|
||||
|
||||
# We allow it as an internal necessity for parsing of xml fragments
|
||||
#new "double element error"
|
||||
#expecteof "$clixon_util_xml" 255 '<a/><b/>' ''
|
||||
|
||||
new "namespace: DefaultAttName"
|
||||
expecteof "$clixon_util_xml" 0 '<x xmlns="n1">hello</x>' '<x xmlns="n1">hello</x>'
|
||||
expecteof "$clixon_util_xml -o" 0 '<x xmlns="n1">hello</x>' '<x xmlns="n1">hello</x>'
|
||||
|
||||
new "namespace: PrefixedAttName"
|
||||
expecteof "$clixon_util_xml" 0 '<x xmlns:n2="urn:example:des"><n2:y>hello</n2:y></x>' '^<x xmlns:n2="urn:example:des"><n2:y>hello</n2:y></x>$'
|
||||
expecteof "$clixon_util_xml -o" 0 '<x xmlns:n2="urn:example:des"><n2:y>hello</n2:y></x>' '^<x xmlns:n2="urn:example:des"><n2:y>hello</n2:y></x>$'
|
||||
|
||||
new "First example 6.1 from https://www.w3.org/TR/2009/REC-xml-names-20091208"
|
||||
XML=$(cat <<EOF
|
||||
|
|
@ -162,7 +160,7 @@ XML=$(cat <<EOF
|
|||
</html:html>
|
||||
EOF
|
||||
)
|
||||
expecteof "$clixon_util_xml" 0 "$XML" "$XML"
|
||||
expecteof "$clixon_util_xml -o" 0 "$XML" "$XML"
|
||||
|
||||
new "Second example 6.1 from https://www.w3.org/TR/2009/REC-xml-names-20091208"
|
||||
XML=$(cat <<EOF
|
||||
|
|
@ -175,7 +173,7 @@ XML=$(cat <<EOF
|
|||
</bk:book>
|
||||
EOF
|
||||
)
|
||||
expecteof "$clixon_util_xml" 0 "$XML" "$XML"
|
||||
expecteof "$clixon_util_xml -o" 0 "$XML" "$XML"
|
||||
|
||||
rm -rf $dir
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue