|
27 | 27 | using Org.BouncyCastle.X509;
|
28 | 28 | using Org.BouncyCastle.Asn1.X509;
|
29 | 29 | using Org.BouncyCastle.X509.Store;
|
| 30 | +using Org.BouncyCastle.Utilities.Collections; |
30 | 31 |
|
31 | 32 | using MimeKit.Cryptography;
|
32 | 33 |
|
@@ -59,6 +60,9 @@ public SqliteCertificateDatabaseTests ()
|
59 | 60 | }
|
60 | 61 |
|
61 | 62 | ctx.Import (rsa.FileName, "no.secret");
|
| 63 | + |
| 64 | + foreach (var crl in SecureMimeTestsBase.ObsoleteCrls) |
| 65 | + ctx.Import (crl); |
62 | 66 | }
|
63 | 67 | }
|
64 | 68 |
|
@@ -124,7 +128,17 @@ public void TestAutoUpgradeVersion1 ()
|
124 | 128 | }
|
125 | 129 | }
|
126 | 130 |
|
127 |
| - static void AssertFindBy (Org.BouncyCastle.Utilities.Collections.ISelector<X509Certificate> selector, X509Certificate expected) |
| 131 | + [Test] |
| 132 | + public void TestEnumerateMatches () |
| 133 | + { |
| 134 | + using (var dbase = new SqliteCertificateDatabase ("sqlite.db", "no.secret")) { |
| 135 | + var certificates = ((IStore<X509Certificate>) dbase).EnumerateMatches (null).ToList (); |
| 136 | + |
| 137 | + Assert.That (certificates, Has.Count.EqualTo (6), "Did not find the expected # of certificate"); |
| 138 | + } |
| 139 | + } |
| 140 | + |
| 141 | + static void AssertFindBy (ISelector<X509Certificate> selector, X509Certificate expected) |
128 | 142 | {
|
129 | 143 | using (var dbase = new SqliteCertificateDatabase ("sqlite.db", "no.secret")) {
|
130 | 144 | // Verify that we can select the Root Certificate
|
@@ -186,5 +200,31 @@ public void TestFindBySubjectKeyIdentifier ()
|
186 | 200 |
|
187 | 201 | AssertFindBy (selector, chain[0]);
|
188 | 202 | }
|
| 203 | + |
| 204 | + [Test] |
| 205 | + public void TestFindPrivateKeys () |
| 206 | + { |
| 207 | + using (var dbase = new SqliteCertificateDatabase ("sqlite.db", "no.secret")) { |
| 208 | + var privateKeys = dbase.FindPrivateKeys (null).ToList (); |
| 209 | + |
| 210 | + Assert.That (privateKeys, Has.Count.EqualTo (1), "Did not find the expected # of private keys"); |
| 211 | + } |
| 212 | + } |
| 213 | + |
| 214 | + [Test] |
| 215 | + public void TestFindCrl () |
| 216 | + { |
| 217 | + using (var dbase = new SqliteCertificateDatabase ("sqlite.db", "no.secret")) { |
| 218 | + foreach (var crl in SecureMimeTestsBase.ObsoleteCrls) { |
| 219 | + var record = dbase.Find (crl, X509CrlRecordFields.Id | X509CrlRecordFields.IsDelta | X509CrlRecordFields.IssuerName | X509CrlRecordFields.ThisUpdate | X509CrlRecordFields.NextUpdate | X509CrlRecordFields.Crl); |
| 220 | + |
| 221 | + Assert.That (record, Is.Not.Null, $"Did not find the expected CRL for {crl.IssuerDN.ToString ()}"); |
| 222 | + Assert.That (record.IsDelta, Is.EqualTo (crl.IsDelta ()), $"IsDelta for {crl.IssuerDN.ToString ()}"); |
| 223 | + Assert.That (record.IssuerName, Is.EqualTo (crl.IssuerDN.ToString ()), $"IssuerName for {crl.IssuerDN.ToString ()}"); |
| 224 | + Assert.That (record.ThisUpdate, Is.EqualTo (crl.ThisUpdate), $"ThisUpdate for {crl.IssuerDN.ToString ()}"); |
| 225 | + Assert.That (record.NextUpdate, Is.EqualTo (crl.NextUpdate), $"NextUpdate for {crl.IssuerDN.ToString ()}"); |
| 226 | + } |
| 227 | + } |
| 228 | + } |
189 | 229 | }
|
190 | 230 | }
|
0 commit comments