diff options
author | Marti Raudsepp <marti@juffo.org> | 2024-05-09 16:54:49 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-09 13:54:49 +0000 |
commit | acc3226faabfad4ce1036722b88871171bd03439 (patch) | |
tree | eceb5fef099ad21c1504014a624431ae0a32c2f3 /tests | |
parent | 8a9709e8c15068f742646264a88d7c5def6f66af (diff) | |
download | pyca-cryptography-acc3226faabfad4ce1036722b88871171bd03439.zip pyca-cryptography-acc3226faabfad4ce1036722b88871171bd03439.tar.gz pyca-cryptography-acc3226faabfad4ce1036722b88871171bd03439.tar.bz2 |
Support empty string in `Name.from_rfc4514_string()` (#10964)
Empty string is a valid result from RFC4514 serialization, and should parse successfully.
According to https://datatracker.ietf.org/doc/html/rfc4514#section-2.1
> If the RDNSequence is an empty sequence, the result is the empty or zero-length string.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/x509/test_name.py | 1 | ||||
-rw-r--r-- | tests/x509/test_x509.py | 3 |
2 files changed, 4 insertions, 0 deletions
diff --git a/tests/x509/test_name.py b/tests/x509/test_name.py index 4c9ccc3..a1ceffc 100644 --- a/tests/x509/test_name.py +++ b/tests/x509/test_name.py @@ -159,6 +159,7 @@ class TestRFC4514: "2.5.4.10=abc", Name([NameAttribute(NameOID.ORGANIZATION_NAME, "abc")]), ), + ("", Name([])), ]: with subtests.test(): result = Name.from_rfc4514_string(value) diff --git a/tests/x509/test_x509.py b/tests/x509/test_x509.py index 40686e4..29e611d 100644 --- a/tests/x509/test_x509.py +++ b/tests/x509/test_x509.py @@ -5885,6 +5885,9 @@ class TestNameAttribute: {NameOID.COMMON_NAME: "CommonName", NameOID.EMAIL_ADDRESS: "E"} ) == ("CommonName=Santa Claus,E=santa@north.pole") + def test_empty_name(self): + assert x509.Name([]).rfc4514_string() == "" + def test_empty_value(self): na = x509.NameAttribute(NameOID.STATE_OR_PROVINCE_NAME, "") assert na.rfc4514_string() == r"ST=" |