aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVincent Breitmoser <valodim@mugenguild.com>2014-07-12 02:02:03 +0200
committerVincent Breitmoser <valodim@mugenguild.com>2014-07-12 02:02:03 +0200
commited0aec57bf4fe67768873401937462ffe6b2a130 (patch)
treeb9c66969d7d182a7d7ce2069c19a73dca87a5884
parent22b0e5a1fcf36e7d0ea4a81eda23ac1f0ae1fe7f (diff)
downloadopen-keychain-ed0aec57bf4fe67768873401937462ffe6b2a130.tar.gz
open-keychain-ed0aec57bf4fe67768873401937462ffe6b2a130.tar.bz2
open-keychain-ed0aec57bf4fe67768873401937462ffe6b2a130.zip
test: more tests for different revocation cases
-rw-r--r--OpenKeychain-Test/src/test/java/org/sufficientlysecure/keychain/tests/PgpKeyOperationTest.java42
1 files changed, 41 insertions, 1 deletions
diff --git a/OpenKeychain-Test/src/test/java/org/sufficientlysecure/keychain/tests/PgpKeyOperationTest.java b/OpenKeychain-Test/src/test/java/org/sufficientlysecure/keychain/tests/PgpKeyOperationTest.java
index 7282af0e5..19193523f 100644
--- a/OpenKeychain-Test/src/test/java/org/sufficientlysecure/keychain/tests/PgpKeyOperationTest.java
+++ b/OpenKeychain-Test/src/test/java/org/sufficientlysecure/keychain/tests/PgpKeyOperationTest.java
@@ -334,6 +334,17 @@ public class PgpKeyOperationTest {
Assert.assertEquals("added key must have expected bitsize",
bits, newKey.getBitStrength());
+ { // bad keysize should fail
+ parcel.reset();
+ parcel.mAddSubKeys.add(new SubkeyAdd(algorithm.rsa, 77, KeyFlags.SIGN_DATA, null));
+
+ WrappedSecretKeyRing secretRing = new WrappedSecretKeyRing(ring.getEncoded(), false, 0);
+ OperationResultParcel.OperationLog log = new OperationResultParcel.OperationLog();
+ modified = op.modifySecretKeyRing(secretRing, parcel, "swag", log, 0);
+
+ Assert.assertNull("creating a subkey with keysize < 512 should fail", modified);
+ }
+
{ // a past expiry should fail
parcel.reset();
parcel.mAddSubKeys.add(new SubkeyAdd(algorithm.rsa, 1024, KeyFlags.SIGN_DATA,
@@ -343,7 +354,7 @@ public class PgpKeyOperationTest {
OperationResultParcel.OperationLog log = new OperationResultParcel.OperationLog();
modified = op.modifySecretKeyRing(secretRing, parcel, "swag", log, 0);
- Assert.assertNull("setting subkey expiry to a past date should fail", modified);
+ Assert.assertNull("creating subkey with past expiry date should fail", modified);
}
}
@@ -447,8 +458,22 @@ public class PgpKeyOperationTest {
UncachedKeyRing modified;
+ {
+
+ parcel.reset();
+ parcel.mRevokeSubKeys.add(123L);
+
+ WrappedSecretKeyRing secretRing = new WrappedSecretKeyRing(ring.getEncoded(), false, 0);
+ OperationResultParcel.OperationLog log = new OperationResultParcel.OperationLog();
+ UncachedKeyRing otherModified = op.modifySecretKeyRing(secretRing, parcel, "swag", log, 0);
+
+ Assert.assertNull("revoking a nonexistent subkey should fail", otherModified);
+
+ }
+
{ // revoked second subkey
+ parcel.reset();
parcel.mRevokeSubKeys.add(keyId);
modified = applyModificationWithChecks(parcel, ring, onlyA, onlyB);
@@ -539,6 +564,19 @@ public class PgpKeyOperationTest {
{ // re-add second user id
parcel.reset();
+ parcel.mChangePrimaryUserId = uid;
+
+ WrappedSecretKeyRing secretRing = new WrappedSecretKeyRing(modified.getEncoded(), false, 0);
+ OperationResultParcel.OperationLog log = new OperationResultParcel.OperationLog();
+ UncachedKeyRing otherModified = op.modifySecretKeyRing(secretRing, parcel, "swag", log, 0);
+
+ Assert.assertNull("setting primary user id to a revoked user id should fail", otherModified);
+
+ }
+
+ { // re-add second user id
+
+ parcel.reset();
parcel.mAddUserIds.add(uid);
applyModificationWithChecks(parcel, modified, onlyA, onlyB);
@@ -643,6 +681,8 @@ public class PgpKeyOperationTest {
Assert.assertNull("changing primary user id to a non-existent one should fail", modified);
}
+ // check for revoked primary user id already done in revoke test
+
}