[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6G1K5JR9PMK0F5XGVRTVG9E":3,"skill-same:01M6G1K5JR9PMK0F5XGVRTVG9E":50},{"skillNo":4,"name":5,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":15,"categories":16,"keywords":17,"publishedAt":23,"linkOnly":24,"markdownContent":25,"markdownBody":25,"frontMatter":26,"refName":27,"commitSha":28,"skillDirectory":29,"forksCount":30,"repositoryHtmlUrl":31,"repositoryHomepageUrl":6,"ownerHtmlUrl":32,"ownerBlogUrl":33,"ownerDescription":34,"updatedAt":35,"install":36,"resources":49},"01M6G1K5JR9PMK0F5XGVRTVG9E","api-test-suite-builder",null,"oabdelmaksoud\u002FAgention","oabdelmaksoud","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F50699149?v=4","01M6D5CVVN778ZCDP1WHS816SP","Omar Abdelmaksoud","01M6D8A4TE76V3DCSH3D94VG1V",2,"MIT","https:\u002F\u002Fgithub.com\u002Foabdelmaksoud\u002FAgention\u002Fblob\u002Fmain\u002Fupstream-sync\u002Fwork\u002Fclaude-skills\u002Fengineering\u002Fapi-test-suite-builder\u002FSKILL.md",[],[18,19,20,21,22],"test","api","api test suite builder","test suite","builder","2026-11-10 10:12:30",false,"# API Test Suite Builder\n\n**Tier:** POWERFUL\n**Category:** Engineering\n**Domain:** Testing \u002F API Quality\n\n---\n\n## Overview\n\nScans API route definitions across frameworks (Next.js App Router, Express, FastAPI, Django REST) and\nauto-generates comprehensive test suites covering auth, input validation, error codes, pagination, file\nuploads, and rate limiting. Outputs ready-to-run test files for Vitest+Supertest (Node) or Pytest+httpx\n(Python).\n\n---\n\n## Core Capabilities\n\n- **Route detection** — scan source files to extract all API endpoints\n- **Auth coverage** — valid\u002Finvalid\u002Fexpired tokens, missing auth header\n- **Input validation** — missing fields, wrong types, boundary values, injection attempts\n- **Error code matrix** — 400\u002F401\u002F403\u002F404\u002F422\u002F500 for each route\n- **Pagination** — first\u002Flast\u002Fempty\u002Foversized pages\n- **File uploads** — valid, oversized, wrong MIME type, empty\n- **Rate limiting** — burst detection, per-user vs global limits\n\n---\n\n## When to Use\n\n- New API added — generate test scaffold before writing implementation (TDD)\n- Legacy API with no tests — scan and generate baseline coverage\n- API contract review — verify existing tests match current route definitions\n- Pre-release regression check — ensure all routes have at least smoke tests\n- Security audit prep — generate adversarial input tests\n\n---\n\n## Route Detection\n\n### Next.js App Router\n```bash\n# Find all route handlers\nfind .\u002Fapp\u002Fapi -name \"route.ts\" -o -name \"route.js\" | sort\n\n# Extract HTTP methods from each route file\ngrep -rn \"export async function\\|export function\" app\u002Fapi\u002F**\u002Froute.ts | \\\n  grep -oE \"(GET|POST|PUT|PATCH|DELETE|HEAD|OPTIONS)\" | sort -u\n\n# Full route map\nfind .\u002Fapp\u002Fapi -name \"route.ts\" | while read f; do\n  route=$(echo $f | sed 's|.\u002Fapp||' | sed 's|\u002Froute.ts||')\n  methods=$(grep -oE \"export (async )?function (GET|POST|PUT|PATCH|DELETE)\" \"$f\" | \\\n    grep -oE \"(GET|POST|PUT|PATCH|DELETE)\")\n  echo \"$methods $route\"\ndone\n```\n\n### Express\n```bash\n# Find all router files\nfind .\u002Fsrc -name \"*.ts\" -o -name \"*.js\" | xargs grep -l \"router\\.\\(get\\|post\\|put\\|delete\\|patch\\)\" 2>\u002Fdev\u002Fnull\n\n# Extract routes with line numbers\ngrep -rn \"router\\.\\(get\\|post\\|put\\|delete\\|patch\\)\\|app\\.\\(get\\|post\\|put\\|delete\\|patch\\)\" \\\n  src\u002F --include=\"*.ts\" | grep -oE \"(get|post|put|delete|patch)\\(['\\\"][^'\\\"]*['\\\"]\"\n\n# Generate route map\ngrep -rn \"router\\.\\|app\\.\" src\u002F --include=\"*.ts\" | \\\n  grep -oE \"\\.(get|post|put|delete|patch)\\(['\\\"][^'\\\"]+['\\\"]\" | \\\n  sed \"s\u002F\\.\\(.*\\)('\\(.*\\)'\u002F\\U\\1 \\2\u002F\"\n```\n\n### FastAPI\n```bash\n# Find all route decorators\ngrep -rn \"@app\\.\\|@router\\.\" . --include=\"*.py\" | \\\n  grep -E \"@(app|router)\\.(get|post|put|delete|patch)\"\n\n# Extract with path and function name\ngrep -rn \"@\\(app\\|router\\)\\.\\(get\\|post\\|put\\|delete\\|patch\\)\" . --include=\"*.py\" | \\\n  grep -oE \"@(app|router)\\.(get|post|put|delete|patch)\\(['\\\"][^'\\\"]*['\\\"]\"\n```\n\n### Django REST Framework\n```bash\n# urlpatterns extraction\ngrep -rn \"path\\|re_path\\|url(\" . --include=\"*.py\" | grep \"urlpatterns\" -A 50 | \\\n  grep -E \"path\\(['\\\"]\" | grep -oE \"['\\\"][^'\\\"]+['\\\"]\" | head -40\n\n# ViewSet router registration\ngrep -rn \"router\\.register\\|DefaultRouter\\|SimpleRouter\" . --include=\"*.py\"\n```\n\n---\n\n## Test Generation Patterns\n\n### Auth Test Matrix\n\nFor every authenticated endpoint, generate:\n\n| Test Case | Expected Status |\n|-----------|----------------|\n| No Authorization header | 401 |\n| Invalid token format | 401 |\n| Valid token, wrong user role | 403 |\n| Expired JWT token | 401 |\n| Valid token, correct role | 2xx |\n| Token from deleted user | 401 |\n\n### Input Validation Matrix\n\nFor every POST\u002FPUT\u002FPATCH endpoint with a request body:\n\n| Test Case | Expected Status |\n|-----------|----------------|\n| Empty body `{}` | 400 or 422 |\n| Missing required fields (one at a time) | 400 or 422 |\n| Wrong type (string where int expected) | 400 or 422 |\n| Boundary: value at min-1 | 400 or 422 |\n| Boundary: value at min | 2xx |\n| Boundary: value at max | 2xx |\n| Boundary: value at max+1 | 400 or 422 |\n| SQL injection in string field | 400 or 200 (sanitized) |\n| XSS payload in string field | 400 or 200 (sanitized) |\n| Null values for required fields | 400 or 422 |\n\n---\n\n## Example Test Files\n\n### Example 1 — Node.js: Vitest + Supertest (Next.js API Route)\n\n```typescript\n\u002F\u002F tests\u002Fapi\u002Fusers.test.ts\nimport { describe, it, expect, beforeAll, afterAll } from 'vitest'\nimport request from 'supertest'\nimport { createServer } from '@\u002Ftest\u002Fhelpers\u002Fserver'\nimport { generateJWT, generateExpiredJWT } from '@\u002Ftest\u002Fhelpers\u002Fauth'\nimport { createTestUser, cleanupTestUsers } from '@\u002Ftest\u002Fhelpers\u002Fdb'\n\nconst app = createServer()\n\ndescribe('GET \u002Fapi\u002Fusers\u002F:id', () => {\n  let validToken: string\n  let adminToken: string\n  let testUserId: string\n\n  beforeAll(async () => {\n    const user = await createTestUser({ role: 'user' })\n    const admin = await createTestUser({ role: 'admin' })\n    testUserId = user.id\n    validToken = generateJWT(user)\n    adminToken = generateJWT(admin)\n  })\n\n  afterAll(async () => {\n    await cleanupTestUsers()\n  })\n\n  \u002F\u002F --- Auth tests ---\n  it('returns 401 with no auth header', async () => {\n    const res = await request(app).get(`\u002Fapi\u002Fusers\u002F${testUserId}`)\n    expect(res.status).toBe(401)\n    expect(res.body).toHaveProperty('error')\n  })\n\n  it('returns 401 with malformed token', async () => {\n    const res = await request(app)\n      .get(`\u002Fapi\u002Fusers\u002F${testUserId}`)\n      .set('Authorization', 'Bearer not-a-real-jwt')\n    expect(res.status).toBe(401)\n  })\n\n  it('returns 401 with expired token', async () => {\n    const expiredToken = generateExpiredJWT({ id: testUserId })\n    const res = await request(app)\n      .get(`\u002Fapi\u002Fusers\u002F${testUserId}`)\n      .set('Authorization', `Bearer ${expiredToken}`)\n    expect(res.status).toBe(401)\n    expect(res.body.error).toMatch(\u002Fexpired\u002Fi)\n  })\n\n  it('returns 403 when accessing another user\\'s profile without admin', async () => {\n    const otherUser = await createTestUser({ role: 'user' })\n    const otherToken = generateJWT(otherUser)\n    const res = await request(app)\n      .get(`\u002Fapi\u002Fusers\u002F${testUserId}`)\n      .set('Authorization', `Bearer ${otherToken}`)\n    expect(res.status).toBe(403)\n    await cleanupTestUsers([otherUser.id])\n  })\n\n  it('returns 200 with valid token for own profile', async () => {\n    const res = await request(app)\n      .get(`\u002Fapi\u002Fusers\u002F${testUserId}`)\n      .set('Authorization', `Bearer ${validToken}`)\n    expect(res.status).toBe(200)\n    expect(res.body).toMatchObject({ id: testUserId })\n    expect(res.body).not.toHaveProperty('password')\n    expect(res.body).not.toHaveProperty('hashedPassword')\n  })\n\n  it('returns 404 for non-existent user', async () => {\n    const res = await request(app)\n      .get('\u002Fapi\u002Fusers\u002F00000000-0000-0000-0000-000000000000')\n      .set('Authorization', `Bearer ${adminToken}`)\n    expect(res.status).toBe(404)\n  })\n\n  \u002F\u002F --- Input validation ---\n  it('returns 400 for invalid UUID format', async () => {\n    const res = await request(app)\n      .get('\u002Fapi\u002Fusers\u002Fnot-a-uuid')\n      .set('Authorization', `Bearer ${adminToken}`)\n    expect(res.status).toBe(400)\n  })\n})\n\ndescribe('POST \u002Fapi\u002Fusers', () => {\n  let adminToken: string\n\n  beforeAll(async () => {\n    const admin = await createTestUser({ role: 'admin' })\n    adminToken = generateJWT(admin)\n  })\n\n  afterAll(cleanupTestUsers)\n\n  \u002F\u002F --- Input validation ---\n  it('returns 422 when body is empty', async () => {\n    const res = await request(app)\n      .post('\u002Fapi\u002Fusers')\n      .set('Authorization', `Bearer ${adminToken}`)\n      .send({})\n    expect(res.status).toBe(422)\n    expect(res.body.errors).toBeDefined()\n  })\n\n  it('returns 422 when email is missing', async () => {\n    const res = await request(app)\n      .post('\u002Fapi\u002Fusers')\n      .set('Authorization', `Bearer ${adminToken}`)\n      .send({ name: 'Test User', role: 'user' })\n    expect(res.status).toBe(422)\n    expect(res.body.errors).toContainEqual(\n      expect.objectContaining({ field: 'email' })\n    )\n  })\n\n  it('returns 422 for invalid email format', async () => {\n    const res = await request(app)\n      .post('\u002Fapi\u002Fusers')\n      .set('Authorization', `Bearer ${adminToken}`)\n      .send({ email: 'not-an-email', name: 'Test', role: 'user' })\n    expect(res.status).toBe(422)\n  })\n\n  it('returns 422 for SQL injection attempt in email field', async () => {\n    const res = await request(app)\n      .post('\u002Fapi\u002Fusers')\n      .set('Authorization', `Bearer ${adminToken}`)\n      .send({ email: \"' OR '1'='1\", name: 'Hacker', role: 'user' })\n    expect(res.status).toBe(422)\n  })\n\n  it('returns 409 when email already exists', async () => {\n    const existing = await createTestUser({ role: 'user' })\n    const res = await request(app)\n      .post('\u002Fapi\u002Fusers')\n      .set('Authorization', `Bearer ${adminToken}`)\n      .send({ email: existing.email, name: 'Duplicate', role: 'user' })\n    expect(res.status).toBe(409)\n  })\n\n  it('creates user successfully with valid data', async () => {\n    const res = await request(app)\n      .post('\u002Fapi\u002Fusers')\n      .set('Authorization', `Bearer ${adminToken}`)\n      .send({ email: 'newuser@example.com', name: 'New User', role: 'user' })\n    expect(res.status).toBe(201)\n    expect(res.body).toHaveProperty('id')\n    expect(res.body.email).toBe('newuser@example.com')\n    expect(res.body).not.toHaveProperty('password')\n  })\n})\n\ndescribe('GET \u002Fapi\u002Fusers (pagination)', () => {\n  let adminToken: string\n\n  beforeAll(async () => {\n    const admin = await createTestUser({ role: 'admin' })\n    adminToken = generateJWT(admin)\n    \u002F\u002F Create 15 test users for pagination\n    await Promise.all(Array.from({ length: 15 }, (_, i) =>\n      createTestUser({ email: `pagtest${i}@example.com` })\n    ))\n  })\n\n  afterAll(cleanupTestUsers)\n\n  it('returns first page with default limit', async () => {\n    const res = await request(app)\n      .get('\u002Fapi\u002Fusers')\n      .set('Authorization', `Bearer ${adminToken}`)\n    expect(res.status).toBe(200)\n    expect(res.body.data).toBeInstanceOf(Array)\n    expect(res.body).toHaveProperty('total')\n    expect(res.body).toHaveProperty('page')\n    expect(res.body).toHaveProperty('pageSize')\n  })\n\n  it('returns empty array for page beyond total', async () => {\n    const res = await request(app)\n      .get('\u002Fapi\u002Fusers?page=9999')\n      .set('Authorization', `Bearer ${adminToken}`)\n    expect(res.status).toBe(200)\n    expect(res.body.data).toHaveLength(0)\n  })\n\n  it('returns 400 for negative page number', async () => {\n    const res = await request(app)\n      .get('\u002Fapi\u002Fusers?page=-1')\n      .set('Authorization', `Bearer ${adminToken}`)\n    expect(res.status).toBe(400)\n  })\n\n  it('caps pageSize at maximum allowed value', async () => {\n    const res = await request(app)\n      .get('\u002Fapi\u002Fusers?pageSize=9999')\n      .set('Authorization', `Bearer ${adminToken}`)\n    expect(res.status).toBe(200)\n    expect(res.body.data.length).toBeLessThanOrEqual(100)\n  })\n})\n```\n\n---\n\n### Example 2 — Node.js: File Upload Tests\n\n```typescript\n\u002F\u002F tests\u002Fapi\u002Fuploads.test.ts\nimport { describe, it, expect } from 'vitest'\nimport request from 'supertest'\nimport path from 'path'\nimport fs from 'fs'\nimport { createServer } from '@\u002Ftest\u002Fhelpers\u002Fserver'\nimport { generateJWT } from '@\u002Ftest\u002Fhelpers\u002Fauth'\nimport { createTestUser } from '@\u002Ftest\u002Fhelpers\u002Fdb'\n\nconst app = createServer()\n\ndescribe('POST \u002Fapi\u002Fupload', () => {\n  let validToken: string\n\n  beforeAll(async () => {\n    const user = await createTestUser({ role: 'user' })\n    validToken = generateJWT(user)\n  })\n\n  it('returns 401 without authentication', async () => {\n    const res = await request(app)\n      .post('\u002Fapi\u002Fupload')\n      .attach('file', Buffer.from('test'), 'test.pdf')\n    expect(res.status).toBe(401)\n  })\n\n  it('returns 400 when no file attached', async () => {\n    const res = await request(app)\n      .post('\u002Fapi\u002Fupload')\n      .set('Authorization', `Bearer ${validToken}`)\n    expect(res.status).toBe(400)\n    expect(res.body.error).toMatch(\u002Ffile\u002Fi)\n  })\n\n  it('returns 400 for unsupported file type (exe)', async () => {\n    const res = await request(app)\n      .post('\u002Fapi\u002Fupload')\n      .set('Authorization', `Bearer ${validToken}`)\n      .attach('file', Buffer.from('MZ fake exe'), { filename: 'virus.exe', contentType: 'application\u002Foctet-stream' })\n    expect(res.status).toBe(400)\n    expect(res.body.error).toMatch(\u002Ftype|format|allowed\u002Fi)\n  })\n\n  it('returns 413 for oversized file (>10MB)', async () => {\n    const largeBuf = Buffer.alloc(11 * 1024 * 1024) \u002F\u002F 11MB\n    const res = await request(app)\n      .post('\u002Fapi\u002Fupload')\n      .set('Authorization', `Bearer ${validToken}`)\n      .attach('file', largeBuf, { filename: 'large.pdf', contentType: 'application\u002Fpdf' })\n    expect(res.status).toBe(413)\n  })\n\n  it('returns 400 for empty file (0 bytes)', async () => {\n    const res = await request(app)\n      .post('\u002Fapi\u002Fupload')\n      .set('Authorization', `Bearer ${validToken}`)\n      .attach('file', Buffer.alloc(0), { filename: 'empty.pdf', contentType: 'application\u002Fpdf' })\n    expect(res.status).toBe(400)\n  })\n\n  it('rejects MIME type spoofing (pdf extension but exe content)', async () => {\n    \u002F\u002F Real malicious file: exe magic bytes but pdf extension\n    const fakeExe = Buffer.from('4D5A9000', 'hex') \u002F\u002F MZ header\n    const res = await request(app)\n      .post('\u002Fapi\u002Fupload')\n      .set('Authorization', `Bearer ${validToken}`)\n      .attach('file', fakeExe, { filename: 'document.pdf', contentType: 'application\u002Fpdf' })\n    \u002F\u002F Should detect magic bytes mismatch\n    expect([400, 415]).toContain(res.status)\n  })\n\n  it('accepts valid PDF file', async () => {\n    const pdfHeader = Buffer.from('%PDF-1.4 test content')\n    const res = await request(app)\n      .post('\u002Fapi\u002Fupload')\n      .set('Authorization', `Bearer ${validToken}`)\n      .attach('file', pdfHeader, { filename: 'valid.pdf', contentType: 'application\u002Fpdf' })\n    expect(res.status).toBe(200)\n    expect(res.body).toHaveProperty('url')\n    expect(res.body).toHaveProperty('id')\n  })\n})\n```\n\n---\n\n### Example 3 — Python: Pytest + httpx (FastAPI)\n\n```python\n# tests\u002Fapi\u002Ftest_items.py\nimport pytest\nimport httpx\nfrom datetime import datetime, timedelta\nimport jwt\n\nBASE_URL = \"http:\u002F\u002Flocalhost:8000\"\nJWT_SECRET = \"test-secret\"  # use test config, never production secret\n\n\ndef make_token(user_id: str, role: str = \"user\", expired: bool = False) -> str:\n    exp = datetime.utcnow() + (timedelta(hours=-1) if expired else timedelta(hours=1))\n    return jwt.encode(\n        {\"sub\": user_id, \"role\": role, \"exp\": exp},\n        JWT_SECRET,\n        algorithm=\"HS256\",\n    )\n\n\n@pytest.fixture\ndef client():\n    with httpx.Client(base_url=BASE_URL) as c:\n        yield c\n\n\n@pytest.fixture\ndef valid_token():\n    return make_token(\"user-123\", role=\"user\")\n\n\n@pytest.fixture\ndef admin_token():\n    return make_token(\"admin-456\", role=\"admin\")\n\n\n@pytest.fixture\ndef expired_token():\n    return make_token(\"user-123\", expired=True)\n\n\nclass TestGetItem:\n    def test_returns_401_without_auth(self, client):\n        res = client.get(\"\u002Fapi\u002Fitems\u002F1\")\n        assert res.status_code == 401\n\n    def test_returns_401_with_invalid_token(self, client):\n        res = client.get(\"\u002Fapi\u002Fitems\u002F1\", headers={\"Authorization\": \"Bearer garbage\"})\n        assert res.status_code == 401\n\n    def test_returns_401_with_expired_token(self, client, expired_token):\n        res = client.get(\"\u002Fapi\u002Fitems\u002F1\", headers={\"Authorization\": f\"Bearer {expired_token}\"})\n        assert res.status_code == 401\n        assert \"expired\" in res.json().get(\"detail\", \"\").lower()\n\n    def test_returns_404_for_nonexistent_item(self, client, valid_token):\n        res = client.get(\n            \"\u002Fapi\u002Fitems\u002F99999999\",\n            headers={\"Authorization\": f\"Bearer {valid_token}\"},\n        )\n        assert res.status_code == 404\n\n    def test_returns_400_for_invalid_id_format(self, client, valid_token):\n        res = client.get(\n            \"\u002Fapi\u002Fitems\u002Fnot-a-number\",\n            headers={\"Authorization\": f\"Bearer {valid_token}\"},\n        )\n        assert res.status_code in (400, 422)\n\n    def test_returns_200_with_valid_auth(self, client, valid_token, test_item):\n        res = client.get(\n            f\"\u002Fapi\u002Fitems\u002F{test_item['id']}\",\n            headers={\"Authorization\": f\"Bearer {valid_token}\"},\n        )\n        assert res.status_code == 200\n        data = res.json()\n        assert data[\"id\"] == test_item[\"id\"]\n        assert \"password\" not in data\n\n\nclass TestCreateItem:\n    def test_returns_422_with_empty_body(self, client, admin_token):\n        res = client.post(\n            \"\u002Fapi\u002Fitems\",\n            json={},\n            headers={\"Authorization\": f\"Bearer {admin_token}\"},\n        )\n        assert res.status_code == 422\n        errors = res.json()[\"detail\"]\n        assert len(errors) > 0\n\n    def test_returns_422_with_missing_required_field(self, client, admin_token):\n        res = client.post(\n            \"\u002Fapi\u002Fitems\",\n            json={\"description\": \"no name field\"},\n            headers={\"Authorization\": f\"Bearer {admin_token}\"},\n        )\n        assert res.status_code == 422\n        fields = [e[\"loc\"][-1] for e in res.json()[\"detail\"]]\n        assert \"name\" in fields\n\n    def test_returns_422_with_wrong_type(self, client, admin_token):\n        res = client.post(\n            \"\u002Fapi\u002Fitems\",\n            json={\"name\": \"test\", \"price\": \"not-a-number\"},\n            headers={\"Authorization\": f\"Bearer {admin_token}\"},\n        )\n        assert res.status_code == 422\n\n    @pytest.mark.parametrize(\"price\", [-1, -0.01])\n    def test_returns_422_for_negative_price(self, client, admin_token, price):\n        res = client.post(\n            \"\u002Fapi\u002Fitems\",\n            json={\"name\": \"test\", \"price\": price},\n            headers={\"Authorization\": f\"Bearer {admin_token}\"},\n        )\n        assert res.status_code == 422\n\n    def test_returns_422_for_price_exceeding_max(self, client, admin_token):\n        res = client.post(\n            \"\u002Fapi\u002Fitems\",\n            json={\"name\": \"test\", \"price\": 1_000_001},\n            headers={\"Authorization\": f\"Bearer {admin_token}\"},\n        )\n        assert res.status_code == 422\n\n    def test_creates_item_successfully(self, client, admin_token):\n        res = client.post(\n            \"\u002Fapi\u002Fitems\",\n            json={\"name\": \"New Widget\", \"price\": 9.99, \"category\": \"tools\"},\n            headers={\"Authorization\": f\"Bearer {admin_token}\"},\n        )\n        assert res.status_code == 201\n        data = res.json()\n        assert \"id\" in data\n        assert data[\"name\"] == \"New Widget\"\n\n    def test_returns_403_for_non_admin(self, client, valid_token):\n        res = client.post(\n            \"\u002Fapi\u002Fitems\",\n            json={\"name\": \"test\", \"price\": 1.0},\n            headers={\"Authorization\": f\"Bearer {valid_token}\"},\n        )\n        assert res.status_code == 403\n\n\nclass TestPagination:\n    def test_returns_paginated_response(self, client, valid_token):\n        res = client.get(\n            \"\u002Fapi\u002Fitems?page=1&size=10\",\n            headers={\"Authorization\": f\"Bearer {valid_token}\"},\n        )\n        assert res.status_code == 200\n        data = res.json()\n        assert \"items\" in data\n        assert \"total\" in data\n        assert \"page\" in data\n        assert len(data[\"items\"]) \u003C= 10\n\n    def test_empty_result_for_out_of_range_page(self, client, valid_token):\n        res = client.get(\n            \"\u002Fapi\u002Fitems?page=99999\",\n            headers={\"Authorization\": f\"Bearer {valid_token}\"},\n        )\n        assert res.status_code == 200\n        assert res.json()[\"items\"] == []\n\n    def test_returns_422_for_page_zero(self, client, valid_token):\n        res = client.get(\n            \"\u002Fapi\u002Fitems?page=0\",\n            headers={\"Authorization\": f\"Bearer {valid_token}\"},\n        )\n        assert res.status_code == 422\n\n    def test_caps_page_size_at_maximum(self, client, valid_token):\n        res = client.get(\n            \"\u002Fapi\u002Fitems?size=9999\",\n            headers={\"Authorization\": f\"Bearer {valid_token}\"},\n        )\n        assert res.status_code == 200\n        assert len(res.json()[\"items\"]) \u003C= 100  # max page size\n\n\nclass TestRateLimiting:\n    def test_rate_limit_after_burst(self, client, valid_token):\n        responses = []\n        for _ in range(60):  # exceed typical 50\u002Fmin limit\n            res = client.get(\n                \"\u002Fapi\u002Fitems\",\n                headers={\"Authorization\": f\"Bearer {valid_token}\"},\n            )\n            responses.append(res.status_code)\n            if res.status_code == 429:\n                break\n        assert 429 in responses, \"Rate limit was not triggered\"\n\n    def test_rate_limit_response_has_retry_after(self, client, valid_token):\n        for _ in range(60):\n            res = client.get(\"\u002Fapi\u002Fitems\", headers={\"Authorization\": f\"Bearer {valid_token}\"})\n            if res.status_code == 429:\n                assert \"Retry-After\" in res.headers or \"retry_after\" in res.json()\n                break\n```\n\n---\n\n## Generating Tests from Route Scan\n\nWhen given a codebase, follow this process:\n\n1. **Scan routes** using the detection commands above\n2. **Read each route handler** to understand:\n   - Expected request body schema\n   - Auth requirements (middleware, decorators)\n   - Return types and status codes\n   - Business rules (ownership, role checks)\n3. **Generate test file** per route group using the patterns above\n4. **Name tests descriptively**: `\"returns 401 when token is expired\"` not `\"auth test 3\"`\n5. **Use factories\u002Ffixtures** for test data — never hardcode IDs\n6. **Assert response shape**, not just status code\n\n---\n\n## Common Pitfalls\n\n- **Testing only happy paths** — 80% of bugs live in error paths; test those first\n- **Hardcoded test data IDs** — use factories\u002Ffixtures; IDs change between environments\n- **Shared state between tests** — always clean up in afterEach\u002FafterAll\n- **Testing implementation, not behavior** — test what the API returns, not how it does it\n- **Missing boundary tests** — off-by-one errors are extremely common in pagination and limits\n- **Not testing token expiry** — expired tokens behave differently from invalid ones\n- **Ignoring Content-Type** — test that API rejects wrong content types (xml when json expected)\n\n---\n\n## Best Practices\n\n1. One describe block per endpoint — keeps failures isolated and readable\n2. Seed minimal data — don't load the entire DB; create only what the test needs\n3. Use `beforeAll` for shared setup, `afterAll` for cleanup — not `beforeEach` for expensive ops\n4. Assert specific error messages\u002Ffields, not just status codes\n5. Test that sensitive fields (password, secret) are never in responses\n6. For auth tests, always test the \"missing header\" case separately from \"invalid token\"\n7. Add rate limit tests last — they can interfere with other test suites if run in parallel\n",{},"main","a318f48de3c5718e8ea2e9f6fae7790e8a759e85","upstream-sync\u002Fwork\u002Fclaude-skills\u002Fengineering\u002Fapi-test-suite-builder",0,"https:\u002F\u002Fgithub.com\u002Foabdelmaksoud\u002FAgention","https:\u002F\u002Fgithub.com\u002Foabdelmaksoud","https:\u002F\u002Fwww.linkedin.com\u002Fin\u002Fo-abdelmaksoud\u002F","Full-Stack Engineer | AI Systems Architect | Building autonomous multi-agent systems","2026-03-08 21:23:03",{"source":7,"skillName":5,"commands":37,"prompt":47,"zipAvailable":48},[38,41,44],{"tool":39,"command":40},"npx","npx skills add oabdelmaksoud\u002FAgention --skill api-test-suite-builder",{"tool":42,"command":43},"bunx","bunx skills add oabdelmaksoud\u002FAgention --skill api-test-suite-builder",{"tool":45,"command":46},"pnpm","pnpm dlx skills add oabdelmaksoud\u002FAgention --skill api-test-suite-builder","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Foabdelmaksoud\u002FAgention\u002Fblob\u002Fmain\u002Fupstream-sync\u002Fwork\u002Fclaude-skills\u002Fengineering\u002Fapi-test-suite-builder\u002FSKILL.md",true,[],[51,70,84,105,131,150],{"skillNo":52,"name":53,"nameZh":6,"description":54,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":55,"categories":56,"keywords":57,"publishedAt":23},"01M6G2QFCBNBYAJF2KTK85G9A6","visa-doc-translate","Translate visa application documents (images) to English and create a bilingual PDF with original and translation","https:\u002F\u002Fgithub.com\u002Foabdelmaksoud\u002FAgention\u002Fblob\u002Fmain\u002Fupstream-sync\u002Fwork\u002Fecc\u002Fskills\u002Fvisa-doc-translate\u002FSKILL.md",[],[58,59,60,61,62,63,64,65,66,67,68,69],"translate","doc","visa doc translate","bilingual","with","english","application","PDF","translation","documents","create","images",{"skillNo":71,"name":72,"nameZh":6,"description":73,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":74,"categories":75,"keywords":76,"publishedAt":23},"01M6G2QB09TSK6BY4ME5X20EVQ","verification-loop","A comprehensive verification system for Claude Code sessions.","https:\u002F\u002Fgithub.com\u002Foabdelmaksoud\u002FAgention\u002Fblob\u002Fmain\u002Fupstream-sync\u002Fwork\u002Fecc\u002Fskills\u002Fverification-loop\u002FSKILL.md",[],[77,78,79,80,81,82,83],"verification","loop","verification loop","sessions","code","claude code sessions","system",{"skillNo":85,"name":86,"nameZh":6,"description":87,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":88,"categories":89,"keywords":90,"publishedAt":23},"01M6G2Q6V2F7G03VAAF27FXPJR","tdd-workflow","Use this skill when writing new features, fixing bugs, or refactoring code. Enforces test-driven development with 80%+ coverage including unit, integration, and E2E tests.","https:\u002F\u002Fgithub.com\u002Foabdelmaksoud\u002FAgention\u002Fblob\u002Fmain\u002Fupstream-sync\u002Fwork\u002Fecc\u002Fskills\u002Ftdd-workflow\u002FSKILL.md",[],[91,92,93,94,95,96,97,98,99,81,100,101,102,103,62,18,104],"workflow","tdd","tdd workflow","use","unit","coverage","refactoring","e2e","integration","development","e2e tests","tests","driven","writing",{"skillNo":106,"name":107,"nameZh":6,"description":108,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":109,"categories":110,"keywords":111,"publishedAt":23},"01M6G2Q359YJRWAR2PFCEQAXF3","swiftui-patterns","SwiftUI architecture patterns, state management with @Observable, view composition, navigation, performance optimization, and modern iOS\u002FmacOS UI best practices.","https:\u002F\u002Fgithub.com\u002Foabdelmaksoud\u002FAgention\u002Fblob\u002Fmain\u002Fupstream-sync\u002Fwork\u002Fecc\u002Fskills\u002Fswiftui-patterns\u002FSKILL.md",[],[112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,62],"patterns","swiftui","swiftui patterns","architecture","macos","performance","state management","best practices","state","ui","Optimization","ios","architecture patterns","Composition","performance optimization","view","management","swiftui architecture","navigation",{"skillNo":132,"name":133,"nameZh":6,"description":134,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":135,"categories":136,"keywords":137,"publishedAt":23},"01M6G2PY8B2FWZTWPZ84H83Y7C","swift-protocol-di-testing","Protocol-based dependency injection for testable Swift code — mock file system, network, and external APIs using focused protocols and Swift Testing.","https:\u002F\u002Fgithub.com\u002Foabdelmaksoud\u002FAgention\u002Fblob\u002Fmain\u002Fupstream-sync\u002Fwork\u002Fecc\u002Fskills\u002Fswift-protocol-di-testing\u002FSKILL.md",[],[138,139,140,141,81,142,143,144,145,83,146,147,148,149],"swift protocol di testing","protocol","swift","testing","protocols","file","network","injection","dependency","swift testing","dependency injection","mock",{"skillNo":151,"name":152,"nameZh":6,"description":153,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":154,"categories":155,"keywords":156,"publishedAt":23},"01M6G2PSCN2GXV9FFZDRRRWVB6","swift-concurrency-6-2","Swift 6.2 Approachable Concurrency — single-threaded by default, @concurrent for explicit background offloading, isolated conformances for main actor types.","https:\u002F\u002Fgithub.com\u002Foabdelmaksoud\u002FAgention\u002Fblob\u002Fmain\u002Fupstream-sync\u002Fwork\u002Fecc\u002Fskills\u002Fswift-concurrency-6-2\u002FSKILL.md",[],[157,158,159,140,160,27,161],"concurrency","swift concurrency","swift concurrency 6 2","default","types"]