diff options
author | Alex Gaynor <alex.gaynor@gmail.com> | 2015-07-14 07:23:06 -0400 |
---|---|---|
committer | Alex Gaynor <alex.gaynor@gmail.com> | 2015-07-14 07:23:06 -0400 |
commit | b5458f33b0421d5a67a349b9570ad628185fe632 (patch) | |
tree | 2d91b47ad3bc57a91e644e296696f36e6547e21e /tests | |
parent | 677c3d55cdbb332723fd1e0e5fe8829465d90c50 (diff) | |
parent | 1b830538ff74d5425f26fcbce55b2ffb5212e76c (diff) | |
download | cryptography-b5458f33b0421d5a67a349b9570ad628185fe632.tar.gz cryptography-b5458f33b0421d5a67a349b9570ad628185fe632.tar.bz2 cryptography-b5458f33b0421d5a67a349b9570ad628185fe632.zip |
Merge pull request #2150 from reaperhulk/encode-uri
support URI general name encoding
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test_x509.py | 28 |
1 files changed, 23 insertions, 5 deletions
diff --git a/tests/test_x509.py b/tests/test_x509.py index 2539be47..94eeab2b 100644 --- a/tests/test_x509.py +++ b/tests/test_x509.py @@ -13,7 +13,7 @@ import pytest import six -from cryptography import x509 +from cryptography import utils, x509 from cryptography.exceptions import UnsupportedAlgorithm from cryptography.hazmat.backends.interfaces import ( DSABackend, EllipticCurveBackend, RSABackend, X509Backend @@ -27,6 +27,14 @@ from .hazmat.primitives.test_ec import _skip_curve_unsupported from .utils import load_vectors_from_file +@utils.register_interface(x509.GeneralName) +class FakeGeneralName(object): + def __init__(self, value): + self._value = value + + value = utils.read_only_property("_value") + + def _load_cert(filename, loader, backend): cert = load_vectors_from_file( filename=filename, @@ -1011,6 +1019,12 @@ class TestCertificateSigningRequestBuilder(object): x509.RFC822Name(u"test@example.com"), x509.RFC822Name(u"email"), x509.RFC822Name(u"email@em\xe5\xefl.com"), + x509.UniformResourceIdentifier( + u"https://\u043f\u044b\u043a\u0430.cryptography" + ), + x509.UniformResourceIdentifier( + u"gopher://cryptography:70/some/path" + ), ]), critical=False, ).sign(private_key, hashes.SHA256(), backend) @@ -1040,6 +1054,12 @@ class TestCertificateSigningRequestBuilder(object): x509.RFC822Name(u"test@example.com"), x509.RFC822Name(u"email"), x509.RFC822Name(u"email@em\xe5\xefl.com"), + x509.UniformResourceIdentifier( + u"https://\u043f\u044b\u043a\u0430.cryptography" + ), + x509.UniformResourceIdentifier( + u"gopher://cryptography:70/some/path" + ), ] def test_invalid_asn1_othername(self, backend): @@ -1069,13 +1089,11 @@ class TestCertificateSigningRequestBuilder(object): x509.NameAttribute(x509.OID_COMMON_NAME, u"SAN"), ]) ).add_extension( - x509.SubjectAlternativeName([ - x509.UniformResourceIdentifier(u"http://test.com"), - ]), + x509.SubjectAlternativeName([FakeGeneralName("")]), critical=False, ) - with pytest.raises(NotImplementedError): + with pytest.raises(ValueError): builder.sign(private_key, hashes.SHA256(), backend) |