Rename test case method to `add_hashes_and_signatures_from_other_server` (#13255)
This commit is contained in:
parent
fa71bb18b5
commit
52a0c8f2f7
|
@ -0,0 +1 @@
|
||||||
|
Preparatory work for a per-room rate limiter on joins.
|
|
@ -45,7 +45,7 @@ class FederationClientTest(FederatingHomeserverTestCase):
|
||||||
# mock up some events to use in the response.
|
# mock up some events to use in the response.
|
||||||
# In real life, these would have things in `prev_events` and `auth_events`, but that's
|
# In real life, these would have things in `prev_events` and `auth_events`, but that's
|
||||||
# a bit annoying to mock up, and the code under test doesn't care, so we don't bother.
|
# a bit annoying to mock up, and the code under test doesn't care, so we don't bother.
|
||||||
create_event_dict = self.add_hashes_and_signatures(
|
create_event_dict = self.add_hashes_and_signatures_from_other_server(
|
||||||
{
|
{
|
||||||
"room_id": test_room_id,
|
"room_id": test_room_id,
|
||||||
"type": "m.room.create",
|
"type": "m.room.create",
|
||||||
|
@ -57,7 +57,7 @@ class FederationClientTest(FederatingHomeserverTestCase):
|
||||||
"origin_server_ts": 500,
|
"origin_server_ts": 500,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
member_event_dict = self.add_hashes_and_signatures(
|
member_event_dict = self.add_hashes_and_signatures_from_other_server(
|
||||||
{
|
{
|
||||||
"room_id": test_room_id,
|
"room_id": test_room_id,
|
||||||
"type": "m.room.member",
|
"type": "m.room.member",
|
||||||
|
@ -69,7 +69,7 @@ class FederationClientTest(FederatingHomeserverTestCase):
|
||||||
"origin_server_ts": 600,
|
"origin_server_ts": 600,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
pl_event_dict = self.add_hashes_and_signatures(
|
pl_event_dict = self.add_hashes_and_signatures_from_other_server(
|
||||||
{
|
{
|
||||||
"room_id": test_room_id,
|
"room_id": test_room_id,
|
||||||
"type": "m.room.power_levels",
|
"type": "m.room.power_levels",
|
||||||
|
|
|
@ -20,7 +20,6 @@ from twisted.test.proto_helpers import MemoryReactor
|
||||||
|
|
||||||
from synapse.api.room_versions import KNOWN_ROOM_VERSIONS
|
from synapse.api.room_versions import KNOWN_ROOM_VERSIONS
|
||||||
from synapse.config.server import DEFAULT_ROOM_VERSION
|
from synapse.config.server import DEFAULT_ROOM_VERSION
|
||||||
from synapse.crypto.event_signing import add_hashes_and_signatures
|
|
||||||
from synapse.events import make_event_from_dict
|
from synapse.events import make_event_from_dict
|
||||||
from synapse.federation.federation_server import server_matches_acl_event
|
from synapse.federation.federation_server import server_matches_acl_event
|
||||||
from synapse.rest import admin
|
from synapse.rest import admin
|
||||||
|
@ -163,11 +162,9 @@ class SendJoinFederationTests(unittest.FederatingHomeserverTestCase):
|
||||||
join_result = self._make_join(joining_user)
|
join_result = self._make_join(joining_user)
|
||||||
|
|
||||||
join_event_dict = join_result["event"]
|
join_event_dict = join_result["event"]
|
||||||
add_hashes_and_signatures(
|
self.add_hashes_and_signatures_from_other_server(
|
||||||
KNOWN_ROOM_VERSIONS[DEFAULT_ROOM_VERSION],
|
|
||||||
join_event_dict,
|
join_event_dict,
|
||||||
signature_name=self.OTHER_SERVER_NAME,
|
KNOWN_ROOM_VERSIONS[DEFAULT_ROOM_VERSION],
|
||||||
signing_key=self.OTHER_SERVER_SIGNATURE_KEY,
|
|
||||||
)
|
)
|
||||||
channel = self.make_signed_federation_request(
|
channel = self.make_signed_federation_request(
|
||||||
"PUT",
|
"PUT",
|
||||||
|
@ -220,11 +217,9 @@ class SendJoinFederationTests(unittest.FederatingHomeserverTestCase):
|
||||||
join_result = self._make_join(joining_user)
|
join_result = self._make_join(joining_user)
|
||||||
|
|
||||||
join_event_dict = join_result["event"]
|
join_event_dict = join_result["event"]
|
||||||
add_hashes_and_signatures(
|
self.add_hashes_and_signatures_from_other_server(
|
||||||
KNOWN_ROOM_VERSIONS[DEFAULT_ROOM_VERSION],
|
|
||||||
join_event_dict,
|
join_event_dict,
|
||||||
signature_name=self.OTHER_SERVER_NAME,
|
KNOWN_ROOM_VERSIONS[DEFAULT_ROOM_VERSION],
|
||||||
signing_key=self.OTHER_SERVER_SIGNATURE_KEY,
|
|
||||||
)
|
)
|
||||||
channel = self.make_signed_federation_request(
|
channel = self.make_signed_federation_request(
|
||||||
"PUT",
|
"PUT",
|
||||||
|
|
|
@ -256,7 +256,7 @@ class FederationTestCase(unittest.FederatingHomeserverTestCase):
|
||||||
]
|
]
|
||||||
for _ in range(0, 8):
|
for _ in range(0, 8):
|
||||||
event = make_event_from_dict(
|
event = make_event_from_dict(
|
||||||
self.add_hashes_and_signatures(
|
self.add_hashes_and_signatures_from_other_server(
|
||||||
{
|
{
|
||||||
"origin_server_ts": 1,
|
"origin_server_ts": 1,
|
||||||
"type": "m.room.message",
|
"type": "m.room.message",
|
||||||
|
|
|
@ -104,7 +104,7 @@ class FederationEventHandlerTests(unittest.FederatingHomeserverTestCase):
|
||||||
# mock up a load of state events which we are missing
|
# mock up a load of state events which we are missing
|
||||||
state_events = [
|
state_events = [
|
||||||
make_event_from_dict(
|
make_event_from_dict(
|
||||||
self.add_hashes_and_signatures(
|
self.add_hashes_and_signatures_from_other_server(
|
||||||
{
|
{
|
||||||
"type": "test_state_type",
|
"type": "test_state_type",
|
||||||
"state_key": f"state_{i}",
|
"state_key": f"state_{i}",
|
||||||
|
@ -131,7 +131,7 @@ class FederationEventHandlerTests(unittest.FederatingHomeserverTestCase):
|
||||||
# Depending on the test, we either persist this upfront (as an outlier),
|
# Depending on the test, we either persist this upfront (as an outlier),
|
||||||
# or let the server request it.
|
# or let the server request it.
|
||||||
prev_event = make_event_from_dict(
|
prev_event = make_event_from_dict(
|
||||||
self.add_hashes_and_signatures(
|
self.add_hashes_and_signatures_from_other_server(
|
||||||
{
|
{
|
||||||
"type": "test_regular_type",
|
"type": "test_regular_type",
|
||||||
"room_id": room_id,
|
"room_id": room_id,
|
||||||
|
@ -165,7 +165,7 @@ class FederationEventHandlerTests(unittest.FederatingHomeserverTestCase):
|
||||||
|
|
||||||
# mock up a regular event to pass into _process_pulled_event
|
# mock up a regular event to pass into _process_pulled_event
|
||||||
pulled_event = make_event_from_dict(
|
pulled_event = make_event_from_dict(
|
||||||
self.add_hashes_and_signatures(
|
self.add_hashes_and_signatures_from_other_server(
|
||||||
{
|
{
|
||||||
"type": "test_regular_type",
|
"type": "test_regular_type",
|
||||||
"room_id": room_id,
|
"room_id": room_id,
|
||||||
|
|
|
@ -272,7 +272,7 @@ class FilterEventsForClientTestCase(unittest.FederatingHomeserverTestCase):
|
||||||
"state_key": "@user:test",
|
"state_key": "@user:test",
|
||||||
"content": {"membership": "invite"},
|
"content": {"membership": "invite"},
|
||||||
}
|
}
|
||||||
self.add_hashes_and_signatures(invite_pdu)
|
self.add_hashes_and_signatures_from_other_server(invite_pdu)
|
||||||
invite_event_id = make_event_from_dict(invite_pdu, RoomVersions.V9).event_id
|
invite_event_id = make_event_from_dict(invite_pdu, RoomVersions.V9).event_id
|
||||||
|
|
||||||
self.get_success(
|
self.get_success(
|
||||||
|
|
|
@ -838,7 +838,7 @@ class FederatingHomeserverTestCase(HomeserverTestCase):
|
||||||
client_ip=client_ip,
|
client_ip=client_ip,
|
||||||
)
|
)
|
||||||
|
|
||||||
def add_hashes_and_signatures(
|
def add_hashes_and_signatures_from_other_server(
|
||||||
self,
|
self,
|
||||||
event_dict: JsonDict,
|
event_dict: JsonDict,
|
||||||
room_version: RoomVersion = KNOWN_ROOM_VERSIONS[DEFAULT_ROOM_VERSION],
|
room_version: RoomVersion = KNOWN_ROOM_VERSIONS[DEFAULT_ROOM_VERSION],
|
||||||
|
|
Loading…
Reference in New Issue