@@ -767,6 +767,59 @@ def test_create_connection_lazy_refresh_token_store(requests_mock):
767767 )
768768
769769
770+ def test_list_auth_providers (requests_mock , api_version ):
771+ requests_mock .get (
772+ API_URL ,
773+ json = {
774+ "api_version" : api_version ,
775+ "endpoints" : [
776+ {"methods" : ["GET" ], "path" : "/credentials/basic" },
777+ {"methods" : ["GET" ], "path" : "/credentials/oidc" },
778+ ],
779+ },
780+ )
781+ requests_mock .get (
782+ API_URL + "credentials/oidc" ,
783+ json = {
784+ "providers" : [
785+ {"id" : "p1" , "issuer" : "https://openeo.example" , "title" : "openEO" , "scopes" : ["openid" ]},
786+ {"id" : "p2" , "issuer" : "https://other.example" , "title" : "Other" , "scopes" : ["openid" ]},
787+ ]
788+ },
789+ )
790+
791+ conn = Connection (API_URL )
792+ providers = conn .list_auth_providers ()
793+ assert len (providers ) == 3
794+
795+ p1 = next (filter (lambda x : x ["id" ] == "p1" , providers ), None )
796+ assert isinstance (p1 , dict )
797+ assert p1 ["type" ] == "oidc"
798+ assert p1 ["issuer" ] == "https://openeo.example"
799+ assert p1 ["title" ] == "openEO"
800+
801+ p2 = next (filter (lambda x : x ["id" ] == "p2" , providers ), None )
802+ assert isinstance (p2 , dict )
803+ assert p2 ["type" ] == "oidc"
804+ assert p2 ["issuer" ] == "https://other.example"
805+ assert p2 ["title" ] == "Other"
806+
807+ basic = next (filter (lambda x : x ["type" ] == "basic" , providers ), None )
808+ assert isinstance (basic , dict )
809+ assert isinstance (basic ["id" ], str )
810+ assert len (basic ["id" ]) > 0
811+ assert basic ["issuer" ] == API_URL + "credentials/basic"
812+ assert basic ["title" ] == "Basic"
813+
814+
815+ def test_list_auth_providers_empty (requests_mock , api_version ):
816+ requests_mock .get (API_URL , json = {"api_version" : api_version , "endpoints" : []})
817+
818+ conn = Connection (API_URL )
819+ providers = conn .list_auth_providers ()
820+ assert len (providers ) == 0
821+
822+
770823def test_authenticate_basic_no_support (requests_mock , api_version ):
771824 requests_mock .get (API_URL , json = {"api_version" : api_version , "endpoints" : []})
772825
0 commit comments