Skip to content

Commit e3aa44e

Browse files
feat: expose a few httplib2 properties and a method (#9)
1 parent e7cd722 commit e3aa44e

File tree

3 files changed

+61
-0
lines changed

3 files changed

+61
-0
lines changed

google_auth_httplib2.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,10 @@ def request(self, uri, method='GET', body=None, headers=None,
227227

228228
return response, content
229229

230+
def add_certificate(self, key, cert, domain, password=None):
231+
"""Proxy to httplib2.Http.add_certificate."""
232+
self.http.add_certificate(key, cert, domain, password=password)
233+
230234
@property
231235
def connections(self):
232236
"""Proxy to httplib2.Http.connections."""
@@ -236,3 +240,23 @@ def connections(self):
236240
def connections(self, value):
237241
"""Proxy to httplib2.Http.connections."""
238242
self.http.connections = value
243+
244+
@property
245+
def follow_redirects(self):
246+
"""Proxy to httplib2.Http.follow_redirects."""
247+
return self.http.follow_redirects
248+
249+
@follow_redirects.setter
250+
def follow_redirects(self, value):
251+
"""Proxy to httplib2.Http.follow_redirects."""
252+
self.http.follow_redirects = value
253+
254+
@property
255+
def timeout(self):
256+
"""Proxy to httplib2.Http.timeout."""
257+
return self.http.timeout
258+
259+
@timeout.setter
260+
def timeout(self, value):
261+
"""Proxy to httplib2.Http.timeout."""
262+
self.http.timeout = value

pylint.config.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@
2525
'protected-access',
2626
'redefined-variable-type',
2727
'similarities',
28+
'useless-object-inheritance',
2829
'no-else-return',
30+
'wrong-import-order',
2931
],
3032
},
3133
}

tests/test_google_auth_httplib2.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ def __init__(self, responses, headers=None):
2626
self.responses = responses
2727
self.requests = []
2828
self.headers = headers or {}
29+
self.add_certificate = mock.Mock(return_value=None)
2930

3031
def request(self, url, method='GET', body=None, headers=None, **kwargs):
3132
self.requests.append((method, url, body, headers, kwargs))
@@ -95,6 +96,40 @@ def test_connections(self):
9596
authed_http.connections = mock.sentinel.connections
9697
assert authed_http.http.connections == mock.sentinel.connections
9798

99+
def test_follow_redirects(self):
100+
auth_http = google_auth_httplib2.AuthorizedHttp(
101+
mock.sentinel.credentials
102+
)
103+
104+
assert auth_http.follow_redirects == auth_http.http.follow_redirects
105+
106+
mock_follow_redirects = mock.sentinel.follow_redirects
107+
auth_http.follow_redirects = mock_follow_redirects
108+
assert auth_http.http.follow_redirects == mock_follow_redirects
109+
110+
def test_timeout(self):
111+
authed_http = google_auth_httplib2.AuthorizedHttp(
112+
mock.sentinel.credentials
113+
)
114+
115+
assert authed_http.timeout == authed_http.http.timeout
116+
117+
authed_http.timeout = mock.sentinel.timeout
118+
assert authed_http.http.timeout == mock.sentinel.timeout
119+
120+
def test_add_certificate(self):
121+
authed_http = google_auth_httplib2.AuthorizedHttp(
122+
mock.sentinel.credentials,
123+
http=MockHttp(MockResponse())
124+
)
125+
126+
authed_http.add_certificate(
127+
"key", "cert", "domain", password="password"
128+
)
129+
authed_http.http.add_certificate.assert_called_once_with(
130+
"key", "cert", "domain", password="password"
131+
)
132+
98133
def test_request_no_refresh(self):
99134
mock_credentials = mock.Mock(wraps=MockCredentials())
100135
mock_response = MockResponse()

0 commit comments

Comments
 (0)