diff options
author | Hugh Nimmo-Smith <hughns@matrix.org> | 2023-02-06 17:12:42 +0000 |
---|---|---|
committer | Patrick Cloke <clokep@users.noreply.github.com> | 2023-05-30 09:43:06 -0400 |
commit | 03920bdd4e9390d74762ecd923ddf0d6c75d222e (patch) | |
tree | a75e9e572692977e1f56815b61612346d0fbab9c /tests/rest | |
parent | Disable account related endpoints when using OAuth delegation (diff) | |
download | synapse-03920bdd4e9390d74762ecd923ddf0d6c75d222e.tar.xz |
Test MSC2965 implementation: well-known discovery document
Diffstat (limited to 'tests/rest')
-rw-r--r-- | tests/rest/test_well_known.py | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/tests/rest/test_well_known.py b/tests/rest/test_well_known.py index 2091b08d89..34333d88df 100644 --- a/tests/rest/test_well_known.py +++ b/tests/rest/test_well_known.py @@ -17,6 +17,13 @@ from synapse.rest.well_known import well_known_resource from tests import unittest +try: + import authlib # noqa: F401 + + HAS_AUTHLIB = True +except ImportError: + HAS_AUTHLIB = False + class WellKnownTests(unittest.HomeserverTestCase): def create_test_resource(self) -> Resource: @@ -96,3 +103,34 @@ class WellKnownTests(unittest.HomeserverTestCase): "GET", "/.well-known/matrix/server", shorthand=False ) self.assertEqual(channel.code, 404) + + @unittest.skip_unless(HAS_AUTHLIB, "requires authlib") + @unittest.override_config( + { + "public_baseurl": "https://homeserver", # this is only required so that client well known is served + "oauth_delegation": { + "enabled": True, + "issuer": "https://issuer", + "account": "https://my-account.issuer", + "client_id": "id", + "client_auth_method": "client_secret_post", + "client_secret": "secret", + }, + } + ) + def test_client_well_known_msc3861_oauth_delegation(self) -> None: + channel = self.make_request( + "GET", "/.well-known/matrix/client", shorthand=False + ) + + self.assertEqual(channel.code, 200) + self.assertEqual( + channel.json_body, + { + "m.homeserver": {"base_url": "https://homeserver/"}, + "org.matrix.msc2965.authentication": { + "issuer": "https://issuer", + "account": "https://my-account.issuer", + }, + }, + ) |