Skip to content
This repository has been archived by the owner on Dec 31, 2023. It is now read-only.

Commit

Permalink
test: add system test for mtls (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
arithmetic1728 committed Jan 21, 2021
1 parent b9def52 commit 3ce1bca
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
5 changes: 5 additions & 0 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
33 changes: 33 additions & 0 deletions tests/system.py
Original file line number Diff line number Diff line change
@@ -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")

0 comments on commit 3ce1bca

Please sign in to comment.