mirror of
https://github.com/servalproject/serval-dna.git
synced 2024-12-21 06:03:12 +00:00
Refactor: define extract_http_header() in testdefs.sh
Also http_unquote_string()
This commit is contained in:
parent
45c6b9ecfa
commit
858a7fc577
@ -533,6 +533,26 @@ assert_rhizome_received() {
|
||||
done
|
||||
}
|
||||
|
||||
# Extract a value from an HTTP header
|
||||
extract_http_header() {
|
||||
local __var="$1"
|
||||
local __headerfile="$2"
|
||||
local __header="$3"
|
||||
local __rexp="$4"
|
||||
local __value=$($SED -n -e "/^$__header:[ $HT]*$__rexp$CR\$/s/^$__header:[ $HT]*\(.*\)$CR\$/\1/p" "$__headerfile")
|
||||
assert --message="$__headerfile contains valid '$__header' header" \
|
||||
--dump-on-fail="$__headerfile" \
|
||||
[ -n "$__value" ]
|
||||
[ -n "$__var" ] && eval $__var=\"\$__value\"
|
||||
}
|
||||
|
||||
# Parse an HTTP quoted-string
|
||||
http_unquote_string() {
|
||||
local __var="$1"
|
||||
local __unq="$(eval echo '"${'$__var'}"' | sed -e 's/^"//' -e 's/"$//' -e 's/\\\(.\)/\1/g')"
|
||||
eval $__var=\"\$__unq\"
|
||||
}
|
||||
|
||||
rhizome_add_bundles() {
|
||||
local encrypted=false
|
||||
case "$1" in
|
||||
|
@ -532,24 +532,6 @@ test_RhizomePayloadDecryptedNonexistPayload() {
|
||||
assertJqGrep --ignore-case http.content '.rhizome_payload_status_message' "payload new to store"
|
||||
}
|
||||
|
||||
extract_http_header() {
|
||||
local __var="$1"
|
||||
local __headerfile="$2"
|
||||
local __header="$3"
|
||||
local __rexp="$4"
|
||||
local __value=$($SED -n -e "/^$__header:[ $HT]*$__rexp$CR\$/s/^$__header:[ $HT]*\(.*\)$CR\$/\1/p" "$__headerfile")
|
||||
assert --message="$__headerfile contains valid '$__header' header" \
|
||||
--dump-on-fail="$__headerfile" \
|
||||
[ -n "$__value" ]
|
||||
[ -n "$__var" ] && eval $__var=\"\$__value\"
|
||||
}
|
||||
|
||||
http_unquote_string() {
|
||||
local __var="$1"
|
||||
local __unq="$(eval echo '"${'$__var'}"' | sed -e 's/^"//' -e 's/"$//' -e 's/\\\(.\)/\1/g')"
|
||||
eval $__var=\"\$__unq\"
|
||||
}
|
||||
|
||||
doc_RhizomeInsert="HTTP RESTful insert new Rhizome bundles"
|
||||
setup_RhizomeInsert() {
|
||||
IDENTITY_COUNT=3
|
||||
|
Loading…
Reference in New Issue
Block a user