I am working on a script which is a test suite that would check all invalid headers case using curl.
I created a bunch of functions which allows me to construct headers tupe (field_name: field_value) with default testing value.
build_foo_header() {
local FOO_KN=${1:-'X-App-Name'}
local FOO_KV=${2:-'MyApp'}
echo $FOO_KN: $FOO_KV
}
I would like to create some arrays in functions with either missing headers or headers with invalid values to test my app behavior.
So i created a sample function as it :
build_headers_invalid_X_App_Name_Value() {
HEADERS=()
# this array should contain all other required headers
HEADERS[0]=$(build_foo_header X-App-Name BadValue)
# HEADERS[1]= header that is required with default value
# and son on for all the remaning required headers
echo "${HEADERS[@]/#/-H}"
}
However i can't get curl how to pass that array to curl ?
$(curl $(build_headers_invalid_X_App_Name_Value) myURl)
Seems to send a request to the first header in the HEADERS array.
I have approximatively 10 required headers that's why I would like to script it that way.