aboutsummaryrefslogtreecommitdiff
path: root/system_tests
diff options
context:
space:
mode:
authorarithmetic1728 <58957152+arithmetic1728@users.noreply.github.com>2020-08-27 14:05:30 -0700
committerGitHub <noreply@github.com>2020-08-27 14:05:30 -0700
commitc0c995f3de237a2346b59797ee7c4d44ff2a197c (patch)
treee63b7688cbbff802ba769c39d8bf0a610e2538cc /system_tests
parentae27b49468c5c3db99d0550af9066ca43cb0dda7 (diff)
downloadgoogle-auth-library-python-c0c995f3de237a2346b59797ee7c4d44ff2a197c.tar.gz
feat: add GOOGLE_API_USE_CLIENT_CERTIFICATE support (#592)
Diffstat (limited to 'system_tests')
-rw-r--r--system_tests/test_mtls_http.py21
1 files changed, 13 insertions, 8 deletions
diff --git a/system_tests/test_mtls_http.py b/system_tests/test_mtls_http.py
index 4a6a9c4..7c56496 100644
--- a/system_tests/test_mtls_http.py
+++ b/system_tests/test_mtls_http.py
@@ -18,6 +18,7 @@ import time
import google.auth
import google.auth.credentials
+from google.auth import environment_vars
from google.auth.transport import mtls
import google.auth.transport.requests
import google.auth.transport.urllib3
@@ -33,7 +34,8 @@ def test_requests():
)
authed_session = google.auth.transport.requests.AuthorizedSession(credentials)
- authed_session.configure_mtls_channel()
+ with mock.patch.dict(os.environ, {environment_vars.GOOGLE_API_USE_CLIENT_CERTIFICATE: "true"}):
+ authed_session.configure_mtls_channel()
# If the devices has default client cert source, then a mutual TLS channel
# is supposed to be created.
@@ -57,7 +59,8 @@ def test_urllib3():
)
authed_http = google.auth.transport.urllib3.AuthorizedHttp(credentials)
- is_mtls = authed_http.configure_mtls_channel()
+ with mock.patch.dict(os.environ, {environment_vars.GOOGLE_API_USE_CLIENT_CERTIFICATE: "true"}):
+ is_mtls = authed_http.configure_mtls_channel()
# If the devices has default client cert source, then a mutual TLS channel
# is supposed to be created.
@@ -83,9 +86,10 @@ def test_requests_with_default_client_cert_source():
authed_session = google.auth.transport.requests.AuthorizedSession(credentials)
if mtls.has_default_client_cert_source():
- authed_session.configure_mtls_channel(
- client_cert_callback=mtls.default_client_cert_source()
- )
+ with mock.patch.dict(os.environ, {environment_vars.GOOGLE_API_USE_CLIENT_CERTIFICATE: "true"}):
+ authed_session.configure_mtls_channel(
+ client_cert_callback=mtls.default_client_cert_source()
+ )
assert authed_session.is_mtls
@@ -105,9 +109,10 @@ def test_urllib3_with_default_client_cert_source():
authed_http = google.auth.transport.urllib3.AuthorizedHttp(credentials)
if mtls.has_default_client_cert_source():
- assert authed_http.configure_mtls_channel(
- client_cert_callback=mtls.default_client_cert_source()
- )
+ with mock.patch.dict(os.environ, {environment_vars.GOOGLE_API_USE_CLIENT_CERTIFICATE: "true"}):
+ assert authed_http.configure_mtls_channel(
+ client_cert_callback=mtls.default_client_cert_source()
+ )
# Sleep 1 second to avoid 503 error.
time.sleep(1)