Skip to content

Commit

Permalink
Re-apply bytes vs. text stuff in moved code.
Browse files Browse the repository at this point in the history
  • Loading branch information
tseaver committed Feb 3, 2015
1 parent b69cab8 commit 7c1ba1b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions gcloud/credentials.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
import base64
import calendar
import datetime
import urllib
import six
from six.moves.urllib.parse import urlencode # pylint: disable=F0401

from Crypto.Hash import SHA256
from Crypto.PublicKey import RSA
Expand Down Expand Up @@ -260,4 +260,4 @@ def generate_signed_url(credentials, resource, expiration,
# Return the built URL.
return '{endpoint}{resource}?{querystring}'.format(
endpoint=api_access_endpoint, resource=resource,
querystring=urllib.urlencode(query_params))
querystring=urlencode(query_params))
14 changes: 7 additions & 7 deletions gcloud/test_credentials.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def test_w_expiration_int(self):

ENDPOINT = 'http://api.example.com'
RESOURCE = '/name/path'
SIGNED = base64.b64encode('DEADBEEF')
SIGNED = base64.b64encode(b'DEADBEEF')
CREDENTIALS = _Credentials()

def _get_signed_query_params(*args):
Expand Down Expand Up @@ -142,17 +142,17 @@ def _run_test_with_credentials(self, credentials, account_name):
sha256 = _SHA256()

EXPIRATION = '100'
SIGNATURE_STRING = 'dummy_signature'
SIGNATURE_STRING = b'dummy_signature'
with _Monkey(MUT, crypt=crypt, RSA=rsa, PKCS1_v1_5=pkcs_v1_5,
SHA256=sha256):
result = self._callFUT(credentials, EXPIRATION, SIGNATURE_STRING)

if crypt._pkcs12_key_as_pem_called:
self.assertEqual(crypt._private_key_text,
base64.b64encode('dummy_private_key_text'))
base64.b64encode(b'dummy_private_key_text'))
self.assertEqual(crypt._private_key_password, 'notasecret')
self.assertEqual(sha256._signature_string, SIGNATURE_STRING)
SIGNED = base64.b64encode('DEADBEEF')
SIGNED = base64.b64encode(b'DEADBEEF')
expected_query = {
'Expires': EXPIRATION,
'GoogleAccessId': account_name,
Expand All @@ -166,7 +166,7 @@ def test_signed_jwt_for_p12(self):
scopes = []
ACCOUNT_NAME = 'dummy_service_account_name'
credentials = client.SignedJwtAssertionCredentials(
ACCOUNT_NAME, 'dummy_private_key_text', scopes)
ACCOUNT_NAME, b'dummy_private_key_text', scopes)
self._run_test_with_credentials(credentials, ACCOUNT_NAME)

def test_service_account_via_json_key(self):
Expand Down Expand Up @@ -205,7 +205,7 @@ def test_signed_jwt_for_p12(self):
from gcloud import credentials as MUT

scopes = []
PRIVATE_KEY = 'dummy_private_key_text'
PRIVATE_KEY = b'dummy_private_key_text'
credentials = client.SignedJwtAssertionCredentials(
'dummy_service_account_name', PRIVATE_KEY, scopes)
crypt = _Crypt()
Expand Down Expand Up @@ -378,7 +378,7 @@ def new(self, pem_key):

def sign(self, signature_hash):
self._signature_hash = signature_hash
return 'DEADBEEF'
return b'DEADBEEF'


class _SHA256(object):
Expand Down

0 comments on commit 7c1ba1b

Please sign in to comment.