14
14
15
15
import json
16
16
17
- import httplib2
18
17
from six .moves import http_client
19
18
from six .moves import urllib
20
19
import unittest2
21
20
22
- from oauth2client import GOOGLE_TOKEN_INFO_URI
23
- from oauth2client .client import GoogleCredentials
24
- from oauth2client .contrib .gce import AppAssertionCredentials
21
+ import oauth2client
22
+ from oauth2client import client
23
+ from oauth2client import transport
24
+ from oauth2client .contrib import gce
25
25
26
26
27
27
class TestComputeEngine (unittest2 .TestCase ):
28
28
29
29
def test_application_default (self ):
30
- default_creds = GoogleCredentials .get_application_default ()
31
- self .assertIsInstance (default_creds , AppAssertionCredentials )
30
+ default_creds = client . GoogleCredentials .get_application_default ()
31
+ self .assertIsInstance (default_creds , gce . AppAssertionCredentials )
32
32
33
33
def test_token_info (self ):
34
- credentials = AppAssertionCredentials ([])
35
- http = httplib2 . Http ()
34
+ credentials = gce . AppAssertionCredentials ([])
35
+ http = transport . get_http_object ()
36
36
37
37
# First refresh to get the access token.
38
38
self .assertIsNone (credentials .access_token )
@@ -41,9 +41,9 @@ def test_token_info(self):
41
41
42
42
# Then check the access token against the token info API.
43
43
query_params = {'access_token' : credentials .access_token }
44
- token_uri = (GOOGLE_TOKEN_INFO_URI + '?' +
44
+ token_uri = (oauth2client . GOOGLE_TOKEN_INFO_URI + '?' +
45
45
urllib .parse .urlencode (query_params ))
46
- response , content = http .request (token_uri )
46
+ response , content = transport .request (http , token_uri )
47
47
self .assertEqual (response .status , http_client .OK )
48
48
49
49
content = content .decode ('utf-8' )
0 commit comments