ЛР4: username проверяется fullmatch, перевод строки -> 400 вместо 500

This commit is contained in:
LOSYASH
2026-11-09 17:42:46 +01:00
parent 92ce8c9a59
commit cc987efca9
2 changed files with 7 additions and 2 deletions
+3
View File
@@ -73,6 +73,9 @@ def main():
r.check(st == 400, "malformed JSON -> 400")
st, _, _ = api.call("POST", "/api/v1/users", {"username": alice["username"], "display_name": "d", "password": PASSWORD})
r.check(st == 409, "duplicate username -> 409")
for bad in ("review123\n", "review123\r\n", " review123", "Review123", "ab"):
st, _, _ = api.call("POST", "/api/v1/users", {"username": bad, "display_name": "d", "password": PASSWORD})
r.check(st == 400, f"invalid username {bad!r} -> 400, not 500 (got {st})")
st, _, _ = api.call("POST", mpath, {"text": " "}, token=alice["token"])
r.check(st == 400, "blank message -> 400")
st, _, _ = api.call("POST", mpath, {"text": "x", "sender_id": eve["id"]}, token=alice["token"])