Skip to content

Conversation

@ggzengel
Copy link

@ggzengel ggzengel commented May 15, 2025

Add --base64 option to decode base64-encoded JSON responses

  • Introduced the --base64 argument to the CLI.
  • When specified, the plugin decodes the HTTP response body from base64 before parsing it as JSON.
  • Maintains existing behavior if --base64 is not used.

Example usage with Passwork

Basic call
./check_http_json.py -vv -H passwork.intranet -p api/v1/app/health-check -X POST \
  --header '{"Accept": "application/json", "Content-Type": "application/json"}' \
  --data '{"token": "0123456789ABCD"}' --ssl --base64

Passwork responds with:

{
  "format": "base64",
  "content": "eyJzdGF0ZXMiOnsibW9uZ29kYiI6Im9rIiwidGFza3MiOiJvayJ9LCJlcnJvcnMiOltdfQ=="
}

The script decodes the 'content' field and parses the resulting JSON.

Advanced check with key assertions
./check_http_json.py -vv -H passwork.intranet -p api/v1/app/health-check -X POST \
  --header '{"Accept": "application/json", "Content-Type": "application/json"}' \
  --data '{"token": "0123456789ABCD"}' --ssl --base64 content \
  -Q states.mongodb,ok states.tasks,ok errors,[]

Decoded JSON:

{
  "states": {
    "mongodb": "ok",
    "tasks": "ok"
  },
  "errors": []
}

Example output:

OK: Status OK.

Add --base64 option to decode base64-encoded JSON responses

- Introduced the --base64 argument to the CLI.
- When specified, the plugin decodes the HTTP response body from base64 before parsing it as JSON.
- Maintains existing behavior if --base64 is not used.

Example usage with Passwork:
  ./check_http_json.py -vv -H passwork.intranet -p api/v1/app/health-check -X POST \
    --header '{"Accept": "application/json", "Content-Type": "application/json"}' \
    --data '{"token": "0123456789ABCD"}' --ssl --base64

  Passwork responds with:
    {
      "format": "base64",
      "content": "eyJzdGF0ZXMiOnsibW9uZ29kYiI6Im9rIiwidGFza3MiOiJvayJ9LCJlcnJvcnMiOltdfQ=="
    }

  The script decodes the 'content' field and parses the resulting JSON.

# ./check_http_json.py -vv -H passwork.intranet -p api/v1/app/health-check -X POST --header '{"Accept": "application/json", "Content-Type": "application/json"}' --data '{"token": "0123456789ABCD"}' --ssl --base64 content -Q states.mongodb,ok states.tasks,ok errors,[] 
{
  "states": {
    "mongodb": "ok",
    "tasks": "ok"
  },
  "errors": []
}
OK: Status OK.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant