@@ -513,6 +513,39 @@ def test_capabilities_caching(requests_mock):
513513 assert con .capabilities ().api_version () == "1.0.0"
514514 assert m .call_count == 1
515515
516+ def test_capabilities_caching_after_authenticate_basic (requests_mock ):
517+ user , pwd = "john262" , "J0hndo3"
518+ requests_mock .get (API_URL , json = {"api_version" : "1.0.0" , "endpoints" : BASIC_ENDPOINTS })
519+ requests_mock .get (API_URL + 'credentials/basic' , text = _credentials_basic_handler (user , pwd ))
520+
521+ with mock .patch ('openeo.rest.connection.AuthConfig' ) as AuthConfig :
522+ conn = Connection (API_URL )
523+ conn ._capabilities_cache ._cache = {"test" :"test1" }
524+ assert conn ._capabilities_cache ._cache != {}
525+ AuthConfig .return_value .get_basic_auth .return_value = (user , pwd )
526+ conn .authenticate_basic (user , pwd )
527+ assert conn ._capabilities_cache ._cache == {}
528+
529+
530+ def test_capabilities_caching_after_authenticate_oidc (requests_mock ):
531+ requests_mock .get (API_URL , json = {"api_version" : "1.0.0" })
532+ client_id = "myclient"
533+ requests_mock .get (API_URL + 'credentials/oidc' , json = {
534+ "providers" : [{"id" : "fauth" , "issuer" : "https://fauth.test" , "title" : "Foo Auth" , "scopes" : ["openid" , "im" ]}]
535+ })
536+ oidc_mock = OidcMock (
537+ requests_mock = requests_mock ,
538+ expected_grant_type = "authorization_code" ,
539+ expected_client_id = client_id ,
540+ expected_fields = {"scope" : "im openid" },
541+ oidc_issuer = "https://fauth.test" ,
542+ scopes_supported = ["openid" , "im" ],
543+ )
544+ conn = Connection (API_URL )
545+ conn ._capabilities_cache ._cache = {"test" : "test1" }
546+ conn .authenticate_oidc_authorization_code (client_id = client_id , webbrowser_open = oidc_mock .webbrowser_open )
547+ assert conn ._capabilities_cache ._cache == {}
548+
516549
517550def test_file_formats (requests_mock ):
518551 requests_mock .get ("https://oeo.test/" , json = {"api_version" : "1.0.0" })
0 commit comments