From 2ceaf44548d617085e73eec1c2c8414042e44a50 Mon Sep 17 00:00:00 2001 From: Fokko Driesprong Date: Thu, 20 Feb 2025 20:32:52 +0100 Subject: [PATCH] REST: Remove deprecated `AUTH_URL` (#1691) --- pyiceberg/catalog/rest.py | 12 ++---------- tests/catalog/test_rest.py | 8 ++++---- 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/pyiceberg/catalog/rest.py b/pyiceberg/catalog/rest.py index a57f17618e..01d7c23480 100644 --- a/pyiceberg/catalog/rest.py +++ b/pyiceberg/catalog/rest.py @@ -79,7 +79,7 @@ from pyiceberg.typedef import EMPTY_DICT, UTF8, IcebergBaseModel, Identifier, Properties from pyiceberg.types import transform_dict_value_to_str from pyiceberg.utils.deprecated import deprecation_message -from pyiceberg.utils.properties import get_first_property_value, get_header_properties, property_as_bool +from pyiceberg.utils.properties import get_header_properties, property_as_bool if TYPE_CHECKING: import pyarrow as pa @@ -137,7 +137,6 @@ class IdentifierKind(Enum): SIGV4 = "rest.sigv4-enabled" SIGV4_REGION = "rest.signing-region" SIGV4_SERVICE = "rest.signing-name" -AUTH_URL = "rest.authorization-url" OAUTH2_SERVER_URI = "oauth2-server-uri" NAMESPACE_SEPARATOR = b"\x1f".decode(UTF8) @@ -318,16 +317,9 @@ def url(self, endpoint: str, prefixed: bool = True, **kwargs: Any) -> str: @property def auth_url(self) -> str: - if self.properties.get(AUTH_URL): - deprecation_message( - deprecated_in="0.8.0", - removed_in="0.9.0", - help_message=f"The property {AUTH_URL} is deprecated. Please use {OAUTH2_SERVER_URI} instead", - ) - self._warn_oauth_tokens_deprecation() - if url := get_first_property_value(self.properties, AUTH_URL, OAUTH2_SERVER_URI): + if url := self.properties.get(OAUTH2_SERVER_URI): return url else: return self.url(Endpoints.get_token, prefixed=False) diff --git a/tests/catalog/test_rest.py b/tests/catalog/test_rest.py index b052f3b13b..4ad825f5b7 100644 --- a/tests/catalog/test_rest.py +++ b/tests/catalog/test_rest.py @@ -49,7 +49,7 @@ TEST_URI = "https://iceberg-test-catalog/" TEST_CREDENTIALS = "client:secret" -TEST_AUTH_URL = "https://auth-endpoint/" +TEST_OAUTH2_SERVER_URI = "https://auth-endpoint/" TEST_TOKEN = "some_jwt_token" TEST_SCOPE = "openid_offline_corpds_ds_profile" TEST_AUDIENCE = "test_audience" @@ -257,9 +257,9 @@ def test_token_with_custom_scope(rest_mock: Mocker) -> None: @pytest.mark.filterwarnings( "ignore:Deprecated in 0.8.0, will be removed in 1.0.0. Iceberg REST client is missing the OAuth2 server URI:DeprecationWarning" ) -def test_token_200_w_auth_url(rest_mock: Mocker) -> None: +def test_token_200_w_oauth2_server_uri(rest_mock: Mocker) -> None: rest_mock.post( - TEST_AUTH_URL, + TEST_OAUTH2_SERVER_URI, json={ "access_token": TEST_TOKEN, "token_type": "Bearer", @@ -271,7 +271,7 @@ def test_token_200_w_auth_url(rest_mock: Mocker) -> None: ) # pylint: disable=W0212 assert ( - RestCatalog("rest", uri=TEST_URI, credential=TEST_CREDENTIALS, **{OAUTH2_SERVER_URI: TEST_AUTH_URL})._session.headers[ + RestCatalog("rest", uri=TEST_URI, credential=TEST_CREDENTIALS, **{OAUTH2_SERVER_URI: OAUTH2_SERVER_URI})._session.headers[ "Authorization" ] == f"Bearer {TEST_TOKEN}"