MatrixSynapse/tests/handlers
David Robertson f7b034a24b
Consistently exclude from user_directory (#10960)
* 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>
2021-10-04 11:45:51 +00:00
..
__init__.py
oidc_test_key.p8
oidc_test_key.pub.pem
test_admin.py
test_appservice.py
test_auth.py
test_cas.py
test_device.py
test_directory.py Use direct references for configuration variables (part 5). (#10897) 2021-09-24 07:25:21 -04:00
test_e2e_keys.py
test_e2e_room_keys.py
test_federation.py Factor out common code for persisting fetched auth events (#10896) 2021-09-24 11:56:33 +01:00
test_message.py
test_oidc.py
test_password_providers.py
test_presence.py
test_profile.py Use direct references for configuration variables (part 7). (#10959) 2021-10-04 07:18:54 -04:00
test_receipts.py
test_register.py Clean-up registration tests (#10945) 2021-09-30 14:06:02 -04:00
test_room.py
test_room_summary.py
test_saml.py
test_send_email.py
test_stats.py Use direct references for configuration variables (part 5). (#10897) 2021-09-24 07:25:21 -04:00
test_sync.py
test_typing.py
test_user_directory.py Consistently exclude from user_directory (#10960) 2021-10-04 11:45:51 +00:00