forked from MirrorHub/synapse
make version optional in body of e2e backup version update
to agree with latest version of the MSC
This commit is contained in:
parent
def5413480
commit
4535a07f4a
3 changed files with 34 additions and 19 deletions
|
@ -352,8 +352,8 @@ class E2eRoomKeysHandler(object):
|
||||||
A deferred of an empty dict.
|
A deferred of an empty dict.
|
||||||
"""
|
"""
|
||||||
if "version" not in version_info:
|
if "version" not in version_info:
|
||||||
raise SynapseError(400, "Missing version in body", Codes.MISSING_PARAM)
|
version_info["version"] = version
|
||||||
if version_info["version"] != version:
|
elif version_info["version"] != version:
|
||||||
raise SynapseError(
|
raise SynapseError(
|
||||||
400, "Version in body does not match", Codes.INVALID_PARAM
|
400, "Version in body does not match", Codes.INVALID_PARAM
|
||||||
)
|
)
|
||||||
|
|
|
@ -375,7 +375,7 @@ class RoomKeysVersionServlet(RestServlet):
|
||||||
"ed25519:something": "hijklmnop"
|
"ed25519:something": "hijklmnop"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"version": "42"
|
"version": "12345"
|
||||||
}
|
}
|
||||||
|
|
||||||
HTTP/1.1 200 OK
|
HTTP/1.1 200 OK
|
||||||
|
|
|
@ -187,9 +187,8 @@ class E2eRoomKeysHandlerTestCase(unittest.TestCase):
|
||||||
self.assertEqual(res, 404)
|
self.assertEqual(res, 404)
|
||||||
|
|
||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
def test_update_bad_version(self):
|
def test_update_missing_version(self):
|
||||||
"""Check that we get a 400 if the version in the body is missing or
|
"""Check that the update succeeds if the version is missing from the body
|
||||||
doesn't match
|
|
||||||
"""
|
"""
|
||||||
version = yield self.handler.create_version(
|
version = yield self.handler.create_version(
|
||||||
self.local_user,
|
self.local_user,
|
||||||
|
@ -197,8 +196,6 @@ class E2eRoomKeysHandlerTestCase(unittest.TestCase):
|
||||||
)
|
)
|
||||||
self.assertEqual(version, "1")
|
self.assertEqual(version, "1")
|
||||||
|
|
||||||
res = None
|
|
||||||
try:
|
|
||||||
yield self.handler.update_version(
|
yield self.handler.update_version(
|
||||||
self.local_user,
|
self.local_user,
|
||||||
version,
|
version,
|
||||||
|
@ -207,9 +204,27 @@ class E2eRoomKeysHandlerTestCase(unittest.TestCase):
|
||||||
"auth_data": "revised_first_version_auth_data",
|
"auth_data": "revised_first_version_auth_data",
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
except errors.SynapseError as e:
|
|
||||||
res = e.code
|
# check we can retrieve it as the current version
|
||||||
self.assertEqual(res, 400)
|
res = yield self.handler.get_version_info(self.local_user)
|
||||||
|
self.assertDictEqual(
|
||||||
|
res,
|
||||||
|
{
|
||||||
|
"algorithm": "m.megolm_backup.v1",
|
||||||
|
"auth_data": "revised_first_version_auth_data",
|
||||||
|
"version": version,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
@defer.inlineCallbacks
|
||||||
|
def test_update_bad_version(self):
|
||||||
|
"""Check that we get a 400 if the version in the body doesn't match
|
||||||
|
"""
|
||||||
|
version = yield self.handler.create_version(
|
||||||
|
self.local_user,
|
||||||
|
{"algorithm": "m.megolm_backup.v1", "auth_data": "first_version_auth_data"},
|
||||||
|
)
|
||||||
|
self.assertEqual(version, "1")
|
||||||
|
|
||||||
res = None
|
res = None
|
||||||
try:
|
try:
|
||||||
|
|
Loading…
Reference in a new issue