From 8b5d094ca3bb5cafa61001b83c1798e40af37223 Mon Sep 17 00:00:00 2001 From: Paul Kehrer Date: Tue, 27 Oct 2015 09:35:17 +0900 Subject: switch to using pyasn1_modules for the test --- dev-requirements.txt | 2 +- setup.py | 2 +- tests/test_x509.py | 26 ++++++++++++++------------ tox.ini | 2 +- 4 files changed, 17 insertions(+), 15 deletions(-) diff --git a/dev-requirements.txt b/dev-requirements.txt index 2c0ca18c..f6eec132 100644 --- a/dev-requirements.txt +++ b/dev-requirements.txt @@ -1,4 +1,3 @@ -asn1crypto coverage flake8 flake8-import-order @@ -6,6 +5,7 @@ invoke iso8601 pep8-naming pretend +pyasn1_modules pytest requests sphinx diff --git a/setup.py b/setup.py index d54afc02..19f1e663 100644 --- a/setup.py +++ b/setup.py @@ -63,7 +63,7 @@ test_requirements = [ "pretend", "iso8601", "hypothesis", - "asn1crypto", + "pyasn1_modules", ] # If there's no vectors locally that probably means we are in a tarball and diff --git a/tests/test_x509.py b/tests/test_x509.py index 1fa4d82a..79424752 100644 --- a/tests/test_x509.py +++ b/tests/test_x509.py @@ -9,7 +9,9 @@ import datetime import ipaddress import os -from asn1crypto import core, x509 as asn1cryptox509 +from pyasn1.codec.der import decoder + +from pyasn1_modules import rfc2459 import pytest @@ -861,17 +863,17 @@ class TestRSACertificateRequest(object): cert = builder.sign(issuer_private_key, hashes.SHA256(), backend) - parsedasn1 = asn1cryptox509.Certificate.load( - cert.public_bytes(serialization.Encoding.DER) - ) - assert isinstance( - parsedasn1.subject.chosen[0][0]['value'].chosen, - core.PrintableString - ) - assert isinstance( - parsedasn1.subject.chosen[1][0]['value'].chosen, - core.UTF8String - ) + parsed, _ = decoder.decode( + cert.public_bytes(serialization.Encoding.DER), + asn1Spec=rfc2459.Certificate() + ) + tbs_cert = parsed.getComponentByName('tbsCertificate') + subject = tbs_cert.getComponentByName('subject') + issuer = tbs_cert.getComponentByName('issuer') + # \x13 is printable string. The first byte of the value of the + # node corresponds to the ASN.1 string type. + assert str(subject[0][0][0][1])[0] == "\x13" + assert str(issuer[0][0][0][1])[0] == "\x13" class TestCertificateBuilder(object): diff --git a/tox.ini b/tox.ini index 820eccf3..35dc5671 100644 --- a/tox.ini +++ b/tox.ini @@ -9,7 +9,7 @@ deps = pretend pytest hypothesis>=1.11.4 - asn1crypto + pyasn1_modules ./vectors passenv = ARCHFLAGS LDFLAGS CFLAGS INCLUDE LIB LD_LIBRARY_PATH USERNAME commands = -- cgit v1.2.3