diff --git a/.github/.OwlBot.lock.yaml b/.github/.OwlBot.lock.yaml index 7d98291..108063d 100644 --- a/.github/.OwlBot.lock.yaml +++ b/.github/.OwlBot.lock.yaml @@ -1,3 +1,3 @@ docker: image: gcr.io/cloud-devrel-public-resources/owlbot-python:latest - digest: sha256:58f73ba196b5414782605236dd0712a73541b44ff2ff4d3a36ec41092dd6fa5b + digest: sha256:4ee57a76a176ede9087c14330c625a71553cf9c72828b2c0ca12f5338171ba60 diff --git a/.kokoro/docs/common.cfg b/.kokoro/docs/common.cfg index b16da79..6a1c19d 100644 --- a/.kokoro/docs/common.cfg +++ b/.kokoro/docs/common.cfg @@ -30,6 +30,7 @@ env_vars: { env_vars: { key: "V2_STAGING_BUCKET" + # Push google cloud library docs to the Cloud RAD bucket `docs-staging-v2` value: "docs-staging-v2" } diff --git a/CHANGELOG.md b/CHANGELOG.md index be1676a..0d27edd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,18 @@ # Changelog +### [1.0.1](https://www.github.com/googleapis/python-binary-authorization/compare/v1.0.0...v1.0.1) (2021-11-01) + + +### Bug Fixes + +* **deps:** drop packaging dependency ([d02c2fd](https://www.github.com/googleapis/python-binary-authorization/commit/d02c2fdbc52d4dc5f8ca333e99d7e7160dcd23e8)) +* **deps:** require google-api-core >= 1.28.0 ([d02c2fd](https://www.github.com/googleapis/python-binary-authorization/commit/d02c2fdbc52d4dc5f8ca333e99d7e7160dcd23e8)) + + +### Documentation + +* list oneofs in docstring ([d02c2fd](https://www.github.com/googleapis/python-binary-authorization/commit/d02c2fdbc52d4dc5f8ca333e99d7e7160dcd23e8)) + ## [1.0.0](https://www.github.com/googleapis/python-binary-authorization/compare/v0.6.0...v1.0.0) (2021-10-22) diff --git a/google/cloud/binaryauthorization_v1/services/binauthz_management_service_v1/async_client.py b/google/cloud/binaryauthorization_v1/services/binauthz_management_service_v1/async_client.py index 7b993e4..bd64cc3 100644 --- a/google/cloud/binaryauthorization_v1/services/binauthz_management_service_v1/async_client.py +++ b/google/cloud/binaryauthorization_v1/services/binauthz_management_service_v1/async_client.py @@ -19,13 +19,15 @@ from typing import Dict, Sequence, Tuple, Type, Union import pkg_resources -import google.api_core.client_options as ClientOptions # type: ignore +from google.api_core.client_options import ClientOptions # type: ignore from google.api_core import exceptions as core_exceptions # type: ignore from google.api_core import gapic_v1 # type: ignore from google.api_core import retry as retries # type: ignore from google.auth import credentials as ga_credentials # type: ignore from google.oauth2 import service_account # type: ignore +OptionalRetry = Union[retries.Retry, object] + from google.cloud.binaryauthorization_v1.services.binauthz_management_service_v1 import ( pagers, ) @@ -187,10 +189,10 @@ def __init__( async def get_policy( self, - request: service.GetPolicyRequest = None, + request: Union[service.GetPolicyRequest, dict] = None, *, name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> resources.Policy: @@ -207,7 +209,7 @@ async def get_policy( project does not have one. Args: - request (:class:`google.cloud.binaryauthorization_v1.types.GetPolicyRequest`): + request (Union[google.cloud.binaryauthorization_v1.types.GetPolicyRequest, dict]): The request object. Request message for [BinauthzManagementService.GetPolicy][]. name (:class:`str`): @@ -279,10 +281,10 @@ async def get_policy( async def update_policy( self, - request: service.UpdatePolicyRequest = None, + request: Union[service.UpdatePolicyRequest, dict] = None, *, policy: resources.Policy = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> resources.Policy: @@ -296,7 +298,7 @@ async def update_policy( request is malformed. Args: - request (:class:`google.cloud.binaryauthorization_v1.types.UpdatePolicyRequest`): + request (Union[google.cloud.binaryauthorization_v1.types.UpdatePolicyRequest, dict]): The request object. Request message for [BinauthzManagementService.UpdatePolicy][]. policy (:class:`google.cloud.binaryauthorization_v1.types.Policy`): @@ -373,12 +375,12 @@ async def update_policy( async def create_attestor( self, - request: service.CreateAttestorRequest = None, + request: Union[service.CreateAttestorRequest, dict] = None, *, parent: str = None, attestor_id: str = None, attestor: resources.Attestor = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> resources.Attestor: @@ -392,7 +394,7 @@ async def create_attestor( already exists. Args: - request (:class:`google.cloud.binaryauthorization_v1.types.CreateAttestorRequest`): + request (Union[google.cloud.binaryauthorization_v1.types.CreateAttestorRequest, dict]): The request object. Request message for [BinauthzManagementService.CreateAttestor][]. parent (:class:`str`): @@ -477,10 +479,10 @@ async def create_attestor( async def get_attestor( self, - request: service.GetAttestorRequest = None, + request: Union[service.GetAttestorRequest, dict] = None, *, name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> resources.Attestor: @@ -491,7 +493,7 @@ async def get_attestor( not exist. Args: - request (:class:`google.cloud.binaryauthorization_v1.types.GetAttestorRequest`): + request (Union[google.cloud.binaryauthorization_v1.types.GetAttestorRequest, dict]): The request object. Request message for [BinauthzManagementService.GetAttestor][]. name (:class:`str`): @@ -564,10 +566,10 @@ async def get_attestor( async def update_attestor( self, - request: service.UpdateAttestorRequest = None, + request: Union[service.UpdateAttestorRequest, dict] = None, *, attestor: resources.Attestor = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> resources.Attestor: @@ -578,7 +580,7 @@ async def update_attestor( not exist. Args: - request (:class:`google.cloud.binaryauthorization_v1.types.UpdateAttestorRequest`): + request (Union[google.cloud.binaryauthorization_v1.types.UpdateAttestorRequest, dict]): The request object. Request message for [BinauthzManagementService.UpdateAttestor][]. attestor (:class:`google.cloud.binaryauthorization_v1.types.Attestor`): @@ -656,10 +658,10 @@ async def update_attestor( async def list_attestors( self, - request: service.ListAttestorsRequest = None, + request: Union[service.ListAttestorsRequest, dict] = None, *, parent: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> pagers.ListAttestorsAsyncPager: @@ -667,7 +669,7 @@ async def list_attestors( Returns INVALID_ARGUMENT if the project does not exist. Args: - request (:class:`google.cloud.binaryauthorization_v1.types.ListAttestorsRequest`): + request (Union[google.cloud.binaryauthorization_v1.types.ListAttestorsRequest, dict]): The request object. Request message for [BinauthzManagementService.ListAttestors][]. parent (:class:`str`): @@ -749,10 +751,10 @@ async def list_attestors( async def delete_attestor( self, - request: service.DeleteAttestorRequest = None, + request: Union[service.DeleteAttestorRequest, dict] = None, *, name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> None: @@ -763,7 +765,7 @@ async def delete_attestor( not exist. Args: - request (:class:`google.cloud.binaryauthorization_v1.types.DeleteAttestorRequest`): + request (Union[google.cloud.binaryauthorization_v1.types.DeleteAttestorRequest, dict]): The request object. Request message for [BinauthzManagementService.DeleteAttestor][]. name (:class:`str`): diff --git a/google/cloud/binaryauthorization_v1/services/binauthz_management_service_v1/client.py b/google/cloud/binaryauthorization_v1/services/binauthz_management_service_v1/client.py index 0c21b73..7c15940 100644 --- a/google/cloud/binaryauthorization_v1/services/binauthz_management_service_v1/client.py +++ b/google/cloud/binaryauthorization_v1/services/binauthz_management_service_v1/client.py @@ -30,6 +30,8 @@ from google.auth.exceptions import MutualTLSChannelError # type: ignore from google.oauth2 import service_account # type: ignore +OptionalRetry = Union[retries.Retry, object] + from google.cloud.binaryauthorization_v1.services.binauthz_management_service_v1 import ( pagers, ) @@ -377,7 +379,7 @@ def get_policy( request: Union[service.GetPolicyRequest, dict] = None, *, name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> resources.Policy: @@ -459,7 +461,7 @@ def update_policy( request: Union[service.UpdatePolicyRequest, dict] = None, *, policy: resources.Policy = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> resources.Policy: @@ -545,7 +547,7 @@ def create_attestor( parent: str = None, attestor_id: str = None, attestor: resources.Attestor = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> resources.Attestor: @@ -647,7 +649,7 @@ def get_attestor( request: Union[service.GetAttestorRequest, dict] = None, *, name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> resources.Attestor: @@ -724,7 +726,7 @@ def update_attestor( request: Union[service.UpdateAttestorRequest, dict] = None, *, attestor: resources.Attestor = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> resources.Attestor: @@ -806,7 +808,7 @@ def list_attestors( request: Union[service.ListAttestorsRequest, dict] = None, *, parent: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> pagers.ListAttestorsPager: @@ -889,7 +891,7 @@ def delete_attestor( request: Union[service.DeleteAttestorRequest, dict] = None, *, name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> None: diff --git a/google/cloud/binaryauthorization_v1/services/binauthz_management_service_v1/transports/base.py b/google/cloud/binaryauthorization_v1/services/binauthz_management_service_v1/transports/base.py index f9205f3..efcb0ac 100644 --- a/google/cloud/binaryauthorization_v1/services/binauthz_management_service_v1/transports/base.py +++ b/google/cloud/binaryauthorization_v1/services/binauthz_management_service_v1/transports/base.py @@ -15,7 +15,6 @@ # import abc from typing import Awaitable, Callable, Dict, Optional, Sequence, Union -import packaging.version import pkg_resources import google.auth # type: ignore @@ -39,15 +38,6 @@ except pkg_resources.DistributionNotFound: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() -try: - # google.auth.__version__ was added in 1.26.0 - _GOOGLE_AUTH_VERSION = google.auth.__version__ -except AttributeError: - try: # try pkg_resources if it is available - _GOOGLE_AUTH_VERSION = pkg_resources.get_distribution("google-auth").version - except pkg_resources.DistributionNotFound: # pragma: NO COVER - _GOOGLE_AUTH_VERSION = None - class BinauthzManagementServiceV1Transport(abc.ABC): """Abstract transport class for BinauthzManagementServiceV1.""" @@ -97,7 +87,7 @@ def __init__( host += ":443" self._host = host - scopes_kwargs = self._get_scopes_kwargs(self._host, scopes) + scopes_kwargs = {"scopes": scopes, "default_scopes": self.AUTH_SCOPES} # Save the scopes. self._scopes = scopes @@ -130,29 +120,6 @@ def __init__( # Save the credentials. self._credentials = credentials - # TODO(busunkim): This method is in the base transport - # to avoid duplicating code across the transport classes. These functions - # should be deleted once the minimum required versions of google-auth is increased. - - # TODO: Remove this function once google-auth >= 1.25.0 is required - @classmethod - def _get_scopes_kwargs( - cls, host: str, scopes: Optional[Sequence[str]] - ) -> Dict[str, Optional[Sequence[str]]]: - """Returns scopes kwargs to pass to google-auth methods depending on the google-auth version""" - - scopes_kwargs = {} - - if _GOOGLE_AUTH_VERSION and ( - packaging.version.parse(_GOOGLE_AUTH_VERSION) - >= packaging.version.parse("1.25.0") - ): - scopes_kwargs = {"scopes": scopes, "default_scopes": cls.AUTH_SCOPES} - else: - scopes_kwargs = {"scopes": scopes or cls.AUTH_SCOPES} - - return scopes_kwargs - def _prep_wrapped_messages(self, client_info): # Precompute the wrapped methods. self._wrapped_methods = { diff --git a/google/cloud/binaryauthorization_v1/services/binauthz_management_service_v1/transports/grpc_asyncio.py b/google/cloud/binaryauthorization_v1/services/binauthz_management_service_v1/transports/grpc_asyncio.py index db886fe..4c68d52 100644 --- a/google/cloud/binaryauthorization_v1/services/binauthz_management_service_v1/transports/grpc_asyncio.py +++ b/google/cloud/binaryauthorization_v1/services/binauthz_management_service_v1/transports/grpc_asyncio.py @@ -20,7 +20,6 @@ from google.api_core import grpc_helpers_async # type: ignore from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore -import packaging.version import grpc # type: ignore from grpc.experimental import aio # type: ignore diff --git a/google/cloud/binaryauthorization_v1/services/system_policy_v1/async_client.py b/google/cloud/binaryauthorization_v1/services/system_policy_v1/async_client.py index e68b6ea..4b7222c 100644 --- a/google/cloud/binaryauthorization_v1/services/system_policy_v1/async_client.py +++ b/google/cloud/binaryauthorization_v1/services/system_policy_v1/async_client.py @@ -19,13 +19,15 @@ from typing import Dict, Sequence, Tuple, Type, Union import pkg_resources -import google.api_core.client_options as ClientOptions # type: ignore +from google.api_core.client_options import ClientOptions # type: ignore from google.api_core import exceptions as core_exceptions # type: ignore from google.api_core import gapic_v1 # type: ignore from google.api_core import retry as retries # type: ignore from google.auth import credentials as ga_credentials # type: ignore from google.oauth2 import service_account # type: ignore +OptionalRetry = Union[retries.Retry, object] + from google.cloud.binaryauthorization_v1.types import resources from google.cloud.binaryauthorization_v1.types import service from google.protobuf import timestamp_pb2 # type: ignore @@ -164,10 +166,10 @@ def __init__( async def get_system_policy( self, - request: service.GetSystemPolicyRequest = None, + request: Union[service.GetSystemPolicyRequest, dict] = None, *, name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> resources.Policy: @@ -175,7 +177,7 @@ async def get_system_policy( location. Args: - request (:class:`google.cloud.binaryauthorization_v1.types.GetSystemPolicyRequest`): + request (Union[google.cloud.binaryauthorization_v1.types.GetSystemPolicyRequest, dict]): The request object. Request to read the current system policy. name (:class:`str`): diff --git a/google/cloud/binaryauthorization_v1/services/system_policy_v1/client.py b/google/cloud/binaryauthorization_v1/services/system_policy_v1/client.py index 003e139..ce8f316 100644 --- a/google/cloud/binaryauthorization_v1/services/system_policy_v1/client.py +++ b/google/cloud/binaryauthorization_v1/services/system_policy_v1/client.py @@ -30,6 +30,8 @@ from google.auth.exceptions import MutualTLSChannelError # type: ignore from google.oauth2 import service_account # type: ignore +OptionalRetry = Union[retries.Retry, object] + from google.cloud.binaryauthorization_v1.types import resources from google.cloud.binaryauthorization_v1.types import service from google.protobuf import timestamp_pb2 # type: ignore @@ -348,7 +350,7 @@ def get_system_policy( request: Union[service.GetSystemPolicyRequest, dict] = None, *, name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> resources.Policy: diff --git a/google/cloud/binaryauthorization_v1/services/system_policy_v1/transports/base.py b/google/cloud/binaryauthorization_v1/services/system_policy_v1/transports/base.py index 37e4e41..0112c94 100644 --- a/google/cloud/binaryauthorization_v1/services/system_policy_v1/transports/base.py +++ b/google/cloud/binaryauthorization_v1/services/system_policy_v1/transports/base.py @@ -15,7 +15,6 @@ # import abc from typing import Awaitable, Callable, Dict, Optional, Sequence, Union -import packaging.version import pkg_resources import google.auth # type: ignore @@ -38,15 +37,6 @@ except pkg_resources.DistributionNotFound: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() -try: - # google.auth.__version__ was added in 1.26.0 - _GOOGLE_AUTH_VERSION = google.auth.__version__ -except AttributeError: - try: # try pkg_resources if it is available - _GOOGLE_AUTH_VERSION = pkg_resources.get_distribution("google-auth").version - except pkg_resources.DistributionNotFound: # pragma: NO COVER - _GOOGLE_AUTH_VERSION = None - class SystemPolicyV1Transport(abc.ABC): """Abstract transport class for SystemPolicyV1.""" @@ -96,7 +86,7 @@ def __init__( host += ":443" self._host = host - scopes_kwargs = self._get_scopes_kwargs(self._host, scopes) + scopes_kwargs = {"scopes": scopes, "default_scopes": self.AUTH_SCOPES} # Save the scopes. self._scopes = scopes @@ -129,29 +119,6 @@ def __init__( # Save the credentials. self._credentials = credentials - # TODO(busunkim): This method is in the base transport - # to avoid duplicating code across the transport classes. These functions - # should be deleted once the minimum required versions of google-auth is increased. - - # TODO: Remove this function once google-auth >= 1.25.0 is required - @classmethod - def _get_scopes_kwargs( - cls, host: str, scopes: Optional[Sequence[str]] - ) -> Dict[str, Optional[Sequence[str]]]: - """Returns scopes kwargs to pass to google-auth methods depending on the google-auth version""" - - scopes_kwargs = {} - - if _GOOGLE_AUTH_VERSION and ( - packaging.version.parse(_GOOGLE_AUTH_VERSION) - >= packaging.version.parse("1.25.0") - ): - scopes_kwargs = {"scopes": scopes, "default_scopes": cls.AUTH_SCOPES} - else: - scopes_kwargs = {"scopes": scopes or cls.AUTH_SCOPES} - - return scopes_kwargs - def _prep_wrapped_messages(self, client_info): # Precompute the wrapped methods. self._wrapped_methods = { diff --git a/google/cloud/binaryauthorization_v1/services/system_policy_v1/transports/grpc_asyncio.py b/google/cloud/binaryauthorization_v1/services/system_policy_v1/transports/grpc_asyncio.py index ec20312..024928e 100644 --- a/google/cloud/binaryauthorization_v1/services/system_policy_v1/transports/grpc_asyncio.py +++ b/google/cloud/binaryauthorization_v1/services/system_policy_v1/transports/grpc_asyncio.py @@ -20,7 +20,6 @@ from google.api_core import grpc_helpers_async # type: ignore from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore -import packaging.version import grpc # type: ignore from grpc.experimental import aio # type: ignore diff --git a/google/cloud/binaryauthorization_v1/services/validation_helper_v1/async_client.py b/google/cloud/binaryauthorization_v1/services/validation_helper_v1/async_client.py index 5a2600c..56999ce 100644 --- a/google/cloud/binaryauthorization_v1/services/validation_helper_v1/async_client.py +++ b/google/cloud/binaryauthorization_v1/services/validation_helper_v1/async_client.py @@ -19,13 +19,15 @@ from typing import Dict, Sequence, Tuple, Type, Union import pkg_resources -import google.api_core.client_options as ClientOptions # type: ignore +from google.api_core.client_options import ClientOptions # type: ignore from google.api_core import exceptions as core_exceptions # type: ignore from google.api_core import gapic_v1 # type: ignore from google.api_core import retry as retries # type: ignore from google.auth import credentials as ga_credentials # type: ignore from google.oauth2 import service_account # type: ignore +OptionalRetry = Union[retries.Retry, object] + from google.cloud.binaryauthorization_v1.types import service from .transports.base import ValidationHelperV1Transport, DEFAULT_CLIENT_INFO from .transports.grpc_asyncio import ValidationHelperV1GrpcAsyncIOTransport @@ -161,9 +163,9 @@ def __init__( async def validate_attestation_occurrence( self, - request: service.ValidateAttestationOccurrenceRequest = None, + request: Union[service.ValidateAttestationOccurrenceRequest, dict] = None, *, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> service.ValidateAttestationOccurrenceResponse: @@ -171,7 +173,7 @@ async def validate_attestation_occurrence( image URI was signed by the given Attestor Args: - request (:class:`google.cloud.binaryauthorization_v1.types.ValidateAttestationOccurrenceRequest`): + request (Union[google.cloud.binaryauthorization_v1.types.ValidateAttestationOccurrenceRequest, dict]): The request object. Request message for [ValidationHelperV1.ValidateAttestationOccurrence][google.cloud.binaryauthorization.v1.ValidationHelperV1.ValidateAttestationOccurrence]. retry (google.api_core.retry.Retry): Designation of what errors, if any, diff --git a/google/cloud/binaryauthorization_v1/services/validation_helper_v1/client.py b/google/cloud/binaryauthorization_v1/services/validation_helper_v1/client.py index 75b7af1..ea12dd3 100644 --- a/google/cloud/binaryauthorization_v1/services/validation_helper_v1/client.py +++ b/google/cloud/binaryauthorization_v1/services/validation_helper_v1/client.py @@ -30,6 +30,8 @@ from google.auth.exceptions import MutualTLSChannelError # type: ignore from google.oauth2 import service_account # type: ignore +OptionalRetry = Union[retries.Retry, object] + from google.cloud.binaryauthorization_v1.types import service from .transports.base import ValidationHelperV1Transport, DEFAULT_CLIENT_INFO from .transports.grpc import ValidationHelperV1GrpcTransport @@ -336,7 +338,7 @@ def validate_attestation_occurrence( self, request: Union[service.ValidateAttestationOccurrenceRequest, dict] = None, *, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> service.ValidateAttestationOccurrenceResponse: diff --git a/google/cloud/binaryauthorization_v1/services/validation_helper_v1/transports/base.py b/google/cloud/binaryauthorization_v1/services/validation_helper_v1/transports/base.py index 31133d4..4ffa26c 100644 --- a/google/cloud/binaryauthorization_v1/services/validation_helper_v1/transports/base.py +++ b/google/cloud/binaryauthorization_v1/services/validation_helper_v1/transports/base.py @@ -15,7 +15,6 @@ # import abc from typing import Awaitable, Callable, Dict, Optional, Sequence, Union -import packaging.version import pkg_resources import google.auth # type: ignore @@ -37,15 +36,6 @@ except pkg_resources.DistributionNotFound: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() -try: - # google.auth.__version__ was added in 1.26.0 - _GOOGLE_AUTH_VERSION = google.auth.__version__ -except AttributeError: - try: # try pkg_resources if it is available - _GOOGLE_AUTH_VERSION = pkg_resources.get_distribution("google-auth").version - except pkg_resources.DistributionNotFound: # pragma: NO COVER - _GOOGLE_AUTH_VERSION = None - class ValidationHelperV1Transport(abc.ABC): """Abstract transport class for ValidationHelperV1.""" @@ -95,7 +85,7 @@ def __init__( host += ":443" self._host = host - scopes_kwargs = self._get_scopes_kwargs(self._host, scopes) + scopes_kwargs = {"scopes": scopes, "default_scopes": self.AUTH_SCOPES} # Save the scopes. self._scopes = scopes @@ -128,29 +118,6 @@ def __init__( # Save the credentials. self._credentials = credentials - # TODO(busunkim): This method is in the base transport - # to avoid duplicating code across the transport classes. These functions - # should be deleted once the minimum required versions of google-auth is increased. - - # TODO: Remove this function once google-auth >= 1.25.0 is required - @classmethod - def _get_scopes_kwargs( - cls, host: str, scopes: Optional[Sequence[str]] - ) -> Dict[str, Optional[Sequence[str]]]: - """Returns scopes kwargs to pass to google-auth methods depending on the google-auth version""" - - scopes_kwargs = {} - - if _GOOGLE_AUTH_VERSION and ( - packaging.version.parse(_GOOGLE_AUTH_VERSION) - >= packaging.version.parse("1.25.0") - ): - scopes_kwargs = {"scopes": scopes, "default_scopes": cls.AUTH_SCOPES} - else: - scopes_kwargs = {"scopes": scopes or cls.AUTH_SCOPES} - - return scopes_kwargs - def _prep_wrapped_messages(self, client_info): # Precompute the wrapped methods. self._wrapped_methods = { diff --git a/google/cloud/binaryauthorization_v1/services/validation_helper_v1/transports/grpc_asyncio.py b/google/cloud/binaryauthorization_v1/services/validation_helper_v1/transports/grpc_asyncio.py index 5d33588..4f60f14 100644 --- a/google/cloud/binaryauthorization_v1/services/validation_helper_v1/transports/grpc_asyncio.py +++ b/google/cloud/binaryauthorization_v1/services/validation_helper_v1/transports/grpc_asyncio.py @@ -20,7 +20,6 @@ from google.api_core import grpc_helpers_async # type: ignore from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore -import packaging.version import grpc # type: ignore from grpc.experimental import aio # type: ignore diff --git a/google/cloud/binaryauthorization_v1/types/resources.py b/google/cloud/binaryauthorization_v1/types/resources.py index ff2f328..b6e5e9b 100644 --- a/google/cloud/binaryauthorization_v1/types/resources.py +++ b/google/cloud/binaryauthorization_v1/types/resources.py @@ -197,6 +197,9 @@ class Attestor(proto.Message): attests to container image artifacts. An existing attestor cannot be modified except where indicated. + + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields + Attributes: name (str): Required. The resource name, in the format: @@ -209,6 +212,7 @@ class Attestor(proto.Message): This specifies how an attestation will be read, and how it will be used during policy enforcement. + This field is a member of `oneof`_ ``attestor_type``. update_time (google.protobuf.timestamp_pb2.Timestamp): Output only. Time when the attestor was last updated. @@ -323,6 +327,13 @@ class AttestorPublicKey(proto.Message): key][google.cloud.binaryauthorization.v1.AttestorPublicKey] that will be used to verify attestations signed by this attestor. + This message has `oneof`_ fields (mutually exclusive fields). + For each oneof, at most one member field can be set at the same time. + Setting any member of the oneof automatically clears all other + members. + + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields + Attributes: comment (str): Optional. A descriptive comment. This field @@ -344,6 +355,7 @@ class AttestorPublicKey(proto.Message): OpenPGP RFC4880 V4 fingerprint, represented as upper-case hex. If ``id`` is provided by the caller, it will be overwritten by the API-calculated ID. + This field is a member of `oneof`_ ``public_key``. pkix_public_key (google.cloud.binaryauthorization_v1.types.PkixPublicKey): A raw PKIX SubjectPublicKeyInfo format public key. @@ -352,6 +364,7 @@ class AttestorPublicKey(proto.Message): RFC3986 URI. If ``id`` is left blank, a default one will be computed based on the digest of the DER encoding of the public key. + This field is a member of `oneof`_ ``public_key``. """ comment = proto.Field(proto.STRING, number=1,) diff --git a/google/cloud/binaryauthorization_v1beta1/services/binauthz_management_service_v1_beta1/async_client.py b/google/cloud/binaryauthorization_v1beta1/services/binauthz_management_service_v1_beta1/async_client.py index ffb2c15..b606e21 100644 --- a/google/cloud/binaryauthorization_v1beta1/services/binauthz_management_service_v1_beta1/async_client.py +++ b/google/cloud/binaryauthorization_v1beta1/services/binauthz_management_service_v1_beta1/async_client.py @@ -19,13 +19,15 @@ from typing import Dict, Sequence, Tuple, Type, Union import pkg_resources -import google.api_core.client_options as ClientOptions # type: ignore +from google.api_core.client_options import ClientOptions # type: ignore from google.api_core import exceptions as core_exceptions # type: ignore from google.api_core import gapic_v1 # type: ignore from google.api_core import retry as retries # type: ignore from google.auth import credentials as ga_credentials # type: ignore from google.oauth2 import service_account # type: ignore +OptionalRetry = Union[retries.Retry, object] + from google.cloud.binaryauthorization_v1beta1.services.binauthz_management_service_v1_beta1 import ( pagers, ) @@ -194,10 +196,10 @@ def __init__( async def get_policy( self, - request: service.GetPolicyRequest = None, + request: Union[service.GetPolicyRequest, dict] = None, *, name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> resources.Policy: @@ -216,7 +218,7 @@ async def get_policy( project does not have one. Args: - request (:class:`google.cloud.binaryauthorization_v1beta1.types.GetPolicyRequest`): + request (Union[google.cloud.binaryauthorization_v1beta1.types.GetPolicyRequest, dict]): The request object. Request message for [BinauthzManagementService.GetPolicy][]. name (:class:`str`): @@ -288,10 +290,10 @@ async def get_policy( async def update_policy( self, - request: service.UpdatePolicyRequest = None, + request: Union[service.UpdatePolicyRequest, dict] = None, *, policy: resources.Policy = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> resources.Policy: @@ -305,7 +307,7 @@ async def update_policy( INVALID_ARGUMENT if the request is malformed. Args: - request (:class:`google.cloud.binaryauthorization_v1beta1.types.UpdatePolicyRequest`): + request (Union[google.cloud.binaryauthorization_v1beta1.types.UpdatePolicyRequest, dict]): The request object. Request message for [BinauthzManagementService.UpdatePolicy][]. policy (:class:`google.cloud.binaryauthorization_v1beta1.types.Policy`): @@ -382,12 +384,12 @@ async def update_policy( async def create_attestor( self, - request: service.CreateAttestorRequest = None, + request: Union[service.CreateAttestorRequest, dict] = None, *, parent: str = None, attestor_id: str = None, attestor: resources.Attestor = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> resources.Attestor: @@ -402,7 +404,7 @@ async def create_attestor( already exists. Args: - request (:class:`google.cloud.binaryauthorization_v1beta1.types.CreateAttestorRequest`): + request (Union[google.cloud.binaryauthorization_v1beta1.types.CreateAttestorRequest, dict]): The request object. Request message for [BinauthzManagementService.CreateAttestor][]. parent (:class:`str`): @@ -487,10 +489,10 @@ async def create_attestor( async def get_attestor( self, - request: service.GetAttestorRequest = None, + request: Union[service.GetAttestorRequest, dict] = None, *, name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> resources.Attestor: @@ -501,7 +503,7 @@ async def get_attestor( does not exist. Args: - request (:class:`google.cloud.binaryauthorization_v1beta1.types.GetAttestorRequest`): + request (Union[google.cloud.binaryauthorization_v1beta1.types.GetAttestorRequest, dict]): The request object. Request message for [BinauthzManagementService.GetAttestor][]. name (:class:`str`): @@ -574,10 +576,10 @@ async def get_attestor( async def update_attestor( self, - request: service.UpdateAttestorRequest = None, + request: Union[service.UpdateAttestorRequest, dict] = None, *, attestor: resources.Attestor = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> resources.Attestor: @@ -588,7 +590,7 @@ async def update_attestor( does not exist. Args: - request (:class:`google.cloud.binaryauthorization_v1beta1.types.UpdateAttestorRequest`): + request (Union[google.cloud.binaryauthorization_v1beta1.types.UpdateAttestorRequest, dict]): The request object. Request message for [BinauthzManagementService.UpdateAttestor][]. attestor (:class:`google.cloud.binaryauthorization_v1beta1.types.Attestor`): @@ -666,10 +668,10 @@ async def update_attestor( async def list_attestors( self, - request: service.ListAttestorsRequest = None, + request: Union[service.ListAttestorsRequest, dict] = None, *, parent: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> pagers.ListAttestorsAsyncPager: @@ -678,7 +680,7 @@ async def list_attestors( Returns INVALID_ARGUMENT if the project does not exist. Args: - request (:class:`google.cloud.binaryauthorization_v1beta1.types.ListAttestorsRequest`): + request (Union[google.cloud.binaryauthorization_v1beta1.types.ListAttestorsRequest, dict]): The request object. Request message for [BinauthzManagementService.ListAttestors][]. parent (:class:`str`): @@ -760,10 +762,10 @@ async def list_attestors( async def delete_attestor( self, - request: service.DeleteAttestorRequest = None, + request: Union[service.DeleteAttestorRequest, dict] = None, *, name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> None: @@ -774,7 +776,7 @@ async def delete_attestor( does not exist. Args: - request (:class:`google.cloud.binaryauthorization_v1beta1.types.DeleteAttestorRequest`): + request (Union[google.cloud.binaryauthorization_v1beta1.types.DeleteAttestorRequest, dict]): The request object. Request message for [BinauthzManagementService.DeleteAttestor][]. name (:class:`str`): diff --git a/google/cloud/binaryauthorization_v1beta1/services/binauthz_management_service_v1_beta1/client.py b/google/cloud/binaryauthorization_v1beta1/services/binauthz_management_service_v1_beta1/client.py index f2dde39..4e62d5f 100644 --- a/google/cloud/binaryauthorization_v1beta1/services/binauthz_management_service_v1_beta1/client.py +++ b/google/cloud/binaryauthorization_v1beta1/services/binauthz_management_service_v1_beta1/client.py @@ -30,6 +30,8 @@ from google.auth.exceptions import MutualTLSChannelError # type: ignore from google.oauth2 import service_account # type: ignore +OptionalRetry = Union[retries.Retry, object] + from google.cloud.binaryauthorization_v1beta1.services.binauthz_management_service_v1_beta1 import ( pagers, ) @@ -382,7 +384,7 @@ def get_policy( request: Union[service.GetPolicyRequest, dict] = None, *, name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> resources.Policy: @@ -466,7 +468,7 @@ def update_policy( request: Union[service.UpdatePolicyRequest, dict] = None, *, policy: resources.Policy = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> resources.Policy: @@ -552,7 +554,7 @@ def create_attestor( parent: str = None, attestor_id: str = None, attestor: resources.Attestor = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> resources.Attestor: @@ -655,7 +657,7 @@ def get_attestor( request: Union[service.GetAttestorRequest, dict] = None, *, name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> resources.Attestor: @@ -732,7 +734,7 @@ def update_attestor( request: Union[service.UpdateAttestorRequest, dict] = None, *, attestor: resources.Attestor = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> resources.Attestor: @@ -814,7 +816,7 @@ def list_attestors( request: Union[service.ListAttestorsRequest, dict] = None, *, parent: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> pagers.ListAttestorsPager: @@ -898,7 +900,7 @@ def delete_attestor( request: Union[service.DeleteAttestorRequest, dict] = None, *, name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> None: diff --git a/google/cloud/binaryauthorization_v1beta1/services/binauthz_management_service_v1_beta1/transports/base.py b/google/cloud/binaryauthorization_v1beta1/services/binauthz_management_service_v1_beta1/transports/base.py index dcc955d..e5a6bb2 100644 --- a/google/cloud/binaryauthorization_v1beta1/services/binauthz_management_service_v1_beta1/transports/base.py +++ b/google/cloud/binaryauthorization_v1beta1/services/binauthz_management_service_v1_beta1/transports/base.py @@ -15,7 +15,6 @@ # import abc from typing import Awaitable, Callable, Dict, Optional, Sequence, Union -import packaging.version import pkg_resources import google.auth # type: ignore @@ -39,15 +38,6 @@ except pkg_resources.DistributionNotFound: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() -try: - # google.auth.__version__ was added in 1.26.0 - _GOOGLE_AUTH_VERSION = google.auth.__version__ -except AttributeError: - try: # try pkg_resources if it is available - _GOOGLE_AUTH_VERSION = pkg_resources.get_distribution("google-auth").version - except pkg_resources.DistributionNotFound: # pragma: NO COVER - _GOOGLE_AUTH_VERSION = None - class BinauthzManagementServiceV1Beta1Transport(abc.ABC): """Abstract transport class for BinauthzManagementServiceV1Beta1.""" @@ -97,7 +87,7 @@ def __init__( host += ":443" self._host = host - scopes_kwargs = self._get_scopes_kwargs(self._host, scopes) + scopes_kwargs = {"scopes": scopes, "default_scopes": self.AUTH_SCOPES} # Save the scopes. self._scopes = scopes @@ -130,29 +120,6 @@ def __init__( # Save the credentials. self._credentials = credentials - # TODO(busunkim): This method is in the base transport - # to avoid duplicating code across the transport classes. These functions - # should be deleted once the minimum required versions of google-auth is increased. - - # TODO: Remove this function once google-auth >= 1.25.0 is required - @classmethod - def _get_scopes_kwargs( - cls, host: str, scopes: Optional[Sequence[str]] - ) -> Dict[str, Optional[Sequence[str]]]: - """Returns scopes kwargs to pass to google-auth methods depending on the google-auth version""" - - scopes_kwargs = {} - - if _GOOGLE_AUTH_VERSION and ( - packaging.version.parse(_GOOGLE_AUTH_VERSION) - >= packaging.version.parse("1.25.0") - ): - scopes_kwargs = {"scopes": scopes, "default_scopes": cls.AUTH_SCOPES} - else: - scopes_kwargs = {"scopes": scopes or cls.AUTH_SCOPES} - - return scopes_kwargs - def _prep_wrapped_messages(self, client_info): # Precompute the wrapped methods. self._wrapped_methods = { diff --git a/google/cloud/binaryauthorization_v1beta1/services/binauthz_management_service_v1_beta1/transports/grpc_asyncio.py b/google/cloud/binaryauthorization_v1beta1/services/binauthz_management_service_v1_beta1/transports/grpc_asyncio.py index cf2fcd7..33f1640 100644 --- a/google/cloud/binaryauthorization_v1beta1/services/binauthz_management_service_v1_beta1/transports/grpc_asyncio.py +++ b/google/cloud/binaryauthorization_v1beta1/services/binauthz_management_service_v1_beta1/transports/grpc_asyncio.py @@ -20,7 +20,6 @@ from google.api_core import grpc_helpers_async # type: ignore from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore -import packaging.version import grpc # type: ignore from grpc.experimental import aio # type: ignore diff --git a/google/cloud/binaryauthorization_v1beta1/types/continuous_validation_logging.py b/google/cloud/binaryauthorization_v1beta1/types/continuous_validation_logging.py index 2fb7c00..dd10062 100644 --- a/google/cloud/binaryauthorization_v1beta1/types/continuous_validation_logging.py +++ b/google/cloud/binaryauthorization_v1beta1/types/continuous_validation_logging.py @@ -27,11 +27,20 @@ class ContinuousValidationEvent(proto.Message): r"""Represents an auditing event from Continuous Validation. + This message has `oneof`_ fields (mutually exclusive fields). + For each oneof, at most one member field can be set at the same time. + Setting any member of the oneof automatically clears all other + members. + + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields + Attributes: pod_event (google.cloud.binaryauthorization_v1beta1.types.ContinuousValidationEvent.ContinuousValidationPodEvent): Pod event. + This field is a member of `oneof`_ ``event_type``. unsupported_policy_event (google.cloud.binaryauthorization_v1beta1.types.ContinuousValidationEvent.UnsupportedPolicyEvent): Unsupported policy event. + This field is a member of `oneof`_ ``event_type``. """ class ContinuousValidationPodEvent(proto.Message): diff --git a/google/cloud/binaryauthorization_v1beta1/types/resources.py b/google/cloud/binaryauthorization_v1beta1/types/resources.py index a04d681..61a6d3a 100644 --- a/google/cloud/binaryauthorization_v1beta1/types/resources.py +++ b/google/cloud/binaryauthorization_v1beta1/types/resources.py @@ -173,6 +173,9 @@ class Attestor(proto.Message): that attests to container image artifacts. An existing attestor cannot be modified except where indicated. + + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields + Attributes: name (str): Required. The resource name, in the format: @@ -183,6 +186,7 @@ class Attestor(proto.Message): chooser dialogs. user_owned_drydock_note (google.cloud.binaryauthorization_v1beta1.types.UserOwnedDrydockNote): A Drydock ATTESTATION_AUTHORITY Note, created by the user. + This field is a member of `oneof`_ ``attestor_type``. update_time (google.protobuf.timestamp_pb2.Timestamp): Output only. Time when the attestor was last updated. @@ -293,6 +297,13 @@ class AttestorPublicKey(proto.Message): key][google.cloud.binaryauthorization.v1beta1.AttestorPublicKey] that will be used to verify attestations signed by this attestor. + This message has `oneof`_ fields (mutually exclusive fields). + For each oneof, at most one member field can be set at the same time. + Setting any member of the oneof automatically clears all other + members. + + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields + Attributes: comment (str): Optional. A descriptive comment. This field @@ -314,6 +325,7 @@ class AttestorPublicKey(proto.Message): OpenPGP RFC4880 V4 fingerprint, represented as upper-case hex. If ``id`` is provided by the caller, it will be overwritten by the API-calculated ID. + This field is a member of `oneof`_ ``public_key``. pkix_public_key (google.cloud.binaryauthorization_v1beta1.types.PkixPublicKey): A raw PKIX SubjectPublicKeyInfo format public key. @@ -322,6 +334,7 @@ class AttestorPublicKey(proto.Message): RFC3986 URI. If ``id`` is left blank, a default one will be computed based on the digest of the DER encoding of the public key. + This field is a member of `oneof`_ ``public_key``. """ comment = proto.Field(proto.STRING, number=1,) diff --git a/noxfile.py b/noxfile.py index 672b28d..f041f1f 100644 --- a/noxfile.py +++ b/noxfile.py @@ -101,7 +101,7 @@ def default(session): "py.test", "--quiet", f"--junitxml=unit_{session.python}_sponge_log.xml", - "--cov=google/cloud", + "--cov=google", "--cov=tests/unit", "--cov-append", "--cov-config=.coveragerc", diff --git a/setup.py b/setup.py index e7a8998..bea03e6 100644 --- a/setup.py +++ b/setup.py @@ -20,7 +20,7 @@ import setuptools # type: ignore -version = "1.0.0" +version = "1.0.1" package_root = os.path.abspath(os.path.dirname(__file__)) @@ -49,9 +49,8 @@ # NOTE: Maintainers, please do not require google-api-core>=2.x.x # Until this issue is closed # https://github.com/googleapis/google-cloud-python/issues/10566 - "google-api-core[grpc] >= 1.26.0, <3.0.0dev", + "google-api-core[grpc] >= 1.28.0, <3.0.0dev", "proto-plus >= 1.15.0", - "packaging >= 14.3", "grafeas >= 1.1.2", ), python_requires=">=3.6", diff --git a/testing/constraints-3.6.txt b/testing/constraints-3.6.txt index db1749a..e93862d 100644 --- a/testing/constraints-3.6.txt +++ b/testing/constraints-3.6.txt @@ -4,8 +4,6 @@ # Pin the version to the lower bound. # e.g., if setup.py has "google-cloud-foo >= 1.14.0, < 2.0.0dev", # Then this file should have google-cloud-foo==1.14.0 -google-api-core==1.26.0 +google-api-core==1.28.0 proto-plus==1.15.0 grafeas==1.1.2 -packaging==14.3 -google-auth==1.24.0 # TODO: remove when google-auth>=1.25.0 si transitively required through google-api-core diff --git a/tests/unit/gapic/binaryauthorization_v1/test_binauthz_management_service_v1.py b/tests/unit/gapic/binaryauthorization_v1/test_binauthz_management_service_v1.py index fdd3374..077c30d 100644 --- a/tests/unit/gapic/binaryauthorization_v1/test_binauthz_management_service_v1.py +++ b/tests/unit/gapic/binaryauthorization_v1/test_binauthz_management_service_v1.py @@ -15,7 +15,6 @@ # import os import mock -import packaging.version import grpc from grpc.experimental import aio @@ -44,9 +43,6 @@ from google.cloud.binaryauthorization_v1.services.binauthz_management_service_v1 import ( transports, ) -from google.cloud.binaryauthorization_v1.services.binauthz_management_service_v1.transports.base import ( - _GOOGLE_AUTH_VERSION, -) from google.cloud.binaryauthorization_v1.types import resources from google.cloud.binaryauthorization_v1.types import service from google.oauth2 import service_account @@ -54,20 +50,6 @@ import google.auth -# TODO(busunkim): Once google-auth >= 1.25.0 is required transitively -# through google-api-core: -# - Delete the auth "less than" test cases -# - Delete these pytest markers (Make the "greater than or equal to" tests the default). -requires_google_auth_lt_1_25_0 = pytest.mark.skipif( - packaging.version.parse(_GOOGLE_AUTH_VERSION) >= packaging.version.parse("1.25.0"), - reason="This test requires google-auth < 1.25.0", -) -requires_google_auth_gte_1_25_0 = pytest.mark.skipif( - packaging.version.parse(_GOOGLE_AUTH_VERSION) < packaging.version.parse("1.25.0"), - reason="This test requires google-auth >= 1.25.0", -) - - def client_cert_source_callback(): return b"cert bytes", b"key bytes" @@ -237,7 +219,7 @@ def test_binauthz_management_service_v1_client_client_options( options = client_options.ClientOptions(api_endpoint="squid.clam.whelk") with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class(client_options=options) + client = client_class(transport=transport_name, client_options=options) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -254,7 +236,7 @@ def test_binauthz_management_service_v1_client_client_options( with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "never"}): with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class() + client = client_class(transport=transport_name) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -271,7 +253,7 @@ def test_binauthz_management_service_v1_client_client_options( with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "always"}): with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class() + client = client_class(transport=transport_name) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -300,7 +282,7 @@ def test_binauthz_management_service_v1_client_client_options( options = client_options.ClientOptions(quota_project_id="octopus") with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class(client_options=options) + client = client_class(transport=transport_name, client_options=options) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -369,7 +351,7 @@ def test_binauthz_management_service_v1_client_mtls_env_auto( ) with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class(client_options=options) + client = client_class(transport=transport_name, client_options=options) if use_client_cert_env == "false": expected_client_cert_source = None @@ -411,7 +393,7 @@ def test_binauthz_management_service_v1_client_mtls_env_auto( expected_client_cert_source = client_cert_source_callback patched.return_value = None - client = client_class() + client = client_class(transport=transport_name) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -433,7 +415,7 @@ def test_binauthz_management_service_v1_client_mtls_env_auto( return_value=False, ): patched.return_value = None - client = client_class() + client = client_class(transport=transport_name) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -468,7 +450,7 @@ def test_binauthz_management_service_v1_client_client_options_scopes( options = client_options.ClientOptions(scopes=["1", "2"],) with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class(client_options=options) + client = client_class(transport=transport_name, client_options=options) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -503,7 +485,7 @@ def test_binauthz_management_service_v1_client_client_options_credentials_file( 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) + client = client_class(transport=transport_name, client_options=options) patched.assert_called_once_with( credentials=None, credentials_file="credentials.json", @@ -2313,7 +2295,6 @@ def test_binauthz_management_service_v1_base_transport(): transport.close() -@requires_google_auth_gte_1_25_0 def test_binauthz_management_service_v1_base_transport_with_credentials_file(): # Instantiate the base transport with a credentials file with mock.patch.object( @@ -2334,26 +2315,6 @@ def test_binauthz_management_service_v1_base_transport_with_credentials_file(): ) -@requires_google_auth_lt_1_25_0 -def test_binauthz_management_service_v1_base_transport_with_credentials_file_old_google_auth(): - # Instantiate the base transport with a credentials file - with mock.patch.object( - google.auth, "load_credentials_from_file", autospec=True - ) as load_creds, mock.patch( - "google.cloud.binaryauthorization_v1.services.binauthz_management_service_v1.transports.BinauthzManagementServiceV1Transport._prep_wrapped_messages" - ) as Transport: - Transport.return_value = None - load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) - transport = transports.BinauthzManagementServiceV1Transport( - credentials_file="credentials.json", quota_project_id="octopus", - ) - load_creds.assert_called_once_with( - "credentials.json", - scopes=("https://www.googleapis.com/auth/cloud-platform",), - quota_project_id="octopus", - ) - - def test_binauthz_management_service_v1_base_transport_with_adc(): # Test the default credentials are used if credentials and credentials_file are None. with mock.patch.object(google.auth, "default", autospec=True) as adc, mock.patch( @@ -2365,7 +2326,6 @@ def test_binauthz_management_service_v1_base_transport_with_adc(): adc.assert_called_once() -@requires_google_auth_gte_1_25_0 def test_binauthz_management_service_v1_auth_adc(): # If no credentials are provided, we should use ADC credentials. with mock.patch.object(google.auth, "default", autospec=True) as adc: @@ -2378,18 +2338,6 @@ def test_binauthz_management_service_v1_auth_adc(): ) -@requires_google_auth_lt_1_25_0 -def test_binauthz_management_service_v1_auth_adc_old_google_auth(): - # If no credentials are provided, we should use ADC credentials. - with mock.patch.object(google.auth, "default", autospec=True) as adc: - adc.return_value = (ga_credentials.AnonymousCredentials(), None) - BinauthzManagementServiceV1Client() - adc.assert_called_once_with( - scopes=("https://www.googleapis.com/auth/cloud-platform",), - quota_project_id=None, - ) - - @pytest.mark.parametrize( "transport_class", [ @@ -2397,7 +2345,6 @@ def test_binauthz_management_service_v1_auth_adc_old_google_auth(): transports.BinauthzManagementServiceV1GrpcAsyncIOTransport, ], ) -@requires_google_auth_gte_1_25_0 def test_binauthz_management_service_v1_transport_auth_adc(transport_class): # If credentials and host are not provided, the transport class should use # ADC credentials. @@ -2411,28 +2358,6 @@ def test_binauthz_management_service_v1_transport_auth_adc(transport_class): ) -@pytest.mark.parametrize( - "transport_class", - [ - transports.BinauthzManagementServiceV1GrpcTransport, - transports.BinauthzManagementServiceV1GrpcAsyncIOTransport, - ], -) -@requires_google_auth_lt_1_25_0 -def test_binauthz_management_service_v1_transport_auth_adc_old_google_auth( - transport_class, -): - # If credentials and host are not provided, the transport class should use - # ADC credentials. - with mock.patch.object(google.auth, "default", autospec=True) as adc: - adc.return_value = (ga_credentials.AnonymousCredentials(), None) - transport_class(quota_project_id="octopus") - adc.assert_called_once_with( - scopes=("https://www.googleapis.com/auth/cloud-platform",), - quota_project_id="octopus", - ) - - @pytest.mark.parametrize( "transport_class,grpc_helpers", [ diff --git a/tests/unit/gapic/binaryauthorization_v1/test_system_policy_v1.py b/tests/unit/gapic/binaryauthorization_v1/test_system_policy_v1.py index 5cbd073..96cf9fb 100644 --- a/tests/unit/gapic/binaryauthorization_v1/test_system_policy_v1.py +++ b/tests/unit/gapic/binaryauthorization_v1/test_system_policy_v1.py @@ -15,7 +15,6 @@ # import os import mock -import packaging.version import grpc from grpc.experimental import aio @@ -39,9 +38,6 @@ SystemPolicyV1Client, ) from google.cloud.binaryauthorization_v1.services.system_policy_v1 import transports -from google.cloud.binaryauthorization_v1.services.system_policy_v1.transports.base import ( - _GOOGLE_AUTH_VERSION, -) from google.cloud.binaryauthorization_v1.types import resources from google.cloud.binaryauthorization_v1.types import service from google.oauth2 import service_account @@ -49,20 +45,6 @@ import google.auth -# TODO(busunkim): Once google-auth >= 1.25.0 is required transitively -# through google-api-core: -# - Delete the auth "less than" test cases -# - Delete these pytest markers (Make the "greater than or equal to" tests the default). -requires_google_auth_lt_1_25_0 = pytest.mark.skipif( - packaging.version.parse(_GOOGLE_AUTH_VERSION) >= packaging.version.parse("1.25.0"), - reason="This test requires google-auth < 1.25.0", -) -requires_google_auth_gte_1_25_0 = pytest.mark.skipif( - packaging.version.parse(_GOOGLE_AUTH_VERSION) < packaging.version.parse("1.25.0"), - reason="This test requires google-auth >= 1.25.0", -) - - def client_cert_source_callback(): return b"cert bytes", b"key bytes" @@ -219,7 +201,7 @@ def test_system_policy_v1_client_client_options( options = client_options.ClientOptions(api_endpoint="squid.clam.whelk") with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class(client_options=options) + client = client_class(transport=transport_name, client_options=options) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -236,7 +218,7 @@ def test_system_policy_v1_client_client_options( with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "never"}): with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class() + client = client_class(transport=transport_name) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -253,7 +235,7 @@ def test_system_policy_v1_client_client_options( with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "always"}): with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class() + client = client_class(transport=transport_name) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -282,7 +264,7 @@ def test_system_policy_v1_client_client_options( options = client_options.ClientOptions(quota_project_id="octopus") with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class(client_options=options) + client = client_class(transport=transport_name, client_options=options) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -341,7 +323,7 @@ def test_system_policy_v1_client_mtls_env_auto( ) with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class(client_options=options) + client = client_class(transport=transport_name, client_options=options) if use_client_cert_env == "false": expected_client_cert_source = None @@ -383,7 +365,7 @@ def test_system_policy_v1_client_mtls_env_auto( expected_client_cert_source = client_cert_source_callback patched.return_value = None - client = client_class() + client = client_class(transport=transport_name) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -405,7 +387,7 @@ def test_system_policy_v1_client_mtls_env_auto( return_value=False, ): patched.return_value = None - client = client_class() + client = client_class(transport=transport_name) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -436,7 +418,7 @@ def test_system_policy_v1_client_client_options_scopes( options = client_options.ClientOptions(scopes=["1", "2"],) with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class(client_options=options) + client = client_class(transport=transport_name, client_options=options) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -467,7 +449,7 @@ def test_system_policy_v1_client_client_options_credentials_file( 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) + client = client_class(transport=transport_name, client_options=options) patched.assert_called_once_with( credentials=None, credentials_file="credentials.json", @@ -835,7 +817,6 @@ def test_system_policy_v1_base_transport(): transport.close() -@requires_google_auth_gte_1_25_0 def test_system_policy_v1_base_transport_with_credentials_file(): # Instantiate the base transport with a credentials file with mock.patch.object( @@ -856,26 +837,6 @@ def test_system_policy_v1_base_transport_with_credentials_file(): ) -@requires_google_auth_lt_1_25_0 -def test_system_policy_v1_base_transport_with_credentials_file_old_google_auth(): - # Instantiate the base transport with a credentials file - with mock.patch.object( - google.auth, "load_credentials_from_file", autospec=True - ) as load_creds, mock.patch( - "google.cloud.binaryauthorization_v1.services.system_policy_v1.transports.SystemPolicyV1Transport._prep_wrapped_messages" - ) as Transport: - Transport.return_value = None - load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) - transport = transports.SystemPolicyV1Transport( - credentials_file="credentials.json", quota_project_id="octopus", - ) - load_creds.assert_called_once_with( - "credentials.json", - scopes=("https://www.googleapis.com/auth/cloud-platform",), - quota_project_id="octopus", - ) - - def test_system_policy_v1_base_transport_with_adc(): # Test the default credentials are used if credentials and credentials_file are None. with mock.patch.object(google.auth, "default", autospec=True) as adc, mock.patch( @@ -887,7 +848,6 @@ def test_system_policy_v1_base_transport_with_adc(): adc.assert_called_once() -@requires_google_auth_gte_1_25_0 def test_system_policy_v1_auth_adc(): # If no credentials are provided, we should use ADC credentials. with mock.patch.object(google.auth, "default", autospec=True) as adc: @@ -900,18 +860,6 @@ def test_system_policy_v1_auth_adc(): ) -@requires_google_auth_lt_1_25_0 -def test_system_policy_v1_auth_adc_old_google_auth(): - # If no credentials are provided, we should use ADC credentials. - with mock.patch.object(google.auth, "default", autospec=True) as adc: - adc.return_value = (ga_credentials.AnonymousCredentials(), None) - SystemPolicyV1Client() - adc.assert_called_once_with( - scopes=("https://www.googleapis.com/auth/cloud-platform",), - quota_project_id=None, - ) - - @pytest.mark.parametrize( "transport_class", [ @@ -919,7 +867,6 @@ def test_system_policy_v1_auth_adc_old_google_auth(): transports.SystemPolicyV1GrpcAsyncIOTransport, ], ) -@requires_google_auth_gte_1_25_0 def test_system_policy_v1_transport_auth_adc(transport_class): # If credentials and host are not provided, the transport class should use # ADC credentials. @@ -933,26 +880,6 @@ def test_system_policy_v1_transport_auth_adc(transport_class): ) -@pytest.mark.parametrize( - "transport_class", - [ - transports.SystemPolicyV1GrpcTransport, - transports.SystemPolicyV1GrpcAsyncIOTransport, - ], -) -@requires_google_auth_lt_1_25_0 -def test_system_policy_v1_transport_auth_adc_old_google_auth(transport_class): - # If credentials and host are not provided, the transport class should use - # ADC credentials. - with mock.patch.object(google.auth, "default", autospec=True) as adc: - adc.return_value = (ga_credentials.AnonymousCredentials(), None) - transport_class(quota_project_id="octopus") - adc.assert_called_once_with( - scopes=("https://www.googleapis.com/auth/cloud-platform",), - quota_project_id="octopus", - ) - - @pytest.mark.parametrize( "transport_class,grpc_helpers", [ diff --git a/tests/unit/gapic/binaryauthorization_v1/test_validation_helper_v1.py b/tests/unit/gapic/binaryauthorization_v1/test_validation_helper_v1.py index 050220c..5cb80b7 100644 --- a/tests/unit/gapic/binaryauthorization_v1/test_validation_helper_v1.py +++ b/tests/unit/gapic/binaryauthorization_v1/test_validation_helper_v1.py @@ -15,7 +15,6 @@ # import os import mock -import packaging.version import grpc from grpc.experimental import aio @@ -39,9 +38,6 @@ ValidationHelperV1Client, ) from google.cloud.binaryauthorization_v1.services.validation_helper_v1 import transports -from google.cloud.binaryauthorization_v1.services.validation_helper_v1.transports.base import ( - _GOOGLE_AUTH_VERSION, -) from google.cloud.binaryauthorization_v1.types import service from google.oauth2 import service_account from grafeas.grafeas_v1.types import attestation # type: ignore @@ -49,20 +45,6 @@ import google.auth -# TODO(busunkim): Once google-auth >= 1.25.0 is required transitively -# through google-api-core: -# - Delete the auth "less than" test cases -# - Delete these pytest markers (Make the "greater than or equal to" tests the default). -requires_google_auth_lt_1_25_0 = pytest.mark.skipif( - packaging.version.parse(_GOOGLE_AUTH_VERSION) >= packaging.version.parse("1.25.0"), - reason="This test requires google-auth < 1.25.0", -) -requires_google_auth_gte_1_25_0 = pytest.mark.skipif( - packaging.version.parse(_GOOGLE_AUTH_VERSION) < packaging.version.parse("1.25.0"), - reason="This test requires google-auth >= 1.25.0", -) - - def client_cert_source_callback(): return b"cert bytes", b"key bytes" @@ -220,7 +202,7 @@ def test_validation_helper_v1_client_client_options( options = client_options.ClientOptions(api_endpoint="squid.clam.whelk") with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class(client_options=options) + client = client_class(transport=transport_name, client_options=options) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -237,7 +219,7 @@ def test_validation_helper_v1_client_client_options( with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "never"}): with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class() + client = client_class(transport=transport_name) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -254,7 +236,7 @@ def test_validation_helper_v1_client_client_options( with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "always"}): with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class() + client = client_class(transport=transport_name) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -283,7 +265,7 @@ def test_validation_helper_v1_client_client_options( options = client_options.ClientOptions(quota_project_id="octopus") with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class(client_options=options) + client = client_class(transport=transport_name, client_options=options) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -352,7 +334,7 @@ def test_validation_helper_v1_client_mtls_env_auto( ) with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class(client_options=options) + client = client_class(transport=transport_name, client_options=options) if use_client_cert_env == "false": expected_client_cert_source = None @@ -394,7 +376,7 @@ def test_validation_helper_v1_client_mtls_env_auto( expected_client_cert_source = client_cert_source_callback patched.return_value = None - client = client_class() + client = client_class(transport=transport_name) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -416,7 +398,7 @@ def test_validation_helper_v1_client_mtls_env_auto( return_value=False, ): patched.return_value = None - client = client_class() + client = client_class(transport=transport_name) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -447,7 +429,7 @@ def test_validation_helper_v1_client_client_options_scopes( options = client_options.ClientOptions(scopes=["1", "2"],) with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class(client_options=options) + client = client_class(transport=transport_name, client_options=options) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -478,7 +460,7 @@ def test_validation_helper_v1_client_client_options_credentials_file( 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) + client = client_class(transport=transport_name, client_options=options) patched.assert_called_once_with( credentials=None, credentials_file="credentials.json", @@ -777,7 +759,6 @@ def test_validation_helper_v1_base_transport(): transport.close() -@requires_google_auth_gte_1_25_0 def test_validation_helper_v1_base_transport_with_credentials_file(): # Instantiate the base transport with a credentials file with mock.patch.object( @@ -798,26 +779,6 @@ def test_validation_helper_v1_base_transport_with_credentials_file(): ) -@requires_google_auth_lt_1_25_0 -def test_validation_helper_v1_base_transport_with_credentials_file_old_google_auth(): - # Instantiate the base transport with a credentials file - with mock.patch.object( - google.auth, "load_credentials_from_file", autospec=True - ) as load_creds, mock.patch( - "google.cloud.binaryauthorization_v1.services.validation_helper_v1.transports.ValidationHelperV1Transport._prep_wrapped_messages" - ) as Transport: - Transport.return_value = None - load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) - transport = transports.ValidationHelperV1Transport( - credentials_file="credentials.json", quota_project_id="octopus", - ) - load_creds.assert_called_once_with( - "credentials.json", - scopes=("https://www.googleapis.com/auth/cloud-platform",), - quota_project_id="octopus", - ) - - def test_validation_helper_v1_base_transport_with_adc(): # Test the default credentials are used if credentials and credentials_file are None. with mock.patch.object(google.auth, "default", autospec=True) as adc, mock.patch( @@ -829,7 +790,6 @@ def test_validation_helper_v1_base_transport_with_adc(): adc.assert_called_once() -@requires_google_auth_gte_1_25_0 def test_validation_helper_v1_auth_adc(): # If no credentials are provided, we should use ADC credentials. with mock.patch.object(google.auth, "default", autospec=True) as adc: @@ -842,18 +802,6 @@ def test_validation_helper_v1_auth_adc(): ) -@requires_google_auth_lt_1_25_0 -def test_validation_helper_v1_auth_adc_old_google_auth(): - # If no credentials are provided, we should use ADC credentials. - with mock.patch.object(google.auth, "default", autospec=True) as adc: - adc.return_value = (ga_credentials.AnonymousCredentials(), None) - ValidationHelperV1Client() - adc.assert_called_once_with( - scopes=("https://www.googleapis.com/auth/cloud-platform",), - quota_project_id=None, - ) - - @pytest.mark.parametrize( "transport_class", [ @@ -861,7 +809,6 @@ def test_validation_helper_v1_auth_adc_old_google_auth(): transports.ValidationHelperV1GrpcAsyncIOTransport, ], ) -@requires_google_auth_gte_1_25_0 def test_validation_helper_v1_transport_auth_adc(transport_class): # If credentials and host are not provided, the transport class should use # ADC credentials. @@ -875,26 +822,6 @@ def test_validation_helper_v1_transport_auth_adc(transport_class): ) -@pytest.mark.parametrize( - "transport_class", - [ - transports.ValidationHelperV1GrpcTransport, - transports.ValidationHelperV1GrpcAsyncIOTransport, - ], -) -@requires_google_auth_lt_1_25_0 -def test_validation_helper_v1_transport_auth_adc_old_google_auth(transport_class): - # If credentials and host are not provided, the transport class should use - # ADC credentials. - with mock.patch.object(google.auth, "default", autospec=True) as adc: - adc.return_value = (ga_credentials.AnonymousCredentials(), None) - transport_class(quota_project_id="octopus") - adc.assert_called_once_with( - scopes=("https://www.googleapis.com/auth/cloud-platform",), - quota_project_id="octopus", - ) - - @pytest.mark.parametrize( "transport_class,grpc_helpers", [ diff --git a/tests/unit/gapic/binaryauthorization_v1beta1/test_binauthz_management_service_v1_beta1.py b/tests/unit/gapic/binaryauthorization_v1beta1/test_binauthz_management_service_v1_beta1.py index e553978..a77d6a1 100644 --- a/tests/unit/gapic/binaryauthorization_v1beta1/test_binauthz_management_service_v1_beta1.py +++ b/tests/unit/gapic/binaryauthorization_v1beta1/test_binauthz_management_service_v1_beta1.py @@ -15,7 +15,6 @@ # import os import mock -import packaging.version import grpc from grpc.experimental import aio @@ -44,9 +43,6 @@ from google.cloud.binaryauthorization_v1beta1.services.binauthz_management_service_v1_beta1 import ( transports, ) -from google.cloud.binaryauthorization_v1beta1.services.binauthz_management_service_v1_beta1.transports.base import ( - _GOOGLE_AUTH_VERSION, -) from google.cloud.binaryauthorization_v1beta1.types import resources from google.cloud.binaryauthorization_v1beta1.types import service from google.oauth2 import service_account @@ -54,20 +50,6 @@ import google.auth -# TODO(busunkim): Once google-auth >= 1.25.0 is required transitively -# through google-api-core: -# - Delete the auth "less than" test cases -# - Delete these pytest markers (Make the "greater than or equal to" tests the default). -requires_google_auth_lt_1_25_0 = pytest.mark.skipif( - packaging.version.parse(_GOOGLE_AUTH_VERSION) >= packaging.version.parse("1.25.0"), - reason="This test requires google-auth < 1.25.0", -) -requires_google_auth_gte_1_25_0 = pytest.mark.skipif( - packaging.version.parse(_GOOGLE_AUTH_VERSION) < packaging.version.parse("1.25.0"), - reason="This test requires google-auth >= 1.25.0", -) - - def client_cert_source_callback(): return b"cert bytes", b"key bytes" @@ -256,7 +238,7 @@ def test_binauthz_management_service_v1_beta1_client_client_options( options = client_options.ClientOptions(api_endpoint="squid.clam.whelk") with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class(client_options=options) + client = client_class(transport=transport_name, client_options=options) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -273,7 +255,7 @@ def test_binauthz_management_service_v1_beta1_client_client_options( with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "never"}): with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class() + client = client_class(transport=transport_name) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -290,7 +272,7 @@ def test_binauthz_management_service_v1_beta1_client_client_options( with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "always"}): with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class() + client = client_class(transport=transport_name) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -319,7 +301,7 @@ def test_binauthz_management_service_v1_beta1_client_client_options( options = client_options.ClientOptions(quota_project_id="octopus") with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class(client_options=options) + client = client_class(transport=transport_name, client_options=options) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -388,7 +370,7 @@ def test_binauthz_management_service_v1_beta1_client_mtls_env_auto( ) with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class(client_options=options) + client = client_class(transport=transport_name, client_options=options) if use_client_cert_env == "false": expected_client_cert_source = None @@ -430,7 +412,7 @@ def test_binauthz_management_service_v1_beta1_client_mtls_env_auto( expected_client_cert_source = client_cert_source_callback patched.return_value = None - client = client_class() + client = client_class(transport=transport_name) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -452,7 +434,7 @@ def test_binauthz_management_service_v1_beta1_client_mtls_env_auto( return_value=False, ): patched.return_value = None - client = client_class() + client = client_class(transport=transport_name) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -487,7 +469,7 @@ def test_binauthz_management_service_v1_beta1_client_client_options_scopes( options = client_options.ClientOptions(scopes=["1", "2"],) with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class(client_options=options) + client = client_class(transport=transport_name, client_options=options) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -522,7 +504,7 @@ def test_binauthz_management_service_v1_beta1_client_client_options_credentials_ 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) + client = client_class(transport=transport_name, client_options=options) patched.assert_called_once_with( credentials=None, credentials_file="credentials.json", @@ -2332,7 +2314,6 @@ def test_binauthz_management_service_v1_beta1_base_transport(): transport.close() -@requires_google_auth_gte_1_25_0 def test_binauthz_management_service_v1_beta1_base_transport_with_credentials_file(): # Instantiate the base transport with a credentials file with mock.patch.object( @@ -2353,26 +2334,6 @@ def test_binauthz_management_service_v1_beta1_base_transport_with_credentials_fi ) -@requires_google_auth_lt_1_25_0 -def test_binauthz_management_service_v1_beta1_base_transport_with_credentials_file_old_google_auth(): - # Instantiate the base transport with a credentials file - with mock.patch.object( - google.auth, "load_credentials_from_file", autospec=True - ) as load_creds, mock.patch( - "google.cloud.binaryauthorization_v1beta1.services.binauthz_management_service_v1_beta1.transports.BinauthzManagementServiceV1Beta1Transport._prep_wrapped_messages" - ) as Transport: - Transport.return_value = None - load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) - transport = transports.BinauthzManagementServiceV1Beta1Transport( - credentials_file="credentials.json", quota_project_id="octopus", - ) - load_creds.assert_called_once_with( - "credentials.json", - scopes=("https://www.googleapis.com/auth/cloud-platform",), - quota_project_id="octopus", - ) - - def test_binauthz_management_service_v1_beta1_base_transport_with_adc(): # Test the default credentials are used if credentials and credentials_file are None. with mock.patch.object(google.auth, "default", autospec=True) as adc, mock.patch( @@ -2384,7 +2345,6 @@ def test_binauthz_management_service_v1_beta1_base_transport_with_adc(): adc.assert_called_once() -@requires_google_auth_gte_1_25_0 def test_binauthz_management_service_v1_beta1_auth_adc(): # If no credentials are provided, we should use ADC credentials. with mock.patch.object(google.auth, "default", autospec=True) as adc: @@ -2397,18 +2357,6 @@ def test_binauthz_management_service_v1_beta1_auth_adc(): ) -@requires_google_auth_lt_1_25_0 -def test_binauthz_management_service_v1_beta1_auth_adc_old_google_auth(): - # If no credentials are provided, we should use ADC credentials. - with mock.patch.object(google.auth, "default", autospec=True) as adc: - adc.return_value = (ga_credentials.AnonymousCredentials(), None) - BinauthzManagementServiceV1Beta1Client() - adc.assert_called_once_with( - scopes=("https://www.googleapis.com/auth/cloud-platform",), - quota_project_id=None, - ) - - @pytest.mark.parametrize( "transport_class", [ @@ -2416,7 +2364,6 @@ def test_binauthz_management_service_v1_beta1_auth_adc_old_google_auth(): transports.BinauthzManagementServiceV1Beta1GrpcAsyncIOTransport, ], ) -@requires_google_auth_gte_1_25_0 def test_binauthz_management_service_v1_beta1_transport_auth_adc(transport_class): # If credentials and host are not provided, the transport class should use # ADC credentials. @@ -2430,28 +2377,6 @@ def test_binauthz_management_service_v1_beta1_transport_auth_adc(transport_class ) -@pytest.mark.parametrize( - "transport_class", - [ - transports.BinauthzManagementServiceV1Beta1GrpcTransport, - transports.BinauthzManagementServiceV1Beta1GrpcAsyncIOTransport, - ], -) -@requires_google_auth_lt_1_25_0 -def test_binauthz_management_service_v1_beta1_transport_auth_adc_old_google_auth( - transport_class, -): - # If credentials and host are not provided, the transport class should use - # ADC credentials. - with mock.patch.object(google.auth, "default", autospec=True) as adc: - adc.return_value = (ga_credentials.AnonymousCredentials(), None) - transport_class(quota_project_id="octopus") - adc.assert_called_once_with( - scopes=("https://www.googleapis.com/auth/cloud-platform",), - quota_project_id="octopus", - ) - - @pytest.mark.parametrize( "transport_class,grpc_helpers", [