Skip to content

Commit 19908ed

Browse files
fix: update GOOGLE_API_USE_MTLS values (#940)
1 parent 47ca361 commit 19908ed

File tree

2 files changed

+17
-17
lines changed

2 files changed

+17
-17
lines changed

Diff for: googleapiclient/discovery.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -471,17 +471,17 @@ def build_from_document(
471471
not client_options or not client_options.api_endpoint
472472
):
473473
mtls_endpoint = urljoin(service["mtlsRootUrl"], service["servicePath"])
474-
use_mtls_env = os.getenv("GOOGLE_API_USE_MTLS", "Never")
474+
use_mtls_env = os.getenv("GOOGLE_API_USE_MTLS", "never")
475475

476-
if not use_mtls_env in ("Never", "Auto", "Always"):
476+
if not use_mtls_env in ("never", "auto", "always"):
477477
raise MutualTLSChannelError(
478-
"Unsupported GOOGLE_API_USE_MTLS value. Accepted values: Never, Auto, Always"
478+
"Unsupported GOOGLE_API_USE_MTLS value. Accepted values: never, auto, always"
479479
)
480480

481-
# Switch to mTLS endpoint, if environment variable is "Always", or
482-
# environment varibable is "Auto" and client cert exists.
483-
if use_mtls_env == "Always" or (
484-
use_mtls_env == "Auto" and client_cert_to_use
481+
# Switch to mTLS endpoint, if environment variable is "always", or
482+
# environment varibable is "auto" and client cert exists.
483+
if use_mtls_env == "always" or (
484+
use_mtls_env == "auto" and client_cert_to_use
485485
):
486486
base = mtls_endpoint
487487

Diff for: tests/test_discovery.py

+10-10
Original file line numberDiff line numberDiff line change
@@ -590,9 +590,9 @@ def test_exception_with_client_cert_source(self):
590590

591591
@parameterized.expand(
592592
[
593-
("Never", REGULAR_ENDPOINT),
594-
("Auto", MTLS_ENDPOINT),
595-
("Always", MTLS_ENDPOINT),
593+
("never", REGULAR_ENDPOINT),
594+
("auto", MTLS_ENDPOINT),
595+
("always", MTLS_ENDPOINT),
596596
]
597597
)
598598
def test_mtls_with_provided_client_cert(self, use_mtls_env, base_url):
@@ -610,7 +610,7 @@ def test_mtls_with_provided_client_cert(self, use_mtls_env, base_url):
610610
self.check_http_client_cert(plus, has_client_cert=True)
611611
self.assertEqual(plus._baseUrl, base_url)
612612

613-
@parameterized.expand(["Never", "Auto", "Always"])
613+
@parameterized.expand(["never", "auto", "always"])
614614
def test_endpoint_not_switch(self, use_mtls_env):
615615
# Test endpoint is not switched if user provided api endpoint
616616
discovery = open(datafile("plus.json")).read()
@@ -630,9 +630,9 @@ def test_endpoint_not_switch(self, use_mtls_env):
630630

631631
@parameterized.expand(
632632
[
633-
("Never", REGULAR_ENDPOINT),
634-
("Auto", MTLS_ENDPOINT),
635-
("Always", MTLS_ENDPOINT),
633+
("never", REGULAR_ENDPOINT),
634+
("auto", MTLS_ENDPOINT),
635+
("always", MTLS_ENDPOINT),
636636
]
637637
)
638638
@mock.patch(
@@ -667,9 +667,9 @@ def test_mtls_with_default_client_cert(
667667

668668
@parameterized.expand(
669669
[
670-
("Never", REGULAR_ENDPOINT),
671-
("Auto", REGULAR_ENDPOINT),
672-
("Always", MTLS_ENDPOINT),
670+
("never", REGULAR_ENDPOINT),
671+
("auto", REGULAR_ENDPOINT),
672+
("always", MTLS_ENDPOINT),
673673
]
674674
)
675675
@mock.patch(

0 commit comments

Comments
 (0)