aboutsummaryrefslogtreecommitdiffstats
path: root/OpenKeychain-Test
diff options
context:
space:
mode:
authorVincent Breitmoser <valodim@mugenguild.com>2015-01-02 01:11:43 +0100
committerVincent Breitmoser <valodim@mugenguild.com>2015-01-02 01:11:43 +0100
commit704fc2dd45f20c7edc68b2930e2a73179d5fbdae (patch)
treedf934bafd3bf46af2e8187a1748c858dc89f1718 /OpenKeychain-Test
parent57e3266fa5dfeab605ba327c7daaccfd57b87d12 (diff)
downloadopen-keychain-704fc2dd45f20c7edc68b2930e2a73179d5fbdae.tar.gz
open-keychain-704fc2dd45f20c7edc68b2930e2a73179d5fbdae.tar.bz2
open-keychain-704fc2dd45f20c7edc68b2930e2a73179d5fbdae.zip
tests: for export, check that a token local cert actually exists before export
Diffstat (limited to 'OpenKeychain-Test')
-rw-r--r--OpenKeychain-Test/src/test/java/org/sufficientlysecure/keychain/operations/ExportTest.java32
1 files changed, 22 insertions, 10 deletions
diff --git a/OpenKeychain-Test/src/test/java/org/sufficientlysecure/keychain/operations/ExportTest.java b/OpenKeychain-Test/src/test/java/org/sufficientlysecure/keychain/operations/ExportTest.java
index 110fec2d3..8ac23b1ee 100644
--- a/OpenKeychain-Test/src/test/java/org/sufficientlysecure/keychain/operations/ExportTest.java
+++ b/OpenKeychain-Test/src/test/java/org/sufficientlysecure/keychain/operations/ExportTest.java
@@ -120,10 +120,13 @@ public class ExportTest {
}
@Test
- public void testExportAllPublic() throws Exception {
+ public void testExportAll() throws Exception {
ImportExportOperation op = new ImportExportOperation(Robolectric.application,
new ProviderHelper(Robolectric.application), null);
+ // make sure there is a local cert (so the later checks that there are none are meaningful)
+ Assert.assertTrue("second keyring has local certification", checkForLocal(mStaticRing2));
+
ByteArrayOutputStream out = new ByteArrayOutputStream();
ExportResult result = op.exportKeyRings(new OperationLog(), null, false, out);
@@ -147,7 +150,8 @@ public class ExportTest {
Assert.assertEquals("first exported key has correct masterkeyid",
masterKeyId1, ring.getMasterKeyId());
Assert.assertFalse("first exported key must not be secret", ring.isSecret());
- checkForLocal(ring);
+ Assert.assertFalse("there must be no local signatures in an exported keyring",
+ checkForLocal(ring));
}
{
@@ -156,7 +160,8 @@ public class ExportTest {
Assert.assertEquals("second exported key has correct masterkeyid",
masterKeyId2, ring.getMasterKeyId());
Assert.assertFalse("second exported key must not be secret", ring.isSecret());
- checkForLocal(ring);
+ Assert.assertFalse("there must be no local signatures in an exported keyring",
+ checkForLocal(ring));
}
out = new ByteArrayOutputStream();
@@ -172,14 +177,16 @@ public class ExportTest {
Assert.assertEquals("1/4 exported key has correct masterkeyid",
masterKeyId1, ring.getMasterKeyId());
Assert.assertFalse("1/4 exported key must not be public", ring.isSecret());
- checkForLocal(ring);
+ Assert.assertFalse("there must be no local signatures in an exported keyring",
+ checkForLocal(ring));
Assert.assertTrue("export must have four keys (2/4)", unc.hasNext());
ring = unc.next();
Assert.assertEquals("2/4 exported key has correct masterkeyid",
masterKeyId1, ring.getMasterKeyId());
Assert.assertTrue("2/4 exported key must be public", ring.isSecret());
- checkForLocal(ring);
+ Assert.assertFalse("there must be no local signatures in an exported keyring",
+ checkForLocal(ring));
}
{
@@ -188,24 +195,29 @@ public class ExportTest {
Assert.assertEquals("3/4 exported key has correct masterkeyid",
masterKeyId2, ring.getMasterKeyId());
Assert.assertFalse("3/4 exported key must not be public", ring.isSecret());
- checkForLocal(ring);
+ Assert.assertFalse("there must be no local signatures in an exported keyring",
+ checkForLocal(ring));
Assert.assertTrue("export must have four keys (4/4)", unc.hasNext());
ring = unc.next();
Assert.assertEquals("4/4 exported key has correct masterkeyid",
masterKeyId2, ring.getMasterKeyId());
Assert.assertTrue("4/4 exported key must be public", ring.isSecret());
- checkForLocal(ring);
+ Assert.assertFalse("there must be no local signatures in an exported keyring",
+ checkForLocal(ring));
}
}
- private void checkForLocal(UncachedKeyRing ring) {
+ /** This function checks whether or not there are any local signatures in a keyring. */
+ private boolean checkForLocal(UncachedKeyRing ring) {
Iterator<WrappedSignature> sigs = ring.getPublicKey().getSignatures();
while (sigs.hasNext()) {
- Assert.assertFalse("there must be no local signatures in an exported keyring",
- sigs.next().isLocal());
+ if (sigs.next().isLocal()) {
+ return true;
+ }
}
+ return false;
}
}