summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/src/androidTest/java/se/leap/bitmaskclient/test/BaseTestDashboardFragment.java2
-rw-r--r--app/src/androidTest/java/se/leap/bitmaskclient/test/UserStatusTestController.java2
-rw-r--r--app/src/androidTest/java/se/leap/bitmaskclient/test/VpnTestController.java23
-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
5 files changed, 94 insertions, 8 deletions
diff --git a/app/src/androidTest/java/se/leap/bitmaskclient/test/BaseTestDashboardFragment.java b/app/src/androidTest/java/se/leap/bitmaskclient/test/BaseTestDashboardFragment.java
index 3e572c31..d0b8cf6f 100644
--- a/app/src/androidTest/java/se/leap/bitmaskclient/test/BaseTestDashboardFragment.java
+++ b/app/src/androidTest/java/se/leap/bitmaskclient/test/BaseTestDashboardFragment.java
@@ -54,7 +54,7 @@ public abstract class BaseTestDashboardFragment extends ActivityInstrumentationT
}
private void clickAndWaitForDashboard(String click_text) {
- solo.clickOnText(click_text);
+ solo.clickOnButton(click_text);
assertTrue(solo.waitForActivity(Dashboard.class, 80 * 1000));
}
diff --git a/app/src/androidTest/java/se/leap/bitmaskclient/test/UserStatusTestController.java b/app/src/androidTest/java/se/leap/bitmaskclient/test/UserStatusTestController.java
index 821a23fd..76d14911 100644
--- a/app/src/androidTest/java/se/leap/bitmaskclient/test/UserStatusTestController.java
+++ b/app/src/androidTest/java/se/leap/bitmaskclient/test/UserStatusTestController.java
@@ -30,7 +30,7 @@ public class UserStatusTestController {
void logIn(String username, String password, boolean expectSuccess) {
solo.enterText(0, username);
solo.enterText(1, password);
- solo.clickOnText(solo.getString(R.string.login_button));
+ solo.clickOnButton(solo.getString(R.string.login_button));
assertTrue(solo.waitForDialogToClose());
if (expectSuccess) {
diff --git a/app/src/androidTest/java/se/leap/bitmaskclient/test/VpnTestController.java b/app/src/androidTest/java/se/leap/bitmaskclient/test/VpnTestController.java
index b0996032..d339ab26 100644
--- a/app/src/androidTest/java/se/leap/bitmaskclient/test/VpnTestController.java
+++ b/app/src/androidTest/java/se/leap/bitmaskclient/test/VpnTestController.java
@@ -9,6 +9,7 @@ import com.robotium.solo.Solo;
import de.blinkt.openvpn.activities.DisconnectVPN;
import mbanje.kurt.fabbutton.FabButton;
import mbanje.kurt.fabbutton.ProgressRingView;
+import se.leap.bitmaskclient.Dashboard;
import se.leap.bitmaskclient.R;
import static junit.framework.Assert.assertTrue;
@@ -48,7 +49,9 @@ public class VpnTestController {
}
protected FabButton getVpnWholeIcon() {
- View view = solo.getView(R.id.vpn_Status_Image);
+ assertTrue(solo.waitForActivity(Dashboard.class, 5 * 1000));
+
+ View view = solo.getView(R.id.vpn_status_image);
if (view != null)
return (FabButton) view;
else
@@ -92,9 +95,9 @@ public class VpnTestController {
okToBrowserWarning();
sayOkToDisconnect();
- int max_seconds_until_connected = 1;
+ int max_seconds_until_connected = 120;
- Condition condition = new Condition() {
+ Condition condition = new Condition() {
@Override
public boolean isSatisfied() {
return iconShowsDisconnected();
@@ -107,17 +110,25 @@ public class VpnTestController {
private void okToBrowserWarning() {
assertTrue(solo.waitForDialogToOpen());
clickYes();
+ solo.waitForDialogToClose();
}
private void clickYes() {
String yes = solo.getString(android.R.string.yes);
- solo.clickOnText(yes);
+ solo.clickOnButton(yes);
+ }
+
+ private void clickDisconnect() {
+ String disconnect = solo.getString(R.string.cancel_connection);
+ solo.clickOnButton(disconnect);
}
private void sayOkToDisconnect() throws IllegalStateException {
boolean disconnect_vpn_appeared = solo.waitForActivity(DisconnectVPN.class);
- if(disconnect_vpn_appeared)
- clickYes();
+ if(disconnect_vpn_appeared){
+ clickDisconnect();
+ solo.waitForDialogToClose();
+ }
else throw new IllegalStateException();
}
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());
+ }
+}