Files
chat/tests/test_api_gateway_routes.py
Andrew K. Choi 64171196b6
All checks were successful
continuous-integration/drone/push Build is passing
calendar features
2025-09-26 14:45:00 +09:00

56 lines
2.5 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import requests
def test_api_gateway_routes():
# Базовый URL для API Gateway
base_url = "http://localhost:8000"
# Маршруты для проверки
routes = [
"/api/v1/calendar/entries", # Стандартный маршрут для календаря
"/api/v1/entry", # Маршрут для мобильного приложения
"/api/v1/entries", # Другой маршрут для мобильного приложения
]
# Создаем токен
token = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIyOSIsImVtYWlsIjoidGVzdDJAZXhhbXBsZS5jb20iLCJleHAiOjE3NTg4NjY5ODJ9._AXkBLeMI4zxC9shFUS3744miuyO8CDnJD1X1AqbLsw"
print("\nПроверка доступности маршрутов через API Gateway с GET:\n")
for route in routes:
try:
# Проверка без аутентификации
print(f"Проверка {route} без аутентификации:")
response = requests.get(f"{base_url}{route}")
status = response.status_code
if status == 404:
print(f"{route}: {status} - Маршрут не найден")
continue
print(f"{route} (без токена): {status} - {'Требует аутентификации' if status == 401 else 'OK'}")
# Проверка с аутентификацией
print(f"Проверка {route} с аутентификацией:")
auth_headers = {"Authorization": f"Bearer {token}"}
response = requests.get(f"{base_url}{route}", headers=auth_headers)
status = response.status_code
if status == 401:
print(f"{route} (с токеном): {status} - Проблема с аутентификацией")
elif status == 404:
print(f"{route} (с токеном): {status} - Маршрут не найден")
elif status == 200:
print(f"{route} (с токеном): {status} - OK")
else:
print(f"{route} (с токеном): {status} - Неожиданный код ответа")
except Exception as e:
print(f"{route}: Ошибка: {str(e)}")
print()
print("Проверка завершена.")
if __name__ == "__main__":
test_api_gateway_routes()