1
0

minor fixes

This commit is contained in:
Hubert Chathi
2020-08-04 16:10:49 -04:00
parent 0f9e402e16
commit b59bc664e6
4 changed files with 17 additions and 20 deletions

View File

@@ -562,7 +562,7 @@ class DeviceHandler(DeviceWorkerHandler):
async def cancel_rehydrate(self, token: str) -> dict:
# FIXME: if can't find token, return 404
token_info = await self.store.clear_dehydration_token(token)
token_info = await self.store.clear_dehydration_token(token, False)
# create device and access token from original login submission
login_submission = token_info.get("login_submission")
device_id = login_submission.get("device_id")

View File

@@ -424,7 +424,7 @@ class LoginRestServlet(RestServlet):
class RestoreDeviceServlet(RestServlet):
PATTERNS = client_patterns("/org.matrix.msc26997/restore_device")
PATTERNS = client_patterns("/org.matrix.msc2697/restore_device")
def __init__(self, hs):
super(RestoreDeviceServlet, self).__init__()

View File

@@ -729,6 +729,7 @@ class DeviceWorkerStore(SQLBaseStore):
)
async def get_dehydrated_device(self, user_id: str) -> Tuple[str, str]:
# FIXME: make sure device ID still exists in devices table
row = await self.db.simple_select_one(
table="dehydrated_devices",
keyvalues={"user_id": user_id},
@@ -761,7 +762,7 @@ class DeviceWorkerStore(SQLBaseStore):
self.db.simple_update_txn(
txn,
table="dehydrated_devices",
keyvalues={"user_id", user_id},
keyvalues={"user_id": user_id},
updatevalues={"device_id": device_id, "device_data": device_data,},
)
return old_device_id

View File

@@ -779,13 +779,12 @@ class DehydrationTestCase(unittest.HomeserverTestCase):
access_token = self.login("kermit", "monkey")
# dehydrate a device
params = json.dumps({
"device_data": "foobar"
})
params = json.dumps({"device_data": "foobar"})
request, channel = self.make_request(
b"POST", b"/_matrix/client/unstable/org.matrix.msc2697/device/dehydrate",
b"POST",
b"/_matrix/client/unstable/org.matrix.msc2697/device/dehydrate",
params,
access_token=access_token
access_token=access_token,
)
self.render(request)
self.assertEquals(channel.code, 200, channel.result)
@@ -798,25 +797,22 @@ class DehydrationTestCase(unittest.HomeserverTestCase):
self.render(request)
# log in, requesting a dehydrated device
params = json.dumps({
"type": "m.login.password",
"user": "kermit",
"password": "monkey",
"org.matrix.msc2697.restore_device": True,
})
request, channel = self.make_request(
"POST", "/_matrix/client/r0/login", params
params = json.dumps(
{
"type": "m.login.password",
"user": "kermit",
"password": "monkey",
"org.matrix.msc2697.restore_device": True,
}
)
request, channel = self.make_request("POST", "/_matrix/client/r0/login", params)
self.render(request)
self.assertEqual(channel.code, 200, channel.result)
self.assertEqual(channel.json_body["device_data"], "foobar")
self.assertEqual(channel.json_body["device_id"], dehydrated_device_id)
dehydration_token = channel.json_body["dehydration_token"]
params = json.dumps({
"rehydrate": True,
"dehydration_token": dehydration_token
})
params = json.dumps({"rehydrate": True, "dehydration_token": dehydration_token})
request, channel = self.make_request(
"POST", "/_matrix/client/unstable/org.matrix.msc2697/restore_device", params
)