test: verify level-four failures and history index
This commit is contained in:
@@ -14,12 +14,13 @@ import urllib.request
|
||||
from uuid import uuid4
|
||||
|
||||
import psycopg
|
||||
from src.db import database_url
|
||||
|
||||
|
||||
URL = os.environ.get("DATABASE_URL")
|
||||
URL = database_url() if os.environ.get("DATABASE_URL") or os.environ.get("DATABASE_URL_FILE") else None
|
||||
|
||||
|
||||
@unittest.skipUnless(URL, "set DATABASE_URL to a disposable PostgreSQL database")
|
||||
@unittest.skipUnless(URL, "set DATABASE_URL or DATABASE_URL_FILE to a disposable PostgreSQL database")
|
||||
class AuthTests(unittest.TestCase):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
@@ -81,7 +82,7 @@ class AuthTests(unittest.TestCase):
|
||||
status = response.status
|
||||
response_headers = response.headers
|
||||
data = response.read()
|
||||
assert status == expected, (method, path, expected, status)
|
||||
assert status == expected, (method, path.split("?", 1)[0], expected, status)
|
||||
request_id = response_headers.get("X-Request-Id")
|
||||
assert request_id
|
||||
payload = json.loads(data) if data else None
|
||||
@@ -140,6 +141,15 @@ class AuthTests(unittest.TestCase):
|
||||
self.assertEqual(headers.get("WWW-Authenticate"), 'Basic realm="messenger", charset="UTF-8"')
|
||||
self.call("POST", "/api/v1/auth/sessions", authorization="Basic " + encoded, body={"unexpected": True}, expected=400)
|
||||
|
||||
def test_huge_page_limit_is_bad_request(self):
|
||||
user, password = self.user()
|
||||
session, _ = self.login(user["username"], password)
|
||||
bearer = "Bearer " + session["token"]
|
||||
for path in ("/api/v1/chats", f"/api/v1/chats/{uuid4()}/messages"):
|
||||
self.call("GET", path + "?limit=" + "9" * 4301, authorization=bearer, expected=400)
|
||||
self.call("GET", "/api/v1/chats?limit=0001", authorization=bearer)
|
||||
self.call("GET", "/api/v1/chats?limit=%D9%A0", authorization=bearer, expected=400)
|
||||
|
||||
def test_z_short_ttl_survives_server_restart_without_extension(self):
|
||||
self.stop_server()
|
||||
self.start_server(ttl="2")
|
||||
|
||||
Reference in New Issue
Block a user