route-tester
Skill4 starsChanged 12 months agoMITView on GitHub
Test authenticated routes in the your project using cookie-based authentication. Use this skill when testing API endpoints, validating route functionality, or debugging authentication issues. Includes patterns for using test-auth-route.js and mock authentication.
- Reads credentials
- Sends data out
We split this skill into the rules it gives an agent
14 rules. 9 are common, 0 are distinctive, and 5 are very specific to this project.
9
Common
Most of the 3 edited versions we read keep these.
0
Distinctive
This author's own choices. Worth a look.
5
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 74
Use the curl command from the test-auth-route.js output:
- Very specific: line 186
Check /src/app.ts in each service for route prefixes:
- Common: line 204
Before testing a route:
- Common: line 218
After testing routes that modify data:
- Very specific: line 275
Check app.ts for route prefixes
- Very specific: line 277
Check service is running (pm2 list)
- Very specific: line 288
Check service logs (pm2 logs <service>)
- Common: line 289
Check Sentry for error details
- Common: line 290
Verify request body matches expected schema
- Common: line 305
Test the route with proper authentication
- Common: line 389
Use database-verification to verify database changes
- Common: line 390
Use error-tracking to check for captured errors
- Common: line 391
Use workflow-builder for workflow route testing
- Common: line 392
Use notification-sender to verify notifications sent
“Common” is measured: kept by at least 6 in 10 of the 3 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 🎯 SKILL ACTIVATED: route-tester ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
your project Route Tester Skill
Purpose
This skill provides patterns for testing authenticated routes in the your project using cookie-based JWT authentication.
When to Use This Skill
- Testing new API endpoints
- Validating route functionality after changes
- Debugging authentication issues
- Testing POST/PUT/DELETE operations
- Verifying request/response data
your project Authentication Overview
The your project uses:
- Keycloak for SSO (realm: yourRealm)
- Cookie-based JWT tokens (not Bearer headers)
- Cookie name:
refresh_token - JWT signing: Using secret from
config.ini
Testing Methods
Method 1: test-auth-route.js (RECOMMENDED)
The test-auth-route.js script handles all authentication complexity automatically.
Location: /root/git/your project_pre/scripts/test-auth-route.js
Basic GET Request
node scripts/test-auth-route.js http://localhost:3000/blog-api/api/endpointPOST Request with JSON Data
node scripts/test-auth-route.js \
http://localhost:3000/blog-api/777/submit \
POST \
'{"responses":{"4577":"13295"},"submissionID":5,"stepInstanceId":"11"}'What the Script Does
- Gets a refresh token from Keycloak
- Username:
testuser - Password:
testpassword
- Username:
- Signs the token with JWT secret from
config.ini - Creates cookie header:
refresh_token=<signed-token> - Makes the authenticated request
- Shows the exact curl command to reproduce manually
Script Output
The script outputs:
- The request details
- The response status and body
- A curl command for manual reproduction
Note: The script is verbose - look for the actual response in the output.
Method 2: Manual curl with Token
Use the curl command from the test-auth-route.js output:
# The script outputs something like:
# 💡 To test manually with curl:
# curl -b "refresh_token=eyJhbGci..." http://localhost:3000/blog-api/api/endpoint
# Copy and modify that curl command:
curl -X POST http://localhost:3000/blog-api/777/submit \
-H "Content-Type: application/json" \
-b "refresh_token=<COPY_TOKEN_FROM_SCRIPT_OUTPUT>" \
-d '{"your": "data"}'Method 3: Mock Authentication (Development Only - EASIEST)
For development, bypass Keycloak entirely using mock auth.
Setup
# Add to service .env file (e.g., blog-api/.env)
MOCK_AUTH=true
MOCK_USER_ID=test-user
MOCK_USER_ROLES=admin,operationsUsage
curl -H "X-Mock-Auth: true" \
-H "X-Mock-User: test-user" \
-H "X-Mock-Roles: admin,operations" \
http://localhost:3002/api/protectedMock Auth Requirements
Mock auth ONLY works when:
NODE_ENVisdevelopmentortest- The
mockAuthmiddleware is added to the route - Will NEVER work in production (security feature)
Common Testing Patterns
Test Form Submission
node scripts/test-auth-route.js \
http://localhost:3000/blog-api/777/submit \
POST \
'{"responses":{"4577":"13295"},"submissionID":5,"stepInstanceId":"11"}'Test Workflow Start
node scripts/test-auth-route.js \
http://localhost:3002/api/workflow/start \
POST \
'{"workflowCode":"DHS_CLOSEOUT","entityType":"Submission","entityID":123}'Test Workflow Step Completion
node scripts/test-auth-route.js \
http://localhost:3002/api/workflow/step/complete \
POST \
'{"stepInstanceID":789,"answers":{"decision":"approved","comments":"Looks good"}}'Test GET with Query Parameters
node scripts/test-auth-route.js \
"http://localhost:3002/api/workflows?status=active&limit=10"Test File Upload
# Get token from test-auth-route.js first, then:
curl -X POST http://localhost:5000/upload \
-H "Content-Type: multipart/form-data" \
-b "refresh_token=<TOKEN>" \
-F "file=@/path/to/file.pdf" \
-F "metadata={\"description\":\"Test file\"}"Hardcoded Test Credentials
The test-auth-route.js script uses these credentials:
- Username:
testuser - Password:
testpassword - Keycloak URL: From
config.ini(usuallyhttp://localhost:8081) - Realm:
yourRealm - Client ID: From
config.ini
Service Ports
| Service | Port | Base URL |
| Users | 3000 | http://localhost:3000 |
| Projects | 3001 | http://localhost:3001 |
| Form | 3002 | http://localhost:3002 |
| 3003 | http://localhost:3003 | |
| Uploads | 5000 | http://localhost:5000 |
Route Prefixes
Check /src/app.ts in each service for route prefixes:
// Example from blog-api/src/app.ts
app.use('/blog-api/api', formRoutes); // Prefix: /blog-api/api
app.use('/api/workflow', workflowRoutes); // Prefix: /api/workflowFull Route = Base URL + Prefix + Route Path
Example:
- Base:
http://localhost:3002 - Prefix:
/form - Route:
/777/submit - Full URL:
http://localhost:3000/blog-api/777/submit
Testing Checklist
Before testing a route:
- Identify the service (form, email, users, etc.)
- Find the correct port
- Check route prefixes in
app.ts - Construct the full URL
- Prepare request body (if POST/PUT)
- Determine authentication method
- Run the test
- Verify response status and data
- Check database changes if applicable
Verifying Database Changes
After testing routes that modify data:
# Connect to MySQL
docker exec -i local-mysql mysql -u root -ppassword1 blog_dev
# Check specific table
mysql> SELECT * FROM WorkflowInstance WHERE id = 123;
mysql> SELECT * FROM WorkflowStepInstance WHERE instanceId = 123;
mysql> SELECT * FROM WorkflowNotification WHERE recipientUserId = 'user-123';Debugging Failed Tests
401 Unauthorized
Possible causes:
- Token expired (regenerate with test-auth-route.js)
- Incorrect cookie format
- JWT secret mismatch
- Keycloak not running
Solutions:
# Check Keycloak is running
docker ps | grep keycloak
# Regenerate token
node scripts/test-auth-route.js http://localhost:3002/api/health
# Verify config.ini has correct jwtSecret403 Forbidden
Possible causes:
- User lacks required role
- Resource permissions incorrect
- Route requires specific permissions
Solutions:
# Use mock auth with admin role
curl -H "X-Mock-Auth: true" \
-H "X-Mock-User: test-admin" \
-H "X-Mock-Roles: admin" \
http://localhost:3002/api/protected404 Not Found
Possible causes:
- Incorrect URL
- Missing route prefix
- Route not registered
Solutions:
- Check
app.tsfor route prefixes - Verify route registration
- Check service is running (
pm2 list)
500 Internal Server Error
Possible causes:
- Database connection issue
- Missing required fields
- Validation error
- Application error
Solutions:
- Check service logs (
pm2 logs <service>) - Check Sentry for error details
- Verify request body matches expected schema
- Check database connectivity
Using auth-route-tester Agent
For comprehensive route testing after making changes:
- Identify affected routes
- Gather route information:
- Full route path (with prefix)
- Expected POST data
- Tables to verify
- Invoke auth-route-tester agent
The agent will:
- Test the route with proper authentication
- Verify database changes
- Check response format
- Report any issues
Example Test Scenarios
After Creating a New Route
# 1. Test with valid data
node scripts/test-auth-route.js \
http://localhost:3002/api/my-new-route \
POST \
'{"field1":"value1","field2":"value2"}'
# 2. Verify database
docker exec -i local-mysql mysql -u root -ppassword1 blog_dev \
-e "SELECT * FROM MyTable ORDER BY createdAt DESC LIMIT 1;"
# 3. Test with invalid data
node scripts/test-auth-route.js \
http://localhost:3002/api/my-new-route \
POST \
'{"field1":"invalid"}'
# 4. Test without authentication
curl http://localhost:3002/api/my-new-route
# Should return 401After Modifying a Route
# 1. Test existing functionality still works
node scripts/test-auth-route.js \
http://localhost:3002/api/existing-route \
POST \
'{"existing":"data"}'
# 2. Test new functionality
node scripts/test-auth-route.js \
http://localhost:3002/api/existing-route \
POST \
'{"new":"field","existing":"data"}'
# 3. Verify backward compatibility
# Test with old request format (if applicable)Configuration Files
config.ini (each service)
[keycloak]
url = http://localhost:8081
realm = yourRealm
clientId = app-client
[jwt]
jwtSecret = your-jwt-secret-here.env (each service)
NODE_ENV=development
MOCK_AUTH=true # Optional: Enable mock auth
MOCK_USER_ID=test-user # Optional: Default mock user
MOCK_USER_ROLES=admin # Optional: Default mock rolesKey Files
/root/git/your project_pre/scripts/test-auth-route.js- Main testing script/blog-api/src/app.ts- Form service routes/notifications/src/app.ts- Email service routes/auth/src/app.ts- Users service routes/config.ini- Service configuration/.env- Environment variables
Related Skills
- Use database-verification to verify database changes
- Use error-tracking to check for captured errors
- Use workflow-builder for workflow route testing
- Use notification-sender to verify notifications sent
Other versions4 projects use a version of this.
Word for word · 0
None found.
Edited · 4
- serithemage/claude-code-infrastructure-showcase★ 12724% same
- serithemage/claude-code-demo★ 410% same
- Metehan-Bicer/claude-code-starter★ 1100% same
- davidanthonyn/claude-skills★ 094% same
Wrote their own version · 0
None found.
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository24 other files it gives its agents.
- api-engineeringSkill
- backend-dev-guidelinesSkill
- budget-and-cost-managementSkill
- build-engineeringSkill
- cloud-engineeringSkill
- cybersecuritySkill
- database-engineeringSkill
- devsecopsSkill
- documentation-as-codeSkill
- engineering-managementSkill
- engineering-operations-managementSkill
- error-trackingSkill
- frontend-dev-guidelinesSkill
- general-it-engineeringSkill
- infrastructure-architectureSkill
- infrastructure-strategySkill
- network-engineeringSkill
- observability-engineeringSkill
- platform-engineeringSkill
- release-engineeringSkill
- skill-developerSkill
- sreSkill
- systems-engineeringSkill
- technical-leadershipSkill
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

