diff options
| author | StevenWdV <stevenwdv@gmail.com> | 2022-02-09 00:40:38 +0100 |
|---|---|---|
| committer | StevenWdV <stevenwdv@gmail.com> | 2022-02-09 00:40:38 +0100 |
| commit | 2aad9b6ae61337ef94b05adc377a9ad2cbaa8eb8 (patch) | |
| tree | 022c006cfac7a60fd0ab8896fac3991cf34b8fce /wrappers/java-android/lib/src | |
| parent | b60ecf2fe5ddfe506e02093286b3931873187e91 (diff) | |
Add Android wrapper, remove plain Java Maven wrapper.
Fix some overrides in Makefiles.
Diffstat (limited to 'wrappers/java-android/lib/src')
| -rw-r--r-- | wrappers/java-android/lib/src/main/AndroidManifest.xml | 4 | ||||
| -rw-r--r-- | wrappers/java-android/lib/src/test/java/org/eduvpn/common/VerifyTests.java | 77 |
2 files changed, 81 insertions, 0 deletions
diff --git a/wrappers/java-android/lib/src/main/AndroidManifest.xml b/wrappers/java-android/lib/src/main/AndroidManifest.xml new file mode 100644 index 0000000..5a49838 --- /dev/null +++ b/wrappers/java-android/lib/src/main/AndroidManifest.xml @@ -0,0 +1,4 @@ +<?xml version="1.0" encoding="utf-8"?> +<manifest package="org.eduvpn.common"> + +</manifest> diff --git a/wrappers/java-android/lib/src/test/java/org/eduvpn/common/VerifyTests.java b/wrappers/java-android/lib/src/test/java/org/eduvpn/common/VerifyTests.java new file mode 100644 index 0000000..a73ac75 --- /dev/null +++ b/wrappers/java-android/lib/src/test/java/org/eduvpn/common/VerifyTests.java @@ -0,0 +1,77 @@ +package org.eduvpn.common; + +import org.apache.commons.io.IOUtils; +import org.junit.BeforeClass; +import org.junit.Test; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; + +public class VerifyTests { + private static byte[] readAll(String resource) throws IOException { + try (InputStream stream = VerifyTests.class.getResourceAsStream(resource)) { + return IOUtils.toByteArray(stream); + } + } + + @SuppressWarnings("OptionalGetWithoutIsPresent") + @BeforeClass + public static void oneTimeSetup() throws IOException { + try (BufferedReader reader = new BufferedReader(new InputStreamReader( + VerifyTests.class.getResourceAsStream("public.key")))) { + Discovery.insecureTestingSetExtraKey(reader.lines().reduce((a, b) -> b).get()); + } + } + + @Test + public void testValid() throws IOException, VerifyException { + Discovery.verify( + readAll("server_list.json.minisig"), + readAll("server_list.json"), + "server_list.json", + 0 + ); + } + + @Test(expected = InvalidSignatureException.class) + public void testInvalidSignature() throws IOException, VerifyException { + Discovery.verify( + readAll("random.txt"), + readAll("server_list.json"), + "server_list.json", + 0 + ); + } + + @Test(expected = InvalidSignatureUnknownKeyException.class) + public void testWrongKey() throws IOException, VerifyException { + Discovery.verify( + readAll("server_list.json.wrong_key.minisig"), + readAll("server_list.json"), + "server_list.json", + 0 + ); + } + + @Test(expected = SignatureTooOldException.class) + public void testOldSignature() throws IOException, VerifyException { + Discovery.verify( + readAll("server_list.json.minisig"), + readAll("server_list.json"), + "server_list.json", + Long.MAX_VALUE + ); + } + + @Test(expected = IllegalArgumentException.class) + public void testUnknownExpectedFile() throws IOException, VerifyException { + Discovery.verify( + readAll("other_list.json.minisig"), + readAll("other_list.json"), + "other_list.json", + 0 + ); + } +} |
