blob: 4ba7cc3efedc358b63cb98993a881b2787309b48 [file] [log] [blame]
Christopher Wilcox7e152582020-09-28 15:27:20 -07001# Copyright 2020 Google LLC
Jon Wayne Parrottbbc39432016-10-27 23:12:39 -07002#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15"""Noxfile for automating system tests.
16
17This file handles setting up environments needed by the system tests. This
18separates the tests from their environment configuration.
19
20See the `nox docs`_ for details on how this file works:
21
22.. _nox docs: http://nox.readthedocs.io/en/latest/
23"""
24
25import os
Jon Wayne Parrottb551ef22016-10-28 12:35:15 -070026import subprocess
Jon Wayne Parrottbbc39432016-10-27 23:12:39 -070027
28from nox.command import which
Bu Sun Kim65e33c02019-10-25 10:45:00 -070029import nox
Jon Wayne Parrottbbc39432016-10-27 23:12:39 -070030import py.path
31
Jon Wayne Parrottb551ef22016-10-28 12:35:15 -070032HERE = os.path.abspath(os.path.dirname(__file__))
Bu Sun Kim621f54b2021-01-22 13:43:41 -070033LIBRARY_DIR = os.path.abspath(os.path.dirname(HERE))
Bu Sun Kim9eec0912019-10-21 17:04:21 -070034DATA_DIR = os.path.join(HERE, "data")
35SERVICE_ACCOUNT_FILE = os.path.join(DATA_DIR, "service_account.json")
36AUTHORIZED_USER_FILE = os.path.join(DATA_DIR, "authorized_user.json")
37EXPLICIT_CREDENTIALS_ENV = "GOOGLE_APPLICATION_CREDENTIALS"
38EXPLICIT_PROJECT_ENV = "GOOGLE_CLOUD_PROJECT"
39EXPECT_PROJECT_ENV = "EXPECT_PROJECT_ID"
Jon Wayne Parrottbbc39432016-10-27 23:12:39 -070040
Bu Sun Kim9eec0912019-10-21 17:04:21 -070041SKIP_GAE_TEST_ENV = "SKIP_APP_ENGINE_SYSTEM_TEST"
42GAE_APP_URL_TMPL = "https://{}-dot-{}.appspot.com"
43GAE_TEST_APP_SERVICE = "google-auth-system-tests"
Jon Wayne Parrottb551ef22016-10-28 12:35:15 -070044
Jon Wayne Parrottbbc39432016-10-27 23:12:39 -070045# The download location for the Cloud SDK
Bu Sun Kim9eec0912019-10-21 17:04:21 -070046CLOUD_SDK_DIST_FILENAME = "google-cloud-sdk.tar.gz"
47CLOUD_SDK_DOWNLOAD_URL = "https://dl.google.com/dl/cloudsdk/release/{}".format(
48 CLOUD_SDK_DIST_FILENAME
49)
Jon Wayne Parrottbbc39432016-10-27 23:12:39 -070050
51# This environment variable is recognized by the Cloud SDK and overrides
52# the location of the SDK's configuration files (which is usually at
53# ${HOME}/.config).
Bu Sun Kim9eec0912019-10-21 17:04:21 -070054CLOUD_SDK_CONFIG_ENV = "CLOUDSDK_CONFIG"
Jon Wayne Parrottbbc39432016-10-27 23:12:39 -070055
56# If set, this is where the environment setup will install the Cloud SDK.
57# If unset, it will download the SDK to a temporary directory.
Bu Sun Kim9eec0912019-10-21 17:04:21 -070058CLOUD_SDK_ROOT = os.environ.get("CLOUD_SDK_ROOT")
Jon Wayne Parrottbbc39432016-10-27 23:12:39 -070059
60if CLOUD_SDK_ROOT is not None:
61 CLOUD_SDK_ROOT = py.path.local(CLOUD_SDK_ROOT)
62 CLOUD_SDK_ROOT.ensure(dir=True) # Makes sure the directory exists.
63else:
64 CLOUD_SDK_ROOT = py.path.local.mkdtemp()
65
66# The full path the cloud sdk install directory
Bu Sun Kim9eec0912019-10-21 17:04:21 -070067CLOUD_SDK_INSTALL_DIR = CLOUD_SDK_ROOT.join("google-cloud-sdk")
Jon Wayne Parrottbbc39432016-10-27 23:12:39 -070068
69# The full path to the gcloud cli executable.
Bu Sun Kim9eec0912019-10-21 17:04:21 -070070GCLOUD = str(CLOUD_SDK_INSTALL_DIR.join("bin", "gcloud"))
Jon Wayne Parrottbbc39432016-10-27 23:12:39 -070071
72# gcloud requires Python 2 and doesn't work on 3, so we need to tell it
73# where to find 2 when we're running in a 3 environment.
Bu Sun Kim9eec0912019-10-21 17:04:21 -070074CLOUD_SDK_PYTHON_ENV = "CLOUDSDK_PYTHON"
75CLOUD_SDK_PYTHON = which("python2", None)
Jon Wayne Parrottbbc39432016-10-27 23:12:39 -070076
77# Cloud SDK helpers
78
79
80def install_cloud_sdk(session):
81 """Downloads and installs the Google Cloud SDK."""
82 # Configure environment variables needed by the SDK.
83 # This sets the config root to the tests' config root. This prevents
84 # our tests from clobbering a developer's configuration when running
85 # these tests locally.
86 session.env[CLOUD_SDK_CONFIG_ENV] = str(CLOUD_SDK_ROOT)
87 # This tells gcloud which Python interpreter to use (always use 2.7)
88 session.env[CLOUD_SDK_PYTHON_ENV] = CLOUD_SDK_PYTHON
Jon Wayne Parrott0c09c732017-03-24 12:10:44 -070089 # This set the $PATH for the subprocesses so they can find the gcloud
90 # executable.
Bu Sun Kim9eec0912019-10-21 17:04:21 -070091 session.env["PATH"] = (
92 str(CLOUD_SDK_INSTALL_DIR.join("bin")) + os.pathsep + os.environ["PATH"]
93 )
Jon Wayne Parrottbbc39432016-10-27 23:12:39 -070094
Jon Wayne Parrott87161412017-03-01 09:28:15 -080095 # If gcloud cli executable already exists, just update it.
Jon Wayne Parrottbbc39432016-10-27 23:12:39 -070096 if py.path.local(GCLOUD).exists():
Bu Sun Kim9eec0912019-10-21 17:04:21 -070097 session.run(GCLOUD, "components", "update", "-q")
Jon Wayne Parrottbbc39432016-10-27 23:12:39 -070098 return
99
100 tar_path = CLOUD_SDK_ROOT.join(CLOUD_SDK_DIST_FILENAME)
101
102 # Download the release.
Bu Sun Kim9eec0912019-10-21 17:04:21 -0700103 session.run("wget", CLOUD_SDK_DOWNLOAD_URL, "-O", str(tar_path), silent=True)
Jon Wayne Parrottbbc39432016-10-27 23:12:39 -0700104
105 # Extract the release.
Bu Sun Kim9eec0912019-10-21 17:04:21 -0700106 session.run("tar", "xzf", str(tar_path), "-C", str(CLOUD_SDK_ROOT))
Jon Wayne Parrottbbc39432016-10-27 23:12:39 -0700107 session.run(tar_path.remove)
108
109 # Run the install script.
110 session.run(
Bu Sun Kim9eec0912019-10-21 17:04:21 -0700111 str(CLOUD_SDK_INSTALL_DIR.join("install.sh")),
112 "--usage-reporting",
113 "false",
114 "--path-update",
115 "false",
116 "--command-completion",
117 "false",
118 silent=True,
119 )
Jon Wayne Parrottbbc39432016-10-27 23:12:39 -0700120
121
122def copy_credentials(credentials_path):
123 """Copies credentials into the SDK root as the application default
124 credentials."""
Bu Sun Kim9eec0912019-10-21 17:04:21 -0700125 dest = CLOUD_SDK_ROOT.join("application_default_credentials.json")
Jon Wayne Parrottbbc39432016-10-27 23:12:39 -0700126 if dest.exists():
127 dest.remove()
128 py.path.local(credentials_path).copy(dest)
129
130
Bu Sun Kim9eec0912019-10-21 17:04:21 -0700131def configure_cloud_sdk(session, application_default_credentials, project=False):
Jon Wayne Parrottbbc39432016-10-27 23:12:39 -0700132 """Installs and configures the Cloud SDK with the given application default
133 credentials.
134
135 If project is True, then a project will be set in the active config.
136 If it is false, this will ensure no project is set.
137 """
138 install_cloud_sdk(session)
139
Jon Wayne Parrott0c09c732017-03-24 12:10:44 -0700140 # Setup the service account as the default user account. This is
141 # needed for the project ID detection to work. Note that this doesn't
142 # change the application default credentials file, which is user
143 # credentials instead of service account credentials sometimes.
144 session.run(
Bu Sun Kim9eec0912019-10-21 17:04:21 -0700145 GCLOUD, "auth", "activate-service-account", "--key-file", SERVICE_ACCOUNT_FILE
146 )
Jon Wayne Parrott0c09c732017-03-24 12:10:44 -0700147
Jon Wayne Parrottbbc39432016-10-27 23:12:39 -0700148 if project:
Bu Sun Kim9eec0912019-10-21 17:04:21 -0700149 session.run(GCLOUD, "config", "set", "project", "example-project")
Jon Wayne Parrottbbc39432016-10-27 23:12:39 -0700150 else:
Bu Sun Kim9eec0912019-10-21 17:04:21 -0700151 session.run(GCLOUD, "config", "unset", "project")
Jon Wayne Parrottbbc39432016-10-27 23:12:39 -0700152
153 # Copy the credentials file to the config root. This is needed because
154 # unfortunately gcloud doesn't provide a clean way to tell it to use
155 # a particular set of credentials. However, this does verify that gcloud
156 # also considers the credentials valid by calling application-default
157 # print-access-token
158 session.run(copy_credentials, application_default_credentials)
159
160 # Calling this forces the Cloud SDK to read the credentials we just wrote
161 # and obtain a new access token with those credentials. This validates
162 # that our credentials matches the format expected by gcloud.
163 # Silent is set to True to prevent leaking secrets in test logs.
164 session.run(
Bu Sun Kim9eec0912019-10-21 17:04:21 -0700165 GCLOUD, "auth", "application-default", "print-access-token", silent=True
166 )
Jon Wayne Parrottbbc39432016-10-27 23:12:39 -0700167
168
169# Test sesssions
170
David Buxtonb790e652020-10-29 21:38:01 +0000171TEST_DEPENDENCIES_ASYNC = ["aiohttp", "pytest-asyncio", "nest-asyncio"]
Bu Sun Kim621f54b2021-01-22 13:43:41 -0700172TEST_DEPENDENCIES_SYNC = ["pytest", "requests", "mock"]
Christopher Wilcox7e152582020-09-28 15:27:20 -0700173PYTHON_VERSIONS_ASYNC = ["3.7"]
174PYTHON_VERSIONS_SYNC = ["2.7", "3.7"]
Bu Sun Kim82e224b2020-03-13 13:21:18 -0700175
Jon Wayne Parrottbbc39432016-10-27 23:12:39 -0700176
Christopher Wilcox7e152582020-09-28 15:27:20 -0700177@nox.session(python=PYTHON_VERSIONS_SYNC)
178def service_account_sync(session):
179 session.install(*TEST_DEPENDENCIES_SYNC)
Bu Sun Kim65e33c02019-10-25 10:45:00 -0700180 session.install(LIBRARY_DIR)
Christopher Wilcox7e152582020-09-28 15:27:20 -0700181 session.run("pytest", "system_tests_sync/test_service_account.py")
Jon Wayne Parrottbbc39432016-10-27 23:12:39 -0700182
183
Christopher Wilcox7e152582020-09-28 15:27:20 -0700184@nox.session(python=PYTHON_VERSIONS_SYNC)
Bu Sun Kim65e33c02019-10-25 10:45:00 -0700185def default_explicit_service_account(session):
Jon Wayne Parrottbbc39432016-10-27 23:12:39 -0700186 session.env[EXPLICIT_CREDENTIALS_ENV] = SERVICE_ACCOUNT_FILE
Bu Sun Kim9eec0912019-10-21 17:04:21 -0700187 session.env[EXPECT_PROJECT_ENV] = "1"
Christopher Wilcox7e152582020-09-28 15:27:20 -0700188 session.install(*TEST_DEPENDENCIES_SYNC)
Bu Sun Kim65e33c02019-10-25 10:45:00 -0700189 session.install(LIBRARY_DIR)
Christopher Wilcox7e152582020-09-28 15:27:20 -0700190 session.run("pytest", "system_tests_sync/test_default.py", "system_tests_sync/test_id_token.py")
Jon Wayne Parrottbbc39432016-10-27 23:12:39 -0700191
192
Christopher Wilcox7e152582020-09-28 15:27:20 -0700193@nox.session(python=PYTHON_VERSIONS_SYNC)
Bu Sun Kim65e33c02019-10-25 10:45:00 -0700194def default_explicit_authorized_user(session):
Jon Wayne Parrottbbc39432016-10-27 23:12:39 -0700195 session.env[EXPLICIT_CREDENTIALS_ENV] = AUTHORIZED_USER_FILE
Christopher Wilcox7e152582020-09-28 15:27:20 -0700196 session.install(*TEST_DEPENDENCIES_SYNC)
Bu Sun Kim65e33c02019-10-25 10:45:00 -0700197 session.install(LIBRARY_DIR)
Christopher Wilcox7e152582020-09-28 15:27:20 -0700198 session.run("pytest", "system_tests_sync/test_default.py")
Jon Wayne Parrottbbc39432016-10-27 23:12:39 -0700199
200
Christopher Wilcox7e152582020-09-28 15:27:20 -0700201@nox.session(python=PYTHON_VERSIONS_SYNC)
Bu Sun Kim65e33c02019-10-25 10:45:00 -0700202def default_explicit_authorized_user_explicit_project(session):
Jon Wayne Parrottbbc39432016-10-27 23:12:39 -0700203 session.env[EXPLICIT_CREDENTIALS_ENV] = AUTHORIZED_USER_FILE
Bu Sun Kim9eec0912019-10-21 17:04:21 -0700204 session.env[EXPLICIT_PROJECT_ENV] = "example-project"
205 session.env[EXPECT_PROJECT_ENV] = "1"
Christopher Wilcox7e152582020-09-28 15:27:20 -0700206 session.install(*TEST_DEPENDENCIES_SYNC)
Bu Sun Kim65e33c02019-10-25 10:45:00 -0700207 session.install(LIBRARY_DIR)
Christopher Wilcox7e152582020-09-28 15:27:20 -0700208 session.run("pytest", "system_tests_sync/test_default.py")
Jon Wayne Parrottbbc39432016-10-27 23:12:39 -0700209
210
Christopher Wilcox7e152582020-09-28 15:27:20 -0700211@nox.session(python=PYTHON_VERSIONS_SYNC)
Bu Sun Kim65e33c02019-10-25 10:45:00 -0700212def default_cloud_sdk_service_account(session):
Jon Wayne Parrottbbc39432016-10-27 23:12:39 -0700213 configure_cloud_sdk(session, SERVICE_ACCOUNT_FILE)
Bu Sun Kim9eec0912019-10-21 17:04:21 -0700214 session.env[EXPECT_PROJECT_ENV] = "1"
Christopher Wilcox7e152582020-09-28 15:27:20 -0700215 session.install(*TEST_DEPENDENCIES_SYNC)
Bu Sun Kim65e33c02019-10-25 10:45:00 -0700216 session.install(LIBRARY_DIR)
Christopher Wilcox7e152582020-09-28 15:27:20 -0700217 session.run("pytest", "system_tests_sync/test_default.py")
Jon Wayne Parrottbbc39432016-10-27 23:12:39 -0700218
219
Christopher Wilcox7e152582020-09-28 15:27:20 -0700220@nox.session(python=PYTHON_VERSIONS_SYNC)
Bu Sun Kim65e33c02019-10-25 10:45:00 -0700221def default_cloud_sdk_authorized_user(session):
Jon Wayne Parrottbbc39432016-10-27 23:12:39 -0700222 configure_cloud_sdk(session, AUTHORIZED_USER_FILE)
Christopher Wilcox7e152582020-09-28 15:27:20 -0700223 session.install(*TEST_DEPENDENCIES_SYNC)
Bu Sun Kim65e33c02019-10-25 10:45:00 -0700224 session.install(LIBRARY_DIR)
Christopher Wilcox7e152582020-09-28 15:27:20 -0700225 session.run("pytest", "system_tests_sync/test_default.py")
Jon Wayne Parrottbbc39432016-10-27 23:12:39 -0700226
227
Christopher Wilcox7e152582020-09-28 15:27:20 -0700228@nox.session(python=PYTHON_VERSIONS_SYNC)
Bu Sun Kim65e33c02019-10-25 10:45:00 -0700229def default_cloud_sdk_authorized_user_configured_project(session):
Jon Wayne Parrottbbc39432016-10-27 23:12:39 -0700230 configure_cloud_sdk(session, AUTHORIZED_USER_FILE, project=True)
Bu Sun Kim9eec0912019-10-21 17:04:21 -0700231 session.env[EXPECT_PROJECT_ENV] = "1"
Christopher Wilcox7e152582020-09-28 15:27:20 -0700232 session.install(*TEST_DEPENDENCIES_SYNC)
Bu Sun Kim65e33c02019-10-25 10:45:00 -0700233 session.install(LIBRARY_DIR)
Christopher Wilcox7e152582020-09-28 15:27:20 -0700234 session.run("pytest", "system_tests_sync/test_default.py")
Jon Wayne Parrottbbc39432016-10-27 23:12:39 -0700235
Christopher Wilcox7e152582020-09-28 15:27:20 -0700236@nox.session(python=PYTHON_VERSIONS_SYNC)
Bu Sun Kim65e33c02019-10-25 10:45:00 -0700237def compute_engine(session):
Christopher Wilcox7e152582020-09-28 15:27:20 -0700238 session.install(*TEST_DEPENDENCIES_SYNC)
Bu Sun Kim65e33c02019-10-25 10:45:00 -0700239 # unset Application Default Credentials so
240 # credentials are detected from environment
241 del session.virtualenv.env["GOOGLE_APPLICATION_CREDENTIALS"]
242 session.install(LIBRARY_DIR)
Christopher Wilcox7e152582020-09-28 15:27:20 -0700243 session.run("pytest", "system_tests_sync/test_compute_engine.py")
Jon Wayne Parrottbbc39432016-10-27 23:12:39 -0700244
245
Bu Sun Kim65e33c02019-10-25 10:45:00 -0700246@nox.session(python=["2.7"])
247def app_engine(session):
Jon Wayne Parrottb551ef22016-10-28 12:35:15 -0700248 if SKIP_GAE_TEST_ENV in os.environ:
Bu Sun Kim9eec0912019-10-21 17:04:21 -0700249 session.log("Skipping App Engine tests.")
Jon Wayne Parrottb551ef22016-10-28 12:35:15 -0700250 return
251
Bu Sun Kim621f54b2021-01-22 13:43:41 -0700252 session.install(LIBRARY_DIR)
Jon Wayne Parrottb551ef22016-10-28 12:35:15 -0700253 # Unlike the default tests above, the App Engine system test require a
254 # 'real' gcloud sdk installation that is configured to deploy to an
255 # app engine project.
256 # Grab the project ID from the cloud sdk.
Bu Sun Kim9eec0912019-10-21 17:04:21 -0700257 project_id = (
258 subprocess.check_output(
259 ["gcloud", "config", "list", "project", "--format", "value(core.project)"]
260 )
261 .decode("utf-8")
262 .strip()
263 )
Jon Wayne Parrottb551ef22016-10-28 12:35:15 -0700264
265 if not project_id:
266 session.error(
Bu Sun Kim9eec0912019-10-21 17:04:21 -0700267 "The Cloud SDK must be installed and configured to deploy to App " "Engine."
268 )
Jon Wayne Parrottb551ef22016-10-28 12:35:15 -0700269
Bu Sun Kim9eec0912019-10-21 17:04:21 -0700270 application_url = GAE_APP_URL_TMPL.format(GAE_TEST_APP_SERVICE, project_id)
Jon Wayne Parrottb551ef22016-10-28 12:35:15 -0700271
272 # Vendor in the test application's dependencies
Bu Sun Kim621f54b2021-01-22 13:43:41 -0700273 session.chdir(os.path.join(HERE, "system_tests_sync/app_engine_test_app"))
Christopher Wilcox7e152582020-09-28 15:27:20 -0700274 session.install(*TEST_DEPENDENCIES_SYNC)
Jon Wayne Parrottb551ef22016-10-28 12:35:15 -0700275 session.run(
Bu Sun Kim9eec0912019-10-21 17:04:21 -0700276 "pip", "install", "--target", "lib", "-r", "requirements.txt", silent=True
277 )
Jon Wayne Parrottb551ef22016-10-28 12:35:15 -0700278
279 # Deploy the application.
Bu Sun Kim9eec0912019-10-21 17:04:21 -0700280 session.run("gcloud", "app", "deploy", "-q", "app.yaml")
Jon Wayne Parrottb551ef22016-10-28 12:35:15 -0700281
282 # Run the tests
Bu Sun Kim9eec0912019-10-21 17:04:21 -0700283 session.env["TEST_APP_URL"] = application_url
Jon Wayne Parrottb551ef22016-10-28 12:35:15 -0700284 session.chdir(HERE)
Christopher Wilcox7e152582020-09-28 15:27:20 -0700285 session.run("pytest", "system_tests_sync/test_app_engine.py")
Jon Wayne Parrottb9897dc2016-11-02 20:31:14 -0700286
287
Christopher Wilcox7e152582020-09-28 15:27:20 -0700288@nox.session(python=PYTHON_VERSIONS_SYNC)
Bu Sun Kim65e33c02019-10-25 10:45:00 -0700289def grpc(session):
290 session.install(LIBRARY_DIR)
Bu Sun Kim621f54b2021-01-22 13:43:41 -0700291 session.install(*TEST_DEPENDENCIES_SYNC, "google-cloud-pubsub==1.7.0")
Jon Wayne Parrottb9897dc2016-11-02 20:31:14 -0700292 session.env[EXPLICIT_CREDENTIALS_ENV] = SERVICE_ACCOUNT_FILE
Christopher Wilcox7e152582020-09-28 15:27:20 -0700293 session.run("pytest", "system_tests_sync/test_grpc.py")
arithmetic1728bb9215a2020-03-20 09:49:44 -0700294
295
Christopher Wilcox7e152582020-09-28 15:27:20 -0700296@nox.session(python=PYTHON_VERSIONS_SYNC)
Bu Sun Kim7a94acb2021-02-03 16:57:08 -0700297def requests(session):
298 session.install(LIBRARY_DIR)
299 session.install(*TEST_DEPENDENCIES_SYNC)
300 session.env[EXPLICIT_CREDENTIALS_ENV] = SERVICE_ACCOUNT_FILE
301 session.run("pytest", "system_tests_sync/test_requests.py")
302
303
304@nox.session(python=PYTHON_VERSIONS_SYNC)
305def urllib3(session):
306 session.install(LIBRARY_DIR)
307 session.install(*TEST_DEPENDENCIES_SYNC)
308 session.env[EXPLICIT_CREDENTIALS_ENV] = SERVICE_ACCOUNT_FILE
309 session.run("pytest", "system_tests_sync/test_urllib3.py")
310
311
312@nox.session(python=PYTHON_VERSIONS_SYNC)
arithmetic1728bb9215a2020-03-20 09:49:44 -0700313def mtls_http(session):
314 session.install(LIBRARY_DIR)
Christopher Wilcox7e152582020-09-28 15:27:20 -0700315 session.install(*TEST_DEPENDENCIES_SYNC, "pyopenssl")
arithmetic1728bb9215a2020-03-20 09:49:44 -0700316 session.env[EXPLICIT_CREDENTIALS_ENV] = SERVICE_ACCOUNT_FILE
Christopher Wilcox7e152582020-09-28 15:27:20 -0700317 session.run("pytest", "system_tests_sync/test_mtls_http.py")
318
Bu Sun Kim7a94acb2021-02-03 16:57:08 -0700319
Christopher Wilcox7e152582020-09-28 15:27:20 -0700320#ASYNC SYSTEM TESTS
321
322@nox.session(python=PYTHON_VERSIONS_ASYNC)
323def service_account_async(session):
324 session.install(*(TEST_DEPENDENCIES_SYNC+TEST_DEPENDENCIES_ASYNC))
325 session.install(LIBRARY_DIR)
326 session.run("pytest", "system_tests_async/test_service_account.py")
327
328
329@nox.session(python=PYTHON_VERSIONS_ASYNC)
330def default_explicit_service_account_async(session):
331 session.env[EXPLICIT_CREDENTIALS_ENV] = SERVICE_ACCOUNT_FILE
332 session.env[EXPECT_PROJECT_ENV] = "1"
333 session.install(*(TEST_DEPENDENCIES_SYNC + TEST_DEPENDENCIES_ASYNC))
334 session.install(LIBRARY_DIR)
David Buxton0323cf32020-10-29 21:26:11 +0000335 session.run("pytest", "system_tests_async/test_default.py",
Christopher Wilcox7e152582020-09-28 15:27:20 -0700336 "system_tests_async/test_id_token.py")
337
338
339@nox.session(python=PYTHON_VERSIONS_ASYNC)
340def default_explicit_authorized_user_async(session):
341 session.env[EXPLICIT_CREDENTIALS_ENV] = AUTHORIZED_USER_FILE
342 session.install(*(TEST_DEPENDENCIES_SYNC + TEST_DEPENDENCIES_ASYNC))
343 session.install(LIBRARY_DIR)
344 session.run("pytest", "system_tests_async/test_default.py")
345
346
347@nox.session(python=PYTHON_VERSIONS_ASYNC)
348def default_explicit_authorized_user_explicit_project_async(session):
349 session.env[EXPLICIT_CREDENTIALS_ENV] = AUTHORIZED_USER_FILE
350 session.env[EXPLICIT_PROJECT_ENV] = "example-project"
351 session.env[EXPECT_PROJECT_ENV] = "1"
352 session.install(*(TEST_DEPENDENCIES_SYNC + TEST_DEPENDENCIES_ASYNC))
353 session.install(LIBRARY_DIR)
354 session.run("pytest", "system_tests_async/test_default.py")
355
356
357@nox.session(python=PYTHON_VERSIONS_ASYNC)
358def default_cloud_sdk_service_account_async(session):
359 configure_cloud_sdk(session, SERVICE_ACCOUNT_FILE)
360 session.env[EXPECT_PROJECT_ENV] = "1"
361 session.install(*(TEST_DEPENDENCIES_SYNC + TEST_DEPENDENCIES_ASYNC))
362 session.install(LIBRARY_DIR)
363 session.run("pytest", "system_tests_async/test_default.py")
364
365
366@nox.session(python=PYTHON_VERSIONS_ASYNC)
367def default_cloud_sdk_authorized_user_async(session):
368 configure_cloud_sdk(session, AUTHORIZED_USER_FILE)
369 session.install(*(TEST_DEPENDENCIES_SYNC + TEST_DEPENDENCIES_ASYNC))
370 session.install(LIBRARY_DIR)
371 session.run("pytest", "system_tests_async/test_default.py")
372
373
374@nox.session(python=PYTHON_VERSIONS_ASYNC)
375def default_cloud_sdk_authorized_user_configured_project_async(session):
376 configure_cloud_sdk(session, AUTHORIZED_USER_FILE, project=True)
377 session.env[EXPECT_PROJECT_ENV] = "1"
378 session.install(*(TEST_DEPENDENCIES_SYNC + TEST_DEPENDENCIES_ASYNC))
379 session.install(LIBRARY_DIR)
380 session.run("pytest", "system_tests_async/test_default.py")