diff options
author | Dominik Schürmann <dominik@dominikschuermann.de> | 2014-08-01 11:09:25 +0200 |
---|---|---|
committer | Dominik Schürmann <dominik@dominikschuermann.de> | 2014-08-01 11:09:25 +0200 |
commit | e10cbc54c606563b2d06f083bca17119ca585127 (patch) | |
tree | 23c71e67b1c4a381997bdb75de476f05d7dcec5f /OpenKeychain-Test/src/test/java/org/sufficientlysecure/keychain/support/KeyringTestingHelper.java | |
parent | bef3e621118d0e4d8fadedf0c9d67b6a9ff41883 (diff) | |
parent | acbf2a18617eea73924dd109e09189420d9876fe (diff) | |
download | open-keychain-e10cbc54c606563b2d06f083bca17119ca585127.tar.gz open-keychain-e10cbc54c606563b2d06f083bca17119ca585127.tar.bz2 open-keychain-e10cbc54c606563b2d06f083bca17119ca585127.zip |
Merge branch 'master' into yubikey
Conflicts:
.gitmodules
OpenKeychain/src/main/java/org/sufficientlysecure/keychain/helper/Preferences.java
OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/CanonicalizedSecretKey.java
OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/UncachedKeyRing.java
Diffstat (limited to 'OpenKeychain-Test/src/test/java/org/sufficientlysecure/keychain/support/KeyringTestingHelper.java')
-rw-r--r-- | OpenKeychain-Test/src/test/java/org/sufficientlysecure/keychain/support/KeyringTestingHelper.java | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/OpenKeychain-Test/src/test/java/org/sufficientlysecure/keychain/support/KeyringTestingHelper.java b/OpenKeychain-Test/src/test/java/org/sufficientlysecure/keychain/support/KeyringTestingHelper.java index 3fa668e6e..015e134ea 100644 --- a/OpenKeychain-Test/src/test/java/org/sufficientlysecure/keychain/support/KeyringTestingHelper.java +++ b/OpenKeychain-Test/src/test/java/org/sufficientlysecure/keychain/support/KeyringTestingHelper.java @@ -29,6 +29,7 @@ import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; +import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.Comparator; @@ -61,7 +62,7 @@ public class KeyringTestingHelper { boolean saveSuccess = saveKeyringResult.success(); // Now re-retrieve the saved key. Should not throw an exception. - providerHelper.getWrappedPublicKeyRing(masterKeyId); + providerHelper.getCanonicalizedPublicKeyRing(masterKeyId); // A different ID should still fail retrieveKeyAndExpectNotFound(providerHelper, masterKeyId - 1); @@ -331,13 +332,32 @@ public class KeyringTestingHelper { } + public static <E> E getNth(Iterator<E> it, int position) { + while(position-- > 0) { + it.next(); + } + return it.next(); + } + + public static long getSubkeyId(UncachedKeyRing ring, int position) { + return getNth(ring.getPublicKeys(), position).getKeyId(); + } + private void retrieveKeyAndExpectNotFound(ProviderHelper providerHelper, long masterKeyId) { try { - providerHelper.getWrappedPublicKeyRing(masterKeyId); + providerHelper.getCanonicalizedPublicKeyRing(masterKeyId); throw new AssertionError("Was expecting the previous call to fail!"); } catch (ProviderHelper.NotFoundException expectedException) { // good } } + public static <E> List<E> itToList(Iterator<E> it) { + List<E> result = new ArrayList<E>(); + while(it.hasNext()) { + result.add(it.next()); + } + return result; + } + } |