diff options
author | David Hook <dgh@bouncycastle.org> | 2021-05-23 13:28:45 +1000 |
---|---|---|
committer | David Hook <dgh@bouncycastle.org> | 2021-05-23 13:28:45 +1000 |
commit | f7d837b990cf19d3b324c7238eace45eb8c5d6bf (patch) | |
tree | c1b71240a688b4dcd3c237c4d2add9f091b33a97 /crypto/test/src | |
parent | github #296 TSP fix (diff) | |
download | BouncyCastle.NET-ed25519-f7d837b990cf19d3b324c7238eace45eb8c5d6bf.tar.xz |
github #283 added extra features fields, corrected parsing for new draft
Diffstat (limited to 'crypto/test/src')
-rw-r--r-- | crypto/test/src/openpgp/test/PgpFeaturesTest.cs | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/crypto/test/src/openpgp/test/PgpFeaturesTest.cs b/crypto/test/src/openpgp/test/PgpFeaturesTest.cs new file mode 100644 index 000000000..2969d8982 --- /dev/null +++ b/crypto/test/src/openpgp/test/PgpFeaturesTest.cs @@ -0,0 +1,55 @@ + +using NUnit.Core; +using NUnit.Framework; +using Org.BouncyCastle.Bcpg.Sig; + +namespace Org.BouncyCastle.Bcpg.OpenPgp.Tests +{ + [TestFixture] + public class PgpFeaturesTest + { + [Test] + public void PerformTest() + { + Features f = new Features(true, Features.FEATURE_MODIFICATION_DETECTION); + Assert.IsTrue(f.SupportsFeature(Features.FEATURE_MODIFICATION_DETECTION)); + Assert.IsTrue(f.SupportsModificationDetection); + Assert.IsTrue(!f.SupportsFeature(Features.FEATURE_VERSION_5_PUBLIC_KEY)); + + f = new Features(true, Features.FEATURE_VERSION_5_PUBLIC_KEY); + Assert.IsTrue(!f.SupportsModificationDetection); + Assert.IsTrue(f.SupportsFeature(Features.FEATURE_VERSION_5_PUBLIC_KEY)); + + f = new Features(true, Features.FEATURE_AEAD_ENCRYPTED_DATA); + Assert.IsTrue(f.SupportsFeature(Features.FEATURE_AEAD_ENCRYPTED_DATA)); + Assert.IsTrue(!f.SupportsModificationDetection); + Assert.IsTrue(!f.SupportsFeature(Features.FEATURE_VERSION_5_PUBLIC_KEY)); + + f = new Features(true, Features.FEATURE_AEAD_ENCRYPTED_DATA | Features.FEATURE_MODIFICATION_DETECTION); + Assert.IsTrue(f.SupportsFeature(Features.FEATURE_AEAD_ENCRYPTED_DATA)); + Assert.IsTrue(f.SupportsModificationDetection); + Assert.IsTrue(!f.SupportsFeature(Features.FEATURE_VERSION_5_PUBLIC_KEY)); + + f = new Features(true, Features.FEATURE_VERSION_5_PUBLIC_KEY | Features.FEATURE_MODIFICATION_DETECTION); + Assert.IsTrue(!f.SupportsFeature(Features.FEATURE_AEAD_ENCRYPTED_DATA)); + Assert.IsTrue(f.SupportsModificationDetection); + Assert.IsTrue(f.SupportsFeature(Features.FEATURE_VERSION_5_PUBLIC_KEY)); + } + + public static void Main(string[] args) + { + Suite.Run(new NullListener(), NUnit.Core.TestFilter.Empty); + } + + [Suite] + public static TestSuite Suite + { + get + { + TestSuite suite = new TestSuite("PGP Features Tests"); + suite.Add(new PgpFeaturesTest()); + return suite; + } + } + } +} |