Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Fix tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
clokep committed Aug 18, 2020
1 parent 02cace6 commit d54f1f5
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 14 deletions.
16 changes: 5 additions & 11 deletions tests/rest/client/v1/test_login.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,7 @@ def test_POST_ratelimiting_per_address(self):
"identifier": {"type": "m.id.user", "user": "kermit" + str(i)},
"password": "monkey",
}
request_data = json.dumps(params)
request, channel = self.make_request(b"POST", LOGIN_URL, request_data)
request, channel = self.make_request(b"POST", LOGIN_URL, params)
self.render(request)

if i == 5:
Expand All @@ -76,14 +75,13 @@ def test_POST_ratelimiting_per_address(self):
# than 1min.
self.assertTrue(retry_after_ms < 6000)

self.reactor.advance(retry_after_ms / 1000.0)
self.reactor.advance(retry_after_ms / 1000.0 + 1.0)

params = {
"type": "m.login.password",
"identifier": {"type": "m.id.user", "user": "kermit" + str(i)},
"password": "monkey",
}
request_data = json.dumps(params)
request, channel = self.make_request(b"POST", LOGIN_URL, params)
self.render(request)

Expand Down Expand Up @@ -111,8 +109,7 @@ def test_POST_ratelimiting_per_account(self):
"identifier": {"type": "m.id.user", "user": "kermit"},
"password": "monkey",
}
request_data = json.dumps(params)
request, channel = self.make_request(b"POST", LOGIN_URL, request_data)
request, channel = self.make_request(b"POST", LOGIN_URL, params)
self.render(request)

if i == 5:
Expand All @@ -132,7 +129,6 @@ def test_POST_ratelimiting_per_account(self):
"identifier": {"type": "m.id.user", "user": "kermit"},
"password": "monkey",
}
request_data = json.dumps(params)
request, channel = self.make_request(b"POST", LOGIN_URL, params)
self.render(request)

Expand Down Expand Up @@ -160,8 +156,7 @@ def test_POST_ratelimiting_per_account_failed_attempts(self):
"identifier": {"type": "m.id.user", "user": "kermit"},
"password": "notamonkey",
}
request_data = json.dumps(params)
request, channel = self.make_request(b"POST", LOGIN_URL, request_data)
request, channel = self.make_request(b"POST", LOGIN_URL, params)
self.render(request)

if i == 5:
Expand All @@ -174,14 +169,13 @@ def test_POST_ratelimiting_per_account_failed_attempts(self):
# than 1min.
self.assertTrue(retry_after_ms < 6000)

self.reactor.advance(retry_after_ms / 1000.0)
self.reactor.advance(retry_after_ms / 1000.0 + 1.0)

params = {
"type": "m.login.password",
"identifier": {"type": "m.id.user", "user": "kermit"},
"password": "notamonkey",
}
request_data = json.dumps(params)
request, channel = self.make_request(b"POST", LOGIN_URL, params)
self.render(request)

Expand Down
4 changes: 2 additions & 2 deletions tests/rest/client/v2_alpha/test_register.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ def test_POST_ratelimiting_guest(self):
else:
self.assertEquals(channel.result["code"], b"200", channel.result)

self.reactor.advance(retry_after_ms / 1000.0)
self.reactor.advance(retry_after_ms / 1000.0 + 1.0)

request, channel = self.make_request(b"POST", self.url + b"?kind=guest", b"{}")
self.render(request)
Expand All @@ -186,7 +186,7 @@ def test_POST_ratelimiting(self):
else:
self.assertEquals(channel.result["code"], b"200", channel.result)

self.reactor.advance(retry_after_ms / 1000.0)
self.reactor.advance(retry_after_ms / 1000.0 + 1.0)

request, channel = self.make_request(b"POST", self.url + b"?kind=guest", b"{}")
self.render(request)
Expand Down
3 changes: 2 additions & 1 deletion tests/storage/test_cleanup_extrems.py
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,7 @@ def test_expiry_logic(self):
self.event_creator_handler._rooms_to_exclude_from_dummy_event_insertion[
"3"
] = 300000

self.event_creator_handler._expire_rooms_to_exclude_from_dummy_event_insertion()
# All entries within time frame
self.assertEqual(
Expand All @@ -362,7 +363,7 @@ def test_expiry_logic(self):
3,
)
# Oldest room to expire
self.pump(1)
self.pump(1.01)
self.event_creator_handler._expire_rooms_to_exclude_from_dummy_event_insertion()
self.assertEqual(
len(
Expand Down

0 comments on commit d54f1f5

Please sign in to comment.