diff options
author | Erik Johnston <erik@matrix.org> | 2016-03-10 14:03:48 +0000 |
---|---|---|
committer | Erik Johnston <erik@matrix.org> | 2016-03-10 14:03:48 +0000 |
commit | c22a3f37a91be8d02a299728684dcfa7c9b13f26 (patch) | |
tree | 33c15c4f8b2875106497d6c13d0da6fcc3278e51 | |
parent | Merge pull request #634 from matrix-org/erikj/pin_saml2_version (diff) | |
parent | Flake8 fix (diff) | |
download | synapse-c22a3f37a91be8d02a299728684dcfa7c9b13f26.tar.xz |
Merge pull request #637 from blide/develop
SYN-646 - Register endpoint returns refresh_token
Diffstat (limited to '')
-rw-r--r-- | synapse/rest/client/v2_alpha/register.py | 13 | ||||
-rw-r--r-- | tests/rest/client/v2_alpha/test_register.py | 18 |
2 files changed, 20 insertions, 11 deletions
diff --git a/synapse/rest/client/v2_alpha/register.py b/synapse/rest/client/v2_alpha/register.py index b090e66bcf..533ff136eb 100644 --- a/synapse/rest/client/v2_alpha/register.py +++ b/synapse/rest/client/v2_alpha/register.py @@ -187,7 +187,7 @@ class RegisterRestServlet(RestServlet): else: logger.info("bind_email not specified: not binding email") - result = self._create_registration_details(user_id, token) + result = yield self._create_registration_details(user_id, token) defer.returnValue((200, result)) def on_OPTIONS(self, _): @@ -198,7 +198,7 @@ class RegisterRestServlet(RestServlet): (user_id, token) = yield self.registration_handler.appservice_register( username, as_token ) - defer.returnValue(self._create_registration_details(user_id, token)) + defer.returnValue((yield self._create_registration_details(user_id, token))) @defer.inlineCallbacks def _do_shared_secret_registration(self, username, password, mac): @@ -225,14 +225,17 @@ class RegisterRestServlet(RestServlet): (user_id, token) = yield self.registration_handler.register( localpart=username, password=password ) - defer.returnValue(self._create_registration_details(user_id, token)) + defer.returnValue((yield self._create_registration_details(user_id, token))) + @defer.inlineCallbacks def _create_registration_details(self, user_id, token): - return { + refresh_token = yield self.auth_handler.issue_refresh_token(user_id) + defer.returnValue({ "user_id": user_id, "access_token": token, "home_server": self.hs.hostname, - } + "refresh_token": refresh_token, + }) @defer.inlineCallbacks def onEmailTokenRequest(self, request): diff --git a/tests/rest/client/v2_alpha/test_register.py b/tests/rest/client/v2_alpha/test_register.py index b867599079..9a202e9dd7 100644 --- a/tests/rest/client/v2_alpha/test_register.py +++ b/tests/rest/client/v2_alpha/test_register.py @@ -62,12 +62,15 @@ class RegisterRestServletTestCase(unittest.TestCase): self.registration_handler.appservice_register = Mock( return_value=(user_id, token) ) - result = yield self.servlet.on_POST(self.request) - self.assertEquals(result, (200, { + (code, result) = yield self.servlet.on_POST(self.request) + self.assertEquals(code, 200) + det_data = { "user_id": user_id, "access_token": token, "home_server": self.hs.hostname - })) + } + self.assertDictContainsSubset(det_data, result) + self.assertIn("refresh_token", result) @defer.inlineCallbacks def test_POST_appservice_registration_invalid(self): @@ -112,12 +115,15 @@ class RegisterRestServletTestCase(unittest.TestCase): }) self.registration_handler.register = Mock(return_value=(user_id, token)) - result = yield self.servlet.on_POST(self.request) - self.assertEquals(result, (200, { + (code, result) = yield self.servlet.on_POST(self.request) + self.assertEquals(code, 200) + det_data = { "user_id": user_id, "access_token": token, "home_server": self.hs.hostname - })) + } + self.assertDictContainsSubset(det_data, result) + self.assertIn("refresh_token", result) def test_POST_disabled_registration(self): self.hs.config.enable_registration = False |