]> Cypherpunks.ru repositories - pyderasn.git/blobdiff - tests/test_pyderasn.py
PrintableString can optionally allow * and &
[pyderasn.git] / tests / test_pyderasn.py
index 9fbb33eb39f2d75231721cee73de95a32d66d717..aaac6cd56957f2bff73496750b953d7565d58697 100644 (file)
@@ -3506,6 +3506,21 @@ class TestPrintableString(
         self.assertEqual(err.exception.offset, offset)
         self.assertEqual(err.exception.decode_path, decode_path)
 
+    def test_allowable_invalid_chars(self):
+        for c, kwargs in (
+                ("*", {"allow_asterisk": True}),
+                ("&", {"allow_ampersand": True}),
+                ("&*", {"allow_asterisk": True, "allow_ampersand": True}),
+        ):
+            s = "hello invalid " + c
+            with assertRaisesRegex(self, DecodeError, "non-printable"):
+                self.base_klass(s)
+            self.base_klass(s, **kwargs)
+            klass = self.base_klass(**kwargs)
+            obj = klass(s)
+            obj = obj.copy()
+            obj(s)
+
 
 class TestTeletexString(
         UnicodeDecodeErrorMixin,