Files
smartsoltech_site/endpoint_test.sh
Andrey K. Choi 37d7fc74b8 fix: PostgreSQL compatibility and Telegram bot token validation
- Fixed PostgreSQL 18+ compatibility by using postgres:17 image
- Added token validation for Telegram bot
- Improved error handling in telegram_bot.py
- Added scripts for bot token management
- Cleaned up old QR codes and added new utility files
2025-11-23 21:23:51 +09:00

49 lines
1.6 KiB
Bash
Executable File
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
BASE_URL="http://localhost:8002/auth"
EMAIL="testuser@example.com"
PASSWORD="secret123"
echo "1⃣ Регистрация пользователя..."
curl -s -X POST "$BASE_URL/register" \
-H "Content-Type: application/json" \
-d "{\"email\": \"$EMAIL\", \"password\": \"$PASSWORD\"}" | tee response_register.json
echo -e "\n"
USER_ID=$(jq .id response_register.json)
echo "2⃣ Аутентификация..."
curl -s -X POST "$BASE_URL/login" \
-H "Content-Type: application/json" \
-d "{\"email\": \"$EMAIL\", \"password\": \"$PASSWORD\"}" | tee response_login.json
echo -e "\n"
TOKEN=$(jq -r .access_token response_login.json)
echo "🔐 Получен токен: $TOKEN"
AUTH_HEADER="Authorization: Bearer $TOKEN"
echo "3⃣ Получение текущего пользователя (/me)..."
curl -s -X GET "$BASE_URL/me" -H "$AUTH_HEADER" | tee response_me.json
echo -e "\n"
echo "4⃣ Получение списка всех пользователей..."
curl -s -X GET "$BASE_URL/users" | tee response_users.json
echo -e "\n"
echo "5⃣ Получение пользователя по ID ($USER_ID)..."
curl -s -X GET "$BASE_URL/users/$USER_ID" | tee response_user.json
echo -e "\n"
echo "6⃣ Обновление пользователя..."
curl -s -X PUT "$BASE_URL/users/$USER_ID" \
-H "Content-Type: application/json" \
-d "{\"email\": \"updated_$EMAIL\", \"role\": \"admin\"}" | tee response_update.json
echo -e "\n"
echo "7⃣ Удаление пользователя..."
curl -s -X DELETE "$BASE_URL/users/$USER_ID" | tee response_delete.json
echo -e "\n"
echo "✅ Тест завершён."