Files
mtusi2026lab2/evidence/lab2/level4-2026-10-08_e64b104/10-rollback.txt
T
2026-10-08 21:21:07 +03:00

17 lines
2.8 KiB
Plaintext

$BASE = 'http://localhost:8080'
$u = 'rollback_' + [guid]::NewGuid().ToString('N').Substring(0,8)
$body = '{\"username\":\"' + $u + '\",\"display_name\":\"RB\",\"password\":\"Test-1234-abcdef\"}'
curl.exe -s -X POST "$BASE/api/v1/users" -H "Content-Type: application/json" -d $body | Out-Null
$cred = [Convert]::ToBase64String([Text.Encoding]::UTF8.GetBytes($u + ':Test-1234-abcdef'))
$tok = (curl.exe -s -X POST "$BASE/api/v1/auth/sessions" -H "Authorization: Basic $cred" | ConvertFrom-Json).token
$me = curl.exe -s "$BASE/api/v1/users/me" -H "Authorization: Bearer $tok" | ConvertFrom-Json
$title = 'rollback-test-' + [guid]::NewGuid().ToString('N').Substring(0,8)
$chatBody = '{\"title\":\"' + $title + '\",\"member_ids\":[\"' + $me.id + '\",\"99999999-9999-4999-8999-999999999999\"]}'
$response = curl.exe -s -w "`nHTTP %{http_code}" -X POST "$BASE/api/v1/chats" -H "Authorization: Bearer $tok" -H "Content-Type: application/json" -d $chatBody
"response: $response" | Tee-Object "$EV4\10-rollback.txt"
$count = docker compose --env-file .env exec -T db psql -U messenger -d messenger -t -c "SELECT count(*) FROM chats WHERE title = '$title';"
"chats with this title: $($count.Trim())" | Tee-Object -Append "$EV4\10-rollback.txt"
response: {"error":{"code":"not_found","message":"Users not found: [99999999-9999-4999-8999-999999999999]","request_id":"a503493b-8e8f-42b5-a92f-78177a5655b7"}} HTTP 404
chats with this title: 0