Split test aws_sig test into ok/failed

This commit is contained in:
Fabrice Reix 2023-09-02 10:16:24 +02:00
parent 715a56a208
commit b1e2e1624c
No known key found for this signature in database
GPG Key ID: BF5213154B2E7155
6 changed files with 30 additions and 22 deletions

View File

@ -0,0 +1,6 @@
error: HTTP connection
--> tests_ok/aws_sigv4.hurl:1:6
|
1 | POST http://localhost:8000/aws-sigv4
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Option aws-sigv4 requires libcurl version 7.75.0 or higher
|

View File

@ -0,0 +1 @@
3

View File

@ -0,0 +1,15 @@
#!/bin/bash
set -Eeuo pipefail
set +eo pipefail
# Check error message when curl/libcurl on this system does not support --aws-sigv4
# simply ignore test if option is available on the system
# FIXME: remove this test once all integration test targets have aws-sigv4 support in libcurl
if curl --aws-sigv4 2>&1 | grep -qv 'option --aws-sigv4: is unknown'; then
cat tests_failed/aws_sigv4.err >&2
exit 3
fi
set -Eeuo pipefail
hurl --user someAccessKeyId:someSecretKey tests_ok/aws_sigv4.hurl

View File

@ -1 +0,0 @@
Received SigV4 Authorization header

View File

@ -10,4 +10,4 @@ def aws_sigv4():
r"^AWS4-HMAC-SHA256 Credential=someAccessKeyId/\d+/eu-central-1/hurltest/aws4_request, SignedHeaders=\S+, Signature=[a-f0-9]+$",
auth,
)
return "Received SigV4 Authorization header"
return ""

View File

@ -1,26 +1,13 @@
#!/bin/bash
set -Eeuo pipefail
set +eo pipefail
# if curl/libcurl on this system does not support --aws-sigv4
# simply ignore test
# FIXME: remove this workaround once all integration test targets have aws-sigv4 support in libcurl
#
# for integration test targets that come with a too old libcurl, we accept the appropriate error
# message and fake the correct result (but only if `curl` doesn't know about `--aws-sigv4` either!).
set +e
output_curl=$(curl --aws-sigv4 2>&1)
output_hurl=$(hurl --user someAccessKeyId:someSecretKey tests_ok/aws_sigv4.hurl 2>&1 )
rc="$?"
set -e
if echo "$output_curl" | grep -q 'option --aws-sigv4: is unknown'; then
# curl on this system does not support --aws-sigv4, so check for the expected error message
if echo "$output_hurl" | grep -q "Option aws-sigv4 requires libcurl version 7.75.0 or higher"; then
cat tests_ok/aws_sigv4.out
exit 0
fi
if curl --aws-sigv4 2>&1 | grep -q 'option --aws-sigv4: is unknown'; then
exit 0
fi
echo -n "$output_hurl"
exit "$rc"
set -Eeuo pipefail
hurl --user someAccessKeyId:someSecretKey tests_ok/aws_sigv4.hurl