remove bad check for url and secure request
هذا الالتزام موجود في:
25
test_api.sh
25
test_api.sh
@@ -51,11 +51,6 @@ jq -c '.[]' "$TEST_FILE" | while read -r test; do
|
||||
retries=$(jq -r '.retries // 0' <<<"$test")
|
||||
follow_location=$(jq -r '.follow_location // false' <<<"$test")
|
||||
|
||||
# Validate URL
|
||||
if ! [[ "$url" =~ ^https?://[a-zA-Z0-9./?=&_-]+$ ]]; then
|
||||
echo "[$idx/$TOTAL] $name -> ERROR: Invalid URL format: $url" >&2
|
||||
continue
|
||||
fi
|
||||
|
||||
CURL_HDR_ARGS=()
|
||||
if jq -e 'type=="object"' <<<"$headers_json" >/dev/null 2>&1; then
|
||||
@@ -79,14 +74,15 @@ jq -c '.[]' "$TEST_FILE" | while read -r test; do
|
||||
http_code="0"
|
||||
latency_ms=0
|
||||
bytes=0
|
||||
use_insecure=false
|
||||
|
||||
while (( attempt <= retries )); do
|
||||
attempt=$((attempt+1))
|
||||
set +o errexit
|
||||
curl_out=$(curl -sS -w '\n%{http_code} %{time_total} %{size_download}' \
|
||||
-X "$method" "${CURL_HDR_ARGS[@]}" $CURL_INSECURE_FLAG $CURL_FOLLOW_FLAG \
|
||||
-X "$method" "${CURL_HDR_ARGS[@]}" ${use_insecure:+$CURL_INSECURE_FLAG} $CURL_FOLLOW_FLAG \
|
||||
--max-time "$TIMEOUT" \
|
||||
${body:+--data-raw} ${body:+$(printf '%s' "$body")} \
|
||||
${encoded_body:+--data-raw} ${encoded_body:+"$encoded_body"} \
|
||||
-D - \
|
||||
--output "$temp_resp" \
|
||||
"$url" 2>&1) || CURL_EXIT=$? && CURL_EXIT=${CURL_EXIT:-0}
|
||||
@@ -100,6 +96,12 @@ jq -c '.[]' "$TEST_FILE" | while read -r test; do
|
||||
|
||||
if [[ "$CURL_EXIT" -ne 0 ]]; then
|
||||
last_err="curl_failed_exit_${CURL_EXIT}: $(printf '%s' "$curl_out" | head -n1)"
|
||||
# Retry with --insecure for SSL errors
|
||||
if [[ "$CURL_EXIT" -eq 56 && "$use_insecure" == "false" ]]; then
|
||||
echo "[$idx/$TOTAL] $name attempt $attempt: SSL error detected, retrying with --insecure" >&2
|
||||
use_insecure=true
|
||||
continue
|
||||
fi
|
||||
echo "[$idx/$TOTAL] $name attempt $attempt: curl error ($CURL_EXIT): $last_err" >&2
|
||||
if (( attempt <= retries )); then sleep 1; continue; else break; fi
|
||||
fi
|
||||
@@ -112,6 +114,11 @@ jq -c '.[]' "$TEST_FILE" | while read -r test; do
|
||||
if [[ "$http_code" =~ ^$prefix[0-9][0-9]$ ]]; then ok_status=true; fi
|
||||
fi
|
||||
|
||||
if [[ "$CURL_EXIT" -ne 0 && "$http_code" == "$expect_status" ]]; then
|
||||
CURL_EXIT=0
|
||||
last_err=""
|
||||
fi
|
||||
|
||||
contains_ok=true
|
||||
if [[ -n "$expect_contains" ]]; then
|
||||
if ! grep -qF "$expect_contains" "$temp_resp"; then
|
||||
@@ -131,6 +138,10 @@ jq -c '.[]' "$TEST_FILE" | while read -r test; do
|
||||
[[ "$latency_ms" -gt "$max_latency_ms" ]] && reasons+=("slow_response:${latency_ms}ms>${max_latency_ms}ms")
|
||||
last_err=$(IFS=','; echo "${reasons[*]}")
|
||||
echo "[$idx/$TOTAL] $name attempt $attempt: FAILED - $last_err" >&2
|
||||
if [[ -s "$temp_resp" ]]; then
|
||||
echo "Response body:" >&2
|
||||
cat "$temp_resp" >&2
|
||||
fi
|
||||
fi
|
||||
|
||||
if (( attempt <= retries )); then sleep 1; continue; else break; fi
|
||||
|
||||
المرجع في مشكلة جديدة
حظر مستخدم