Files
mtusi2026lab2/bruno/negative/invalid-calendar-cursor.bru
2026-10-10 02:13:35 +03:00

47 lines
1.6 KiB
Plaintext
Raw Permalink 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.
meta {
name: Invalid calendar cursor
type: http
seq: 7
}
get {
url: {{baseUrl}}/api/v1/chats/{{chatId}}/messages?cursor={{calendarCursor}}
body: none
auth: none
}
headers {
Authorization: Bearer {{token}}
}
script:pre-request {
// Курсор собирается с реальным scope текущего чата, но с датой 31 февраля:
// платформенный Date.parse молча переносит её на 3 марта, поэтому проверка
// календаря (date-fns parseISO) должна отклонить запрос до SQL.
// В песочнице Bruno доступен btoa, но не Buffer.
const json = JSON.stringify({
scope: `messages:${bru.getVar("chatId")}`,
created_at: "2026-02-31T00:00:00.000Z",
id: "00000000-0000-4000-8000-000000000000"
});
const cursor = btoa(json).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
bru.setVar("calendarCursor", cursor);
}
tests {
test("400 invalid_request", function() {
expect(res.status).to.equal(400);
});
test("формат ошибки по контракту", function() {
expect(res.body.error.code).to.equal("invalid_request");
expect(res.body.error.request_id).to.equal(res.headers["x-request-id"]);
});
}
docs {
Несуществующая календарная дата (31 февраля, 29 февраля невисокосного года)
— 400 invalid_request, а не 500 из PostgreSQL. Регрессия: 2026-02-31 проходила
проверку формы и доходила до SQL.
}