Skip to content

Commit e408f8e

Browse files
authored
test: re-enable system tests (#670)
1 parent 596e9d8 commit e408f8e

File tree

15 files changed

+38
-37
lines changed

15 files changed

+38
-37
lines changed

packages/google-auth/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ scripts/local_test_setup
3030
tests/data/key.json
3131
tests/data/key.p12
3232
tests/data/user-key.json
33+
system_tests/data/
3334

3435
# PyCharm configuration:
3536
.idea

packages/google-auth/.kokoro/build.sh

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,14 @@ env | grep KOKORO
3131
export GOOGLE_APPLICATION_CREDENTIALS=${KOKORO_GFILE_DIR}/service-account.json
3232

3333
# Setup project id.
34-
export PROJECT_ID=$(cat "${KOKORO_GFILE_DIR}/project-id.json")
34+
export PROJECT_ID=$(cat "${KOKORO_GFILE_DIR}/project-id.txt")
35+
36+
# Activate gcloud with service account credentials
37+
gcloud auth activate-service-account --key-file=$GOOGLE_APPLICATION_CREDENTIALS
38+
gcloud config set project ${PROJECT_ID}
39+
40+
# Decrypt system test secrets
41+
./scripts/decrypt-secrets.sh
3542

3643
# Remove old nox
3744
python3 -m pip uninstall --yes --quiet nox-automation
@@ -47,3 +54,10 @@ if [[ -n "${NOX_SESSION:-}" ]]; then
4754
else
4855
python3 -m nox
4956
fi
57+
58+
59+
# Decrypt system test secrets
60+
./scripts/decrypt-secrets.sh
61+
62+
# Run system tests which use a different noxfile
63+
python3 -m nox -f system_tests/noxfile.py

packages/google-auth/.kokoro/continuous/common.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ action {
1111
gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline"
1212

1313
# Download resources for system tests (service account key, etc.)
14-
gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/google-cloud-python"
14+
gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/google-auth-library-python"
1515

1616
# Use the trampoline script to run in docker.
1717
build_file: "google-auth-library-python/.kokoro/trampoline.sh"

packages/google-auth/.kokoro/presubmit/common.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ action {
1111
gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline"
1212

1313
# Download resources for system tests (service account key, etc.)
14-
gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/google-cloud-python"
14+
gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/google-auth-library-python"
1515

1616
# Use the trampoline script to run in docker.
1717
build_file: "google-auth-library-python/.kokoro/trampoline.sh"

packages/google-auth/synth.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
s.move(
1111
templated_files / ".kokoro",
1212
excludes=[
13-
".kokoro/continuous/common.cfg",
14-
".kokoro/presubmit/common.cfg",
15-
".kokoro/build.sh",
13+
"continuous/common.cfg",
14+
"presubmit/common.cfg",
15+
"build.sh",
1616
],
1717
) # just move kokoro configs

packages/google-auth/system_tests/__init__.py

Whitespace-only changes.

packages/google-auth/system_tests/noxfile.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
import py.path
3131

3232
HERE = os.path.abspath(os.path.dirname(__file__))
33-
LIBRARY_DIR = os.path.join(HERE, "..")
33+
LIBRARY_DIR = os.path.abspath(os.path.dirname(HERE))
3434
DATA_DIR = os.path.join(HERE, "data")
3535
SERVICE_ACCOUNT_FILE = os.path.join(DATA_DIR, "service_account.json")
3636
AUTHORIZED_USER_FILE = os.path.join(DATA_DIR, "authorized_user.json")
@@ -169,7 +169,7 @@ def configure_cloud_sdk(session, application_default_credentials, project=False)
169169
# Test sesssions
170170

171171
TEST_DEPENDENCIES_ASYNC = ["aiohttp", "pytest-asyncio", "nest-asyncio"]
172-
TEST_DEPENDENCIES_SYNC = ["pytest", "requests"]
172+
TEST_DEPENDENCIES_SYNC = ["pytest", "requests", "mock"]
173173
PYTHON_VERSIONS_ASYNC = ["3.7"]
174174
PYTHON_VERSIONS_SYNC = ["2.7", "3.7"]
175175

@@ -249,6 +249,7 @@ def app_engine(session):
249249
session.log("Skipping App Engine tests.")
250250
return
251251

252+
session.install(LIBRARY_DIR)
252253
# Unlike the default tests above, the App Engine system test require a
253254
# 'real' gcloud sdk installation that is configured to deploy to an
254255
# app engine project.
@@ -269,9 +270,8 @@ def app_engine(session):
269270
application_url = GAE_APP_URL_TMPL.format(GAE_TEST_APP_SERVICE, project_id)
270271

271272
# Vendor in the test application's dependencies
272-
session.chdir(os.path.join(HERE, "../app_engine_test_app"))
273+
session.chdir(os.path.join(HERE, "system_tests_sync/app_engine_test_app"))
273274
session.install(*TEST_DEPENDENCIES_SYNC)
274-
session.install(LIBRARY_DIR)
275275
session.run(
276276
"pip", "install", "--target", "lib", "-r", "requirements.txt", silent=True
277277
)
@@ -288,7 +288,7 @@ def app_engine(session):
288288
@nox.session(python=PYTHON_VERSIONS_SYNC)
289289
def grpc(session):
290290
session.install(LIBRARY_DIR)
291-
session.install(*TEST_DEPENDENCIES_SYNC, "google-cloud-pubsub==1.0.0")
291+
session.install(*TEST_DEPENDENCIES_SYNC, "google-cloud-pubsub==1.7.0")
292292
session.env[EXPLICIT_CREDENTIALS_ENV] = SERVICE_ACCOUNT_FILE
293293
session.run("pytest", "system_tests_sync/test_grpc.py")
294294

10.1 KB
Binary file not shown.

packages/google-auth/system_tests/system_tests_async/__init__.py

Whitespace-only changes.

packages/google-auth/system_tests/system_tests_async/conftest.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@ async def _token_info(access_token=None, id_token=None):
7171
url = _helpers.update_query(sync_conftest.TOKEN_INFO_URL, query_params)
7272

7373
response = await http_request(url=url, method="GET")
74-
data = await response.data.read()
74+
75+
data = await response.content()
7576

7677
return json.loads(data.decode("utf-8"))
7778

0 commit comments

Comments
 (0)