test(spanner): clear context-aware mTLS env var in unit tests#17838
test(spanner): clear context-aware mTLS env var in unit tests#17838sakthivelmanii wants to merge 1 commit into
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
1f56844
Compare
Unset CLOUDSDK_CONTEXT_AWARE_USE_CLIENT_CERTIFICATE in mTLS unit tests to prevent failures in Google and Kokoro CI environments.
1f56844 to
a03427a
Compare
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> 🦕