Corp/api_tests.http
igor_nadein c819196bb9 feat(testing): добавление комплексной инфраструктуры API тестирования
Postman коллекция (52 теста):
- Аутентификация (3): login, refresh, verify
- Сотрудники (11): CRUD, search, bulk operations, skills
- Отделы (3): list, create, retrieve
- Документы (3): list, create, retrieve
- Лента (5): posts CRUD с пагинацией
- Коммуникации (5): чаты и сообщения
- Календарь (3): события и подписки
- Заявки (3): requests CRUD
- Уведомления (3): list, mark_read, mark_all_read
- Действия сотрудников (3): actions CRUD
- Роли отделов (3): department_roles CRUD
- Продвинутые функции: группы (5), навыки (2)

Newman CLI интеграция:
- newman_test_results.txt - последний запуск (32 requests, 0 failures)
- newman-report.json - детальный JSON отчет

REST Client:
- api_tests.http - альтернатива Postman для VSCode REST Client

Документация:
- API_QUICKSTART.md - быстрый старт с примерами
- docs/guides/API_TESTING_GUIDE.md - полное руководство (см. след. коммит)
2026-02-17 18:33:36 +03:00

468 lines
11 KiB
HTTP
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.

### EUSRR API Tests
### Используйте расширение REST Client для VS Code
### https://marketplace.visualstudio.com/items?itemName=humao.rest-client
@baseUrl = http://localhost:8000
@contentType = application/json
### Variables (будут заменены после выполнения Login запроса)
@accessToken = your_access_token_here
@refreshToken = your_refresh_token_here
#############################################
# Authentication
#############################################
### Login - Получение токена
# @name login
POST {{baseUrl}}/api/auth/token/
Content-Type: {{contentType}}
{
"email": "admin@example.com",
"password": "password"
}
### Save tokens to variables (автоматически после успешного login)
@accessToken = {{login.response.body.access}}
@refreshToken = {{login.response.body.refresh}}
### Refresh Token
POST {{baseUrl}}/api/auth/token/refresh/
Content-Type: {{contentType}}
{
"refresh": "{{refreshToken}}"
}
### Register New User
POST {{baseUrl}}/api/v1/auth/register/
Content-Type: {{contentType}}
{
"email": "newuser@example.com",
"password": "StrongPass123!",
"password2": "StrongPass123!",
"first_name": "Иван",
"last_name": "Иванов"
}
#############################################
# Employees
#############################################
### List Employees
GET {{baseUrl}}/api/v1/employees/?page=1
Authorization: Bearer {{accessToken}}
### Get Current User (Me)
GET {{baseUrl}}/api/v1/employees/me/
Authorization: Bearer {{accessToken}}
### Get Employee by ID
GET {{baseUrl}}/api/v1/employees/1/
Authorization: Bearer {{accessToken}}
### Update Employee
PATCH {{baseUrl}}/api/v1/employees/1/
Authorization: Bearer {{accessToken}}
Content-Type: {{contentType}}
{
"first_name": "Иван",
"last_name": "Петров"
}
### Search Employees
GET {{baseUrl}}/api/v1/employees/?search=Иванов
Authorization: Bearer {{accessToken}}
#############################################
# Departments
#############################################
### List Departments
GET {{baseUrl}}/api/v1/departments/
Authorization: Bearer {{accessToken}}
### Get Department by ID
GET {{baseUrl}}/api/v1/departments/1/
Authorization: Bearer {{accessToken}}
### Create Department
POST {{baseUrl}}/api/v1/departments/
Authorization: Bearer {{accessToken}}
Content-Type: {{contentType}}
{
"name": "Новый отдел",
"description": "Описание отдела"
}
### Update Department
PATCH {{baseUrl}}/api/v1/departments/1/
Authorization: Bearer {{accessToken}}
Content-Type: {{contentType}}
{
"name": "Обновленное название отдела"
}
#############################################
# Positions
#############################################
### List Positions
GET {{baseUrl}}/api/v1/positions/
Authorization: Bearer {{accessToken}}
### Create Position
POST {{baseUrl}}/api/v1/positions/
Authorization: Bearer {{accessToken}}
Content-Type: {{contentType}}
{
"title": "Разработчик",
"description": "Full-stack разработчик"
}
#############################################
# Documents
#############################################
### List Documents
GET {{baseUrl}}/api/v1/documents/?page=1
Authorization: Bearer {{accessToken}}
### Get Document by ID
GET {{baseUrl}}/api/v1/documents/1/
Authorization: Bearer {{accessToken}}
### Create Document
POST {{baseUrl}}/api/v1/documents/
Authorization: Bearer {{accessToken}}
Content-Type: {{contentType}}
{
"title": "Новый документ",
"content": "Содержание документа",
"document_type": "report"
}
### Update Document
PATCH {{baseUrl}}/api/v1/documents/1/
Authorization: Bearer {{accessToken}}
Content-Type: {{contentType}}
{
"title": "Обновленное название"
}
### Delete Document
DELETE {{baseUrl}}/api/v1/documents/1/
Authorization: Bearer {{accessToken}}
#############################################
# Feed (Posts & Comments)
#############################################
### List Posts
GET {{baseUrl}}/api/v1/posts/?page=1
Authorization: Bearer {{accessToken}}
### Get Post by ID
GET {{baseUrl}}/api/v1/posts/1/
Authorization: Bearer {{accessToken}}
### Create Post
POST {{baseUrl}}/api/v1/posts/
Authorization: Bearer {{accessToken}}
Content-Type: {{contentType}}
{
"content": "Новый пост в ленте компании! #важное"
}
### Update Post
PATCH {{baseUrl}}/api/v1/posts/1/
Authorization: Bearer {{accessToken}}
Content-Type: {{contentType}}
{
"content": "Обновленный пост"
}
### Delete Post
DELETE {{baseUrl}}/api/v1/posts/1/
Authorization: Bearer {{accessToken}}
### Like Post
POST {{baseUrl}}/api/v1/posts/1/like/
Authorization: Bearer {{accessToken}}
### Unlike Post
DELETE {{baseUrl}}/api/v1/posts/1/unlike/
Authorization: Bearer {{accessToken}}
### List Comments for Post
GET {{baseUrl}}/api/v1/comments/?post=1
Authorization: Bearer {{accessToken}}
### Create Comment
POST {{baseUrl}}/api/v1/comments/
Authorization: Bearer {{accessToken}}
Content-Type: {{contentType}}
{
"post": 1,
"content": "Отличный пост!"
}
#############################################
# Communications (Messenger)
#############################################
### List Chats
GET {{baseUrl}}/api/v1/communications/chats/
Authorization: Bearer {{accessToken}}
### Get Chat by ID
GET {{baseUrl}}/api/v1/communications/chats/1/
Authorization: Bearer {{accessToken}}
### Create Private Chat
POST {{baseUrl}}/api/v1/communications/chats/
Authorization: Bearer {{accessToken}}
Content-Type: {{contentType}}
{
"chat_type": "private",
"participants": [2]
}
### Create Group Chat
POST {{baseUrl}}/api/v1/communications/chats/
Authorization: Bearer {{accessToken}}
Content-Type: {{contentType}}
{
"name": "Рабочая группа",
"chat_type": "group",
"participants": [2, 3, 4]
}
### List Messages in Chat
GET {{baseUrl}}/api/v1/communications/messages/?chat=1
Authorization: Bearer {{accessToken}}
### Send Message
POST {{baseUrl}}/api/v1/communications/messages/
Authorization: Bearer {{accessToken}}
Content-Type: {{contentType}}
{
"chat": 1,
"content": "Привет! Это тестовое сообщение"
}
### Update Message
PATCH {{baseUrl}}/api/v1/communications/messages/1/
Authorization: Bearer {{accessToken}}
Content-Type: {{contentType}}
{
"content": "Исправленное сообщение"
}
### Delete Message
DELETE {{baseUrl}}/api/v1/communications/messages/1/
Authorization: Bearer {{accessToken}}
### Mark Message as Read
POST {{baseUrl}}/api/v1/communications/messages/1/mark_as_read/
Authorization: Bearer {{accessToken}}
#############################################
# Calendar
#############################################
### List Calendars
GET {{baseUrl}}/api/v1/calendar/calendars/
Authorization: Bearer {{accessToken}}
### List Events
GET {{baseUrl}}/api/v1/calendar/events/
Authorization: Bearer {{accessToken}}
### Get Events for Date Range
GET {{baseUrl}}/api/v1/calendar/events/?start=2026-02-01&end=2026-02-28
Authorization: Bearer {{accessToken}}
### Create Event
POST {{baseUrl}}/api/v1/calendar/events/
Authorization: Bearer {{accessToken}}
Content-Type: {{contentType}}
{
"title": "Встреча",
"start": "2026-02-20T10:00:00Z",
"end": "2026-02-20T11:00:00Z",
"description": "Важная встреча",
"location": "Офис"
}
### Update Event
PATCH {{baseUrl}}/api/v1/calendar/events/1/
Authorization: Bearer {{accessToken}}
Content-Type: {{contentType}}
{
"title": "Перенесенная встреча"
}
### Delete Event
DELETE {{baseUrl}}/api/v1/calendar/events/1/
Authorization: Bearer {{accessToken}}
#############################################
# Requests (Заявки)
#############################################
### List Requests
GET {{baseUrl}}/api/v1/requests/?page=1
Authorization: Bearer {{accessToken}}
### Filter Requests by Status
GET {{baseUrl}}/api/v1/requests/?status=pending
Authorization: Bearer {{accessToken}}
### Get Request by ID
GET {{baseUrl}}/api/v1/requests/1/
Authorization: Bearer {{accessToken}}
### Create Request
POST {{baseUrl}}/api/v1/requests/
Authorization: Bearer {{accessToken}}
Content-Type: {{contentType}}
{
"title": "Новая заявка в IT",
"description": "Не работает интернет в кабинете 205",
"request_type": "support",
"priority": "high"
}
### Update Request
PATCH {{baseUrl}}/api/v1/requests/1/
Authorization: Bearer {{accessToken}}
Content-Type: {{contentType}}
{
"status": "in_progress"
}
#############################################
# Notifications
#############################################
### List Notifications
GET {{baseUrl}}/api/v1/notifications/
Authorization: Bearer {{accessToken}}
### Get Unread Notifications Count
GET {{baseUrl}}/api/v1/notifications/unread_count/
Authorization: Bearer {{accessToken}}
### Get Notification by ID
GET {{baseUrl}}/api/v1/notifications/1/
Authorization: Bearer {{accessToken}}
### Mark Notification as Read
POST {{baseUrl}}/api/v1/notifications/1/mark_as_read/
Authorization: Bearer {{accessToken}}
### Mark All Notifications as Read
POST {{baseUrl}}/api/v1/notifications/mark_all_as_read/
Authorization: Bearer {{accessToken}}
### Delete Notification
DELETE {{baseUrl}}/api/v1/notifications/1/
Authorization: Bearer {{accessToken}}
#############################################
# Groups
#############################################
### List Groups
GET {{baseUrl}}/api/v1/groups/
Authorization: Bearer {{accessToken}}
### Get Group by ID
GET {{baseUrl}}/api/v1/groups/1/
Authorization: Bearer {{accessToken}}
### Create Group
POST {{baseUrl}}/api/v1/groups/
Authorization: Bearer {{accessToken}}
Content-Type: {{contentType}}
{
"name": "Администраторы",
"description": "Группа администраторов системы"
}
#############################################
# Skills
#############################################
### List Skills
GET {{baseUrl}}/api/v1/skills/
Authorization: Bearer {{accessToken}}
### Create Skill
POST {{baseUrl}}/api/v1/skills/
Authorization: Bearer {{accessToken}}
Content-Type: {{contentType}}
{
"name": "Python",
"category": "programming"
}
#############################################
# Polls
#############################################
### List Polls
GET {{baseUrl}}/api/v1/communications/polls/
Authorization: Bearer {{accessToken}}
### Get Poll by ID
GET {{baseUrl}}/api/v1/communications/polls/1/
Authorization: Bearer {{accessToken}}
### Create Poll
POST {{baseUrl}}/api/v1/communications/polls/
Authorization: Bearer {{accessToken}}
Content-Type: {{contentType}}
{
"question": "Где провести корпоратив?",
"options": [
{"text": "Ресторан"},
{"text": "Боулинг"},
{"text": "Квест-комната"}
],
"multiple_choice": false,
"anonymous": false
}
### Vote in Poll
POST {{baseUrl}}/api/v1/communications/polls/1/vote/
Authorization: Bearer {{accessToken}}
Content-Type: {{contentType}}
{
"option_id": 1
}