Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

test_classes: Give useful error when using /json/ URLs wrong.

Tim Abbott9361a3cffe7c
diff --git a/zerver/lib/test_classes.py b/zerver/lib/test_classes.py
index 399dcecff68..48e2d0d7fd8 100644
--- a/zerver/lib/test_classes.py
+++ b/zerver/lib/test_classes.py
@@ -1074,6 +1074,7 @@ Output:
def api_get(
self, user: UserProfile, url: str, info: Mapping[str, Any] = {}, **extra: str
) -> "TestHttpResponse":
+ assert not url.startswith("/json/"), "Invalid URL for API authentication"
extra["HTTP_AUTHORIZATION"] = self.encode_user(user)
return self.client_get(
url,
@@ -1096,6 +1097,7 @@ Output:
intentionally_undocumented: bool = False,
**extra: str,
) -> "TestHttpResponse":
+ assert not url.startswith("/json/"), "Invalid URL for API authentication"
extra["HTTP_AUTHORIZATION"] = self.encode_user(user)
return self.client_post(
url,
@@ -1112,6 +1114,7 @@ Output:
def api_patch(
self, user: UserProfile, url: str, info: Mapping[str, Any] = {}, **extra: str
) -> "TestHttpResponse":
+ assert not url.startswith("/json/"), "Invalid URL for API authentication"
extra["HTTP_AUTHORIZATION"] = self.encode_user(user)
return self.client_patch(
url,
@@ -1128,6 +1131,7 @@ Output:
def api_delete(
self, user: UserProfile, url: str, info: Mapping[str, Any] = {}, **extra: str
) -> "TestHttpResponse":
+ assert not url.startswith("/json/"), "Invalid URL for API authentication"
extra["HTTP_AUTHORIZATION"] = self.encode_user(user)
return self.client_delete(
url,