Script 'mail_helper' called by obssrc
Hello community,
here is the log from the commit of package python-google-auth-httplib2 for
openSUSE:Factory checked in at 2021-08-26 23:15:19
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python-google-auth-httplib2 (Old)
and /work/SRC/openSUSE:Factory/.python-google-auth-httplib2.new.1899 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-google-auth-httplib2"
Thu Aug 26 23:15:19 2021 rev:2 rq:914433 version:0.1.0
Changes:
--------
---
/work/SRC/openSUSE:Factory/python-google-auth-httplib2/python-google-auth-httplib2.changes
2019-03-14 22:43:05.266625557 +0100
+++
/work/SRC/openSUSE:Factory/.python-google-auth-httplib2.new.1899/python-google-auth-httplib2.changes
2021-08-26 23:16:44.184176864 +0200
@@ -1,0 +2,18 @@
+Mon Aug 23 11:45:51 UTC 2021 - John Paul Adrian Glaubitz
<[email protected]>
+
+- Update to version 0.1.0
+ * chore: release 0.1.0 (#22)
+ * feat: add close method (#14)
+ * build: migrate to flakybot (#21)
+ * chore: use nox and kokoro (#16)
+ * Add renovate.json (#15)
+ * Fix the signature of AuthorizedHttp.request to match
+ the signature of the request in httplib2 (#13)
+ * Expose redirect_codes on AuthorizedHttp. (#12)
+- from version 0.0.4
+ * Release 0.0.4 (#11)
+ * feat: expose a few httplib2 properties and a method (#9)
+ * Bug: Catch any underlying exceptions from http.HTTPException (#7)
+- Update BuildRequires and Requires from setup.py
+
+-------------------------------------------------------------------
Old:
----
google-auth-httplib2-0.0.3.tar.gz
New:
----
google-auth-httplib2-0.1.0.tar.gz
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ python-google-auth-httplib2.spec ++++++
--- /var/tmp/diff_new_pack.Ne1ycB/_old 2021-08-26 23:16:44.628176447 +0200
+++ /var/tmp/diff_new_pack.Ne1ycB/_new 2021-08-26 23:16:44.632176444 +0200
@@ -1,7 +1,7 @@
#
# spec file for package python-google-auth-httplib2
#
-# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany.
+# Copyright (c) 2021 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
@@ -18,7 +18,7 @@
%{?!python_module:%define python_module() python-%{**} python3-%{**}}
Name: python-google-auth-httplib2
-Version: 0.0.3
+Version: 0.1.0
Release: 0
Summary: Google Authentication Library: httplib2 transport
License: Apache-2.0
@@ -27,7 +27,7 @@
Source:
https://files.pythonhosted.org/packages/source/g/google-auth-httplib2/google-auth-httplib2-%{version}.tar.gz
BuildRequires: %{python_module Flask}
BuildRequires: %{python_module google-auth}
-BuildRequires: %{python_module httplib2 >= 0.9.1}
+BuildRequires: %{python_module httplib2 >= 0.15.0}
BuildRequires: %{python_module mock}
BuildRequires: %{python_module pytest-localserver}
BuildRequires: %{python_module pytest}
@@ -36,7 +36,7 @@
BuildRequires: fdupes
BuildRequires: python-rpm-macros
Requires: python-google-auth
-Requires: python-httplib2 >= 0.9.1
+Requires: python-httplib2 >= 0.15.0
Requires: python-six
BuildArch: noarch
%python_subpackages
++++++ google-auth-httplib2-0.0.3.tar.gz -> google-auth-httplib2-0.1.0.tar.gz
++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/google-auth-httplib2-0.0.3/PKG-INFO
new/google-auth-httplib2-0.1.0/PKG-INFO
--- old/google-auth-httplib2-0.0.3/PKG-INFO 2017-11-14 18:37:50.000000000
+0100
+++ new/google-auth-httplib2-0.1.0/PKG-INFO 2021-03-04 19:27:18.528247000
+0100
@@ -1,12 +1,11 @@
Metadata-Version: 1.1
Name: google-auth-httplib2
-Version: 0.0.3
+Version: 0.1.0
Summary: Google Authentication Library: httplib2 transport
Home-page:
https://github.com/GoogleCloudPlatform/google-auth-library-python-httplib2
Author: Google Cloud Platform
-Author-email: [email protected]
+Author-email: [email protected]
License: Apache 2.0
-Description-Content-Type: UNKNOWN
Description: ``httplib2`` Transport for Google Auth
======================================
@@ -46,9 +45,10 @@
Classifier: Programming Language :: Python :: 2
Classifier: Programming Language :: Python :: 2.7
Classifier: Programming Language :: Python :: 3
-Classifier: Programming Language :: Python :: 3.4
Classifier: Programming Language :: Python :: 3.5
Classifier: Programming Language :: Python :: 3.6
+Classifier: Programming Language :: Python :: 3.7
+Classifier: Programming Language :: Python :: 3.8
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: Apache Software License
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/google-auth-httplib2-0.0.3/google_auth_httplib2.egg-info/PKG-INFO
new/google-auth-httplib2-0.1.0/google_auth_httplib2.egg-info/PKG-INFO
--- old/google-auth-httplib2-0.0.3/google_auth_httplib2.egg-info/PKG-INFO
2017-11-14 18:37:50.000000000 +0100
+++ new/google-auth-httplib2-0.1.0/google_auth_httplib2.egg-info/PKG-INFO
2021-03-04 19:27:18.000000000 +0100
@@ -1,12 +1,11 @@
Metadata-Version: 1.1
Name: google-auth-httplib2
-Version: 0.0.3
+Version: 0.1.0
Summary: Google Authentication Library: httplib2 transport
Home-page:
https://github.com/GoogleCloudPlatform/google-auth-library-python-httplib2
Author: Google Cloud Platform
-Author-email: [email protected]
+Author-email: [email protected]
License: Apache 2.0
-Description-Content-Type: UNKNOWN
Description: ``httplib2`` Transport for Google Auth
======================================
@@ -46,9 +45,10 @@
Classifier: Programming Language :: Python :: 2
Classifier: Programming Language :: Python :: 2.7
Classifier: Programming Language :: Python :: 3
-Classifier: Programming Language :: Python :: 3.4
Classifier: Programming Language :: Python :: 3.5
Classifier: Programming Language :: Python :: 3.6
+Classifier: Programming Language :: Python :: 3.7
+Classifier: Programming Language :: Python :: 3.8
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: Apache Software License
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/google-auth-httplib2-0.0.3/google_auth_httplib2.egg-info/requires.txt
new/google-auth-httplib2-0.1.0/google_auth_httplib2.egg-info/requires.txt
--- old/google-auth-httplib2-0.0.3/google_auth_httplib2.egg-info/requires.txt
2017-11-14 18:37:50.000000000 +0100
+++ new/google-auth-httplib2-0.1.0/google_auth_httplib2.egg-info/requires.txt
2021-03-04 19:27:18.000000000 +0100
@@ -1,2 +1,3 @@
google-auth
-httplib2>=0.9.1
+httplib2>=0.15.0
+six
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/google-auth-httplib2-0.0.3/google_auth_httplib2.py
new/google-auth-httplib2-0.1.0/google_auth_httplib2.py
--- old/google-auth-httplib2-0.0.3/google_auth_httplib2.py 2017-11-14
18:30:12.000000000 +0100
+++ new/google-auth-httplib2-0.1.0/google_auth_httplib2.py 2021-03-04
19:24:25.000000000 +0100
@@ -21,11 +21,12 @@
from google.auth import exceptions
from google.auth import transport
import httplib2
+from six.moves import http_client
_LOGGER = logging.getLogger(__name__)
# Properties present in file-like streams / buffers.
-_STREAM_PROPERTIES = ('read', 'seek', 'tell')
+_STREAM_PROPERTIES = ("read", "seek", "tell")
class _Response(transport.Response):
@@ -35,6 +36,7 @@
response (httplib2.Response): The raw httplib2 response.
data (bytes): The response body.
"""
+
def __init__(self, response, data):
self._response = response
self._data = data
@@ -79,11 +81,13 @@
.. automethod:: __call__
"""
+
def __init__(self, http):
self.http = http
- def __call__(self, url, method='GET', body=None, headers=None,
- timeout=None, **kwargs):
+ def __call__(
+ self, url, method="GET", body=None, headers=None, timeout=None,
**kwargs
+ ):
"""Make an HTTP request using httplib2.
Args:
@@ -106,16 +110,19 @@
"""
if timeout is not None:
_LOGGER.warning(
- 'httplib2 transport does not support per-request timeout. '
- 'Set the timeout when constructing the httplib2.Http instance.'
+ "httplib2 transport does not support per-request timeout. "
+ "Set the timeout when constructing the httplib2.Http instance."
)
try:
- _LOGGER.debug('Making request: %s %s', method, url)
+ _LOGGER.debug("Making request: %s %s", method, url)
response, data = self.http.request(
- url, method=method, body=body, headers=headers, **kwargs)
+ url, method=method, body=body, headers=headers, **kwargs
+ )
return _Response(response, data)
- except httplib2.HttpLib2Error as exc:
+ # httplib2 should catch the lower http error, this is a bug and
+ # needs to be fixed there. Catch the error for the meanwhile.
+ except (httplib2.HttpLib2Error, http_client.HTTPException) as exc:
raise exceptions.TransportError(exc)
@@ -144,9 +151,14 @@
The underlying :meth:`request` implementation handles adding the
credentials' headers to the request and refreshing credentials as needed.
"""
- def __init__(self, credentials, http=None,
- refresh_status_codes=transport.DEFAULT_REFRESH_STATUS_CODES,
- max_refresh_attempts=transport.DEFAULT_MAX_REFRESH_ATTEMPTS):
+
+ def __init__(
+ self,
+ credentials,
+ http=None,
+ refresh_status_codes=transport.DEFAULT_REFRESH_STATUS_CODES,
+ max_refresh_attempts=transport.DEFAULT_MAX_REFRESH_ATTEMPTS,
+ ):
"""
Args:
credentials (google.auth.credentials.Credentials): The credentials
@@ -172,43 +184,63 @@
# credentials.refresh).
self._request = Request(self.http)
- def request(self, uri, method='GET', body=None, headers=None,
- **kwargs):
+ def close(self):
+ """Calls httplib2's Http.close"""
+ self.http.close()
+
+ def request(
+ self,
+ uri,
+ method="GET",
+ body=None,
+ headers=None,
+ redirections=httplib2.DEFAULT_MAX_REDIRECTS,
+ connection_type=None,
+ **kwargs
+ ):
"""Implementation of httplib2's Http.request."""
- _credential_refresh_attempt = kwargs.pop(
- '_credential_refresh_attempt', 0)
+ _credential_refresh_attempt =
kwargs.pop("_credential_refresh_attempt", 0)
# Make a copy of the headers. They will be modified by the credentials
# and we want to pass the original headers if we recurse.
request_headers = headers.copy() if headers is not None else {}
- self.credentials.before_request(
- self._request, method, uri, request_headers)
+ self.credentials.before_request(self._request, method, uri,
request_headers)
# Check if the body is a file-like stream, and if so, save the body
# stream position so that it can be restored in case of refresh.
body_stream_position = None
- if all(getattr(body, stream_prop, None) for stream_prop in
- _STREAM_PROPERTIES):
+ if all(getattr(body, stream_prop, None) for stream_prop in
_STREAM_PROPERTIES):
body_stream_position = body.tell()
# Make the request.
response, content = self.http.request(
- uri, method, body=body, headers=request_headers, **kwargs)
+ uri,
+ method,
+ body=body,
+ headers=request_headers,
+ redirections=redirections,
+ connection_type=connection_type,
+ **kwargs
+ )
# If the response indicated that the credentials needed to be
# refreshed, then refresh the credentials and re-attempt the
# request.
# A stored token may expire between the time it is retrieved and
# the time the request is made, so we may need to try twice.
- if (response.status in self._refresh_status_codes
- and _credential_refresh_attempt < self._max_refresh_attempts):
+ if (
+ response.status in self._refresh_status_codes
+ and _credential_refresh_attempt < self._max_refresh_attempts
+ ):
_LOGGER.info(
- 'Refreshing credentials due to a %s response. Attempt %s/%s.',
- response.status, _credential_refresh_attempt + 1,
- self._max_refresh_attempts)
+ "Refreshing credentials due to a %s response. Attempt %s/%s.",
+ response.status,
+ _credential_refresh_attempt + 1,
+ self._max_refresh_attempts,
+ )
self.credentials.refresh(self._request)
@@ -218,12 +250,22 @@
# Recurse. Pass in the original headers, not our modified set.
return self.request(
- uri, method, body=body, headers=headers,
+ uri,
+ method,
+ body=body,
+ headers=headers,
+ redirections=redirections,
+ connection_type=connection_type,
_credential_refresh_attempt=_credential_refresh_attempt + 1,
- **kwargs)
+ **kwargs
+ )
return response, content
+ def add_certificate(self, key, cert, domain, password=None):
+ """Proxy to httplib2.Http.add_certificate."""
+ self.http.add_certificate(key, cert, domain, password=password)
+
@property
def connections(self):
"""Proxy to httplib2.Http.connections."""
@@ -233,3 +275,33 @@
def connections(self, value):
"""Proxy to httplib2.Http.connections."""
self.http.connections = value
+
+ @property
+ def follow_redirects(self):
+ """Proxy to httplib2.Http.follow_redirects."""
+ return self.http.follow_redirects
+
+ @follow_redirects.setter
+ def follow_redirects(self, value):
+ """Proxy to httplib2.Http.follow_redirects."""
+ self.http.follow_redirects = value
+
+ @property
+ def timeout(self):
+ """Proxy to httplib2.Http.timeout."""
+ return self.http.timeout
+
+ @timeout.setter
+ def timeout(self, value):
+ """Proxy to httplib2.Http.timeout."""
+ self.http.timeout = value
+
+ @property
+ def redirect_codes(self):
+ """Proxy to httplib2.Http.redirect_codes."""
+ return self.http.redirect_codes
+
+ @redirect_codes.setter
+ def redirect_codes(self, value):
+ """Proxy to httplib2.Http.redirect_codes."""
+ self.http.redirect_codes = value
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/google-auth-httplib2-0.0.3/setup.py
new/google-auth-httplib2-0.1.0/setup.py
--- old/google-auth-httplib2-0.0.3/setup.py 2017-11-14 18:37:42.000000000
+0100
+++ new/google-auth-httplib2-0.1.0/setup.py 2021-03-04 19:24:25.000000000
+0100
@@ -16,43 +16,42 @@
from setuptools import setup
+version = "0.1.0"
-DEPENDENCIES = (
- 'google-auth',
- 'httplib2 >= 0.9.1',
-)
+DEPENDENCIES = ["google-auth", "httplib2 >= 0.15.0", "six"]
-with io.open('README.rst', 'r') as fh:
+with io.open("README.rst", "r") as fh:
long_description = fh.read()
setup(
- name='google-auth-httplib2',
- version='0.0.3',
- author='Google Cloud Platform',
- author_email='[email protected]',
- description='Google Authentication Library: httplib2 transport',
+ name="google-auth-httplib2",
+ version=version,
+ author="Google Cloud Platform",
+ author_email="[email protected]",
+ description="Google Authentication Library: httplib2 transport",
long_description=long_description,
-
url='https://github.com/GoogleCloudPlatform/google-auth-library-python-httplib2',
- py_modules=['google_auth_httplib2'],
+
url="https://github.com/GoogleCloudPlatform/google-auth-library-python-httplib2",
+ py_modules=["google_auth_httplib2"],
install_requires=DEPENDENCIES,
- license='Apache 2.0',
- keywords='google auth oauth client',
- classifiers=(
- 'Programming Language :: Python :: 2',
- 'Programming Language :: Python :: 2.7',
- 'Programming Language :: Python :: 3',
- 'Programming Language :: Python :: 3.4',
- 'Programming Language :: Python :: 3.5',
- 'Programming Language :: Python :: 3.6',
- 'Development Status :: 3 - Alpha',
- 'Intended Audience :: Developers',
- 'License :: OSI Approved :: Apache Software License',
- 'Operating System :: POSIX',
- 'Operating System :: Microsoft :: Windows',
- 'Operating System :: MacOS :: MacOS X',
- 'Operating System :: OS Independent',
- 'Topic :: Internet :: WWW/HTTP',
- ),
+ license="Apache 2.0",
+ keywords="google auth oauth client",
+ classifiers=[
+ "Programming Language :: Python :: 2",
+ "Programming Language :: Python :: 2.7",
+ "Programming Language :: Python :: 3",
+ "Programming Language :: Python :: 3.5",
+ "Programming Language :: Python :: 3.6",
+ "Programming Language :: Python :: 3.7",
+ "Programming Language :: Python :: 3.8",
+ "Development Status :: 3 - Alpha",
+ "Intended Audience :: Developers",
+ "License :: OSI Approved :: Apache Software License",
+ "Operating System :: POSIX",
+ "Operating System :: Microsoft :: Windows",
+ "Operating System :: MacOS :: MacOS X",
+ "Operating System :: OS Independent",
+ "Topic :: Internet :: WWW/HTTP",
+ ],
)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/google-auth-httplib2-0.0.3/tests/compliance.py
new/google-auth-httplib2-0.1.0/tests/compliance.py
--- old/google-auth-httplib2-0.0.3/tests/compliance.py 2017-03-22
21:06:35.000000000 +0100
+++ new/google-auth-httplib2-0.1.0/tests/compliance.py 2021-03-04
19:24:25.000000000 +0100
@@ -19,12 +19,11 @@
from six.moves import http_client
# .invalid will never resolve, see https://tools.ietf.org/html/rfc2606
-NXDOMAIN = 'test.invalid'
+NXDOMAIN = "test.invalid"
class RequestResponseTests(object):
-
- @pytest.fixture(scope='module')
+ @pytest.fixture(scope="module")
def server(self):
"""Provides a test HTTP server.
@@ -37,15 +36,16 @@
# pylint: disable=unused-variable
# (pylint thinks the flask routes are unusued.)
- @app.route('/basic')
+ @app.route("/basic")
def index():
- header_value = flask.request.headers.get('x-test-header', 'value')
- headers = {'X-Test-Header': header_value}
- return 'Basic Content', http_client.OK, headers
+ header_value = flask.request.headers.get("x-test-header", "value")
+ headers = {"X-Test-Header": header_value}
+ return "Basic Content", http_client.OK, headers
- @app.route('/server_error')
+ @app.route("/server_error")
def server_error():
- return 'Error', http_client.INTERNAL_SERVER_ERROR
+ return "Error", http_client.INTERNAL_SERVER_ERROR
+
# pylint: enable=unused-variable
server = WSGIServer(application=app.wsgi_app)
@@ -55,38 +55,40 @@
def test_request_basic(self, server):
request = self.make_request()
- response = request(url=server.url + '/basic', method='GET')
+ response = request(url=server.url + "/basic", method="GET")
assert response.status == http_client.OK
- assert response.headers['x-test-header'] == 'value'
- assert response.data == b'Basic Content'
+ assert response.headers["x-test-header"] == "value"
+ assert response.data == b"Basic Content"
def test_request_timeout(self, server):
request = self.make_request()
- response = request(url=server.url + '/basic', method='GET', timeout=2)
+ response = request(url=server.url + "/basic", method="GET", timeout=2)
assert response.status == http_client.OK
- assert response.headers['x-test-header'] == 'value'
- assert response.data == b'Basic Content'
+ assert response.headers["x-test-header"] == "value"
+ assert response.data == b"Basic Content"
def test_request_headers(self, server):
request = self.make_request()
response = request(
- url=server.url + '/basic', method='GET', headers={
- 'x-test-header': 'hello world'})
+ url=server.url + "/basic",
+ method="GET",
+ headers={"x-test-header": "hello world"},
+ )
assert response.status == http_client.OK
- assert response.headers['x-test-header'] == 'hello world'
- assert response.data == b'Basic Content'
+ assert response.headers["x-test-header"] == "hello world"
+ assert response.data == b"Basic Content"
def test_request_error(self, server):
request = self.make_request()
- response = request(url=server.url + '/server_error', method='GET')
+ response = request(url=server.url + "/server_error", method="GET")
assert response.status == http_client.INTERNAL_SERVER_ERROR
- assert response.data == b'Error'
+ assert response.data == b"Error"
def test_connection_error(self):
request = self.make_request()
with pytest.raises(exceptions.TransportError):
- request(url='http://{}'.format(NXDOMAIN), method='GET')
+ request(url="http://{}".format(NXDOMAIN), method="GET")
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/google-auth-httplib2-0.0.3/tests/test_google_auth_httplib2.py
new/google-auth-httplib2-0.1.0/tests/test_google_auth_httplib2.py
--- old/google-auth-httplib2-0.0.3/tests/test_google_auth_httplib2.py
2017-03-22 21:06:35.000000000 +0100
+++ new/google-auth-httplib2-0.1.0/tests/test_google_auth_httplib2.py
2021-03-04 19:24:25.000000000 +0100
@@ -26,14 +26,25 @@
self.responses = responses
self.requests = []
self.headers = headers or {}
+ self.add_certificate = mock.Mock(return_value=None)
- def request(self, url, method='GET', body=None, headers=None, **kwargs):
- self.requests.append((method, url, body, headers, kwargs))
+ def request(
+ self,
+ url,
+ method="GET",
+ body=None,
+ headers=None,
+ redirections=httplib2.DEFAULT_MAX_REDIRECTS,
+ connection_type=None,
+ ):
+ self.requests.append(
+ (method, url, body, headers, redirections, connection_type)
+ )
return self.responses.pop(0)
class MockResponse(object):
- def __init__(self, status=http_client.OK, data=b''):
+ def __init__(self, status=http_client.OK, data=b""):
self.status = status
self.data = data
@@ -48,13 +59,19 @@
return google_auth_httplib2.Request(http)
def test_timeout(self):
- url = 'http://example.com'
+ url = "http://example.com"
http = MockHttp(responses=[MockResponse()])
request = google_auth_httplib2.Request(http)
- request(url=url, method='GET', timeout=5)
+ request(url=url, method="GET", timeout=5)
assert http.requests[0] == (
- 'GET', url, None, None, {})
+ "GET",
+ url,
+ None,
+ None,
+ httplib2.DEFAULT_MAX_REDIRECTS,
+ None,
+ )
def test__make_default_http():
@@ -63,45 +80,86 @@
class MockCredentials(object):
- def __init__(self, token='token'):
+ def __init__(self, token="token"):
self.token = token
def apply(self, headers):
- headers['authorization'] = self.token
+ headers["authorization"] = self.token
def before_request(self, request, method, url, headers):
self.apply(headers)
def refresh(self, request):
- self.token += '1'
+ self.token += "1"
class TestAuthorizedHttp(object):
- TEST_URL = 'http://example.com'
+ TEST_URL = "http://example.com"
def test_authed_http_defaults(self):
- authed_http = google_auth_httplib2.AuthorizedHttp(
- mock.sentinel.credentials)
+ authed_http =
google_auth_httplib2.AuthorizedHttp(mock.sentinel.credentials)
assert authed_http.credentials == mock.sentinel.credentials
assert isinstance(authed_http.http, httplib2.Http)
+ def test_close(self):
+ with mock.patch("httplib2.Http.close", autospec=True) as close:
+ authed_http =
google_auth_httplib2.AuthorizedHttp(mock.sentinel.credentials)
+ authed_http.close()
+
+ close.assert_called_once()
+
def test_connections(self):
- authed_http = google_auth_httplib2.AuthorizedHttp(
- mock.sentinel.credentials)
+ authed_http =
google_auth_httplib2.AuthorizedHttp(mock.sentinel.credentials)
assert authed_http.connections == authed_http.http.connections
authed_http.connections = mock.sentinel.connections
assert authed_http.http.connections == mock.sentinel.connections
+ def test_follow_redirects(self):
+ auth_http =
google_auth_httplib2.AuthorizedHttp(mock.sentinel.credentials)
+
+ assert auth_http.follow_redirects == auth_http.http.follow_redirects
+
+ mock_follow_redirects = mock.sentinel.follow_redirects
+ auth_http.follow_redirects = mock_follow_redirects
+ assert auth_http.http.follow_redirects == mock_follow_redirects
+
+ def test_timeout(self):
+ authed_http =
google_auth_httplib2.AuthorizedHttp(mock.sentinel.credentials)
+
+ assert authed_http.timeout == authed_http.http.timeout
+
+ authed_http.timeout = mock.sentinel.timeout
+ assert authed_http.http.timeout == mock.sentinel.timeout
+
+ def test_redirect_codes(self):
+ authed_http =
google_auth_httplib2.AuthorizedHttp(mock.sentinel.credentials)
+
+ assert authed_http.redirect_codes == authed_http.http.redirect_codes
+
+ authed_http.redirect_codes = mock.sentinel.redirect_codes
+ assert authed_http.http.redirect_codes == mock.sentinel.redirect_codes
+
+ def test_add_certificate(self):
+ authed_http = google_auth_httplib2.AuthorizedHttp(
+ mock.sentinel.credentials, http=MockHttp(MockResponse())
+ )
+
+ authed_http.add_certificate("key", "cert", "domain",
password="password")
+ authed_http.http.add_certificate.assert_called_once_with(
+ "key", "cert", "domain", password="password"
+ )
+
def test_request_no_refresh(self):
mock_credentials = mock.Mock(wraps=MockCredentials())
mock_response = MockResponse()
mock_http = MockHttp([mock_response])
authed_http = google_auth_httplib2.AuthorizedHttp(
- mock_credentials, http=mock_http)
+ mock_credentials, http=mock_http
+ )
response, data = authed_http.request(self.TEST_URL)
@@ -110,18 +168,27 @@
assert mock_credentials.before_request.called
assert not mock_credentials.refresh.called
assert mock_http.requests == [
- ('GET', self.TEST_URL, None, {'authorization': 'token'}, {})]
+ (
+ "GET",
+ self.TEST_URL,
+ None,
+ {"authorization": "token"},
+ httplib2.DEFAULT_MAX_REDIRECTS,
+ None,
+ )
+ ]
def test_request_refresh(self):
mock_credentials = mock.Mock(wraps=MockCredentials())
mock_final_response = MockResponse(status=http_client.OK)
# First request will 401, second request will succeed.
- mock_http = MockHttp([
- MockResponse(status=http_client.UNAUTHORIZED),
- mock_final_response])
+ mock_http = MockHttp(
+ [MockResponse(status=http_client.UNAUTHORIZED),
mock_final_response]
+ )
authed_http = google_auth_httplib2.AuthorizedHttp(
- mock_credentials, http=mock_http)
+ mock_credentials, http=mock_http
+ )
response, data = authed_http.request(self.TEST_URL)
@@ -130,28 +197,87 @@
assert mock_credentials.before_request.call_count == 2
assert mock_credentials.refresh.called
assert mock_http.requests == [
- ('GET', self.TEST_URL, None, {'authorization': 'token'}, {}),
- ('GET', self.TEST_URL, None, {'authorization': 'token1'}, {})]
+ (
+ "GET",
+ self.TEST_URL,
+ None,
+ {"authorization": "token"},
+ httplib2.DEFAULT_MAX_REDIRECTS,
+ None,
+ ),
+ (
+ "GET",
+ self.TEST_URL,
+ None,
+ {"authorization": "token1"},
+ httplib2.DEFAULT_MAX_REDIRECTS,
+ None,
+ ),
+ ]
def test_request_stream_body(self):
mock_credentials = mock.Mock(wraps=MockCredentials())
mock_response = MockResponse()
# Refresh is needed to cover the resetting of the body position.
- mock_http = MockHttp([
- MockResponse(status=http_client.UNAUTHORIZED),
- mock_response])
+ mock_http = MockHttp(
+ [MockResponse(status=http_client.UNAUTHORIZED), mock_response]
+ )
- body = six.StringIO('body')
+ body = six.StringIO("body")
body.seek(1)
authed_http = google_auth_httplib2.AuthorizedHttp(
- mock_credentials, http=mock_http)
+ mock_credentials, http=mock_http
+ )
+
+ response, data = authed_http.request(self.TEST_URL, method="POST",
body=body)
+
+ assert response == mock_response
+ assert data == mock_response.data
+ assert mock_http.requests == [
+ (
+ "POST",
+ self.TEST_URL,
+ body,
+ {"authorization": "token"},
+ httplib2.DEFAULT_MAX_REDIRECTS,
+ None,
+ ),
+ (
+ "POST",
+ self.TEST_URL,
+ body,
+ {"authorization": "token1"},
+ httplib2.DEFAULT_MAX_REDIRECTS,
+ None,
+ ),
+ ]
+
+ def test_request_positional_args(self):
+ """Verifies that clients can pass args to request as positioanls."""
+ mock_credentials = mock.Mock(wraps=MockCredentials())
+ mock_response = MockResponse()
+ mock_http = MockHttp([mock_response])
+
+ authed_http = google_auth_httplib2.AuthorizedHttp(
+ mock_credentials, http=mock_http
+ )
response, data = authed_http.request(
- self.TEST_URL, method='POST', body=body)
+ self.TEST_URL, "GET", None, None, httplib2.DEFAULT_MAX_REDIRECTS,
None
+ )
assert response == mock_response
assert data == mock_response.data
+ assert mock_credentials.before_request.called
+ assert not mock_credentials.refresh.called
assert mock_http.requests == [
- ('POST', self.TEST_URL, body, {'authorization': 'token'}, {}),
- ('POST', self.TEST_URL, body, {'authorization': 'token1'}, {})]
+ (
+ "GET",
+ self.TEST_URL,
+ None,
+ {"authorization": "token"},
+ httplib2.DEFAULT_MAX_REDIRECTS,
+ None,
+ )
+ ]