From 598a5e74396eb843817848a9a3631784dc9d8654 Mon Sep 17 00:00:00 2001 From: Vincent Breitmoser Date: Wed, 3 Sep 2014 03:05:18 +0200 Subject: implement test case for mailvelope keyring with no key flags --- .../keychain/provider/ProviderHelperSaveTest.java | 25 ++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'OpenKeychain-Test/src/test/java') diff --git a/OpenKeychain-Test/src/test/java/org/sufficientlysecure/keychain/provider/ProviderHelperSaveTest.java b/OpenKeychain-Test/src/test/java/org/sufficientlysecure/keychain/provider/ProviderHelperSaveTest.java index 44918c5fb..ad06b29a6 100644 --- a/OpenKeychain-Test/src/test/java/org/sufficientlysecure/keychain/provider/ProviderHelperSaveTest.java +++ b/OpenKeychain-Test/src/test/java/org/sufficientlysecure/keychain/provider/ProviderHelperSaveTest.java @@ -25,6 +25,7 @@ import org.junit.runner.RunWith; import org.robolectric.Robolectric; import org.robolectric.RobolectricTestRunner; import org.robolectric.shadows.ShadowLog; +import org.sufficientlysecure.keychain.pgp.CanonicalizedPublicKeyRing; import org.sufficientlysecure.keychain.pgp.CanonicalizedSecretKey; import org.sufficientlysecure.keychain.pgp.CanonicalizedSecretKey.SecretKeyType; import org.sufficientlysecure.keychain.pgp.CanonicalizedSecretKeyRing; @@ -75,6 +76,30 @@ public class ProviderHelperSaveTest { } + @Test public void testImportNoFlagKey() throws Exception { + + UncachedKeyRing pub = + readRingFromResource("/test-keys/mailvelope_07_no_key_flags.asc"); + long keyId = pub.getMasterKeyId(); + Assert.assertNull("key flags should be null", pub.getPublicKey().getKeyUsage()); + + mProviderHelper.savePublicKeyRing(pub); + + CachedPublicKeyRing cachedRing = mProviderHelper.getCachedPublicKeyRing(keyId); + CanonicalizedPublicKeyRing pubRing = mProviderHelper.getCanonicalizedPublicKeyRing(keyId); + + Assert.assertEquals("master key should be signing key", pubRing.getSignId(), keyId); + Assert.assertEquals("master key should be signing key (cached)", cachedRing.getSignId(), keyId); + Assert.assertEquals("master key should be encryption key", pubRing.getEncryptId(), keyId); + Assert.assertEquals("master key should be signing key (cached)", cachedRing.getEncryptId(), keyId); + + Assert.assertNull("canonicalized key flags should be null", pubRing.getPublicKey().getKeyUsage()); + Assert.assertTrue("master key should be able to certify", pubRing.getPublicKey().canCertify()); + Assert.assertTrue("master key should be able to sign", pubRing.getPublicKey().canSign()); + Assert.assertTrue("master key should be able to encrypt", pubRing.getPublicKey().canEncrypt()); + + } + @Test public void testImportDivertToCard() throws Exception { UncachedKeyRing pub = -- cgit v1.2.3