47 lines
1.1 KiB
Plaintext
47 lines
1.1 KiB
Plaintext
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);
|
||
}
|