71 lines
2.2 KiB
Python
71 lines
2.2 KiB
Python
|
|
#!/usr/bin/env python3
|
||
|
|
"""
|
||
|
|
Simple test script to verify route consistency in the gateway.
|
||
|
|
This script checks that all routes follow the /api/v1 pattern.
|
||
|
|
"""
|
||
|
|
|
||
|
|
import re
|
||
|
|
from pathlib import Path
|
||
|
|
|
||
|
|
def test_route_consistency():
|
||
|
|
"""Test that all routes follow the /api/v1 pattern."""
|
||
|
|
|
||
|
|
# Files to check
|
||
|
|
files_to_check = [
|
||
|
|
"app/main.py",
|
||
|
|
"app/routes/webhooks.py",
|
||
|
|
"app/middleware/auth.py"
|
||
|
|
]
|
||
|
|
|
||
|
|
print("Testing route consistency...")
|
||
|
|
|
||
|
|
# Patterns to look for
|
||
|
|
patterns = {
|
||
|
|
"old_sse_route": r'/api/events',
|
||
|
|
"old_webhook_route": r'/v1/webhooks',
|
||
|
|
"new_sse_route": r'/api/v1/events',
|
||
|
|
"new_webhook_route": r'/api/v1/webhooks'
|
||
|
|
}
|
||
|
|
|
||
|
|
issues_found = []
|
||
|
|
|
||
|
|
for file_path in files_to_check:
|
||
|
|
full_path = Path("gateway") / file_path
|
||
|
|
if not full_path.exists():
|
||
|
|
continue
|
||
|
|
|
||
|
|
print(f"\nChecking {file_path}...")
|
||
|
|
|
||
|
|
with open(full_path, 'r') as f:
|
||
|
|
content = f.read()
|
||
|
|
|
||
|
|
# Check for old patterns (should not exist)
|
||
|
|
for pattern_name, pattern in patterns.items():
|
||
|
|
if "old" in pattern_name:
|
||
|
|
matches = re.findall(pattern, content)
|
||
|
|
if matches:
|
||
|
|
issues_found.append(f"❌ Found old pattern {pattern} in {file_path}: {matches}")
|
||
|
|
else:
|
||
|
|
print(f"✅ No old {pattern_name} found")
|
||
|
|
|
||
|
|
# Check for new patterns (should exist)
|
||
|
|
for pattern_name, pattern in patterns.items():
|
||
|
|
if "new" in pattern_name:
|
||
|
|
matches = re.findall(pattern, content)
|
||
|
|
if matches:
|
||
|
|
print(f"✅ Found new {pattern_name}: {len(matches)} occurrences")
|
||
|
|
else:
|
||
|
|
issues_found.append(f"❌ Missing new pattern {pattern} in {file_path}")
|
||
|
|
|
||
|
|
if issues_found:
|
||
|
|
print("\n❌ Issues found:")
|
||
|
|
for issue in issues_found:
|
||
|
|
print(f" {issue}")
|
||
|
|
return False
|
||
|
|
else:
|
||
|
|
print("\n✅ All route consistency checks passed!")
|
||
|
|
return True
|
||
|
|
|
||
|
|
if __name__ == "__main__":
|
||
|
|
success = test_route_consistency()
|
||
|
|
exit(0 if success else 1)
|