diff options
author | Danny Hermes <daniel.j.hermes@gmail.com> | 2016-08-10 15:21:57 -0700 |
---|---|---|
committer | Danny Hermes <daniel.j.hermes@gmail.com> | 2016-08-10 15:23:02 -0700 |
commit | e0b2256e3db98c5376258f9b98ca8fe31a24be28 (patch) | |
tree | ee2b17414359d6f0ef8e7b461aff264d2622bb7e | |
parent | 2c442070d526d72972acc3120b4d6f00eeac71bb (diff) | |
download | oauth2client-e0b2256e3db98c5376258f9b98ca8fe31a24be28.tar.gz |
Use transport helpers in system tests
-rw-r--r-- | scripts/run_gce_system_tests.py | 20 | ||||
-rw-r--r-- | scripts/run_system_tests.py | 14 |
2 files changed, 17 insertions, 17 deletions
diff --git a/scripts/run_gce_system_tests.py b/scripts/run_gce_system_tests.py index d446f9c..01b7ba6 100644 --- a/scripts/run_gce_system_tests.py +++ b/scripts/run_gce_system_tests.py @@ -14,25 +14,25 @@ import json -import httplib2 from six.moves import http_client from six.moves import urllib import unittest2 -from oauth2client import GOOGLE_TOKEN_INFO_URI -from oauth2client.client import GoogleCredentials -from oauth2client.contrib.gce import AppAssertionCredentials +import oauth2client +from oauth2client import client +from oauth2client import transport +from oauth2client.contrib import gce class TestComputeEngine(unittest2.TestCase): def test_application_default(self): - default_creds = GoogleCredentials.get_application_default() - self.assertIsInstance(default_creds, AppAssertionCredentials) + default_creds = client.GoogleCredentials.get_application_default() + self.assertIsInstance(default_creds, gce.AppAssertionCredentials) def test_token_info(self): - credentials = AppAssertionCredentials([]) - http = httplib2.Http() + credentials = gce.AppAssertionCredentials([]) + http = transport.get_http_object() # First refresh to get the access token. self.assertIsNone(credentials.access_token) @@ -41,9 +41,9 @@ class TestComputeEngine(unittest2.TestCase): # Then check the access token against the token info API. query_params = {'access_token': credentials.access_token} - token_uri = (GOOGLE_TOKEN_INFO_URI + '?' + + token_uri = (oauth2client.GOOGLE_TOKEN_INFO_URI + '?' + urllib.parse.urlencode(query_params)) - response, content = http.request(token_uri) + response, content = transport.request(http, token_uri) self.assertEqual(response.status, http_client.OK) content = content.decode('utf-8') diff --git a/scripts/run_system_tests.py b/scripts/run_system_tests.py index ce99e7c..4c9c80c 100644 --- a/scripts/run_system_tests.py +++ b/scripts/run_system_tests.py @@ -15,12 +15,12 @@ import json import os -import httplib2 from six.moves import http_client import oauth2client from oauth2client import client -from oauth2client.service_account import ServiceAccountCredentials +from oauth2client import service_account +from oauth2client import transport JSON_KEY_PATH = os.getenv('OAUTH2CLIENT_TEST_JSON_KEY_PATH') @@ -56,8 +56,8 @@ def _require_environ(): def _check_user_info(credentials, expected_email): - http = credentials.authorize(httplib2.Http()) - response, content = http.request(USER_INFO) + http = credentials.authorize(transport.get_http_object()) + response, content = transport.request(http, USER_INFO) if response.status != http_client.OK: raise ValueError('Expected 200 OK response.') @@ -68,14 +68,14 @@ def _check_user_info(credentials, expected_email): def run_json(): - credentials = ServiceAccountCredentials.from_json_keyfile_name( - JSON_KEY_PATH, scopes=SCOPE) + factory = service_account.ServiceAccountCredentials.from_json_keyfile_name + credentials = factory(JSON_KEY_PATH, scopes=SCOPE) service_account_email = credentials._service_account_email _check_user_info(credentials, service_account_email) def run_p12(): - credentials = ServiceAccountCredentials.from_p12_keyfile( + credentials = service_account.ServiceAccountCredentials.from_p12_keyfile( P12_KEY_EMAIL, P12_KEY_PATH, scopes=SCOPE) _check_user_info(credentials, P12_KEY_EMAIL) |