Merge "Add a test that exercises the GCS Credentials class"
This commit is contained in:
commit
eb9eb8bc12
1
roles/upload-logs-gcs/library/test-fixtures/auth.json
Normal file
1
roles/upload-logs-gcs/library/test-fixtures/auth.json
Normal file
@ -0,0 +1 @@
|
||||
{"access_token": "something", "expires_in": 3599, "token_type": "Bearer"}
|
@ -26,6 +26,7 @@ import fixtures
|
||||
|
||||
from bs4 import BeautifulSoup
|
||||
from .zuul_google_storage_upload import FileList, Indexer, FileDetail
|
||||
from .zuul_google_storage_upload import Credentials
|
||||
|
||||
|
||||
FIXTURE_DIR = os.path.join(os.path.dirname(__file__),
|
||||
@ -404,3 +405,13 @@ class TestFileDetail(testtools.TestCase):
|
||||
|
||||
self.assertEqual(time.gmtime(0), file_detail.last_modified)
|
||||
self.assertEqual(0, file_detail.size)
|
||||
|
||||
|
||||
class TestCredential(testtools.TestCase):
|
||||
|
||||
def test_credential(self):
|
||||
path = os.path.join(FIXTURE_DIR, 'auth.json')
|
||||
headers = {}
|
||||
c = Credentials(path)
|
||||
c.before_request(None, None, None, headers)
|
||||
self.assertEqual("Bearer something", headers['authorization'])
|
||||
|
@ -260,7 +260,7 @@ def sizeof_fmt(num, suffix='B'):
|
||||
|
||||
class Credentials(gce_cred.Credentials):
|
||||
def __init__(self, path):
|
||||
super().__init__()
|
||||
super(Credentials, self).__init__()
|
||||
self._path = path
|
||||
self.refresh(None)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user