summary refs log tree commit diff
path: root/tests/handlers/test_federation.py (follow)
Commit message (Collapse)AuthorAgeFilesLines
* Avoid checking the event cache when backfilling events (#14164)Andrew Morgan2022-10-181-1/+104
|
* Faster Room Joins: don't leave a stuck room partial state flag if the join ↵reivilibre2022-08-011-1/+121
| | | | fails. (#13403)
* Refactor `_resolve_state_at_missing_prevs` to return an `EventContext` (#13404)Sean Quah2022-08-011-4/+11
| | | | | | | | Previously, `_resolve_state_at_missing_prevs` returned the resolved state before an event and a partial state flag. These were unwieldy to carry around would only ever be used to build an event context. Build the event context directly instead. Signed-off-by: Sean Quah <seanq@matrix.org>
* Faster room joins: avoid blocking when pulling events with missing prevs ↵Sean Quah2022-07-261-0/+1
| | | | | | | | | (#13355) Avoid blocking on full state in `_resolve_state_at_missing_prevs` and return a new flag indicating whether the resolved state is partial. Thread that flag around so that it makes it into the event context. Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com>
* Rip out auth-event reconciliation code (#12943)Richard van der Hoff2022-07-141-139/+1
| | | | | | | There is a corner in `_check_event_auth` (long known as "the weird corner") where, if we get an event with auth_events which don't match those we were expecting, we attempt to resolve the diffence between our state and the remote's with a state resolution. This isn't specced, and there's general agreement we shouldn't be doing it. However, it turns out that the faster-joins code was relying on it, so we need to introduce something similar (but rather simpler) for that.
* Rename test case method to `add_hashes_and_signatures_from_other_server` ↵David Robertson2022-07-121-1/+1
| | | | (#13255)
* Fix inconsistencies in event validation (#13088)Richard van der Hoff2022-06-171-4/+10
|
* Fix typechecks against twisted trunk (#13061)David Robertson2022-06-151-4/+4
|
* Wait for lazy join to complete when getting current state (#12872)Erik Johnston2022-06-011-2/+4
|
* Rename storage classes (#12913)Erik Johnston2022-05-311-2/+4
|
* Pull out less state when handling gaps mk2 (#12852)Erik Johnston2022-05-261-1/+5
|
* Fix up `state_store` naming (#12871)Erik Johnston2022-05-251-2/+2
|
* Add some type hints to `event_federation` datastore (#12753)Dirk Klimpel2022-05-181-0/+1
| | | Co-authored-by: David Robertson <david.m.robertson1@gmail.com>
* Add type hints for `tests/unittest.py`. (#12347)Richard van der Hoff2022-04-011-2/+3
| | | In particular, add type hints for get_success and friends, which are then helpful in a bunch of places.
* Raise an exception when getting state at an outlier (#12191)Richard van der Hoff2022-04-011-18/+54
| | | | | | It seems like calling `_get_state_group_for_events` for an event where the state is unknown is an error. Accordingly, let's raise an exception rather than silently returning an empty result.
* Bump `black` and `click` versions (#12320)David Robertson2022-03-291-3/+3
|
* Add type hints to more tests files. (#12240)Dirk Klimpel2022-03-171-15/+21
|
* Remove `HomeServer.get_datastore()` (#12031)Richard van der Hoff2022-02-231-1/+1
| | | | | | | The presence of this method was confusing, and mostly present for backwards compatibility. Let's get rid of it. Part of #11733
* Refactor the way we set `outlier` (#11634)Richard van der Hoff2022-01-051-3/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * `_auth_and_persist_outliers`: mark persisted events as outliers Mark any events that get persisted via `_auth_and_persist_outliers` as, well, outliers. Currently this will be a no-op as everything will already be flagged as an outlier, but I'm going to change that. * `process_remote_join`: stop flagging as outlier The events are now flagged as outliers later on, by `_auth_and_persist_outliers`. * `send_join`: remove `outlier=True` The events created here are returned in the result of `send_join` to `FederationHandler.do_invite_join`. From there they are passed into `FederationEventHandler.process_remote_join`, which passes them to `_auth_and_persist_outliers`... which sets the `outlier` flag. * `get_event_auth`: remove `outlier=True` stop flagging the events returned by `get_event_auth` as outliers. This method is only called by `_get_remote_auth_chain_for_event`, which passes the results into `_auth_and_persist_outliers`, which will flag them as outliers. * `_get_remote_auth_chain_for_event`: remove `outlier=True` we pass all the events into `_auth_and_persist_outliers`, which will now flag the events as outliers. * `_check_sigs_and_hash_and_fetch`: remove unused `outlier` parameter This param is now never set to True, so we can remove it. * `_check_sigs_and_hash_and_fetch_one`: remove unused `outlier` param This is no longer set anywhere, so we can remove it. * `get_pdu`: remove unused `outlier` parameter ... and chase it down into `get_pdu_from_destination_raw`. * `event_from_pdu_json`: remove redundant `outlier` param This is never set to `True`, so can be removed. * changelog * update docstring
* Fix 500 error on `/messages` when we accumulate more than 5 backward ↵Eric Eastwood2021-10-141-0/+64
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | extremities (#11027) Found while working on the Gitter backfill script and noticed it only happened after we sent 7 batches, https://gitlab.com/gitterHQ/webapp/-/merge_requests/2229#note_665906390 When there are more than 5 backward extremities for a given depth, backfill will throw an error because we sliced the extremity list to 5 but then try to iterate over the full list. This causes us to look for state that we never fetched and we get a `KeyError`. Before when calling `/messages` when there are more than 5 backward extremities: ``` Traceback (most recent call last): File "/usr/local/lib/python3.8/site-packages/synapse/http/server.py", line 258, in _async_render_wrapper callback_return = await self._async_render(request) File "/usr/local/lib/python3.8/site-packages/synapse/http/server.py", line 446, in _async_render callback_return = await raw_callback_return File "/usr/local/lib/python3.8/site-packages/synapse/rest/client/room.py", line 580, in on_GET msgs = await self.pagination_handler.get_messages( File "/usr/local/lib/python3.8/site-packages/synapse/handlers/pagination.py", line 396, in get_messages await self.hs.get_federation_handler().maybe_backfill( File "/usr/local/lib/python3.8/site-packages/synapse/handlers/federation.py", line 133, in maybe_backfill return await self._maybe_backfill_inner(room_id, current_depth, limit) File "/usr/local/lib/python3.8/site-packages/synapse/handlers/federation.py", line 386, in _maybe_backfill_inner likely_extremeties_domains = get_domains_from_state(states[e_id]) KeyError: '$zpFflMEBtZdgcMQWTakaVItTLMjLFdKcRWUPHbbSZJl' ```
* Factor out common code for persisting fetched auth events (#10896)Richard van der Hoff2021-09-241-1/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Factor more stuff out of `_get_events_and_persist` It turns out that the event-sorting algorithm in `_get_events_and_persist` is also useful in other circumstances. Here we move the current `_auth_and_persist_fetched_events` to `_auth_and_persist_fetched_events_inner`, and then factor the sorting part out to `_auth_and_persist_fetched_events`. * `_get_remote_auth_chain_for_event`: remove redundant `outlier` assignment `get_event_auth` returns events with the outlier flag already set, so this is redundant (though we need to update a test where `get_event_auth` is mocked). * `_get_remote_auth_chain_for_event`: move existing-event tests earlier Move a couple of tests outside the loop. This is a bit inefficient for now, but a future commit will make it better. It should be functionally identical. * `_get_remote_auth_chain_for_event`: use `_auth_and_persist_fetched_events` We can use the same codepath for persisting the events fetched as part of an auth chain as for those fetched individually by `_get_events_and_persist` for building the state at a backwards extremity. * `_get_remote_auth_chain_for_event`: use a dict for efficiency `_auth_and_persist_fetched_events` sorts the events itself, so we no longer need to care about maintaining the ordering from `get_event_auth` (and no longer need to sort by depth in `get_event_auth`). That means that we can use a map, making it easier to filter out events we already have, etc. * changelog * `_auth_and_persist_fetched_events`: improve docstring
* Split `FederationHandler` in half (#10692)Richard van der Hoff2021-08-261-4/+12
| | | The idea here is to take anything to do with incoming events and move it out to a separate handler, as a way of making FederationHandler smaller.
* Flatten the synapse.rest.client package (#10600)reivilibre2021-08-171-1/+1
|
* Fix backfilled events being rejected for no `state_groups` (#10439)Eric Eastwood2021-07-291-0/+131
| | | | | | | | | | | | | Reproducible on a federated homeserver when there is a membership auth event as a floating outlier. Then when we try to backfill one of that persons messages, it has missing membership auth to fetch which caused us to mistakenly replace the `context` for the message with that of the floating membership `outlier` event. Since `outliers` have no `state` or `state_group`, the error bubbles up when we continue down the persisting route: `sqlite3.IntegrityError: NOT NULL constraint failed: event_to_state_groups.state_group` Call stack: ``` backfill _auth_and_persist_event _check_event_auth _update_auth_events_and_context_for_auth ```
* Improve validation for `send_{join,leave,knock}` (#10225)Richard van der Hoff2021-06-241-1/+1
| | | The idea here is to stop people sending things that aren't joins/leaves/knocks through these endpoints: previously you could send anything you liked through them. I wasn't able to find any security holes from doing so, but it doesn't sound like a good thing.
* Fix (final) Bugbear violations (#9838)Jonathan de Jong2021-04-201-1/+1
|
* Remove redundant "coding: utf-8" lines (#9786)Jonathan de Jong2021-04-141-1/+0
| | | | | | | Part of #9744 Removes all redundant `# -*- coding: utf-8 -*-` lines from files, as python 3 automatically reads source code as utf-8 now. `Signed-off-by: Jonathan de Jong <jonathan@automatia.nl>`
* Update black, and run auto formatting over the codebase (#9381)Eric Eastwood2021-02-161-2/+10
| | | | | | | - Update black version to the latest - Run black auto formatting over the codebase - Run autoformatting according to [`docs/code_style.md `](https://github.com/matrix-org/synapse/blob/80d6dc9783aa80886a133756028984dbf8920168/docs/code_style.md) - Update `code_style.md` docs around installing black to use the correct version
* Honour ratelimit flag for application services for invite ratelimiting (#9302)Erik Johnston2021-02-031-47/+0
|
* Ratelimit invites by room and target user (#9258)Erik Johnston2021-01-291-1/+92
|
* Various clean-ups to the logging context code (#8935)Patrick Cloke2020-12-141-3/+3
|
* Apply an IP range blacklist to push and key revocation requests. (#8821)Patrick Cloke2020-12-021-1/+1
| | | | | | | | | | | | Replaces the `federation_ip_range_blacklist` configuration setting with an `ip_range_blacklist` setting with wider scope. It now applies to: * Federation * Identity servers * Push notifications * Checking key validitity for third-party invite events The old `federation_ip_range_blacklist` setting is still honored if present, but with reduced scope (it only applies to federation and identity servers).
* Consistently use room_id from federation request body (#8776)Richard van der Hoff2020-11-191-1/+0
| | | | | | | | | | | | | * Consistently use room_id from federation request body Some federation APIs have a redundant `room_id` path param (see https://github.com/matrix-org/matrix-doc/issues/2330). We should make sure we consistently use either the path param or the body param, and the body param is easier. * Kill off some references to "context" Once upon a time, "rooms" were known as "contexts". I think this kills of the last references to "contexts".
* Remove the deprecated Handlers object (#8494)Patrick Cloke2020-10-091-1/+1
| | | All handlers now available via get_*_handler() methods on the HomeServer.
* Implement room version 6 (MSC2240). (#7506)Patrick Cloke2020-05-151-3/+3
|
* Strictly enforce canonicaljson requirements in a new room version (#7381)Patrick Cloke2020-05-141-1/+66
|
* Pass room_version into `event_from_pdu_json`Richard van der Hoff2020-02-061-2/+4
| | | | It's called from all over the shop, so this one's a bit messy.
* Fix bug which caused rejected events to be stored with the wrong room state ↵Richard van der Hoff2019-11-061-0/+126
| | | | | | | | | | | | (#6320) Fixes a bug where rejected events were persisted with the wrong state group. Also fixes an occasional internal-server-error when receiving events over federation which are rejected and (possibly because they are backwards-extremities) have no prev_group. Fixes #6289.
* Lint (again)Brendan Abolivier2019-10-031-3/+1
|
* LintBrendan Abolivier2019-10-031-5/+5
|
* Add test caseBrendan Abolivier2019-10-031-0/+83
|
* Make unit tests workErik Johnston2016-01-181-141/+0
|
* Merge pull request #456 from matrix-org/store_event_actionsDavid Baker2016-01-081-0/+11
|\ | | | | Send unread notification counts
| * fix testsDavid Baker2016-01-061-0/+4
| |
| * fix testsDavid Baker2016-01-041-1/+1
| |
| * Add mocks to make tests work againDavid Baker2015-12-221-0/+7
| |
* | copyrightsMatthew Hodgson2016-01-071-1/+1
|/
* Don't needlessly compute contextErik Johnston2015-06-031-2/+2
|
* Don't bother checking for updates if the stream token hasn't advanced for a userMark Haines2015-05-131-2/+2
|
* Make work in both Maria and SQLite. Fix testsErik Johnston2015-04-011-0/+9
|
* Factor out some of the common homeserver setup code into aMark Haines2015-02-111-8/+3
| | | | setup_test_homeserver function in utils.
* Try to ensure we don't persist an event we have already persisted. In ↵Erik Johnston2015-02-031-1/+4
| | | | persist_event check if we already have the event, if so then update instead of replacing so that we don't cause a bump of the stream_ordering.
* Initial implementation of auth conflict resolutionErik Johnston2015-01-291-0/+2
|
* Construct the EventContext in the state handler rather than constructing one ↵Mark Haines2014-12-161-10/+8
| | | | and then immediately calling state_handler.annotate_context_with_state
* Kill off synapse.api.events.*Erik Johnston2014-12-161-5/+2
|
* Fix federation testErik Johnston2014-12-111-18/+24
|
* fix UTs by telling all the mock stores about the new methods for tracking ↵Matthew Hodgson2014-12-091-0/+2
| | | | retries
* Fix bugs when joining a remote room that has dodgy event graphs. This should ↵Erik Johnston2014-11-271-1/+5
| | | | also fix the number of times a HS will trigger a GET /event/
* Fix tests.Erik Johnston2014-11-261-1/+1
|
* Fix bugs in invite/join dances.Erik Johnston2014-11-251-5/+7
| | | | | We now do more implement more of the auth on the events so that we don't reject valid events.
* replace user_id with senderMark Haines2014-11-191-1/+2
|
* Merge PDUs and Events into one objectMark Haines2014-11-141-2/+3
|
* Validate signatures on incoming eventsMark Haines2014-11-141-1/+3
|
* Rename annotate_state_groups to annotate_event_with_stateErik Johnston2014-11-111-3/+3
|
* Fix Federation testErik Johnston2014-11-051-1/+1
|
* Fix federation handler tests. I've removed the invite/join dance ones as ↵Erik Johnston2014-11-041-57/+27
| | | | they are completely out of date.
* SPEC-7: Rename 'ts' to 'origin_server_ts'Mark Haines2014-10-171-3/+3
|
* Merge branch 'develop' into server2server_signingMark Haines2014-09-301-1/+1
|\ | | | | | | | | | | Conflicts: synapse/storage/__init__.py tests/rest/test_presence.py
| * Fix test where we changed arguments used to call the notifierErik Johnston2014-09-251-1/+1
| |
* | Sign federation transactionsMark Haines2014-09-241-1/+6
|/
* Correctly handle receiving 'missing' Pdus from federation, rather than just ↵Erik Johnston2014-09-151-1/+3
| | | | discarding them.
* Have all unit tests import from our own subclass of trial's unittest ↵Paul "LeoNerd" Evans2014-09-121-5/+1
| | | | TestCase; set up logging in ONE PLACE ONLY
* Fix test to assert that we don't do authErik Johnston2014-09-031-1/+1
|
* fix the copyright holder from matrix.org to OpenMarket Ltd, as matrix.org ↵Matthew Hodgson2014-09-031-1/+1
| | | | hasn't been incorporated in time for launch.
* Remove get_state_for_room function from federation handlerMark Haines2014-08-281-2/+8
|
* Merge branch 'develop' into storage_transactionsMark Haines2014-08-271-2/+1
|\ | | | | | | | | | | Conflicts: tests/handlers/test_federation.py tests/handlers/test_room.py
| * Fix tests.Erik Johnston2014-08-271-2/+1
| |
* | Fill out prev_events before calling persist_eventMark Haines2014-08-271-17/+26
|/
* Fix ALL THE UNIT TESTSKegan Dougal2014-08-261-1/+0
|
* Fix federation test, since we now hit store.get_roomErik Johnston2014-08-201-1/+2
|
* Update testsErik Johnston2014-08-191-4/+4
|
* Removed http_server from HomeServer. Updated unit tests to use either ↵Kegan Dougal2014-08-141-1/+1
| | | | resource_for_federation or resource_for_client depending on what is being tested.
* add in copyrights to everything, not just the synapse subdir, and add a ↵Matthew Hodgson2014-08-131-0/+14
| | | | copyrighter.pl whilst we're at it
* Reference Matrix Home Servermatrix.org2014-08-121-0/+107