Reject noncanonical cursor dates and noninteger cursor versions
This commit is contained in:
@@ -143,3 +143,39 @@ def test_login_body_is_rejected(shared):
|
||||
raw=body,
|
||||
headers={"Authorization": "Basic " + basic},
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"date",
|
||||
[
|
||||
"2026-W01-1T00:00:00Z",
|
||||
"20260101T000000Z",
|
||||
"2026-01-01 00:00:00Z",
|
||||
"2026-01-01X00:00:00Z",
|
||||
"2026-01-01T00:00:00+00:00",
|
||||
"2026-02-30T00:00:00Z",
|
||||
"2026-01-01T24:00:00Z",
|
||||
"2026-01-01T00:00:00.1234567Z",
|
||||
],
|
||||
)
|
||||
def test_cursor_rejects_noncanonical_dates_over_http(shared, date):
|
||||
c, alice, _, _, chat = shared
|
||||
for path, scope in [
|
||||
("/api/v1/chats", "chats:" + alice["id"]),
|
||||
(f"/api/v1/chats/{chat['id']}/messages", "messages:" + chat["id"]),
|
||||
]:
|
||||
payload = [1, scope, date, str(uuid.uuid4())]
|
||||
cursor = base64.urlsafe_b64encode(json.dumps(payload).encode()).decode().rstrip("=")
|
||||
c.call("GET", path + "?cursor=" + cursor, 400, actor=alice)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("version", [True, 1.0])
|
||||
def test_cursor_rejects_noninteger_version_over_http(shared, version):
|
||||
c, alice, _, _, chat = shared
|
||||
for path, scope in [
|
||||
("/api/v1/chats", "chats:" + alice["id"]),
|
||||
(f"/api/v1/chats/{chat['id']}/messages", "messages:" + chat["id"]),
|
||||
]:
|
||||
payload = [version, scope, "2026-01-01T00:00:00Z", str(uuid.uuid4())]
|
||||
cursor = base64.urlsafe_b64encode(json.dumps(payload).encode()).decode().rstrip("=")
|
||||
c.call("GET", path + "?cursor=" + cursor, 400, actor=alice)
|
||||
|
||||
Reference in New Issue
Block a user