aboutsummaryrefslogtreecommitdiffstats
path: root/tests/test_x509.py
diff options
context:
space:
mode:
authorMarti <marti@juffo.org>2016-08-26 04:26:31 +0300
committerPaul Kehrer <paul.l.kehrer@gmail.com>2016-08-26 09:26:31 +0800
commit40f1999de74a3bf44f000486a0ce1a58c82827e6 (patch)
treed7c3cb6ea4f0b3846cc8685669c75d963f43db64 /tests/test_x509.py
parenteafc4ee77f92d4e6e208351fd17e9cb1ae045677 (diff)
downloadcryptography-40f1999de74a3bf44f000486a0ce1a58c82827e6.tar.gz
cryptography-40f1999de74a3bf44f000486a0ce1a58c82827e6.tar.bz2
cryptography-40f1999de74a3bf44f000486a0ce1a58c82827e6.zip
Allow passing iterators where collections are expected (#3078)
Iterators can only be enumerated once, breaking code like this in Python 3 for example: san = SubjectAlternativeName(map(DNSName, lst)) This is also a slight behavior change if the caller modifies the list after passing it to the constructor, because input lists are now copied. Which seems like a good thing. Also: * Name now checks that attributes elements are of type NameAttribute * NoticeReference now allows notice_numbers to be any iterable
Diffstat (limited to 'tests/test_x509.py')
-rw-r--r--tests/test_x509.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/tests/test_x509.py b/tests/test_x509.py
index b1d627c3..47b81cb5 100644
--- a/tests/test_x509.py
+++ b/tests/test_x509.py
@@ -3680,6 +3680,14 @@ class TestName(object):
assert hash(name1) == hash(name2)
assert hash(name1) != hash(name3)
+ def test_iter_input(self):
+ attrs = [
+ x509.NameAttribute(x509.ObjectIdentifier('2.999.1'), u'value1')
+ ]
+ name = x509.Name(iter(attrs))
+ assert list(name) == attrs
+ assert list(name) == attrs
+
def test_repr(self):
name = x509.Name([
x509.NameAttribute(NameOID.COMMON_NAME, u'cryptography.io'),
@@ -3700,3 +3708,7 @@ class TestName(object):
"=<ObjectIdentifier(oid=2.5.4.10, name=organizationName)>, val"
"ue=u'PyCA')>])>"
)
+
+ def test_not_nameattribute(self):
+ with pytest.raises(TypeError):
+ x509.Name(["not-a-NameAttribute"])