Test .NET API endpoints with curl to validate JWT authentication, CRUD operations, business isolation, and Clean Architecture compliance
Tests .NET API endpoints using curl to validate JWT authentication, CRUD operations, business isolation, and Clean Architecture compliance. Automatically triggered after implementing API endpoints, fixing backend bugs, or before deploying backend changes.
/plugin marketplace add usmanali4073/stylemate-plugins/plugin install stylemate-architecture@stylemate-pluginsThis skill inherits all available tools. When active, it can use any tool Claude has access to.
Use this skill to perform integration testing of .NET microservices using curl and command-line tools.
Validates security implementation:
Tests all API operations:
Verifies multi-tenancy security:
Checks input validation:
Verifies monitoring:
curl - HTTP requests to APIdotnet build - Compile verificationdotnet test - Run unit testsdocker-compose - Start servicesjq - Parse JSON responses (if available)cd {context}/{context}-api
dotnet build
Expected: 0 errors, 0 warnings
docker-compose up -d {context}_api
Expected: Container starts successfully
curl -f http://localhost:{port}/health
Expected: HTTP 200
# 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
# 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}
# 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
# 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
# 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
#!/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!"
#!/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
Cause: Token validation misconfigured Check: JWT_SECRET, Issuer, Audience in appsettings.json
Cause: Policy not matching claim Check: Authorization policy definition, claim names
Cause: Missing business_id filter Fix: CRITICAL SECURITY ISSUE - Add filtering immediately
Cause: Unhandled exceptions Check: Application logs, add try-catch, validation
This skill ensures comprehensive API testing covering functionality, security, and architectural compliance.
Master authentication and authorization patterns including JWT, OAuth2, session management, and RBAC to build secure, scalable access control systems. Use when implementing auth systems, securing APIs, or debugging security issues.