summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
authorNeil Johnson <neil@matrix.org>2019-01-29 15:58:37 +0000
committerNeil Johnson <neil@matrix.org>2019-01-29 15:58:37 +0000
commitf03b3a7a3a33df190ec9473ffc5bc4be04c58ae8 (patch)
tree5b01f26f8224771e186ca2cb4ffa37e86e7a8d81 /tests
parentisort (diff)
downloadsynapse-f03b3a7a3a33df190ec9473ffc5bc4be04c58ae8.tar.xz
support change_password in capabilities end-point
Diffstat (limited to 'tests')
-rw-r--r--tests/rest/client/v2_alpha/test_capabilities.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/rest/client/v2_alpha/test_capabilities.py b/tests/rest/client/v2_alpha/test_capabilities.py
index 131a4af417..62dbfa06b2 100644
--- a/tests/rest/client/v2_alpha/test_capabilities.py
+++ b/tests/rest/client/v2_alpha/test_capabilities.py
@@ -31,6 +31,7 @@ class CapabilitiesTestCase(unittest.HomeserverTestCase):
     def make_homeserver(self, reactor, clock):
         self.url = b"/_matrix/client/r0/capabilities"
         hs = self.setup_test_homeserver()
+        self.store = hs.get_datastore()
         return hs
 
     def test_check_auth_required(self):
@@ -53,3 +54,25 @@ class CapabilitiesTestCase(unittest.HomeserverTestCase):
         self.assertEqual(
             DEFAULT_ROOM_VERSION, capabilities['m.room_versions']['default']
         )
+
+    def test_get_change_password_capabilities(self):
+        localpart = "user"
+        password = "pass"
+        user = self.register_user(localpart, password)
+        access_token = self.login(user, password)
+
+        request, channel = self.make_request("GET", self.url, access_token=access_token)
+        self.render(request)
+        capabilities = channel.json_body['capabilities']
+
+        self.assertEqual(channel.code, 200)
+
+        # Test case where password is handled outside of Synapse
+        self.assertTrue(capabilities['m.change_password'])
+        self.get_success(self.store.user_set_password_hash(user, None))
+        request, channel = self.make_request("GET", self.url, access_token=access_token)
+        self.render(request)
+        capabilities = channel.json_body['capabilities']
+
+        self.assertEqual(channel.code, 200)
+        self.assertFalse(capabilities['m.change_password'])