Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.
 
 
 
 
 
 

60 рядки
2.1 KiB

  1. # Copyright 2023 The Matrix.org Foundation C.I.C.
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License at
  6. #
  7. # http://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software
  10. # distributed under the License is distributed on an "AS IS" BASIS,
  11. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. # See the License for the specific language governing permissions and
  13. # limitations under the License.
  14. from http import HTTPStatus
  15. from synapse.rest.client import auth_issuer
  16. from tests.unittest import HomeserverTestCase, override_config, skip_unless
  17. from tests.utils import HAS_AUTHLIB
  18. ISSUER = "https://account.example.com/"
  19. class AuthIssuerTestCase(HomeserverTestCase):
  20. servlets = [
  21. auth_issuer.register_servlets,
  22. ]
  23. def test_returns_404_when_msc3861_disabled(self) -> None:
  24. # Make an unauthenticated request for the discovery info.
  25. channel = self.make_request(
  26. "GET",
  27. "/_matrix/client/unstable/org.matrix.msc2965/auth_issuer",
  28. )
  29. self.assertEqual(channel.code, HTTPStatus.NOT_FOUND)
  30. @skip_unless(HAS_AUTHLIB, "requires authlib")
  31. @override_config(
  32. {
  33. "disable_registration": True,
  34. "experimental_features": {
  35. "msc3861": {
  36. "enabled": True,
  37. "issuer": ISSUER,
  38. "client_id": "David Lister",
  39. "client_auth_method": "client_secret_post",
  40. "client_secret": "Who shot Mister Burns?",
  41. }
  42. },
  43. }
  44. )
  45. def test_returns_issuer_when_oidc_enabled(self) -> None:
  46. # Make an unauthenticated request for the discovery info.
  47. channel = self.make_request(
  48. "GET",
  49. "/_matrix/client/unstable/org.matrix.msc2965/auth_issuer",
  50. )
  51. self.assertEqual(channel.code, HTTPStatus.OK)
  52. self.assertEqual(channel.json_body, {"issuer": ISSUER})