Remove unnecessary json.dumps from tests (#13303)

This commit is contained in:
Dirk Klimpel 2022-07-17 23:28:45 +02:00 committed by GitHub
parent 5d4028f217
commit efee345b45
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 143 additions and 200 deletions

View file

@ -12,7 +12,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import json
from http import HTTPStatus
from twisted.test.proto_helpers import MemoryReactor
@ -89,7 +88,7 @@ class PasswordPolicyTestCase(unittest.HomeserverTestCase):
)
def test_password_too_short(self) -> None:
request_data = json.dumps({"username": "kermit", "password": "shorty"})
request_data = {"username": "kermit", "password": "shorty"}
channel = self.make_request("POST", self.register_url, request_data)
self.assertEqual(channel.code, HTTPStatus.BAD_REQUEST, channel.result)
@ -100,7 +99,7 @@ class PasswordPolicyTestCase(unittest.HomeserverTestCase):
)
def test_password_no_digit(self) -> None:
request_data = json.dumps({"username": "kermit", "password": "longerpassword"})
request_data = {"username": "kermit", "password": "longerpassword"}
channel = self.make_request("POST", self.register_url, request_data)
self.assertEqual(channel.code, HTTPStatus.BAD_REQUEST, channel.result)
@ -111,7 +110,7 @@ class PasswordPolicyTestCase(unittest.HomeserverTestCase):
)
def test_password_no_symbol(self) -> None:
request_data = json.dumps({"username": "kermit", "password": "l0ngerpassword"})
request_data = {"username": "kermit", "password": "l0ngerpassword"}
channel = self.make_request("POST", self.register_url, request_data)
self.assertEqual(channel.code, HTTPStatus.BAD_REQUEST, channel.result)
@ -122,7 +121,7 @@ class PasswordPolicyTestCase(unittest.HomeserverTestCase):
)
def test_password_no_uppercase(self) -> None:
request_data = json.dumps({"username": "kermit", "password": "l0ngerpassword!"})
request_data = {"username": "kermit", "password": "l0ngerpassword!"}
channel = self.make_request("POST", self.register_url, request_data)
self.assertEqual(channel.code, HTTPStatus.BAD_REQUEST, channel.result)
@ -133,7 +132,7 @@ class PasswordPolicyTestCase(unittest.HomeserverTestCase):
)
def test_password_no_lowercase(self) -> None:
request_data = json.dumps({"username": "kermit", "password": "L0NGERPASSWORD!"})
request_data = {"username": "kermit", "password": "L0NGERPASSWORD!"}
channel = self.make_request("POST", self.register_url, request_data)
self.assertEqual(channel.code, HTTPStatus.BAD_REQUEST, channel.result)
@ -144,7 +143,7 @@ class PasswordPolicyTestCase(unittest.HomeserverTestCase):
)
def test_password_compliant(self) -> None:
request_data = json.dumps({"username": "kermit", "password": "L0ngerpassword!"})
request_data = {"username": "kermit", "password": "L0ngerpassword!"}
channel = self.make_request("POST", self.register_url, request_data)
# Getting a 401 here means the password has passed validation and the server has
@ -161,16 +160,14 @@ class PasswordPolicyTestCase(unittest.HomeserverTestCase):
user_id = self.register_user("kermit", compliant_password)
tok = self.login("kermit", compliant_password)
request_data = json.dumps(
{
"new_password": not_compliant_password,
"auth": {
"password": compliant_password,
"type": LoginType.PASSWORD,
"user": user_id,
},
}
)
request_data = {
"new_password": not_compliant_password,
"auth": {
"password": compliant_password,
"type": LoginType.PASSWORD,
"user": user_id,
},
}
channel = self.make_request(
"POST",
"/_matrix/client/r0/account/password",