summaryrefslogtreecommitdiff
path: root/tests/accel-pppd/pppoe/test_pppoe_session_chap_secrets.py
diff options
context:
space:
mode:
authorDenys Fedoryshchenko <denys.f@collabora.com>2024-09-05 10:43:15 +0300
committerGitHub <noreply@github.com>2024-09-05 10:43:15 +0300
commit3a6ee62003bd840ec86be4638d9e84d1cc1aa12b (patch)
treebe0eb2e5642f2be76f6f1ef9aae587231ac3a0b6 /tests/accel-pppd/pppoe/test_pppoe_session_chap_secrets.py
parent9b1ea1cc887d3e90cb9cbf7eb9e7f3eba073e46f (diff)
parent634d67196c30c69230b4382463aab414f0e9a279 (diff)
downloadaccel-ppp-3a6ee62003bd840ec86be4638d9e84d1cc1aa12b.tar.gz
accel-ppp-3a6ee62003bd840ec86be4638d9e84d1cc1aa12b.zip
Merge pull request #191 from svlobanov/test-pppoe-chap-secrets
tests: add test pppoe session using chap-secrets auth
Diffstat (limited to 'tests/accel-pppd/pppoe/test_pppoe_session_chap_secrets.py')
-rw-r--r--tests/accel-pppd/pppoe/test_pppoe_session_chap_secrets.py103
1 files changed, 103 insertions, 0 deletions
diff --git a/tests/accel-pppd/pppoe/test_pppoe_session_chap_secrets.py b/tests/accel-pppd/pppoe/test_pppoe_session_chap_secrets.py
new file mode 100644
index 00000000..e8ac472d
--- /dev/null
+++ b/tests/accel-pppd/pppoe/test_pppoe_session_chap_secrets.py
@@ -0,0 +1,103 @@
+import pytest
+from common import process
+import time
+
+
+@pytest.fixture()
+def chap_secrets_config():
+ return "loginCSAB * pass123 192.0.2.37"
+
+
+@pytest.fixture()
+def accel_pppd_config(veth_pair_netns, chap_secrets_config_file):
+ print(
+ "accel_pppd_config veth_pair_netns: "
+ + str(veth_pair_netns)
+ + "chap_secrets_config_file"
+ + str(chap_secrets_config_file)
+ )
+ return (
+ """
+ [modules]
+ chap-secrets
+ pppoe
+ auth_pap
+
+ [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]
+ interface="""
+ + veth_pair_netns["veth_a"]
+ + """
+ [chap-secrets]
+ gw-ip-address=192.0.2.1
+ chap-secrets="""
+ + chap_secrets_config_file
+ )
+
+
+@pytest.fixture()
+def pppd_config(veth_pair_netns):
+ print("pppd_config veth_pair_netns: " + str(veth_pair_netns))
+ return (
+ """
+ nodetach
+ noipdefault
+ defaultroute
+ connect /bin/true
+ noauth
+ persist
+ mtu 1492
+ noaccomp
+ default-asyncmap
+ user loginCSAB
+ password pass123
+ nic-"""
+ + veth_pair_netns["veth_b"]
+ )
+
+
+# test pppoe session without auth check
+def test_pppoe_session_chap_secrets(pppd_instance, accel_cmd):
+
+ # test that pppd (with accel-pppd) started successfully
+ assert pppd_instance["is_started"]
+
+ # wait until session is started
+ max_wait_time = 10.0
+ sleep_time = 0.0
+ is_started = False # is session started
+ while sleep_time < max_wait_time:
+ (exit, out, err) = process.run(
+ [
+ accel_cmd,
+ "show sessions match username log.nCSAB username,ip,state",
+ ]
+ )
+ assert exit == 0 # accel-cmd fails
+ # print(out)
+ if "loginCSAB" in out and "192.0.2.37" in out and "active" in out:
+ # session is found
+ print(
+ "test_pppoe_session_chap_secrets: session found in (sec): "
+ + str(sleep_time)
+ )
+ is_started = True
+ break
+ time.sleep(0.1)
+ sleep_time += 0.1
+
+ print("test_pppoe_session_chap_secrets: last accel-cmd out: " + out)
+
+ # test that session is started
+ assert is_started == True