mirror of
https://github.com/moparisthebest/open-keychain
synced 2025-02-25 07:51:48 -05:00
test: more tests for different revocation cases
This commit is contained in:
parent
22b0e5a1fc
commit
ed0aec57bf
@ -334,6 +334,17 @@ public class PgpKeyOperationTest {
|
|||||||
Assert.assertEquals("added key must have expected bitsize",
|
Assert.assertEquals("added key must have expected bitsize",
|
||||||
bits, newKey.getBitStrength());
|
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
|
{ // a past expiry should fail
|
||||||
parcel.reset();
|
parcel.reset();
|
||||||
parcel.mAddSubKeys.add(new SubkeyAdd(algorithm.rsa, 1024, KeyFlags.SIGN_DATA,
|
parcel.mAddSubKeys.add(new SubkeyAdd(algorithm.rsa, 1024, KeyFlags.SIGN_DATA,
|
||||||
@ -343,7 +354,7 @@ public class PgpKeyOperationTest {
|
|||||||
OperationResultParcel.OperationLog log = new OperationResultParcel.OperationLog();
|
OperationResultParcel.OperationLog log = new OperationResultParcel.OperationLog();
|
||||||
modified = op.modifySecretKeyRing(secretRing, parcel, "swag", log, 0);
|
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;
|
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
|
{ // revoked second subkey
|
||||||
|
|
||||||
|
parcel.reset();
|
||||||
parcel.mRevokeSubKeys.add(keyId);
|
parcel.mRevokeSubKeys.add(keyId);
|
||||||
|
|
||||||
modified = applyModificationWithChecks(parcel, ring, onlyA, onlyB);
|
modified = applyModificationWithChecks(parcel, ring, onlyA, onlyB);
|
||||||
@ -536,6 +561,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
|
{ // re-add second user id
|
||||||
|
|
||||||
parcel.reset();
|
parcel.reset();
|
||||||
@ -643,6 +681,8 @@ public class PgpKeyOperationTest {
|
|||||||
Assert.assertNull("changing primary user id to a non-existent one should fail", modified);
|
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
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user