summary refs log tree commit diff
path: root/tests/test_utils (follow)
Commit message (Collapse)AuthorAgeFilesLines
* Correctly mention previous copyright (#16820)Erik Johnston2024-01-234-0/+4
| | | | | 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-215-51/+80
|
* Replace simple_async_mock with AsyncMock (#16180)Patrick Cloke2023-08-251-18/+1
| | | | Python 3.8 has a native AsyncMock, use it instead of a custom implementation.
* Replace make_awaitable with AsyncMock (#16179)Patrick Cloke2023-08-241-12/+0
| | | | Python 3.8 provides a native AsyncMock, we can replace the homegrown version we have.
* Log when events are (unexpectedly) filtered out of responses in tests (#14213)Eric Eastwood2023-06-011-0/+12
| | | | | See https://github.com/matrix-org/synapse/pull/14095#discussion_r990335492 This is useful because when see that a relevant event is an `outlier` or `soft-failed`, then that's a good unexpected indicator explaining why it's not showing up. `filter_events_for_client` is used in `/sync`, `/messages`, `/context` which are all common end-to-end assertion touch points (also notifications, relations).
* Handle errors when introspecting tokensQuentin Gliech2023-05-301-2/+2
| | | | | This returns a proper 503 when the introspection endpoint is not working for some reason, which should avoid logging out clients in those cases.
* Remove duplicate timestamp from test logs (`_trial_temp/test.log`) (#15636)Eric Eastwood2023-05-221-4/+3
| | | | | | | | | | | | | | | | | | | | | | | | Fix https://github.com/matrix-org/synapse/issues/15618 ### Before ``` 2023-05-17 22:51:36-0500 [-] 2023-05-17 22:51:36,889 - synapse.server - 338 - INFO - sentinel - Finished setting up. ``` ### After ``` 2023-05-19 18:16:20-0500 [-] synapse.server - 338 - INFO - sentinel - Finished setting up. ``` ### Dev notes The `Twisted.Logger` controls the `2023-05-19 18:16:20-0500 [-]` prefix, see : [`twisted/twisted` -> `src/twisted/logger/_format.py#L362-L374`](https://github.com/twisted/twisted/blob/34b161e66bc7c9f9efbb95e82c770a863933e498/src/twisted/logger/_format.py#L362-L374) And we delegate our logs to the Twisted Logger for the tests which puts it in `_trial_temp/test.log`
* Ensure fed-sender catchup does not block for full state (#15248)David Robertson2023-03-131-0/+31
| | | | * Reproduce bad scenario in test * Avoid catchup optimisation for partial state rooms
* Add a class UnpersistedEventContext to allow for the batching up of storing ↵Shay2023-02-091-1/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | state groups (#14675) * add class UnpersistedEventContext * modify create new client event to create unpersistedeventcontexts * persist event contexts after creation * fix tests to persist unpersisted event contexts * cleanup * misc lints + cleanup * changelog + fix comments * lints * fix batch insertion? * reduce redundant calculation * add unpersisted event classes * rework compute_event_context, split into function that returns unpersisted event context and then persists it * use calculate_context_info to create unpersisted event contexts * update typing * $%#^&* * black * fix comments and consolidate classes, use attr.s for class * requested changes * lint * requested changes * requested changes * refactor to be stupidly explicit * clearer renaming and flow * make partial state non-optional * update docstrings --------- Co-authored-by: Erik Johnston <erik@matrix.org>
* Add more missing type hints to tests. (#15028)Patrick Cloke2023-02-085-23/+31
|
* Reload the pyo3-log config when the Python logging config changes. (#14976)Patrick Cloke2023-02-031-0/+3
| | | | | | | | | | | Since pyo3-log is initialized very early in the Python start-up it caches the state of the loggers before they're fully initialized (and thus are essentially disabled). Whenever we reload the logging configuration we now also tell pyo3-log to discard any cached logging configuration it has; it will refetch the current logging configuration from Python at the next point it logs. This fixes Rust log lines not appearing in the homeserver logs.
* Support OIDC backchannel logouts (#11414)Quentin Gliech2022-10-311-2/+25
| | | | | | | If configured an OIDC IdP can log a user's session out of Synapse when they log out of the identity provider. The IdP sends a request directly to Synapse (and must be configured with an endpoint) when a user logs out.
* Refactor OIDC tests to better mimic an actual OIDC provider. (#13910)Quentin Gliech2022-10-252-8/+357
| | | | | | | | | This implements a fake OIDC server, which intercepts calls to the HTTP client. Improves accuracy of tests by covering more internal methods. One particular example was the ID token validation, which previously mocked. This uncovered an incorrect dependency: Synapse actually requires at least authlib 0.15.1, not 0.14.0.
* Rename storage classes (#12913)Erik Johnston2022-05-311-1/+1
|
* Remove unused `# type: ignore`s (#12531)David Robertson2022-04-272-5/+5
| | | | | | | | | | | | | | | | | | | | | | Over time we've begun to use newer versions of mypy, typeshed, stub packages---and of course we've improved our own annotations. This makes some type ignore comments no longer necessary. I have removed them. There was one exception: a module that imports `select.epoll`. The ignore is redundant on Linux, but I've kept it ignored for those of us who work on the source tree using not-Linux. (#11771) I'm more interested in the config line which enforces this. I want unused ignores to be reported, because I think it's useful feedback when annotating to know when you've fixed a problem you had to previously ignore. * Installing extras before typechecking Lacking an easy way to install all extras generically, let's bite the bullet and make install the hand-maintained `all` extra before typechecking. Now that https://github.com/matrix-org/backend-meta/pull/6 is merged to the release/v1 branch.
* Remove `HomeServer.get_datastore()` (#12031)Richard van der Hoff2022-02-231-1/+3
| | | | | | | The presence of this method was confusing, and mostly present for backwards compatibility. Let's get rid of it. Part of #11733
* Cache empty responses from `/user/devices` (#11587)David Robertson2022-01-051-2/+2
| | | If we've never made a request to a remote homeserver, we should cache the response---even if the response is "this user has no devices".
* Create a constant for a small png image in tests. (#10834)Patrick Cloke2021-09-161-2/+12
| | | To avoid duplicating it between a few tests.
* Use inline type hints in `tests/` (#10350)Jonathan de Jong2021-07-131-3/+3
| | | | | | | | This PR is tantamount to running: python3.8 -m com2ann -v 6 tests/ (com2ann requires python 3.8 to run)
* Remove redundant "coding: utf-8" lines (#9786)Jonathan de Jong2021-04-144-4/+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>`
* Bump black configuration to target py36 (#9781)Dan Callahan2021-04-131-3/+3
| | | Signed-off-by: Dan Callahan <danc@element.io>
* Use mock from the stdlib. (#9772)Patrick Cloke2021-04-091-2/+1
|
* Fix additional type hints. (#9543)Patrick Cloke2021-03-091-1/+1
| | | Type hint fixes due to Twisted 21.2.0 adding type hints.
* Fix bugs in handling clientRedirectUrl, and improve OIDC tests (#9127, #9128)Richard van der Hoff2021-01-181-0/+53
| | | | | | | | | | | | | | | | * Factor out a common TestHtmlParser Looks like I'm doing this in a few different places. * Improve OIDC login test Complete the OIDC login flow, rather than giving up halfway through. * Ensure that OIDC login works with multiple OIDC providers * Fix bugs in handling clientRedirectUrl - don't drop duplicate query-params, or params with no value - allow utf-8 in query-params
* Preparatory refactoring of the SamlHandlerTestCase (#8938)Richard van der Hoff2020-12-151-0/+12
| | | | | | | | | | | | | * move simple_async_mock to test_utils ... so that it can be re-used * Remove references to `SamlHandler._map_saml_response_to_user` from tests This method is going away, so we can no longer use it as a test point. Instead, factor out a higher-level method which takes a SAML object, and verify correct behaviour by mocking out `AuthHandler.complete_sso_login`. * changelog
* Various clean-ups to the logging context code (#8935)Patrick Cloke2020-12-141-1/+1
|
* Factor out FakeResponse from test_oidcRichard van der Hoff2020-12-021-0/+27
|
* Fail test cases if they fail to await all awaitables (#8690)Patrick Cloke2020-10-301-1/+33
|
* Tell Black to format code for Python 3.5 (#8664)Dan Callahan2020-10-271-1/+1
| | | | | | | | This allows trailing commas in multi-line arg lists. Minor, but we might as well keep our formatting current with regard to our minimum supported Python version. Signed-off-by: Dan Callahan <danc@element.io>
* Update test logging to be able to accept braces (#8335)Jonathan de Jong2020-09-181-2/+1
|
* Make `StreamToken.room_key` be a `RoomStreamToken` instance. (#8281)Erik Johnston2020-09-111-1/+4
|
* Allow for make_awaitable's return value to be re-used. (#8261)Patrick Cloke2020-09-081-3/+10
|
* Convert additional databases to async/await part 2 (#8200)Patrick Cloke2020-09-011-4/+3
|
* Convert state resolution to async/await (#7942)Patrick Cloke2020-07-241-1/+6
|
* Convert the message handler to async/await. (#7884)Patrick Cloke2020-07-221-20/+8
|
* isort 5 compatibility (#7786)Will Hunt2020-07-051-2/+0
| | | The CI appears to use the latest version of isort, which is a problem when isort gets a major version bump. Rather than try to pin the version, I've done the necessary to make isort5 happy with synapse.
* Fix bug in EventContext.deserialize. (#7393)Erik Johnston2020-05-051-6/+20
| | | | This caused `prev_state_ids` to be incorrect if the state event was not replacing an existing state entry.
* Fix limit logic for EventsStream (#7358)Richard van der Hoff2020-04-292-0/+116
| | | | | | | | | | | | | | | | | | | * 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.
* Move logging utilities out of the side drawer of util/ and into logging/ (#5606)Amber Brown2019-07-041-1/+1
|
* Run Black. (#5482)Amber Brown2019-06-201-1/+1
|
* Run Black on the tests again (#5170)Amber Brown2019-05-101-1/+3
|
* Enable configuring test log level via env var (#4506)Richard van der Hoff2019-01-292-0/+72
I got fed up with always adding '@unittest.DEBUG' every time I needed to debug a test.