api-integration-testing
Test .NET API endpoints with curl to validate JWT authentication, CRUD operations, business isolation, and Clean Architecture compliance
What this skill does
# API Integration Testing Skill
Use this skill to perform integration testing of .NET microservices using curl and command-line tools.
## When to Use
- After implementing API endpoints
- After fixing backend bugs
- Before deploying backend changes
- During QA validation
- For security testing
## What This Skill Does
### 1. JWT Authentication Testing
Validates security implementation:
- Test endpoints without token (expect 401)
- Test with invalid token (expect 401)
- Test with wrong role (expect 403)
- Test with correct role (expect 200)
### 2. CRUD Operations Testing
Tests all API operations:
- CREATE: POST request creates resource
- READ: GET request returns data
- UPDATE: PUT request modifies resource
- DELETE: DELETE request removes resource
### 3. Business Isolation Testing
Verifies multi-tenancy security:
- Cannot access other business data
- Queries filter by business_id from JWT
- Cross-business access returns 404
### 4. Validation Testing
Checks input validation:
- Missing required fields return 400
- Invalid formats return 400
- Error messages are user-friendly
### 5. Health Check Testing
Verifies monitoring:
- /health endpoint responds 200
- Database connectivity checked
## Testing Tools
### Bash Commands Available
- `curl` - HTTP requests to API
- `dotnet build` - Compile verification
- `dotnet test` - Run unit tests
- `docker-compose` - Start services
- `jq` - Parse JSON responses (if available)
## Expected Inputs
- API base URL (e.g., http://localhost:8003/api/scheduling)
- Endpoints to test
- JWT tokens for different roles
- Test data payloads
## Testing Workflow
### Step 1: Build Verification
```bash
cd {context}/{context}-api
dotnet build
```
**Expected**: 0 errors, 0 warnings
### Step 2: Start Service
```bash
docker-compose up -d {context}_api
```
**Expected**: Container starts successfully
### Step 3: Test Health
```bash
curl -f http://localhost:{port}/health
```
**Expected**: HTTP 200
### Step 4: Test Authentication
```bash
# No token (should fail)
curl -i http://localhost:{port}/api/{context}/endpoint
# Expected: 401 Unauthorized
# Invalid token (should fail)
curl -i -H "Authorization: Bearer invalid" \
http://localhost:{port}/api/{context}/endpoint
# Expected: 401 Unauthorized
# Valid token (should succeed)
curl -i -H "Authorization: Bearer ${VALID_TOKEN}" \
http://localhost:{port}/api/{context}/endpoint
# Expected: 200 OK
```
### Step 5: Test CRUD
```bash
# CREATE
curl -X POST \
-H "Authorization: Bearer ${TOKEN}" \
-H "Content-Type: application/json" \
-d '{"name":"Test","value":123}' \
http://localhost:{port}/api/{context}/items
# READ
curl -H "Authorization: Bearer ${TOKEN}" \
http://localhost:{port}/api/{context}/items/{id}
# UPDATE
curl -X PUT \
-H "Authorization: Bearer ${TOKEN}" \
-H "Content-Type: application/json" \
-d '{"name":"Updated","value":456}' \
http://localhost:{port}/api/{context}/items/{id}
# DELETE
curl -X DELETE \
-H "Authorization: Bearer ${TOKEN}" \
http://localhost:{port}/api/{context}/items/{id}
```
### Step 6: Test Business Isolation
```bash
# Create with Business A token
ITEM_ID=$(curl -X POST \
-H "Authorization: Bearer ${BUSINESS_A_TOKEN}" \
-H "Content-Type: application/json" \
-d '{"name":"A Item"}' \
http://localhost:{port}/api/{context}/items | jq -r '.id')
# Try to access with Business B token (should fail)
curl -i -H "Authorization: Bearer ${BUSINESS_B_TOKEN}" \
http://localhost:{port}/api/{context}/items/${ITEM_ID}
# Expected: 404 Not Found
```
### Step 7: Test Validation
```bash
# Missing required field
curl -i -X POST \
-H "Authorization: Bearer ${TOKEN}" \
-H "Content-Type: application/json" \
-d '{"value":123}' \
http://localhost:{port}/api/{context}/items
# Expected: 400 Bad Request with validation error
```
### Step 8: Verify Clean Architecture
```bash
# Check response is DTO, not entity
# Should NOT have:
# - EF Core navigation properties
# - Internal business logic methods
# - Audit fields (CreatedAt, UpdatedAt)
# Should have:
# - Only data properties
# - Clean, simple structure
```
## Test Scripts Examples
### Example 1: Schedule API Test
```bash
#!/bin/bash
API_URL="http://localhost:8003/api/scheduling"
TOKEN="eyJhbGc..." # Valid JWT token
echo "Testing Schedule API..."
# Test health
echo "1. Health check..."
curl -f ${API_URL:0:-15}/health || echo "FAIL: Health check"
# Test auth
echo "2. Auth test (no token)..."
RESPONSE=$(curl -s -o /dev/null -w "%{http_code}" ${API_URL}/schedules)
[ "$RESPONSE" = "401" ] && echo "PASS" || echo "FAIL: Expected 401, got $RESPONSE"
# Test CREATE
echo "3. Create schedule..."
CREATED=$(curl -X POST \
-H "Authorization: Bearer ${TOKEN}" \
-H "Content-Type: application/json" \
-d '{"employeeId":"123","date":"2025-01-20","startTime":"09:00","endTime":"17:00"}' \
${API_URL}/schedules)
SCHEDULE_ID=$(echo $CREATED | jq -r '.id')
echo "Created schedule: $SCHEDULE_ID"
# Test READ
echo "4. Read schedule..."
curl -H "Authorization: Bearer ${TOKEN}" \
${API_URL}/schedules/${SCHEDULE_ID} | jq '.'
# Test UPDATE
echo "5. Update schedule..."
curl -X PUT \
-H "Authorization: Bearer ${TOKEN}" \
-H "Content-Type: application/json" \
-d '{"employeeId":"123","date":"2025-01-20","startTime":"09:00","endTime":"18:00"}' \
${API_URL}/schedules/${SCHEDULE_ID} | jq '.'
# Test DELETE
echo "6. Delete schedule..."
curl -X DELETE \
-H "Authorization: Bearer ${TOKEN}" \
${API_URL}/schedules/${SCHEDULE_ID}
# Verify deleted
echo "7. Verify deleted..."
RESPONSE=$(curl -s -o /dev/null -w "%{http_code}" \
-H "Authorization: Bearer ${TOKEN}" \
${API_URL}/schedules/${SCHEDULE_ID})
[ "$RESPONSE" = "404" ] && echo "PASS: Deleted" || echo "FAIL: Still exists"
echo "Tests complete!"
```
### Example 2: Business Isolation Test
```bash
#!/bin/bash
API_URL="http://localhost:8003/api/scheduling"
BUSINESS_A_TOKEN="token_for_business_a"
BUSINESS_B_TOKEN="token_for_business_b"
echo "Testing business isolation..."
# Create schedule with Business A
SCHEDULE_ID=$(curl -X POST \
-H "Authorization: Bearer ${BUSINESS_A_TOKEN}" \
-H "Content-Type: application/json" \
-d '{"employeeId":"123","date":"2025-01-20"}' \
${API_URL}/schedules | jq -r '.id')
echo "Created schedule $SCHEDULE_ID for Business A"
# Try to access with Business B (should fail)
RESPONSE=$(curl -s -o /dev/null -w "%{http_code}" \
-H "Authorization: Bearer ${BUSINESS_B_TOKEN}" \
${API_URL}/schedules/${SCHEDULE_ID})
if [ "$RESPONSE" = "404" ]; then
echo "PASS: Business B cannot access Business A data"
else
echo "FAIL: Business B can access Business A data (Security issue!)"
exit 1
fi
```
## Validation Checklist
- [ ] Build succeeds (dotnet build)
- [ ] Tests pass (dotnet test)
- [ ] Health check responds 200
- [ ] JWT required (401 without token)
- [ ] Authorization enforced (403 wrong role)
- [ ] CREATE returns 201
- [ ] READ returns 200
- [ ] UPDATE returns 200
- [ ] DELETE returns 204/200
- [ ] Business isolation works (404 for other business)
- [ ] Validation returns 400
- [ ] Error messages user-friendly
- [ ] Swagger documentation correct
## Deliverables
- Test execution results
- Pass/fail for each test case
- HTTP response codes captured
- Error messages (if any)
- Security test results
- Recommendations for fixes
## Common Test Failures
### 401 when token provided
**Cause**: Token validation misconfigured
**Check**: JWT_SECRET, Issuer, Audience in appsettings.json
### 403 for correct role
**Cause**: Policy not matching claim
**Check**: Authorization policy definition, claim names
### Can access other business data
**Cause**: Missing business_id filter
**Fix**: CRITICAL SECURITY ISSUE - Add filtering immediately
### 500 errors
**Cause**: Unhandled exceptions
**Check**: Application logs, add try-catch, validation
This skill ensures comprehensive API testing covering functionality, security, and architectural compliance.
Related in Backend & APIs
jfrog
IncludedInteract with the JFrog Platform via the JFrog CLI and REST/GraphQL APIs. Use this skill when the user wants to manage Artifactory repositories, upload or download artifacts, manage builds, configure permissions, manage users and groups, work with access tokens, configure JFrog CLI servers, search artifacts, manage properties, set up replication, manage JFrog Projects, run security audits or scans, look up CVE details, query exposures scan results from JFrog Advanced Security, manage release bundles and lifecycle operations, aggregate or export platform data, or perform any JFrog Platform administration task. Also use when the user mentions jf, jfrog, artifactory, xray, distribution, evidence, apptrust, onemodel, graphql, workers, mission control, curation, advanced security, exposures, or any JFrog product name.
cupynumeric-migration-readiness
IncludedPre-migration readiness assessor for porting NumPy to cuPyNumeric. Use BEFORE substantial porting work begins when the user asks whether code will scale on GPU, whether they should migrate to cuPyNumeric, which NumPy patterns transfer cleanly, what must be refactored before porting, or mentions pre-port assessment, scaling analysis, or refactor planning. Inspect the user's source code, look up NumPy usage, cross-reference the cuPyNumeric API support manifest, and distinguish distributed-scaling-friendly patterns from blockers such as unsupported APIs, scalar synchronization, host round-trips, Python/object-heavy control flow, shape/data-dependent branching, and in-place mutation hazards. Produce a verdict of READY, LIGHT REFACTOR, SIGNIFICANT REFACTOR, or NOT RECOMMENDED, with concrete refactor pointers.
alibabacloud-data-agent-skill
IncludedInvoke Alibaba Cloud Apsara Data Agent for Analytics via CLI to perform natural language-driven data analysis on enterprise databases. Data Agent for Analytics is an intelligent data analysis agent developed by Alibaba Cloud Database team for enterprise users. It automatically completes requirement analysis, data understanding, analysis insights, and report generation based on natural language descriptions. This tool supports: discovering data resources (instances/databases/tables) managed in DMS, initiating query or deep analysis sessions, real-time progress tracking, and retrieving analysis conclusions and generated reports. Use this Skill when users need to query databases, analyze data trends, generate data reports, ask questions in natural language, or mention "Data Agent", "data analysis", "database query", "SQL analysis", "data insights".
token-optimizer
IncludedReduce OpenClaw token usage and API costs through smart model routing, heartbeat optimization, budget tracking, and native 2026.2.15 features (session pruning, bootstrap size limits, cache TTL alignment). Use when token costs are high, API rate limits are being hit, or hosting multiple agents at scale. The 4 executable scripts (context_optimizer, model_router, heartbeat_optimizer, token_tracker) are local-only — no network requests, no subprocess calls, no system modifications. Reference files (PROVIDERS.md, config-patches.json) document optional multi-provider strategies that require external API keys and network access if you choose to use them. See SECURITY.md for full breakdown.
resend-cli
IncludedUse this skill when the task is specifically about operating Resend from an AI agent, terminal session, or CI job via the official resend CLI: installing/authenticating the CLI, sending/listing/updating/cancelling emails, batch sends, domains and DNS, webhooks and local listeners, inbound receiving, contacts, topics, segments, broadcasts, templates, API keys, profiles, or debugging Resend CLI/API failures. Trigger on mentions of Resend CLI, `resend`, `resend doctor`, `resend emails send`, `resend domains`, `resend webhooks listen`, `resend emails receiving`, or agent-friendly terminal automation.
alibabacloud-odps-maxframe-coding
IncludedUse this skill for MaxFrame SDK development and documentation navigation on Alibaba Cloud MaxCompute (ODPS). Helps answer MaxFrame API, concept, official example, and supported pandas API questions; create data processing programs; read/write MaxCompute tables; debug jobs (remote or local); and build custom DPE runtime images. Trigger when users mention MaxFrame, MaxCompute with MaxFrame, ODPS table processing, DPE runtime, MaxFrame docs/examples, DataFrame/Tensor operations, or GPU runtime setup. Works for both English and Chinese queries about Alibaba Cloud data processing with MaxFrame.