This directory contains a complete test suite that validates every single documented endpoint across all DIDentity platform services.
The test suite validates all documented endpoints from the API Documentation:
- ✅
POST /signup- User registration - ✅
POST /login- User authentication - ✅
POST /token- Alternative token endpoint - ✅
POST /token/refresh- Token refresh - ✅
POST /token/revoke- Token revocation - ✅
GET /health- Health check - ✅
GET /sdk/{language}- SDK generation (typescript, python, java)
- ✅
POST /dids- DID creation for all methods:keymethod (cryptographic keys)webmethod (web domains)ethrmethod (Ethereum addresses)sovmethod (Sovrin network)ionmethod (ION network)
- ✅
GET /dids/{did}- DID resolution - ✅
GET /health- Health check - ✅
GET /sdk/{language}- SDK generation
- ✅
POST /credentials/issue- Credential issuance for multiple types:- Education credentials
- Identity credentials
- Professional credentials
- ✅
GET /health- Health check - ✅
GET /sdk/{language}- SDK generation
- ✅
POST /credentials/verify- Credential verification - ✅
GET /health- Health check - ✅
GET /sdk/{language}- SDK generation
The suite also tests error conditions:
- ✅ Duplicate user registration (400 error)
- ✅ Invalid login credentials (401 error)
- ✅ Invalid DID resolution (404 error)
- ✅ Invalid credential verification (404 error)
Tests the complete workflow:
- User registration → 2. DID creation → 3. Credential issuance → 4. Credential verification
Linux/macOS:
cd tests
chmod +x run_comprehensive_test.sh
./run_comprehensive_test.shWindows:
cd tests
run_comprehensive_test.bat-
Install Dependencies:
cd tests pip install -r requirements.txt -
Run Tests:
python comprehensive_api_test.py
Ensure all DIDentity services are running:
# Start all services
docker-compose up -d
# Verify services are running
curl http://localhost:8004/health # Auth Service
curl http://localhost:8001/health # DID Service
curl http://localhost:8002/health # Credential Service
curl http://localhost:8003/health # Verification Service- Python 3.7+
- Dependencies listed in
requirements.txt
The test suite provides detailed, color-coded output:
🚀 DIDentity Comprehensive API Test Suite
==============================================================
📊 HEALTH CHECKS
✅ Auth Service Health
✅ Did Service Health
✅ Credential Service Health
✅ Verification Service Health
🔐 AUTHENTICATION TESTS
✅ User Registration
✅ User Login
✅ Token Endpoint
✅ Token Refresh
🆔 DID SERVICE TESTS
✅ Create DID - KEY Method
✅ Create DID - WEB Method
✅ Create DID - ETHR Method
✅ Create DID - SOV Method
✅ Create DID - ION Method
✅ Resolve DID
📄 CREDENTIAL SERVICE TESTS
✅ Issue Credential - Education
✅ Issue Credential - Identity
✅ Issue Credential - Professional
✅ VERIFICATION SERVICE TESTS
✅ Verify Credential
🛠️ SDK GENERATION TESTS
✅ SDK Generation - Auth (typescript)
✅ SDK Generation - Auth (python)
✅ SDK Generation - Auth (java)
... (all service/language combinations)
🚨 Testing Error Scenarios
✅ Invalid Registration (Duplicate Email)
✅ Invalid Login (Wrong Password)
✅ Invalid DID Resolution
✅ Invalid Credential Verification
🔒 FINAL AUTHENTICATION TESTS
✅ Token Revoke
============================================================
TEST SUMMARY
============================================================
Total Tests: 45
Passed: 45
Failed: 0
Success Rate: 100.0%
Duration: 12.34s
🎉 ALL TESTS PASSED!
The test suite connects to services on localhost:
base_urls = {
'auth': 'http://localhost:8004',
'did': 'http://localhost:8001',
'credential': 'http://localhost:8002',
'verification': 'http://localhost:8003'
}Each test run uses unique test data:
- Random username:
test_user_{8_chars} - Random email:
test_{8_chars}@example.com - Fixed password:
TestPassword123!
- Registration: Creates new user account
- Login: Validates credentials
- Token Operations: Tests refresh and revocation
- Authorization: Uses JWT tokens for protected endpoints
Tests all 5 supported DID methods with realistic identifiers:
| Method | Test Identifier | Description |
|---|---|---|
key |
z6MkpTHR8VNsBxYAAWHut2Geadd9jSwuBV8xRoAnwWsdvktH |
Base58 public key |
web |
example.com |
Domain name |
ethr |
0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC |
Ethereum address |
sov |
WRfXPg8dantKVubE3HX8pw |
Sovrin identifier |
ion |
EiClkZMDxPKqC9c-umQfTkR8vvZ9JPhl_xLDI9Ef9Fxn9A |
ION identifier |
Tests multiple W3C-compliant credential types:
-
Education Credential
- Type:
UniversityDegreeCredential - Contains: degree information, university details
- Type:
-
Identity Credential
- Type:
IdentityCredential - Contains: personal information, nationality
- Type:
-
Professional Credential
- Type:
ProfessionalCredential - Contains: job title, organization, skills, expiration
- Type:
Tests SDK generation for all combinations:
- Services: auth, did, credential, verification
- Languages: typescript, python, java
- Total: 12 SDK generation tests
-
Services Not Running
❌ Auth Service Health Error: Request failed: Connection refusedSolution: Start services with
docker-compose up -d -
Permission Denied
bash: ./run_comprehensive_test.sh: Permission deniedSolution:
chmod +x run_comprehensive_test.sh -
Python Not Found
❌ Python 3 is required but not installed.Solution: Install Python 3.7+ from python.org
-
Dependencies Missing
ModuleNotFoundError: No module named 'requests'Solution: Install dependencies with
pip install -r requirements.txt
For detailed debugging, modify the test script to include verbose output:
# Add at the top of comprehensive_api_test.py
import logging
logging.basicConfig(level=logging.DEBUG)- Test Duration: ~10-15 seconds for full suite
- Parallel Execution: Tests run sequentially to maintain state
- Resource Usage: Minimal - only HTTP requests
- Cleanup: No persistent data created (unique test users)
This test suite is perfect for CI/CD pipelines:
# Example GitHub Actions usage
- name: Run API Tests
run: |
cd tests
python comprehensive_api_test.pyThe script exits with code 0 for success, 1 for failure.
To add tests for new endpoints:
- Add to the appropriate service section
- Follow the existing pattern
- Update the test count expectations
- Add error scenario testing if applicable
Example:
def test_new_endpoint(self):
self.log_test("New Endpoint", "POST /new-endpoint")
# ... test implementation
self.result.add_result("New Endpoint", success, error)When modifying the test suite:
- Ensure all existing tests still pass
- Add appropriate error handling
- Update this README if adding new test categories
- Test on both Unix and Windows systems
Total Test Coverage: 45+ individual tests covering every documented endpoint plus error scenarios and complete workflow validation.