- Update to 3.0.2:
- Fix API key leaking into requests exceptions
- Skip man page generation to fix build on Windows (Alexander Todorov)
- Drop python2 support
- New option bugzilla modify --minor-update option
- requests: use PYTHONBUGZILLA_REQUESTS_TIMEOUT env variable
- xmlrpc: Don't add api key to passed in user dictionary
- cli: Add query --extrafield, --includefield, --excludefield
- Revive bugzilla.rhbugzilla.RHBugzilla import path
- Bugzilla REST API support
- Add --json command line output option
- Add APIs for Bugzilla Groups (Pierre-Yves Chibon)
- Add Bugzilla.get_requests_session() API to access raw requests
Session
- Add Bugzilla.get_xmlrpc_proxy() API to access raw ServerProxy
- Add Bugzilla requests_session= init parameter to pass in auth, etc.
- Add bugzilla attach --ignore-obsolete (Čestmír Kalina)
- Add bugzilla login --api-key for API key prompting (Danilo C. L. de
Paula)
- Add bugzilla new --private
- Remove 106-basic-auth.diff, which is not necessary anymore.
OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-bugzilla?expand=0&rev=50
This commit is contained in:
@@ -1,104 +0,0 @@
|
||||
--- a/bugzilla/base.py
|
||||
+++ b/bugzilla/base.py
|
||||
@@ -24,13 +24,13 @@ if sys.version_info[0] >= 3:
|
||||
from collections.abc import Mapping
|
||||
from configparser import ConfigParser
|
||||
from http.cookiejar import LoadError, MozillaCookieJar
|
||||
- from urllib.parse import urlparse, parse_qsl
|
||||
+ from urllib.parse import urlparse, urlunparse, parse_qsl
|
||||
from xmlrpc.client import Binary, Fault
|
||||
else:
|
||||
from collections import Mapping
|
||||
from ConfigParser import SafeConfigParser as ConfigParser
|
||||
from cookielib import LoadError, MozillaCookieJar
|
||||
- from urlparse import urlparse, parse_qsl
|
||||
+ from urlparse import urlparse, urlunparse, parse_qsl
|
||||
from xmlrpclib import Binary, Fault
|
||||
# pylint: enable=import-error
|
||||
|
||||
@@ -215,13 +215,16 @@ class Bugzilla(object):
|
||||
"""
|
||||
Turn passed url into a bugzilla XMLRPC web url
|
||||
"""
|
||||
- if '://' not in url:
|
||||
+ scheme, netloc, path, params, query, fragment = urlparse(url)
|
||||
+ if not scheme:
|
||||
log.debug('No scheme given for url, assuming https')
|
||||
- url = 'https://' + url
|
||||
- if url.count('/') < 3:
|
||||
+ scheme = 'https'
|
||||
+
|
||||
+ if not path:
|
||||
log.debug('No path given for url, assuming /xmlrpc.cgi')
|
||||
- url = url + '/xmlrpc.cgi'
|
||||
- return url
|
||||
+ path = 'xmlrpc.cgi'
|
||||
+
|
||||
+ return urlunparse((scheme, netloc, path, params, query, fragment))
|
||||
|
||||
@staticmethod
|
||||
def _listify(val):
|
||||
@@ -234,7 +237,7 @@ class Bugzilla(object):
|
||||
|
||||
def __init__(self, url=-1, user=None, password=None, cookiefile=-1,
|
||||
sslverify=True, tokenfile=-1, use_creds=True, api_key=None,
|
||||
- cert=None, configpaths=-1):
|
||||
+ cert=None, configpaths=-1, basic_auth=False):
|
||||
"""
|
||||
:param url: The bugzilla instance URL, which we will connect
|
||||
to immediately. Most users will want to specify this at
|
||||
@@ -263,6 +266,7 @@ class Bugzilla(object):
|
||||
to file or directory for custom certs.
|
||||
:param api_key: A bugzilla5+ API key
|
||||
:param configpaths: A list of possible bugzillarc locations.
|
||||
+ :param basic_auth: Use headers with HTTP Basic authentication
|
||||
"""
|
||||
if url == -1:
|
||||
raise TypeError("Specify a valid bugzilla url, or pass url=None")
|
||||
@@ -300,6 +304,7 @@ class Bugzilla(object):
|
||||
self.cookiefile = cookiefile
|
||||
self.tokenfile = tokenfile
|
||||
self.configpath = configpaths
|
||||
+ self._basic_auth = basic_auth
|
||||
|
||||
if url:
|
||||
self.connect(url)
|
||||
@@ -564,6 +569,9 @@ class Bugzilla(object):
|
||||
"""
|
||||
Backend login method for Bugzilla3
|
||||
"""
|
||||
+ if self._basic_auth:
|
||||
+ self._transport.set_basic_auth(user, password)
|
||||
+
|
||||
payload = {'login': user, 'password': password}
|
||||
if restrict_login:
|
||||
payload['restrict_login'] = True
|
||||
diff --git a/bugzilla/transport.py b/bugzilla/transport.py
|
||||
index 12422bb..d750202 100644
|
||||
--- a/bugzilla/transport.py
|
||||
+++ b/bugzilla/transport.py
|
||||
@@ -4,6 +4,7 @@
|
||||
# option) any later version. See http://www.gnu.org/copyleft/gpl.html for
|
||||
# the full text of the license.
|
||||
|
||||
+import base64
|
||||
from logging import getLogger
|
||||
import sys
|
||||
|
||||
@@ -143,6 +144,16 @@ class _RequestsTransport(Transport):
|
||||
if cert:
|
||||
self.session.cert = cert
|
||||
|
||||
+ def set_basic_auth(self, user, password):
|
||||
+ """
|
||||
+ Set basic authentication method.
|
||||
+
|
||||
+ :return:
|
||||
+ """
|
||||
+ b64str = str(base64.b64encode("{}:{}".format(user, password)))
|
||||
+ authstr = "Basic {}".format(b64str.encode("utf-8").decode("utf-8"))
|
||||
+ self.request_defaults["headers"]["Authorization"] = authstr
|
||||
+
|
||||
def parse_response(self, response):
|
||||
"""
|
||||
Parse XMLRPC response
|
||||
Reference in New Issue
Block a user