summaryrefslogtreecommitdiff
path: root/app/src/test
diff options
context:
space:
mode:
authorcyBerta <cyberta@riseup.net>2017-09-21 01:36:33 +0200
committercyBerta <cyberta@riseup.net>2017-09-21 01:36:33 +0200
commit6f5e56314d199723d1ff41c05ce46204727d53ab (patch)
tree343c1a52e91b3294633b1ddf0530e5dfb4ad18fd /app/src/test
parentd77b9aefea75491b50f28a6880906ba9496979f2 (diff)
update ics-openvpn: add and fix tests
Diffstat (limited to 'app/src/test')
-rw-r--r--app/src/test/java/de/blinkt/openvpn/core/TestConfigParser.java37
-rw-r--r--app/src/test/java/de/blinkt/openvpn/core/TestIpParser.java38
2 files changed, 75 insertions, 0 deletions
diff --git a/app/src/test/java/de/blinkt/openvpn/core/TestConfigParser.java b/app/src/test/java/de/blinkt/openvpn/core/TestConfigParser.java
new file mode 100644
index 00000000..560d4fc8
--- /dev/null
+++ b/app/src/test/java/de/blinkt/openvpn/core/TestConfigParser.java
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2012-2016 Arne Schwabe
+ * Distributed under the GNU GPL v2 with additional terms. For full terms see the file doc/LICENSE.txt
+ */
+
+package de.blinkt.openvpn.core;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import java.io.IOException;
+import java.io.StringReader;
+
+import de.blinkt.openvpn.VpnProfile;
+
+/**
+ * Created by arne on 03.10.16.
+ */
+
+public class TestConfigParser {
+
+ String miniconfig = "client\nremote test.blinkt.de\n";
+
+ @Test
+ public void testHttpProxyPass() throws IOException, ConfigParser.ConfigParseError {
+ String httpproxypass = "<http-proxy-user-pass>\n" +
+ "foo\n" +
+ "bar\n" +
+ "</http-proxy-user-pass>\n";
+
+ ConfigParser cp = new ConfigParser();
+ cp.parseConfig(new StringReader(miniconfig + httpproxypass));
+ VpnProfile p = cp.convertProfile();
+ Assert.assertTrue(p.mCustomConfigOptions.contains(httpproxypass));
+
+ }
+}
diff --git a/app/src/test/java/de/blinkt/openvpn/core/TestIpParser.java b/app/src/test/java/de/blinkt/openvpn/core/TestIpParser.java
new file mode 100644
index 00000000..37f9fdcd
--- /dev/null
+++ b/app/src/test/java/de/blinkt/openvpn/core/TestIpParser.java
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2012-2016 Arne Schwabe
+ * Distributed under the GNU GPL v2 with additional terms. For full terms see the file doc/LICENSE.txt
+ */
+
+package de.blinkt.openvpn.core;
+
+import junit.framework.Assert;
+
+import org.junit.Test;
+
+import java.net.Inet6Address;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+
+/**
+ * Created by arne on 23.07.16.
+ */
+
+public class TestIpParser {
+
+ @Test
+ public void parseIPv6Zeros() throws UnknownHostException {
+
+ testAddress("2020:0:1234::", 45, "2020:0:1234::/45");
+ testAddress("::", 0, "::/0");
+ testAddress("2a02:2e0:3fe:1001:302::", 128, "2a02:2e0:3fe:1001:302::/128");
+ testAddress("2a02:2e0:3fe:1001:302::70", 128, "2a02:2e0:3fe:1001:302:0:0:70/128");
+ }
+
+ void testAddress(String input, int mask, String output) throws UnknownHostException {
+ Inet6Address ip = (Inet6Address) InetAddress.getByName(input);
+
+ NetworkSpace.ipAddress netIp = new NetworkSpace.ipAddress(ip, mask, true);
+
+ Assert.assertEquals(output, netIp.toString());
+ }
+}