summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorSergey V. Lobanov <sergey@lobanov.in>2024-08-19 20:01:11 +0000
committerSergey V. Lobanov <sergey@lobanov.in>2024-08-19 20:01:11 +0000
commit3498d52d7eb33b33b16d0ceef44ed3b52debdd5c (patch)
tree173d70d427091a0299bd9cd86b5e5de424177aa8 /tests
parent0eb54934a8746091a5f3eef2ae0db726975c24da (diff)
downloadaccel-ppp-3498d52d7eb33b33b16d0ceef44ed3b52debdd5c.tar.gz
accel-ppp-3498d52d7eb33b33b16d0ceef44ed3b52debdd5c.zip
tests: add pcre negative cases, improve pcre-related code test coverage
these test cases will help for pcre2 migration (issue #173)
Diffstat (limited to 'tests')
-rw-r--r--tests/accel-pppd/general/test_basic.py (renamed from tests/accel-pppd/test_basic.py)0
-rw-r--r--tests/accel-pppd/general/test_pcre_negative_cases.py55
-rw-r--r--tests/accel-pppd/ipoe/dhcpv4/test_ipoe_shared_session_wo_auth.py4
-rw-r--r--tests/accel-pppd/pppoe/test_pppoe_session_wo_auth.py2
4 files changed, 58 insertions, 3 deletions
diff --git a/tests/accel-pppd/test_basic.py b/tests/accel-pppd/general/test_basic.py
index 2b2c6f71..2b2c6f71 100644
--- a/tests/accel-pppd/test_basic.py
+++ b/tests/accel-pppd/general/test_basic.py
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..7ad05ff3
--- /dev/null
+++ b/tests/accel-pppd/general/test_pcre_negative_cases.py
@@ -0,0 +1,55 @@
+import pytest
+from common import process
+
+
+@pytest.fixture()
+def accel_pppd_config():
+ return """
+ [modules]
+ pppoe
+
+ [log]
+ log-debug=/dev/stdout
+ level=5
+
+ [cli]
+ tcp=127.0.0.1:2001
+ """
+
+
+# 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
+ )
diff --git a/tests/accel-pppd/ipoe/dhcpv4/test_ipoe_shared_session_wo_auth.py b/tests/accel-pppd/ipoe/dhcpv4/test_ipoe_shared_session_wo_auth.py
index 104e4e9b..da9a40e0 100644
--- a/tests/accel-pppd/ipoe/dhcpv4/test_ipoe_shared_session_wo_auth.py
+++ b/tests/accel-pppd/ipoe/dhcpv4/test_ipoe_shared_session_wo_auth.py
@@ -28,8 +28,8 @@ def accel_pppd_config(veth_pair_netns):
noauth=1
shared=1
gw-ip-address=192.0.2.1/24
- interface="""
- + veth_pair_netns["veth_a"]
+ interface=re:."""
+ + veth_pair_netns["veth_a"][1:]
)
diff --git a/tests/accel-pppd/pppoe/test_pppoe_session_wo_auth.py b/tests/accel-pppd/pppoe/test_pppoe_session_wo_auth.py
index 0c8aa2c0..5ce870dd 100644
--- a/tests/accel-pppd/pppoe/test_pppoe_session_wo_auth.py
+++ b/tests/accel-pppd/pppoe/test_pppoe_session_wo_auth.py
@@ -69,7 +69,7 @@ def test_pppoe_session_wo_auth(pppd_instance, accel_cmd):
(exit, out, err) = process.run(
[
accel_cmd,
- "show sessions match username loginAB username,ip,state",
+ "show sessions match username log.nAB username,ip,state",
]
)
assert exit == 0 # accel-cmd fails