-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change error for generating signed url.
- Loading branch information
1 parent
771bc7a
commit 6c00bf2
Showing
2 changed files
with
22 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,7 +40,7 @@ def _callFUT(self, *args, **kwargs): | |
return generate_signed_url(*args, **kwargs) | ||
|
||
def _generate_helper(self, response_type=None, response_disposition=None, | ||
generation=None): | ||
generation=None, credentials=None): | ||
import base64 | ||
from six.moves.urllib.parse import parse_qs | ||
from six.moves.urllib.parse import urlsplit | ||
|
@@ -50,7 +50,7 @@ def _generate_helper(self, response_type=None, response_disposition=None, | |
ENDPOINT = 'http://api.example.com' | ||
RESOURCE = '/name/path' | ||
SIGNED = base64.b64encode(b'DEADBEEF') | ||
CREDENTIALS = _Credentials() | ||
CREDENTIALS = credentials or _Credentials() | ||
|
||
def _get_signed_query_params(*args): | ||
credentials, expiration = args[:2] | ||
|
@@ -90,15 +90,19 @@ def _get_signed_query_params(*args): | |
self.assertEqual(frag, '') | ||
|
||
def test_w_expiration_int(self): | ||
self._generate_helper() | ||
self._generate_helper(credentials=_Credentials()) | ||
|
||
def test_w_google_credentials(self): | ||
self._generate_helper(credentials=_GoogleCredentials()) | ||
|
||
def test_w_custom_fields(self): | ||
response_type = 'text/plain' | ||
response_disposition = 'attachment; filename=blob.png' | ||
generation = '123' | ||
self._generate_helper(response_type=response_type, | ||
response_disposition=response_disposition, | ||
generation=generation) | ||
generation=generation, | ||
credentials=_Credentials()) | ||
|
||
|
||
class Test__get_signed_query_params(unittest2.TestCase): | ||
|
@@ -226,6 +230,12 @@ def sign_blob(self, bytes_to_sign): | |
return None, self._sign_result | ||
|
||
|
||
class _GoogleCredentials(object): | ||
|
||
def __init__(self, service_account_email='[email protected]'): | ||
self.service_account_email = service_account_email | ||
|
||
|
||
class _Client(object): | ||
|
||
def __init__(self): | ||
|