mirror of
https://mau.dev/maunium/synapse.git
synced 2024-10-01 01:36:05 -04:00
Use literals in place of HTTPStatus
constants in tests (#13488)
* Use literals in place of `HTTPStatus` constants in tests * newsfile * code style * code style
This commit is contained in:
parent
51c01d450a
commit
2281427175
1
changelog.d/13488.misc
Normal file
1
changelog.d/13488.misc
Normal file
@ -0,0 +1 @@
|
||||
Use literals in place of `HTTPStatus` constants in tests.
|
@ -11,7 +11,6 @@
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
from http import HTTPStatus
|
||||
from typing import Collection
|
||||
|
||||
from parameterized import parameterized
|
||||
@ -81,7 +80,7 @@ class BackgroundUpdatesTestCase(unittest.HomeserverTestCase):
|
||||
access_token=self.admin_user_tok,
|
||||
)
|
||||
|
||||
self.assertEqual(HTTPStatus.BAD_REQUEST, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(400, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(Codes.MISSING_PARAM, channel.json_body["errcode"])
|
||||
|
||||
# job_name invalid
|
||||
@ -92,7 +91,7 @@ class BackgroundUpdatesTestCase(unittest.HomeserverTestCase):
|
||||
access_token=self.admin_user_tok,
|
||||
)
|
||||
|
||||
self.assertEqual(HTTPStatus.BAD_REQUEST, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(400, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(Codes.UNKNOWN, channel.json_body["errcode"])
|
||||
|
||||
def _register_bg_update(self) -> None:
|
||||
@ -365,4 +364,4 @@ class BackgroundUpdatesTestCase(unittest.HomeserverTestCase):
|
||||
access_token=self.admin_user_tok,
|
||||
)
|
||||
|
||||
self.assertEqual(HTTPStatus.BAD_REQUEST, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(400, channel.code, msg=channel.json_body)
|
||||
|
@ -12,7 +12,6 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
import urllib.parse
|
||||
from http import HTTPStatus
|
||||
|
||||
from parameterized import parameterized
|
||||
|
||||
@ -104,7 +103,7 @@ class DeviceRestTestCase(unittest.HomeserverTestCase):
|
||||
@parameterized.expand(["GET", "PUT", "DELETE"])
|
||||
def test_user_is_not_local(self, method: str) -> None:
|
||||
"""
|
||||
Tests that a lookup for a user that is not a local returns a HTTPStatus.BAD_REQUEST
|
||||
Tests that a lookup for a user that is not a local returns a 400
|
||||
"""
|
||||
url = (
|
||||
"/_synapse/admin/v2/users/@unknown_person:unknown_domain/devices/%s"
|
||||
@ -117,7 +116,7 @@ class DeviceRestTestCase(unittest.HomeserverTestCase):
|
||||
access_token=self.admin_user_tok,
|
||||
)
|
||||
|
||||
self.assertEqual(HTTPStatus.BAD_REQUEST, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(400, channel.code, msg=channel.json_body)
|
||||
self.assertEqual("Can only lookup local users", channel.json_body["error"])
|
||||
|
||||
def test_unknown_device(self) -> None:
|
||||
@ -179,7 +178,7 @@ class DeviceRestTestCase(unittest.HomeserverTestCase):
|
||||
content=update,
|
||||
)
|
||||
|
||||
self.assertEqual(HTTPStatus.BAD_REQUEST, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(400, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(Codes.TOO_LARGE, channel.json_body["errcode"])
|
||||
|
||||
# Ensure the display name was not updated.
|
||||
@ -353,7 +352,7 @@ class DevicesRestTestCase(unittest.HomeserverTestCase):
|
||||
|
||||
def test_user_is_not_local(self) -> None:
|
||||
"""
|
||||
Tests that a lookup for a user that is not a local returns a HTTPStatus.BAD_REQUEST
|
||||
Tests that a lookup for a user that is not a local returns a 400
|
||||
"""
|
||||
url = "/_synapse/admin/v2/users/@unknown_person:unknown_domain/devices"
|
||||
|
||||
@ -363,7 +362,7 @@ class DevicesRestTestCase(unittest.HomeserverTestCase):
|
||||
access_token=self.admin_user_tok,
|
||||
)
|
||||
|
||||
self.assertEqual(HTTPStatus.BAD_REQUEST, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(400, channel.code, msg=channel.json_body)
|
||||
self.assertEqual("Can only lookup local users", channel.json_body["error"])
|
||||
|
||||
def test_user_has_no_devices(self) -> None:
|
||||
@ -479,7 +478,7 @@ class DeleteDevicesRestTestCase(unittest.HomeserverTestCase):
|
||||
|
||||
def test_user_is_not_local(self) -> None:
|
||||
"""
|
||||
Tests that a lookup for a user that is not a local returns a HTTPStatus.BAD_REQUEST
|
||||
Tests that a lookup for a user that is not a local returns a 400
|
||||
"""
|
||||
url = "/_synapse/admin/v2/users/@unknown_person:unknown_domain/delete_devices"
|
||||
|
||||
@ -489,7 +488,7 @@ class DeleteDevicesRestTestCase(unittest.HomeserverTestCase):
|
||||
access_token=self.admin_user_tok,
|
||||
)
|
||||
|
||||
self.assertEqual(HTTPStatus.BAD_REQUEST, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(400, channel.code, msg=channel.json_body)
|
||||
self.assertEqual("Can only lookup local users", channel.json_body["error"])
|
||||
|
||||
def test_unknown_devices(self) -> None:
|
||||
|
@ -11,7 +11,6 @@
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
from http import HTTPStatus
|
||||
from typing import List
|
||||
|
||||
from twisted.test.proto_helpers import MemoryReactor
|
||||
@ -81,11 +80,7 @@ class EventReportsTestCase(unittest.HomeserverTestCase):
|
||||
"""
|
||||
channel = self.make_request("GET", self.url, b"{}")
|
||||
|
||||
self.assertEqual(
|
||||
401,
|
||||
channel.code,
|
||||
msg=channel.json_body,
|
||||
)
|
||||
self.assertEqual(401, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(Codes.MISSING_TOKEN, channel.json_body["errcode"])
|
||||
|
||||
def test_requester_is_no_admin(self) -> None:
|
||||
@ -99,11 +94,7 @@ class EventReportsTestCase(unittest.HomeserverTestCase):
|
||||
access_token=self.other_user_tok,
|
||||
)
|
||||
|
||||
self.assertEqual(
|
||||
403,
|
||||
channel.code,
|
||||
msg=channel.json_body,
|
||||
)
|
||||
self.assertEqual(403, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(Codes.FORBIDDEN, channel.json_body["errcode"])
|
||||
|
||||
def test_default_success(self) -> None:
|
||||
@ -278,7 +269,7 @@ class EventReportsTestCase(unittest.HomeserverTestCase):
|
||||
|
||||
def test_invalid_search_order(self) -> None:
|
||||
"""
|
||||
Testing that a invalid search order returns a HTTPStatus.BAD_REQUEST
|
||||
Testing that a invalid search order returns a 400
|
||||
"""
|
||||
|
||||
channel = self.make_request(
|
||||
@ -287,17 +278,13 @@ class EventReportsTestCase(unittest.HomeserverTestCase):
|
||||
access_token=self.admin_user_tok,
|
||||
)
|
||||
|
||||
self.assertEqual(
|
||||
HTTPStatus.BAD_REQUEST,
|
||||
channel.code,
|
||||
msg=channel.json_body,
|
||||
)
|
||||
self.assertEqual(400, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(Codes.INVALID_PARAM, channel.json_body["errcode"])
|
||||
self.assertEqual("Unknown direction: bar", channel.json_body["error"])
|
||||
|
||||
def test_limit_is_negative(self) -> None:
|
||||
"""
|
||||
Testing that a negative limit parameter returns a HTTPStatus.BAD_REQUEST
|
||||
Testing that a negative limit parameter returns a 400
|
||||
"""
|
||||
|
||||
channel = self.make_request(
|
||||
@ -306,16 +293,12 @@ class EventReportsTestCase(unittest.HomeserverTestCase):
|
||||
access_token=self.admin_user_tok,
|
||||
)
|
||||
|
||||
self.assertEqual(
|
||||
HTTPStatus.BAD_REQUEST,
|
||||
channel.code,
|
||||
msg=channel.json_body,
|
||||
)
|
||||
self.assertEqual(400, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(Codes.INVALID_PARAM, channel.json_body["errcode"])
|
||||
|
||||
def test_from_is_negative(self) -> None:
|
||||
"""
|
||||
Testing that a negative from parameter returns a HTTPStatus.BAD_REQUEST
|
||||
Testing that a negative from parameter returns a 400
|
||||
"""
|
||||
|
||||
channel = self.make_request(
|
||||
@ -324,11 +307,7 @@ class EventReportsTestCase(unittest.HomeserverTestCase):
|
||||
access_token=self.admin_user_tok,
|
||||
)
|
||||
|
||||
self.assertEqual(
|
||||
HTTPStatus.BAD_REQUEST,
|
||||
channel.code,
|
||||
msg=channel.json_body,
|
||||
)
|
||||
self.assertEqual(400, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(Codes.INVALID_PARAM, channel.json_body["errcode"])
|
||||
|
||||
def test_next_token(self) -> None:
|
||||
@ -466,11 +445,7 @@ class EventReportDetailTestCase(unittest.HomeserverTestCase):
|
||||
"""
|
||||
channel = self.make_request("GET", self.url, b"{}")
|
||||
|
||||
self.assertEqual(
|
||||
401,
|
||||
channel.code,
|
||||
msg=channel.json_body,
|
||||
)
|
||||
self.assertEqual(401, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(Codes.MISSING_TOKEN, channel.json_body["errcode"])
|
||||
|
||||
def test_requester_is_no_admin(self) -> None:
|
||||
@ -484,11 +459,7 @@ class EventReportDetailTestCase(unittest.HomeserverTestCase):
|
||||
access_token=self.other_user_tok,
|
||||
)
|
||||
|
||||
self.assertEqual(
|
||||
403,
|
||||
channel.code,
|
||||
msg=channel.json_body,
|
||||
)
|
||||
self.assertEqual(403, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(Codes.FORBIDDEN, channel.json_body["errcode"])
|
||||
|
||||
def test_default_success(self) -> None:
|
||||
@ -507,7 +478,7 @@ class EventReportDetailTestCase(unittest.HomeserverTestCase):
|
||||
|
||||
def test_invalid_report_id(self) -> None:
|
||||
"""
|
||||
Testing that an invalid `report_id` returns a HTTPStatus.BAD_REQUEST.
|
||||
Testing that an invalid `report_id` returns a 400.
|
||||
"""
|
||||
|
||||
# `report_id` is negative
|
||||
@ -517,11 +488,7 @@ class EventReportDetailTestCase(unittest.HomeserverTestCase):
|
||||
access_token=self.admin_user_tok,
|
||||
)
|
||||
|
||||
self.assertEqual(
|
||||
HTTPStatus.BAD_REQUEST,
|
||||
channel.code,
|
||||
msg=channel.json_body,
|
||||
)
|
||||
self.assertEqual(400, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(Codes.INVALID_PARAM, channel.json_body["errcode"])
|
||||
self.assertEqual(
|
||||
"The report_id parameter must be a string representing a positive integer.",
|
||||
@ -535,11 +502,7 @@ class EventReportDetailTestCase(unittest.HomeserverTestCase):
|
||||
access_token=self.admin_user_tok,
|
||||
)
|
||||
|
||||
self.assertEqual(
|
||||
HTTPStatus.BAD_REQUEST,
|
||||
channel.code,
|
||||
msg=channel.json_body,
|
||||
)
|
||||
self.assertEqual(400, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(Codes.INVALID_PARAM, channel.json_body["errcode"])
|
||||
self.assertEqual(
|
||||
"The report_id parameter must be a string representing a positive integer.",
|
||||
@ -553,11 +516,7 @@ class EventReportDetailTestCase(unittest.HomeserverTestCase):
|
||||
access_token=self.admin_user_tok,
|
||||
)
|
||||
|
||||
self.assertEqual(
|
||||
HTTPStatus.BAD_REQUEST,
|
||||
channel.code,
|
||||
msg=channel.json_body,
|
||||
)
|
||||
self.assertEqual(400, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(Codes.INVALID_PARAM, channel.json_body["errcode"])
|
||||
self.assertEqual(
|
||||
"The report_id parameter must be a string representing a positive integer.",
|
||||
@ -575,11 +534,7 @@ class EventReportDetailTestCase(unittest.HomeserverTestCase):
|
||||
access_token=self.admin_user_tok,
|
||||
)
|
||||
|
||||
self.assertEqual(
|
||||
404,
|
||||
channel.code,
|
||||
msg=channel.json_body,
|
||||
)
|
||||
self.assertEqual(404, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(Codes.NOT_FOUND, channel.json_body["errcode"])
|
||||
self.assertEqual("Event report not found", channel.json_body["error"])
|
||||
|
||||
|
@ -11,7 +11,6 @@
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
from http import HTTPStatus
|
||||
from typing import List, Optional
|
||||
|
||||
from parameterized import parameterized
|
||||
@ -77,7 +76,7 @@ class FederationTestCase(unittest.HomeserverTestCase):
|
||||
access_token=self.admin_user_tok,
|
||||
)
|
||||
|
||||
self.assertEqual(HTTPStatus.BAD_REQUEST, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(400, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(Codes.INVALID_PARAM, channel.json_body["errcode"])
|
||||
|
||||
# negative from
|
||||
@ -87,7 +86,7 @@ class FederationTestCase(unittest.HomeserverTestCase):
|
||||
access_token=self.admin_user_tok,
|
||||
)
|
||||
|
||||
self.assertEqual(HTTPStatus.BAD_REQUEST, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(400, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(Codes.INVALID_PARAM, channel.json_body["errcode"])
|
||||
|
||||
# unkown order_by
|
||||
@ -97,7 +96,7 @@ class FederationTestCase(unittest.HomeserverTestCase):
|
||||
access_token=self.admin_user_tok,
|
||||
)
|
||||
|
||||
self.assertEqual(HTTPStatus.BAD_REQUEST, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(400, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(Codes.INVALID_PARAM, channel.json_body["errcode"])
|
||||
|
||||
# invalid search order
|
||||
@ -107,7 +106,7 @@ class FederationTestCase(unittest.HomeserverTestCase):
|
||||
access_token=self.admin_user_tok,
|
||||
)
|
||||
|
||||
self.assertEqual(HTTPStatus.BAD_REQUEST, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(400, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(Codes.INVALID_PARAM, channel.json_body["errcode"])
|
||||
|
||||
# invalid destination
|
||||
@ -469,7 +468,7 @@ class FederationTestCase(unittest.HomeserverTestCase):
|
||||
access_token=self.admin_user_tok,
|
||||
)
|
||||
|
||||
self.assertEqual(HTTPStatus.BAD_REQUEST, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(400, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(
|
||||
"The retry timing does not need to be reset for this destination.",
|
||||
channel.json_body["error"],
|
||||
@ -574,7 +573,7 @@ class DestinationMembershipTestCase(unittest.HomeserverTestCase):
|
||||
access_token=self.admin_user_tok,
|
||||
)
|
||||
|
||||
self.assertEqual(HTTPStatus.BAD_REQUEST, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(400, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(Codes.INVALID_PARAM, channel.json_body["errcode"])
|
||||
|
||||
# negative from
|
||||
@ -584,7 +583,7 @@ class DestinationMembershipTestCase(unittest.HomeserverTestCase):
|
||||
access_token=self.admin_user_tok,
|
||||
)
|
||||
|
||||
self.assertEqual(HTTPStatus.BAD_REQUEST, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(400, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(Codes.INVALID_PARAM, channel.json_body["errcode"])
|
||||
|
||||
# invalid search order
|
||||
@ -594,7 +593,7 @@ class DestinationMembershipTestCase(unittest.HomeserverTestCase):
|
||||
access_token=self.admin_user_tok,
|
||||
)
|
||||
|
||||
self.assertEqual(HTTPStatus.BAD_REQUEST, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(400, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(Codes.INVALID_PARAM, channel.json_body["errcode"])
|
||||
|
||||
# invalid destination
|
||||
|
@ -13,7 +13,6 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
import os
|
||||
from http import HTTPStatus
|
||||
|
||||
from parameterized import parameterized
|
||||
|
||||
@ -81,11 +80,7 @@ class DeleteMediaByIDTestCase(unittest.HomeserverTestCase):
|
||||
access_token=self.other_user_token,
|
||||
)
|
||||
|
||||
self.assertEqual(
|
||||
403,
|
||||
channel.code,
|
||||
msg=channel.json_body,
|
||||
)
|
||||
self.assertEqual(403, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(Codes.FORBIDDEN, channel.json_body["errcode"])
|
||||
|
||||
def test_media_does_not_exist(self) -> None:
|
||||
@ -105,7 +100,7 @@ class DeleteMediaByIDTestCase(unittest.HomeserverTestCase):
|
||||
|
||||
def test_media_is_not_local(self) -> None:
|
||||
"""
|
||||
Tests that a lookup for a media that is not a local returns a HTTPStatus.BAD_REQUEST
|
||||
Tests that a lookup for a media that is not a local returns a 400
|
||||
"""
|
||||
url = "/_synapse/admin/v1/media/%s/%s" % ("unknown_domain", "12345")
|
||||
|
||||
@ -115,7 +110,7 @@ class DeleteMediaByIDTestCase(unittest.HomeserverTestCase):
|
||||
access_token=self.admin_user_tok,
|
||||
)
|
||||
|
||||
self.assertEqual(HTTPStatus.BAD_REQUEST, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(400, channel.code, msg=channel.json_body)
|
||||
self.assertEqual("Can only delete local media", channel.json_body["error"])
|
||||
|
||||
def test_delete_media(self) -> None:
|
||||
@ -230,11 +225,7 @@ class DeleteMediaByDateSizeTestCase(unittest.HomeserverTestCase):
|
||||
|
||||
channel = self.make_request("POST", self.url, b"{}")
|
||||
|
||||
self.assertEqual(
|
||||
401,
|
||||
channel.code,
|
||||
msg=channel.json_body,
|
||||
)
|
||||
self.assertEqual(401, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(Codes.MISSING_TOKEN, channel.json_body["errcode"])
|
||||
|
||||
def test_requester_is_no_admin(self) -> None:
|
||||
@ -250,16 +241,12 @@ class DeleteMediaByDateSizeTestCase(unittest.HomeserverTestCase):
|
||||
access_token=self.other_user_token,
|
||||
)
|
||||
|
||||
self.assertEqual(
|
||||
403,
|
||||
channel.code,
|
||||
msg=channel.json_body,
|
||||
)
|
||||
self.assertEqual(403, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(Codes.FORBIDDEN, channel.json_body["errcode"])
|
||||
|
||||
def test_media_is_not_local(self) -> None:
|
||||
"""
|
||||
Tests that a lookup for media that is not local returns a HTTPStatus.BAD_REQUEST
|
||||
Tests that a lookup for media that is not local returns a 400
|
||||
"""
|
||||
url = "/_synapse/admin/v1/media/%s/delete" % "unknown_domain"
|
||||
|
||||
@ -269,7 +256,7 @@ class DeleteMediaByDateSizeTestCase(unittest.HomeserverTestCase):
|
||||
access_token=self.admin_user_tok,
|
||||
)
|
||||
|
||||
self.assertEqual(HTTPStatus.BAD_REQUEST, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(400, channel.code, msg=channel.json_body)
|
||||
self.assertEqual("Can only delete local media", channel.json_body["error"])
|
||||
|
||||
def test_missing_parameter(self) -> None:
|
||||
@ -282,11 +269,7 @@ class DeleteMediaByDateSizeTestCase(unittest.HomeserverTestCase):
|
||||
access_token=self.admin_user_tok,
|
||||
)
|
||||
|
||||
self.assertEqual(
|
||||
HTTPStatus.BAD_REQUEST,
|
||||
channel.code,
|
||||
msg=channel.json_body,
|
||||
)
|
||||
self.assertEqual(400, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(Codes.MISSING_PARAM, channel.json_body["errcode"])
|
||||
self.assertEqual(
|
||||
"Missing integer query parameter 'before_ts'", channel.json_body["error"]
|
||||
@ -302,11 +285,7 @@ class DeleteMediaByDateSizeTestCase(unittest.HomeserverTestCase):
|
||||
access_token=self.admin_user_tok,
|
||||
)
|
||||
|
||||
self.assertEqual(
|
||||
HTTPStatus.BAD_REQUEST,
|
||||
channel.code,
|
||||
msg=channel.json_body,
|
||||
)
|
||||
self.assertEqual(400, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(Codes.INVALID_PARAM, channel.json_body["errcode"])
|
||||
self.assertEqual(
|
||||
"Query parameter before_ts must be a positive integer.",
|
||||
@ -319,11 +298,7 @@ class DeleteMediaByDateSizeTestCase(unittest.HomeserverTestCase):
|
||||
access_token=self.admin_user_tok,
|
||||
)
|
||||
|
||||
self.assertEqual(
|
||||
HTTPStatus.BAD_REQUEST,
|
||||
channel.code,
|
||||
msg=channel.json_body,
|
||||
)
|
||||
self.assertEqual(400, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(Codes.INVALID_PARAM, channel.json_body["errcode"])
|
||||
self.assertEqual(
|
||||
"Query parameter before_ts you provided is from the year 1970. "
|
||||
@ -337,11 +312,7 @@ class DeleteMediaByDateSizeTestCase(unittest.HomeserverTestCase):
|
||||
access_token=self.admin_user_tok,
|
||||
)
|
||||
|
||||
self.assertEqual(
|
||||
HTTPStatus.BAD_REQUEST,
|
||||
channel.code,
|
||||
msg=channel.json_body,
|
||||
)
|
||||
self.assertEqual(400, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(Codes.INVALID_PARAM, channel.json_body["errcode"])
|
||||
self.assertEqual(
|
||||
"Query parameter size_gt must be a string representing a positive integer.",
|
||||
@ -354,11 +325,7 @@ class DeleteMediaByDateSizeTestCase(unittest.HomeserverTestCase):
|
||||
access_token=self.admin_user_tok,
|
||||
)
|
||||
|
||||
self.assertEqual(
|
||||
HTTPStatus.BAD_REQUEST,
|
||||
channel.code,
|
||||
msg=channel.json_body,
|
||||
)
|
||||
self.assertEqual(400, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(Codes.INVALID_PARAM, channel.json_body["errcode"])
|
||||
self.assertEqual(
|
||||
"Boolean query parameter 'keep_profiles' must be one of ['true', 'false']",
|
||||
@ -667,11 +634,7 @@ class QuarantineMediaByIDTestCase(unittest.HomeserverTestCase):
|
||||
b"{}",
|
||||
)
|
||||
|
||||
self.assertEqual(
|
||||
401,
|
||||
channel.code,
|
||||
msg=channel.json_body,
|
||||
)
|
||||
self.assertEqual(401, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(Codes.MISSING_TOKEN, channel.json_body["errcode"])
|
||||
|
||||
@parameterized.expand(["quarantine", "unquarantine"])
|
||||
@ -688,11 +651,7 @@ class QuarantineMediaByIDTestCase(unittest.HomeserverTestCase):
|
||||
access_token=self.other_user_token,
|
||||
)
|
||||
|
||||
self.assertEqual(
|
||||
403,
|
||||
channel.code,
|
||||
msg=channel.json_body,
|
||||
)
|
||||
self.assertEqual(403, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(Codes.FORBIDDEN, channel.json_body["errcode"])
|
||||
|
||||
def test_quarantine_media(self) -> None:
|
||||
@ -800,11 +759,7 @@ class ProtectMediaByIDTestCase(unittest.HomeserverTestCase):
|
||||
|
||||
channel = self.make_request("POST", self.url % (action, self.media_id), b"{}")
|
||||
|
||||
self.assertEqual(
|
||||
401,
|
||||
channel.code,
|
||||
msg=channel.json_body,
|
||||
)
|
||||
self.assertEqual(401, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(Codes.MISSING_TOKEN, channel.json_body["errcode"])
|
||||
|
||||
@parameterized.expand(["protect", "unprotect"])
|
||||
@ -821,11 +776,7 @@ class ProtectMediaByIDTestCase(unittest.HomeserverTestCase):
|
||||
access_token=self.other_user_token,
|
||||
)
|
||||
|
||||
self.assertEqual(
|
||||
403,
|
||||
channel.code,
|
||||
msg=channel.json_body,
|
||||
)
|
||||
self.assertEqual(403, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(Codes.FORBIDDEN, channel.json_body["errcode"])
|
||||
|
||||
def test_protect_media(self) -> None:
|
||||
@ -913,11 +864,7 @@ class PurgeMediaCacheTestCase(unittest.HomeserverTestCase):
|
||||
access_token=self.other_user_token,
|
||||
)
|
||||
|
||||
self.assertEqual(
|
||||
403,
|
||||
channel.code,
|
||||
msg=channel.json_body,
|
||||
)
|
||||
self.assertEqual(403, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(Codes.FORBIDDEN, channel.json_body["errcode"])
|
||||
|
||||
def test_invalid_parameter(self) -> None:
|
||||
@ -930,11 +877,7 @@ class PurgeMediaCacheTestCase(unittest.HomeserverTestCase):
|
||||
access_token=self.admin_user_tok,
|
||||
)
|
||||
|
||||
self.assertEqual(
|
||||
HTTPStatus.BAD_REQUEST,
|
||||
channel.code,
|
||||
msg=channel.json_body,
|
||||
)
|
||||
self.assertEqual(400, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(Codes.INVALID_PARAM, channel.json_body["errcode"])
|
||||
self.assertEqual(
|
||||
"Query parameter before_ts must be a positive integer.",
|
||||
@ -947,11 +890,7 @@ class PurgeMediaCacheTestCase(unittest.HomeserverTestCase):
|
||||
access_token=self.admin_user_tok,
|
||||
)
|
||||
|
||||
self.assertEqual(
|
||||
HTTPStatus.BAD_REQUEST,
|
||||
channel.code,
|
||||
msg=channel.json_body,
|
||||
)
|
||||
self.assertEqual(400, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(Codes.INVALID_PARAM, channel.json_body["errcode"])
|
||||
self.assertEqual(
|
||||
"Query parameter before_ts you provided is from the year 1970. "
|
||||
|
@ -13,7 +13,6 @@
|
||||
# limitations under the License.
|
||||
import random
|
||||
import string
|
||||
from http import HTTPStatus
|
||||
from typing import Optional
|
||||
|
||||
from twisted.test.proto_helpers import MemoryReactor
|
||||
@ -74,11 +73,7 @@ class ManageRegistrationTokensTestCase(unittest.HomeserverTestCase):
|
||||
def test_create_no_auth(self) -> None:
|
||||
"""Try to create a token without authentication."""
|
||||
channel = self.make_request("POST", self.url + "/new", {})
|
||||
self.assertEqual(
|
||||
401,
|
||||
channel.code,
|
||||
msg=channel.json_body,
|
||||
)
|
||||
self.assertEqual(401, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(Codes.MISSING_TOKEN, channel.json_body["errcode"])
|
||||
|
||||
def test_create_requester_not_admin(self) -> None:
|
||||
@ -89,11 +84,7 @@ class ManageRegistrationTokensTestCase(unittest.HomeserverTestCase):
|
||||
{},
|
||||
access_token=self.other_user_tok,
|
||||
)
|
||||
self.assertEqual(
|
||||
403,
|
||||
channel.code,
|
||||
msg=channel.json_body,
|
||||
)
|
||||
self.assertEqual(403, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(Codes.FORBIDDEN, channel.json_body["errcode"])
|
||||
|
||||
def test_create_using_defaults(self) -> None:
|
||||
@ -168,11 +159,7 @@ class ManageRegistrationTokensTestCase(unittest.HomeserverTestCase):
|
||||
access_token=self.admin_user_tok,
|
||||
)
|
||||
|
||||
self.assertEqual(
|
||||
HTTPStatus.BAD_REQUEST,
|
||||
channel.code,
|
||||
msg=channel.json_body,
|
||||
)
|
||||
self.assertEqual(400, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(channel.json_body["errcode"], Codes.INVALID_PARAM)
|
||||
|
||||
def test_create_token_invalid_chars(self) -> None:
|
||||
@ -188,11 +175,7 @@ class ManageRegistrationTokensTestCase(unittest.HomeserverTestCase):
|
||||
access_token=self.admin_user_tok,
|
||||
)
|
||||
|
||||
self.assertEqual(
|
||||
HTTPStatus.BAD_REQUEST,
|
||||
channel.code,
|
||||
msg=channel.json_body,
|
||||
)
|
||||
self.assertEqual(400, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(channel.json_body["errcode"], Codes.INVALID_PARAM)
|
||||
|
||||
def test_create_token_already_exists(self) -> None:
|
||||
@ -215,7 +198,7 @@ class ManageRegistrationTokensTestCase(unittest.HomeserverTestCase):
|
||||
data,
|
||||
access_token=self.admin_user_tok,
|
||||
)
|
||||
self.assertEqual(HTTPStatus.BAD_REQUEST, channel2.code, msg=channel2.json_body)
|
||||
self.assertEqual(400, channel2.code, msg=channel2.json_body)
|
||||
self.assertEqual(channel2.json_body["errcode"], Codes.INVALID_PARAM)
|
||||
|
||||
def test_create_unable_to_generate_token(self) -> None:
|
||||
@ -262,7 +245,7 @@ class ManageRegistrationTokensTestCase(unittest.HomeserverTestCase):
|
||||
access_token=self.admin_user_tok,
|
||||
)
|
||||
self.assertEqual(
|
||||
HTTPStatus.BAD_REQUEST,
|
||||
400,
|
||||
channel.code,
|
||||
msg=channel.json_body,
|
||||
)
|
||||
@ -275,11 +258,7 @@ class ManageRegistrationTokensTestCase(unittest.HomeserverTestCase):
|
||||
{"uses_allowed": 1.5},
|
||||
access_token=self.admin_user_tok,
|
||||
)
|
||||
self.assertEqual(
|
||||
HTTPStatus.BAD_REQUEST,
|
||||
channel.code,
|
||||
msg=channel.json_body,
|
||||
)
|
||||
self.assertEqual(400, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(channel.json_body["errcode"], Codes.INVALID_PARAM)
|
||||
|
||||
def test_create_expiry_time(self) -> None:
|
||||
@ -291,11 +270,7 @@ class ManageRegistrationTokensTestCase(unittest.HomeserverTestCase):
|
||||
{"expiry_time": self.clock.time_msec() - 10000},
|
||||
access_token=self.admin_user_tok,
|
||||
)
|
||||
self.assertEqual(
|
||||
HTTPStatus.BAD_REQUEST,
|
||||
channel.code,
|
||||
msg=channel.json_body,
|
||||
)
|
||||
self.assertEqual(400, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(channel.json_body["errcode"], Codes.INVALID_PARAM)
|
||||
|
||||
# Should fail with float
|
||||
@ -305,11 +280,7 @@ class ManageRegistrationTokensTestCase(unittest.HomeserverTestCase):
|
||||
{"expiry_time": self.clock.time_msec() + 1000000.5},
|
||||
access_token=self.admin_user_tok,
|
||||
)
|
||||
self.assertEqual(
|
||||
HTTPStatus.BAD_REQUEST,
|
||||
channel.code,
|
||||
msg=channel.json_body,
|
||||
)
|
||||
self.assertEqual(400, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(channel.json_body["errcode"], Codes.INVALID_PARAM)
|
||||
|
||||
def test_create_length(self) -> None:
|
||||
@ -331,11 +302,7 @@ class ManageRegistrationTokensTestCase(unittest.HomeserverTestCase):
|
||||
{"length": 0},
|
||||
access_token=self.admin_user_tok,
|
||||
)
|
||||
self.assertEqual(
|
||||
HTTPStatus.BAD_REQUEST,
|
||||
channel.code,
|
||||
msg=channel.json_body,
|
||||
)
|
||||
self.assertEqual(400, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(channel.json_body["errcode"], Codes.INVALID_PARAM)
|
||||
|
||||
# Should fail with a negative integer
|
||||
@ -345,11 +312,7 @@ class ManageRegistrationTokensTestCase(unittest.HomeserverTestCase):
|
||||
{"length": -5},
|
||||
access_token=self.admin_user_tok,
|
||||
)
|
||||
self.assertEqual(
|
||||
HTTPStatus.BAD_REQUEST,
|
||||
channel.code,
|
||||
msg=channel.json_body,
|
||||
)
|
||||
self.assertEqual(400, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(channel.json_body["errcode"], Codes.INVALID_PARAM)
|
||||
|
||||
# Should fail with a float
|
||||
@ -359,11 +322,7 @@ class ManageRegistrationTokensTestCase(unittest.HomeserverTestCase):
|
||||
{"length": 8.5},
|
||||
access_token=self.admin_user_tok,
|
||||
)
|
||||
self.assertEqual(
|
||||
HTTPStatus.BAD_REQUEST,
|
||||
channel.code,
|
||||
msg=channel.json_body,
|
||||
)
|
||||
self.assertEqual(400, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(channel.json_body["errcode"], Codes.INVALID_PARAM)
|
||||
|
||||
# Should fail with 65
|
||||
@ -373,11 +332,7 @@ class ManageRegistrationTokensTestCase(unittest.HomeserverTestCase):
|
||||
{"length": 65},
|
||||
access_token=self.admin_user_tok,
|
||||
)
|
||||
self.assertEqual(
|
||||
HTTPStatus.BAD_REQUEST,
|
||||
channel.code,
|
||||
msg=channel.json_body,
|
||||
)
|
||||
self.assertEqual(400, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(channel.json_body["errcode"], Codes.INVALID_PARAM)
|
||||
|
||||
# UPDATING
|
||||
@ -389,11 +344,7 @@ class ManageRegistrationTokensTestCase(unittest.HomeserverTestCase):
|
||||
self.url + "/1234", # Token doesn't exist but that doesn't matter
|
||||
{},
|
||||
)
|
||||
self.assertEqual(
|
||||
401,
|
||||
channel.code,
|
||||
msg=channel.json_body,
|
||||
)
|
||||
self.assertEqual(401, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(Codes.MISSING_TOKEN, channel.json_body["errcode"])
|
||||
|
||||
def test_update_requester_not_admin(self) -> None:
|
||||
@ -404,11 +355,7 @@ class ManageRegistrationTokensTestCase(unittest.HomeserverTestCase):
|
||||
{},
|
||||
access_token=self.other_user_tok,
|
||||
)
|
||||
self.assertEqual(
|
||||
403,
|
||||
channel.code,
|
||||
msg=channel.json_body,
|
||||
)
|
||||
self.assertEqual(403, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(Codes.FORBIDDEN, channel.json_body["errcode"])
|
||||
|
||||
def test_update_non_existent(self) -> None:
|
||||
@ -420,11 +367,7 @@ class ManageRegistrationTokensTestCase(unittest.HomeserverTestCase):
|
||||
access_token=self.admin_user_tok,
|
||||
)
|
||||
|
||||
self.assertEqual(
|
||||
404,
|
||||
channel.code,
|
||||
msg=channel.json_body,
|
||||
)
|
||||
self.assertEqual(404, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(channel.json_body["errcode"], Codes.NOT_FOUND)
|
||||
|
||||
def test_update_uses_allowed(self) -> None:
|
||||
@ -472,11 +415,7 @@ class ManageRegistrationTokensTestCase(unittest.HomeserverTestCase):
|
||||
{"uses_allowed": 1.5},
|
||||
access_token=self.admin_user_tok,
|
||||
)
|
||||
self.assertEqual(
|
||||
HTTPStatus.BAD_REQUEST,
|
||||
channel.code,
|
||||
msg=channel.json_body,
|
||||
)
|
||||
self.assertEqual(400, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(channel.json_body["errcode"], Codes.INVALID_PARAM)
|
||||
|
||||
# Should fail with a negative integer
|
||||
@ -486,11 +425,7 @@ class ManageRegistrationTokensTestCase(unittest.HomeserverTestCase):
|
||||
{"uses_allowed": -5},
|
||||
access_token=self.admin_user_tok,
|
||||
)
|
||||
self.assertEqual(
|
||||
HTTPStatus.BAD_REQUEST,
|
||||
channel.code,
|
||||
msg=channel.json_body,
|
||||
)
|
||||
self.assertEqual(400, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(channel.json_body["errcode"], Codes.INVALID_PARAM)
|
||||
|
||||
def test_update_expiry_time(self) -> None:
|
||||
@ -529,11 +464,7 @@ class ManageRegistrationTokensTestCase(unittest.HomeserverTestCase):
|
||||
{"expiry_time": past_time},
|
||||
access_token=self.admin_user_tok,
|
||||
)
|
||||
self.assertEqual(
|
||||
HTTPStatus.BAD_REQUEST,
|
||||
channel.code,
|
||||
msg=channel.json_body,
|
||||
)
|
||||
self.assertEqual(400, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(channel.json_body["errcode"], Codes.INVALID_PARAM)
|
||||
|
||||
# Should fail a float
|
||||
@ -543,11 +474,7 @@ class ManageRegistrationTokensTestCase(unittest.HomeserverTestCase):
|
||||
{"expiry_time": new_expiry_time + 0.5},
|
||||
access_token=self.admin_user_tok,
|
||||
)
|
||||
self.assertEqual(
|
||||
HTTPStatus.BAD_REQUEST,
|
||||
channel.code,
|
||||
msg=channel.json_body,
|
||||
)
|
||||
self.assertEqual(400, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(channel.json_body["errcode"], Codes.INVALID_PARAM)
|
||||
|
||||
def test_update_both(self) -> None:
|
||||
@ -589,11 +516,7 @@ class ManageRegistrationTokensTestCase(unittest.HomeserverTestCase):
|
||||
access_token=self.admin_user_tok,
|
||||
)
|
||||
|
||||
self.assertEqual(
|
||||
HTTPStatus.BAD_REQUEST,
|
||||
channel.code,
|
||||
msg=channel.json_body,
|
||||
)
|
||||
self.assertEqual(400, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(channel.json_body["errcode"], Codes.INVALID_PARAM)
|
||||
|
||||
# DELETING
|
||||
@ -605,11 +528,7 @@ class ManageRegistrationTokensTestCase(unittest.HomeserverTestCase):
|
||||
self.url + "/1234", # Token doesn't exist but that doesn't matter
|
||||
{},
|
||||
)
|
||||
self.assertEqual(
|
||||
401,
|
||||
channel.code,
|
||||
msg=channel.json_body,
|
||||
)
|
||||
self.assertEqual(401, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(Codes.MISSING_TOKEN, channel.json_body["errcode"])
|
||||
|
||||
def test_delete_requester_not_admin(self) -> None:
|
||||
@ -620,11 +539,7 @@ class ManageRegistrationTokensTestCase(unittest.HomeserverTestCase):
|
||||
{},
|
||||
access_token=self.other_user_tok,
|
||||
)
|
||||
self.assertEqual(
|
||||
403,
|
||||
channel.code,
|
||||
msg=channel.json_body,
|
||||
)
|
||||
self.assertEqual(403, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(Codes.FORBIDDEN, channel.json_body["errcode"])
|
||||
|
||||
def test_delete_non_existent(self) -> None:
|
||||
@ -636,11 +551,7 @@ class ManageRegistrationTokensTestCase(unittest.HomeserverTestCase):
|
||||
access_token=self.admin_user_tok,
|
||||
)
|
||||
|
||||
self.assertEqual(
|
||||
404,
|
||||
channel.code,
|
||||
msg=channel.json_body,
|
||||
)
|
||||
self.assertEqual(404, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(channel.json_body["errcode"], Codes.NOT_FOUND)
|
||||
|
||||
def test_delete(self) -> None:
|
||||
@ -666,11 +577,7 @@ class ManageRegistrationTokensTestCase(unittest.HomeserverTestCase):
|
||||
self.url + "/1234", # Token doesn't exist but that doesn't matter
|
||||
{},
|
||||
)
|
||||
self.assertEqual(
|
||||
401,
|
||||
channel.code,
|
||||
msg=channel.json_body,
|
||||
)
|
||||
self.assertEqual(401, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(Codes.MISSING_TOKEN, channel.json_body["errcode"])
|
||||
|
||||
def test_get_requester_not_admin(self) -> None:
|
||||
@ -697,11 +604,7 @@ class ManageRegistrationTokensTestCase(unittest.HomeserverTestCase):
|
||||
access_token=self.admin_user_tok,
|
||||
)
|
||||
|
||||
self.assertEqual(
|
||||
404,
|
||||
channel.code,
|
||||
msg=channel.json_body,
|
||||
)
|
||||
self.assertEqual(404, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(channel.json_body["errcode"], Codes.NOT_FOUND)
|
||||
|
||||
def test_get(self) -> None:
|
||||
@ -728,11 +631,7 @@ class ManageRegistrationTokensTestCase(unittest.HomeserverTestCase):
|
||||
def test_list_no_auth(self) -> None:
|
||||
"""Try to list tokens without authentication."""
|
||||
channel = self.make_request("GET", self.url, {})
|
||||
self.assertEqual(
|
||||
401,
|
||||
channel.code,
|
||||
msg=channel.json_body,
|
||||
)
|
||||
self.assertEqual(401, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(Codes.MISSING_TOKEN, channel.json_body["errcode"])
|
||||
|
||||
def test_list_requester_not_admin(self) -> None:
|
||||
@ -743,11 +642,7 @@ class ManageRegistrationTokensTestCase(unittest.HomeserverTestCase):
|
||||
{},
|
||||
access_token=self.other_user_tok,
|
||||
)
|
||||
self.assertEqual(
|
||||
403,
|
||||
channel.code,
|
||||
msg=channel.json_body,
|
||||
)
|
||||
self.assertEqual(403, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(Codes.FORBIDDEN, channel.json_body["errcode"])
|
||||
|
||||
def test_list_all(self) -> None:
|
||||
@ -780,11 +675,7 @@ class ManageRegistrationTokensTestCase(unittest.HomeserverTestCase):
|
||||
access_token=self.admin_user_tok,
|
||||
)
|
||||
|
||||
self.assertEqual(
|
||||
HTTPStatus.BAD_REQUEST,
|
||||
channel.code,
|
||||
msg=channel.json_body,
|
||||
)
|
||||
self.assertEqual(400, channel.code, msg=channel.json_body)
|
||||
|
||||
def _test_list_query_parameter(self, valid: str) -> None:
|
||||
"""Helper used to test both valid=true and valid=false."""
|
||||
|
@ -12,7 +12,6 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
import urllib.parse
|
||||
from http import HTTPStatus
|
||||
from typing import List, Optional
|
||||
from unittest.mock import Mock
|
||||
|
||||
@ -98,7 +97,7 @@ class DeleteRoomTestCase(unittest.HomeserverTestCase):
|
||||
|
||||
def test_room_is_not_valid(self) -> None:
|
||||
"""
|
||||
Check that invalid room names, return an error HTTPStatus.BAD_REQUEST.
|
||||
Check that invalid room names, return an error 400.
|
||||
"""
|
||||
url = "/_synapse/admin/v1/rooms/%s" % "invalidroom"
|
||||
|
||||
@ -109,7 +108,7 @@ class DeleteRoomTestCase(unittest.HomeserverTestCase):
|
||||
access_token=self.admin_user_tok,
|
||||
)
|
||||
|
||||
self.assertEqual(HTTPStatus.BAD_REQUEST, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(400, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(
|
||||
"invalidroom is not a legal room ID",
|
||||
channel.json_body["error"],
|
||||
@ -145,7 +144,7 @@ class DeleteRoomTestCase(unittest.HomeserverTestCase):
|
||||
access_token=self.admin_user_tok,
|
||||
)
|
||||
|
||||
self.assertEqual(HTTPStatus.BAD_REQUEST, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(400, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(
|
||||
"User must be our own: @not:exist.bla",
|
||||
channel.json_body["error"],
|
||||
@ -163,7 +162,7 @@ class DeleteRoomTestCase(unittest.HomeserverTestCase):
|
||||
access_token=self.admin_user_tok,
|
||||
)
|
||||
|
||||
self.assertEqual(HTTPStatus.BAD_REQUEST, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(400, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(Codes.BAD_JSON, channel.json_body["errcode"])
|
||||
|
||||
def test_purge_is_not_bool(self) -> None:
|
||||
@ -178,7 +177,7 @@ class DeleteRoomTestCase(unittest.HomeserverTestCase):
|
||||
access_token=self.admin_user_tok,
|
||||
)
|
||||
|
||||
self.assertEqual(HTTPStatus.BAD_REQUEST, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(400, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(Codes.BAD_JSON, channel.json_body["errcode"])
|
||||
|
||||
def test_purge_room_and_block(self) -> None:
|
||||
@ -546,7 +545,7 @@ class DeleteRoomV2TestCase(unittest.HomeserverTestCase):
|
||||
)
|
||||
def test_room_is_not_valid(self, method: str, url: str) -> None:
|
||||
"""
|
||||
Check that invalid room names, return an error HTTPStatus.BAD_REQUEST.
|
||||
Check that invalid room names, return an error 400.
|
||||
"""
|
||||
|
||||
channel = self.make_request(
|
||||
@ -556,7 +555,7 @@ class DeleteRoomV2TestCase(unittest.HomeserverTestCase):
|
||||
access_token=self.admin_user_tok,
|
||||
)
|
||||
|
||||
self.assertEqual(HTTPStatus.BAD_REQUEST, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(400, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(
|
||||
"invalidroom is not a legal room ID",
|
||||
channel.json_body["error"],
|
||||
@ -592,7 +591,7 @@ class DeleteRoomV2TestCase(unittest.HomeserverTestCase):
|
||||
access_token=self.admin_user_tok,
|
||||
)
|
||||
|
||||
self.assertEqual(HTTPStatus.BAD_REQUEST, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(400, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(
|
||||
"User must be our own: @not:exist.bla",
|
||||
channel.json_body["error"],
|
||||
@ -610,7 +609,7 @@ class DeleteRoomV2TestCase(unittest.HomeserverTestCase):
|
||||
access_token=self.admin_user_tok,
|
||||
)
|
||||
|
||||
self.assertEqual(HTTPStatus.BAD_REQUEST, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(400, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(Codes.BAD_JSON, channel.json_body["errcode"])
|
||||
|
||||
def test_purge_is_not_bool(self) -> None:
|
||||
@ -625,7 +624,7 @@ class DeleteRoomV2TestCase(unittest.HomeserverTestCase):
|
||||
access_token=self.admin_user_tok,
|
||||
)
|
||||
|
||||
self.assertEqual(HTTPStatus.BAD_REQUEST, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(400, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(Codes.BAD_JSON, channel.json_body["errcode"])
|
||||
|
||||
def test_delete_expired_status(self) -> None:
|
||||
@ -722,9 +721,7 @@ class DeleteRoomV2TestCase(unittest.HomeserverTestCase):
|
||||
access_token=self.admin_user_tok,
|
||||
)
|
||||
|
||||
self.assertEqual(
|
||||
HTTPStatus.BAD_REQUEST, second_channel.code, msg=second_channel.json_body
|
||||
)
|
||||
self.assertEqual(400, second_channel.code, msg=second_channel.json_body)
|
||||
self.assertEqual(Codes.UNKNOWN, second_channel.json_body["errcode"])
|
||||
self.assertEqual(
|
||||
f"History purge already in progress for {self.room_id}",
|
||||
@ -1546,7 +1543,7 @@ class RoomTestCase(unittest.HomeserverTestCase):
|
||||
|
||||
_search_test(None, "foo")
|
||||
_search_test(None, "bar")
|
||||
_search_test(None, "", expected_http_code=HTTPStatus.BAD_REQUEST)
|
||||
_search_test(None, "", expected_http_code=400)
|
||||
|
||||
# Test that the whole room id returns the room
|
||||
_search_test(room_id_1, room_id_1)
|
||||
@ -1836,7 +1833,7 @@ class JoinAliasRoomTestCase(unittest.HomeserverTestCase):
|
||||
access_token=self.admin_user_tok,
|
||||
)
|
||||
|
||||
self.assertEqual(HTTPStatus.BAD_REQUEST, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(400, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(Codes.MISSING_PARAM, channel.json_body["errcode"])
|
||||
|
||||
def test_local_user_does_not_exist(self) -> None:
|
||||
@ -1866,7 +1863,7 @@ class JoinAliasRoomTestCase(unittest.HomeserverTestCase):
|
||||
access_token=self.admin_user_tok,
|
||||
)
|
||||
|
||||
self.assertEqual(HTTPStatus.BAD_REQUEST, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(400, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(
|
||||
"This endpoint can only be used with local users",
|
||||
channel.json_body["error"],
|
||||
@ -1893,7 +1890,7 @@ class JoinAliasRoomTestCase(unittest.HomeserverTestCase):
|
||||
|
||||
def test_room_is_not_valid(self) -> None:
|
||||
"""
|
||||
Check that invalid room names, return an error HTTPStatus.BAD_REQUEST.
|
||||
Check that invalid room names, return an error 400.
|
||||
"""
|
||||
url = "/_synapse/admin/v1/join/invalidroom"
|
||||
|
||||
@ -1904,7 +1901,7 @@ class JoinAliasRoomTestCase(unittest.HomeserverTestCase):
|
||||
access_token=self.admin_user_tok,
|
||||
)
|
||||
|
||||
self.assertEqual(HTTPStatus.BAD_REQUEST, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(400, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(
|
||||
"invalidroom was not legal room ID or room alias",
|
||||
channel.json_body["error"],
|
||||
@ -2243,11 +2240,11 @@ class MakeRoomAdminTestCase(unittest.HomeserverTestCase):
|
||||
access_token=self.admin_user_tok,
|
||||
)
|
||||
|
||||
# We expect this to fail with a HTTPStatus.BAD_REQUEST as there are no room admins.
|
||||
# We expect this to fail with a 400 as there are no room admins.
|
||||
#
|
||||
# (Note we assert the error message to ensure that it's not denied for
|
||||
# some other reason)
|
||||
self.assertEqual(HTTPStatus.BAD_REQUEST, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(400, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(
|
||||
channel.json_body["error"],
|
||||
"No local admin user in room with power to update power levels.",
|
||||
@ -2291,7 +2288,7 @@ class BlockRoomTestCase(unittest.HomeserverTestCase):
|
||||
|
||||
@parameterized.expand([("PUT",), ("GET",)])
|
||||
def test_room_is_not_valid(self, method: str) -> None:
|
||||
"""Check that invalid room names, return an error HTTPStatus.BAD_REQUEST."""
|
||||
"""Check that invalid room names, return an error 400."""
|
||||
|
||||
channel = self.make_request(
|
||||
method,
|
||||
@ -2300,7 +2297,7 @@ class BlockRoomTestCase(unittest.HomeserverTestCase):
|
||||
access_token=self.admin_user_tok,
|
||||
)
|
||||
|
||||
self.assertEqual(HTTPStatus.BAD_REQUEST, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(400, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(
|
||||
"invalidroom is not a legal room ID",
|
||||
channel.json_body["error"],
|
||||
@ -2317,7 +2314,7 @@ class BlockRoomTestCase(unittest.HomeserverTestCase):
|
||||
access_token=self.admin_user_tok,
|
||||
)
|
||||
|
||||
self.assertEqual(HTTPStatus.BAD_REQUEST, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(400, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(Codes.BAD_JSON, channel.json_body["errcode"])
|
||||
|
||||
# `block` is not set
|
||||
@ -2328,7 +2325,7 @@ class BlockRoomTestCase(unittest.HomeserverTestCase):
|
||||
access_token=self.admin_user_tok,
|
||||
)
|
||||
|
||||
self.assertEqual(HTTPStatus.BAD_REQUEST, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(400, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(Codes.MISSING_PARAM, channel.json_body["errcode"])
|
||||
|
||||
# no content is send
|
||||
@ -2338,7 +2335,7 @@ class BlockRoomTestCase(unittest.HomeserverTestCase):
|
||||
access_token=self.admin_user_tok,
|
||||
)
|
||||
|
||||
self.assertEqual(HTTPStatus.BAD_REQUEST, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(400, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(Codes.NOT_JSON, channel.json_body["errcode"])
|
||||
|
||||
def test_block_room(self) -> None:
|
||||
|
@ -11,7 +11,6 @@
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
from http import HTTPStatus
|
||||
from typing import List
|
||||
|
||||
from twisted.test.proto_helpers import MemoryReactor
|
||||
@ -94,7 +93,7 @@ class ServerNoticeTestCase(unittest.HomeserverTestCase):
|
||||
@override_config({"server_notices": {"system_mxid_localpart": "notices"}})
|
||||
def test_user_is_not_local(self) -> None:
|
||||
"""
|
||||
Tests that a lookup for a user that is not a local returns a HTTPStatus.BAD_REQUEST
|
||||
Tests that a lookup for a user that is not a local returns a 400
|
||||
"""
|
||||
channel = self.make_request(
|
||||
"POST",
|
||||
@ -106,7 +105,7 @@ class ServerNoticeTestCase(unittest.HomeserverTestCase):
|
||||
},
|
||||
)
|
||||
|
||||
self.assertEqual(HTTPStatus.BAD_REQUEST, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(400, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(
|
||||
"Server notices can only be sent to local users", channel.json_body["error"]
|
||||
)
|
||||
@ -122,7 +121,7 @@ class ServerNoticeTestCase(unittest.HomeserverTestCase):
|
||||
access_token=self.admin_user_tok,
|
||||
)
|
||||
|
||||
self.assertEqual(HTTPStatus.BAD_REQUEST, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(400, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(Codes.NOT_JSON, channel.json_body["errcode"])
|
||||
|
||||
# no content
|
||||
@ -133,7 +132,7 @@ class ServerNoticeTestCase(unittest.HomeserverTestCase):
|
||||
content={"user_id": self.other_user},
|
||||
)
|
||||
|
||||
self.assertEqual(HTTPStatus.BAD_REQUEST, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(400, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(Codes.MISSING_PARAM, channel.json_body["errcode"])
|
||||
|
||||
# no body
|
||||
@ -144,7 +143,7 @@ class ServerNoticeTestCase(unittest.HomeserverTestCase):
|
||||
content={"user_id": self.other_user, "content": ""},
|
||||
)
|
||||
|
||||
self.assertEqual(HTTPStatus.BAD_REQUEST, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(400, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(Codes.UNKNOWN, channel.json_body["errcode"])
|
||||
self.assertEqual("'body' not in content", channel.json_body["error"])
|
||||
|
||||
@ -156,7 +155,7 @@ class ServerNoticeTestCase(unittest.HomeserverTestCase):
|
||||
content={"user_id": self.other_user, "content": {"body": ""}},
|
||||
)
|
||||
|
||||
self.assertEqual(HTTPStatus.BAD_REQUEST, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(400, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(Codes.UNKNOWN, channel.json_body["errcode"])
|
||||
self.assertEqual("'msgtype' not in content", channel.json_body["error"])
|
||||
|
||||
@ -172,7 +171,7 @@ class ServerNoticeTestCase(unittest.HomeserverTestCase):
|
||||
},
|
||||
)
|
||||
|
||||
self.assertEqual(HTTPStatus.BAD_REQUEST, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(400, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(Codes.UNKNOWN, channel.json_body["errcode"])
|
||||
self.assertEqual(
|
||||
"Server notices are not enabled on this server", channel.json_body["error"]
|
||||
|
@ -12,7 +12,6 @@
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
from http import HTTPStatus
|
||||
from typing import List, Optional
|
||||
|
||||
from twisted.test.proto_helpers import MemoryReactor
|
||||
@ -51,11 +50,7 @@ class UserMediaStatisticsTestCase(unittest.HomeserverTestCase):
|
||||
"""
|
||||
channel = self.make_request("GET", self.url, b"{}")
|
||||
|
||||
self.assertEqual(
|
||||
401,
|
||||
channel.code,
|
||||
msg=channel.json_body,
|
||||
)
|
||||
self.assertEqual(401, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(Codes.MISSING_TOKEN, channel.json_body["errcode"])
|
||||
|
||||
def test_requester_is_no_admin(self) -> None:
|
||||
@ -69,11 +64,7 @@ class UserMediaStatisticsTestCase(unittest.HomeserverTestCase):
|
||||
access_token=self.other_user_tok,
|
||||
)
|
||||
|
||||
self.assertEqual(
|
||||
403,
|
||||
channel.code,
|
||||
msg=channel.json_body,
|
||||
)
|
||||
self.assertEqual(403, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(Codes.FORBIDDEN, channel.json_body["errcode"])
|
||||
|
||||
def test_invalid_parameter(self) -> None:
|
||||
@ -87,11 +78,7 @@ class UserMediaStatisticsTestCase(unittest.HomeserverTestCase):
|
||||
access_token=self.admin_user_tok,
|
||||
)
|
||||
|
||||
self.assertEqual(
|
||||
HTTPStatus.BAD_REQUEST,
|
||||
channel.code,
|
||||
msg=channel.json_body,
|
||||
)
|
||||
self.assertEqual(400, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(Codes.INVALID_PARAM, channel.json_body["errcode"])
|
||||
|
||||
# negative from
|
||||
@ -101,11 +88,7 @@ class UserMediaStatisticsTestCase(unittest.HomeserverTestCase):
|
||||
access_token=self.admin_user_tok,
|
||||
)
|
||||
|
||||
self.assertEqual(
|
||||
HTTPStatus.BAD_REQUEST,
|
||||
channel.code,
|
||||
msg=channel.json_body,
|
||||
)
|
||||
self.assertEqual(400, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(Codes.INVALID_PARAM, channel.json_body["errcode"])
|
||||
|
||||
# negative limit
|
||||
@ -115,11 +98,7 @@ class UserMediaStatisticsTestCase(unittest.HomeserverTestCase):
|
||||
access_token=self.admin_user_tok,
|
||||
)
|
||||
|
||||
self.assertEqual(
|
||||
HTTPStatus.BAD_REQUEST,
|
||||
channel.code,
|
||||
msg=channel.json_body,
|
||||
)
|
||||
self.assertEqual(400, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(Codes.INVALID_PARAM, channel.json_body["errcode"])
|
||||
|
||||
# negative from_ts
|
||||
@ -129,11 +108,7 @@ class UserMediaStatisticsTestCase(unittest.HomeserverTestCase):
|
||||
access_token=self.admin_user_tok,
|
||||
)
|
||||
|
||||
self.assertEqual(
|
||||
HTTPStatus.BAD_REQUEST,
|
||||
channel.code,
|
||||
msg=channel.json_body,
|
||||
)
|
||||
self.assertEqual(400, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(Codes.INVALID_PARAM, channel.json_body["errcode"])
|
||||
|
||||
# negative until_ts
|
||||
@ -143,11 +118,7 @@ class UserMediaStatisticsTestCase(unittest.HomeserverTestCase):
|
||||
access_token=self.admin_user_tok,
|
||||
)
|
||||
|
||||
self.assertEqual(
|
||||
HTTPStatus.BAD_REQUEST,
|
||||
channel.code,
|
||||
msg=channel.json_body,
|
||||
)
|
||||
self.assertEqual(400, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(Codes.INVALID_PARAM, channel.json_body["errcode"])
|
||||
|
||||
# until_ts smaller from_ts
|
||||
@ -157,11 +128,7 @@ class UserMediaStatisticsTestCase(unittest.HomeserverTestCase):
|
||||
access_token=self.admin_user_tok,
|
||||
)
|
||||
|
||||
self.assertEqual(
|
||||
HTTPStatus.BAD_REQUEST,
|
||||
channel.code,
|
||||
msg=channel.json_body,
|
||||
)
|
||||
self.assertEqual(400, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(Codes.INVALID_PARAM, channel.json_body["errcode"])
|
||||
|
||||
# empty search term
|
||||
@ -171,11 +138,7 @@ class UserMediaStatisticsTestCase(unittest.HomeserverTestCase):
|
||||
access_token=self.admin_user_tok,
|
||||
)
|
||||
|
||||
self.assertEqual(
|
||||
HTTPStatus.BAD_REQUEST,
|
||||
channel.code,
|
||||
msg=channel.json_body,
|
||||
)
|
||||
self.assertEqual(400, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(Codes.INVALID_PARAM, channel.json_body["errcode"])
|
||||
|
||||
# invalid search order
|
||||
@ -185,11 +148,7 @@ class UserMediaStatisticsTestCase(unittest.HomeserverTestCase):
|
||||
access_token=self.admin_user_tok,
|
||||
)
|
||||
|
||||
self.assertEqual(
|
||||
HTTPStatus.BAD_REQUEST,
|
||||
channel.code,
|
||||
msg=channel.json_body,
|
||||
)
|
||||
self.assertEqual(400, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(Codes.INVALID_PARAM, channel.json_body["errcode"])
|
||||
|
||||
def test_limit(self) -> None:
|
||||
|
@ -17,7 +17,6 @@ import hmac
|
||||
import os
|
||||
import urllib.parse
|
||||
from binascii import unhexlify
|
||||
from http import HTTPStatus
|
||||
from typing import List, Optional
|
||||
from unittest.mock import Mock, patch
|
||||
|
||||
@ -79,7 +78,7 @@ class UserRegisterTestCase(unittest.HomeserverTestCase):
|
||||
|
||||
channel = self.make_request("POST", self.url, b"{}")
|
||||
|
||||
self.assertEqual(HTTPStatus.BAD_REQUEST, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(400, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(
|
||||
"Shared secret registration is not enabled", channel.json_body["error"]
|
||||
)
|
||||
@ -111,7 +110,7 @@ class UserRegisterTestCase(unittest.HomeserverTestCase):
|
||||
body = {"nonce": nonce}
|
||||
channel = self.make_request("POST", self.url, body)
|
||||
|
||||
self.assertEqual(HTTPStatus.BAD_REQUEST, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(400, channel.code, msg=channel.json_body)
|
||||
self.assertEqual("username must be specified", channel.json_body["error"])
|
||||
|
||||
# 61 seconds
|
||||
@ -119,7 +118,7 @@ class UserRegisterTestCase(unittest.HomeserverTestCase):
|
||||
|
||||
channel = self.make_request("POST", self.url, body)
|
||||
|
||||
self.assertEqual(HTTPStatus.BAD_REQUEST, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(400, channel.code, msg=channel.json_body)
|
||||
self.assertEqual("unrecognised nonce", channel.json_body["error"])
|
||||
|
||||
def test_register_incorrect_nonce(self) -> None:
|
||||
@ -198,7 +197,7 @@ class UserRegisterTestCase(unittest.HomeserverTestCase):
|
||||
# Now, try and reuse it
|
||||
channel = self.make_request("POST", self.url, body)
|
||||
|
||||
self.assertEqual(HTTPStatus.BAD_REQUEST, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(400, channel.code, msg=channel.json_body)
|
||||
self.assertEqual("unrecognised nonce", channel.json_body["error"])
|
||||
|
||||
def test_missing_parts(self) -> None:
|
||||
@ -219,7 +218,7 @@ class UserRegisterTestCase(unittest.HomeserverTestCase):
|
||||
# Must be an empty body present
|
||||
channel = self.make_request("POST", self.url, {})
|
||||
|
||||
self.assertEqual(HTTPStatus.BAD_REQUEST, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(400, channel.code, msg=channel.json_body)
|
||||
self.assertEqual("nonce must be specified", channel.json_body["error"])
|
||||
|
||||
#
|
||||
@ -229,28 +228,28 @@ class UserRegisterTestCase(unittest.HomeserverTestCase):
|
||||
# Must be present
|
||||
channel = self.make_request("POST", self.url, {"nonce": nonce()})
|
||||
|
||||
self.assertEqual(HTTPStatus.BAD_REQUEST, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(400, channel.code, msg=channel.json_body)
|
||||
self.assertEqual("username must be specified", channel.json_body["error"])
|
||||
|
||||
# Must be a string
|
||||
body = {"nonce": nonce(), "username": 1234}
|
||||
channel = self.make_request("POST", self.url, body)
|
||||
|
||||
self.assertEqual(HTTPStatus.BAD_REQUEST, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(400, channel.code, msg=channel.json_body)
|
||||
self.assertEqual("Invalid username", channel.json_body["error"])
|
||||
|
||||
# Must not have null bytes
|
||||
body = {"nonce": nonce(), "username": "abcd\u0000"}
|
||||
channel = self.make_request("POST", self.url, body)
|
||||
|
||||
self.assertEqual(HTTPStatus.BAD_REQUEST, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(400, channel.code, msg=channel.json_body)
|
||||
self.assertEqual("Invalid username", channel.json_body["error"])
|
||||
|
||||
# Must not have null bytes
|
||||
body = {"nonce": nonce(), "username": "a" * 1000}
|
||||
channel = self.make_request("POST", self.url, body)
|
||||
|
||||
self.assertEqual(HTTPStatus.BAD_REQUEST, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(400, channel.code, msg=channel.json_body)
|
||||
self.assertEqual("Invalid username", channel.json_body["error"])
|
||||
|
||||
#
|
||||
@ -261,28 +260,28 @@ class UserRegisterTestCase(unittest.HomeserverTestCase):
|
||||
body = {"nonce": nonce(), "username": "a"}
|
||||
channel = self.make_request("POST", self.url, body)
|
||||
|
||||
self.assertEqual(HTTPStatus.BAD_REQUEST, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(400, channel.code, msg=channel.json_body)
|
||||
self.assertEqual("password must be specified", channel.json_body["error"])
|
||||
|
||||
# Must be a string
|
||||
body = {"nonce": nonce(), "username": "a", "password": 1234}
|
||||
channel = self.make_request("POST", self.url, body)
|
||||
|
||||
self.assertEqual(HTTPStatus.BAD_REQUEST, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(400, channel.code, msg=channel.json_body)
|
||||
self.assertEqual("Invalid password", channel.json_body["error"])
|
||||
|
||||
# Must not have null bytes
|
||||
body = {"nonce": nonce(), "username": "a", "password": "abcd\u0000"}
|
||||
channel = self.make_request("POST", self.url, body)
|
||||
|
||||
self.assertEqual(HTTPStatus.BAD_REQUEST, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(400, channel.code, msg=channel.json_body)
|
||||
self.assertEqual("Invalid password", channel.json_body["error"])
|
||||
|
||||
# Super long
|
||||
body = {"nonce": nonce(), "username": "a", "password": "A" * 1000}
|
||||
channel = self.make_request("POST", self.url, body)
|
||||
|
||||
self.assertEqual(HTTPStatus.BAD_REQUEST, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(400, channel.code, msg=channel.json_body)
|
||||
self.assertEqual("Invalid password", channel.json_body["error"])
|
||||
|
||||
#
|
||||
@ -298,7 +297,7 @@ class UserRegisterTestCase(unittest.HomeserverTestCase):
|
||||
}
|
||||
channel = self.make_request("POST", self.url, body)
|
||||
|
||||
self.assertEqual(HTTPStatus.BAD_REQUEST, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(400, channel.code, msg=channel.json_body)
|
||||
self.assertEqual("Invalid user type", channel.json_body["error"])
|
||||
|
||||
def test_displayname(self) -> None:
|
||||
@ -591,7 +590,7 @@ class UsersListTestCase(unittest.HomeserverTestCase):
|
||||
access_token=self.admin_user_tok,
|
||||
)
|
||||
|
||||
self.assertEqual(HTTPStatus.BAD_REQUEST, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(400, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(Codes.INVALID_PARAM, channel.json_body["errcode"])
|
||||
|
||||
# negative from
|
||||
@ -601,7 +600,7 @@ class UsersListTestCase(unittest.HomeserverTestCase):
|
||||
access_token=self.admin_user_tok,
|
||||
)
|
||||
|
||||
self.assertEqual(HTTPStatus.BAD_REQUEST, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(400, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(Codes.INVALID_PARAM, channel.json_body["errcode"])
|
||||
|
||||
# invalid guests
|
||||
@ -611,7 +610,7 @@ class UsersListTestCase(unittest.HomeserverTestCase):
|
||||
access_token=self.admin_user_tok,
|
||||
)
|
||||
|
||||
self.assertEqual(HTTPStatus.BAD_REQUEST, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(400, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(Codes.INVALID_PARAM, channel.json_body["errcode"])
|
||||
|
||||
# invalid deactivated
|
||||
@ -621,7 +620,7 @@ class UsersListTestCase(unittest.HomeserverTestCase):
|
||||
access_token=self.admin_user_tok,
|
||||
)
|
||||
|
||||
self.assertEqual(HTTPStatus.BAD_REQUEST, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(400, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(Codes.INVALID_PARAM, channel.json_body["errcode"])
|
||||
|
||||
# unkown order_by
|
||||
@ -631,7 +630,7 @@ class UsersListTestCase(unittest.HomeserverTestCase):
|
||||
access_token=self.admin_user_tok,
|
||||
)
|
||||
|
||||
self.assertEqual(HTTPStatus.BAD_REQUEST, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(400, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(Codes.INVALID_PARAM, channel.json_body["errcode"])
|
||||
|
||||
# invalid search order
|
||||
@ -641,7 +640,7 @@ class UsersListTestCase(unittest.HomeserverTestCase):
|
||||
access_token=self.admin_user_tok,
|
||||
)
|
||||
|
||||
self.assertEqual(HTTPStatus.BAD_REQUEST, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(400, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(Codes.INVALID_PARAM, channel.json_body["errcode"])
|
||||
|
||||
def test_limit(self) -> None:
|
||||
@ -991,18 +990,18 @@ class DeactivateAccountTestCase(unittest.HomeserverTestCase):
|
||||
access_token=self.admin_user_tok,
|
||||
)
|
||||
|
||||
self.assertEqual(HTTPStatus.BAD_REQUEST, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(400, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(Codes.BAD_JSON, channel.json_body["errcode"])
|
||||
|
||||
def test_user_is_not_local(self) -> None:
|
||||
"""
|
||||
Tests that deactivation for a user that is not a local returns a HTTPStatus.BAD_REQUEST
|
||||
Tests that deactivation for a user that is not a local returns a 400
|
||||
"""
|
||||
url = "/_synapse/admin/v1/deactivate/@unknown_person:unknown_domain"
|
||||
|
||||
channel = self.make_request("POST", url, access_token=self.admin_user_tok)
|
||||
|
||||
self.assertEqual(HTTPStatus.BAD_REQUEST, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(400, channel.code, msg=channel.json_body)
|
||||
self.assertEqual("Can only deactivate local users", channel.json_body["error"])
|
||||
|
||||
def test_deactivate_user_erase_true(self) -> None:
|
||||
@ -1259,7 +1258,7 @@ class UserRestTestCase(unittest.HomeserverTestCase):
|
||||
access_token=self.admin_user_tok,
|
||||
content={"admin": "not_bool"},
|
||||
)
|
||||
self.assertEqual(HTTPStatus.BAD_REQUEST, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(400, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(Codes.BAD_JSON, channel.json_body["errcode"])
|
||||
|
||||
# deactivated not bool
|
||||
@ -1269,7 +1268,7 @@ class UserRestTestCase(unittest.HomeserverTestCase):
|
||||
access_token=self.admin_user_tok,
|
||||
content={"deactivated": "not_bool"},
|
||||
)
|
||||
self.assertEqual(HTTPStatus.BAD_REQUEST, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(400, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(Codes.UNKNOWN, channel.json_body["errcode"])
|
||||
|
||||
# password not str
|
||||
@ -1279,7 +1278,7 @@ class UserRestTestCase(unittest.HomeserverTestCase):
|
||||
access_token=self.admin_user_tok,
|
||||
content={"password": True},
|
||||
)
|
||||
self.assertEqual(HTTPStatus.BAD_REQUEST, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(400, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(Codes.UNKNOWN, channel.json_body["errcode"])
|
||||
|
||||
# password not length
|
||||
@ -1289,7 +1288,7 @@ class UserRestTestCase(unittest.HomeserverTestCase):
|
||||
access_token=self.admin_user_tok,
|
||||
content={"password": "x" * 513},
|
||||
)
|
||||
self.assertEqual(HTTPStatus.BAD_REQUEST, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(400, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(Codes.UNKNOWN, channel.json_body["errcode"])
|
||||
|
||||
# user_type not valid
|
||||
@ -1299,7 +1298,7 @@ class UserRestTestCase(unittest.HomeserverTestCase):
|
||||
access_token=self.admin_user_tok,
|
||||
content={"user_type": "new type"},
|
||||
)
|
||||
self.assertEqual(HTTPStatus.BAD_REQUEST, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(400, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(Codes.UNKNOWN, channel.json_body["errcode"])
|
||||
|
||||
# external_ids not valid
|
||||
@ -1311,7 +1310,7 @@ class UserRestTestCase(unittest.HomeserverTestCase):
|
||||
"external_ids": {"auth_provider": "prov", "wrong_external_id": "id"}
|
||||
},
|
||||
)
|
||||
self.assertEqual(HTTPStatus.BAD_REQUEST, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(400, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(Codes.MISSING_PARAM, channel.json_body["errcode"])
|
||||
|
||||
channel = self.make_request(
|
||||
@ -1320,7 +1319,7 @@ class UserRestTestCase(unittest.HomeserverTestCase):
|
||||
access_token=self.admin_user_tok,
|
||||
content={"external_ids": {"external_id": "id"}},
|
||||
)
|
||||
self.assertEqual(HTTPStatus.BAD_REQUEST, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(400, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(Codes.MISSING_PARAM, channel.json_body["errcode"])
|
||||
|
||||
# threepids not valid
|
||||
@ -1330,7 +1329,7 @@ class UserRestTestCase(unittest.HomeserverTestCase):
|
||||
access_token=self.admin_user_tok,
|
||||
content={"threepids": {"medium": "email", "wrong_address": "id"}},
|
||||
)
|
||||
self.assertEqual(HTTPStatus.BAD_REQUEST, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(400, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(Codes.MISSING_PARAM, channel.json_body["errcode"])
|
||||
|
||||
channel = self.make_request(
|
||||
@ -1339,7 +1338,7 @@ class UserRestTestCase(unittest.HomeserverTestCase):
|
||||
access_token=self.admin_user_tok,
|
||||
content={"threepids": {"address": "value"}},
|
||||
)
|
||||
self.assertEqual(HTTPStatus.BAD_REQUEST, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(400, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(Codes.MISSING_PARAM, channel.json_body["errcode"])
|
||||
|
||||
def test_get_user(self) -> None:
|
||||
@ -2228,7 +2227,7 @@ class UserRestTestCase(unittest.HomeserverTestCase):
|
||||
access_token=self.admin_user_tok,
|
||||
content={"deactivated": False},
|
||||
)
|
||||
self.assertEqual(HTTPStatus.BAD_REQUEST, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(400, channel.code, msg=channel.json_body)
|
||||
|
||||
# Reactivate the user.
|
||||
channel = self.make_request(
|
||||
@ -2431,7 +2430,7 @@ class UserRestTestCase(unittest.HomeserverTestCase):
|
||||
content={"password": "abc123", "deactivated": "false"},
|
||||
)
|
||||
|
||||
self.assertEqual(HTTPStatus.BAD_REQUEST, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(400, channel.code, msg=channel.json_body)
|
||||
|
||||
# Check user is not deactivated
|
||||
channel = self.make_request(
|
||||
@ -2712,7 +2711,7 @@ class PushersRestTestCase(unittest.HomeserverTestCase):
|
||||
|
||||
def test_user_is_not_local(self) -> None:
|
||||
"""
|
||||
Tests that a lookup for a user that is not a local returns a HTTPStatus.BAD_REQUEST
|
||||
Tests that a lookup for a user that is not a local returns a 400
|
||||
"""
|
||||
url = "/_synapse/admin/v1/users/@unknown_person:unknown_domain/pushers"
|
||||
|
||||
@ -2722,7 +2721,7 @@ class PushersRestTestCase(unittest.HomeserverTestCase):
|
||||
access_token=self.admin_user_tok,
|
||||
)
|
||||
|
||||
self.assertEqual(HTTPStatus.BAD_REQUEST, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(400, channel.code, msg=channel.json_body)
|
||||
self.assertEqual("Can only look up local users", channel.json_body["error"])
|
||||
|
||||
def test_get_pushers(self) -> None:
|
||||
@ -2840,7 +2839,7 @@ class UserMediaRestTestCase(unittest.HomeserverTestCase):
|
||||
|
||||
@parameterized.expand(["GET", "DELETE"])
|
||||
def test_user_is_not_local(self, method: str) -> None:
|
||||
"""Tests that a lookup for a user that is not a local returns a HTTPStatus.BAD_REQUEST"""
|
||||
"""Tests that a lookup for a user that is not a local returns a 400"""
|
||||
url = "/_synapse/admin/v1/users/@unknown_person:unknown_domain/media"
|
||||
|
||||
channel = self.make_request(
|
||||
@ -2849,7 +2848,7 @@ class UserMediaRestTestCase(unittest.HomeserverTestCase):
|
||||
access_token=self.admin_user_tok,
|
||||
)
|
||||
|
||||
self.assertEqual(HTTPStatus.BAD_REQUEST, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(400, channel.code, msg=channel.json_body)
|
||||
self.assertEqual("Can only look up local users", channel.json_body["error"])
|
||||
|
||||
def test_limit_GET(self) -> None:
|
||||
@ -2970,7 +2969,7 @@ class UserMediaRestTestCase(unittest.HomeserverTestCase):
|
||||
access_token=self.admin_user_tok,
|
||||
)
|
||||
|
||||
self.assertEqual(HTTPStatus.BAD_REQUEST, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(400, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(Codes.INVALID_PARAM, channel.json_body["errcode"])
|
||||
|
||||
# invalid search order
|
||||
@ -2980,7 +2979,7 @@ class UserMediaRestTestCase(unittest.HomeserverTestCase):
|
||||
access_token=self.admin_user_tok,
|
||||
)
|
||||
|
||||
self.assertEqual(HTTPStatus.BAD_REQUEST, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(400, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(Codes.INVALID_PARAM, channel.json_body["errcode"])
|
||||
|
||||
# negative limit
|
||||
@ -2990,7 +2989,7 @@ class UserMediaRestTestCase(unittest.HomeserverTestCase):
|
||||
access_token=self.admin_user_tok,
|
||||
)
|
||||
|
||||
self.assertEqual(HTTPStatus.BAD_REQUEST, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(400, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(Codes.INVALID_PARAM, channel.json_body["errcode"])
|
||||
|
||||
# negative from
|
||||
@ -3000,7 +2999,7 @@ class UserMediaRestTestCase(unittest.HomeserverTestCase):
|
||||
access_token=self.admin_user_tok,
|
||||
)
|
||||
|
||||
self.assertEqual(HTTPStatus.BAD_REQUEST, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(400, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(Codes.INVALID_PARAM, channel.json_body["errcode"])
|
||||
|
||||
def test_next_token(self) -> None:
|
||||
@ -3614,7 +3613,7 @@ class WhoisRestTestCase(unittest.HomeserverTestCase):
|
||||
|
||||
def test_user_is_not_local(self) -> None:
|
||||
"""
|
||||
Tests that a lookup for a user that is not a local returns a HTTPStatus.BAD_REQUEST
|
||||
Tests that a lookup for a user that is not a local returns a 400
|
||||
"""
|
||||
url = self.url_prefix % "@unknown_person:unknown_domain" # type: ignore[attr-defined]
|
||||
|
||||
@ -3623,7 +3622,7 @@ class WhoisRestTestCase(unittest.HomeserverTestCase):
|
||||
url,
|
||||
access_token=self.admin_user_tok,
|
||||
)
|
||||
self.assertEqual(HTTPStatus.BAD_REQUEST, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(400, channel.code, msg=channel.json_body)
|
||||
self.assertEqual("Can only whois a local user", channel.json_body["error"])
|
||||
|
||||
def test_get_whois_admin(self) -> None:
|
||||
@ -3697,12 +3696,12 @@ class ShadowBanRestTestCase(unittest.HomeserverTestCase):
|
||||
@parameterized.expand(["POST", "DELETE"])
|
||||
def test_user_is_not_local(self, method: str) -> None:
|
||||
"""
|
||||
Tests that shadow-banning for a user that is not a local returns a HTTPStatus.BAD_REQUEST
|
||||
Tests that shadow-banning for a user that is not a local returns a 400
|
||||
"""
|
||||
url = "/_synapse/admin/v1/whois/@unknown_person:unknown_domain"
|
||||
|
||||
channel = self.make_request(method, url, access_token=self.admin_user_tok)
|
||||
self.assertEqual(HTTPStatus.BAD_REQUEST, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(400, channel.code, msg=channel.json_body)
|
||||
|
||||
def test_success(self) -> None:
|
||||
"""
|
||||
@ -3806,7 +3805,7 @@ class RateLimitTestCase(unittest.HomeserverTestCase):
|
||||
)
|
||||
def test_user_is_not_local(self, method: str, error_msg: str) -> None:
|
||||
"""
|
||||
Tests that a lookup for a user that is not a local returns a HTTPStatus.BAD_REQUEST
|
||||
Tests that a lookup for a user that is not a local returns a 400
|
||||
"""
|
||||
url = (
|
||||
"/_synapse/admin/v1/users/@unknown_person:unknown_domain/override_ratelimit"
|
||||
@ -3818,7 +3817,7 @@ class RateLimitTestCase(unittest.HomeserverTestCase):
|
||||
access_token=self.admin_user_tok,
|
||||
)
|
||||
|
||||
self.assertEqual(HTTPStatus.BAD_REQUEST, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(400, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(error_msg, channel.json_body["error"])
|
||||
|
||||
def test_invalid_parameter(self) -> None:
|
||||
@ -3833,7 +3832,7 @@ class RateLimitTestCase(unittest.HomeserverTestCase):
|
||||
content={"messages_per_second": "string"},
|
||||
)
|
||||
|
||||
self.assertEqual(HTTPStatus.BAD_REQUEST, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(400, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(Codes.INVALID_PARAM, channel.json_body["errcode"])
|
||||
|
||||
# messages_per_second is negative
|
||||
@ -3844,7 +3843,7 @@ class RateLimitTestCase(unittest.HomeserverTestCase):
|
||||
content={"messages_per_second": -1},
|
||||
)
|
||||
|
||||
self.assertEqual(HTTPStatus.BAD_REQUEST, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(400, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(Codes.INVALID_PARAM, channel.json_body["errcode"])
|
||||
|
||||
# burst_count is a string
|
||||
@ -3855,7 +3854,7 @@ class RateLimitTestCase(unittest.HomeserverTestCase):
|
||||
content={"burst_count": "string"},
|
||||
)
|
||||
|
||||
self.assertEqual(HTTPStatus.BAD_REQUEST, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(400, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(Codes.INVALID_PARAM, channel.json_body["errcode"])
|
||||
|
||||
# burst_count is negative
|
||||
@ -3866,7 +3865,7 @@ class RateLimitTestCase(unittest.HomeserverTestCase):
|
||||
content={"burst_count": -1},
|
||||
)
|
||||
|
||||
self.assertEqual(HTTPStatus.BAD_REQUEST, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(400, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(Codes.INVALID_PARAM, channel.json_body["errcode"])
|
||||
|
||||
def test_return_zero_when_null(self) -> None:
|
||||
@ -4021,7 +4020,7 @@ class AccountDataTestCase(unittest.HomeserverTestCase):
|
||||
access_token=self.admin_user_tok,
|
||||
)
|
||||
|
||||
self.assertEqual(HTTPStatus.BAD_REQUEST, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(400, channel.code, msg=channel.json_body)
|
||||
self.assertEqual("Can only look up local users", channel.json_body["error"])
|
||||
|
||||
def test_success(self) -> None:
|
||||
|
@ -11,9 +11,6 @@
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from http import HTTPStatus
|
||||
|
||||
from twisted.test.proto_helpers import MemoryReactor
|
||||
|
||||
import synapse.rest.admin
|
||||
@ -40,7 +37,7 @@ class UsernameAvailableTestCase(unittest.HomeserverTestCase):
|
||||
if username == "allowed":
|
||||
return True
|
||||
raise SynapseError(
|
||||
HTTPStatus.BAD_REQUEST,
|
||||
400,
|
||||
"User ID already taken.",
|
||||
errcode=Codes.USER_IN_USE,
|
||||
)
|
||||
@ -67,10 +64,6 @@ class UsernameAvailableTestCase(unittest.HomeserverTestCase):
|
||||
url = "%s?username=%s" % (self.url, "disallowed")
|
||||
channel = self.make_request("GET", url, access_token=self.admin_user_tok)
|
||||
|
||||
self.assertEqual(
|
||||
HTTPStatus.BAD_REQUEST,
|
||||
channel.code,
|
||||
msg=channel.json_body,
|
||||
)
|
||||
self.assertEqual(400, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(channel.json_body["errcode"], "M_USER_IN_USE")
|
||||
self.assertEqual(channel.json_body["error"], "User ID already taken.")
|
||||
|
Loading…
Reference in New Issue
Block a user