Skip to content
This repository was archived by the owner on Dec 31, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,17 @@
from typing import Dict, Sequence, Tuple, Type, Union
import pkg_resources

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.api_core.client_options import ClientOptions
from google.api_core import exceptions as core_exceptions
from google.api_core import gapic_v1
from google.api_core import retry as retries
from google.auth import credentials as ga_credentials # type: ignore
from google.oauth2 import service_account # type: ignore

OptionalRetry = Union[retries.Retry, object]
try:
OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault]
except AttributeError: # pragma: NO COVER
OptionalRetry = Union[retries.Retry, object] # type: ignore

from google.cloud.devtools.containeranalysis_v1.types import containeranalysis
from google.iam.v1 import iam_policy_pb2 # type: ignore
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,25 @@
# limitations under the License.
#
from collections import OrderedDict
from distutils import util
import os
import re
from typing import Dict, Optional, Sequence, Tuple, Type, Union
import pkg_resources

from google.api_core import client_options as client_options_lib # 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.api_core import client_options as client_options_lib
from google.api_core import exceptions as core_exceptions
from google.api_core import gapic_v1
from google.api_core import retry as retries
from google.auth import credentials as ga_credentials # type: ignore
from google.auth.transport import mtls # type: ignore
from google.auth.transport.grpc import SslCredentials # type: ignore
from google.auth.exceptions import MutualTLSChannelError # type: ignore
from google.oauth2 import service_account # type: ignore

OptionalRetry = Union[retries.Retry, object]
try:
OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault]
except AttributeError: # pragma: NO COVER
OptionalRetry = Union[retries.Retry, object] # type: ignore

from google.cloud.devtools.containeranalysis_v1.types import containeranalysis
from google.iam.v1 import iam_policy_pb2 # type: ignore
Expand Down Expand Up @@ -289,8 +291,15 @@ def __init__(
client_options = client_options_lib.ClientOptions()

# Create SSL credentials for mutual TLS if needed.
use_client_cert = bool(
util.strtobool(os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false"))
if os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") not in (
"true",
"false",
):
raise ValueError(
"Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`"
)
use_client_cert = (
os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") == "true"
)

client_cert_source_func = None
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
import pkg_resources

import google.auth # type: ignore
import google.api_core # 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
import google.api_core
from google.api_core import exceptions as core_exceptions
from google.api_core import gapic_v1
from google.api_core import retry as retries
from google.auth import credentials as ga_credentials # type: ignore
from google.oauth2 import service_account # type: ignore

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
import warnings
from typing import Callable, Dict, Optional, Sequence, Tuple, Union

from google.api_core import grpc_helpers # type: ignore
from google.api_core import gapic_v1 # type: ignore
from google.api_core import grpc_helpers
from google.api_core import gapic_v1
import google.auth # type: ignore
from google.auth import credentials as ga_credentials # type: ignore
from google.auth.transport.grpc import SslCredentials # type: ignore
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
import warnings
from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union

from google.api_core import gapic_v1 # type: ignore
from google.api_core import grpc_helpers_async # type: ignore
from google.api_core import gapic_v1
from google.api_core import grpc_helpers_async
from google.auth import credentials as ga_credentials # type: ignore
from google.auth.transport.grpc import SslCredentials # type: ignore

Expand Down
48 changes: 36 additions & 12 deletions tests/unit/gapic/containeranalysis_v1/test_container_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,9 @@ def test_set_iam_policy_flattened():
# request object values.
assert len(call.mock_calls) == 1
_, args, _ = call.mock_calls[0]
assert args[0].resource == "resource_value"
arg = args[0].resource
mock_val = "resource_value"
assert arg == mock_val


def test_set_iam_policy_flattened_error():
Expand Down Expand Up @@ -695,7 +697,9 @@ async def test_set_iam_policy_flattened_async():
# request object values.
assert len(call.mock_calls)
_, args, _ = call.mock_calls[0]
assert args[0].resource == "resource_value"
arg = args[0].resource
mock_val = "resource_value"
assert arg == mock_val


@pytest.mark.asyncio
Expand Down Expand Up @@ -876,7 +880,9 @@ def test_get_iam_policy_flattened():
# request object values.
assert len(call.mock_calls) == 1
_, args, _ = call.mock_calls[0]
assert args[0].resource == "resource_value"
arg = args[0].resource
mock_val = "resource_value"
assert arg == mock_val


def test_get_iam_policy_flattened_error():
Expand Down Expand Up @@ -910,7 +916,9 @@ async def test_get_iam_policy_flattened_async():
# request object values.
assert len(call.mock_calls)
_, args, _ = call.mock_calls[0]
assert args[0].resource == "resource_value"
arg = args[0].resource
mock_val = "resource_value"
assert arg == mock_val


@pytest.mark.asyncio
Expand Down Expand Up @@ -1112,8 +1120,12 @@ def test_test_iam_permissions_flattened():
# request object values.
assert len(call.mock_calls) == 1
_, args, _ = call.mock_calls[0]
assert args[0].resource == "resource_value"
assert args[0].permissions == ["permissions_value"]
arg = args[0].resource
mock_val = "resource_value"
assert arg == mock_val
arg = args[0].permissions
mock_val = ["permissions_value"]
assert arg == mock_val


def test_test_iam_permissions_flattened_error():
Expand Down Expand Up @@ -1155,8 +1167,12 @@ async def test_test_iam_permissions_flattened_async():
# request object values.
assert len(call.mock_calls)
_, args, _ = call.mock_calls[0]
assert args[0].resource == "resource_value"
assert args[0].permissions == ["permissions_value"]
arg = args[0].resource
mock_val = "resource_value"
assert arg == mock_val
arg = args[0].permissions
mock_val = ["permissions_value"]
assert arg == mock_val


@pytest.mark.asyncio
Expand Down Expand Up @@ -1338,8 +1354,12 @@ def test_get_vulnerability_occurrences_summary_flattened():
# request object values.
assert len(call.mock_calls) == 1
_, args, _ = call.mock_calls[0]
assert args[0].parent == "parent_value"
assert args[0].filter == "filter_value"
arg = args[0].parent
mock_val = "parent_value"
assert arg == mock_val
arg = args[0].filter
mock_val = "filter_value"
assert arg == mock_val


def test_get_vulnerability_occurrences_summary_flattened_error():
Expand Down Expand Up @@ -1381,8 +1401,12 @@ async def test_get_vulnerability_occurrences_summary_flattened_async():
# request object values.
assert len(call.mock_calls)
_, args, _ = call.mock_calls[0]
assert args[0].parent == "parent_value"
assert args[0].filter == "filter_value"
arg = args[0].parent
mock_val = "parent_value"
assert arg == mock_val
arg = args[0].filter
mock_val = "filter_value"
assert arg == mock_val


@pytest.mark.asyncio
Expand Down