← 返回
未分类

HTTP API Test Runner

Build 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.
http-api-test-runner 用于把一次性接口调试转成可复用的 API 测试用例与校验脚本,统一输出 PASS/FAIL/SKIP 报告。支持状态码、JSON 字段、列表断言及鉴权场景,并提供异步轮询等复杂流程示例,适合联调、自测与回归验证。
may
未分类 community v1.0.2 3 版本 100000 Key: 无需
★ 0
Stars
📥 12
下载
💾 0
安装
3
版本
#latest

概述

HTTP API Test Runner

Use this skill to turn one-off HTTP checks into reusable .http cases and a runnable verification script.

Prerequisites

Required runtime dependencies:

  • bash
  • curl
  • python3

Quick self-check:

bash --version
curl --version
python3 --version

Generate two artifacts by default:

  • .api-tests.http
  • .api-verify.sh

The .http file is the source of truth. The shell script executes the cases, prints readable PASS/FAIL/SKIP output, and exits non-zero when any non-skipped case fails.

Quick Start

  1. Collect only the missing inputs: host, method, auth, request data, cases, and expected results.
  2. Choose a starting point:
    • Use templates/ for a new endpoint.
    • Use examples/ when the endpoint looks similar to an existing example.
    • Use references/complex-scenarios.md for multi-step or advanced validation.
  3. Generate or update:
    • .api-tests.http
    • .api-verify.sh
  4. Validate the generated script:
bash -n './<feature>.api-verify.sh'
bash './<feature>.api-verify.sh'
COOKIE='full Cookie header' AUTH_TOKEN='token value' bash './<feature>.api-verify.sh'
# optional for unstable networks:
MAX_TIME=40 RETRY_COUNT=2 RETRY_DELAY=1 bash './<feature>.api-verify.sh'
  1. If cases fail, classify the problem before editing assertions:
    • auth mismatch
    • request shape mismatch
    • environment or fixture mismatch
    • business assertion mismatch

See references/debugging-cookbook.md for the failure checklist.

Need a minimal runnable path first: see GET_STARTED.md.

What To Collect

Ask only for fields the user did not already provide.

InputNeeded for
------
Base URL / hostResolving request targets
HTTP methodBuilding the request
AuthenticationCookie, bearer, custom headers, or none
Request dataPath params, query params, JSON body, form body
CasesPositive, negative, auth failure, boundary checks
Expected resultsStatus, JSON path, marker text, list membership, error behavior
Output preferenceBrief summary, key fields, raw response save path

For cookie-based tests, tell the user to copy the full Cookie: request header from a successful browser Network request. Do not reconstruct cookies from the storage panel.

Generated comments and final usage notes should follow the user's language.

Choose Your Starting Point

  • templates/basic.api-tests.txt
  • Fastest path for a new endpoint.
  • Includes a small set of common variables and assertions.
  • templates/basic.api-verify.sh
  • Runnable shell script with timeout handling, env-based secrets, and formatted output.
  • examples/resource-detail/
  • Resource detail lookup with cookie auth and JSON field assertions.
  • examples/auth-login-required/
  • Unauthenticated and invalid-auth cases.
  • examples/list-assertions/
  • List projection, membership, and absence checks.
  • examples/async-job-polling/
  • Submit -> poll -> verify pattern with a runnable pre-step script for async workflows.

Note: publishable skill assets use .api-tests.txt to satisfy upload restrictions, while generated runtime artifacts should still use .api-tests.http.

Scenario Index

GoalStart with
------
Resource detail/config lookupexamples/resource-detail/
Authentication failure checksexamples/auth-login-required/
List membership assertionsexamples/list-assertions/
Async submit + poll + verifyexamples/async-job-polling/
New endpoint from scratchtemplates/basic.api-tests.txt + templates/basic.api-verify.sh

Artifact Contract

The generated .http file should:

  • declare variables such as @host, @cookie, @token, @resourceId
  • use ### titles for each case
  • keep one request per case
  • add explicit expect.* comments
  • keep real secrets out of the file by default

The generated shell script should:

  • read the .http file
  • resolve {{variable}} placeholders
  • accept secrets from environment variables
  • print PASS/FAIL/SKIP output for each case
  • print a summary line
  • exit non-zero if any non-skipped case fails

Safety Rules

  • Do not commit real cookies, tokens, passwords, or internal credentials.
  • Use placeholders such as @cookie = and @token = .
  • When secrets are missing, authenticated cases should SKIP with a clear reason instead of crashing the parser.
  • Before publishing or committing generated artifacts, run a lightweight secret scan:
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>

Reference Map

  • Fastest first run: GET_STARTED.md
  • Assertion reference: references/assertion-cheatsheet.md
  • Complex flows and advanced validation: references/complex-scenarios.md
  • Failure diagnosis and triage: references/debugging-cookbook.md
  • FAQ: references/faq.md
  • Lightweight publishable example: references/http_test_artifact_example.md

Default Running Checks

After generating artifacts, run:

bash -n './<feature>.api-verify.sh'
bash './<feature>.api-verify.sh'
COOKIE='full Cookie header' AUTH_TOKEN='token value' bash './<feature>.api-verify.sh'

Interpretation:

  • bash -n catches shell syntax errors.
  • Running without secrets should verify parsing and expected SKIP behavior.
  • Running with secrets should verify actual API behavior and assertions.

版本历史

共 3 个版本

  • v1.0.2 添加FAQ,精简内容 当前
    2026-06-09 15:26 安全 安全
  • v1.0.1 增加新示例
    2026-06-09 14:48 安全 安全
  • v1.0.0 Initial release
    2026-06-08 11:45 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

developer-tools

Github

steipete
使用 `gh` CLI 与 GitHub 交互,通过 `gh issue`、`gh pr`、`gh run` 和 `gh api` 管理议题、PR、CI 运行及高级查询。
★ 672 📥 324,767
ai-intelligence

Self-Improving + Proactive Agent

ivangdavila
自我反思+自我批评+自我学习+自组织记忆。智能体评估自身工作、发现错误并持续改进。
★ 1,366 📥 319,412
ai-intelligence

self-improving agent

pskoett
捕获经验教训、错误及修正内容,以实现持续改进。适用于以下场景:(1)命令或操作意外失败;(2)用户纠正Claude(如“不,那不对……”“实际上……”);(3)用户请求的功能不存在;(4)外部API或工具出现故障;(5)Claude发现自身
★ 4,067 📥 803,147