public void ConstructorEmpty () { X509BasicConstraintsExtension bc = new X509BasicConstraintsExtension (); Assert.IsFalse (bc.Critical, "Critical"); Assert.IsNull (bc.RawData, "RawData"); Assert.AreEqual (oid, bc.Oid.Value, "Oid.Value"); Assert.AreEqual (fname, bc.Oid.FriendlyName, "Oid.FriendlyName"); Assert.AreEqual (String.Empty, bc.Format (true), "Format(true)"); Assert.AreEqual (String.Empty, bc.Format (false), "Format(false)"); }
public void ConstructorEmpty () { X509BasicConstraintsExtension bc = new X509BasicConstraintsExtension (); Assert.IsFalse (bc.Critical, "Critical"); Assert.IsNull (bc.RawData, "RawData"); Assert.AreEqual (oid, bc.Oid.Value, "Oid.Value"); // FIXME: Don't expect that FriendlyName is English. This test fails under non-English Windows. //Assert.AreEqual (fname, bc.Oid.FriendlyName, "Oid.FriendlyName"); Assert.AreEqual (String.Empty, bc.Format (true), "Format(true)"); Assert.AreEqual (String.Empty, bc.Format (false), "Format(false)"); }
public void ConstructorAsnEncodedData_BadAsn () { AsnEncodedData aed = new AsnEncodedData ("1.2.3", new byte[0]); X509BasicConstraintsExtension bc = new X509BasicConstraintsExtension (aed, true); Assert.AreEqual (String.Empty, bc.Format (true), "Format(true)"); Assert.AreEqual (String.Empty, bc.Format (false), "Format(false)"); bool b = bc.CertificateAuthority; }
public void ConstructorAsnEncodedData () { AsnEncodedData aed = new AsnEncodedData (new byte[] { 0x30, 0x06, 0x01, 0x01, 0xFF, 0x02, 0x01, 0x01 }); X509BasicConstraintsExtension bc = new X509BasicConstraintsExtension (aed, true); Assert.IsTrue (bc.Critical, "Critical"); Assert.AreEqual (8, bc.RawData.Length, "RawData"); // original Oid ignored Assert.AreEqual (oid, bc.Oid.Value, "Oid.Value"); // FIXME: Don't expect that FriendlyName is English. This test fails under non-English Windows. //Assert.AreEqual (fname, bc.Oid.FriendlyName, "Oid.FriendlyName"); Assert.IsTrue (bc.CertificateAuthority, "CertificateAuthority"); Assert.IsTrue (bc.HasPathLengthConstraint, "HasPathLengthConstraint"); Assert.AreEqual (1, bc.PathLengthConstraint, "PathLengthConstraint"); Assert.AreEqual ("Subject Type=CA" + Environment.NewLine + "Path Length Constraint=1" + Environment.NewLine, bc.Format (true), "Format(true)"); Assert.AreEqual ("Subject Type=CA, Path Length Constraint=1", bc.Format (false), "Format(false)"); }
public void Constructor_FalseFalseNegative () { X509BasicConstraintsExtension bc = new X509BasicConstraintsExtension (false, false, -1, true); Assert.IsFalse (bc.CertificateAuthority, "CertificateAuthority"); Assert.IsFalse (bc.HasPathLengthConstraint, "HasPathLengthConstraint"); Assert.AreEqual (0, bc.PathLengthConstraint, "PathLengthConstraint"); Assert.AreEqual ("30-00", BitConverter.ToString (bc.RawData), "RawData"); Assert.AreEqual ("Subject Type=End Entity" + Environment.NewLine + "Path Length Constraint=None" + Environment.NewLine, bc.Format (true), "Format(true)"); Assert.AreEqual ("Subject Type=End Entity, Path Length Constraint=None", bc.Format (false), "Format(false)"); }
public void Constructor_TrueTrueMaxInt () { X509BasicConstraintsExtension bc = new X509BasicConstraintsExtension (true, true, Int32.MaxValue, true); Assert.IsTrue (bc.CertificateAuthority, "CertificateAuthority"); Assert.IsTrue (bc.HasPathLengthConstraint, "HasPathLengthConstraint"); Assert.AreEqual (Int32.MaxValue, bc.PathLengthConstraint, "PathLengthConstraint"); Assert.AreEqual ("30-09-01-01-FF-02-04-7F-FF-FF-FF", BitConverter.ToString (bc.RawData), "RawData"); Assert.AreEqual ("Subject Type=CA" + Environment.NewLine + "Path Length Constraint=2147483647" + Environment.NewLine, bc.Format (true), "Format(true)"); Assert.AreEqual ("Subject Type=CA, Path Length Constraint=2147483647", bc.Format (false), "Format(false)"); }
public void Constructor_TrueTrueZero () { X509BasicConstraintsExtension bc = new X509BasicConstraintsExtension (true, true, 0, true); Assert.IsTrue (bc.CertificateAuthority, "CertificateAuthority"); Assert.IsTrue (bc.HasPathLengthConstraint, "HasPathLengthConstraint"); Assert.AreEqual (0, bc.PathLengthConstraint, "PathLengthConstraint"); Assert.AreEqual ("30-06-01-01-FF-02-01-00", BitConverter.ToString (bc.RawData), "RawData"); Assert.AreEqual ("Subject Type=CA" + Environment.NewLine + "Path Length Constraint=0" + Environment.NewLine, bc.Format (true), "Format(true)"); Assert.AreEqual ("Subject Type=CA, Path Length Constraint=0", bc.Format (false), "Format(false)"); }
public void ConstructorAsnEncodedData_SmallestValid () { AsnEncodedData aed = new AsnEncodedData ("1.2.3", new byte[] { 0x30, 0x00 }); X509BasicConstraintsExtension bc = new X509BasicConstraintsExtension (aed, true); Assert.IsFalse (bc.CertificateAuthority, "CertificateAuthority"); Assert.IsFalse (bc.HasPathLengthConstraint, "HasPathLengthConstraint"); Assert.AreEqual (0, bc.PathLengthConstraint, "PathLengthConstraint"); Assert.AreEqual ("30-00", BitConverter.ToString (bc.RawData), "RawData"); Assert.AreEqual ("Subject Type=End Entity" + Environment.NewLine + "Path Length Constraint=None" + Environment.NewLine, bc.Format (true), "Format(true)"); Assert.AreEqual ("Subject Type=End Entity, Path Length Constraint=None", bc.Format (false), "Format(false)"); }
public void ConstructorAsnEncodedData_BadAsnLength () { AsnEncodedData aed = new AsnEncodedData ("1.2.3", new byte[] { 0x30, 0x01 }); X509BasicConstraintsExtension bc = new X509BasicConstraintsExtension (aed, true); Assert.AreEqual ("3001", bc.Format (true), "Format(true)"); Assert.AreEqual ("3001", bc.Format (false), "Format(false)"); bool b = bc.CertificateAuthority; }