From 641149c2b4cc17edd5934d76e23a47d782b28f55 Mon Sep 17 00:00:00 2001 From: Paul Kehrer Date: Sun, 6 Mar 2016 19:10:56 -0430 Subject: raise ValueError if > 2 byte value for NameAttribute with CN OID --- tests/test_x509.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'tests') diff --git a/tests/test_x509.py b/tests/test_x509.py index 6145edb1..9054c4ed 100644 --- a/tests/test_x509.py +++ b/tests/test_x509.py @@ -3327,6 +3327,20 @@ class TestNameAttribute(object): b'bytes' ) + def test_init_bad_country_code_value(self): + with pytest.raises(ValueError): + x509.NameAttribute( + NameOID.COUNTRY_NAME, + u'United States' + ) + + # unicode string of length 2, but > 2 bytes + with pytest.raises(ValueError): + x509.NameAttribute( + NameOID.COUNTRY_NAME, + u'\U0001F37A\U0001F37A' + ) + def test_eq(self): assert x509.NameAttribute( x509.ObjectIdentifier('2.999.1'), u'value' -- cgit v1.2.3