Also expose unstable capability
This commit is contained in:
parent
cf3b20a2f1
commit
151b237768
|
@ -68,6 +68,9 @@ class CapabilitiesRestServlet(RestServlet):
|
|||
"m.get_login_token": {
|
||||
"enabled": self.config.auth.login_via_existing_enabled,
|
||||
},
|
||||
"org.matrix.msc3882.get_login_token": {
|
||||
"enabled": self.config.auth.login_via_existing_enabled,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -174,6 +174,7 @@ class LoginRestServlet(RestServlet):
|
|||
# If the login token flow is enabled advertise the get_login_token flag.
|
||||
if self._get_login_token_enabled:
|
||||
tokenTypeFlow["get_login_token"] = True
|
||||
tokenTypeFlow["org.matrix.msc3882.get_login_token"] = True
|
||||
flows.append(tokenTypeFlow)
|
||||
|
||||
flows.extend({"type": t} for t in self.auth_handler.get_supported_login_types())
|
||||
|
|
|
@ -200,6 +200,7 @@ class CapabilitiesTestCase(unittest.HomeserverTestCase):
|
|||
|
||||
self.assertEqual(channel.code, HTTPStatus.OK)
|
||||
self.assertFalse(capabilities["m.get_login_token"]["enabled"])
|
||||
self.assertFalse(capabilities["org.matrix.msc3882.get_login_token"]["enabled"])
|
||||
|
||||
@override_config({"login_via_existing_session": {"enabled": True}})
|
||||
def test_get_get_token_login_fields_when_enabled(self) -> None:
|
||||
|
@ -214,3 +215,4 @@ class CapabilitiesTestCase(unittest.HomeserverTestCase):
|
|||
|
||||
self.assertEqual(channel.code, HTTPStatus.OK)
|
||||
self.assertTrue(capabilities["m.get_login_token"]["enabled"])
|
||||
self.assertTrue(capabilities["org.matrix.msc3882.get_login_token"]["enabled"])
|
||||
|
|
|
@ -527,7 +527,11 @@ class LoginRestServletTestCase(unittest.HomeserverTestCase):
|
|||
self.assertCountEqual(
|
||||
channel.json_body["flows"],
|
||||
[
|
||||
{"type": "m.login.token", "get_login_token": True},
|
||||
{
|
||||
"type": "m.login.token",
|
||||
"get_login_token": True,
|
||||
"org.matrix.msc3882.get_login_token": True,
|
||||
},
|
||||
{"type": "m.login.password"},
|
||||
{"type": "m.login.application_service"},
|
||||
],
|
||||
|
|
|
@ -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, versions
|
||||
from synapse.rest.client import capabilities, login, login_token_request, versions
|
||||
from synapse.server import HomeServer
|
||||
from synapse.util import Clock
|
||||
|
||||
|
@ -31,6 +31,7 @@ class LoginTokenRequestServletTestCase(unittest.HomeserverTestCase):
|
|||
admin.register_servlets,
|
||||
login_token_request.register_servlets,
|
||||
versions.register_servlets, # TODO: remove once unstable revision 0 support is removed
|
||||
capabilities.register_servlets, # TODO: remove once unstable revision 1 support is removed
|
||||
]
|
||||
|
||||
def make_homeserver(self, reactor: MemoryReactor, clock: Clock) -> HomeServer:
|
||||
|
@ -179,18 +180,21 @@ class LoginTokenRequestServletTestCase(unittest.HomeserverTestCase):
|
|||
def test_unstable_revision1_support(self) -> None:
|
||||
# TODO: remove when unstable MSC3882 is no longer needed
|
||||
|
||||
self.register_user(self.user, self.password)
|
||||
token = self.login(self.user, self.password)
|
||||
|
||||
# check feature is advertised in versions response:
|
||||
channel = self.make_request(
|
||||
"GET", "/_matrix/client/versions", {}, access_token=None
|
||||
"GET", "/_matrix/client/v3/capabilities", {}, access_token=token
|
||||
)
|
||||
self.assertEqual(channel.code, 200)
|
||||
self.assertEqual(
|
||||
channel.json_body["unstable_features"]["org.matrix.msc3882"], True
|
||||
channel.json_body["capabilities"]["org.matrix.msc3882.get_login_token"][
|
||||
"enabled"
|
||||
],
|
||||
True,
|
||||
)
|
||||
|
||||
self.register_user(self.user, self.password)
|
||||
token = self.login(self.user, self.password)
|
||||
|
||||
# check feature is available via the r1 unstable endpoint and returns an expires_in_ms value in milliseconds
|
||||
channel = self.make_request(
|
||||
"POST",
|
||||
|
|
Loading…
Reference in New Issue