Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

SYN-646 - Register endpoint returns refresh_token #637

Merged
merged 2 commits into from
Mar 10, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions synapse/rest/client/v2_alpha/register.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ def on_POST(self, request):
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, _):
Expand All @@ -198,7 +198,7 @@ def _do_appservice_registration(self, username, as_token):
(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):
Expand All @@ -225,14 +225,17 @@ def _do_shared_secret_registration(self, username, password, mac):
(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):
Expand Down
18 changes: 12 additions & 6 deletions tests/rest/client/v2_alpha/test_register.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,15 @@ def test_POST_appservice_registration_valid(self):
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):
Expand Down Expand Up @@ -112,12 +115,15 @@ def test_POST_user_valid(self):
})
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
Expand Down