Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .github/auto-approve.yml

This file was deleted.

6 changes: 0 additions & 6 deletions .librarian/config.yaml

This file was deleted.

2 changes: 1 addition & 1 deletion .librarian/state.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
image: us-central1-docker.pkg.dev/cloud-sdk-librarian-prod/images-prod/python-librarian-generator:latest
image: us-central1-docker.pkg.dev/cloud-sdk-librarian-prod/images-prod/python-librarian-generator@sha256:c8612d3fffb3f6a32353b2d1abd16b61e87811866f7ec9d65b59b02eb452a620
libraries:
- id: google-api-core
version: 2.28.1
Expand Down
40 changes: 0 additions & 40 deletions owlbot.py

This file was deleted.

2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ ignore_missing_imports = true
filterwarnings = [
# treat all warnings as errors
"error",
# Prevent Python version warnings from interfering with tests
"ignore:.* Python version .*:FutureWarning",
# Remove once https://github.com/pytest-dev/pytest-cov/issues/621 is fixed
"ignore:.*The --rsyncdir command line argument and rsyncdirs config variable are deprecated:DeprecationWarning",
# Remove once https://github.com/protocolbuffers/protobuf/issues/12186 is fixed
Expand Down
44 changes: 30 additions & 14 deletions tests/asyncio/test_grpc_helpers_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -522,11 +522,15 @@ def test_create_channel_explicit_with_duplicate_credentials():
target = "example:443"

with pytest.raises(exceptions.DuplicateCredentialArgs) as excinfo:
grpc_helpers_async.create_channel(
target,
credentials_file="credentials.json",
credentials=mock.sentinel.credentials,
)
with pytest.warns(
DeprecationWarning,
match="argument is deprecated because of a potential security risk",
):
Copy link
Contributor

@daniel-sanche daniel-sanche Nov 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think we could extract these lines, so it doesn't need to be copy/pasted in some many places?

I'm imagining something like:

assert_deprecation_warning = functools.partial(
    pytest.warns, 
    DeprecationWarning, 
    match="argument is deprecated because of a potential security risk"
)


with assert_deprecation_warning():
   ...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great idea! Done.

grpc_helpers_async.create_channel(
target,
credentials_file="credentials.json",
credentials=mock.sentinel.credentials,
)

assert "mutually exclusive" in str(excinfo.value)

Expand Down Expand Up @@ -641,9 +645,13 @@ def test_create_channel_with_credentials_file(
credentials_file = "/path/to/credentials/file.json"
composite_creds = composite_creds_call.return_value

channel = grpc_helpers_async.create_channel(
target, credentials_file=credentials_file
)
with pytest.warns(
DeprecationWarning,
match="argument is deprecated because of a potential security risk",
):
channel = grpc_helpers_async.create_channel(
target, credentials_file=credentials_file
)

google.auth.load_credentials_from_file.assert_called_once_with(
credentials_file, scopes=None, default_scopes=None
Expand All @@ -670,9 +678,13 @@ def test_create_channel_with_credentials_file_and_scopes(
credentials_file = "/path/to/credentials/file.json"
composite_creds = composite_creds_call.return_value

channel = grpc_helpers_async.create_channel(
target, credentials_file=credentials_file, scopes=scopes
)
with pytest.warns(
DeprecationWarning,
match="argument is deprecated because of a potential security risk",
):
channel = grpc_helpers_async.create_channel(
target, credentials_file=credentials_file, scopes=scopes
)

google.auth.load_credentials_from_file.assert_called_once_with(
credentials_file, scopes=scopes, default_scopes=None
Expand All @@ -699,9 +711,13 @@ def test_create_channel_with_credentials_file_and_default_scopes(
credentials_file = "/path/to/credentials/file.json"
composite_creds = composite_creds_call.return_value

channel = grpc_helpers_async.create_channel(
target, credentials_file=credentials_file, default_scopes=default_scopes
)
with pytest.warns(
DeprecationWarning,
match="argument is deprecated because of a potential security risk",
):
channel = grpc_helpers_async.create_channel(
target, credentials_file=credentials_file, default_scopes=default_scopes
)

google.auth.load_credentials_from_file.assert_called_once_with(
credentials_file, scopes=None, default_scopes=default_scopes
Expand Down
62 changes: 47 additions & 15 deletions tests/unit/operations_v1/test_operations_rest_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,11 @@ def test_operations_client_client_options(
)

# Check the case credentials_file is provided
options = client_options.ClientOptions(credentials_file="credentials.json")
with pytest.warns(
DeprecationWarning,
match="argument is deprecated because of a potential security risk",
):
options = client_options.ClientOptions(credentials_file="credentials.json")
with mock.patch.object(transport_class, "__init__") as patched:
patched.return_value = None
client = client_class(client_options=options, transport=transport_name)
Expand Down Expand Up @@ -539,11 +543,20 @@ def test_operations_client_client_options_credentials_file(
client_class, transport_class, transport_name
):
# Check the case credentials file is provided.
options = client_options.ClientOptions(credentials_file="credentials.json")
with pytest.warns(
DeprecationWarning,
match="argument is deprecated because of a potential security risk",
):
options = client_options.ClientOptions(credentials_file="credentials.json")
if "async" in str(client_class):
# TODO(): Add support for credentials file to async REST transport.
with pytest.raises(core_exceptions.AsyncRestUnsupportedParameterError):
client_class(client_options=options, transport=transport_name)
with pytest.warns(
DeprecationWarning,
match="argument is deprecated because of a potential security risk",
):

client_class(client_options=options, transport=transport_name)
else:
with mock.patch.object(transport_class, "__init__") as patched:
patched.return_value = None
Expand All @@ -570,10 +583,21 @@ def test_operations_client_client_options_credentials_file(
return_value=(mock.sentinel.credentials, mock.sentinel.project),
)
def test_list_operations_rest(google_auth_default, credentials_file):
sync_transport = transports.rest.OperationsRestTransport(
credentials_file=credentials_file,
http_options=HTTP_OPTIONS,
)
if credentials_file:
with pytest.warns(
DeprecationWarning,
match="argument is deprecated because of a potential security risk",
):
sync_transport = transports.rest.OperationsRestTransport(
credentials_file=credentials_file,
http_options=HTTP_OPTIONS,
)
else:
# no warning expected
sync_transport = transports.rest.OperationsRestTransport(
credentials_file=credentials_file,
http_options=HTTP_OPTIONS,
)

client = AbstractOperationsClient(transport=sync_transport)

Expand Down Expand Up @@ -1130,10 +1154,14 @@ def test_transport_adc(client_class, transport_class, credentials):
def test_operations_base_transport_error():
# Passing both a credentials object and credentials_file should raise an error
with pytest.raises(core_exceptions.DuplicateCredentialArgs):
transports.OperationsTransport(
credentials=ga_credentials.AnonymousCredentials(),
credentials_file="credentials.json",
)
with pytest.warns(
DeprecationWarning,
match="argument is deprecated because of a potential security risk",
):
transports.OperationsTransport(
credentials=ga_credentials.AnonymousCredentials(),
credentials_file="credentials.json",
)


def test_operations_base_transport():
Expand Down Expand Up @@ -1171,10 +1199,14 @@ def test_operations_base_transport_with_credentials_file():
) as Transport:
Transport.return_value = None
load_creds.return_value = (ga_credentials.AnonymousCredentials(), None)
transports.OperationsTransport(
credentials_file="credentials.json",
quota_project_id="octopus",
)
with pytest.warns(
DeprecationWarning,
match="argument is deprecated because of a potential security risk",
):
transports.OperationsTransport(
credentials_file="credentials.json",
quota_project_id="octopus",
)
load_creds.assert_called_once_with(
"credentials.json",
scopes=None,
Expand Down
40 changes: 24 additions & 16 deletions tests/unit/test_client_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,22 @@ def get_client_encrypted_cert():

def test_constructor():

options = client_options.ClientOptions(
api_endpoint="foo.googleapis.com",
client_cert_source=get_client_cert,
quota_project_id="quote-proj",
credentials_file="path/to/credentials.json",
scopes=[
"https://www.googleapis.com/auth/cloud-platform",
"https://www.googleapis.com/auth/cloud-platform.read-only",
],
api_audience="foo2.googleapis.com",
universe_domain="googleapis.com",
)
with pytest.warns(
DeprecationWarning,
match="argument is deprecated because of a potential security risk",
):
options = client_options.ClientOptions(
api_endpoint="foo.googleapis.com",
client_cert_source=get_client_cert,
quota_project_id="quote-proj",
credentials_file="path/to/credentials.json",
scopes=[
"https://www.googleapis.com/auth/cloud-platform",
"https://www.googleapis.com/auth/cloud-platform.read-only",
],
api_audience="foo2.googleapis.com",
universe_domain="googleapis.com",
)

assert options.api_endpoint == "foo.googleapis.com"
assert options.client_cert_source() == (b"cert", b"key")
Expand Down Expand Up @@ -102,10 +106,14 @@ def test_constructor_with_api_key():

def test_constructor_with_both_api_key_and_credentials_file():
with pytest.raises(ValueError):
client_options.ClientOptions(
api_key="api-key",
credentials_file="path/to/credentials.json",
)
with pytest.warns(
DeprecationWarning,
match="argument is deprecated because of a potential security risk",
):
client_options.ClientOptions(
api_key="api-key",
credentials_file="path/to/credentials.json",
)


def test_from_dict():
Expand Down
40 changes: 28 additions & 12 deletions tests/unit/test_grpc_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -581,11 +581,15 @@ def test_create_channel_explicit_with_duplicate_credentials():
target = "example.com:443"

with pytest.raises(exceptions.DuplicateCredentialArgs):
grpc_helpers.create_channel(
target,
credentials_file="credentials.json",
credentials=mock.sentinel.credentials,
)
with pytest.warns(
DeprecationWarning,
match="argument is deprecated because of a potential security risk",
):
grpc_helpers.create_channel(
target,
credentials_file="credentials.json",
credentials=mock.sentinel.credentials,
)


@mock.patch("grpc.compute_engine_channel_credentials")
Expand Down Expand Up @@ -710,7 +714,11 @@ def test_create_channel_with_credentials_file(
credentials_file = "/path/to/credentials/file.json"
composite_creds = composite_creds_call.return_value

channel = grpc_helpers.create_channel(target, credentials_file=credentials_file)
with pytest.warns(
DeprecationWarning,
match="argument is deprecated because of a potential security risk",
):
channel = grpc_helpers.create_channel(target, credentials_file=credentials_file)

google.auth.load_credentials_from_file.assert_called_once_with(
credentials_file, scopes=None, default_scopes=None
Expand Down Expand Up @@ -742,9 +750,13 @@ def test_create_channel_with_credentials_file_and_scopes(
credentials_file = "/path/to/credentials/file.json"
composite_creds = composite_creds_call.return_value

channel = grpc_helpers.create_channel(
target, credentials_file=credentials_file, scopes=scopes
)
with pytest.warns(
DeprecationWarning,
match="argument is deprecated because of a potential security risk",
):
channel = grpc_helpers.create_channel(
target, credentials_file=credentials_file, scopes=scopes
)

google.auth.load_credentials_from_file.assert_called_once_with(
credentials_file, scopes=scopes, default_scopes=None
Expand Down Expand Up @@ -776,9 +788,13 @@ def test_create_channel_with_credentials_file_and_default_scopes(
credentials_file = "/path/to/credentials/file.json"
composite_creds = composite_creds_call.return_value

channel = grpc_helpers.create_channel(
target, credentials_file=credentials_file, default_scopes=default_scopes
)
with pytest.warns(
DeprecationWarning,
match="argument is deprecated because of a potential security risk",
):
channel = grpc_helpers.create_channel(
target, credentials_file=credentials_file, default_scopes=default_scopes
)

load_credentials_from_file.assert_called_once_with(
credentials_file, scopes=None, default_scopes=default_scopes
Expand Down
20 changes: 12 additions & 8 deletions tests/unit/test_python_version_support.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,17 +178,20 @@ def test_override_gapic_end_only():
"google.api_core._python_version_support.PYTHON_VERSION_INFO",
{version_tuple: overridden_info},
):
result_before_boundary = check_python_version(
today=custom_gapic_end + datetime.timedelta(days=-1)
)
with pytest.warns(FutureWarning, match="past its end of life"):
result_before_boundary = check_python_version(
today=custom_gapic_end + datetime.timedelta(days=-1)
)
assert result_before_boundary == PythonVersionStatus.PYTHON_VERSION_EOL

result_at_boundary = check_python_version(today=custom_gapic_end)
with pytest.warns(FutureWarning, match="past its end of life"):
result_at_boundary = check_python_version(today=custom_gapic_end)
assert result_at_boundary == PythonVersionStatus.PYTHON_VERSION_EOL

result_after_boundary = check_python_version(
today=custom_gapic_end + datetime.timedelta(days=1)
)
with pytest.warns(FutureWarning, match="non-supported Python version"):
result_after_boundary = check_python_version(
today=custom_gapic_end + datetime.timedelta(days=1)
)
assert (
result_after_boundary == PythonVersionStatus.PYTHON_VERSION_UNSUPPORTED
)
Expand Down Expand Up @@ -217,7 +220,8 @@ def test_override_gapic_deprecation_only():
result_before_boundary == PythonVersionStatus.PYTHON_VERSION_SUPPORTED
)

result_at_boundary = check_python_version(today=custom_gapic_dep)
with pytest.warns(FutureWarning, match="Google will stop supporting"):
result_at_boundary = check_python_version(today=custom_gapic_dep)
assert result_at_boundary == PythonVersionStatus.PYTHON_VERSION_DEPRECATED


Expand Down