Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: skip some system tests for mtls testing #106

Merged
merged 1 commit into from Jan 5, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
23 changes: 20 additions & 3 deletions tests/system/v1/conftest.py
Expand Up @@ -33,9 +33,20 @@ def project_id():


@pytest.fixture(scope="session")
def credentials():
def use_mtls():
return "always" == os.environ.get("GOOGLE_API_USE_MTLS_ENDPOINT", "never")


@pytest.fixture(scope="session")
def credentials(use_mtls):
import google.auth
from google.oauth2 import service_account

if use_mtls:
# mTLS test uses user credentials instead of service account credentials
creds, _ = google.auth.default()
return creds

# NOTE: the test config in noxfile checks that the env variable is indeed set
filename = os.environ["GOOGLE_APPLICATION_CREDENTIALS"]
return service_account.Credentials.from_service_account_file(filename)
Expand All @@ -59,7 +70,11 @@ def small_table_reference():


@pytest.fixture(scope="session")
def local_shakespeare_table_reference(project_id):
def local_shakespeare_table_reference(project_id, use_mtls):
if use_mtls:
pytest.skip(
"Skip it for mTLS testing since the table does not exist for mTLS project"
)
return _TABLE_FORMAT.format(project_id, "public_samples_copy", "shakespeare")


Expand Down Expand Up @@ -100,7 +115,9 @@ def table(project_id, dataset, bq_client):


@pytest.fixture(scope="session")
def bq_client(credentials):
def bq_client(credentials, use_mtls):
if use_mtls:
pytest.skip("Skip it for mTLS testing since bigquery does not support mTLS")
from google.cloud import bigquery

return bigquery.Client(credentials=credentials)
Expand Down