Files
mtusi2026lab2/bruno/auth/register-user.bru
T
ilya.tyunin 575f8ee386
Skeleton contracts / contracts (pull_request) Canceled after 0s
feat: lab2 done
2026-10-09 15:48:03 +03:00

54 lines
1.3 KiB
Plaintext
Raw 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: Register first user
type: http
seq: 1
}
post {
url: {{baseUrl}}/api/v1/users
body: json
auth: none
}
body:json {
{
"username": "{{username}}",
"display_name": "Демо-пользователь",
"password": "{{password}}"
}
}
vars:pre-request {
baseUrl: http://localhost:8080
}
script:pre-request {
if (!bru.getVar("suffix")) {
bru.setVar("suffix", Math.random().toString(36).slice(2, 10));
}
bru.setVar("username", `demo_${bru.getVar("suffix")}`);
}
script:post-response {
bru.setVar("userId", res.body.id);
bru.setVar("displayName", res.body.display_name);
}
tests {
test("201 created", function() {
expect(res.status).to.equal(201);
});
test("пароль и хеш не утекли", function() {
expect(res.body).to.not.have.property("password");
expect(res.body).to.not.have.property("password_hash");
});
}
docs {
Регистрация с паролем (12–128 code points).
Username генерируется из случайного суффикса, чтобы повторный запуск коллекции
не упирался в 409. Сохраняет переменные: username, userId, displayName.
Ответ никогда не содержит password или password_hash.
}