Files
2026-10-09 15:48:03 +03:00

47 lines
1.1 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: Create session (Basic)
type: http
seq: 4
}
post {
url: {{baseUrl}}/api/v1/auth/sessions
body: none
auth: basic
}
auth:basic {
username: {{username}}
password: {{password}}
}
docs {
Вход: Authorization: Basic base64(username:password), тело запроса не передаётся.
Пароль кодируется как UTF-8, разделитель — первый символ ":".
Сохраняет token и expiresAt. Неверные credentials дают 401 с
WWW-Authenticate: Basic realm="messenger", charset="UTF-8".
}
tests {
test("201 created", function() {
expect(res.status).to.equal(201);
});
test("token_type bearer", function() {
expect(res.body.token_type).to.equal("Bearer");
});
test("expires_at в UTC", function() {
expect(res.body.expires_at).to.match(/Z$/);
});
test("user совпадает с зарегистрированным", function() {
expect(res.body.user.id).to.equal(bru.getVar("userId"));
});
}
script:post-response {
bru.setVar("token", res.body.token);
bru.setVar("expiresAt", res.body.expires_at);
}