@@ -81,6 +81,7 @@ class Config(object):
8181
8282 CLIENT = None
8383 TEST_BUCKET = None
84+ TESTING_MTLS = False
8485
8586
8687def setUpModule ():
@@ -91,6 +92,10 @@ def setUpModule():
9192 Config .TEST_BUCKET = Config .CLIENT .bucket (bucket_name )
9293 Config .TEST_BUCKET .versioning_enabled = True
9394 retry_429_503 (Config .TEST_BUCKET .create )()
95+ # mTLS testing uses the system test as well. For mTLS testing,
96+ # GOOGLE_API_USE_CLIENT_CERTIFICATE env var will be set to "true"
97+ # explicitly.
98+ Config .TESTING_MTLS = (os .getenv ("GOOGLE_API_USE_CLIENT_CERTIFICATE" ) == "true" )
9499
95100
96101def tearDownModule ():
@@ -101,6 +106,14 @@ def tearDownModule():
101106
102107
103108class TestClient (unittest .TestCase ):
109+ @classmethod
110+ def setUpClass (cls ):
111+ if (
112+ type (Config .CLIENT ._credentials )
113+ is not google .oauth2 .service_account .Credentials
114+ ):
115+ cls .skipTest (self = cls , reason = "These tests require a service account credential" )
116+
104117 def setUp (self ):
105118 self .case_hmac_keys_to_delete = []
106119
@@ -563,6 +576,15 @@ def tearDown(self):
563576class TestStorageWriteFiles (TestStorageFiles ):
564577 ENCRYPTION_KEY = "b23ff11bba187db8c37077e6af3b25b8"
565578
579+ @classmethod
580+ def setUpClass (cls ):
581+ if (
582+ type (Config .CLIENT ._credentials )
583+ is not google .oauth2 .service_account .Credentials
584+ ):
585+ cls .skipTest (self = cls , reason = "These tests require a service account credential" )
586+
587+
566588 def test_large_file_write_from_stream (self ):
567589 blob = self .bucket .blob ("LargeFile" )
568590
@@ -1264,7 +1286,7 @@ def setUpClass(cls):
12641286 type (Config .CLIENT ._credentials )
12651287 is not google .oauth2 .service_account .Credentials
12661288 ):
1267- cls .skipTest ("Signing tests requires a service account credential" )
1289+ cls .skipTest (self = cls , reason = "Signing tests requires a service account credential" )
12681290
12691291 bucket_name = "gcp-signing" + unique_resource_id ()
12701292 cls .bucket = retry_429_503 (Config .CLIENT .create_bucket )(bucket_name )
@@ -1825,6 +1847,11 @@ class TestStorageNotificationCRUD(unittest.TestCase):
18251847 CUSTOM_ATTRIBUTES = {"attr1" : "value1" , "attr2" : "value2" }
18261848 BLOB_NAME_PREFIX = "blob-name-prefix/"
18271849
1850+ @classmethod
1851+ def setUpClass (cls ):
1852+ if Config .TESTING_MTLS :
1853+ cls .skipTest (self = cls , reason = "Skip pubsub tests for mTLS testing" )
1854+
18281855 @property
18291856 def topic_path (self ):
18301857 return "projects/{}/topics/{}" .format (Config .CLIENT .project , self .TOPIC_NAME )
@@ -1987,6 +2014,8 @@ def _kms_key_name(self, key_name=None):
19872014
19882015 @classmethod
19892016 def setUpClass (cls ):
2017+ if Config .TESTING_MTLS :
2018+ cls .skipTest (self = cls , reason = "Skip kms tests for mTLS testing" )
19902019 super (TestKMSIntegration , cls ).setUpClass ()
19912020 _empty_bucket (cls .bucket )
19922021
@@ -2441,6 +2470,14 @@ def test_ubla_set_unset_preserves_acls(self):
24412470
24422471
24432472class TestV4POSTPolicies (unittest .TestCase ):
2473+ @classmethod
2474+ def setUpClass (cls ):
2475+ if (
2476+ type (Config .CLIENT ._credentials )
2477+ is not google .oauth2 .service_account .Credentials
2478+ ):
2479+ cls .skipTest (self = cls , reason = "These tests require a service account credential" )
2480+
24442481 def setUp (self ):
24452482 self .case_buckets_to_delete = []
24462483
0 commit comments