diff options
Diffstat (limited to 'tests/accel-pppd/general')
-rw-r--r-- | tests/accel-pppd/general/test_basic.py | 83 | ||||
-rw-r--r-- | tests/accel-pppd/general/test_pcre_negative_cases.py | 65 |
2 files changed, 148 insertions, 0 deletions
diff --git a/tests/accel-pppd/general/test_basic.py b/tests/accel-pppd/general/test_basic.py new file mode 100644 index 00000000..9652ee0b --- /dev/null +++ b/tests/accel-pppd/general/test_basic.py @@ -0,0 +1,83 @@ +import pytest +from common import process + + +def test_accel_pppd_version(accel_pppd): + (exit, out, err) = process.run([accel_pppd, "--version"]) + + # test that accel-pppd --version exits with code 0, prints + # nothing to stdout and prints to stdout + assert exit == 0 and err == "" and "accel-ppp " in out and len(out.split(" ")) == 2 + + +@pytest.fixture() +def accel_pppd_config(): + return """ + [modules] + log_file + log_syslog + log_tcp + #log_pgsql + + connlimit + pptp + l2tp + sstp + radius + pppoe + ipoe + + auth_mschap_v2 + auth_mschap_v1 + auth_chap_md5 + auth_pap + + chap-secrets + + ippool + + pppd_compat + shaper + #net-snmp + logwtmp + + ipv6_nd + ipv6_dhcp + ipv6pool + + [core] + log-error=/dev/stderr + + [log] + log-debug=/dev/stdout + log-file=/dev/stdout + log-emerg=/dev/stderr + level=5 + + [cli] + tcp=127.0.0.1:2001 + + [pppoe] + + [client-ip-range] + 10.0.0.0/8 + + [radius] + """ + + +# load all modules and check that accel-pppd replies to 'show stat' command +def test_load_all_modules(accel_pppd_instance, accel_cmd): + + # test that accel-pppd started successfully + assert accel_pppd_instance + + (exit_sh_stat, out_sh_stat, err_sh_stat) = process.run([accel_cmd, "show stat"]) + + # test that 'show stat' has no errors and contains 'uptime' + assert ( + exit_sh_stat == 0 + and len(out_sh_stat) > 1 + and err_sh_stat == "" + and "uptime" in out_sh_stat + ) diff --git a/tests/accel-pppd/general/test_pcre_negative_cases.py b/tests/accel-pppd/general/test_pcre_negative_cases.py new file mode 100644 index 00000000..698c83ab --- /dev/null +++ b/tests/accel-pppd/general/test_pcre_negative_cases.py @@ -0,0 +1,65 @@ +import pytest +from common import process + + +@pytest.fixture() +def accel_pppd_config(): + return """ + [modules] + radius + pppoe + + [core] + log-error=/dev/stderr + + [log] + log-debug=/dev/stdout + log-file=/dev/stdout + log-emerg=/dev/stderr + level=5 + + [cli] + tcp=127.0.0.1:2001 + + [radius] + + [pppoe] + """ + + +# test pcre-related negative cases +def test_pcre_negative_cases(accel_pppd_instance, accel_cmd): + + # test that accel-pppd started successfully + assert accel_pppd_instance + + (exit_sh_sess, out_sh_sess, err_sh_sess) = process.run([accel_cmd, "show sessions match username 00("]) + # test that 'show sessions' with invalid regexp reports the issue and error position + assert ( + exit_sh_sess == 0 + and len(out_sh_sess) > 0 + and err_sh_sess == "" + and "match: " in out_sh_sess + and "at 3" in out_sh_sess + ) + + + (exit_iface_add, out_iface_add, err_iface_add) = process.run([accel_cmd, "pppoe interface add re:000("]) + # test that 'pppoe interface add' with invalid regexp reports the issue and error position + assert ( + exit_iface_add == 0 + and len(out_iface_add) > 0 + and err_iface_add == "" + and "pppoe: " in out_iface_add + and "at 4" in out_iface_add + ) + + (exit_term, out_term, err_term) = process.run([accel_cmd, "terminate match username 00("]) + # test that 'terminate' with invalid regexp reports the issue and error position + assert ( + exit_term == 0 + and len(out_term) > 0 + and err_term == "" + and "match: " in out_term + and "at 3" in out_term + ) |