Uh oh!
There was an error while loading. Please reload this page.
test(spanner): clear context-aware mTLS env var in unit tests - #17838
Conversation
There was a problem hiding this comment.
Code Review
This pull request updates the GAPIC generator templates and Google Cloud Spanner unit tests to properly handle the CLOUDSDK_CONTEXT_AWARE_USE_CLIENT_CERTIFICATE environment variable by popping it during mTLS endpoint tests. It also sets GOOGLE_API_USE_CLIENT_CERTIFICATE to "false" when testing specific GOOGLE_API_USE_MTLS_ENDPOINT behaviors. The reviewer recommends also explicitly setting CLOUDSDK_CONTEXT_AWARE_USE_CLIENT_CERTIFICATE to "false" in those same test cases to avoid test failures in environments where it is set to "true".
| # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "never". | ||
| with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "never"}): | ||
| with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "never", "GOOGLE_API_USE_CLIENT_CERTIFICATE": "false"}): |
There was a problem hiding this comment.
To prevent test failures in environments where CLOUDSDK_CONTEXT_AWARE_USE_CLIENT_CERTIFICATE is set to "true", we should also explicitly set it to "false" in this mock.patch.dict call, similar to how GOOGLE_API_USE_CLIENT_CERTIFICATE is handled.
with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "never", "GOOGLE_API_USE_CLIENT_CERTIFICATE": "false", "CLOUDSDK_CONTEXT_AWARE_USE_CLIENT_CERTIFICATE": "false"}):
| # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "always". | ||
| with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "always"}): | ||
| with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "always", "GOOGLE_API_USE_CLIENT_CERTIFICATE": "false"}): |
There was a problem hiding this comment.
To prevent test failures in environments where CLOUDSDK_CONTEXT_AWARE_USE_CLIENT_CERTIFICATE is set to "true", we should also explicitly set it to "false" in this mock.patch.dict call, similar to how GOOGLE_API_USE_CLIENT_CERTIFICATE is handled.
with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "always", "GOOGLE_API_USE_CLIENT_CERTIFICATE": "false", "CLOUDSDK_CONTEXT_AWARE_USE_CLIENT_CERTIFICATE": "false"}):
1be920c to
1f56844CompareUnset CLOUDSDK_CONTEXT_AWARE_USE_CLIENT_CERTIFICATE in mTLS unit tests to prevent failures in Google and Kokoro CI environments.
1f56844 to
a03427aCompareparthea
commented
Jul 23, 2026
Wait for #17880 to be merged first |
@sakthivelmanii , Please could you resolve the conflicts? |
parthea
commented
Jul 24, 2026
These are auto-generated files. I'll take a look |
Fixed |
Uh oh!
There was an error while loading. Please reload this page.
Unset CLOUDSDK_CONTEXT_AWARE_USE_CLIENT_CERTIFICATE in mTLS unit tests to prevent failures in Google and Kokoro CI environments.
Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly:
Fixes #<issue_number_goes_here> 🦕