diff options
author | Vincent Breitmoser <valodim@mugenguild.com> | 2015-01-01 21:13:07 +0100 |
---|---|---|
committer | Vincent Breitmoser <valodim@mugenguild.com> | 2015-01-01 21:13:07 +0100 |
commit | 1c1ae769ef78a9bd3c95f97b95215616ee9b15db (patch) | |
tree | 5ed49a4b266bc66afec913fa25939350ce180b75 /OpenKeychain-Test/src/test/java/org/sufficientlysecure/keychain | |
parent | 2d38079574381ddafc47bd1f31dc6e35a2d67b6a (diff) | |
download | open-keychain-1c1ae769ef78a9bd3c95f97b95215616ee9b15db.tar.gz open-keychain-1c1ae769ef78a9bd3c95f97b95215616ee9b15db.tar.bz2 open-keychain-1c1ae769ef78a9bd3c95f97b95215616ee9b15db.zip |
small improvements regarding pin tests and logging
Diffstat (limited to 'OpenKeychain-Test/src/test/java/org/sufficientlysecure/keychain')
-rw-r--r-- | OpenKeychain-Test/src/test/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperationTest.java | 28 |
1 files changed, 23 insertions, 5 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 6b53a93ce..103e2dc88 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 @@ -916,7 +916,7 @@ public class PgpKeyOperationTest { parcel.mNewUnlock = new ChangeUnlockParcel(""); // note that canonicalization here necessarily strips the empty notation packet UncachedKeyRing modified = applyModificationWithChecks(parcel, ring, onlyA, onlyB, - passphrase, true, false); + passphrase); Assert.assertEquals("exactly three packets should have been modified (the secret keys)", 3, onlyB.size()); @@ -929,7 +929,7 @@ public class PgpKeyOperationTest { // modify keyring, change to non-empty passphrase String otherPassphrase = TestingUtils.genPassphrase(true); parcel.mNewUnlock = new ChangeUnlockParcel(otherPassphrase); - modified = applyModificationWithChecks(parcel, modified, onlyA, onlyB, "", true, false); + modified = applyModificationWithChecks(parcel, modified, onlyA, onlyB, ""); Assert.assertEquals("exactly three packets should have been modified (the secret keys)", 3, onlyB.size()); @@ -989,11 +989,15 @@ public class PgpKeyOperationTest { @Test public void testUnlockPin() throws Exception { + String pin = "5235125"; + // change passphrase to a pin type - parcel.mNewUnlock = new ChangeUnlockParcel(null, "52351"); + parcel.mNewUnlock = new ChangeUnlockParcel(null, pin); UncachedKeyRing modified = applyModificationWithChecks(parcel, ring, onlyA, onlyB); - Assert.assertEquals("exactly four packets should have been modified (the secret keys + notation packet)", + Assert.assertEquals("exactly three packets should have been added (the secret keys + notation packet)", + 3, onlyA.size()); + Assert.assertEquals("exactly four packets should have been added (the secret keys + notation packet)", 4, onlyB.size()); RawPacket dkSig = onlyB.get(1); @@ -1001,11 +1005,25 @@ public class PgpKeyOperationTest { PacketTags.SIGNATURE, dkSig.tag); // check that notation data contains pin - CanonicalizedSecretKeyRing secretRing = new CanonicalizedSecretKeyRing(modified.getEncoded(), false, 0); + CanonicalizedSecretKeyRing secretRing = new CanonicalizedSecretKeyRing( + modified.getEncoded(), false, 0); Assert.assertEquals("secret key type should be 'pin' after this", SecretKeyType.PIN, secretRing.getSecretKey().getSecretKeyType()); + // need to sleep for a sec, so the timestamp changes for notation data + Thread.sleep(1000); + + { + parcel.mNewUnlock = new ChangeUnlockParcel("phrayse", null); + applyModificationWithChecks(parcel, modified, onlyA, onlyB, pin, true, false); + + Assert.assertEquals("exactly four packets should have been removed (the secret keys + notation packet)", + 4, onlyA.size()); + Assert.assertEquals("exactly three packets should have been added (no more notation packet)", + 3, onlyB.size()); + } + } private static UncachedKeyRing applyModificationWithChecks(SaveKeyringParcel parcel, |