feat(modem): Added target test config with CHAP authentication

Related to https://github.com/espressif/esp-protocols/issues/635
This commit is contained in:
David Cermak
2024-08-23 17:17:11 +02:00
parent 73c48307a3
commit f8ae7defd6
6 changed files with 41 additions and 14 deletions

View File

@ -15,7 +15,7 @@ jobs:
matrix: matrix:
idf_ver: ["latest"] idf_ver: ["latest"]
idf_target: ["esp32c3"] idf_target: ["esp32c3"]
test: [ { app: pppd, path: test/target }, { app: sim800_c3, path: examples/pppos_client }, { app: sim800_cmux, path: examples/simple_cmux_client } ] test: [ { app: pppd, path: test/target }, { app: pppd_chap_auth, path: test/target }, { app: sim800_c3, path: examples/pppos_client }, { app: sim800_cmux, path: examples/simple_cmux_client } ]
include: include:
- idf_ver: "latest" - idf_ver: "latest"
idf_target: "esp32s2" idf_target: "esp32s2"
@ -58,7 +58,7 @@ jobs:
matrix: matrix:
idf_ver: ["latest"] idf_ver: ["latest"]
idf_target: ["esp32c3"] idf_target: ["esp32c3"]
test: [ { app: pppd, path: test/target }, { app: sim800_c3, path: examples/pppos_client }, { app: sim800_cmux, path: examples/simple_cmux_client } ] test: [ { app: pppd, path: test/target }, { app: pppd_chap_auth, path: test/target }, { app: sim800_c3, path: examples/pppos_client }, { app: sim800_cmux, path: examples/simple_cmux_client } ]
include: include:
- idf_ver: "latest" - idf_ver: "latest"
idf_target: "esp32s2" idf_target: "esp32s2"

View File

@ -27,12 +27,23 @@ menu "Test App Configuration"
help help
Pin number of UART RX. Pin number of UART RX.
config TEST_APP_TCP_PORT config TEST_APP_AUTH
int "Port of test" bool "Use PPP authentication"
range 0 65535 select LWIP_PPP_CHAP_SUPPORT
default 2222 default n
help help
The remote port to which the client will connects to Set to true for the PPP client to use authentication
once the PPP connection established
config TEST_APP_AUTH_USERNAME
string "Set username for authentication"
default "myclient"
help
Username to authenticate the PPP connection.
config TEST_APP_AUTH_PASSWORD
string "Set password for authentication"
default "mypassword"
help
Password to authenticate the PPP connection.
endmenu endmenu

View File

@ -94,6 +94,10 @@ extern "C" void app_main(void)
ESP_ERROR_CHECK(esp_event_handler_register(IP_EVENT, ESP_EVENT_ANY_ID, on_modem_event, nullptr)); ESP_ERROR_CHECK(esp_event_handler_register(IP_EVENT, ESP_EVENT_ANY_ID, on_modem_event, nullptr));
ESP_ERROR_CHECK(esp_event_handler_register(NETIF_PPP_STATUS, ESP_EVENT_ANY_ID, &on_ppp_changed, nullptr)); ESP_ERROR_CHECK(esp_event_handler_register(NETIF_PPP_STATUS, ESP_EVENT_ANY_ID, &on_ppp_changed, nullptr));
#if CONFIG_TEST_APP_AUTH
esp_netif_ppp_set_auth(ppp_netif, NETIF_PPP_AUTHTYPE_CHAP, CONFIG_TEST_APP_AUTH_USERNAME, CONFIG_TEST_APP_AUTH_PASSWORD);
#endif
modem_start_network(); modem_start_network();
Catch::Session session; Catch::Session session;
int numFailed = session.run(); int numFailed = session.run();

View File

@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD # SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD
# SPDX-License-Identifier: Unlicense OR CC0-1.0 # SPDX-License-Identifier: Unlicense OR CC0-1.0
from __future__ import print_function, unicode_literals from __future__ import print_function, unicode_literals
@ -9,14 +9,20 @@ from threading import Event, Thread
import netifaces import netifaces
def run_server(server_stop, port, server_ip, client_ip): def run_server(server_stop, port, server_ip, client_ip, auth, auth_user, auth_password):
print('Starting PPP server on port: {}'.format(port)) print('Starting PPP server on port: {}'.format(port))
try: try:
arg_list = [ arg_list = [
'sudo', 'pppd', port, '115200', 'sudo', 'pppd', port, '115200',
'{}:{}'.format(server_ip, client_ip), 'modem', 'local', 'noauth', '{}:{}'.format(server_ip, client_ip), 'modem', 'local',
'debug', 'nocrtscts', 'nodetach', '+ipv6' 'debug', 'nocrtscts', 'nodetach', '+ipv6'
] ]
if auth:
arg_list.extend(['auth', '+chap'])
subprocess.run(['sudo', 'rm', '/etc/ppp/chap-secrets'])
subprocess.run(f"echo '{auth_user} * {auth_password} *' | sudo tee -a /etc/ppp/chap-secrets", shell=True)
else:
arg_list.append('noauth')
p = subprocess.Popen(arg_list, stdout=subprocess.PIPE, bufsize=1) p = subprocess.Popen(arg_list, stdout=subprocess.PIPE, bufsize=1)
while not server_stop.is_set(): while not server_stop.is_set():
if p.poll() is not None: if p.poll() is not None:
@ -51,6 +57,9 @@ def test_examples_protocol_pppos_connect(dut):
try: try:
server_ip = dut.app.sdkconfig.get('TEST_APP_PPP_SERVER_IP') server_ip = dut.app.sdkconfig.get('TEST_APP_PPP_SERVER_IP')
client_ip = dut.app.sdkconfig.get('TEST_APP_PPP_CLIENT_IP') client_ip = dut.app.sdkconfig.get('TEST_APP_PPP_CLIENT_IP')
auth = dut.app.sdkconfig.get('TEST_APP_AUTH')
auth_user = dut.app.sdkconfig.get('TEST_APP_AUTH_USERNAME')
auth_password = dut.app.sdkconfig.get('TEST_APP_AUTH_PASSWORD')
except Exception: except Exception:
print( print(
'ENV_TEST_FAILURE: Some mandatory configuration not found in sdkconfig' 'ENV_TEST_FAILURE: Some mandatory configuration not found in sdkconfig'
@ -63,7 +72,7 @@ def test_examples_protocol_pppos_connect(dut):
# Start the PPP server # Start the PPP server
server_stop = Event() server_stop = Event()
t = Thread(target=run_server, t = Thread(target=run_server,
args=(server_stop, port, server_ip, client_ip)) args=(server_stop, port, server_ip, client_ip, auth, auth_user, auth_password))
t.start() t.start()
try: try:
ppp_server_timeout = time.time() + 30 ppp_server_timeout = time.time() + 30

View File

@ -0,0 +1,4 @@
CONFIG_COMPILER_CXX_EXCEPTIONS=y
CONFIG_ESP_MAIN_TASK_STACK_SIZE=4096
CONFIG_LWIP_PPP_SUPPORT=y
CONFIG_TEST_APP_AUTH=y

View File

@ -1,4 +1,3 @@
CONFIG_COMPILER_CXX_EXCEPTIONS=y CONFIG_COMPILER_CXX_EXCEPTIONS=y
CONFIG_CXX_EXCEPTIONS=y
CONFIG_PPP_SUPPORT=y
CONFIG_ESP_MAIN_TASK_STACK_SIZE=4096 CONFIG_ESP_MAIN_TASK_STACK_SIZE=4096
CONFIG_LWIP_PPP_SUPPORT=y