Skip to content

Commit

Permalink
monkey patch twisted to make the py3 smoke tests pass
Browse files Browse the repository at this point in the history
  • Loading branch information
tardyp committed Apr 30, 2017
1 parent 615cb76 commit 4094bb6
Show file tree
Hide file tree
Showing 6 changed files with 111 additions and 4 deletions.
8 changes: 7 additions & 1 deletion master/buildbot/monkeypatches/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

from twisted.python import util
from builtins import int

from future.utils import PY3

def onlyOnce(fn):
'Set up FN to only run once within an interpreter instance'
Expand All @@ -42,6 +42,11 @@ def patch_python14653():
from buildbot.monkeypatches import python14653
python14653.patch()

@onlyOnce
def patch_twisted9127():
if PY3:
from buildbot.monkeypatches import twisted9127
twisted9127.patch()

@onlyOnce
def patch_testcase_timeout():
Expand Down Expand Up @@ -121,3 +126,4 @@ def patch_all(for_tests=False):
patch_unittest_testcase()

patch_python14653()
patch_twisted9127()
53 changes: 53 additions & 0 deletions master/buildbot/monkeypatches/twisted9127.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# This file is part of Buildbot. Buildbot is free software: you can
# redistribute it and/or modify it under the terms of the GNU General Public
# License as published by the Free Software Foundation, version 2.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
# details.
#
# You should have received a copy of the GNU General Public License along with
# this program; if not, write to the Free Software Foundation, Inc., 51
# Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Copyright Buildbot Team Members

from __future__ import absolute_import
from __future__ import print_function

from twisted.python.compat import nativeString
from twisted.python.compat import networkString


# patch for http://twistedmatrix.com/trac/ticket/9127
# unfortunatly the impacted code is deeply inside render method, so we need to patch the whole
# render method

def render(self, request):
"""
Send www-authenticate headers to the client
"""
def generateWWWAuthenticate(scheme, challenge):
_l = []
for k, v in challenge.items():
_l.append(networkString("%s=%s" % (nativeString(k), quoteString(nativeString(v)))))
return b" ".join([scheme, b", ".join(_l)])

def quoteString(s):
return '"%s"' % (s.replace('\\', '\\\\').replace('"', '\\"'),)

request.setResponseCode(401)
for fact in self._credentialFactories:
challenge = fact.getChallenge(request)
request.responseHeaders.addRawHeader(
b'www-authenticate',
generateWWWAuthenticate(fact.scheme, challenge))
if request.method == b'HEAD':
return b''
return b'Unauthorized'


def patch():
from twisted.web._auth.wrapper import UnauthorizedResource
UnauthorizedResource.render = render
2 changes: 0 additions & 2 deletions master/buildbot/newsfragments/auth.py3.bugfix

This file was deleted.

2 changes: 2 additions & 0 deletions master/buildbot/newsfragments/auth_py3.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Fix :py:class:`UserPasswordAuth` authentication on ``py3`` and recent browsers. (:issue:`3162`, :issue:`3163`).
The ``py3`` fix also requires Twisted https://github.com/twisted/twisted/pull/773.
48 changes: 48 additions & 0 deletions master/docs/relnotes/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,54 @@ Release Notes

.. towncrier release notes start
Buildbot ``0.9.6-35-g615cb76`` ( ``2017-04-30`` )
=====================================================

Bug fixes
---------

- Fix :py:class:`UserPasswordAuth` authentication on ``py3`` and recent
browsers. (:issue:`3162`, :issue:`3163`). The ``py3`` fix also requires
Twisted https://github.com/twisted/twisted/pull/773.
- :ref:`ConsoleView` now display changes the same way as in Recent Changes
page.
- Fix issue with :ref:`ConsoleView` when no change source is configured but
still builds have ``got_revision`` property

Features
--------

- Builds ``state_string`` is now automatically computed according to the
:py:meth:`BuildStep.getResultSummary`, :py:attr:`BuildStep.description` and
``updateBuildSummaryPolicy`` from :ref:`Buildstep-Common-Parameters`. This
allows the dashboards and reporters to get a descent summary text of the
build without fetching the steps.


Buildbot ``0.9.6-35-g615cb76`` ( ``2017-04-30`` )
=====================================================

Bug fixes
---------

- Fix :py:class:`UserPasswordAuth` authentication on ``py3`` and recent
browsers. (:issue:`3162`, :issue:`3163`). The ``py3`` fix also requires
Twisted https://github.com/twisted/twisted/pull/773.
- :ref:`ConsoleView` now display changes the same way as in Recent Changes
page.
- Fix issue with :ref:`ConsoleView` when no change source is configured but
still builds have ``got_revision`` property

Features
--------

- Builds ``state_string`` is now automatically computed according to the
:py:meth:`BuildStep.getResultSummary`, :py:attr:`BuildStep.description` and
``updateBuildSummaryPolicy`` from :ref:`Buildstep-Common-Parameters`. This
allows the dashboards and reporters to get a descent summary text of the
build without fetching the steps.


Buildbot ``0.9.6`` ( ``2017-04-19`` )
=====================================================

Expand Down
2 changes: 1 addition & 1 deletion master/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ def define_plugin_entries(groups):
# dependencies
setup_args['install_requires'] = [
'setuptools >= 8.0',
'Twisted',
'Twisted ' + twisted_ver,
'Jinja2 >= 2.1',
# required for tests, but Twisted requires this anyway
'zope.interface >= 4.1.1',
Expand Down

0 comments on commit 4094bb6

Please sign in to comment.