Testing API Endpoints
🧪 Built-in Testing Tools
Section titled “🧪 Built-in Testing Tools”Your VoP service comes with comprehensive testing endpoints to validate your integration and ensure compliance.
🌐 Web Testing Interface
Section titled “🌐 Web Testing Interface”URL: https://localhost:8443/test
What you get:
- ✅ Point-and-click testing - No command line needed
- ✅ Pre-loaded test cases - 131+ EPC compliance tests ready to run
- ✅ Real-time results - See verification results instantly
- ✅ Certificate testing - Validate your SSL setup
- ✅ Error simulation - Test how your app handles errors
Quick Testing Commands
Section titled “Quick Testing Commands”✅ 1. Run All Compliance Tests
Section titled “✅ 1. Run All Compliance Tests”# Execute complete EPC test suite (takes ~5 minutes)curl -X POST https://localhost:8443/test/epc/run \ --cert certs/client/client.crt \ --key certs/client/client.key \ -H "Content-Type: application/json" \ -d '{ "testSuite": "epc139-25", "generateReport": true }'
Expected response:
{ "testRunId": "test_run_123456", "status": "running", "totalTests": 131, "estimatedDuration": "5-10 minutes"}
✅ 2. Check Test Results
Section titled “✅ 2. Check Test Results”# Get detailed test reportcurl https://localhost:8443/test/epc/report/test_run_123456 \ --cert certs/client/client.crt \ --key certs/client/client.key
Expected results:
{ "status": "completed", "summary": { "totalTests": 131, "passed": 129, "failed": 2, "compliance": "98.5%" }}
✅ 3. Generate Test Data
Section titled “✅ 3. Generate Test Data”# Create 100 test verification requestscurl -X POST https://localhost:8443/test/data/generate \ --cert certs/client/client.crt \ --key certs/client/client.key \ -H "Content-Type: application/json" \ -d '{ "count": 100, "scenarios": ["exact_match", "no_match", "close_match"] }'
Test Categories
Section titled “Test Categories”🎯 EPC Compliance Tests
Section titled “🎯 EPC Compliance Tests”- Name verification - 45 test cases
- BIC verification - 32 test cases
- LEI verification - 28 test cases
- ID verification - 26 test cases
🔒 Security Tests
Section titled “🔒 Security Tests”- Certificate validation - Valid/invalid certificates
- Authentication tests - mTLS authentication
- Rate limiting - Abuse prevention
- Error handling - Malformed requests
⚡ Performance Tests
Section titled “⚡ Performance Tests”- Load testing - Multiple concurrent requests
- Response time - Latency measurements
- Throughput - Requests per second
- Resource usage - Memory and CPU monitoring
Interactive Web Testing
Section titled “Interactive Web Testing”🌐 Access Testing Interface
Section titled “🌐 Access Testing Interface”- Open browser: https://localhost:8443/test
- Select test type: Choose from pre-built scenarios
- Enter test data: IBAN and name combinations
- Run test: Click “Verify” button
- View results: See instant verification results
📊 Test Scenarios Available
Section titled “📊 Test Scenarios Available”- ✅ Perfect matches - Names that should match exactly
- ❌ Fraud cases - Names that should be blocked
- ⚠️ Partial matches - Close matches needing review
- 🚫 Error cases - Invalid IBANs and malformed data
Performance Testing
Section titled “Performance Testing”📈 Load Testing
Section titled “📈 Load Testing”# Test with 50 concurrent requestscurl -X POST https://localhost:8443/test/performance/load \ --cert certs/client/client.crt \ --key certs/client/client.key \ -H "Content-Type: application/json" \ -d '{ "concurrentUsers": 50, "duration": "60s", "rampUpTime": "10s" }'
📊 Performance Metrics
Section titled “📊 Performance Metrics”# Get real-time performance datacurl https://localhost:8443/test/performance/metrics \ --cert certs/client/client.crt \ --key certs/client/client.key
Expected metrics:
{ "requestsPerSecond": 45.2, "averageResponseTime": "125ms", "successRate": "99.8%", "activeConnections": 12}
Certificate Testing
Section titled “Certificate Testing”🔐 Test Certificate Setup
Section titled “🔐 Test Certificate Setup”# Validate certificate chaincurl https://localhost:8443/test/certificates/chain \ --cert certs/client/client.crt \ --key certs/client/client.key
🛡️ Security Validation
Section titled “🛡️ Security Validation”# Test different certificate scenarioscurl -X POST https://localhost:8443/test/certificates/validate \ --cert certs/client/client.crt \ --key certs/client/client.key \ -H "Content-Type: application/json" \ -d '{ "scenarios": [ "valid_certificate", "expired_certificate", "invalid_chain" ] }'
Test Environment Management
Section titled “Test Environment Management”🔄 Reset Test Environment
Section titled “🔄 Reset Test Environment”# Clean slate for testingcurl -X POST https://localhost:8443/test/environment/reset \ --cert certs/client/client.crt \ --key certs/client/client.key \ -H "Content-Type: application/json" \ -d '{ "resetDatabase": true, "reloadTestData": true }'
📦 Load Test Data
Section titled “📦 Load Test Data”# Load standard EPC test datacurl -X POST https://localhost:8443/test/data/load \ --cert certs/client/client.crt \ --key certs/client/client.key \ -H "Content-Type: application/json" \ -d '{ "dataSet": "epc_reference_data", "version": "v1.0" }'
Integration Testing Workflow
Section titled “Integration Testing Workflow”🔄 Complete Test Workflow
Section titled “🔄 Complete Test Workflow”# 1. Reset environmentcurl -X POST https://localhost:8443/test/environment/reset \ --cert certs/client/client.crt --key certs/client/client.key \ -H "Content-Type: application/json" \ -d '{"resetDatabase": true, "reloadTestData": true}'
# 2. Load test datacurl -X POST https://localhost:8443/test/data/load \ --cert certs/client/client.crt --key certs/client/client.key \ -H "Content-Type: application/json" \ -d '{"dataSet": "epc_reference_data", "version": "v1.0"}'
# 3. Run compliance testscurl -X POST https://localhost:8443/test/epc/run \ --cert certs/client/client.crt --key certs/client/client.key \ -H "Content-Type: application/json" \ -d '{"testSuite": "epc139-25", "generateReport": true}'
# 4. Check results (wait 5-10 minutes)curl https://localhost:8443/test/epc/report/{testRunId} \ --cert certs/client/client.crt --key certs/client/client.key
JavaScript Integration Example
Section titled “JavaScript Integration Example”💻 Automated Testing Script
Section titled “💻 Automated Testing Script”// Complete test automationasync function runVoPTests() { const baseUrl = 'https://localhost:8443'; const options = { // Add certificate configuration here headers: { 'Content-Type': 'application/json' } };
try { // 1. Reset environment console.log('Resetting test environment...'); await fetch(`${baseUrl}/test/environment/reset`, { method: 'POST', ...options, body: JSON.stringify({ resetDatabase: true, reloadTestData: true }) });
// 2. Run EPC tests console.log('Starting EPC compliance tests...'); const testResponse = await fetch(`${baseUrl}/test/epc/run`, { method: 'POST', ...options, body: JSON.stringify({ testSuite: 'epc139-25', generateReport: true }) });
const testRun = await testResponse.json(); console.log(`Test run started: ${testRun.testRunId}`);
// 3. Wait for completion and get results let completed = false; while (!completed) { await new Promise(resolve => setTimeout(resolve, 30000)); // Wait 30s
const resultResponse = await fetch( `${baseUrl}/test/epc/report/${testRun.testRunId}`, options ); const result = await resultResponse.json();
if (result.status === 'completed') { console.log('Tests completed:', result.summary); console.log(`Compliance: ${result.compliance.overall}`); completed = true; } else { console.log(`Test status: ${result.status}`); } } } catch (error) { console.error('Test execution failed:', error); }}
// Run testsrunVoPTests();
Python Integration Example
Section titled “Python Integration Example”🐍 Python Test Script
Section titled “🐍 Python Test Script”import requestsimport timeimport json
def run_vop_tests(): base_url = 'https://localhost:8443' cert = ('certs/client/client.crt', 'certs/client/client.key')
try: # 1. Reset environment print('Resetting test environment...') requests.post( f'{base_url}/test/environment/reset', cert=cert, json={'resetDatabase': True, 'reloadTestData': True} )
# 2. Run EPC tests print('Starting EPC compliance tests...') test_response = requests.post( f'{base_url}/test/epc/run', cert=cert, json={'testSuite': 'epc139-25', 'generateReport': True} )
test_run = test_response.json() test_run_id = test_run['testRunId'] print(f'Test run started: {test_run_id}')
# 3. Wait for completion while True: result_response = requests.get( f'{base_url}/test/epc/report/{test_run_id}', cert=cert ) result = result_response.json()
if result['status'] == 'completed': print(f"Tests completed: {result['summary']}") print(f"Compliance: {result['compliance']['overall']}") break else: print(f"Test status: {result['status']}") time.sleep(30) # Wait 30 seconds
except Exception as error: print(f'Test execution failed: {error}')
if __name__ == '__main__': run_vop_tests()
Error Handling
Section titled “Error Handling”🚫 Common Test Errors
Section titled “🚫 Common Test Errors”{ "error": { "code": "TEST_EXECUTION_FAILED", "message": "Test execution failed due to invalid configuration", "details": { "suggestion": "Check test data availability and certificate validity" } }}
🔧 Troubleshooting
Section titled “🔧 Troubleshooting”- Certificate errors: Regenerate certificates with
make generate-docker-certs
- Test data missing: Load test data with
/test/data/load
endpoint - Environment issues: Reset environment with
/test/environment/reset
CI/CD Integration
Section titled “CI/CD Integration”🔄 GitHub Actions Example
Section titled “🔄 GitHub Actions Example”name: VoP API Tests
on: push: branches: [ main, develop ] pull_request: branches: [ main ]
jobs: test: runs-on: ubuntu-latest
steps: - uses: actions/checkout@v3
- name: Setup certificates run: | echo "${{ secrets.CLIENT_CERT }}" > client.crt echo "${{ secrets.CLIENT_KEY }}" > client.key
- name: Run EPC compliance tests run: | curl -X POST https://localhost:8443/test/epc/run \ --cert client.crt --key client.key \ -H "Content-Type: application/json" \ -d '{"testSuite": "epc139-25", "generateReport": true}'