← 返回
安全合规 中文

Smoke Test Generator

Generate comprehensive API smoke test suites — categorised tests for auth, CRUD, integrations, cached vs live endpoints, with summary reporting. Use when val...
生成全面的API冒烟测试套件——包含针对认证、CRUD、集成以及缓存与实时端点的分类测试,并提供摘要报告。
nissan
安全合规 clawhub v1.0.0 1 版本 99830.2 Key: 无需
★ 0
Stars
📥 588
下载
💾 6
安装
1
版本
#latest

概述

Smoke Test Generator

A structured pattern for API smoke testing with categorised test suites and summary reporting. Adapted from a production test suite that verified 34 endpoints across auth, CRUD, cached audio, story generation, ElevenLabs, and Mistral agent APIs.

Test Categories

CategoryWhat It TestsFail =
---------
AuthLogin, token validation, protected routesNothing else works
CRUDCreate, read, update, delete operationsData layer broken
CachedPre-cached content serves correctlyDemo will fail
LiveReal API calls complete successfullyExternal dependency down
IntegrationEnd-to-end workflows across servicesPipeline broken

Pattern

import httpx
import asyncio

BASE_URL = "http://localhost:8000"
results = {"pass": 0, "fail": 0, "skip": 0}

async def test(name: str, category: str, fn):
    try:
        await fn()
        results["pass"] += 1
        print(f"  ✅ [{category}] {name}")
    except Exception as e:
        results["fail"] += 1
        print(f"  ❌ [{category}] {name}: {e}")

async def run_smoke_tests():
    async with httpx.AsyncClient(base_url=BASE_URL, timeout=30) as client:
        # Auth
        await test("Login with valid creds", "auth",
            lambda: assert_status(client.post("/login", json={"email": "test@test.com", "password": "test"}), 200))
        
        # CRUD
        await test("Create item", "crud",
            lambda: assert_status(client.post("/api/items", json={"name": "test"}), 201))
        
        # Cached
        await test("Cached content returns 200", "cached",
            lambda: assert_status(client.get("/api/cached/1"), 200))
        
        # Integration
        await test("Full pipeline completes", "integration",
            lambda: assert_status(client.post("/api/pipeline", json={...}), 200))
    
    total = results["pass"] + results["fail"]
    print(f"\n{'='*40}")
    print(f"Results: {results['pass']}/{total} passed")
    if results["fail"] > 0:
        print(f"⚠️ {results['fail']} failures — do not demo!")

Files

  • scripts/smoke_test.py — Example smoke test suite with all categories

版本历史

共 1 个版本

  • v1.0.0 当前
    2026-03-30 06:28 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

content-creation

Fact Checker

nissan
对照源数据验证 Markdown 草稿中的声明、数字和事实。适用场景:发布前审核博客文章、报告或文档的准确性。
★ 3 📥 2,096
security-compliance

OpenClaw Backup

alex3alex
备份与恢复 OpenClaw 数据。适用于创建备份、设置自动备份计划、从备份恢复或管理备份轮转。处理 ~/.openclaw 目录归档并包含适当的排除规则。
★ 89 📥 30,598
security-compliance

Skill Vetter

spclaudehome
AI智能体技能安全预审工具。安装ClawdHub、GitHub等来源技能前,检查风险信号、权限范围及可疑模式。
★ 1,212 📥 266,313