mirror of
https://github.com/moparisthebest/open-keychain
synced 2024-11-11 03:25:05 -05:00
Merge submodules
This commit is contained in:
commit
9ce7d29a2d
3
.gitmodules
vendored
3
.gitmodules
vendored
@ -34,3 +34,6 @@
|
|||||||
[submodule "extern/minidns"]
|
[submodule "extern/minidns"]
|
||||||
path = extern/minidns
|
path = extern/minidns
|
||||||
url = https://github.com/open-keychain/minidns.git
|
url = https://github.com/open-keychain/minidns.git
|
||||||
|
[submodule "OpenKeychain/src/test/resources/extern/OpenPGP-Haskell"]
|
||||||
|
path = OpenKeychain/src/test/resources/extern/OpenPGP-Haskell
|
||||||
|
url = https://github.com/singpolyma/OpenPGP-Haskell.git
|
||||||
|
@ -5,9 +5,10 @@ import android.content.Context;
|
|||||||
import org.sufficientlysecure.keychain.pgp.NullProgressable;
|
import org.sufficientlysecure.keychain.pgp.NullProgressable;
|
||||||
import org.sufficientlysecure.keychain.pgp.UncachedKeyRing;
|
import org.sufficientlysecure.keychain.pgp.UncachedKeyRing;
|
||||||
import org.sufficientlysecure.keychain.provider.ProviderHelper;
|
import org.sufficientlysecure.keychain.provider.ProviderHelper;
|
||||||
import org.sufficientlysecure.keychain.remote.AppSettings;
|
|
||||||
import org.sufficientlysecure.keychain.service.OperationResults;
|
import org.sufficientlysecure.keychain.service.OperationResults;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper for tests of the Keyring import in ProviderHelper.
|
* Helper for tests of the Keyring import in ProviderHelper.
|
||||||
*/
|
*/
|
||||||
@ -19,13 +20,11 @@ public class KeyringTestingHelper {
|
|||||||
this.context = robolectricContext;
|
this.context = robolectricContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean addKeyring() throws Exception {
|
public boolean addKeyring(Collection<String> blobFiles) throws Exception {
|
||||||
|
|
||||||
ProviderHelper providerHelper = new ProviderHelper(context);
|
ProviderHelper providerHelper = new ProviderHelper(context);
|
||||||
|
|
||||||
// providerHelper.insertApiApp(new AppSettings("robo-test-package", new byte[]{5, 4, 3, 2, 1}));
|
byte[] data = TestDataUtil.readAllFully(blobFiles);
|
||||||
|
|
||||||
byte[] data = TestDataUtil.readFully(getClass().getResourceAsStream("/public-key-for-sample.blob"));
|
|
||||||
UncachedKeyRing ring = UncachedKeyRing.decodeFromData(data);
|
UncachedKeyRing ring = UncachedKeyRing.decodeFromData(data);
|
||||||
long masterKeyId = ring.getMasterKeyId();
|
long masterKeyId = ring.getMasterKeyId();
|
||||||
|
|
||||||
@ -45,6 +44,7 @@ public class KeyringTestingHelper {
|
|||||||
return saveSuccess;
|
return saveSuccess;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void retrieveKeyAndExpectNotFound(ProviderHelper providerHelper, long masterKeyId) {
|
private void retrieveKeyAndExpectNotFound(ProviderHelper providerHelper, long masterKeyId) {
|
||||||
try {
|
try {
|
||||||
providerHelper.getWrappedPublicKeyRing(masterKeyId);
|
providerHelper.getWrappedPublicKeyRing(masterKeyId);
|
||||||
|
@ -3,6 +3,7 @@ package org.sufficientlysecure.keychain.testsupport;
|
|||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
import java.util.Collection;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Misc support functions. Would just use Guava / Apache Commons but
|
* Misc support functions. Would just use Guava / Apache Commons but
|
||||||
@ -10,9 +11,14 @@ import java.io.InputStream;
|
|||||||
*/
|
*/
|
||||||
public class TestDataUtil {
|
public class TestDataUtil {
|
||||||
public static byte[] readFully(InputStream input) {
|
public static byte[] readFully(InputStream input) {
|
||||||
|
ByteArrayOutputStream output = new ByteArrayOutputStream();
|
||||||
|
appendToOutput(input, output);
|
||||||
|
return output.toByteArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void appendToOutput(InputStream input, ByteArrayOutputStream output) {
|
||||||
byte[] buffer = new byte[8192];
|
byte[] buffer = new byte[8192];
|
||||||
int bytesRead;
|
int bytesRead;
|
||||||
ByteArrayOutputStream output = new ByteArrayOutputStream();
|
|
||||||
try {
|
try {
|
||||||
while ((bytesRead = input.read(buffer)) != -1) {
|
while ((bytesRead = input.read(buffer)) != -1) {
|
||||||
output.write(buffer, 0, bytesRead);
|
output.write(buffer, 0, bytesRead);
|
||||||
@ -20,6 +26,19 @@ public class TestDataUtil {
|
|||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static byte[] readAllFully(Collection<String> inputResources) {
|
||||||
|
ByteArrayOutputStream output = new ByteArrayOutputStream();
|
||||||
|
|
||||||
|
for (String inputResource : inputResources) {
|
||||||
|
appendToOutput(getResourceAsStream(inputResource), output);
|
||||||
|
}
|
||||||
return output.toByteArray();
|
return output.toByteArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static InputStream getResourceAsStream(String resourceName) {
|
||||||
|
return TestDataUtil.class.getResourceAsStream(resourceName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,10 @@
|
|||||||
package tests;
|
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.Assert;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
@ -14,7 +19,68 @@ public class ProviderHelperKeyringTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSavePublicKeyring() throws Exception {
|
public void testSavePublicKeyring() throws Exception {
|
||||||
Assert.assertTrue(new KeyringTestingHelper(Robolectric.application).addKeyring());
|
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<String> prependResourcePath(Collection<String> files) {
|
||||||
|
Collection<String> prependedFiles = new ArrayList<String>();
|
||||||
|
for (String file: files) {
|
||||||
|
prependedFiles.add("/extern/OpenPGP-Haskell/tests/data/" + file);
|
||||||
|
}
|
||||||
|
return prependedFiles;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
1
OpenKeychain/src/test/resources/extern/OpenPGP-Haskell
vendored
Submodule
1
OpenKeychain/src/test/resources/extern/OpenPGP-Haskell
vendored
Submodule
@ -0,0 +1 @@
|
|||||||
|
Subproject commit eba7e4fdce3de6622b4ec3862b405b0acd016377
|
Loading…
Reference in New Issue
Block a user