Skip to content

Commit

Permalink
[tests] Fixed test
Browse files Browse the repository at this point in the history
  • Loading branch information
nemesifier committed Nov 21, 2024
1 parent 953a1b5 commit 399c68a
Showing 1 changed file with 76 additions and 2 deletions.
78 changes: 76 additions & 2 deletions tests/openvpn/test_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,82 @@ def test_parse_text(self):
}
self.assertDictEqual(o.config, expected)

def test_parse_server(self):
native = """# openvpn config: test-server
auth SHA1
auth-nocache
ca ca.pem
cert cert.pem
cipher AES-128-GCM
comp-lzo adaptive
crl-verify crl.pem
dev tap0
dev-type tap
dh dh.pem
duplicate-cn
engine rsax
fast-io
group nogroup
keepalive 20 60
key key.pem
log /var/log/openvpn.log
mode server
mssfix 1450
mtu-disc no
mute-replay-warnings
persist-key
persist-tun
port 1194
proto udp
script-security 0
status /var/log/openvpn.status 10
status-version 1
tls-server
user nobody
verb 3
"""
expected = {
"openvpn": [
{
"auth": "SHA1",
"auth_nocache": True,
"ca": "ca.pem",
"cert": "cert.pem",
"cipher": "AES-128-GCM",
"comp_lzo": "adaptive",
"crl_verify": "crl.pem",
"dev": "tap0",
"dev_type": "tap",
"dh": "dh.pem",
"duplicate_cn": True,
"engine": "rsax",
"fast_io": True,
"group": "nogroup",
"keepalive": "20 60",
"key": "key.pem",
"log": "/var/log/openvpn.log",
"mode": "server",
"name": "test-server",
"mssfix": 1450,
"mtu_disc": "no",
"mute_replay_warnings": True,
"persist_key": True,
"persist_tun": True,
"port": 1194,
"proto": "udp",
"script_security": 0,
"status": "/var/log/openvpn.status 10",
"status_version": 1,
"tls_server": True,
"user": "nobody",
"verb": 3,
}
]
}
o = OpenVpn(native=native)
self.assertDictEqual(o.config, expected)

def test_parse_data_ciphers(self):
native = """# openvpn config: test-server
Expand Down Expand Up @@ -119,7 +195,6 @@ def test_parse_data_ciphers(self):
"name": "test-server",
"mssfix": 1450,
"mtu_disc": "no",
"mtu_test": False,
"mute_replay_warnings": True,
"persist_key": True,
"persist_tun": True,
Expand All @@ -129,7 +204,6 @@ def test_parse_data_ciphers(self):
"status": "/var/log/openvpn.status 10",
"status_version": 1,
"tls_server": True,
"tun_ipv6": False,
"user": "nobody",
"verb": 3,
}
Expand Down

0 comments on commit 399c68a

Please sign in to comment.