Skip to content

Commit

Permalink
Drop asn1crypto and just support pyasn1
Browse files Browse the repository at this point in the history
I added asn1crypto support three years ago in #33, because I was under
the impression that other Python packages such as PyCA cryptography
were going to standardize on asn1crypto. Since 2017 cryptography and
other dependencies have dropped asn1crypto. kdcproxy is currently the
only package in RHEL that depends on python-asn1crypto.

Let's keep it simple and just support pyasn1.

Signed-off-by: Christian Heimes <[email protected]>
  • Loading branch information
tiran authored and frozencemetery committed Dec 8, 2020
1 parent fcad7d5 commit d36d26b
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 153 deletions.
27 changes: 1 addition & 26 deletions kdcproxy/codec.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,36 +19,11 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.

import os
import struct

from kdcproxy import parse_pyasn1 as asn1mod
from kdcproxy.exceptions import ParsingError

ASN1MOD = os.environ.get('KDCPROXY_ASN1MOD')

if ASN1MOD is None:
try:
from asn1crypto.version import __version_info__ as asn1crypto_version
except ImportError:
asn1crypto_version = None
else:
if asn1crypto_version >= (0, 22, 0):
ASN1MOD = 'asn1crypto'
if ASN1MOD is None:
try:
__import__('pyasn1')
except ImportError:
pass
else:
ASN1MOD = 'pyasn1'

if ASN1MOD == 'asn1crypto':
from kdcproxy import parse_asn1crypto as asn1mod
elif ASN1MOD == 'pyasn1':
from kdcproxy import parse_pyasn1 as asn1mod
else:
raise ValueError("Invalid KDCPROXY_ASN1MOD='{}'".format(ASN1MOD))


class ProxyRequest(object):
TYPE = None
Expand Down
104 changes: 0 additions & 104 deletions kdcproxy/parse_asn1crypto.py

This file was deleted.

2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
from setuptools import setup

install_requires = [
'asn1crypto>=0.23',
'pyasn1',
'dnspython'
]

Expand Down
16 changes: 0 additions & 16 deletions tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
# THE SOFTWARE.

import os
import sys
import unittest
from base64 import b64decode
try:
Expand Down Expand Up @@ -226,21 +225,6 @@ def test_kpasswdreq(self):
'FREEIPA.LOCAL KPASSWD-REQ (603 bytes) (version 0x0001)'
)

def test_asn1mod(self):
modmap = {
'asn1crypto': (
'kdcproxy.parse_asn1crypto', 'kdcproxy.parse_pyasn1'),
'pyasn1': (
'kdcproxy.parse_pyasn1', 'kdcproxy.parse_asn1crypto'),
}
asn1mod = os.environ.get('KDCPROXY_ASN1MOD', None)
if asn1mod is None:
self.fail("Tests require KDCPROXY_ASN1MOD env var.")
self.assertIn(asn1mod, modmap)
mod, opposite = modmap[asn1mod]
self.assertIn(mod, set(sys.modules))
self.assertNotIn(opposite, set(sys.modules))


class KDCProxyConfigTests(unittest.TestCase):

Expand Down
7 changes: 1 addition & 6 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
[tox]
minversion = 2.3.1
envlist = {py36,py37,py38,py39}-{asn1crypto,pyasn1},pep8,py3pep8,doc,coverage-report
envlist = py36,py37,py38,py39,pep8,py3pep8,doc,coverage-report
skip_missing_interpreters = true

[testenv]
deps =
.[tests]
pyasn1: pyasn1
asn1crypto: asn1crypto>=0.23
setenv =
asn1crypto: KDCPROXY_ASN1MOD=asn1crypto
pyasn1: KDCPROXY_ASN1MOD=pyasn1
commands =
{envpython} -m coverage run --parallel \
-m pytest --capture=no --strict {posargs}
Expand Down

0 comments on commit d36d26b

Please sign in to comment.