diff options
author | Arne Schwabe <arne@rfc2549.org> | 2021-01-21 12:24:06 +0100 |
---|---|---|
committer | Arne Schwabe <arne@rfc2549.org> | 2021-02-16 16:40:04 +0100 |
commit | 96db8d0bf1110f029cf5ad90bc939cd444100600 (patch) | |
tree | b2d7915f465bdeee6847e171e72a5c28e7bd9b72 /main/src/test/java/de | |
parent | a965f961b5dc5cba44d9a81a538c11c4394de24e (diff) |
Implement UI support for --peer-fingerprint
Diffstat (limited to 'main/src/test/java/de')
-rw-r--r-- | main/src/test/java/de/blinkt/openvpn/core/TestConfigParser.kt | 40 |
1 files changed, 40 insertions, 0 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 2983982d..fbaa4be2 100644 --- a/main/src/test/java/de/blinkt/openvpn/core/TestConfigParser.kt +++ b/main/src/test/java/de/blinkt/openvpn/core/TestConfigParser.kt @@ -348,4 +348,44 @@ verify-x509-name homevpn.evil.cloud name Assert.assertFalse(config.contains("key-direction")) } + @Test + @Throws(IOException::class, ConfigParser.ConfigParseError::class) + fun testPeerFingerprint() { + val conf = """ +<cert> +dummy +</cert> +cipher AES-256-GCM +client +dev-type tun +<key> +dummykey +</key> +remote home.evil.cloud 65443 udp +"""; + val fps = """ + 28:45:c7:ad:6a:c4:83:c7:a0:0a:0a:91:4b:43:e3:09:79:05:a2:ce:c2:e2:5e:c9:70:5a:2b:a4:e1:0f:97:e3 + F8:FA:6D:CF:58:65:98:5F:E0:E7:2A:B4:25:ED:2C:DD:45:7B:21:C1:B7:46:1D:46:C3:2B:1D:1D:F7:0E:43:51 + ef:5c:fc:a4:d5:59:78:14:e0:87:66:0b:53:df:e5:1e:a1:39:e0:1f:7a:ca:ca:87:4e:78:8b:45:c7:3d:af:c7 + """.trimIndent() + val fpBlock = "<peer-fingerprint>\n${fps}\n</peer-fingerprint>" + + val fpSingle = "00:11:22:33:44:55:66:77:88:99:aa:bb:cc:dd:ee:ff:00:11:22:33:44:55:66:77:88:99:aa:bb:cc:dd:ee:ff" + val fpSingleCmd = "peer-fingerprint ${fpSingle}\n" + + val cp = ConfigParser() + cp.parseConfig(StringReader(conf + fpBlock)) + val vp = cp.convertProfile() + + Assert.assertTrue(vp.mCheckPeerFingerprint) + Assert.assertEquals(fps.trim(), vp.mPeerFingerPrints.trim()) + + cp.parseConfig(StringReader(conf + fpBlock + "\n" + fpSingleCmd)) + val vp2 = cp.convertProfile() + Assert.assertTrue(vp2.mCheckPeerFingerprint) + Assert.assertEquals((fps + "\n" + fpSingle).trim(), vp2.mPeerFingerPrints.trim()) + + + } + } |