9f0d22d678
Google keeps changing the with_scopes method signature. We need to override that method in order to keep our path attribute around when it re-instantiates the object. As long as we always call refresh after the object is created, we can drop our custom constructor and then change with_scopes to use generic arguments. This should keep up with any further minor API changes without needing further local changes. Also, a minor inconsistency in command line arguments (used only for local manual testing) is corrected. Change-Id: Id41dfc464eb86429771a78c1fefae006e0915cb9
40 lines
1.2 KiB
Python
40 lines
1.2 KiB
Python
# Copyright (C) 2018-2019 Red Hat, Inc.
|
|
#
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
# you may not use this file except in compliance with the License.
|
|
# You may obtain a copy of the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
# implied.
|
|
#
|
|
# See the License for the specific language governing permissions and
|
|
# limitations under the License.
|
|
|
|
# Make coding more python3-ish
|
|
from __future__ import (absolute_import, division, print_function)
|
|
__metaclass__ = type
|
|
|
|
import os
|
|
import testtools
|
|
|
|
from .zuul_google_storage_upload import Credentials
|
|
|
|
|
|
FIXTURE_DIR = os.path.join(os.path.dirname(__file__),
|
|
'test-fixtures')
|
|
|
|
|
|
class TestCredential(testtools.TestCase):
|
|
|
|
def test_credential(self):
|
|
path = os.path.join(FIXTURE_DIR, 'gcs', 'auth.json')
|
|
headers = {}
|
|
c = Credentials()
|
|
c._set_path(path)
|
|
c.before_request(None, None, None, headers)
|
|
self.assertEqual("Bearer something", headers['authorization'])
|