summaryrefslogtreecommitdiff
path: root/tests/test_connectivity.py
diff options
context:
space:
mode:
authorYuval Adam <_@yuv.al>2025-07-18 15:43:32 +0200
committerYuval Adam <_@yuv.al>2025-07-18 15:43:32 +0200
commitd0c73a92f27a652eaf925d880625a05ae211211d (patch)
tree7a82b603764f56690b7a8e3d0241e1d19934839c /tests/test_connectivity.py
parent350eedaf53068b1822846fceee15c97c644aad8a (diff)
Add tests
Diffstat (limited to 'tests/test_connectivity.py')
-rw-r--r--tests/test_connectivity.py58
1 files changed, 58 insertions, 0 deletions
diff --git a/tests/test_connectivity.py b/tests/test_connectivity.py
new file mode 100644
index 0000000..a344861
--- /dev/null
+++ b/tests/test_connectivity.py
@@ -0,0 +1,58 @@
+#!/usr/bin/env python3
+
+import sys
+import os
+import requests
+sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
+
+from config import Config
+
+def test_api_connectivity():
+ """Test basic API connectivity"""
+ print("="*50)
+ print("API CONNECTIVITY TEST")
+ print("="*50)
+
+ config = Config.from_env()
+
+ # Test Namecheap API connectivity
+ print("\n1. Testing Namecheap API connectivity...")
+ try:
+ response = requests.get("https://api.namecheap.com/xml.response",
+ params={"Command": "namecheap.domains.check", "DomainList": "test.com"},
+ timeout=10)
+ print(f" ✓ Namecheap API reachable (Status: {response.status_code})")
+ except Exception as e:
+ print(f" ❌ Namecheap API unreachable: {e}")
+
+ # Test Cloudflare API connectivity
+ print("\n2. Testing Cloudflare API connectivity...")
+ try:
+ headers = {"Authorization": f"Bearer {config.cloudflare_api_token}"}
+ response = requests.get("https://api.cloudflare.com/client/v4/user/tokens/verify",
+ headers=headers, timeout=10)
+ print(f" ✓ Cloudflare API reachable (Status: {response.status_code})")
+
+ if response.status_code == 200:
+ result = response.json()
+ if result.get('success'):
+ print(f" ✓ Cloudflare API token is valid")
+ else:
+ print(f" ❌ Cloudflare API token is invalid: {result.get('errors', [])}")
+ else:
+ print(f" ❌ Cloudflare API token verification failed")
+ except Exception as e:
+ print(f" ❌ Cloudflare API unreachable: {e}")
+
+ print("\n3. API Token Information:")
+ print(f" - Namecheap API Key: {len(config.namecheap_api_key)} chars")
+ print(f" - Cloudflare API Token: {len(config.cloudflare_api_token)} chars")
+ print(f" - Expected Cloudflare token length: 40 chars")
+
+ if len(config.cloudflare_api_token) < 40:
+ print(f" ⚠ Cloudflare token appears to be truncated")
+ print(f" - Current token: {config.cloudflare_api_token}")
+ print(f" - Please check if the token is complete in .env file")
+
+if __name__ == "__main__":
+ test_api_connectivity() \ No newline at end of file