1
0

Add tests for unstable support whilst still relied on

This commit is contained in:
Hugh Nimmo-Smith
2023-05-25 13:39:06 +01:00
parent 1d41bf1f78
commit 17f73cd702
+27 -1
View File
@@ -15,7 +15,7 @@
from twisted.test.proto_helpers import MemoryReactor
from synapse.rest import admin
from synapse.rest.client import login, login_token_request
from synapse.rest.client import login, login_token_request, versions
from synapse.server import HomeServer
from synapse.util import Clock
@@ -30,6 +30,7 @@ class LoginTokenRequestServletTestCase(unittest.HomeserverTestCase):
login.register_servlets,
admin.register_servlets,
login_token_request.register_servlets,
versions.register_servlets, # TODO: remove once unstable revision 0 support is removed
]
def make_homeserver(self, reactor: MemoryReactor, clock: Clock) -> HomeServer:
@@ -131,3 +132,28 @@ class LoginTokenRequestServletTestCase(unittest.HomeserverTestCase):
channel = self.make_request("POST", GET_TOKEN_ENDPOINT, {}, access_token=token)
self.assertEqual(channel.code, 200)
self.assertEqual(channel.json_body["expires_in_ms"], 15000)
@override_config(
{
"login_via_existing_session": {
"enabled": True,
"require_ui_auth": False,
"token_timeout": "15s",
}
}
)
def test_unstable_support(self) -> None:
# TODO: remove support for unstable MSC3882 is no longer needed
# check feature is advertised in versions response:
channel = self.make_request("GET", "/_matrix/client/versions", {}, access_token=None)
self.assertEqual(channel.code, 200)
self.assertEqual(channel.json_body["unstable_features"]["org.matrix.msc3882"], True)
self.register_user(self.user, self.password)
token = self.login(self.user, self.password)
# check feature is available via the unstable endpoint and returns an expires_in value in seconds
channel = self.make_request("POST", "/_matrix/client/unstable/org.matrix.msc3882/login/token", {}, access_token=token)
self.assertEqual(channel.code, 200)
self.assertEqual(channel.json_body["expires_in"], 15)