aboutsummaryrefslogtreecommitdiffstats
path: root/OpenKeychain-Test
diff options
context:
space:
mode:
authorVincent Breitmoser <valodim@mugenguild.com>2014-09-03 03:05:18 +0200
committerVincent Breitmoser <valodim@mugenguild.com>2014-09-03 03:05:18 +0200
commit598a5e74396eb843817848a9a3631784dc9d8654 (patch)
treebb27f2f09ffbdaadc214c821dd8c63c8e47e7176 /OpenKeychain-Test
parent6e219d245f32481f5e90012e8aefd70e3ff1000b (diff)
downloadopen-keychain-598a5e74396eb843817848a9a3631784dc9d8654.tar.gz
open-keychain-598a5e74396eb843817848a9a3631784dc9d8654.tar.bz2
open-keychain-598a5e74396eb843817848a9a3631784dc9d8654.zip
implement test case for mailvelope keyring with no key flags
Diffstat (limited to 'OpenKeychain-Test')
-rw-r--r--OpenKeychain-Test/src/test/java/org/sufficientlysecure/keychain/provider/ProviderHelperSaveTest.java25
1 files changed, 25 insertions, 0 deletions
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 =