summary refs log tree commit diff
path: root/tests/unittest.py (follow)
Commit message (Collapse)AuthorAgeFilesLines
* Bump black from 23.10.1 to 24.2.0 (#16936)dependabot[bot]2024-03-131-2/+1
|
* Correctly mention previous copyright (#16820)Erik Johnston2024-01-231-0/+2
| | | | | During the migration the automated script to update the copyright headers accidentally got rid of some of the existing copyright lines. Reinstate them.
* Update license headersPatrick Cloke2023-11-211-12/+16
|
* Fix type hint errors from Twisted trunk (#16526)Patrick Cloke2023-10-231-1/+2
|
* Register media servlets via regex. (#16419)Patrick Cloke2023-10-061-2/+2
| | | | | This converts the media servlet URLs in the same way as (most) of the rest of Synapse. This will give more flexibility in the versions each endpoint exists under.
* Refactor storing of server keys (#16261)Erik Johnston2023-09-121-13/+13
|
* Bump mypy-zope & mypy. (#16188)Patrick Cloke2023-08-291-3/+3
|
* Support IPv6-only SMTP servers (#16155)Evilham2023-08-291-1/+1
| | | | Use Twisted HostnameEndpoint to connect to SMTP servers (instead of connectTCP/connectSSL) which properly supports IPv6-only servers.
* Re-introduce the outbound federation proxy (#15913)Eric Eastwood2023-07-181-0/+1
| | | | | Allow configuring the set of workers to proxy outbound federation traffic through (`outbound_federation_restricted_to`). This is useful when you have a worker setup with `federation_sender` instances responsible for sending outbound federation requests and want to make sure *all* outbound federation traffic goes through those instances. Before this change, the generic workers would still contact federation themselves for things like profile lookups, backfill, etc. This PR allows you to set more strict access controls/firewall for all workers and only allow the `federation_sender`'s to contact the outside world.
* Revert "Federation outbound proxy" (#15910)Eric Eastwood2023-07-101-1/+0
| | | | | | Revert "Federation outbound proxy (#15773)" This reverts commit b07b14b494ae1dd564b4c44f844c9a9545b3d08a.
* Federation outbound proxy (#15773)Eric Eastwood2023-07-051-0/+1
| | | | | | | Allow configuring the set of workers to proxy outbound federation traffic through (`outbound_federation_restricted_to`). This is useful when you have a worker setup with `federation_sender` instances responsible for sending outbound federation requests and want to make sure *all* outbound federation traffic goes through those instances. Before this change, the generic workers would still contact federation themselves for things like profile lookups, backfill, etc. This PR allows you to set more strict access controls/firewall for all workers and only allow the `federation_sender`'s to contact the outside world. The original code is from @erikjohnston's branches which I've gotten in-shape to merge.
* Limit the size of the `HomeServerConfig` cache in trial test runs (#15646)Sean Quah2023-05-221-16/+7
| | | | | | | | | | | | ...to try to control memory usage. `HomeServerConfig`s hold on to many Jinja2 objects, which come out to over 0.5 MiB per config. Over the course of a full test run, the cache grows to ~360 entries. Limit it to 8 entries. Part of #15622. Signed-off-by: Sean Quah <seanq@matrix.org>
* Fix `HomeServer`s leaking during `trial` test runs (#15630)Sean Quah2023-05-191-2/+9
| | | | | | | | | | | | | | | | | | | This change fixes two memory leaks during `trial` test runs. Garbage collection is disabled during each test case and a gen-0 GC is run at the end of each test. However, when the gen-0 GC is run, the `TestCase` object usually still holds references to the `HomeServer` used during the test. As a result, the `HomeServer` gets promoted to gen-1 and then never garbage collected. Fix this by periodically running full GCs. Additionally, fix `HomeServer`s leaking after tests that touch inbound federation due to `FederationRateLimiter`s adding themselves to a global set, by turning the set into a `WeakSet`. Resolves #15622. Signed-off-by: Sean Quah <seanq@matrix.org>
* Factor out an `is_mine_server_name` method (#15542)Sean Quah2023-05-051-2/+14
| | | | | | | | | | | | Add an `is_mine_server_name` method, similar to `is_mine_id`. Ideally we would use this consistently, instead of sometimes comparing against `hs.hostname` and other times reaching into `hs.config.server.server_name`. Also fix a bug in the tests where `hs.hostname` would sometimes differ from `hs.config.server.server_name`. Signed-off-by: Sean Quah <seanq@matrix.org>
* Modify StoreKeyFetcher to read from server_keys_json. (#15417)Patrick Cloke2023-04-201-9/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | Before this change: * `PerspectivesKeyFetcher` and `ServerKeyFetcher` write to `server_keys_json`. * `PerspectivesKeyFetcher` also writes to `server_signature_keys`. * `StoreKeyFetcher` reads from `server_signature_keys`. After this change: * `PerspectivesKeyFetcher` and `ServerKeyFetcher` write to `server_keys_json`. * `PerspectivesKeyFetcher` also writes to `server_signature_keys`. * `StoreKeyFetcher` reads from `server_keys_json`. This results in `StoreKeyFetcher` now using the results from `ServerKeyFetcher` in addition to those from `PerspectivesKeyFetcher`, i.e. keys which are directly fetched from a server will now be pulled from the database instead of refetched. An additional minor change is included to avoid creating a `PerspectivesKeyFetcher` (and checking it) if no `trusted_key_servers` are configured. The overall impact of this should be better usage of cached results: * If a server has no trusted key servers configured then it should reduce how often keys are fetched. * if a server's trusted key server does not have a requested server's keys cached then it should reduce how often keys are directly fetched.
* Speedup tests by caching HomeServerConfig instances (#15284)Val Lorentz2023-04-181-2/+60
| | | | | | | | | | | | | | | | | | | These two lines: ``` config_obj = HomeServerConfig() config_obj.parse_config_dict(config, "", "") ``` are called many times with the exact same value for `config`. As the test suite is CPU-bound and non-negligeably time is spent in `parse_config_dict`, this saves ~5% on the overall runtime of the Trial test suite (tested with both `-j2` and `-j12` on a 12t CPU). This is sadly rather limited, as the cache cannot be shared between processes (it contains at least jinja2.Template and RLock objects which aren't pickleable), and Trial tends to run close tests in different processes.
* Improve robustness when handling a perspective key response by deduplicating ↵reivilibre2023-04-131-10/+6
| | | | | | | | | | | | | | | received server keys. (#15423) * Change `store_server_verify_keys` to take a `Mapping[(str, str), FKR]` This is because we already can't handle duplicate keys — leads to cardinality violation * Newsfile Signed-off-by: Olivier Wilkinson (reivilibre) <oliverw@matrix.org> --------- Signed-off-by: Olivier Wilkinson (reivilibre) <oliverw@matrix.org>
* Speed up SQLite unit test CI (#15334)Erik Johnston2023-03-301-3/+13
| | | Tests now take 40% of the time.
* Batch up storing state groups when creating new room (#14918)Shay2023-02-241-2/+2
|
* Fix-up type hints in tests/server.py. (#15084)Patrick Cloke2023-02-171-3/+8
| | | | | This file was being ignored by mypy, we remove that and add the missing type hints & deal with any fallout.
* Add final type hint to tests.unittest. (#15072)Patrick Cloke2023-02-141-1/+3
| | | | Adds a return type to HomeServerTestCase.make_homeserver and deal with any variables which are no longer Any.
* Add more missing type hints to tests. (#15028)Patrick Cloke2023-02-081-1/+1
|
* Fix type hints in typing edu unit tests (#14886)Andrew Morgan2023-01-261-1/+2
|
* Remove redundant types from comments. (#14412)Patrick Cloke2022-11-161-10/+8
| | | | | | | Remove type hints from comments which have been added as Python type hints. This helps avoid drift between comments and reality, as well as removing redundant information. Also adds some missing type hints which were simple to fill in.
* Persist CreateRoom events to DB in a batch (#13800)Shay2022-09-281-1/+3
|
* Improve the `synapse.api.auth.Auth` mock used in unit tests. (#13809)Quentin Gliech2022-09-211-26/+10
| | | To return the proper type (`Requester`) instead of a `dict`.
* Implement MSC3852: Expose `last_seen_user_agent` to users for their own ↵Andrew Morgan2022-08-191-0/+15
| | | | devices; also expose to Admin API (#13549)
* Add missing type hints for tests.unittest. (#13397)Patrick Cloke2022-07-271-38/+48
|
* Rate limit joins per-room (#13276)David Robertson2022-07-191-2/+2
|
* Remove unnecessary `json.dumps` from tests (#13303)Dirk Klimpel2022-07-171-19/+12
|
* Rename test case method to `add_hashes_and_signatures_from_other_server` ↵David Robertson2022-07-121-1/+1
| | | | (#13255)
* Move the "email unsubscribe" resource, refactor the macaroon generator & ↵Quentin Gliech2022-06-141-1/+1
| | | | | | | | | | | | | | | | | | | | | simplify the access token verification logic. (#12986) This simplifies the access token verification logic by removing the `rights` parameter which was only ever used for the unsubscribe link in email notifications. The latter has been moved under the `/_synapse` namespace, since it is not a standard API. This also makes the email verification link more secure, by embedding the app_id and pushkey in the macaroon and verifying it. This prevents the user from tampering the query parameters of that unsubscribe link. Macaroon generation is refactored: - Centralised all macaroon generation and verification logic to the `MacaroonGenerator` - Moved to `synapse.utils` - Changed the constructor to require only a `Clock`, hostname, and a secret key (instead of a full `Homeserver`). - Added tests for all methods.
* Respect the `@cancellable` flag for `RestServlet`s and ↵Sean Quah2022-05-111-1/+1
| | | | | | | | | | | | | | | `BaseFederationServlet`s (#12699) Both `RestServlet`s and `BaseFederationServlet`s register their handlers with `HttpServer.register_paths` / `JsonResource.register_paths`. Update `JsonResource` to respect the `@cancellable` flag on handlers registered in this way. Although `ReplicationEndpoint` also registers itself using `register_paths`, it does not pass the handler method that would have the `@cancellable` flag directly, and so needs separate handling. Signed-off-by: Sean Quah <seanq@element.io>
* Add type hints for `tests/unittest.py`. (#12347)Richard van der Hoff2022-04-011-28/+57
| | | In particular, add type hints for get_success and friends, which are then helpful in a bunch of places.
* Remove redundant `get_success` calls in test code (#12346)Richard van der Hoff2022-04-011-16/+5
| | | There are a bunch of places we call get_success on an immediate value, which is unnecessary. Let's rip them out, and remove the redundant functionality in get_success and friends.
* Move single-use methods out of `TestCase` (#12348)Richard van der Hoff2022-04-011-27/+0
| | | | These methods are only used by a single testcase, so they shouldn't be cluttering up the base `TestCase` class.
* Replace assertEquals and friends with non-deprecated versions. (#12092)Patrick Cloke2022-02-281-3/+3
|
* Remove `HomeServer.get_datastore()` (#12031)Richard van der Hoff2022-02-231-6/+8
| | | | | | | The presence of this method was confusing, and mostly present for backwards compatibility. Let's get rid of it. Part of #11733
* Faster joins: Support for calling `/federation/v1/state` (#12013)Richard van der Hoff2022-02-221-0/+21
| | | | This is an endpoint that we have server-side support for, but no client-side support. It's going to be useful for resyncing partial-stated rooms, so let's introduce it.
* Tests: replace mocked Authenticator with the real thing (#11913)Richard van der Hoff2022-02-111-30/+106
| | | | | | | | | | | | If we prepopulate the test homeserver with a key for a remote homeserver, we can make federation requests to it without having to stub out the authenticator. This has two advantages: * means that what we are testing is closer to reality (ie, we now have complete tests for the incoming-request-authorisation flow) * some tests require that other objects be signed by the remote server (eg, the event in `/send_join`), and doing that would require a whole separate set of mocking out. It's much simpler just to use real keys.
* Expose the registered device ID from the `register_appservice_user` test ↵reivilibre2022-02-021-4/+5
| | | | helper. (#11615)
* Fix case in `wait_for_background_updates` where `self.store` does not exist ↵Andrew Morgan2021-12-071-7/+4
| | | | | | (#11331) Pull the DataStore from the HomeServer instance, which always exists.
* Make background updates controllable via a plugin (#11306)Erik Johnston2021-11-291-6/+4
| | | Co-authored-by: Brendan Abolivier <babolivier@matrix.org>
* Store arbitrary relations from events. (#11391)Patrick Cloke2021-11-221-1/+6
| | | | | Instead of only known relation types. This also reworks the background update for thread relations to crawl events and search for any relation type, not just threaded relations.
* Misc typing fixes for tests, part 2 of N (#11330)David Robertson2021-11-161-16/+15
|
* Misc typing fixes for `tests`, part 1 of N (#11323)David Robertson2021-11-121-11/+21
| | | | | | | | | | * Annotate HomeserverTestCase.servlets * Correct annotation of federation_auth_origin * Use AnyStr custom_headers instead of a Union This allows (str, str) and (bytes, bytes). This disallows (str, bytes) and (bytes, str) * DomainSpecificString.SIGIL is a ClassVar
* Fix-up some type hints in the relations tests. (#11076)Patrick Cloke2021-10-141-2/+2
|
* Don't drop user dir deltas when server leaves room (#10982)David Robertson2021-10-061-0/+9
| | | | | | | | | Fix a long-standing bug where a batch of user directory changes would be silently dropped if the server left a room early in the batch. * Pull out `wait_for_background_update` in tests Co-authored-by: Patrick Cloke <clokep@users.noreply.github.com> Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com>
* Consistently exclude from user_directory (#10960)David Robertson2021-10-041-0/+29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Introduce `should_include_local_users_in_dir` We exclude three kinds of local users from the user_directory tables. At present we don't consistently exclude all three in the same places. This commit introduces a new function to gather those exclusion conditions together. Because we have to handle local and remote users in different ways, I've made that function only consider the case of remote users. It's the caller's responsibility to make the local versus remote distinction clear and correct. A test fixup is required. The test now hits a path which makes db queries against the users table. The expected rows were missing, because we were using a dummy user that hadn't actually been registered. We also add new test cases to covert the exclusion logic. ---- By my reading this makes these changes: * When an app service user registers or changes their profile, they will _not_ be added to the user directory. (Previously only support and deactivated users were excluded). This is consistent with the logic that rebuilds the user directory. See also [the discussion here](https://github.com/matrix-org/synapse/pull/10914#discussion_r716859548). * When rebuilding the directory, exclude support and disabled users from room sharing tables. Previously only appservice users were excluded. * Exclude all three categories of local users when rebuilding the directory. Previously `_populate_user_directory_process_users` didn't do any exclusion. Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com>
* Use direct references for configuration variables (part 7). (#10959)Patrick Cloke2021-10-041-1/+1
|
* type-hint `HomeserverTestcase.setup_test_homeserver` (#10961)David Robertson2021-10-011-2/+2
| | | | | * type-hint `HomeserverTestcase.setup_test_homeserver` For better IDE completion. A small drive-by.
* Refactor user directory tests (#10935)David Robertson2021-09-301-1/+3
| | | | | | | | | | | | | * Pull out GetUserDirectoryTables helper * Don't rebuild the dir in tests that don't need it In #10796 I changed registering a user to add directory entries under. This means we don't have to force a directory regbuild in to tests of the user directory search. * Move test_initial to tests/storage * Add type hints to both test_user_directory files Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com>
* Use direct references for configuration variables (part 6). (#10916)Patrick Cloke2021-09-291-1/+1
|
* Add types to synapse.util. (#10601)reivilibre2021-09-101-2/+2
|
* Flatten tests/rest/client/{v1,v2_alpha} too (#10667)David Robertson2021-08-201-1/+1
|
* Add a new version of the R30 phone-home metric, which removes a false ↵reivilibre2021-07-191-2/+13
| | | | | impression of retention given by the old R30 metric (#10332) Signed-off-by: Olivier Wilkinson (reivilibre) <olivier@librepush.net>
* Use inline type hints in `tests/` (#10350)Jonathan de Jong2021-07-131-1/+1
| | | | | | | | This PR is tantamount to running: python3.8 -m com2ann -v 6 tests/ (com2ann requires python 3.8 to run)
* [pyupgrade] `tests/` (#10347)Jonathan de Jong2021-07-131-1/+1
|
* Remove various bits of compatibility code for Python <3.6 (#9879)Andrew Morgan2021-04-271-1/+1
| | | I went through and removed a bunch of cruft that was lying around for compatibility with old Python versions. This PR also will now prevent Synapse from starting unless you're running Python 3.6+.
* Improved validation for received requests (#9817)Richard van der Hoff2021-04-231-0/+1
| | | | | | * Simplify `start_listening` callpath * Correctly check the size of uploaded files
* pass a reactor into SynapseSite (#9874)Richard van der Hoff2021-04-231-0/+1
|
* 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>`
* Use mock from the stdlib. (#9772)Patrick Cloke2021-04-091-2/+1
|
* Record more information into structured logs. (#9654)Patrick Cloke2021-04-081-1/+1
| | | | Records additional request information into the structured logs, e.g. the requester, IP address, etc.
* Ensure we use a copy of the event content dict before modifying it in ↵Andrew Morgan2021-03-171-0/+10
| | | | | | | | | serialize_event (#9585) This bug was discovered by DINUM. We were modifying `serialized_event["content"]`, which - if you've got `USE_FROZEN_DICTS` turned on or are [using a third party rules module](https://github.com/matrix-org/synapse/blob/17cd48fe5171d50da4cb59db647b993168e7dfab/synapse/events/third_party_rules.py#L73-L76) - will raise a 500 if you try to a edit a reply to a message. `serialized_event["content"]` could be set to the edit event's content, instead of a copy of it, which is bad as we attempt to modify it. Instead, we also end up modifying the original event's content. DINUM uses a third party rules module, which meant the event's content got frozen and thus an exception was raised. To be clear, the problem is not that the event's content was frozen. In fact doing so helped us uncover the fact we weren't copying event content correctly.
* Enable flake8-bugbear, but disable most checks. (#9499)Jonathan de Jong2021-03-161-1/+1
| | | | * Adds B00 to ignored checks. * Fixes remaining issues.
* Update black, and run auto formatting over the codebase (#9381)Eric Eastwood2021-02-161-1/+4
| | | | | | | - 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
* Ratelimit 3PID /requestToken API (#9238)Erik Johnston2021-01-281-0/+5
|
* Skip unit tests which require optional dependencies (#9031)Richard van der Hoff2021-01-071-1/+27
| | | If we are lacking an optional dependency, skip the tests that rely on it.
* Implement a username picker for synapse (#8942)Richard van der Hoff2020-12-181-1/+7
| | | | | | | | | | | | | | The final part (for now) of my work to implement a username picker in synapse itself. The idea is that we allow `UsernameMappingProvider`s to return `localpart=None`, in which case, rather than redirecting the browser back to the client, we redirect to a username-picker resource, which allows the user to enter a username. We *then* complete the SSO flow (including doing the client permission checks). The static resources for the username picker itself (in https://github.com/matrix-org/synapse/tree/rav/username_picker/synapse/res/username_picker) are essentially lifted wholesale from https://github.com/matrix-org/matrix-synapse-saml-mozilla/tree/master/matrix_synapse_saml_mozilla/res. As the comment says, we might want to think about making them customisable, but that can be a follow-up. Fixes #8876.
* lintRichard van der Hoff2020-12-151-1/+1
|
* Remove spurious "SynapseRequest" result from `make_request"Richard van der Hoff2020-12-151-38/+6
| | | | This was never used, so let's get rid of it.
* fix up various test casesRichard van der Hoff2020-12-021-6/+19
| | | | | A few test cases were relying on being able to mount non-client servlets on the test resource. it's better to give them their own Resources.
* Add `create_resource_dict` method to HomeserverTestCaseRichard van der Hoff2020-12-021-7/+21
| | | | | | Rather than using a single JsonResource, construct a resource tree, as we do in the prod code, and allow testcases to add extra resources by overriding `create_resource_dict`.
* Remove deprecated `/_matrix/client/*/admin` endpoints (#8785)Dirk Klimpel2020-11-251-2/+2
| | | These are now only available via `/_synapse/admin/v1`.
* Remove redundant `HomeserverTestCase.render`Richard van der Hoff2020-11-161-14/+0
|
* Remove redundant calls to `render()`Richard van der Hoff2020-11-161-8/+2
|
* Make `make_request` actually render the requestRichard van der Hoff2020-11-161-0/+8
| | | | | | remove the stubbing out of `request.process`, so that `requestReceived` also renders the request via the appropriate resource. Replace render() with a stub for now.
* Merge branch 'develop' into rav/pass_site_to_make_requestRichard van der Hoff2020-11-161-11/+7
|\
| * Rename `create_test_json_resource` to `create_test_resource` (#8759)Richard van der Hoff2020-11-161-11/+7
| | | | | | | | | | The root resource isn't necessarily a JsonResource, so rename this method accordingly, and update a couple of test classes to use the method rather than directly manipulating self.resource.
* | fix dict handling for make_request()Richard van der Hoff2020-11-151-3/+0
| |
* | pass a Site into make_requestRichard van der Hoff2020-11-151-0/+1
| |
* | pass a Site into RestHelperRichard van der Hoff2020-11-151-1/+1
|/
* Add `displayname` to Shared-Secret Registration for admins (#8722)Dirk Klimpel2020-11-051-6/+13
| | | Add `displayname` to Shared-Secret Registration for admins to `POST /_synapse/admin/v1/register`
* Fail test cases if they fail to await all awaitables (#8690)Patrick Cloke2020-10-301-1/+5
|
* Don't instansiate Requester directly (#8614)Erik Johnston2020-10-221-2/+2
|
* Add basic tests for sync/pagination with vector clock tokens. (#8488)Erik Johnston2020-10-141-1/+31
| | | | | These are tests for #8439
* Fix message duplication if something goes wrong after persisting the event ↵Erik Johnston2020-10-131-2/+9
| | | | | (#8476) Should fix #3365.
* kill off `send_nonmember_event`Richard van der Hoff2020-10-051-1/+3
| | | | This is now redundant, and we can just call `handle_new_client_event` directly.
* Add unit test for event persister sharding (#8433)Erik Johnston2020-10-021-1/+1
|
* Add checks for postgres sequence consistency (#8402)Erik Johnston2020-09-281-1/+30
|
* Create a mechanism for marking tests "logcontext clean" (#8399)Richard van der Hoff2020-09-281-1/+14
|
* Simplify super() calls to Python 3 syntax. (#8344)Patrick Cloke2020-09-181-1/+1
| | | | | | | This converts calls like super(Foo, self) -> super(). Generated with: sed -i "" -Ee 's/super\([^\(]+\)/super()/g' **/*.py
* Show a confirmation page during user password reset (#8004)Andrew Morgan2020-09-101-0/+4
| | | | | This PR adds a confirmation step to resetting your user password between clicking the link in your email and your password actually being reset. This is to better align our password reset flow with the industry standard of requiring a confirmation from the user after email validation.
* Stop sub-classing object (#8249)Patrick Cloke2020-09-041-1/+1
|
* Add a shadow-banned flag to users. (#8092)Patrick Cloke2020-08-141-2/+6
|
* Convert synapse.api to async/await (#8031)Patrick Cloke2020-08-061-14/+10
|
* Rename database classes to make some sense (#8033)Erik Johnston2020-08-051-3/+3
|
* Convert the message handler to async/await. (#7884)Patrick Cloke2020-07-221-1/+3
|
* Create a ListenerConfig object (#7681)Richard van der Hoff2020-06-161-1/+1
| | | | | | | | | | This ended up being a bit more invasive than I'd hoped for (not helped by generic_worker duplicating some of the code from homeserver), but hopefully it's an improvement. The idea is that, rather than storing unstructured `dict`s in the config for the listener configurations, we instead parse it into a structured `ListenerConfig` object.
* Fix limit logic for EventsStream (#7358)Richard van der Hoff2020-04-291-26/+4
| | | | | | | | | | | | | | | | | | | * Factor out functions for injecting events into database I want to add some more flexibility to the tools for injecting events into the database, and I don't want to clutter up HomeserverTestCase with them, so let's factor them out to a new file. * Rework TestReplicationDataHandler This wasn't very easy to work with: the mock wrapping was largely superfluous, and it's useful to be able to inspect the received rows, and clear out the received list. * Fix AssertionErrors being thrown by EventsStream Part of the problem was that there was an off-by-one error in the assertion, but also the limit logic was too simple. Fix it all up and add some tests.
* Set a logging context while running the bg updatesRichard van der Hoff2020-03-311-4/+7
| | | | | This mostly just reduces the amount of "running from sentinel context" spam during unittest setup.
* Merge pull request #7157 from matrix-org/rev.outbound_device_pokes_testsRichard van der Hoff2020-03-301-5/+3
|\ | | | | Add tests for outbound device pokes
| * Add tests for outbound device pokesRichard van der Hoff2020-03-271-0/+1
| |
| * Remove spurious "name" parameter to `default_config`Richard van der Hoff2020-03-241-5/+2
| | | | | | | | | | this is never set to anything other than "test", and is a source of unnecessary boilerplate.
* | Clean up some LoggingContext stuff (#7120)Richard van der Hoff2020-03-241-4/+8
|/ | | | | | | | | | | | | | | | | | | | | | | * Pull Sentinel out of LoggingContext ... and drop a few unnecessary references to it * Factor out LoggingContext.current_context move `current_context` and `set_context` out to top-level functions. Mostly this means that I can more easily trace what's actually referring to LoggingContext, but I think it's generally neater. * move copy-to-parent into `stop` this really just makes `start` and `stop` more symetric. It also means that it behaves correctly if you manually `set_log_context` rather than using the context manager. * Replace `LoggingContext.alive` with `finished` Turn `alive` into `finished` and make it a bit better defined.
* Implement GET /_matrix/client/r0/rooms/{roomId}/aliases (#6939)Richard van der Hoff2020-02-181-9/+19
| | | | | per matrix-org/matrix-doc#2432
* s/get_room_version/get_room_version_id/Richard van der Hoff2020-01-311-1/+3
| | | | | ... to make way for a forthcoming get_room_version which returns a RoomVersion object.
* Fix `/events/:event_id` deprecated API. (#6731)Erik Johnston2020-01-201-1/+1
|
* Merge pull request #6629 from matrix-org/rav/kill_event_reference_hashesRichard van der Hoff2020-01-061-5/+1
|\ | | | | Remove a bunch of unused code from event creation
| * Remove unused hashes and depths from create_event paramsRichard van der Hoff2020-01-061-5/+1
| |
* | Workaround for error when fetching notary's own key (#6620)Richard van der Hoff2020-01-061-1/+10
|/ | | | | | | | | | | | | | * Kill off redundant SynapseRequestFactory We already get the Site via the Channel, so there's no need for a dedicated RequestFactory: we can just use the right constructor. * Workaround for error when fetching notary's own key As a notary server, when we return our own keys, include all of our signing keys in verify_keys. This is a workaround for #6596.
* Merge pull request #6484 from matrix-org/erikj/port_sync_handlerErik Johnston2019-12-091-1/+6
|\ | | | | Port SyncHandler to async/await
| * Port SyncHandler to async/awaitErik Johnston2019-12-051-1/+6
| |
* | Move background update handling out of storeErik Johnston2019-12-051-4/+6
| |
* | Move DB pool and helper functions into dedicated Database classErik Johnston2019-12-051-1/+1
|/
* Remove underscore from SQLBaseStore functionsErik Johnston2019-12-041-1/+1
|
* Implementation of MSC2314 (#6176)Amber Brown2019-11-281-1/+67
|
* Remove DelayedCall debugging from test runs (#5787)Amber Brown2019-07-311-6/+0
|
* More refactoring in `get_events_as_list` (#5707)Richard van der Hoff2019-07-171-0/+1
| | | | | | | | We can now use `_get_events_from_cache_or_db` rather than going right back to the database, which means that (a) we can benefit from caching, and (b) it opens the way forward to more extensive checks on the original event. We now always require the original event to exist before we will serve up a redaction.
* Merge pull request #5589 from matrix-org/erikj/admin_exfiltrate_dataErik Johnston2019-07-151-1/+1
|\ | | | | Add basic function to get all data for a user out of synapse
| * Merge branch 'develop' of github.com:matrix-org/synapse into ↵Erik Johnston2019-07-051-1/+1
| |\ | | | | | | | | | erikj/admin_exfiltrate_data
| * | Add basic function to get all data for a user out of synapseErik Johnston2019-07-021-1/+1
| | |
* | | Add a mechanism for per-test configs (#5657)Richard van der Hoff2019-07-121-1/+54
| |/ |/| | | | | | | | | It's useful to be able to tweak the homeserver config to be used for each test. This PR adds a mechanism to do so.
* | Move logging utilities out of the side drawer of util/ and into logging/ (#5606)Amber Brown2019-07-041-1/+1
|/
* Make the http server handle coroutine-making REST servlets (#5475)Amber Brown2019-06-291-8/+32
|
* Pass config_dir_path and data_dir_path into Config.read_config. (#5522)Richard van der Hoff2019-06-241-1/+1
| | | | | | * Pull config_dir_path and data_dir_path calculation out of read_config_files * Pass config_dir_path and data_dir_path into read_config
* Run Black. (#5482)Amber Brown2019-06-201-10/+8
|
* Expose statistics on extrems to prometheus (#5384)Amber Brown2019-06-131-1/+60
|
* Change password reset links to /_matrix.Erik Johnston2019-06-111-0/+12
|
* Migrate all tests to use the dict-based config format instead of hanging ↵Amber Brown2019-05-131-2/+10
| | | | items off HomeserverConfig (#5171)
* Run Black on the tests again (#5170)Amber Brown2019-05-101-4/+9
|
* Remove the requirement to authenticate for /admin/server_version. (#5122)Richard van der Hoff2019-05-071-4/+18
| | | | | | | | | This endpoint isn't much use for its intended purpose if you first need to get yourself an admin's auth token. I've restricted it to the `/_synapse/admin` path to make it a bit easier to lock down for those concerned about exposing this information. I don't imagine anyone is using it in anger currently.
* Add config option to block users from looking up 3PIDs (#5010)Brendan Abolivier2019-04-041-1/+1
|
* Some more porting to HomeserverTestCase and remove old RESTHelper (#4913)Amber Brown2019-03-221-0/+12
|
* Migrate the user directory initial population to a background task (#4864)Amber Brown2019-03-191-2/+2
|
* Update test_typing to use HomeserverTestCase. (#4771)Richard van der Hoff2019-03-041-2/+6
|
* Enable configuring test log level via env var (#4506)Richard van der Hoff2019-01-291-30/+7
| | | | I got fed up with always adding '@unittest.DEBUG' every time I needed to debug a test.
* Use native UPSERTs where possible (#4306)Amber Brown2019-01-241-2/+10
|
* create support user (#4141)Neil Johnson2018-12-141-0/+1
| | | | | | Allow for the creation of a support user. A support user can access the server, join rooms, interact with other users, but does not appear in the user directory nor does it contribute to monthly active user limits.
* Patch defer.inlineCallbacks to check logcontexts in tests (#4205)Richard van der Hoff2018-12-041-1/+3
|
* Check logcontexts before and after each test (#4190)Richard van der Hoff2018-11-271-2/+9
| | | | | | | | | | | | * Add better diagnostics to flakey keyring test * fix interpolation fail * Check logcontexts before and after each test * update changelog * update changelog
* Do a GC after each test to fix logcontext leaks (#4227)Richard van der Hoff2018-11-271-2/+13
| | | | | | | | | | * Some words about garbage collections and logcontexts * Do a GC after each test to fix logcontext leaks This feels like an awful hack, but... * changelog
* Remove some boilerplate in tests (#4156)Amber Brown2018-11-071-4/+6
|
* Tests for user consent resource (#4140)Amber Brown2018-11-061-2/+10
|
* Write some tests for the email pusher (#4095)Amber Brown2018-10-301-1/+8
|
* Fix userconsent on Python 3 (#3938)Amber Brown2018-10-021-1/+79
|
* Replaced all occurences of e.message with str(e)Schnuffle2018-09-271-1/+1
| | | | Signed-off-by: Schnuffle <schnuffle@github.com>
* Fix client IPs being broken on Python 3 (#3908)Amber Brown2018-09-201-2/+5
|
* Add a regression test for logging on failed connections (#3912)Amber Brown2018-09-201-1/+2
|
* Fix tests on postgresql (#3740)Amber Brown2018-09-041-2/+5
|
* Port storage/ to Python 3 (#3725)Amber Brown2018-08-311-0/+11
|
* Integrate presence from hotfixes (#3694)Amber Brown2018-08-181-1/+7
|
* Implement a new test baseclass to cut down on boilerplate (#3684)Amber Brown2018-08-141-0/+144
|
* Run black.black2018-08-101-2/+5
|
* Refactor REST API tests to use explicit reactors (#3351)Amber Brown2018-07-171-0/+11
|
* cleanupsAmber Brown2018-06-271-1/+4
|
* handle federation not telling us about prev_eventsAmber Brown2018-06-271-1/+1
|
* Put python's logs into Trial when running unit tests (#3319)Amber Brown2018-06-041-13/+27
|
* enable twisted delayedcall debugging in UTsRichard van der Hoff2018-01-091-1/+5
|
* Slightly saner logging for unittestsRichard van der Hoff2016-07-251-4/+7
| | | | | | | 1. Give the handler used for logging in unit tests a formatter, so that the output is slightly more meaningful 2. Log some synapse.storage stuff, because it's useful.
* Fix flake8 warnings for testsMark Haines2016-02-191-3/+4
|
* copyrightsMatthew Hodgson2016-01-071-1/+1
|
* Don't make @unittest.DEBUG print the huge amount of verbosity generated by ↵Paul "LeoNerd" Evans2015-01-121-0/+2
| | | | the synapse.storage loggers
* Added a useful unit test primitive for asserting object attributesPaul "LeoNerd" Evans2014-09-171-0/+11
|
* Define a CLOS-like 'around' modifier as a decorator, to neaten up the ↵Paul "LeoNerd" Evans2014-09-121-10/+23
| | | | 'orig_*' noise of wrapping the setUp()/tearDown() methods
* Add some docstringsPaul "LeoNerd" Evans2014-09-121-0/+6
|
* Additionally look first for a 'loglevel' attribute on the running test ↵Paul "LeoNerd" Evans2014-09-121-3/+7
| | | | method, before the TestCase
* Define a (class) decorator for easily setting a DEBUG logging level on a ↵Paul "LeoNerd" Evans2014-09-121-0/+5
| | | | TestCase
* Allow a TestCase to set a 'loglevel' attribute, which overrides the logging ↵Paul "LeoNerd" Evans2014-09-121-1/+22
| | | | level while that testcase runs
* Have all unit tests import from our own subclass of trial's unittest ↵Paul "LeoNerd" Evans2014-09-121-0/+30
TestCase; set up logging in ONE PLACE ONLY