aboutsummaryrefslogtreecommitdiffstats
path: root/OpenKeychain-Test
diff options
context:
space:
mode:
authorVincent Breitmoser <valodim@mugenguild.com>2014-08-16 06:49:46 +0200
committerVincent Breitmoser <valodim@mugenguild.com>2014-08-16 06:53:50 +0200
commit6e84c728011cebe44c3b2ef6c6cacee64098c16a (patch)
treecf32d735e9941def0f0d9c384a73afa8ded77a92 /OpenKeychain-Test
parentde0d95432e40b9ed436c3509364ba49d2e487723 (diff)
downloadopen-keychain-6e84c728011cebe44c3b2ef6c6cacee64098c16a.tar.gz
open-keychain-6e84c728011cebe44c3b2ef6c6cacee64098c16a.tar.bz2
open-keychain-6e84c728011cebe44c3b2ef6c6cacee64098c16a.zip
tests: more expected error types
Diffstat (limited to 'OpenKeychain-Test')
-rw-r--r--OpenKeychain-Test/src/test/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperationTest.java42
1 files changed, 35 insertions, 7 deletions
diff --git a/OpenKeychain-Test/src/test/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperationTest.java b/OpenKeychain-Test/src/test/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperationTest.java
index 88cf260fb..10a42b80f 100644
--- a/OpenKeychain-Test/src/test/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperationTest.java
+++ b/OpenKeychain-Test/src/test/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperationTest.java
@@ -118,7 +118,8 @@ public class PgpKeyOperationTest {
parcel.mAddUserIds.add("shy");
parcel.mNewPassphrase = passphrase;
- assertFailure("creating ring with < 512 bytes keysize should fail", parcel);
+ assertFailure("creating ring with < 512 bytes keysize should fail", parcel,
+ LogType.MSG_CR_ERROR_KEYSIZE_512);
}
{
@@ -128,7 +129,19 @@ public class PgpKeyOperationTest {
parcel.mAddUserIds.add("shy");
parcel.mNewPassphrase = passphrase;
- assertFailure("creating ring with ElGamal master key should fail", parcel);
+ assertFailure("creating ring with ElGamal master key should fail", parcel,
+ LogType.MSG_CR_ERROR_MASTER_ELGAMAL);
+ }
+
+ {
+ parcel.reset();
+ parcel.mAddSubKeys.add(new SaveKeyringParcel.SubkeyAdd(
+ PublicKeyAlgorithmTags.RSA_GENERAL, 1024, KeyFlags.CERTIFY_OTHER, null));
+ parcel.mAddUserIds.add("lotus");
+ parcel.mNewPassphrase = passphrase;
+
+ assertFailure("creating master key with null expiry should fail", parcel,
+ LogType.MSG_CR_ERROR_NULL_EXPIRY);
}
{
@@ -138,7 +151,8 @@ public class PgpKeyOperationTest {
parcel.mAddUserIds.add("shy");
parcel.mNewPassphrase = passphrase;
- assertFailure("creating ring with bad algorithm choice should fail", parcel);
+ assertFailure("creating ring with bad algorithm choice should fail", parcel,
+ LogType.MSG_CR_ERROR_UNKNOWN_ALGO);
}
{
@@ -148,7 +162,8 @@ public class PgpKeyOperationTest {
parcel.mAddUserIds.add("shy");
parcel.mNewPassphrase = passphrase;
- assertFailure("creating ring with non-certifying master key should fail", parcel);
+ assertFailure("creating ring with non-certifying master key should fail", parcel,
+ LogType.MSG_CR_ERROR_NO_CERTIFY);
}
{
@@ -157,7 +172,8 @@ public class PgpKeyOperationTest {
PublicKeyAlgorithmTags.RSA_GENERAL, 1024, KeyFlags.CERTIFY_OTHER, 0L));
parcel.mNewPassphrase = passphrase;
- assertFailure("creating ring without user ids should fail", parcel);
+ assertFailure("creating ring without user ids should fail", parcel,
+ LogType.MSG_CR_ERROR_NO_USER_ID);
}
{
@@ -165,7 +181,8 @@ public class PgpKeyOperationTest {
parcel.mAddUserIds.add("shy");
parcel.mNewPassphrase = passphrase;
- assertFailure("creating ring without subkeys should fail", parcel);
+ assertFailure("creating ring with no master key should fail", parcel,
+ LogType.MSG_CR_ERROR_NO_MASTER);
}
}
@@ -337,6 +354,15 @@ public class PgpKeyOperationTest {
}
+ {
+ parcel.reset();
+ parcel.mAddSubKeys.add(new SaveKeyringParcel.SubkeyAdd(
+ PublicKeyAlgorithmTags.RSA_GENERAL, 1024, KeyFlags.SIGN_DATA, null));
+
+ assertModifyFailure("creating master key with null expiry should fail", ring, parcel,
+ LogType.MSG_MF_ERROR_NULL_EXPIRY);
+ }
+
{ // a past expiry should fail
parcel.reset();
parcel.mAddSubKeys.add(new SubkeyAdd(PublicKeyAlgorithmTags.RSA_GENERAL, 1024, KeyFlags.SIGN_DATA,
@@ -879,12 +905,14 @@ public class PgpKeyOperationTest {
Assert.assertEquals(java.util.Arrays.toString(expected), java.util.Arrays.toString(actual));
}
- private void assertFailure(String reason, SaveKeyringParcel parcel) {
+ private void assertFailure(String reason, SaveKeyringParcel parcel, LogType expected) {
EditKeyResult result = op.createSecretKeyRing(parcel);
Assert.assertFalse(reason, result.success());
Assert.assertNull(reason, result.getRing());
+ Assert.assertTrue(reason + "(with correct error)",
+ result.getLog().containsType(expected));
}