diff options
author | Marti Raudsepp <marti@juffo.org> | 2018-07-09 16:11:18 +0300 |
---|---|---|
committer | Paul Kehrer <paul.l.kehrer@gmail.com> | 2018-07-09 18:41:18 +0530 |
commit | 9e1873af35a2b530e71e1579b2d62c233b75ba26 (patch) | |
tree | 52798039846ad61753859f64a68c2cfdeae0b747 /tests/x509 | |
parent | dd6f4c2977ff03ba0e45e3528f49f126f587f123 (diff) | |
download | cryptography-9e1873af35a2b530e71e1579b2d62c233b75ba26.tar.gz cryptography-9e1873af35a2b530e71e1579b2d62c233b75ba26.tar.bz2 cryptography-9e1873af35a2b530e71e1579b2d62c233b75ba26.zip |
Make RelativeDistinguishedName preserve attribtue order (#4306)
Duplicate attributes now raise an error instead of silently discarding
duplicates.
Diffstat (limited to 'tests/x509')
-rw-r--r-- | tests/x509/test_x509.py | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/tests/x509/test_x509.py b/tests/x509/test_x509.py index 335a0fbf..7f9f1830 100644 --- a/tests/x509/test_x509.py +++ b/tests/x509/test_x509.py @@ -3886,11 +3886,11 @@ class TestRelativeDistinguishedName(object): x509.RelativeDistinguishedName(["not-a-NameAttribute"]) def test_init_duplicate_attribute(self): - rdn = x509.RelativeDistinguishedName([ - x509.NameAttribute(x509.ObjectIdentifier('2.999.1'), u'value1'), - x509.NameAttribute(x509.ObjectIdentifier('2.999.1'), u'value1'), - ]) - assert len(rdn) == 1 + with pytest.raises(ValueError): + x509.RelativeDistinguishedName([ + x509.NameAttribute(x509.ObjectIdentifier('2.999.1'), u'val1'), + x509.NameAttribute(x509.ObjectIdentifier('2.999.1'), u'val1'), + ]) def test_hash(self): rdn1 = x509.RelativeDistinguishedName([ @@ -3932,8 +3932,11 @@ class TestRelativeDistinguishedName(object): assert rdn1 != object() def test_iter_input(self): + # Order must be preserved too attrs = [ - x509.NameAttribute(x509.ObjectIdentifier('2.999.1'), u'value1') + x509.NameAttribute(x509.ObjectIdentifier('2.999.1'), u'value1'), + x509.NameAttribute(x509.ObjectIdentifier('2.999.1'), u'value2'), + x509.NameAttribute(x509.ObjectIdentifier('2.999.1'), u'value3') ] rdn = x509.RelativeDistinguishedName(iter(attrs)) assert list(rdn) == attrs |