diff options
author | Bu Sun Kim <8822365+busunkim96@users.noreply.github.com> | 2021-01-22 13:43:41 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-22 13:43:41 -0700 |
commit | 621f54bd70eded4f68d2caa9b894d5504117452b (patch) | |
tree | de847889bf849147c10efcfe3c38836ccc7ccf23 /system_tests | |
parent | 694e5580d37968f415b347a4310bb01cfa72f0e3 (diff) | |
download | google-auth-library-python-621f54bd70eded4f68d2caa9b894d5504117452b.tar.gz |
test: re-enable system tests (#670)
Diffstat (limited to 'system_tests')
-rw-r--r-- | system_tests/__init__.py | 0 | ||||
-rw-r--r-- | system_tests/noxfile.py | 10 | ||||
-rw-r--r-- | system_tests/secrets.tar.enc | bin | 0 -> 10323 bytes | |||
-rw-r--r-- | system_tests/system_tests_async/__init__.py | 0 | ||||
-rw-r--r-- | system_tests/system_tests_async/conftest.py | 3 | ||||
-rw-r--r-- | system_tests/system_tests_async/test_default.py | 5 | ||||
-rw-r--r-- | system_tests/system_tests_sync/app_engine_test_app/requirements.txt | 2 | ||||
-rw-r--r-- | system_tests/system_tests_sync/secrets.tar.enc | bin | 10323 -> 0 bytes | |||
-rw-r--r-- | system_tests/system_tests_sync/test_grpc.py | 23 | ||||
-rw-r--r-- | system_tests/system_tests_sync/test_mtls_http.py | 5 |
10 files changed, 17 insertions, 31 deletions
diff --git a/system_tests/__init__.py b/system_tests/__init__.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/system_tests/__init__.py diff --git a/system_tests/noxfile.py b/system_tests/noxfile.py index dcfe8ee..5d0014b 100644 --- a/system_tests/noxfile.py +++ b/system_tests/noxfile.py @@ -30,7 +30,7 @@ import nox import py.path HERE = os.path.abspath(os.path.dirname(__file__)) -LIBRARY_DIR = os.path.join(HERE, "..") +LIBRARY_DIR = os.path.abspath(os.path.dirname(HERE)) DATA_DIR = os.path.join(HERE, "data") SERVICE_ACCOUNT_FILE = os.path.join(DATA_DIR, "service_account.json") 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) # Test sesssions TEST_DEPENDENCIES_ASYNC = ["aiohttp", "pytest-asyncio", "nest-asyncio"] -TEST_DEPENDENCIES_SYNC = ["pytest", "requests"] +TEST_DEPENDENCIES_SYNC = ["pytest", "requests", "mock"] PYTHON_VERSIONS_ASYNC = ["3.7"] PYTHON_VERSIONS_SYNC = ["2.7", "3.7"] @@ -249,6 +249,7 @@ def app_engine(session): session.log("Skipping App Engine tests.") return + session.install(LIBRARY_DIR) # Unlike the default tests above, the App Engine system test require a # 'real' gcloud sdk installation that is configured to deploy to an # app engine project. @@ -269,9 +270,8 @@ def app_engine(session): application_url = GAE_APP_URL_TMPL.format(GAE_TEST_APP_SERVICE, project_id) # Vendor in the test application's dependencies - session.chdir(os.path.join(HERE, "../app_engine_test_app")) + session.chdir(os.path.join(HERE, "system_tests_sync/app_engine_test_app")) session.install(*TEST_DEPENDENCIES_SYNC) - session.install(LIBRARY_DIR) session.run( "pip", "install", "--target", "lib", "-r", "requirements.txt", silent=True ) @@ -288,7 +288,7 @@ def app_engine(session): @nox.session(python=PYTHON_VERSIONS_SYNC) def grpc(session): session.install(LIBRARY_DIR) - session.install(*TEST_DEPENDENCIES_SYNC, "google-cloud-pubsub==1.0.0") + session.install(*TEST_DEPENDENCIES_SYNC, "google-cloud-pubsub==1.7.0") session.env[EXPLICIT_CREDENTIALS_ENV] = SERVICE_ACCOUNT_FILE session.run("pytest", "system_tests_sync/test_grpc.py") diff --git a/system_tests/secrets.tar.enc b/system_tests/secrets.tar.enc Binary files differnew file mode 100644 index 0000000..29e0692 --- /dev/null +++ b/system_tests/secrets.tar.enc diff --git a/system_tests/system_tests_async/__init__.py b/system_tests/system_tests_async/__init__.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/system_tests/system_tests_async/__init__.py diff --git a/system_tests/system_tests_async/conftest.py b/system_tests/system_tests_async/conftest.py index ecff74c..47a473e 100644 --- a/system_tests/system_tests_async/conftest.py +++ b/system_tests/system_tests_async/conftest.py @@ -71,7 +71,8 @@ async def token_info(http_request): url = _helpers.update_query(sync_conftest.TOKEN_INFO_URL, query_params) response = await http_request(url=url, method="GET") - data = await response.data.read() + + data = await response.content() return json.loads(data.decode("utf-8")) diff --git a/system_tests/system_tests_async/test_default.py b/system_tests/system_tests_async/test_default.py index 383cbff..32299c0 100644 --- a/system_tests/system_tests_async/test_default.py +++ b/system_tests/system_tests_async/test_default.py @@ -15,14 +15,13 @@ import os import pytest -import google.auth +from google.auth import _default_async EXPECT_PROJECT_ID = os.environ.get("EXPECT_PROJECT_ID") @pytest.mark.asyncio async def test_application_default_credentials(verify_refresh): - credentials, project_id = google.auth.default_async() - #breakpoint() + credentials, project_id = _default_async.default_async() if EXPECT_PROJECT_ID is not None: assert project_id is not None diff --git a/system_tests/system_tests_sync/app_engine_test_app/requirements.txt b/system_tests/system_tests_sync/app_engine_test_app/requirements.txt index e390e14..bd5c476 100644 --- a/system_tests/system_tests_sync/app_engine_test_app/requirements.txt +++ b/system_tests/system_tests_sync/app_engine_test_app/requirements.txt @@ -1,3 +1,3 @@ urllib3 # Relative path to google-auth-python's source. -../.. +../../.. diff --git a/system_tests/system_tests_sync/secrets.tar.enc b/system_tests/system_tests_sync/secrets.tar.enc Binary files differdeleted file mode 100644 index af10c71..0000000 --- a/system_tests/system_tests_sync/secrets.tar.enc +++ /dev/null diff --git a/system_tests/system_tests_sync/test_grpc.py b/system_tests/system_tests_sync/test_grpc.py index 650fa96..7dcbd4c 100644 --- a/system_tests/system_tests_sync/test_grpc.py +++ b/system_tests/system_tests_sync/test_grpc.py @@ -17,8 +17,6 @@ import google.auth.credentials import google.auth.jwt import google.auth.transport.grpc from google.cloud import pubsub_v1 -from google.cloud.pubsub_v1.gapic import publisher_client -from google.cloud.pubsub_v1.gapic.transports import publisher_grpc_transport def test_grpc_request_with_regular_credentials(http_request): @@ -27,13 +25,8 @@ def test_grpc_request_with_regular_credentials(http_request): credentials, ["https://www.googleapis.com/auth/pubsub"] ) - transport = publisher_grpc_transport.PublisherGrpcTransport( - address=publisher_client.PublisherClient.SERVICE_ADDRESS, - credentials=credentials, - ) - # Create a pub/sub client. - client = pubsub_v1.PublisherClient(transport=transport) + client = pubsub_v1.PublisherClient(credentials=credentials) # list the topics and drain the iterator to test that an authorized API # call works. @@ -48,13 +41,8 @@ def test_grpc_request_with_jwt_credentials(): credentials, audience=audience ) - transport = publisher_grpc_transport.PublisherGrpcTransport( - address=publisher_client.PublisherClient.SERVICE_ADDRESS, - credentials=credentials, - ) - # Create a pub/sub client. - client = pubsub_v1.PublisherClient(transport=transport) + client = pubsub_v1.PublisherClient(credentials=credentials) # list the topics and drain the iterator to test that an authorized API # call works. @@ -68,13 +56,8 @@ def test_grpc_request_with_on_demand_jwt_credentials(): credentials ) - transport = publisher_grpc_transport.PublisherGrpcTransport( - address=publisher_client.PublisherClient.SERVICE_ADDRESS, - credentials=credentials, - ) - # Create a pub/sub client. - client = pubsub_v1.PublisherClient(transport=transport) + client = pubsub_v1.PublisherClient(credentials=credentials) # list the topics and drain the iterator to test that an authorized API # call works. diff --git a/system_tests/system_tests_sync/test_mtls_http.py b/system_tests/system_tests_sync/test_mtls_http.py index 7c56496..bcf2a59 100644 --- a/system_tests/system_tests_sync/test_mtls_http.py +++ b/system_tests/system_tests_sync/test_mtls_http.py @@ -13,8 +13,11 @@ # limitations under the License. import json -from os import path +import mock +import os import time +from os import path + import google.auth import google.auth.credentials |