summary refs log tree commit diff
path: root/crypto/test
diff options
context:
space:
mode:
authorPeter Dettman <peter.dettman@bouncycastle.org>2020-04-05 21:16:59 +0700
committerPeter Dettman <peter.dettman@bouncycastle.org>2020-04-05 21:16:59 +0700
commit184077ebeabe315ec4dc13e2670868422f7b9594 (patch)
tree2178074db98529109b9d91e5e42e8c555bd904e8 /crypto/test
parentAdd OIW dsaWithSHA1 OID to 'noParams' (diff)
downloadBouncyCastle.NET-ed25519-184077ebeabe315ec4dc13e2670868422f7b9594.tar.xz
Add OtherName support and refactoring
Diffstat (limited to 'crypto/test')
-rw-r--r--crypto/test/src/test/PkixNameConstraintsTest.cs31
1 files changed, 31 insertions, 0 deletions
diff --git a/crypto/test/src/test/PkixNameConstraintsTest.cs b/crypto/test/src/test/PkixNameConstraintsTest.cs
index 073f9f2a3..65f39dcd2 100644
--- a/crypto/test/src/test/PkixNameConstraintsTest.cs
+++ b/crypto/test/src/test/PkixNameConstraintsTest.cs
@@ -197,6 +197,37 @@ namespace Org.BouncyCastle.Tests
             constraintValidator.checkPermitted(
                 new GeneralName(GeneralName.DirectoryName,
                     new X509Name(true, "cn=Valid DN nameConstraints EE Certificate Test1, ou=permittedSubtree1, o=Test Certificates 2011, c=US")));
+
+            GeneralName name = new GeneralName(GeneralName.OtherName, new OtherName(new DerObjectIdentifier("1.1"), DerNull.Instance));
+            GeneralSubtree subtree = new GeneralSubtree(name);
+
+            PkixNameConstraintValidator validator = new PkixNameConstraintValidator();
+            validator.IntersectPermittedSubtree(new DerSequence(subtree));
+
+            name = new GeneralName(GeneralName.OtherName, new OtherName(new DerObjectIdentifier("1.1"), DerNull.Instance));
+            subtree = new GeneralSubtree(name);
+
+            validator = new PkixNameConstraintValidator();
+            validator.IntersectPermittedSubtree(new DerSequence(subtree));
+            validator.AddExcludedSubtree(subtree);
+
+            try
+            {
+                validator.checkExcluded(name);
+            }
+            catch (PkixNameConstraintValidatorException e)
+            {
+                IsEquals("OtherName is from an excluded subtree.", e.Message);
+            }
+
+            try
+            {
+                validator.checkPermitted(name);
+            }
+            catch (PkixNameConstraintValidatorException e)
+            {
+                Fail(e.Message);
+            }
         }
 
 		/**