init commit

This commit is contained in:
2025-11-24 07:02:33 +09:00
commit 7bf003e70d
488 changed files with 51130 additions and 0 deletions

48
endpoint_test.sh Executable file
View File

@@ -0,0 +1,48 @@
#!/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 "✅ Тест завершён."