Skip to content
This repository was archived by the owner on Nov 12, 2025. It is now read-only.

Commit 89ba292

Browse files
fix: skip some system tests for mtls testing (#106)
1 parent bcec3ea commit 89ba292

1 file changed

Lines changed: 20 additions & 3 deletions

File tree

tests/system/v1/conftest.py

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,20 @@ def project_id():
3333

3434

3535
@pytest.fixture(scope="session")
36-
def credentials():
36+
def use_mtls():
37+
return "always" == os.environ.get("GOOGLE_API_USE_MTLS_ENDPOINT", "never")
38+
39+
40+
@pytest.fixture(scope="session")
41+
def credentials(use_mtls):
42+
import google.auth
3743
from google.oauth2 import service_account
3844

45+
if use_mtls:
46+
# mTLS test uses user credentials instead of service account credentials
47+
creds, _ = google.auth.default()
48+
return creds
49+
3950
# NOTE: the test config in noxfile checks that the env variable is indeed set
4051
filename = os.environ["GOOGLE_APPLICATION_CREDENTIALS"]
4152
return service_account.Credentials.from_service_account_file(filename)
@@ -59,7 +70,11 @@ def small_table_reference():
5970

6071

6172
@pytest.fixture(scope="session")
62-
def local_shakespeare_table_reference(project_id):
73+
def local_shakespeare_table_reference(project_id, use_mtls):
74+
if use_mtls:
75+
pytest.skip(
76+
"Skip it for mTLS testing since the table does not exist for mTLS project"
77+
)
6378
return _TABLE_FORMAT.format(project_id, "public_samples_copy", "shakespeare")
6479

6580

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

101116

102117
@pytest.fixture(scope="session")
103-
def bq_client(credentials):
118+
def bq_client(credentials, use_mtls):
119+
if use_mtls:
120+
pytest.skip("Skip it for mTLS testing since bigquery does not support mTLS")
104121
from google.cloud import bigquery
105122

106123
return bigquery.Client(credentials=credentials)

0 commit comments

Comments
 (0)