##// END OF EJS Templates
bugzilla: support Bugzilla 4.4.3+ API login token authentication (issue4257)...
Jim Hague -
r21542:d12d8d41 stable
parent child Browse files
Show More
@@ -1,7 +1,7 b''
1 1 # bugzilla.py - bugzilla integration for mercurial
2 2 #
3 3 # Copyright 2006 Vadim Gelfer <vadim.gelfer@gmail.com>
4 # Copyright 2011-2 Jim Hague <jim.hague@acm.org>
4 # Copyright 2011-4 Jim Hague <jim.hague@acm.org>
5 5 #
6 6 # This software may be used and distributed according to the terms of the
7 7 # GNU General Public License version 2 or any later version.
@@ -523,7 +523,7 b' class cookietransportrequest(object):'
523 523
524 524 The regular xmlrpclib transports ignore cookies. Which causes
525 525 a bit of a problem when you need a cookie-based login, as with
526 the Bugzilla XMLRPC interface.
526 the Bugzilla XMLRPC interface prior to 4.4.3.
527 527
528 528 So this is a helper for defining a Transport which looks for
529 529 cookies being set in responses and saves them to add to all future
@@ -620,7 +620,9 b' class bzxmlrpc(bzaccess):'
620 620 ver = self.bzproxy.Bugzilla.version()['version'].split('.')
621 621 self.bzvermajor = int(ver[0])
622 622 self.bzverminor = int(ver[1])
623 self.bzproxy.User.login({'login': user, 'password': passwd})
623 login = self.bzproxy.User.login({'login': user, 'password': passwd,
624 'restrict_login': True})
625 self.bztoken = login.get('token', '')
624 626
625 627 def transport(self, uri):
626 628 if urlparse.urlparse(uri, "http")[0] == "https":
@@ -631,13 +633,15 b' class bzxmlrpc(bzaccess):'
631 633 def get_bug_comments(self, id):
632 634 """Return a string with all comment text for a bug."""
633 635 c = self.bzproxy.Bug.comments({'ids': [id],
634 'include_fields': ['text']})
636 'include_fields': ['text'],
637 'token': self.bztoken})
635 638 return ''.join([t['text'] for t in c['bugs'][str(id)]['comments']])
636 639
637 640 def filter_real_bug_ids(self, bugs):
638 641 probe = self.bzproxy.Bug.get({'ids': sorted(bugs.keys()),
639 642 'include_fields': [],
640 643 'permissive': True,
644 'token': self.bztoken,
641 645 })
642 646 for badbug in probe['faults']:
643 647 id = badbug['id']
@@ -662,6 +666,7 b' class bzxmlrpc(bzaccess):'
662 666 if 'fix' in newstate:
663 667 args['status'] = self.fixstatus
664 668 args['resolution'] = self.fixresolution
669 args['token'] = self.bztoken
665 670 self.bzproxy.Bug.update(args)
666 671 else:
667 672 if 'fix' in newstate:
@@ -719,10 +724,12 b' class bzxmlrpcemail(bzxmlrpc):'
719 724 than the subject line, and leave a blank line after it.
720 725 '''
721 726 user = self.map_committer(committer)
722 matches = self.bzproxy.User.get({'match': [user]})
727 matches = self.bzproxy.User.get({'match': [user],
728 'token': self.bztoken})
723 729 if not matches['users']:
724 730 user = self.ui.config('bugzilla', 'user', 'bugs')
725 matches = self.bzproxy.User.get({'match': [user]})
731 matches = self.bzproxy.User.get({'match': [user],
732 'token': self.bztoken})
726 733 if not matches['users']:
727 734 raise util.Abort(_("default bugzilla user %s email not found") %
728 735 user)
General Comments 0
You need to be logged in to leave comments. Login now