summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcyBerta <cyberta@riseup.net>2018-10-20 02:46:31 +0200
committercyBerta <cyberta@riseup.net>2022-08-08 18:58:38 +0200
commit46d5ba9cf94c2490d18047a8e0085a3d8f9a6e0e (patch)
tree8a34fea0dbf622736a861358d5a8775f961fe0d4
parent316cd680bd15ab9d57532d5433236275461122b5 (diff)
remove test classes
-rw-r--r--main/src/test/java/de/blinkt/openvpn/core/TestConfigGenerator.java77
-rw-r--r--main/src/test/java/de/blinkt/openvpn/core/TestIpParser.java37
-rw-r--r--main/src/test/java/de/blinkt/openvpn/core/TestLogFileHandler.java124
3 files changed, 0 insertions, 238 deletions
diff --git a/main/src/test/java/de/blinkt/openvpn/core/TestConfigGenerator.java b/main/src/test/java/de/blinkt/openvpn/core/TestConfigGenerator.java
deleted file mode 100644
index e2be04b4..00000000
--- a/main/src/test/java/de/blinkt/openvpn/core/TestConfigGenerator.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Copyright (c) 2012-2018 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 android.content.Context;
-import android.content.pm.PackageManager;
-import android.os.Build;
-
-import junit.framework.Assert;
-
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
-import org.robolectric.RuntimeEnvironment;
-import org.robolectric.annotation.Config;
-
-import de.blinkt.openvpn.VpnProfile;
-
-import static de.blinkt.openvpn.VpnProfile.AUTH_RETRY_NOINTERACT;
-import static de.blinkt.openvpn.VpnProfile.TYPE_USERPASS;
-
-/**
- * Created by arne on 14.03.18.
- */
-
-
-@Config(sdk = Build.VERSION_CODES.O_MR1)
-@RunWith(RobolectricTestRunner.class)
-public class TestConfigGenerator {
- @Test
- public void testAuthRetryGen() throws PackageManager.NameNotFoundException {
- /*Context mc = mock(Context.class);
- PackageManager mpm = mock(PackageManager.class);
-
- PackageInfo mpi = new PackageInfo();
- mpi.versionCode = 177;
- mpi.versionName = "foo";
-
- when(mc.getCacheDir()).thenReturn(new File("/j/unit/test/"));
- when(mc.getPackageName()).thenReturn("de.blinkt.openvpn");
- when(mc.getPackageManager()).thenReturn(mpm);
- when(mpm.getPackageInfo(eq("de.blinkt.openvpn"),eq(0))).thenReturn(mpi);*/
-
-
-
- VpnProfile vp = new VpnProfile ("test") {
- @Override
- public String getPlatformVersionEnvString() {
- return "test";
- }
- };
-
- vp.mAuthenticationType = TYPE_USERPASS;
- vp.mAuthRetry = AUTH_RETRY_NOINTERACT;
- String config = vp.getConfigFile(RuntimeEnvironment.application, false);
- Assert.assertTrue(config.contains("\nauth-retry nointeract\n"));
- for (Connection connection: vp.mConnections)
- Assert.assertTrue(connection.mProxyType == Connection.ProxyType.NONE);
-
- }
-
- @Test
- public void testEscape()
- {
- String uglyPassword = "^OrFg1{G^SS8b4J@B$Y1Dr\\GwG-dw3aBJ/R@WI*doCVP',+:>zjqC[&b6[8=KL:`{l&:i!_4*npE?4k2c^(n>9Tjp~u2Z]l8(y&Gg<-cwR2k=yKK:-%f-ezQ\"^g)[d,kbsu$cqih\\wA~on$~)QSODtip2cd,+->qv,roF*9>6q:lTepm=r?Y-+(K]ERGn\"+AiLj<(R_'BOg:vsh0wh]BQ-PVo534;l%R*FF!+,$?Q00%839(k?E!x0R[Lx6qK\\&";
- String escapedUglyPassword = VpnProfile.openVpnEscape(uglyPassword);
-
- String testWithQuote = "'meinpw";
- String escapedQuote = VpnProfile.openVpnEscape(testWithQuote);
- org.junit.Assert.assertEquals("\"'meinpw\"", escapedQuote);
- }
-
-
-}
diff --git a/main/src/test/java/de/blinkt/openvpn/core/TestIpParser.java b/main/src/test/java/de/blinkt/openvpn/core/TestIpParser.java
deleted file mode 100644
index b57749e3..00000000
--- a/main/src/test/java/de/blinkt/openvpn/core/TestIpParser.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * 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.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());
- }
-}
diff --git a/main/src/test/java/de/blinkt/openvpn/core/TestLogFileHandler.java b/main/src/test/java/de/blinkt/openvpn/core/TestLogFileHandler.java
deleted file mode 100644
index b32e5efa..00000000
--- a/main/src/test/java/de/blinkt/openvpn/core/TestLogFileHandler.java
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
- * Copyright (c) 2012-2017 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 android.annotation.SuppressLint;
-
-import junit.framework.Assert;
-
-import org.junit.Before;
-import org.junit.Test;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.UnsupportedEncodingException;
-import java.util.Arrays;
-
-public class TestLogFileHandler {
-
- byte[] testUnescaped = new byte[]{0x00, 0x55, -27, 0x00, 0x56, 0x10, -128, 0x55, 0x54};
- byte[] expectedEscaped = new byte[]{0x55, 0x00, 0x00, 0x00, 0x09, 0x00, 0x56, 0x00, -27, 0x00, 0x56, 0x01, 0x10, -128, 0x56, 0x00, 0x54};
- private TestingLogFileHandler lfh;
-
-
- @Before
- public void setup() {
- lfh = new TestingLogFileHandler();
- }
-
- @Test
- public void testWriteByteArray() throws IOException {
-
- ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
-
- lfh.setLogFile(byteArrayOutputStream);
-
- lfh.writeEscapedBytes(testUnescaped);
-
- byte[] result = byteArrayOutputStream.toByteArray();
- Assert.assertTrue(Arrays.equals(expectedEscaped, result));
- }
-
- @Test
- public void readByteArray() throws IOException {
-
- ByteArrayInputStream in = new ByteArrayInputStream(expectedEscaped);
-
- lfh.readCacheContents(in);
-
- Assert.assertTrue(Arrays.equals(testUnescaped, lfh.mRestoredByteArray));
-
- }
-
- @Test
- public void testMarschal() throws UnsupportedEncodingException {
- LogItem li = new LogItem(VpnStatus.LogLevel.DEBUG, 72, "foobar");
- LogItem li2 = marschalAndBack(li);
- testEquals(li, li2);
- Assert.assertEquals(li, li2);
- }
-
- @Test
- public void testMarschalArgs() throws UnsupportedEncodingException {
- LogItem li = new LogItem(VpnStatus.LogLevel.DEBUG, 72, 772, "sinnloser Text", 7723, 723.2f, 7.2);
- LogItem li2 = marschalAndBack(li);
- testEquals(li, li2);
- Assert.assertEquals(li, li2);
- }
-
- @Test
- public void testMarschalString() throws UnsupportedEncodingException {
- LogItem li = new LogItem(VpnStatus.LogLevel.DEBUG, "Nutzlose Nachricht");
- LogItem li2 = marschalAndBack(li);
- testEquals(li, li2);
- Assert.assertEquals(li, li2);
- }
-
-
- private void testEquals(LogItem li, LogItem li2) {
- Assert.assertEquals(li.getLogLevel(), li2.getLogLevel());
- Assert.assertEquals(li.getLogtime(), li2.getLogtime());
- Assert.assertEquals(li.getVerbosityLevel(), li2.getVerbosityLevel());
- Assert.assertEquals(li.toString(), li2.toString());
-
- }
-
- private LogItem marschalAndBack(LogItem li) throws UnsupportedEncodingException {
- byte[] bytes = li.getMarschaledBytes();
-
- return new LogItem(bytes, bytes.length);
- }
-
-
- @SuppressLint("HandlerLeak")
- static class TestingLogFileHandler extends LogFileHandler {
-
- public byte[] mRestoredByteArray;
-
- public TestingLogFileHandler() {
- super(null);
- }
-
- public void setLogFile(OutputStream out) {
- mLogFile = out;
- }
-
- @Override
- public void readCacheContents(InputStream in) throws IOException {
- super.readCacheContents(in);
- }
-
- @Override
- protected void restoreLogItem(byte[] buf, int len) {
- mRestoredByteArray = Arrays.copyOf(buf, len);
- }
- }
-
-
-} \ No newline at end of file