diff --git a/packages/google-cloud-compute/noxfile.py b/packages/google-cloud-compute/noxfile.py index fb09e54a93f2..ff946ee14bf6 100644 --- a/packages/google-cloud-compute/noxfile.py +++ b/packages/google-cloud-compute/noxfile.py @@ -138,6 +138,11 @@ def system(session): ) session.install("-e", ".") + # If mtls is enabled via environment variable + # GOOGLE_API_USE_CLIENT_CERTIFICATE, then pyopenssl is needed. Here we + # install it regardless. + session.install("pyopenssl") + # Run py.test against the system tests. if system_test_exists: session.run("py.test", "--quiet", system_test_path, *session.posargs) diff --git a/packages/google-cloud-compute/tests/system.py b/packages/google-cloud-compute/tests/system.py new file mode 100644 index 000000000000..2a4191546d78 --- /dev/null +++ b/packages/google-cloud-compute/tests/system.py @@ -0,0 +1,33 @@ +# -*- coding: utf-8 -*- +# +# Copyright 2021 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import os +import pytest + +from google.cloud import compute + + +@pytest.fixture(scope="session") +def project_id(): + return os.environ["PROJECT_ID"] + + +def test_list_instances_not_throw_mtls(project_id): + client = compute.InstancesClient() + + # For regular system testing, the following call should never throw. + # For mTLS testing, the call throws if mTLS is not properly configured. + client.list(project=project_id, zone="us-west1-a")