Skip to content

Commit 737e15b

Browse files
committed
Bugzilla: Remove explicit basic_auth support
This was added during this dev cycle, but it's no longer needed with the request_session passthrough support Signed-off-by: Cole Robinson <crobinso@redhat.com>
1 parent 061a4ec commit 737e15b

3 files changed

Lines changed: 1 addition & 23 deletions

File tree

bugzilla/_session.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# This work is licensed under the GNU GPLv2 or later.
22
# See the COPYING file in the top-level directory.
33

4-
import base64
54
from logging import getLogger
65

76
import requests
@@ -62,15 +61,6 @@ def _set_tokencache_param(self):
6261
token = self.get_token_value()
6362
self._session.params["Bugzilla_token"] = token
6463

65-
def set_basic_auth(self, user, password):
66-
"""
67-
Set basic authentication method.
68-
"""
69-
formatstr = "{}:{}".format(user, password).encode("utf-8")
70-
b64str = base64.b64encode(formatstr).decode("utf-8")
71-
authstr = "Basic {}".format(b64str)
72-
self._session.headers["Authorization"] = authstr
73-
7464
def set_response_cookies(self, response):
7565
"""
7666
Save any cookies received from the passed requests response

bugzilla/base.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ def get_rcfile_default_url():
175175

176176
def __init__(self, url=-1, user=None, password=None, cookiefile=-1,
177177
sslverify=True, tokenfile=-1, use_creds=True, api_key=None,
178-
cert=None, configpaths=-1, basic_auth=False,
178+
cert=None, configpaths=-1,
179179
force_rest=False, force_xmlrpc=False, requests_session=None):
180180
"""
181181
:param url: The bugzilla instance URL, which we will connect
@@ -206,7 +206,6 @@ def __init__(self, url=-1, user=None, password=None, cookiefile=-1,
206206
to file or directory for custom certs.
207207
:param api_key: A bugzilla5+ API key
208208
:param configpaths: A list of possible bugzillarc locations.
209-
:param basic_auth: Use headers with HTTP Basic authentication
210209
:param force_rest: Force use of the REST API
211210
:param force_xmlrpc: Force use of the XMLRPC API. If neither force_X
212211
parameter are specified, heuristics will be used to determine
@@ -256,8 +255,6 @@ def __init__(self, url=-1, user=None, password=None, cookiefile=-1,
256255
self._settokenfile(tokenfile)
257256
self._setconfigpath(configpaths)
258257

259-
self._basic_auth = basic_auth
260-
261258
if url:
262259
self.connect(url)
263260

@@ -588,9 +585,6 @@ def login(self, user=None, password=None, restrict_login=None):
588585
log.info("logging in with restrict_login=True")
589586

590587
try:
591-
if self._basic_auth:
592-
self._session.set_basic_auth(user, password)
593-
594588
payload = {'login': user, 'password': password}
595589
if restrict_login:
596590
payload['restrict_login'] = True

tests/test_api_misc.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -189,12 +189,6 @@ def test_api_login():
189189
# Errors on api_key + login()
190190
bz.login()
191191

192-
# Will log in immediately, hitting basic_auth path
193-
bz = tests.mockbackend.make_bz(
194-
bz_kwargs={"basic_auth": True, "user": "FOO", "password": "BAR"},
195-
user_login_args="data/mockargs/test_api_login1.txt",
196-
user_login_return={})
197-
198192
# Hit default api_key code path
199193
bz = tests.mockbackend.make_bz(
200194
bz_kwargs={"api_key": "FAKE_KEY"},

0 commit comments

Comments
 (0)