Christopher Wilcox | 7e15258 | 2020-09-28 15:27:20 -0700 | [diff] [blame] | 1 | # Copyright 2020 Google LLC |
Jon Wayne Parrott | bbc3943 | 2016-10-27 23:12:39 -0700 | [diff] [blame] | 2 | # |
| 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 | |
| 17 | This file handles setting up environments needed by the system tests. This |
| 18 | separates the tests from their environment configuration. |
| 19 | |
| 20 | See the `nox docs`_ for details on how this file works: |
| 21 | |
| 22 | .. _nox docs: http://nox.readthedocs.io/en/latest/ |
| 23 | """ |
| 24 | |
| 25 | import os |
Jon Wayne Parrott | b551ef2 | 2016-10-28 12:35:15 -0700 | [diff] [blame] | 26 | import subprocess |
Jon Wayne Parrott | bbc3943 | 2016-10-27 23:12:39 -0700 | [diff] [blame] | 27 | |
| 28 | from nox.command import which |
Bu Sun Kim | 65e33c0 | 2019-10-25 10:45:00 -0700 | [diff] [blame] | 29 | import nox |
Jon Wayne Parrott | bbc3943 | 2016-10-27 23:12:39 -0700 | [diff] [blame] | 30 | import py.path |
| 31 | |
Jon Wayne Parrott | b551ef2 | 2016-10-28 12:35:15 -0700 | [diff] [blame] | 32 | HERE = os.path.abspath(os.path.dirname(__file__)) |
Bu Sun Kim | 621f54b | 2021-01-22 13:43:41 -0700 | [diff] [blame] | 33 | LIBRARY_DIR = os.path.abspath(os.path.dirname(HERE)) |
Bu Sun Kim | 9eec091 | 2019-10-21 17:04:21 -0700 | [diff] [blame] | 34 | DATA_DIR = os.path.join(HERE, "data") |
| 35 | SERVICE_ACCOUNT_FILE = os.path.join(DATA_DIR, "service_account.json") |
| 36 | AUTHORIZED_USER_FILE = os.path.join(DATA_DIR, "authorized_user.json") |
| 37 | EXPLICIT_CREDENTIALS_ENV = "GOOGLE_APPLICATION_CREDENTIALS" |
| 38 | EXPLICIT_PROJECT_ENV = "GOOGLE_CLOUD_PROJECT" |
| 39 | EXPECT_PROJECT_ENV = "EXPECT_PROJECT_ID" |
Jon Wayne Parrott | bbc3943 | 2016-10-27 23:12:39 -0700 | [diff] [blame] | 40 | |
Bu Sun Kim | 9eec091 | 2019-10-21 17:04:21 -0700 | [diff] [blame] | 41 | SKIP_GAE_TEST_ENV = "SKIP_APP_ENGINE_SYSTEM_TEST" |
| 42 | GAE_APP_URL_TMPL = "https://{}-dot-{}.appspot.com" |
| 43 | GAE_TEST_APP_SERVICE = "google-auth-system-tests" |
Jon Wayne Parrott | b551ef2 | 2016-10-28 12:35:15 -0700 | [diff] [blame] | 44 | |
Jon Wayne Parrott | bbc3943 | 2016-10-27 23:12:39 -0700 | [diff] [blame] | 45 | # The download location for the Cloud SDK |
Bu Sun Kim | 9eec091 | 2019-10-21 17:04:21 -0700 | [diff] [blame] | 46 | CLOUD_SDK_DIST_FILENAME = "google-cloud-sdk.tar.gz" |
| 47 | CLOUD_SDK_DOWNLOAD_URL = "https://dl.google.com/dl/cloudsdk/release/{}".format( |
| 48 | CLOUD_SDK_DIST_FILENAME |
| 49 | ) |
Jon Wayne Parrott | bbc3943 | 2016-10-27 23:12:39 -0700 | [diff] [blame] | 50 | |
| 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 Kim | 9eec091 | 2019-10-21 17:04:21 -0700 | [diff] [blame] | 54 | CLOUD_SDK_CONFIG_ENV = "CLOUDSDK_CONFIG" |
Jon Wayne Parrott | bbc3943 | 2016-10-27 23:12:39 -0700 | [diff] [blame] | 55 | |
| 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 Kim | 9eec091 | 2019-10-21 17:04:21 -0700 | [diff] [blame] | 58 | CLOUD_SDK_ROOT = os.environ.get("CLOUD_SDK_ROOT") |
Jon Wayne Parrott | bbc3943 | 2016-10-27 23:12:39 -0700 | [diff] [blame] | 59 | |
| 60 | if 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. |
| 63 | else: |
| 64 | CLOUD_SDK_ROOT = py.path.local.mkdtemp() |
| 65 | |
| 66 | # The full path the cloud sdk install directory |
Bu Sun Kim | 9eec091 | 2019-10-21 17:04:21 -0700 | [diff] [blame] | 67 | CLOUD_SDK_INSTALL_DIR = CLOUD_SDK_ROOT.join("google-cloud-sdk") |
Jon Wayne Parrott | bbc3943 | 2016-10-27 23:12:39 -0700 | [diff] [blame] | 68 | |
| 69 | # The full path to the gcloud cli executable. |
Bu Sun Kim | 9eec091 | 2019-10-21 17:04:21 -0700 | [diff] [blame] | 70 | GCLOUD = str(CLOUD_SDK_INSTALL_DIR.join("bin", "gcloud")) |
Jon Wayne Parrott | bbc3943 | 2016-10-27 23:12:39 -0700 | [diff] [blame] | 71 | |
| 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 Kim | 9eec091 | 2019-10-21 17:04:21 -0700 | [diff] [blame] | 74 | CLOUD_SDK_PYTHON_ENV = "CLOUDSDK_PYTHON" |
| 75 | CLOUD_SDK_PYTHON = which("python2", None) |
Jon Wayne Parrott | bbc3943 | 2016-10-27 23:12:39 -0700 | [diff] [blame] | 76 | |
| 77 | # Cloud SDK helpers |
| 78 | |
| 79 | |
| 80 | def 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 Parrott | 0c09c73 | 2017-03-24 12:10:44 -0700 | [diff] [blame] | 89 | # This set the $PATH for the subprocesses so they can find the gcloud |
| 90 | # executable. |
Bu Sun Kim | 9eec091 | 2019-10-21 17:04:21 -0700 | [diff] [blame] | 91 | session.env["PATH"] = ( |
| 92 | str(CLOUD_SDK_INSTALL_DIR.join("bin")) + os.pathsep + os.environ["PATH"] |
| 93 | ) |
Jon Wayne Parrott | bbc3943 | 2016-10-27 23:12:39 -0700 | [diff] [blame] | 94 | |
Jon Wayne Parrott | 8716141 | 2017-03-01 09:28:15 -0800 | [diff] [blame] | 95 | # If gcloud cli executable already exists, just update it. |
Jon Wayne Parrott | bbc3943 | 2016-10-27 23:12:39 -0700 | [diff] [blame] | 96 | if py.path.local(GCLOUD).exists(): |
Bu Sun Kim | 9eec091 | 2019-10-21 17:04:21 -0700 | [diff] [blame] | 97 | session.run(GCLOUD, "components", "update", "-q") |
Jon Wayne Parrott | bbc3943 | 2016-10-27 23:12:39 -0700 | [diff] [blame] | 98 | return |
| 99 | |
| 100 | tar_path = CLOUD_SDK_ROOT.join(CLOUD_SDK_DIST_FILENAME) |
| 101 | |
| 102 | # Download the release. |
Bu Sun Kim | 9eec091 | 2019-10-21 17:04:21 -0700 | [diff] [blame] | 103 | session.run("wget", CLOUD_SDK_DOWNLOAD_URL, "-O", str(tar_path), silent=True) |
Jon Wayne Parrott | bbc3943 | 2016-10-27 23:12:39 -0700 | [diff] [blame] | 104 | |
| 105 | # Extract the release. |
Bu Sun Kim | 9eec091 | 2019-10-21 17:04:21 -0700 | [diff] [blame] | 106 | session.run("tar", "xzf", str(tar_path), "-C", str(CLOUD_SDK_ROOT)) |
Jon Wayne Parrott | bbc3943 | 2016-10-27 23:12:39 -0700 | [diff] [blame] | 107 | session.run(tar_path.remove) |
| 108 | |
| 109 | # Run the install script. |
| 110 | session.run( |
Bu Sun Kim | 9eec091 | 2019-10-21 17:04:21 -0700 | [diff] [blame] | 111 | 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 Parrott | bbc3943 | 2016-10-27 23:12:39 -0700 | [diff] [blame] | 120 | |
| 121 | |
| 122 | def copy_credentials(credentials_path): |
| 123 | """Copies credentials into the SDK root as the application default |
| 124 | credentials.""" |
Bu Sun Kim | 9eec091 | 2019-10-21 17:04:21 -0700 | [diff] [blame] | 125 | dest = CLOUD_SDK_ROOT.join("application_default_credentials.json") |
Jon Wayne Parrott | bbc3943 | 2016-10-27 23:12:39 -0700 | [diff] [blame] | 126 | if dest.exists(): |
| 127 | dest.remove() |
| 128 | py.path.local(credentials_path).copy(dest) |
| 129 | |
| 130 | |
Bu Sun Kim | 9eec091 | 2019-10-21 17:04:21 -0700 | [diff] [blame] | 131 | def configure_cloud_sdk(session, application_default_credentials, project=False): |
Jon Wayne Parrott | bbc3943 | 2016-10-27 23:12:39 -0700 | [diff] [blame] | 132 | """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 Parrott | 0c09c73 | 2017-03-24 12:10:44 -0700 | [diff] [blame] | 140 | # 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 Kim | 9eec091 | 2019-10-21 17:04:21 -0700 | [diff] [blame] | 145 | GCLOUD, "auth", "activate-service-account", "--key-file", SERVICE_ACCOUNT_FILE |
| 146 | ) |
Jon Wayne Parrott | 0c09c73 | 2017-03-24 12:10:44 -0700 | [diff] [blame] | 147 | |
Jon Wayne Parrott | bbc3943 | 2016-10-27 23:12:39 -0700 | [diff] [blame] | 148 | if project: |
Bu Sun Kim | 9eec091 | 2019-10-21 17:04:21 -0700 | [diff] [blame] | 149 | session.run(GCLOUD, "config", "set", "project", "example-project") |
Jon Wayne Parrott | bbc3943 | 2016-10-27 23:12:39 -0700 | [diff] [blame] | 150 | else: |
Bu Sun Kim | 9eec091 | 2019-10-21 17:04:21 -0700 | [diff] [blame] | 151 | session.run(GCLOUD, "config", "unset", "project") |
Jon Wayne Parrott | bbc3943 | 2016-10-27 23:12:39 -0700 | [diff] [blame] | 152 | |
| 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 Kim | 9eec091 | 2019-10-21 17:04:21 -0700 | [diff] [blame] | 165 | GCLOUD, "auth", "application-default", "print-access-token", silent=True |
| 166 | ) |
Jon Wayne Parrott | bbc3943 | 2016-10-27 23:12:39 -0700 | [diff] [blame] | 167 | |
| 168 | |
| 169 | # Test sesssions |
| 170 | |
David Buxton | b790e65 | 2020-10-29 21:38:01 +0000 | [diff] [blame] | 171 | TEST_DEPENDENCIES_ASYNC = ["aiohttp", "pytest-asyncio", "nest-asyncio"] |
Bu Sun Kim | 621f54b | 2021-01-22 13:43:41 -0700 | [diff] [blame] | 172 | TEST_DEPENDENCIES_SYNC = ["pytest", "requests", "mock"] |
Christopher Wilcox | 7e15258 | 2020-09-28 15:27:20 -0700 | [diff] [blame] | 173 | PYTHON_VERSIONS_ASYNC = ["3.7"] |
Tres Seaver | 560cf1e | 2021-08-03 16:35:54 -0400 | [diff] [blame] | 174 | PYTHON_VERSIONS_SYNC = ["3.7"] |
Bu Sun Kim | 82e224b | 2020-03-13 13:21:18 -0700 | [diff] [blame] | 175 | |
Jon Wayne Parrott | bbc3943 | 2016-10-27 23:12:39 -0700 | [diff] [blame] | 176 | |
Bu Sun Kim | e87b1ec | 2021-03-15 09:02:06 -0600 | [diff] [blame] | 177 | def default(session, *test_paths): |
| 178 | # replace 'session._runner.friendly_name' with |
| 179 | # session.name once nox has released a new version |
| 180 | # https://github.com/theacodes/nox/pull/386 |
| 181 | sponge_log = f"--junitxml=system_{str(session._runner.friendly_name)}_sponge_log.xml" |
| 182 | session.run( |
| 183 | "pytest", sponge_log, *test_paths, |
| 184 | ) |
| 185 | |
| 186 | |
Christopher Wilcox | 7e15258 | 2020-09-28 15:27:20 -0700 | [diff] [blame] | 187 | @nox.session(python=PYTHON_VERSIONS_SYNC) |
| 188 | def service_account_sync(session): |
| 189 | session.install(*TEST_DEPENDENCIES_SYNC) |
Bu Sun Kim | 65e33c0 | 2019-10-25 10:45:00 -0700 | [diff] [blame] | 190 | session.install(LIBRARY_DIR) |
Tres Seaver | d3944af | 2021-07-08 15:51:47 -0400 | [diff] [blame] | 191 | default( |
| 192 | session, |
| 193 | "system_tests_sync/test_service_account.py", |
| 194 | *session.posargs, |
| 195 | ) |
Jon Wayne Parrott | bbc3943 | 2016-10-27 23:12:39 -0700 | [diff] [blame] | 196 | |
| 197 | |
Christopher Wilcox | 7e15258 | 2020-09-28 15:27:20 -0700 | [diff] [blame] | 198 | @nox.session(python=PYTHON_VERSIONS_SYNC) |
Bu Sun Kim | 65e33c0 | 2019-10-25 10:45:00 -0700 | [diff] [blame] | 199 | def default_explicit_service_account(session): |
Jon Wayne Parrott | bbc3943 | 2016-10-27 23:12:39 -0700 | [diff] [blame] | 200 | session.env[EXPLICIT_CREDENTIALS_ENV] = SERVICE_ACCOUNT_FILE |
Bu Sun Kim | 9eec091 | 2019-10-21 17:04:21 -0700 | [diff] [blame] | 201 | session.env[EXPECT_PROJECT_ENV] = "1" |
Christopher Wilcox | 7e15258 | 2020-09-28 15:27:20 -0700 | [diff] [blame] | 202 | session.install(*TEST_DEPENDENCIES_SYNC) |
Bu Sun Kim | 65e33c0 | 2019-10-25 10:45:00 -0700 | [diff] [blame] | 203 | session.install(LIBRARY_DIR) |
Bu Sun Kim | e87b1ec | 2021-03-15 09:02:06 -0600 | [diff] [blame] | 204 | default( |
| 205 | session, |
| 206 | "system_tests_sync/test_default.py", |
| 207 | "system_tests_sync/test_id_token.py", |
Tres Seaver | d3944af | 2021-07-08 15:51:47 -0400 | [diff] [blame] | 208 | *session.posargs, |
Bu Sun Kim | e87b1ec | 2021-03-15 09:02:06 -0600 | [diff] [blame] | 209 | ) |
Jon Wayne Parrott | bbc3943 | 2016-10-27 23:12:39 -0700 | [diff] [blame] | 210 | |
| 211 | |
Christopher Wilcox | 7e15258 | 2020-09-28 15:27:20 -0700 | [diff] [blame] | 212 | @nox.session(python=PYTHON_VERSIONS_SYNC) |
Bu Sun Kim | 65e33c0 | 2019-10-25 10:45:00 -0700 | [diff] [blame] | 213 | def default_explicit_authorized_user(session): |
Jon Wayne Parrott | bbc3943 | 2016-10-27 23:12:39 -0700 | [diff] [blame] | 214 | session.env[EXPLICIT_CREDENTIALS_ENV] = AUTHORIZED_USER_FILE |
Christopher Wilcox | 7e15258 | 2020-09-28 15:27:20 -0700 | [diff] [blame] | 215 | session.install(*TEST_DEPENDENCIES_SYNC) |
Bu Sun Kim | 65e33c0 | 2019-10-25 10:45:00 -0700 | [diff] [blame] | 216 | session.install(LIBRARY_DIR) |
Bu Sun Kim | e87b1ec | 2021-03-15 09:02:06 -0600 | [diff] [blame] | 217 | default( |
Tres Seaver | d3944af | 2021-07-08 15:51:47 -0400 | [diff] [blame] | 218 | session, |
| 219 | "system_tests_sync/test_default.py", |
| 220 | *session.posargs, |
Bu Sun Kim | e87b1ec | 2021-03-15 09:02:06 -0600 | [diff] [blame] | 221 | ) |
Jon Wayne Parrott | bbc3943 | 2016-10-27 23:12:39 -0700 | [diff] [blame] | 222 | |
| 223 | |
Christopher Wilcox | 7e15258 | 2020-09-28 15:27:20 -0700 | [diff] [blame] | 224 | @nox.session(python=PYTHON_VERSIONS_SYNC) |
Bu Sun Kim | 65e33c0 | 2019-10-25 10:45:00 -0700 | [diff] [blame] | 225 | def default_explicit_authorized_user_explicit_project(session): |
Jon Wayne Parrott | bbc3943 | 2016-10-27 23:12:39 -0700 | [diff] [blame] | 226 | session.env[EXPLICIT_CREDENTIALS_ENV] = AUTHORIZED_USER_FILE |
Bu Sun Kim | 9eec091 | 2019-10-21 17:04:21 -0700 | [diff] [blame] | 227 | session.env[EXPLICIT_PROJECT_ENV] = "example-project" |
| 228 | session.env[EXPECT_PROJECT_ENV] = "1" |
Christopher Wilcox | 7e15258 | 2020-09-28 15:27:20 -0700 | [diff] [blame] | 229 | session.install(*TEST_DEPENDENCIES_SYNC) |
Bu Sun Kim | 65e33c0 | 2019-10-25 10:45:00 -0700 | [diff] [blame] | 230 | session.install(LIBRARY_DIR) |
Bu Sun Kim | e87b1ec | 2021-03-15 09:02:06 -0600 | [diff] [blame] | 231 | default( |
Tres Seaver | d3944af | 2021-07-08 15:51:47 -0400 | [diff] [blame] | 232 | session, |
| 233 | "system_tests_sync/test_default.py", |
| 234 | *session.posargs, |
Bu Sun Kim | e87b1ec | 2021-03-15 09:02:06 -0600 | [diff] [blame] | 235 | ) |
Jon Wayne Parrott | bbc3943 | 2016-10-27 23:12:39 -0700 | [diff] [blame] | 236 | |
| 237 | |
Christopher Wilcox | 7e15258 | 2020-09-28 15:27:20 -0700 | [diff] [blame] | 238 | @nox.session(python=PYTHON_VERSIONS_SYNC) |
Bu Sun Kim | 65e33c0 | 2019-10-25 10:45:00 -0700 | [diff] [blame] | 239 | def default_cloud_sdk_service_account(session): |
Jon Wayne Parrott | bbc3943 | 2016-10-27 23:12:39 -0700 | [diff] [blame] | 240 | configure_cloud_sdk(session, SERVICE_ACCOUNT_FILE) |
Bu Sun Kim | 9eec091 | 2019-10-21 17:04:21 -0700 | [diff] [blame] | 241 | session.env[EXPECT_PROJECT_ENV] = "1" |
Christopher Wilcox | 7e15258 | 2020-09-28 15:27:20 -0700 | [diff] [blame] | 242 | session.install(*TEST_DEPENDENCIES_SYNC) |
Bu Sun Kim | 65e33c0 | 2019-10-25 10:45:00 -0700 | [diff] [blame] | 243 | session.install(LIBRARY_DIR) |
Bu Sun Kim | e87b1ec | 2021-03-15 09:02:06 -0600 | [diff] [blame] | 244 | default( |
Tres Seaver | d3944af | 2021-07-08 15:51:47 -0400 | [diff] [blame] | 245 | session, |
| 246 | "system_tests_sync/test_default.py", |
| 247 | *session.posargs, |
Bu Sun Kim | e87b1ec | 2021-03-15 09:02:06 -0600 | [diff] [blame] | 248 | ) |
Jon Wayne Parrott | bbc3943 | 2016-10-27 23:12:39 -0700 | [diff] [blame] | 249 | |
| 250 | |
Christopher Wilcox | 7e15258 | 2020-09-28 15:27:20 -0700 | [diff] [blame] | 251 | @nox.session(python=PYTHON_VERSIONS_SYNC) |
Bu Sun Kim | 65e33c0 | 2019-10-25 10:45:00 -0700 | [diff] [blame] | 252 | def default_cloud_sdk_authorized_user(session): |
Jon Wayne Parrott | bbc3943 | 2016-10-27 23:12:39 -0700 | [diff] [blame] | 253 | configure_cloud_sdk(session, AUTHORIZED_USER_FILE) |
Christopher Wilcox | 7e15258 | 2020-09-28 15:27:20 -0700 | [diff] [blame] | 254 | session.install(*TEST_DEPENDENCIES_SYNC) |
Bu Sun Kim | 65e33c0 | 2019-10-25 10:45:00 -0700 | [diff] [blame] | 255 | session.install(LIBRARY_DIR) |
Bu Sun Kim | e87b1ec | 2021-03-15 09:02:06 -0600 | [diff] [blame] | 256 | default( |
Tres Seaver | d3944af | 2021-07-08 15:51:47 -0400 | [diff] [blame] | 257 | session, |
| 258 | "system_tests_sync/test_default.py", |
| 259 | *session.posargs, |
Bu Sun Kim | e87b1ec | 2021-03-15 09:02:06 -0600 | [diff] [blame] | 260 | ) |
Jon Wayne Parrott | bbc3943 | 2016-10-27 23:12:39 -0700 | [diff] [blame] | 261 | |
| 262 | |
Christopher Wilcox | 7e15258 | 2020-09-28 15:27:20 -0700 | [diff] [blame] | 263 | @nox.session(python=PYTHON_VERSIONS_SYNC) |
Bu Sun Kim | 65e33c0 | 2019-10-25 10:45:00 -0700 | [diff] [blame] | 264 | def default_cloud_sdk_authorized_user_configured_project(session): |
Jon Wayne Parrott | bbc3943 | 2016-10-27 23:12:39 -0700 | [diff] [blame] | 265 | configure_cloud_sdk(session, AUTHORIZED_USER_FILE, project=True) |
Bu Sun Kim | 9eec091 | 2019-10-21 17:04:21 -0700 | [diff] [blame] | 266 | session.env[EXPECT_PROJECT_ENV] = "1" |
Christopher Wilcox | 7e15258 | 2020-09-28 15:27:20 -0700 | [diff] [blame] | 267 | session.install(*TEST_DEPENDENCIES_SYNC) |
Bu Sun Kim | 65e33c0 | 2019-10-25 10:45:00 -0700 | [diff] [blame] | 268 | session.install(LIBRARY_DIR) |
Bu Sun Kim | e87b1ec | 2021-03-15 09:02:06 -0600 | [diff] [blame] | 269 | default( |
Tres Seaver | d3944af | 2021-07-08 15:51:47 -0400 | [diff] [blame] | 270 | session, |
| 271 | "system_tests_sync/test_default.py", |
| 272 | *session.posargs, |
Bu Sun Kim | e87b1ec | 2021-03-15 09:02:06 -0600 | [diff] [blame] | 273 | ) |
| 274 | |
Jon Wayne Parrott | bbc3943 | 2016-10-27 23:12:39 -0700 | [diff] [blame] | 275 | |
Christopher Wilcox | 7e15258 | 2020-09-28 15:27:20 -0700 | [diff] [blame] | 276 | @nox.session(python=PYTHON_VERSIONS_SYNC) |
Bu Sun Kim | 65e33c0 | 2019-10-25 10:45:00 -0700 | [diff] [blame] | 277 | def compute_engine(session): |
Christopher Wilcox | 7e15258 | 2020-09-28 15:27:20 -0700 | [diff] [blame] | 278 | session.install(*TEST_DEPENDENCIES_SYNC) |
Bu Sun Kim | 65e33c0 | 2019-10-25 10:45:00 -0700 | [diff] [blame] | 279 | # unset Application Default Credentials so |
| 280 | # credentials are detected from environment |
| 281 | del session.virtualenv.env["GOOGLE_APPLICATION_CREDENTIALS"] |
| 282 | session.install(LIBRARY_DIR) |
Bu Sun Kim | e87b1ec | 2021-03-15 09:02:06 -0600 | [diff] [blame] | 283 | default( |
Tres Seaver | d3944af | 2021-07-08 15:51:47 -0400 | [diff] [blame] | 284 | session, |
| 285 | "system_tests_sync/test_compute_engine.py", |
| 286 | *session.posargs, |
Bu Sun Kim | e87b1ec | 2021-03-15 09:02:06 -0600 | [diff] [blame] | 287 | ) |
Jon Wayne Parrott | bbc3943 | 2016-10-27 23:12:39 -0700 | [diff] [blame] | 288 | |
| 289 | |
Christopher Wilcox | 7e15258 | 2020-09-28 15:27:20 -0700 | [diff] [blame] | 290 | @nox.session(python=PYTHON_VERSIONS_SYNC) |
Bu Sun Kim | 65e33c0 | 2019-10-25 10:45:00 -0700 | [diff] [blame] | 291 | def grpc(session): |
| 292 | session.install(LIBRARY_DIR) |
Bu Sun Kim | 621f54b | 2021-01-22 13:43:41 -0700 | [diff] [blame] | 293 | session.install(*TEST_DEPENDENCIES_SYNC, "google-cloud-pubsub==1.7.0") |
Jon Wayne Parrott | b9897dc | 2016-11-02 20:31:14 -0700 | [diff] [blame] | 294 | session.env[EXPLICIT_CREDENTIALS_ENV] = SERVICE_ACCOUNT_FILE |
Bu Sun Kim | e87b1ec | 2021-03-15 09:02:06 -0600 | [diff] [blame] | 295 | default( |
Tres Seaver | d3944af | 2021-07-08 15:51:47 -0400 | [diff] [blame] | 296 | session, |
| 297 | "system_tests_sync/test_grpc.py", |
| 298 | *session.posargs, |
Bu Sun Kim | e87b1ec | 2021-03-15 09:02:06 -0600 | [diff] [blame] | 299 | ) |
arithmetic1728 | bb9215a | 2020-03-20 09:49:44 -0700 | [diff] [blame] | 300 | |
| 301 | |
Christopher Wilcox | 7e15258 | 2020-09-28 15:27:20 -0700 | [diff] [blame] | 302 | @nox.session(python=PYTHON_VERSIONS_SYNC) |
Bu Sun Kim | 7a94acb | 2021-02-03 16:57:08 -0700 | [diff] [blame] | 303 | def requests(session): |
| 304 | session.install(LIBRARY_DIR) |
| 305 | session.install(*TEST_DEPENDENCIES_SYNC) |
| 306 | session.env[EXPLICIT_CREDENTIALS_ENV] = SERVICE_ACCOUNT_FILE |
Bu Sun Kim | e87b1ec | 2021-03-15 09:02:06 -0600 | [diff] [blame] | 307 | default( |
Tres Seaver | d3944af | 2021-07-08 15:51:47 -0400 | [diff] [blame] | 308 | session, |
| 309 | "system_tests_sync/test_requests.py", |
| 310 | *session.posargs, |
Bu Sun Kim | e87b1ec | 2021-03-15 09:02:06 -0600 | [diff] [blame] | 311 | ) |
Bu Sun Kim | 7a94acb | 2021-02-03 16:57:08 -0700 | [diff] [blame] | 312 | |
| 313 | |
| 314 | @nox.session(python=PYTHON_VERSIONS_SYNC) |
| 315 | def urllib3(session): |
| 316 | session.install(LIBRARY_DIR) |
| 317 | session.install(*TEST_DEPENDENCIES_SYNC) |
| 318 | session.env[EXPLICIT_CREDENTIALS_ENV] = SERVICE_ACCOUNT_FILE |
Bu Sun Kim | e87b1ec | 2021-03-15 09:02:06 -0600 | [diff] [blame] | 319 | default( |
Tres Seaver | d3944af | 2021-07-08 15:51:47 -0400 | [diff] [blame] | 320 | session, |
| 321 | "system_tests_sync/test_urllib3.py", |
| 322 | *session.posargs, |
Bu Sun Kim | e87b1ec | 2021-03-15 09:02:06 -0600 | [diff] [blame] | 323 | ) |
Bu Sun Kim | 7a94acb | 2021-02-03 16:57:08 -0700 | [diff] [blame] | 324 | |
| 325 | |
| 326 | @nox.session(python=PYTHON_VERSIONS_SYNC) |
arithmetic1728 | bb9215a | 2020-03-20 09:49:44 -0700 | [diff] [blame] | 327 | def mtls_http(session): |
| 328 | session.install(LIBRARY_DIR) |
Christopher Wilcox | 7e15258 | 2020-09-28 15:27:20 -0700 | [diff] [blame] | 329 | session.install(*TEST_DEPENDENCIES_SYNC, "pyopenssl") |
arithmetic1728 | bb9215a | 2020-03-20 09:49:44 -0700 | [diff] [blame] | 330 | session.env[EXPLICIT_CREDENTIALS_ENV] = SERVICE_ACCOUNT_FILE |
Bu Sun Kim | e87b1ec | 2021-03-15 09:02:06 -0600 | [diff] [blame] | 331 | default( |
Tres Seaver | d3944af | 2021-07-08 15:51:47 -0400 | [diff] [blame] | 332 | session, |
| 333 | "system_tests_sync/test_mtls_http.py", |
| 334 | *session.posargs, |
Bu Sun Kim | e87b1ec | 2021-03-15 09:02:06 -0600 | [diff] [blame] | 335 | ) |
Christopher Wilcox | 7e15258 | 2020-09-28 15:27:20 -0700 | [diff] [blame] | 336 | |
Bu Sun Kim | 7a94acb | 2021-02-03 16:57:08 -0700 | [diff] [blame] | 337 | |
Ryan Kohler | 48e8be3 | 2021-03-25 17:35:43 -0700 | [diff] [blame] | 338 | @nox.session(python=PYTHON_VERSIONS_SYNC) |
| 339 | def external_accounts(session): |
Tres Seaver | d3944af | 2021-07-08 15:51:47 -0400 | [diff] [blame] | 340 | session.install( |
| 341 | *TEST_DEPENDENCIES_SYNC, |
| 342 | "google-auth", |
| 343 | "google-api-python-client", |
| 344 | "enum34", |
| 345 | ) |
| 346 | default( |
| 347 | session, |
| 348 | "system_tests_sync/test_external_accounts.py", |
| 349 | *session.posargs, |
| 350 | ) |
Bu Sun Kim | e87b1ec | 2021-03-15 09:02:06 -0600 | [diff] [blame] | 351 | |
Christopher Wilcox | 7e15258 | 2020-09-28 15:27:20 -0700 | [diff] [blame] | 352 | |
bojeil-google | ed8e035 | 2021-08-16 12:34:28 -0700 | [diff] [blame] | 353 | @nox.session(python=PYTHON_VERSIONS_SYNC) |
| 354 | def downscoping(session): |
| 355 | session.install( |
| 356 | *TEST_DEPENDENCIES_SYNC, |
| 357 | "google-auth", |
| 358 | "google-cloud-storage", |
| 359 | ) |
| 360 | default( |
| 361 | session, |
| 362 | "system_tests_sync/test_downscoping.py", |
| 363 | *session.posargs, |
| 364 | ) |
| 365 | |
| 366 | |
Ryan Kohler | 48e8be3 | 2021-03-25 17:35:43 -0700 | [diff] [blame] | 367 | # ASYNC SYSTEM TESTS |
| 368 | |
Christopher Wilcox | 7e15258 | 2020-09-28 15:27:20 -0700 | [diff] [blame] | 369 | @nox.session(python=PYTHON_VERSIONS_ASYNC) |
| 370 | def service_account_async(session): |
Bu Sun Kim | e87b1ec | 2021-03-15 09:02:06 -0600 | [diff] [blame] | 371 | session.install(*(TEST_DEPENDENCIES_SYNC + TEST_DEPENDENCIES_ASYNC)) |
Christopher Wilcox | 7e15258 | 2020-09-28 15:27:20 -0700 | [diff] [blame] | 372 | session.install(LIBRARY_DIR) |
Bu Sun Kim | e87b1ec | 2021-03-15 09:02:06 -0600 | [diff] [blame] | 373 | default( |
Tres Seaver | d3944af | 2021-07-08 15:51:47 -0400 | [diff] [blame] | 374 | session, |
| 375 | "system_tests_async/test_service_account.py", |
| 376 | *session.posargs, |
Bu Sun Kim | e87b1ec | 2021-03-15 09:02:06 -0600 | [diff] [blame] | 377 | ) |
Christopher Wilcox | 7e15258 | 2020-09-28 15:27:20 -0700 | [diff] [blame] | 378 | |
| 379 | |
| 380 | @nox.session(python=PYTHON_VERSIONS_ASYNC) |
| 381 | def default_explicit_service_account_async(session): |
| 382 | session.env[EXPLICIT_CREDENTIALS_ENV] = SERVICE_ACCOUNT_FILE |
| 383 | session.env[EXPECT_PROJECT_ENV] = "1" |
| 384 | session.install(*(TEST_DEPENDENCIES_SYNC + TEST_DEPENDENCIES_ASYNC)) |
| 385 | session.install(LIBRARY_DIR) |
Bu Sun Kim | e87b1ec | 2021-03-15 09:02:06 -0600 | [diff] [blame] | 386 | default( |
| 387 | session, |
Ryan Kohler | 48e8be3 | 2021-03-25 17:35:43 -0700 | [diff] [blame] | 388 | "system_tests_async/test_default.py", |
Bu Sun Kim | e87b1ec | 2021-03-15 09:02:06 -0600 | [diff] [blame] | 389 | "system_tests_async/test_id_token.py", |
Tres Seaver | d3944af | 2021-07-08 15:51:47 -0400 | [diff] [blame] | 390 | *session.posargs, |
Bu Sun Kim | e87b1ec | 2021-03-15 09:02:06 -0600 | [diff] [blame] | 391 | ) |
Christopher Wilcox | 7e15258 | 2020-09-28 15:27:20 -0700 | [diff] [blame] | 392 | |
| 393 | |
| 394 | @nox.session(python=PYTHON_VERSIONS_ASYNC) |
| 395 | def default_explicit_authorized_user_async(session): |
| 396 | session.env[EXPLICIT_CREDENTIALS_ENV] = AUTHORIZED_USER_FILE |
| 397 | session.install(*(TEST_DEPENDENCIES_SYNC + TEST_DEPENDENCIES_ASYNC)) |
| 398 | session.install(LIBRARY_DIR) |
Bu Sun Kim | e87b1ec | 2021-03-15 09:02:06 -0600 | [diff] [blame] | 399 | default( |
Tres Seaver | d3944af | 2021-07-08 15:51:47 -0400 | [diff] [blame] | 400 | session, |
| 401 | "system_tests_async/test_default.py", |
| 402 | *session.posargs, |
Bu Sun Kim | e87b1ec | 2021-03-15 09:02:06 -0600 | [diff] [blame] | 403 | ) |
Christopher Wilcox | 7e15258 | 2020-09-28 15:27:20 -0700 | [diff] [blame] | 404 | |
| 405 | |
| 406 | @nox.session(python=PYTHON_VERSIONS_ASYNC) |
| 407 | def default_explicit_authorized_user_explicit_project_async(session): |
| 408 | session.env[EXPLICIT_CREDENTIALS_ENV] = AUTHORIZED_USER_FILE |
| 409 | session.env[EXPLICIT_PROJECT_ENV] = "example-project" |
| 410 | session.env[EXPECT_PROJECT_ENV] = "1" |
| 411 | session.install(*(TEST_DEPENDENCIES_SYNC + TEST_DEPENDENCIES_ASYNC)) |
| 412 | session.install(LIBRARY_DIR) |
Bu Sun Kim | e87b1ec | 2021-03-15 09:02:06 -0600 | [diff] [blame] | 413 | default( |
Tres Seaver | d3944af | 2021-07-08 15:51:47 -0400 | [diff] [blame] | 414 | session, |
| 415 | "system_tests_async/test_default.py", |
| 416 | *session.posargs, |
Bu Sun Kim | e87b1ec | 2021-03-15 09:02:06 -0600 | [diff] [blame] | 417 | ) |
Christopher Wilcox | 7e15258 | 2020-09-28 15:27:20 -0700 | [diff] [blame] | 418 | |
| 419 | |
| 420 | @nox.session(python=PYTHON_VERSIONS_ASYNC) |
| 421 | def default_cloud_sdk_service_account_async(session): |
| 422 | configure_cloud_sdk(session, SERVICE_ACCOUNT_FILE) |
| 423 | session.env[EXPECT_PROJECT_ENV] = "1" |
| 424 | session.install(*(TEST_DEPENDENCIES_SYNC + TEST_DEPENDENCIES_ASYNC)) |
| 425 | session.install(LIBRARY_DIR) |
Bu Sun Kim | e87b1ec | 2021-03-15 09:02:06 -0600 | [diff] [blame] | 426 | default( |
Tres Seaver | d3944af | 2021-07-08 15:51:47 -0400 | [diff] [blame] | 427 | session, |
| 428 | "system_tests_async/test_default.py", |
| 429 | *session.posargs, |
Bu Sun Kim | e87b1ec | 2021-03-15 09:02:06 -0600 | [diff] [blame] | 430 | ) |
Christopher Wilcox | 7e15258 | 2020-09-28 15:27:20 -0700 | [diff] [blame] | 431 | |
| 432 | |
| 433 | @nox.session(python=PYTHON_VERSIONS_ASYNC) |
| 434 | def default_cloud_sdk_authorized_user_async(session): |
| 435 | configure_cloud_sdk(session, AUTHORIZED_USER_FILE) |
| 436 | session.install(*(TEST_DEPENDENCIES_SYNC + TEST_DEPENDENCIES_ASYNC)) |
| 437 | session.install(LIBRARY_DIR) |
Bu Sun Kim | e87b1ec | 2021-03-15 09:02:06 -0600 | [diff] [blame] | 438 | default( |
Tres Seaver | d3944af | 2021-07-08 15:51:47 -0400 | [diff] [blame] | 439 | session, |
| 440 | "system_tests_async/test_default.py", |
| 441 | *session.posargs, |
Bu Sun Kim | e87b1ec | 2021-03-15 09:02:06 -0600 | [diff] [blame] | 442 | ) |
Christopher Wilcox | 7e15258 | 2020-09-28 15:27:20 -0700 | [diff] [blame] | 443 | |
| 444 | |
| 445 | @nox.session(python=PYTHON_VERSIONS_ASYNC) |
| 446 | def default_cloud_sdk_authorized_user_configured_project_async(session): |
| 447 | configure_cloud_sdk(session, AUTHORIZED_USER_FILE, project=True) |
| 448 | session.env[EXPECT_PROJECT_ENV] = "1" |
| 449 | session.install(*(TEST_DEPENDENCIES_SYNC + TEST_DEPENDENCIES_ASYNC)) |
| 450 | session.install(LIBRARY_DIR) |
Bu Sun Kim | e87b1ec | 2021-03-15 09:02:06 -0600 | [diff] [blame] | 451 | default( |
Tres Seaver | d3944af | 2021-07-08 15:51:47 -0400 | [diff] [blame] | 452 | session, |
| 453 | "system_tests_async/test_default.py", |
| 454 | *session.posargs, |
Bu Sun Kim | e87b1ec | 2021-03-15 09:02:06 -0600 | [diff] [blame] | 455 | ) |