Test MSC2965 implementation: well-known discovery document

clokep/http-conn-pool
Hugh Nimmo-Smith 2023-02-06 17:12:42 +00:00 committed by Patrick Cloke
parent 31691d6151
commit 03920bdd4e
1 changed files with 38 additions and 0 deletions

View File

@ -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",
},
},
)