Insforge Backend Tests
This directory contains all test scripts for the Insforge backend.
Prerequisites
- Backend server running on
http://localhost:7130 - Root admin credentials:
root/change-this-password - API key for storage operations
Environment Variables
Set these before running tests:
# Required for API authentication
export ACCESS_API_KEY="your_api_key_here"
# Optional - defaults shown
export ROOT_ADMIN_USERNAME="admin"
export ROOT_ADMIN_PASSWORD="change-this-password"
export TEST_API_BASE="http://localhost:7130/api"
# Required for cloud/S3 tests
export AWS_S3_BUCKET="your-s3-bucket"
export AWS_REGION="us-east-1"
export AWS_ACCESS_KEY_ID="your-access-key"
export AWS_SECRET_ACCESS_KEY="your-secret-key"
export APP_KEY="app12345" # 7-9 character tenant identifier
Test Organization
Tests are organized into two categories:
Local Tests (./local/)
Tests for local Docker deployment with local file storage:
test-auth-router.sh- Authentication and JWT teststest-database-router.sh- Database CRUD operationstest-e2e.sh- End-to-end workflowstest-public-bucket.sh- Local storage bucket teststest-config.sh- Configuration managementtest-oauth-config.sh- OAuth configurationcomprehensive-curl-tests.sh- Comprehensive API tests
Cloud Tests (./cloud/)
Tests for cloud deployment with S3 multi-tenant storage:
test-s3-multitenant.sh- S3 storage with APP_KEY folder structure
Running Tests
Run all tests
./run-all-tests.sh
Run local tests only
cd local && for test in test-*.sh; do ./$test; done
Run cloud tests only
cd cloud && for test in test-*.sh; do ./$test; done
Run individual test
./local/test-auth-router.sh
./cloud/test-s3-multitenant.sh
Test Data Cleanup
All tests automatically clean up after themselves by:
- Deleting test users (email prefix:
testuser_) - Removing test tables
- Deleting test storage buckets
Manual cleanup
To remove ALL test data from the system:
./cleanup-all-test-data.sh
This will prompt for confirmation and then delete:
- All users with email prefix
testuser_ - All tables containing
test_,temp_,_test,_temp - All buckets containing
test,temp,public-images-,private-docs- - All API keys with "test" in their name
Test Configuration
All tests source test-config.sh which provides:
- Shared configuration and environment variables
- Color output utilities
- Automatic cleanup functions
- Error tracking
Writing New Tests
- Create a new shell script in the appropriate subdirectory (
local/orcloud/) - Source the test configuration:
source "$SCRIPT_DIR/test-config.sh" - Register resources for cleanup:
register_test_user "$email" register_test_table "$table_name" register_test_bucket "$bucket_name" - Use utility functions:
print_success "Test passed" print_fail "Test failed" print_info "Running test..." - Tests will automatically clean up on exit
Authentication
- Auth endpoints (users, profiles): Use JWT tokens via
Authorization: Bearer $token - Database endpoints: Use JWT tokens via
Authorization: Bearer $token - Storage endpoints: Use API keys via
x-api-key: $api_key
Exit Codes
0: All tests passed1: One or more tests failed
Tests track failures and return appropriate exit codes for CI/CD integration.