def test_oidc_backend_normalization(self, tmp_path, to_set, to_get): config = AuthConfig(path=tmp_path) with mock.patch.object(openeo.rest.auth.config, "utcnow_rfc3339", return_value="2020-06-08T11:18:27Z"): config.set_oidc_client_config(to_set, "default", client_id="client123", client_secret="$6cr67") for backend in [to_set, to_get]: assert config.get_oidc_client_configs(backend, "default") == ("client123", "$6cr67") assert config.get_oidc_provider_configs(backend) == { "default": { "date": "2020-06-08T11:18:27Z", "client_id": "client123", "client_secret": "$6cr67" } }
def test_oidc(self, tmp_path): config = AuthConfig(path=tmp_path) with mock.patch.object(openeo.rest.auth.config, "utcnow_rfc3339", return_value="2020-06-08T11:18:27Z"): config.set_oidc_client_config("oeo.test", "default", client_id="client123", client_secret="$6cr67") assert config.path.exists() assert [p.name for p in tmp_path.iterdir()] == [AuthConfig.DEFAULT_FILENAME] with config.path.open("r") as f: data = json.load(f) assert data["backends"] == { "oeo.test": { "oidc": { "providers": { "default": { "date": "2020-06-08T11:18:27Z", "client_id": "client123", "client_secret": "$6cr67" } } } } } assert config.get_oidc_client_configs("oeo.test", "default") == ("client123", "$6cr67") assert config.get_oidc_provider_configs("oeo.test") == { "default": { "date": "2020-06-08T11:18:27Z", "client_id": "client123", "client_secret": "$6cr67" } }