diff options
author | Erik Johnston <erikj@jki.re> | 2019-03-05 16:31:00 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-03-05 16:31:00 +0000 |
commit | 16c8b4ecbd99c4be6419bf65212acc613a179950 (patch) | |
tree | 40d5d962898b33a964b6d3f4e834d8ad98a8d05e /tests/rest/client | |
parent | Add rate-limiting on registration (#4735) (diff) | |
parent | add API documentation (diff) | |
download | synapse-16c8b4ecbd99c4be6419bf65212acc613a179950.tar.xz |
Merge pull request #4772 from jbweston/jbweston/server-version-api
Add 'server_version' endpoint to admin API
Diffstat (limited to 'tests/rest/client')
-rw-r--r-- | tests/rest/client/v1/test_admin.py | 38 |
1 files changed, 36 insertions, 2 deletions
diff --git a/tests/rest/client/v1/test_admin.py b/tests/rest/client/v1/test_admin.py index 407bf0ac4c..ea03b7e523 100644 --- a/tests/rest/client/v1/test_admin.py +++ b/tests/rest/client/v1/test_admin.py @@ -20,14 +20,48 @@ import json from mock import Mock from synapse.api.constants import UserTypes -from synapse.rest.client.v1.admin import register_servlets +from synapse.rest.client.v1 import admin, login from tests import unittest +class VersionTestCase(unittest.HomeserverTestCase): + + servlets = [ + admin.register_servlets, + login.register_servlets, + ] + + url = '/_matrix/client/r0/admin/server_version' + + def test_version_string(self): + self.register_user("admin", "pass", admin=True) + self.admin_token = self.login("admin", "pass") + + request, channel = self.make_request("GET", self.url, + access_token=self.admin_token) + self.render(request) + + self.assertEqual(200, int(channel.result["code"]), + msg=channel.result["body"]) + self.assertEqual({'server_version', 'python_version'}, + set(channel.json_body.keys())) + + def test_inaccessible_to_non_admins(self): + self.register_user("unprivileged-user", "pass", admin=False) + user_token = self.login("unprivileged-user", "pass") + + request, channel = self.make_request("GET", self.url, + access_token=user_token) + self.render(request) + + self.assertEqual(403, int(channel.result['code']), + msg=channel.result['body']) + + class UserRegisterTestCase(unittest.HomeserverTestCase): - servlets = [register_servlets] + servlets = [admin.register_servlets] def make_homeserver(self, reactor, clock): |