[Pkg-freeipa-devel] [Git][freeipa-team/python-kdcproxy][upstream] 9 commits: Properly handle missing Content-Length

Timo Aaltonen gitlab at salsa.debian.org
Sat Aug 4 09:22:38 BST 2018


Timo Aaltonen pushed to branch upstream at FreeIPA packaging / python-kdcproxy


Commits:
5edbbeb7 by Nathaniel McCallum at 2015-08-03T20:52:14Z
Properly handle missing Content-Length

- - - - -
d9923b58 by Christian Heimes at 2017-01-04T15:38:47Z
Fix tests

Python 2's mock is no longer compatible to more recent versions of
Python's socket module. Tests are still fine without the autospec
feature.

More recent versions of pytests refuse to load tests because pytest
considers webtest.TestApp as a test class with a non-trival __init__.

Signed-off-by: Christian Heimes <cheimes at redhat.com>

- - - - -
5ed2ab9d by Christian Heimes at 2017-01-04T15:50:29Z
Fix PEP8 violations

Recent versions of flake8 became more strict.

Signed-off-by: Christian Heimes <cheimes at redhat.com>

- - - - -
84a83297 by Christian Heimes at 2017-01-04T15:50:29Z
Port setup.py and tox to setuptools

Let's use setuptools to build and distribute kdcproxy. This gives us
wheel packages and nicer dependency management. The special case for
setuptools < 18.0 is required for old installations.

Signed-off-by: Christian Heimes <cheimes at redhat.com>

- - - - -
07f5204a by Christian Heimes at 2017-01-04T15:52:55Z
Add Travis CI configuration

Signed-off-by: Christian Heimes <cheimes at redhat.com>

- - - - -
483c00d0 by Mark Schreiber at 2017-01-04T16:02:38Z
Eliminate import error message

Avoid logging an error message due to a failing import.  Key the
attempted import off the Python version rather than trying, failing, and
falling back.

- - - - -
55034d6b by Nathaniel McCallum at 2017-01-04T16:33:31Z
Fix some pep8 issues

Signed-off-by: Nathaniel McCallum <npmccallum at redhat.com>

- - - - -
881e3ec1 by Christian Heimes at 2017-01-19T12:54:24Z
Prepare 0.3.3

kdcproxy is now official stable and supports 3.5 and 3.6.

Signed-off-by: Christian Heimes <cheimes at redhat.com>

- - - - -
d2a2e11a by Christian Heimes at 2017-01-19T13:17:10Z
typo, I forgot a trailing comma

Signed-off-by: Christian Heimes <cheimes at redhat.com>

- - - - -


9 changed files:

- .gitignore
- + .travis.yml
- MANIFEST.in
- kdcproxy/__init__.py
- kdcproxy/config/mit.py
- + setup.cfg
- setup.py
- tests.py
- tox.ini


Changes:

=====================================
.gitignore
=====================================
--- a/.gitignore
+++ b/.gitignore
@@ -5,3 +5,5 @@ __pycache__
 /dist
 /build
 /MANIFEST
+/*.egg-info
+/.cache


=====================================
.travis.yml
=====================================
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,29 @@
+sudo: false
+
+language: python
+
+cache: pip
+
+matrix:
+  include:
+    - python: 2.7
+      env: TOXENV=py27
+    - python: 3.4
+      env: TOXENV=py34
+    - python: 3.5
+      env: TOXENV=py35
+    - python: 3.6
+      env: TOXENV=py36
+    - python: 2.7
+      env: TOXENV=pep8
+    - python: 3.5
+      env: TOXENV=py3pep8
+
+install:
+  - pip install --upgrade pip setuptools
+  - pip --version
+  - pip install tox
+  - tox --version
+
+script:
+  - tox


=====================================
MANIFEST.in
=====================================
--- a/MANIFEST.in
+++ b/MANIFEST.in
@@ -1 +1,5 @@
 include README COPYING
+include tox.ini
+include setup.cfg
+include tests.py tests.krb5.conf
+include .coveragerc


=====================================
kdcproxy/__init__.py
=====================================
--- a/kdcproxy/__init__.py
+++ b/kdcproxy/__init__.py
@@ -27,16 +27,16 @@ import struct
 import sys
 import time
 
-try:  # Python 3.x
+import kdcproxy.codec as codec
+from kdcproxy.config import MetaResolver
+
+if sys.version_info.major >= 3:  # Python 3.x
     import http.client as httplib
     import urllib.parse as urlparse
-except ImportError:  # Python 2.x
+else:
     import httplib
     import urlparse
 
-import kdcproxy.codec as codec
-from kdcproxy.config import MetaResolver
-
 
 class HTTPException(Exception):
 
@@ -178,10 +178,13 @@ class Application:
                 raise HTTPException(405, "Method not allowed (%s)." % method)
 
             # Parse the request
+            length = -1
             try:
                 length = int(env["CONTENT_LENGTH"])
-            except AttributeError:
-                raise HTTPException(411, "Length required.")
+            except KeyError:
+                pass
+            except ValueError:
+                pass
             if length < 0:
                 raise HTTPException(411, "Length required.")
             if length > self.MAX_LENGTH:
@@ -228,8 +231,8 @@ class Application:
                 for addr in addrs + (None,):
                     if addr is not None:
                         # Bypass unspecified socktypes
-                        if (len(scheme) > 1
-                                and addr[1] != self.SOCKTYPES[scheme[1]]):
+                        if (len(scheme) > 1 and
+                                addr[1] != self.SOCKTYPES[scheme[1]]):
                             continue
 
                         # Create the socket
@@ -278,4 +281,5 @@ class Application:
             start_response(str(e), e.headers)
             return [e.message]
 
+
 application = Application()


=====================================
kdcproxy/config/mit.py
=====================================
--- a/kdcproxy/config/mit.py
+++ b/kdcproxy/config/mit.py
@@ -33,8 +33,10 @@ from kdcproxy.config import IConfig
 class KRB5Error(Exception):
     pass
 
+
 PY3 = sys.version_info[0] == 3
 
+
 try:
     LIBKRB5 = ctypes.CDLL('libkrb5.so.3')
 except OSError as e:  # pragma: no cover
@@ -272,6 +274,7 @@ class MITConfig(IConfig):
     def use_dns(self, default=True):
         return self.__config["dns"]
 
+
 if __name__ == "__main__":
     from pprint import pprint
     with KRB5Profile() as prof:


=====================================
setup.cfg
=====================================
--- /dev/null
+++ b/setup.cfg
@@ -0,0 +1,8 @@
+[bdist_wheel]
+universal = 1
+
+[aliases]
+# requires setuptools and wheel package
+# dnf install python3-setuptools python3-wheel
+packages = clean --all egg_info bdist_wheel sdist --format=zip sdist --format=gztar
+release = packages register upload


=====================================
setup.py
=====================================
--- a/setup.py
+++ b/setup.py
@@ -21,11 +21,32 @@
 
 import os
 import sys
-from distutils.core import setup
 
-dns = "dnspython"
-if sys.version_info.major == 3:
-    dns += "3"
+import setuptools
+from setuptools import setup
+
+
+SETUPTOOLS_VERSION = tuple(int(v) for v in setuptools.__version__.split("."))
+
+install_requires = [
+    'pyasn1',
+]
+
+extras_require = {
+    "tests": ["pytest", "coverage", "WebTest"],
+    "test_pep8": ['flake8', 'flake8-import-order', 'pep8-naming']
+}
+
+if SETUPTOOLS_VERSION >= (18, 0):
+    extras_require.update({
+        ":python_version<'3'": ["dnspython"],
+        ":python_version>='3'": ["dnspython3"],
+    })
+else:
+    if sys.version_info.major == 2:
+        install_requires.append("dnspython")
+    else:
+        install_requires.append("dnspython3")
 
 
 def read(fname):
@@ -33,9 +54,10 @@ def read(fname):
     with open(fname) as f:
         return f.read()
 
+
 setup(
     name="kdcproxy",
-    version="0.3.2",
+    version="0.3.3",
     author="Nalin Dahyabhai, Nathaniel McCallum, Christian Heimes",
     author_email="nalin at redhat.com, npmccallum at redhat.com, cheimes at redhat.com",
     description=("A kerberos KDC HTTP proxy WSGI module."),
@@ -44,15 +66,18 @@ setup(
     url="http://github.com/npmccallum/kdcproxy",
     packages=['kdcproxy', 'kdcproxy.config'],
     long_description=read('README'),
-    requires=['pyasn1', dns],
+    install_requires=install_requires,
+    extras_require=extras_require,
     classifiers=[
-        "Development Status :: 3 - Alpha",
+        "Development Status :: 5 - Production/Stable",
         "Environment :: Web Environment",
         "Intended Audience :: System Administrators",
         "License :: OSI Approved :: MIT License",
         "Operating System :: OS Independent",
         "Programming Language :: Python :: 2.7",
         "Programming Language :: Python :: 3",
+        "Programming Language :: Python :: 3.5",
+        "Programming Language :: Python :: 3.6",
         "Topic :: Internet :: Proxy Servers",
     ],
 )


=====================================
tests.py
=====================================
--- a/tests.py
+++ b/tests.py
@@ -34,7 +34,7 @@ from dns.rdtypes.IN.SRV import SRV
 
 from pyasn1.codec.der import decoder, encoder
 
-from webtest import TestApp
+from webtest import TestApp as WebTestApp
 
 import kdcproxy
 # from kdcproxy import asn1
@@ -59,7 +59,7 @@ class KDCProxyWSGITests(unittest.TestCase):
         self.await_reply.return_value = b'RESPONSE'
         self.resolver = self.app._Application__resolver = mock.Mock()
         self.resolver.lookup.return_value = ["kerberos://k1.kdcproxy.test.:88"]
-        self.tapp = TestApp(self.app)
+        self.tapp = WebTestApp(self.app)
 
     def post(self, body, expect_errors=False):
         return self.tapp.post(
@@ -79,7 +79,7 @@ class KDCProxyWSGITests(unittest.TestCase):
         self.assertEqual(r.text, 'Method not allowed (GET).')
 
     @mock.patch('socket.getaddrinfo', return_value=addrinfo)
-    @mock.patch('socket.socket', autospec=True)
+    @mock.patch('socket.socket')
     def test_post_asreq(self, m_socket, m_getaddrinfo):
         response = self.post(KDCProxyCodecTests.asreq1)
         self.assert_response(response)
@@ -92,7 +92,7 @@ class KDCProxyWSGITests(unittest.TestCase):
         )
 
     @mock.patch('socket.getaddrinfo', return_value=addrinfo)
-    @mock.patch('socket.socket', autospec=True)
+    @mock.patch('socket.socket')
     def test_post_kpasswd(self, m_socket, m_getaddrinfo):
         response = self.post(KDCProxyCodecTests.kpasswdreq)
         self.assert_response(response)


=====================================
tox.ini
=====================================
--- a/tox.ini
+++ b/tox.ini
@@ -1,44 +1,33 @@
 [tox]
-envlist = py27,py34,pep8,py3pep8,doc
+minversion = 2.3.1
+envlist = py27,py34,py35,py36,pep8,py3pep8,doc
+skip_missing_interpreters = true
 
 [testenv]
 deps =
-    pytest
-    coverage
-    WebTest
-    pyasn1
+   .[tests]
 commands =
-    coverage run -m pytest --capture=no --strict {posargs}
-    coverage report -m
+    {envpython} -m coverage run -m pytest --capture=no --strict {posargs}
+    {envpython} -m coverage report -m
 
 [testenv:py27]
 deps =
-    {[testenv]deps}
-    dnspython
-    mock
-
-[testenv:py34]
-deps =
-    {[testenv]deps}
-    dnspython3
+   .[tests]
+   mock
 
 [testenv:pep8]
 basepython = python2.7
 deps =
-    flake8
-    flake8-import-order
-    pep8-naming
+    .[test_pep8]
 commands =
-    flake8 {posargs}
+    {envpython} -m flake8
 
 [testenv:py3pep8]
-basepython = python3.4
+basepython = python3
 deps =
-    flake8
-    flake8-import-order
-    pep8-naming
+    .[test_pep8]
 commands =
-    flake8 {posargs}
+    {envpython} -m flake8
 
 [testenv:doc]
 deps =



View it on GitLab: https://salsa.debian.org/freeipa-team/python-kdcproxy/compare/f32c13314edd9bfb45df7aadcb482ee8c1d360e3...d2a2e11a09584f4e8df60b3ca69c2d161565a547

-- 
View it on GitLab: https://salsa.debian.org/freeipa-team/python-kdcproxy/compare/f32c13314edd9bfb45df7aadcb482ee8c1d360e3...d2a2e11a09584f4e8df60b3ca69c2d161565a547
You're receiving this email because of your account on salsa.debian.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/pkg-freeipa-devel/attachments/20180804/4f99de9f/attachment-0001.html>


More information about the Pkg-freeipa-devel mailing list