Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop asn1crypto and just support pyasn1 #57

Merged
merged 1 commit into from
Dec 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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