From 718acbf954b1318c6a90ba0f9c79e63f398fb498 Mon Sep 17 00:00:00 2001 From: Vincent Breitmoser Date: Wed, 9 Jul 2014 15:53:18 +0200 Subject: put unit tests into external module (CAVEAT) this requires a more up to date version of gradle-android-test-plugin than is currently in the repositories. it must be added to the local maven repo using ./install-custom-gradle-test-plugin.sh before compiling. --- .gitmodules | 4 +- .travis.yml | 1 + OpenKeychain-Test/build.gradle | 80 ++++++++++++++++++ .../keychain/tests/PgpDecryptVerifyTest.java | 36 ++++++++ .../keychain/tests/ProviderHelperKeyringTest.java | 84 +++++++++++++++++++ .../keychain/tests/UncachedKeyringTest.java | 91 +++++++++++++++++++++ .../src/test/resources/extern/OpenPGP-Haskell | 1 + .../src/test/resources/public-key-for-sample.blob | Bin 0 -> 35198 bytes .../src/test/resources/sample-altered.txt | 26 ++++++ OpenKeychain-Test/src/test/resources/sample.txt | 26 ++++++ OpenKeychain/build.gradle | 7 -- .../src/test/java/tests/PgpDecryptVerifyTest.java | 36 -------- .../test/java/tests/ProviderHelperKeyringTest.java | 86 ------------------- .../src/test/java/tests/UncachedKeyringTest.java | 51 ------------ .../src/test/resources/extern/OpenPGP-Haskell | 1 - .../src/test/resources/public-key-for-sample.blob | Bin 35198 -> 0 bytes OpenKeychain/src/test/resources/sample-altered.txt | 26 ------ OpenKeychain/src/test/resources/sample.txt | 26 ------ build.gradle | 4 + install-custom-gradle-test-plugin.sh | 15 ++++ settings.gradle | 1 + 21 files changed, 367 insertions(+), 235 deletions(-) create mode 100644 OpenKeychain-Test/build.gradle create mode 100644 OpenKeychain-Test/src/test/java/org/sufficientlysecure/keychain/tests/PgpDecryptVerifyTest.java create mode 100644 OpenKeychain-Test/src/test/java/org/sufficientlysecure/keychain/tests/ProviderHelperKeyringTest.java create mode 100644 OpenKeychain-Test/src/test/java/org/sufficientlysecure/keychain/tests/UncachedKeyringTest.java create mode 160000 OpenKeychain-Test/src/test/resources/extern/OpenPGP-Haskell create mode 100644 OpenKeychain-Test/src/test/resources/public-key-for-sample.blob create mode 100644 OpenKeychain-Test/src/test/resources/sample-altered.txt create mode 100644 OpenKeychain-Test/src/test/resources/sample.txt delete mode 100644 OpenKeychain/src/test/java/tests/PgpDecryptVerifyTest.java delete mode 100644 OpenKeychain/src/test/java/tests/ProviderHelperKeyringTest.java delete mode 100644 OpenKeychain/src/test/java/tests/UncachedKeyringTest.java delete mode 160000 OpenKeychain/src/test/resources/extern/OpenPGP-Haskell delete mode 100644 OpenKeychain/src/test/resources/public-key-for-sample.blob delete mode 100644 OpenKeychain/src/test/resources/sample-altered.txt delete mode 100644 OpenKeychain/src/test/resources/sample.txt create mode 100755 install-custom-gradle-test-plugin.sh diff --git a/.gitmodules b/.gitmodules index b7b0e1173..956362d4b 100644 --- a/.gitmodules +++ b/.gitmodules @@ -31,6 +31,6 @@ [submodule "extern/minidns"] path = extern/minidns url = https://github.com/open-keychain/minidns.git -[submodule "OpenKeychain/src/test/resources/extern/OpenPGP-Haskell"] - path = OpenKeychain/src/test/resources/extern/OpenPGP-Haskell +[submodule "OpenKeychain-Test/src/test/resources/extern/OpenPGP-Haskell"] + path = OpenKeychain-Test/src/test/resources/extern/OpenPGP-Haskell url = https://github.com/singpolyma/OpenPGP-Haskell.git diff --git a/.travis.yml b/.travis.yml index 5da831e61..2e86699f3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,6 +12,7 @@ before_install: # Install required Android components. #- echo "y" | android update sdk -a --filter build-tools-19.1.0,android-19,platform-tools,extra-android-support,extra-android-m2repository --no-ui --force - ( sleep 5 && while [ 1 ]; do sleep 1; echo y; done ) | android update sdk --no-ui --all --force --filter build-tools-19.1.0,android-19,platform-tools,extra-android-support,extra-android-m2repository + - ./install-custom-gradle-test-plugin.sh install: echo "Installation done" script: gradle assemble -S -q diff --git a/OpenKeychain-Test/build.gradle b/OpenKeychain-Test/build.gradle new file mode 100644 index 000000000..d795ace3d --- /dev/null +++ b/OpenKeychain-Test/build.gradle @@ -0,0 +1,80 @@ +apply plugin: 'java' +apply plugin: 'android-test' + +dependencies { + testCompile 'junit:junit:4.11' + testCompile 'com.google.android:android:4.1.1.4' + testCompile('com.squareup:fest-android:1.0.+') { exclude module: 'support-v4' } + testCompile ('org.robolectric:robolectric:2.3') { + exclude module: 'classworlds' + exclude module: 'maven-artifact' + exclude module: 'maven-artifact-manager' + exclude module: 'maven-error-diagnostics' + exclude module: 'maven-model' + exclude module: 'maven-plugin-registry' + exclude module: 'maven-profile' + exclude module: 'maven-project' + exclude module: 'maven-settings' + exclude module: 'nekohtml' + exclude module: 'plexus-container-default' + exclude module: 'plexus-interpolation' + exclude module: 'plexus-utils' + exclude module: 'support-v4' // crazy but my android studio don't like this dependency and to fix it remove .idea and re import project + exclude module: 'wagon-file' + exclude module: 'wagon-http-lightweight' + exclude module: 'wagon-http-shared' + exclude module: 'wagon-provider-api' + } +} + +android { + projectUnderTest ':OpenKeychain' +} + +// new workaround to force add custom output dirs for android studio +task addTest { + def file = file(project.name + ".iml") + doLast { + try { + def parsedXml = (new XmlParser()).parse(file) + def node = parsedXml.component[1] + def outputNode = parsedXml.component[1].output[0] + def outputTestNode = parsedXml.component[1].'output-test'[0] + def rewrite = false + + new Node(node, 'sourceFolder', ['url': 'file://$MODULE_DIR$/' + "${it}", 'isTestSource': "true"]) + + if(outputNode == null) { + new Node(node, 'output', ['url': 'file://$MODULE_DIR$/build/resources/testDebug']) + } else { + if(outputNode.attributes['url'] != 'file://$MODULE_DIR$/build/resources/testDebug') { + outputNode.attributes = ['url': 'file://$MODULE_DIR$/build/resources/testDebug'] + rewrite = true + } + } + + if(outputTestNode == null) { + new Node(node, 'output-test', ['url': 'file://$MODULE_DIR$/build/test-classes/debug']) + } else { + if(outputTestNode.attributes['url'] != 'file://$MODULE_DIR$/build/test-classes/debug') { + outputTestNode.attributes = ['url': 'file://$MODULE_DIR$/build/test-classes/debug'] + rewrite = true + } + } + + if(rewrite) { + def writer = new StringWriter() + new XmlNodePrinter(new PrintWriter(writer)).print(parsedXml) + file.text = writer.toString() + } + } catch (FileNotFoundException e) { + // iml not found, common on command line only builds + } + + } +} + +// always do the addtest on prebuild +gradle.projectsEvaluated { + testDebugClasses.dependsOn(addTest) +} diff --git a/OpenKeychain-Test/src/test/java/org/sufficientlysecure/keychain/tests/PgpDecryptVerifyTest.java b/OpenKeychain-Test/src/test/java/org/sufficientlysecure/keychain/tests/PgpDecryptVerifyTest.java new file mode 100644 index 000000000..bc78f540c --- /dev/null +++ b/OpenKeychain-Test/src/test/java/org/sufficientlysecure/keychain/tests/PgpDecryptVerifyTest.java @@ -0,0 +1,36 @@ +package org.sufficientlysecure.keychain.tests; + +import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.robolectric.*; +import org.openintents.openpgp.OpenPgpSignatureResult; +import org.sufficientlysecure.keychain.testsupport.PgpVerifyTestingHelper; + +@RunWith(RobolectricTestRunner.class) +@org.robolectric.annotation.Config(emulateSdk = 18) // Robolectric doesn't yet support 19 +public class PgpDecryptVerifyTest { + + @Test + public void testVerifySuccess() throws Exception { + + String testFileName = "/sample.txt"; + int expectedSignatureResult = OpenPgpSignatureResult.SIGNATURE_SUCCESS_UNCERTIFIED; + + int status = new PgpVerifyTestingHelper(Robolectric.application).doTestFile(testFileName); + + Assert.assertEquals(expectedSignatureResult, status); + } + + @Test + public void testVerifyFailure() throws Exception { + + String testFileName = "/sample-altered.txt"; + int expectedSignatureResult = OpenPgpSignatureResult.SIGNATURE_ERROR; + + int status = new PgpVerifyTestingHelper(Robolectric.application).doTestFile(testFileName); + + Assert.assertEquals(expectedSignatureResult, status); + } + +} diff --git a/OpenKeychain-Test/src/test/java/org/sufficientlysecure/keychain/tests/ProviderHelperKeyringTest.java b/OpenKeychain-Test/src/test/java/org/sufficientlysecure/keychain/tests/ProviderHelperKeyringTest.java new file mode 100644 index 000000000..c0e8df714 --- /dev/null +++ b/OpenKeychain-Test/src/test/java/org/sufficientlysecure/keychain/tests/ProviderHelperKeyringTest.java @@ -0,0 +1,84 @@ +package org.sufficientlysecure.keychain.tests; + +import java.util.Collections; +import java.util.Arrays; +import java.util.Collection; +import java.util.ArrayList; + +import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.robolectric.*; +import org.sufficientlysecure.keychain.testsupport.KeyringTestingHelper; + +@RunWith(RobolectricTestRunner.class) +@org.robolectric.annotation.Config(emulateSdk = 18) // Robolectric doesn't yet support 19 +public class ProviderHelperKeyringTest { + + @Test + public void testSavePublicKeyring() throws Exception { + Assert.assertTrue(new KeyringTestingHelper(Robolectric.application).addKeyring(Collections.singleton( + "/public-key-for-sample.blob" + ))); + } + + @Test + public void testSavePublicKeyringRsa() throws Exception { + Assert.assertTrue(new KeyringTestingHelper(Robolectric.application).addKeyring(prependResourcePath(Arrays.asList( + "000001-006.public_key", + "000002-013.user_id", + "000003-002.sig", + "000004-012.ring_trust", + "000005-002.sig", + "000006-012.ring_trust", + "000007-002.sig", + "000008-012.ring_trust", + "000009-002.sig", + "000010-012.ring_trust", + "000011-002.sig", + "000012-012.ring_trust", + "000013-014.public_subkey", + "000014-002.sig", + "000015-012.ring_trust" + )))); + } + + @Test + public void testSavePublicKeyringDsa() throws Exception { + Assert.assertTrue(new KeyringTestingHelper(Robolectric.application).addKeyring(prependResourcePath(Arrays.asList( + "000016-006.public_key", + "000017-002.sig", + "000018-012.ring_trust", + "000019-013.user_id", + "000020-002.sig", + "000021-012.ring_trust", + "000022-002.sig", + "000023-012.ring_trust", + "000024-014.public_subkey", + "000025-002.sig", + "000026-012.ring_trust" + )))); + } + + @Test + public void testSavePublicKeyringDsa2() throws Exception { + Assert.assertTrue(new KeyringTestingHelper(Robolectric.application).addKeyring(prependResourcePath(Arrays.asList( + "000027-006.public_key", + "000028-002.sig", + "000029-012.ring_trust", + "000030-013.user_id", + "000031-002.sig", + "000032-012.ring_trust", + "000033-002.sig", + "000034-012.ring_trust" + )))); + } + + private static Collection prependResourcePath(Collection files) { + Collection prependedFiles = new ArrayList(); + for (String file: files) { + prependedFiles.add("/extern/OpenPGP-Haskell/tests/data/" + file); + } + return prependedFiles; + } +} diff --git a/OpenKeychain-Test/src/test/java/org/sufficientlysecure/keychain/tests/UncachedKeyringTest.java b/OpenKeychain-Test/src/test/java/org/sufficientlysecure/keychain/tests/UncachedKeyringTest.java new file mode 100644 index 000000000..509ebd581 --- /dev/null +++ b/OpenKeychain-Test/src/test/java/org/sufficientlysecure/keychain/tests/UncachedKeyringTest.java @@ -0,0 +1,91 @@ +package org.sufficientlysecure.keychain.tests; + +import android.app.Activity; + +import org.junit.Assert; +import org.junit.Test; +import org.junit.Before; +import org.junit.runner.RunWith; +import org.robolectric.*; +import org.robolectric.shadows.ShadowLog; +import org.spongycastle.bcpg.sig.KeyFlags; +import org.sufficientlysecure.keychain.Constants; +import org.sufficientlysecure.keychain.pgp.PgpKeyOperation; +import org.sufficientlysecure.keychain.pgp.UncachedKeyRing; +import org.sufficientlysecure.keychain.service.OperationResultParcel; +import org.sufficientlysecure.keychain.service.SaveKeyringParcel; +import org.sufficientlysecure.keychain.testsupport.KeyringBuilder; +import org.sufficientlysecure.keychain.testsupport.KeyringTestingHelper; +import org.sufficientlysecure.keychain.testsupport.TestDataUtil; +import org.sufficientlysecure.keychain.ui.KeyListActivity; + +import java.util.HashSet; + +@RunWith(RobolectricTestRunner.class) +@org.robolectric.annotation.Config(emulateSdk = 18) // Robolectric doesn't yet support 19 +public class UncachedKeyringTest { + + @Before + public void setUp() throws Exception { + ShadowLog.stream = System.out; + } + + @Test + public void testCreateKey() throws Exception { + Activity activity = Robolectric.buildActivity(KeyListActivity.class).create().get(); + + SaveKeyringParcel parcel = new SaveKeyringParcel(); + parcel.addSubKeys.add(new SaveKeyringParcel.SubkeyAdd( + Constants.choice.algorithm.rsa, 1024, KeyFlags.CERTIFY_OTHER, null)); + // parcel.addSubKeys.add(new SubkeyAdd(algorithm.rsa, 1024, KeyFlags.SIGN_DATA, null)); + parcel.addUserIds.add("swagerinho"); + parcel.newPassphrase = "swag"; + PgpKeyOperation op = new PgpKeyOperation(null); + + OperationResultParcel.OperationLog log = new OperationResultParcel.OperationLog(); + UncachedKeyRing ring = op.createSecretKeyRing(parcel, log, 0); + + if (ring == null) { + log.print(activity); + throw new AssertionError("oh no"); + } + + if (!"swagerinho".equals(ring.getMasterKeyId())) { + log.print(activity); + throw new AssertionError("oh noo"); + } + + } + + @Test + public void testVerifySuccess() throws Exception { + UncachedKeyRing expectedKeyRing = KeyringBuilder.ring2(); + UncachedKeyRing inputKeyRing = KeyringBuilder.ring1(); + // new UncachedKeyringTestingHelper().doTestCanonicalize(inputKeyRing, expectedKeyRing); + + OperationResultParcel.OperationLog log = new OperationResultParcel.OperationLog(); + UncachedKeyRing canonicalizedRing = inputKeyRing.canonicalize(log, 0); + + if (canonicalizedRing == null) { + throw new AssertionError("Canonicalization failed; messages: [" + log.toString() + "]"); + } + + HashSet onlyA = new HashSet(); + HashSet onlyB = new HashSet(); + Assert.assertTrue(KeyringTestingHelper.diffKeyrings( + expectedKeyRing.getEncoded(), expectedKeyRing.getEncoded(), onlyA, onlyB)); + + } + + /** + * Just testing my own test code. Should really be using a library for this. + */ + @Test + public void testConcat() throws Exception { + byte[] actual = TestDataUtil.concatAll(new byte[]{1}, new byte[]{2,-2}, new byte[]{5},new byte[]{3}); + byte[] expected = new byte[]{1,2,-2,5,3}; + Assert.assertEquals(java.util.Arrays.toString(expected), java.util.Arrays.toString(actual)); + } + + +} diff --git a/OpenKeychain-Test/src/test/resources/extern/OpenPGP-Haskell b/OpenKeychain-Test/src/test/resources/extern/OpenPGP-Haskell new file mode 160000 index 000000000..eba7e4fdc --- /dev/null +++ b/OpenKeychain-Test/src/test/resources/extern/OpenPGP-Haskell @@ -0,0 +1 @@ +Subproject commit eba7e4fdce3de6622b4ec3862b405b0acd016377 diff --git a/OpenKeychain-Test/src/test/resources/public-key-for-sample.blob b/OpenKeychain-Test/src/test/resources/public-key-for-sample.blob new file mode 100644 index 000000000..4aa91510b Binary files /dev/null and b/OpenKeychain-Test/src/test/resources/public-key-for-sample.blob differ diff --git a/OpenKeychain-Test/src/test/resources/sample-altered.txt b/OpenKeychain-Test/src/test/resources/sample-altered.txt new file mode 100644 index 000000000..458821f81 --- /dev/null +++ b/OpenKeychain-Test/src/test/resources/sample-altered.txt @@ -0,0 +1,26 @@ +-----BEGIN PGP SIGNED MESSAGE----- +Hash: SHA1 + +This is a simple text document, which is used to illustrate +the concept of signing simple text files. There are no +control characters or special formatting commands in this +text, just simple printable ASCII characters. +MALICIOUS TEXT +To make this a slightly less uninteresting document, there +follows a short shopping list. + + eggs, 1 doz + milk, 1 gal + bacon, 1 lb + olive oil + bread, 1 loaf + +That's all there is to this document. + +-----BEGIN PGP SIGNATURE----- +Version: PGPfreeware 5.5.5 for non-commercial use + +iQA/AwUBN78ib3S9RCOKzj55EQKqDACg1NV2/iyPKrDlOVJvJwz6ArcQ0UQAnjNC +CDxKAFyaaGa835l1vpbFkAJk +=3r/N +-----END PGP SIGNATURE----- diff --git a/OpenKeychain-Test/src/test/resources/sample.txt b/OpenKeychain-Test/src/test/resources/sample.txt new file mode 100644 index 000000000..c0065f78d --- /dev/null +++ b/OpenKeychain-Test/src/test/resources/sample.txt @@ -0,0 +1,26 @@ +-----BEGIN PGP SIGNED MESSAGE----- +Hash: SHA1 + +This is a simple text document, which is used to illustrate +the concept of signing simple text files. There are no +control characters or special formatting commands in this +text, just simple printable ASCII characters. + +To make this a slightly less uninteresting document, there +follows a short shopping list. + + eggs, 1 doz + milk, 1 gal + bacon, 1 lb + olive oil + bread, 1 loaf + +That's all there is to this document. + +-----BEGIN PGP SIGNATURE----- +Version: PGPfreeware 5.5.5 for non-commercial use + +iQA/AwUBN78ib3S9RCOKzj55EQKqDACg1NV2/iyPKrDlOVJvJwz6ArcQ0UQAnjNC +CDxKAFyaaGa835l1vpbFkAJk +=3r/N +-----END PGP SIGNATURE----- diff --git a/OpenKeychain/build.gradle b/OpenKeychain/build.gradle index f419141b4..749a7f9ab 100644 --- a/OpenKeychain/build.gradle +++ b/OpenKeychain/build.gradle @@ -21,13 +21,6 @@ dependencies { compile project(':extern:minidns') compile project(':extern:KeybaseLib:Lib') - - // Unit tests are run with Robolectric - testCompile 'junit:junit:4.11' - testCompile 'org.robolectric:robolectric:2.3' - testCompile 'com.squareup:fest-android:1.0.8' - testCompile 'com.google.android:android:4.1.1.4' - // compile dependencies are automatically also included in testCompile } android { diff --git a/OpenKeychain/src/test/java/tests/PgpDecryptVerifyTest.java b/OpenKeychain/src/test/java/tests/PgpDecryptVerifyTest.java deleted file mode 100644 index d759bce05..000000000 --- a/OpenKeychain/src/test/java/tests/PgpDecryptVerifyTest.java +++ /dev/null @@ -1,36 +0,0 @@ -package tests; - -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.robolectric.*; -import org.openintents.openpgp.OpenPgpSignatureResult; -import org.sufficientlysecure.keychain.testsupport.PgpVerifyTestingHelper; - -@RunWith(RobolectricTestRunner.class) -@org.robolectric.annotation.Config(emulateSdk = 18) // Robolectric doesn't yet support 19 -public class PgpDecryptVerifyTest { - - @Test - public void testVerifySuccess() throws Exception { - - String testFileName = "/sample.txt"; - int expectedSignatureResult = OpenPgpSignatureResult.SIGNATURE_SUCCESS_UNCERTIFIED; - - int status = new PgpVerifyTestingHelper(Robolectric.application).doTestFile(testFileName); - - Assert.assertEquals(expectedSignatureResult, status); - } - - @Test - public void testVerifyFailure() throws Exception { - - String testFileName = "/sample-altered.txt"; - int expectedSignatureResult = OpenPgpSignatureResult.SIGNATURE_ERROR; - - int status = new PgpVerifyTestingHelper(Robolectric.application).doTestFile(testFileName); - - Assert.assertEquals(expectedSignatureResult, status); - } - -} diff --git a/OpenKeychain/src/test/java/tests/ProviderHelperKeyringTest.java b/OpenKeychain/src/test/java/tests/ProviderHelperKeyringTest.java deleted file mode 100644 index 3d48c2f97..000000000 --- a/OpenKeychain/src/test/java/tests/ProviderHelperKeyringTest.java +++ /dev/null @@ -1,86 +0,0 @@ -package tests; - -import java.util.Collections; -import java.util.Arrays; -import java.util.Collection; -import java.util.ArrayList; - -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.robolectric.*; -import org.openintents.openpgp.OpenPgpSignatureResult; -import org.sufficientlysecure.keychain.testsupport.KeyringTestingHelper; -import org.sufficientlysecure.keychain.testsupport.PgpVerifyTestingHelper; - -@RunWith(RobolectricTestRunner.class) -@org.robolectric.annotation.Config(emulateSdk = 18) // Robolectric doesn't yet support 19 -public class ProviderHelperKeyringTest { - - @Test - public void testSavePublicKeyring() throws Exception { - Assert.assertTrue(new KeyringTestingHelper(Robolectric.application).addKeyring(Collections.singleton( - "/public-key-for-sample.blob" - ))); - } - - @Test - public void testSavePublicKeyringRsa() throws Exception { - Assert.assertTrue(new KeyringTestingHelper(Robolectric.application).addKeyring(prependResourcePath(Arrays.asList( - "000001-006.public_key", - "000002-013.user_id", - "000003-002.sig", - "000004-012.ring_trust", - "000005-002.sig", - "000006-012.ring_trust", - "000007-002.sig", - "000008-012.ring_trust", - "000009-002.sig", - "000010-012.ring_trust", - "000011-002.sig", - "000012-012.ring_trust", - "000013-014.public_subkey", - "000014-002.sig", - "000015-012.ring_trust" - )))); - } - - @Test - public void testSavePublicKeyringDsa() throws Exception { - Assert.assertTrue(new KeyringTestingHelper(Robolectric.application).addKeyring(prependResourcePath(Arrays.asList( - "000016-006.public_key", - "000017-002.sig", - "000018-012.ring_trust", - "000019-013.user_id", - "000020-002.sig", - "000021-012.ring_trust", - "000022-002.sig", - "000023-012.ring_trust", - "000024-014.public_subkey", - "000025-002.sig", - "000026-012.ring_trust" - )))); - } - - @Test - public void testSavePublicKeyringDsa2() throws Exception { - Assert.assertTrue(new KeyringTestingHelper(Robolectric.application).addKeyring(prependResourcePath(Arrays.asList( - "000027-006.public_key", - "000028-002.sig", - "000029-012.ring_trust", - "000030-013.user_id", - "000031-002.sig", - "000032-012.ring_trust", - "000033-002.sig", - "000034-012.ring_trust" - )))); - } - - private static Collection prependResourcePath(Collection files) { - Collection prependedFiles = new ArrayList(); - for (String file: files) { - prependedFiles.add("/extern/OpenPGP-Haskell/tests/data/" + file); - } - return prependedFiles; - } -} diff --git a/OpenKeychain/src/test/java/tests/UncachedKeyringTest.java b/OpenKeychain/src/test/java/tests/UncachedKeyringTest.java deleted file mode 100644 index 86089340c..000000000 --- a/OpenKeychain/src/test/java/tests/UncachedKeyringTest.java +++ /dev/null @@ -1,51 +0,0 @@ -package tests; - -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.robolectric.*; -import org.sufficientlysecure.keychain.pgp.UncachedKeyRing; -import org.sufficientlysecure.keychain.service.OperationResultParcel; -import org.sufficientlysecure.keychain.testsupport.*; -import org.sufficientlysecure.keychain.testsupport.KeyringBuilder; -import org.sufficientlysecure.keychain.testsupport.KeyringTestingHelper; -import org.sufficientlysecure.keychain.testsupport.TestDataUtil; - -import java.util.HashSet; - -@RunWith(RobolectricTestRunner.class) -@org.robolectric.annotation.Config(emulateSdk = 18) // Robolectric doesn't yet support 19 -public class UncachedKeyringTest { - - @Test - public void testVerifySuccess() throws Exception { - UncachedKeyRing expectedKeyRing = KeyringBuilder.ring2(); - UncachedKeyRing inputKeyRing = KeyringBuilder.ring1(); - // new UncachedKeyringTestingHelper().doTestCanonicalize(inputKeyRing, expectedKeyRing); - - OperationResultParcel.OperationLog log = new OperationResultParcel.OperationLog(); - UncachedKeyRing canonicalizedRing = inputKeyRing.canonicalize(log, 0); - - if (canonicalizedRing == null) { - throw new AssertionError("Canonicalization failed; messages: [" + log.toString() + "]"); - } - - HashSet onlyA = new HashSet(); - HashSet onlyB = new HashSet(); - Assert.assertTrue(KeyringTestingHelper.diffKeyrings( - canonicalizedRing.getEncoded(), expectedKeyRing.getEncoded(), onlyA, onlyB)); - - } - - /** - * Just testing my own test code. Should really be using a library for this. - */ - @Test - public void testConcat() throws Exception { - byte[] actual = TestDataUtil.concatAll(new byte[]{1}, new byte[]{2,-2}, new byte[]{5},new byte[]{3}); - byte[] expected = new byte[]{1,2,-2,5,3}; - Assert.assertEquals(java.util.Arrays.toString(expected), java.util.Arrays.toString(actual)); - } - - -} diff --git a/OpenKeychain/src/test/resources/extern/OpenPGP-Haskell b/OpenKeychain/src/test/resources/extern/OpenPGP-Haskell deleted file mode 160000 index eba7e4fdc..000000000 --- a/OpenKeychain/src/test/resources/extern/OpenPGP-Haskell +++ /dev/null @@ -1 +0,0 @@ -Subproject commit eba7e4fdce3de6622b4ec3862b405b0acd016377 diff --git a/OpenKeychain/src/test/resources/public-key-for-sample.blob b/OpenKeychain/src/test/resources/public-key-for-sample.blob deleted file mode 100644 index 4aa91510b..000000000 Binary files a/OpenKeychain/src/test/resources/public-key-for-sample.blob and /dev/null differ diff --git a/OpenKeychain/src/test/resources/sample-altered.txt b/OpenKeychain/src/test/resources/sample-altered.txt deleted file mode 100644 index 458821f81..000000000 --- a/OpenKeychain/src/test/resources/sample-altered.txt +++ /dev/null @@ -1,26 +0,0 @@ ------BEGIN PGP SIGNED MESSAGE----- -Hash: SHA1 - -This is a simple text document, which is used to illustrate -the concept of signing simple text files. There are no -control characters or special formatting commands in this -text, just simple printable ASCII characters. -MALICIOUS TEXT -To make this a slightly less uninteresting document, there -follows a short shopping list. - - eggs, 1 doz - milk, 1 gal - bacon, 1 lb - olive oil - bread, 1 loaf - -That's all there is to this document. - ------BEGIN PGP SIGNATURE----- -Version: PGPfreeware 5.5.5 for non-commercial use - -iQA/AwUBN78ib3S9RCOKzj55EQKqDACg1NV2/iyPKrDlOVJvJwz6ArcQ0UQAnjNC -CDxKAFyaaGa835l1vpbFkAJk -=3r/N ------END PGP SIGNATURE----- diff --git a/OpenKeychain/src/test/resources/sample.txt b/OpenKeychain/src/test/resources/sample.txt deleted file mode 100644 index c0065f78d..000000000 --- a/OpenKeychain/src/test/resources/sample.txt +++ /dev/null @@ -1,26 +0,0 @@ ------BEGIN PGP SIGNED MESSAGE----- -Hash: SHA1 - -This is a simple text document, which is used to illustrate -the concept of signing simple text files. There are no -control characters or special formatting commands in this -text, just simple printable ASCII characters. - -To make this a slightly less uninteresting document, there -follows a short shopping list. - - eggs, 1 doz - milk, 1 gal - bacon, 1 lb - olive oil - bread, 1 loaf - -That's all there is to this document. - ------BEGIN PGP SIGNATURE----- -Version: PGPfreeware 5.5.5 for non-commercial use - -iQA/AwUBN78ib3S9RCOKzj55EQKqDACg1NV2/iyPKrDlOVJvJwz6ArcQ0UQAnjNC -CDxKAFyaaGa835l1vpbFkAJk -=3r/N ------END PGP SIGNATURE----- diff --git a/build.gradle b/build.gradle index ceb963cd8..06036785b 100644 --- a/build.gradle +++ b/build.gradle @@ -1,12 +1,16 @@ buildscript { repositories { mavenCentral() + // need this for com.novoda:gradle-android-test-plugin:0.9.9-SNAPSHOT below (0.9.3 in repos doesn't work!) + // run ./install-custom-gradle-test-plugin.sh to pull the thing into the local repository + mavenLocal() } dependencies { // NOTE: Always use fixed version codes not dynamic ones, e.g. 0.7.3 instead of 0.7.+, see README for more information classpath 'com.android.tools.build:gradle:0.12.0' classpath 'org.robolectric:robolectric-gradle-plugin:0.11.0' + classpath 'com.novoda:gradle-android-test-plugin:0.9.9-SNAPSHOT' } } diff --git a/install-custom-gradle-test-plugin.sh b/install-custom-gradle-test-plugin.sh new file mode 100755 index 000000000..85c13d959 --- /dev/null +++ b/install-custom-gradle-test-plugin.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +mkdir temp +cd temp + + git clone https://github.com/nenick/gradle-android-test-plugin.git + cd gradle-android-test-plugin + + echo "rootProject.name = 'gradle-android-test-plugin-parent'" > settings.gradle + echo "include ':gradle-android-test-plugin'" >> settings.gradle + + ./gradlew :gradle-android-test-plugin:install + + cd .. +cd .. \ No newline at end of file diff --git a/settings.gradle b/settings.gradle index d8802320c..86088e04a 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,4 +1,5 @@ include ':OpenKeychain' +include ':OpenKeychain-Test' include ':extern:openpgp-api-lib' include ':extern:openkeychain-api-lib' include ':extern:html-textview' -- cgit v1.2.3