Install
openclaw skills install http-testBuild reusable HTTP API test artifacts from user-provided endpoints, authentication, request data, expected results, and validation rules. Use this skill when the user wants to create .http files, run HTTP/REST API checks, replay browser or curl requests, validate JSON fields or response markers, compare expected vs actual responses, or generate formatted PASS/FAIL API test reports.
openclaw skills install http-testUse this skill to turn ad hoc HTTP endpoint checks into repeatable .http cases and a runnable formatter script.
The user provides endpoints, authentication, request data, scenarios, and expected results. Produce artifacts that can be rerun and that print a readable PASS/FAIL report instead of raw response dumps.
Use this skill when the user asks to:
.http tests for an HTTP/REST API.Ask only for missing information. Do not ask for values already provided.
Collect:
https://api.example.test.GET when unspecified.For cookie-based tests, tell the user to copy the complete request cookie from a successful browser Network request:
Please copy the full `Cookie:` request header from the browser Network panel for a successful target request. Do not reconstruct cookies only from the Application/Storage panel, because HttpOnly, path, domain, and host-bound cookies may be missed.
Use the user's language for generated file comments and final instructions.
Create two files by default, near the user's existing test or technical docs unless they specify another location:
<feature>.api-tests.http
<feature>.api-verify.sh
If the project already uses another naming style, follow it.
The .http file is the source of truth. It should contain:
@host, @resourceId, @cookie, @token.###.expect.* comments for assertions.The formatter script should:
.http file.{{host}}, {{resourceId}}, {{cookie}}.Prefer bash + curl for portability. For JSON parsing, prefer python3 embedded snippets over mandatory jq, unless the repo already depends on jq.
Default behavior:
.http, such as @cookie = <set via COOKIE> or @token = <set via AUTH_TOKEN>.COOKIE, AUTH_TOKEN, ADMIN_COOKIE.[SKIP] message instead of failing parsing.If the user explicitly asks to embed cookies or tokens for local convenience:
This script temporarily embeds real credentials for local testing only. Do not commit, share, or publish it.
Before publishing or committing, check for secrets and internal identifiers with searches such as:
rg -n "password|secret|session_id|auth_token|access_token|refresh_token" <artifact-dir>
rg -n "Authorization: Bearer [A-Za-z0-9._-]+|C[o]okie: [A-Za-z0-9_%-]+=" <artifact-dir>
Prefer explicit assertions in .http comments. Title-based inference is allowed only as a fallback.
Supported assertion comments:
# expect.status = 200
# expect.errno = 0
# expect.errno_not = 0
# expect.contains = TARGET_MARKER
# expect.not_contains = ERROR_MARKER
# expect.json_path = data.status
# expect.equals = enabled
# expect.exists = data.items[0].id
# expect.absent = data.deprecatedField
# expect.list_contains = data.items[].code:TARGET_CODE
# expect.list_not_contains = data.items[].code:TARGET_CODE
# expect.save = tmp/case-1.response.json
# output.fields = code,message,data.id,data.status
Rules:
expect.status validates HTTP status.expect.errno and expect.errno_not apply to APIs that expose an errno-style field.expect.contains and expect.not_contains search the response text.expect.json_path + expect.equals validates one JSON field.expect.exists and expect.absent validate JSON path presence.expect.list_contains validates a projected list path contains a value.expect.save optionally saves raw response for debugging.output.fields controls key fields printed in the formatted report.If an API uses code, status, error, or another convention instead of errno, adapt the generated assertions and output names to the API.
Use this structure for common GET and POST cases:
### <feature> API tests
#
# Usage:
# 1. Confirm the target environment has the code/config under test.
# 2. Export secrets when needed:
# COOKIE='full Cookie header' AUTH_TOKEN='token value' bash './<feature>.api-verify.sh'
# 3. Run the formatter script to see PASS/FAIL output.
@host = https://api.example.test
@resourceId = sample-123
@cookie = <set via COOKIE>
@token = <set via AUTH_TOKEN>
### Case-1 GET positive: resource should be enabled
# auth = cookie
# expect.status = 200
# expect.json_path = data.status
# expect.equals = enabled
# output.fields = code,message,data.id,data.status
GET {{host}}/v1/resources/{{resourceId}}
Cookie: {{cookie}}
### Case-2 GET negative: missing resource should return error
# expect.status = 404
# expect.contains = not_found
GET {{host}}/v1/resources/missing-id
### Case-3 POST positive: create should return success
# auth = bearer
# expect.status = 200
# expect.json_path = code
# expect.equals = 0
POST {{host}}/v1/resources
Content-Type: application/json
Authorization: Bearer {{token}}
{
"name": "sample"
}
The formatter script should print enough information to diagnose failures without opening raw JSON:
[PASS] Case-1 GET positive: resource should be enabled
URL: https://api.example.test/v1/resources/sample-123
method: GET
expectation: json_path data.status == enabled
HTTP=200 cost=123ms
key fields: code=0,message='',data.id='sample-123',data.status='enabled'
[FAIL] Case-2 GET negative: missing resource should return error
URL: https://api.example.test/v1/resources/missing-id
method: GET
expectation: contains not_found
HTTP=200 cost=98ms
reason: expected HTTP status 404 but got 200
Summary: PASS=1 FAIL=1 SKIP=0
For non-JSON responses, print status, headers or content type when useful, response size, and text marker results.
When generating the formatter script:
.http file.GET, POST, PUT, PATCH, and DELETE when present..http case.curl --silent --show-error --location --max-time 20.After creating artifacts:
bash -n './<feature>.api-verify.sh'
bash './<feature>.api-verify.sh'
COOKIE='full Cookie header' AUTH_TOKEN='token value' bash './<feature>.api-verify.sh'
If authenticated cases fail or return login errors:
Cookie: or Authorization: request header from a successful Network request.If a positive case does not contain the expected marker:
If list validation appears to pass but the displayed item looks unrelated:
Before finishing:
.http and script contain the same cases.