Fix jwt-token
This commit is contained in:
@@ -183,49 +183,6 @@ def test_device_list():
|
||||
except Exception as e:
|
||||
print(f"❌ Unexpected error: {e}")
|
||||
|
||||
def test_alert_rules():
|
||||
"""Check if there are any device offline alert rules configured"""
|
||||
print("\n⚠️ Checking Device Offline Alert Rules")
|
||||
print("-" * 40)
|
||||
|
||||
try:
|
||||
response = requests.get(f"{API_BASE_URL}/alerts/rules", headers=get_auth_headers(), verify=False, timeout=10)
|
||||
|
||||
if response.status_code == 200:
|
||||
data = response.json()
|
||||
if data.get('success') and data.get('data'):
|
||||
rules = data['data']
|
||||
offline_rules = []
|
||||
|
||||
for rule in rules:
|
||||
conditions = rule.get('conditions', {})
|
||||
if conditions.get('device_offline'):
|
||||
offline_rules.append(rule)
|
||||
|
||||
if offline_rules:
|
||||
print(f"📋 Found {len(offline_rules)} device offline alert rules:")
|
||||
for rule in offline_rules:
|
||||
print(f" 📌 Rule: {rule['name']}")
|
||||
print(f" Description: {rule.get('description', 'No description')}")
|
||||
print(f" Active: {rule.get('is_active', False)}")
|
||||
print(f" Channels: {rule.get('alert_channels', [])}")
|
||||
if rule.get('sms_phone_number'):
|
||||
print(f" SMS: {rule['sms_phone_number']}")
|
||||
print()
|
||||
else:
|
||||
print("⚠️ No device offline alert rules found!")
|
||||
print(" You may want to create alert rules for device offline monitoring.")
|
||||
else:
|
||||
print(f"❌ No alert rules found")
|
||||
else:
|
||||
print(f"❌ HTTP Error: {response.status_code}")
|
||||
print(f" Response: {response.text}")
|
||||
|
||||
except requests.exceptions.RequestException as e:
|
||||
print(f"❌ Network error: {e}")
|
||||
except Exception as e:
|
||||
print(f"❌ Unexpected error: {e}")
|
||||
|
||||
def main():
|
||||
print("🏥 DEVICE HEALTH MONITORING TEST")
|
||||
print("=" * 60)
|
||||
@@ -239,15 +196,15 @@ def main():
|
||||
print("❌ Authentication failed, some tests may not work")
|
||||
print()
|
||||
|
||||
# Run all tests
|
||||
# Run relevant tests only
|
||||
test_device_health_status()
|
||||
test_device_list()
|
||||
test_alert_rules()
|
||||
test_manual_health_check()
|
||||
|
||||
print("\n" + "=" * 60)
|
||||
print("🏁 Device Health Monitoring Test Complete")
|
||||
print("=" * 60)
|
||||
print("ℹ️ Note: Alert rules are managed by the backend service automatically")
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
Reference in New Issue
Block a user