@@ -551,6 +551,39 @@ def test_capabilities_caching(requests_mock):
551
551
assert con .capabilities ().api_version () == "1.0.0"
552
552
assert m .call_count == 1
553
553
554
+ def test_capabilities_caching_after_authenticate_basic (requests_mock ):
555
+ user , pwd = "john262" , "J0hndo3"
556
+ requests_mock .get (API_URL , json = {"api_version" : "1.0.0" , "endpoints" : BASIC_ENDPOINTS })
557
+ requests_mock .get (API_URL + 'credentials/basic' , text = _credentials_basic_handler (user , pwd ))
558
+
559
+ with mock .patch ('openeo.rest.connection.AuthConfig' ) as AuthConfig :
560
+ conn = Connection (API_URL )
561
+ conn ._capabilities_cache ._cache = {"test" :"test1" }
562
+ assert conn ._capabilities_cache ._cache != {}
563
+ AuthConfig .return_value .get_basic_auth .return_value = (user , pwd )
564
+ conn .authenticate_basic (user , pwd )
565
+ assert conn ._capabilities_cache ._cache == {}
566
+
567
+
568
+ def test_capabilities_caching_after_authenticate_oidc (requests_mock ):
569
+ requests_mock .get (API_URL , json = {"api_version" : "1.0.0" })
570
+ client_id = "myclient"
571
+ requests_mock .get (API_URL + 'credentials/oidc' , json = {
572
+ "providers" : [{"id" : "fauth" , "issuer" : "https://fauth.test" , "title" : "Foo Auth" , "scopes" : ["openid" , "im" ]}]
573
+ })
574
+ oidc_mock = OidcMock (
575
+ requests_mock = requests_mock ,
576
+ expected_grant_type = "authorization_code" ,
577
+ expected_client_id = client_id ,
578
+ expected_fields = {"scope" : "im openid" },
579
+ oidc_issuer = "https://fauth.test" ,
580
+ scopes_supported = ["openid" , "im" ],
581
+ )
582
+ conn = Connection (API_URL )
583
+ conn ._capabilities_cache ._cache = {"test" : "test1" }
584
+ conn .authenticate_oidc_authorization_code (client_id = client_id , webbrowser_open = oidc_mock .webbrowser_open )
585
+ assert conn ._capabilities_cache ._cache == {}
586
+
554
587
555
588
def test_file_formats (requests_mock ):
556
589
requests_mock .get ("https://oeo.test/" , json = {"api_version" : "1.0.0" })
0 commit comments