Fix jwt-token
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
# Environment configuration for test scripts
|
||||
# Copy this to .env in the project root or set these as environment variables
|
||||
|
||||
# API Base URL - Update this to your deployment
|
||||
# API Base URL - Tests default to localhost:3002 for local development
|
||||
API_BASE_URL=http://localhost:3002/api
|
||||
|
||||
# For production deployment, use your domain:
|
||||
# For production/remote testing, update to your deployment:
|
||||
# API_BASE_URL=https://your-domain.com/uggla/api
|
||||
|
||||
# Base path (should match VITE_BASE_PATH)
|
||||
|
||||
@@ -14,7 +14,12 @@ import argparse
|
||||
import os
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
# Disable SSL warnings for self-signed certificates
|
||||
import warnings
|
||||
warnings.filterwarnings('ignore', message='Unverified HTTPS request')
|
||||
|
||||
# Configuration from environment variables
|
||||
# Tests default to localhost:3002 for local development
|
||||
API_BASE_URL = os.getenv('API_BASE_URL', 'http://localhost:3002/api')
|
||||
BASE_PATH = os.getenv('VITE_BASE_PATH', '').rstrip('/')
|
||||
|
||||
@@ -45,7 +50,7 @@ def fetch_devices():
|
||||
"""Fetch active devices from the API"""
|
||||
global DEVICES
|
||||
try:
|
||||
response = requests.get(f"{API_BASE_URL}/devices/map")
|
||||
response = requests.get(f"{API_BASE_URL}/devices/map", verify=False)
|
||||
if response.status_code == 200:
|
||||
data = response.json()
|
||||
api_devices = data.get('data', [])
|
||||
@@ -290,7 +295,7 @@ def send_heartbeat(device_id):
|
||||
print("-"*40 + "\n")
|
||||
|
||||
try:
|
||||
response = requests.post(url, json=heartbeat_data, headers=headers, timeout=10)
|
||||
response = requests.post(url, json=heartbeat_data, headers=headers, timeout=10, verify=False)
|
||||
|
||||
if response.status_code == 201:
|
||||
if DEBUG_MODE:
|
||||
@@ -326,7 +331,7 @@ def send_detection(detection_data):
|
||||
print("="*60 + "\n")
|
||||
|
||||
try:
|
||||
response = requests.post(url, json=detection_data, headers=headers, timeout=10)
|
||||
response = requests.post(url, json=detection_data, headers=headers, timeout=10, verify=False)
|
||||
|
||||
if response.status_code == 201:
|
||||
# Estimate distance from RSSI for display purposes only
|
||||
@@ -645,7 +650,7 @@ def test_api_health():
|
||||
url = f"{API_BASE_URL}/health"
|
||||
|
||||
try:
|
||||
response = requests.get(url, timeout=5)
|
||||
response = requests.get(url, timeout=5, verify=False)
|
||||
if response.status_code == 200:
|
||||
print("✅ API health check passed")
|
||||
return True
|
||||
|
||||
@@ -2,19 +2,7 @@
|
||||
"""
|
||||
Orlan Detection Test Script
|
||||
Tests the critical alert system for Orlan military drones by simulating
|
||||
a long-distan try:
|
||||
response = requests.post(f"{API_BASE_URL}/detectors", json=detection_data, headers=get_auth_headers())
|
||||
if response.status_code == 201:
|
||||
status = "🚨 CRITICAL ALERT" if distance_km <= 5 else "⚠️ DETECTED" if is_detectable(distance_km) else "📡 MONITORING"
|
||||
print(f"{status} - Step {step}/{total_steps}: Distance={distance_km:.1f}km, RSSI={rssi:.0f}dBm")
|
||||
return True
|
||||
else:
|
||||
print(f"❌ Failed to send detection: {response.status_code}")
|
||||
print(f"Response: {response.text}")
|
||||
return False
|
||||
except Exception as e:
|
||||
print(f"❌ Error sending detection: {e}")
|
||||
return Falserom undetectable range to directly overhead.
|
||||
a long-distance approach from undetectable range to directly overhead.
|
||||
|
||||
Test Scenario:
|
||||
- Starts 50km away (beyond detection range)
|
||||
@@ -30,7 +18,12 @@ import math
|
||||
import os
|
||||
from datetime import datetime
|
||||
|
||||
# Disable SSL warnings for self-signed certificates
|
||||
import warnings
|
||||
warnings.filterwarnings('ignore', message='Unverified HTTPS request')
|
||||
|
||||
# Configuration from environment variables
|
||||
# Tests default to localhost:3002 for local development
|
||||
API_BASE_URL = os.getenv('API_BASE_URL', 'http://localhost:3002/api')
|
||||
BASE_PATH = os.getenv('VITE_BASE_PATH', '').rstrip('/')
|
||||
|
||||
@@ -60,7 +53,7 @@ def authenticate():
|
||||
|
||||
try:
|
||||
print(f"🔐 Authenticating as user: {USERNAME}")
|
||||
response = requests.post(f"{API_BASE_URL}/auth/login", json=login_data)
|
||||
response = requests.post(f"{API_BASE_URL}/auth/login", json=login_data, verify=False)
|
||||
|
||||
if response.status_code == 200:
|
||||
data = response.json()
|
||||
@@ -127,7 +120,7 @@ def is_detectable(distance_km):
|
||||
def fetch_devices():
|
||||
"""Fetch devices from API"""
|
||||
try:
|
||||
response = requests.get(f"{API_BASE_URL}/devices", headers=get_auth_headers())
|
||||
response = requests.get(f"{API_BASE_URL}/devices", headers=get_auth_headers(), verify=False)
|
||||
if response.status_code == 200:
|
||||
data = response.json()
|
||||
return data.get('data', [])
|
||||
@@ -155,7 +148,7 @@ def send_detection(device, drone_lat, drone_lon, distance_km, step, total_steps)
|
||||
}
|
||||
|
||||
try:
|
||||
response = requests.post(f"{API_BASE_URL}/detectors", json=detection_data)
|
||||
response = requests.post(f"{API_BASE_URL}/detectors", json=detection_data, verify=False)
|
||||
if response.status_code == 201:
|
||||
status = "🚨 CRITICAL ALERT" if distance_km <= 5 else "⚠️ DETECTED" if is_detectable(distance_km) else "📡 MONITORING"
|
||||
print(f"{status} - Step {step}/{total_steps}: Distance={distance_km:.1f}km, RSSI={rssi:.0f}dBm")
|
||||
|
||||
@@ -12,7 +12,12 @@ import math
|
||||
import os
|
||||
from datetime import datetime
|
||||
|
||||
# Disable SSL warnings for self-signed certificates
|
||||
import warnings
|
||||
warnings.filterwarnings('ignore', message='Unverified HTTPS request')
|
||||
|
||||
# Configuration from environment variables
|
||||
# Tests default to localhost:3002 for local development
|
||||
API_BASE_URL = os.getenv('API_BASE_URL', 'http://localhost:3002/api')
|
||||
BASE_PATH = os.getenv('VITE_BASE_PATH', '').rstrip('/')
|
||||
|
||||
@@ -42,7 +47,7 @@ def authenticate():
|
||||
|
||||
try:
|
||||
print(f"🔐 Authenticating as user: {USERNAME}")
|
||||
response = requests.post(f"{API_BASE_URL}/auth/login", json=login_data)
|
||||
response = requests.post(f"{API_BASE_URL}/auth/login", json=login_data, verify=False)
|
||||
|
||||
if response.status_code == 200:
|
||||
data = response.json()
|
||||
@@ -100,7 +105,7 @@ def rssi_from_distance(distance_km):
|
||||
def fetch_devices():
|
||||
"""Fetch devices from API"""
|
||||
try:
|
||||
response = requests.get(f"{API_BASE_URL}/devices/map")
|
||||
response = requests.get(f"{API_BASE_URL}/devices/map", verify=False)
|
||||
if response.status_code == 200:
|
||||
data = response.json()
|
||||
return data.get('data', [])
|
||||
@@ -125,7 +130,7 @@ def send_detection(device, drone_lat, drone_lon, distance_km, step, total_steps)
|
||||
}
|
||||
|
||||
try:
|
||||
response = requests.post(f"{API_BASE_URL}/detections", json=detection_data)
|
||||
response = requests.post(f"{API_BASE_URL}/detections", json=detection_data, verify=False)
|
||||
if response.status_code == 201:
|
||||
print(f"🚨 ORLAN DETECTION {step}/{total_steps}: Distance={distance_km:.2f}km, RSSI={rssi:.0f}dBm")
|
||||
return True
|
||||
|
||||
Reference in New Issue
Block a user