mirror of
https://git.dirksys.ovh/dirk/bankserver.git
synced 2025-12-20 02:59:20 +01:00
184 lines
3.7 KiB
Plaintext
184 lines
3.7 KiB
Plaintext
POST {{host}}/api/login
|
|
{
|
|
"name": "user1",
|
|
"password": "this-is-a-password"
|
|
}
|
|
HTTP 200
|
|
|
|
[Captures]
|
|
user1-token: jsonpath "$.token"
|
|
|
|
POST {{host}}/api/login
|
|
{
|
|
"name": "user2",
|
|
"password": "this-is-a-password"
|
|
}
|
|
HTTP 200
|
|
|
|
[Captures]
|
|
user2-token: jsonpath "$.token"
|
|
|
|
POST {{host}}/api/login
|
|
{
|
|
"name": "user3",
|
|
"password": "this-is-a-password"
|
|
}
|
|
HTTP 200
|
|
|
|
[Captures]
|
|
user3-token: jsonpath "$.token"
|
|
|
|
GET {{host}}/api/users/@me
|
|
Authorization: Bearer {{user1-token}}
|
|
HTTP 200
|
|
[Captures]
|
|
user1: jsonpath "$.id"
|
|
|
|
GET {{host}}/api/users/@me
|
|
Authorization: Bearer {{user2-token}}
|
|
HTTP 200
|
|
[Captures]
|
|
user2: jsonpath "$.id"
|
|
|
|
POST {{host}}/api/chats
|
|
Authorization: Bearer {{user1-token}}
|
|
{
|
|
"user": "user2"
|
|
}
|
|
HTTP 200
|
|
|
|
[Captures]
|
|
chat: jsonpath "$.id"
|
|
|
|
# Verify that other users can't access chat
|
|
|
|
GET {{host}}/api/chats?limit=50
|
|
Authorization: Bearer {{user3-token}}
|
|
HTTP 200
|
|
[Asserts]
|
|
jsonpath "$.pagination.limit" == 50
|
|
jsonpath "$.pagination.offset" == 0
|
|
jsonpath "$.pagination.total" == 0
|
|
jsonpath "$.result" isCollection
|
|
jsonpath "$.result" isEmpty
|
|
|
|
GET {{host}}/api/chats/{{chat}}
|
|
Authorization: Bearer {{user3-token}}
|
|
HTTP 403
|
|
GET {{host}}/api/chats/{{chat}}/messages?limit=50
|
|
Authorization: Bearer {{user3-token}}
|
|
HTTP 403
|
|
|
|
# List chats for all users that participate
|
|
|
|
GET {{host}}/api/chats?limit=50
|
|
Authorization: Bearer {{user1-token}}
|
|
HTTP 200
|
|
[Asserts]
|
|
jsonpath "$.pagination.limit" == 50
|
|
jsonpath "$.pagination.offset" == 0
|
|
jsonpath "$.pagination.total" == 1
|
|
jsonpath "$.result" isCollection
|
|
jsonpath "$.result[0].id" == {{chat}}
|
|
|
|
GET {{host}}/api/chats?limit=50
|
|
Authorization: Bearer {{user2-token}}
|
|
HTTP 200
|
|
[Asserts]
|
|
jsonpath "$.pagination.limit" == 50
|
|
jsonpath "$.pagination.offset" == 0
|
|
jsonpath "$.pagination.total" == 1
|
|
jsonpath "$.result" isCollection
|
|
jsonpath "$.result[0].id" == {{chat}}
|
|
|
|
# Post messages
|
|
|
|
POST {{host}}/api/chats/{{chat}}/messages
|
|
Authorization: Bearer {{user1-token}}
|
|
{
|
|
"text": "Hello World 1"
|
|
}
|
|
HTTP 200
|
|
[Asserts]
|
|
jsonpath "$.text" == "Hello World 1"
|
|
jsonpath "$.sender" == {{user1}}
|
|
jsonpath "$.extra" == null
|
|
[Captures]
|
|
message1: jsonpath "$.id"
|
|
|
|
POST {{host}}/api/chats/{{chat}}/messages
|
|
Authorization: Bearer {{user2-token}}
|
|
{
|
|
"text": "Hello World 2"
|
|
}
|
|
HTTP 200
|
|
[Asserts]
|
|
jsonpath "$.text" == "Hello World 2"
|
|
jsonpath "$.sender" == {{user2}}
|
|
jsonpath "$.extra" == null
|
|
[Captures]
|
|
message2: jsonpath "$.id"
|
|
|
|
## Test read status
|
|
|
|
GET {{host}}/api/chats/{{chat}}
|
|
Authorization: Bearer {{user1-token}}
|
|
HTTP 200
|
|
[Asserts]
|
|
jsonpath "$.id" == {{chat}}
|
|
jsonpath "$.read_until" == null
|
|
|
|
GET {{host}}/api/chats/{{chat}}
|
|
Authorization: Bearer {{user2-token}}
|
|
HTTP 200
|
|
[Asserts]
|
|
jsonpath "$.id" == {{chat}}
|
|
jsonpath "$.read_until" == null
|
|
|
|
|
|
POST {{host}}/api/chats/{{chat}}/messages/{{message2}}/read
|
|
Authorization: Bearer {{user2-token}}
|
|
HTTP 200
|
|
|
|
GET {{host}}/api/chats/{{chat}}
|
|
Authorization: Bearer {{user2-token}}
|
|
HTTP 200
|
|
[Asserts]
|
|
jsonpath "$.id" == {{chat}}
|
|
jsonpath "$.read_until" == {{message2}}
|
|
jsonpath "$.unread" == 0
|
|
|
|
|
|
POST {{host}}/api/chats/{{chat}}/messages/{{message1}}/read
|
|
Authorization: Bearer {{user2-token}}
|
|
HTTP 200
|
|
|
|
GET {{host}}/api/chats/{{chat}}
|
|
Authorization: Bearer {{user2-token}}
|
|
HTTP 200
|
|
[Asserts]
|
|
jsonpath "$.id" == {{chat}}
|
|
jsonpath "$.read_until" == {{message1}}
|
|
jsonpath "$.unread" == 1
|
|
|
|
|
|
GET {{host}}/api/chats/{{chat}}
|
|
Authorization: Bearer {{user1-token}}
|
|
HTTP 200
|
|
[Asserts]
|
|
jsonpath "$.id" == {{chat}}
|
|
jsonpath "$.read_until" == null
|
|
jsonpath "$.unread" == 2
|
|
|
|
# Verify list messages endpoint
|
|
|
|
GET {{host}}/api/chats/{{chat}}/messages?limit=50
|
|
Authorization: Bearer {{user1-token}}
|
|
HTTP 200
|
|
[Asserts]
|
|
jsonpath "$.pagination.limit" == 50
|
|
jsonpath "$.pagination.offset" == 0
|
|
jsonpath "$.result" isCollection
|
|
jsonpath "$.result[0].id" == {{message2}}
|
|
jsonpath "$.result[1].id" == {{message1}}
|