1
0

test_well_known.py 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. # -*- coding: utf-8 -*-
  2. # Copyright 2018 New Vector
  3. #
  4. # Licensed under the Apache License, Version 2.0 (the "License");
  5. # you may not use this file except in compliance with the License.
  6. # You may obtain a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. # See the License for the specific language governing permissions and
  14. # limitations under the License.
  15. from synapse.rest.well_known import WellKnownResource
  16. from tests import unittest
  17. class WellKnownTests(unittest.HomeserverTestCase):
  18. def setUp(self):
  19. super(WellKnownTests, self).setUp()
  20. # replace the JsonResource with a WellKnownResource
  21. self.resource = WellKnownResource(self.hs)
  22. def test_well_known(self):
  23. self.hs.config.public_baseurl = "https://tesths"
  24. self.hs.config.default_identity_server = "https://testis"
  25. request, channel = self.make_request(
  26. "GET", "/.well-known/matrix/client", shorthand=False
  27. )
  28. self.render(request)
  29. self.assertEqual(request.code, 200)
  30. self.assertEqual(
  31. channel.json_body,
  32. {
  33. "m.homeserver": {"base_url": "https://tesths"},
  34. "m.identity_server": {"base_url": "https://testis"},
  35. },
  36. )
  37. def test_well_known_no_public_baseurl(self):
  38. self.hs.config.public_baseurl = None
  39. request, channel = self.make_request(
  40. "GET", "/.well-known/matrix/client", shorthand=False
  41. )
  42. self.render(request)
  43. self.assertEqual(request.code, 404)