diff options
author | Arne Schwabe <arne@rfc2549.org> | 2021-09-28 01:24:09 +0200 |
---|---|---|
committer | Arne Schwabe <arne@rfc2549.org> | 2021-10-01 19:56:39 +0200 |
commit | f6227082f1c70f0443e0f5d6a5f10c2838e1b7ee (patch) | |
tree | a44ba5d3290fd4c292097bea3566742d67ffb016 /main/src/test | |
parent | 9e704d04dc7f2f93bddf85d371772340fa5af0b1 (diff) |
Implement using compat-mode
Diffstat (limited to 'main/src/test')
-rw-r--r-- | main/src/test/java/de/blinkt/openvpn/core/TestConfigParser.kt | 46 |
1 files changed, 45 insertions, 1 deletions
diff --git a/main/src/test/java/de/blinkt/openvpn/core/TestConfigParser.kt b/main/src/test/java/de/blinkt/openvpn/core/TestConfigParser.kt index fbaa4be2..c9dd64a2 100644 --- a/main/src/test/java/de/blinkt/openvpn/core/TestConfigParser.kt +++ b/main/src/test/java/de/blinkt/openvpn/core/TestConfigParser.kt @@ -9,6 +9,7 @@ import android.content.Context import android.os.Build import androidx.test.core.app.ApplicationProvider import de.blinkt.openvpn.R +import de.blinkt.openvpn.fragments.Utils import org.junit.Assert import org.junit.Test import org.junit.runner.RunWith @@ -145,7 +146,7 @@ class TestConfigParser { cp.parseConfig(StringReader(config4)) val vp4 = cp.convertProfile() - Assert.assertEquals("AES-128-GCM:AES-256-GCM:CHACHA20-POLY1305:BF-CBC", vp4.mDataCiphers) + Assert.assertEquals("AES-128-GCM:AES-256-GCM:CHACHA20-POLY1305", vp4.mDataCiphers) @@ -153,6 +154,49 @@ class TestConfigParser { @Test + fun testCompatmodeImport() { + val config = ("client\n" + + "tun-mtu 1234\n" + + "<connection>\n" + + "remote foo.bar\n" + + "tun-mtu 1222\n" + + "</connection>\n" + + "<cert>\nfakecert\n</cert>\n" + + "<key>\nfakekey\n</key>\n" + + "route 8.8.8.8 255.255.255.255 net_gateway\n") + val c:Context = ApplicationProvider.getApplicationContext() + + val config1 = config + "compat-mode 2.7.7\n" + + val cp = ConfigParser() + cp.parseConfig(StringReader(config1)) + val vp = cp.convertProfile() + + Assert.assertEquals(20707, vp.mCompatMode) + Assert.assertEquals(0,Utils.mapCompatVer(vp.mCompatMode)) + + + val config2 = config + "compat-mode 2.4.0\n" + + + cp.parseConfig(StringReader(config2)) + val vp2 = cp.convertProfile() + Assert.assertEquals(20400, vp2.mCompatMode) + Assert.assertEquals(2,Utils.mapCompatVer(vp2.mCompatMode)) + val conf2 = vp2.getConfigFile(c, false) + Assert.assertTrue(conf2.contains("compat-mode 2.4.0")); + + val config3 = config + "compat-mode 1.17.23\n"; + cp.parseConfig(StringReader(config3)) + val vp3 = cp.convertProfile() + Assert.assertEquals(11723, vp3.mCompatMode) + Assert.assertEquals(3,Utils.mapCompatVer(vp3.mCompatMode)) + + val conf = vp3.getConfigFile(c, false) + Assert.assertTrue(conf.contains("compat-mode 1.17.23")); + } + + @Test @Throws(IOException::class, ConfigParser.ConfigParseError::class) fun testSockProxyImport() { val proxy = "ca baz\n" + |