@@ -437,14 +437,16 @@ def test_get_login_flows(self):
437437 channel = self .make_request ("GET" , "/_matrix/client/r0/login" )
438438 self .assertEqual (channel .code , 200 , channel .result )
439439
440- expected_flows = [
441- { "type" : " m.login.cas"} ,
442- { "type" : " m.login.sso"} ,
443- { "type" : " m.login.token"} ,
444- { "type" : " m.login.password"} ,
445- ] + ADDITIONAL_LOGIN_FLOWS
440+ expected_flow_types = [
441+ " m.login.cas" ,
442+ " m.login.sso" ,
443+ " m.login.token" ,
444+ " m.login.password" ,
445+ ] + [ f [ "type" ] for f in ADDITIONAL_LOGIN_FLOWS ]
446446
447- self .assertCountEqual (channel .json_body ["flows" ], expected_flows )
447+ self .assertCountEqual (
448+ [f ["type" ] for f in channel .json_body ["flows" ]], expected_flow_types
449+ )
448450
449451 @override_config ({"experimental_features" : {"msc2858_enabled" : True }})
450452 def test_get_msc2858_login_flows (self ):
@@ -636,22 +638,25 @@ def test_multi_sso_redirect_to_unknown(self):
636638 )
637639 self .assertEqual (channel .code , 400 , channel .result )
638640
639- def test_client_idp_redirect_msc2858_disabled (self ):
640- """If the client tries to pick an IdP but MSC2858 is disabled, return a 400"""
641- channel = self ._make_sso_redirect_request (True , "oidc" )
642- self .assertEqual (channel .code , 400 , channel .result )
643- self .assertEqual (channel .json_body ["errcode" ], "M_UNRECOGNIZED" )
644-
645- @override_config ({"experimental_features" : {"msc2858_enabled" : True }})
646641 def test_client_idp_redirect_to_unknown (self ):
647642 """If the client tries to pick an unknown IdP, return a 404"""
648- channel = self ._make_sso_redirect_request (True , "xxx" )
643+ channel = self ._make_sso_redirect_request (False , "xxx" )
649644 self .assertEqual (channel .code , 404 , channel .result )
650645 self .assertEqual (channel .json_body ["errcode" ], "M_NOT_FOUND" )
651646
652- @override_config ({"experimental_features" : {"msc2858_enabled" : True }})
653647 def test_client_idp_redirect_to_oidc (self ):
654648 """If the client pick a known IdP, redirect to it"""
649+ channel = self ._make_sso_redirect_request (False , "oidc" )
650+ self .assertEqual (channel .code , 302 , channel .result )
651+ oidc_uri = channel .headers .getRawHeaders ("Location" )[0 ]
652+ oidc_uri_path , oidc_uri_query = oidc_uri .split ("?" , 1 )
653+
654+ # it should redirect us to the auth page of the OIDC server
655+ self .assertEqual (oidc_uri_path , TEST_OIDC_AUTH_ENDPOINT )
656+
657+ @override_config ({"experimental_features" : {"msc2858_enabled" : True }})
658+ def test_client_msc2858_redirect_to_oidc (self ):
659+ """Test the unstable API"""
655660 channel = self ._make_sso_redirect_request (True , "oidc" )
656661 self .assertEqual (channel .code , 302 , channel .result )
657662 oidc_uri = channel .headers .getRawHeaders ("Location" )[0 ]
@@ -660,6 +665,12 @@ def test_client_idp_redirect_to_oidc(self):
660665 # it should redirect us to the auth page of the OIDC server
661666 self .assertEqual (oidc_uri_path , TEST_OIDC_AUTH_ENDPOINT )
662667
668+ def test_client_idp_redirect_msc2858_disabled (self ):
669+ """If the client tries to use the MSC2858 endpoint but MSC2858 is disabled, return a 400"""
670+ channel = self ._make_sso_redirect_request (True , "oidc" )
671+ self .assertEqual (channel .code , 400 , channel .result )
672+ self .assertEqual (channel .json_body ["errcode" ], "M_UNRECOGNIZED" )
673+
663674 def _make_sso_redirect_request (
664675 self , unstable_endpoint : bool = False , idp_prov : Optional [str ] = None
665676 ):
0 commit comments