diff --git a/examples/protocols/esp_local_ctrl/pytest_esp_local_ctrl.py b/examples/protocols/esp_local_ctrl/pytest_esp_local_ctrl.py index 3adab74337..ebb8aacaa2 100644 --- a/examples/protocols/esp_local_ctrl/pytest_esp_local_ctrl.py +++ b/examples/protocols/esp_local_ctrl/pytest_esp_local_ctrl.py @@ -9,6 +9,7 @@ import sys import pexpect import pytest +from common_test_methods import get_env_config from pytest_embedded import Dut @@ -45,6 +46,12 @@ def test_examples_esp_local_ctrl(dut: Dut) -> None: rel_project_path = os.path.join('examples', 'protocols', 'esp_local_ctrl') idf_path = get_sdk_path() + if dut.app.sdkconfig.get('EXAMPLE_WIFI_SSID_PWD_FROM_STDIN') is True: + env_config = get_env_config('wifi_router') + ap_ssid = env_config['ap_ssid'] + ap_password = env_config['ap_password'] + dut.expect('Please input ssid password:') + dut.write(' '.join([ap_ssid, ap_password])) dut_ip = dut.expect(r'IPv4 address: (\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})')[1].decode() dut.expect('esp_https_server: Starting server') dut.expect('esp_https_server: Server listening on port 443') diff --git a/examples/protocols/esp_local_ctrl/sdkconfig.ci b/examples/protocols/esp_local_ctrl/sdkconfig.ci new file mode 100644 index 0000000000..543e69e76e --- /dev/null +++ b/examples/protocols/esp_local_ctrl/sdkconfig.ci @@ -0,0 +1 @@ +CONFIG_EXAMPLE_WIFI_SSID_PWD_FROM_STDIN=y diff --git a/examples/protocols/http_server/advanced_tests/pytest_http_server_advanced.py b/examples/protocols/http_server/advanced_tests/pytest_http_server_advanced.py index c339321dae..1bb2e1e85d 100644 --- a/examples/protocols/http_server/advanced_tests/pytest_http_server_advanced.py +++ b/examples/protocols/http_server/advanced_tests/pytest_http_server_advanced.py @@ -17,6 +17,7 @@ except ModuleNotFoundError: sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', '..', '..', 'tools', 'ci', 'python_packages')) from idf_http_server_test import test as client +from common_test_methods import get_env_config from pytest_embedded import Dut # When running on local machine execute the following before running this script @@ -47,6 +48,12 @@ def test_examples_protocol_http_server_advanced(dut: Dut) -> None: # Parse IP address of STA logging.info('Waiting to connect with AP') + if dut.app.sdkconfig.get('EXAMPLE_WIFI_SSID_PWD_FROM_STDIN') is True: + env_config = get_env_config('wifi_router') + ap_ssid = env_config['ap_ssid'] + ap_password = env_config['ap_password'] + dut.expect('Please input ssid password:') + dut.write(' '.join([ap_ssid, ap_password])) got_ip = dut.expect(r'IPv4 address: (\d+\.\d+\.\d+\.\d+)', timeout=30)[1].decode() got_port = dut.expect(r"(?:[\s\S]*)Started HTTP server on port: '(\d+)'", timeout=30)[1].decode() diff --git a/examples/protocols/http_server/advanced_tests/sdkconfig.ci b/examples/protocols/http_server/advanced_tests/sdkconfig.ci new file mode 100644 index 0000000000..543e69e76e --- /dev/null +++ b/examples/protocols/http_server/advanced_tests/sdkconfig.ci @@ -0,0 +1 @@ +CONFIG_EXAMPLE_WIFI_SSID_PWD_FROM_STDIN=y diff --git a/examples/protocols/http_server/persistent_sockets/pytest_http_server_persistence.py b/examples/protocols/http_server/persistent_sockets/pytest_http_server_persistence.py index d0245f943f..d20db381af 100644 --- a/examples/protocols/http_server/persistent_sockets/pytest_http_server_persistence.py +++ b/examples/protocols/http_server/persistent_sockets/pytest_http_server_persistence.py @@ -19,6 +19,7 @@ except ModuleNotFoundError: sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', '..', '..', 'tools', 'ci', 'python_packages')) from idf_http_server_test import adder as client +from common_test_methods import get_env_config from pytest_embedded import Dut # When running on local machine execute the following before running this script @@ -43,6 +44,12 @@ def test_examples_protocol_http_server_persistence(dut: Dut) -> None: # Parse IP address of STA logging.info('Waiting to connect with AP') + if dut.app.sdkconfig.get('EXAMPLE_WIFI_SSID_PWD_FROM_STDIN') is True: + env_config = get_env_config('wifi_router') + ap_ssid = env_config['ap_ssid'] + ap_password = env_config['ap_password'] + dut.expect('Please input ssid password:') + dut.write(' '.join([ap_ssid, ap_password])) got_ip = dut.expect(r'IPv4 address: (\d+\.\d+\.\d+\.\d+)', timeout=30)[1].decode() got_port = dut.expect(r"(?:[\s\S]*)Starting server on port: '(\d+)'", timeout=30)[1].decode() diff --git a/examples/protocols/http_server/persistent_sockets/sdkconfig.ci b/examples/protocols/http_server/persistent_sockets/sdkconfig.ci new file mode 100644 index 0000000000..543e69e76e --- /dev/null +++ b/examples/protocols/http_server/persistent_sockets/sdkconfig.ci @@ -0,0 +1 @@ +CONFIG_EXAMPLE_WIFI_SSID_PWD_FROM_STDIN=y diff --git a/examples/protocols/http_server/simple/pytest_http_server_simple.py b/examples/protocols/http_server/simple/pytest_http_server_simple.py index 65a0c296ad..d4ab0ae7fb 100644 --- a/examples/protocols/http_server/simple/pytest_http_server_simple.py +++ b/examples/protocols/http_server/simple/pytest_http_server_simple.py @@ -23,6 +23,7 @@ except ModuleNotFoundError: sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', '..', '..', 'tools', 'ci', 'python_packages')) from idf_http_server_test import client +from common_test_methods import get_env_config from pytest_embedded import Dut @@ -75,6 +76,12 @@ def test_examples_protocol_http_server_simple(dut: Dut) -> None: # Parse IP address of STA logging.info('Waiting to connect with AP') + if dut.app.sdkconfig.get('EXAMPLE_WIFI_SSID_PWD_FROM_STDIN') is True: + env_config = get_env_config('wifi_router') + ap_ssid = env_config['ap_ssid'] + ap_password = env_config['ap_password'] + dut.expect('Please input ssid password:') + dut.write(' '.join([ap_ssid, ap_password])) got_ip = dut.expect(r'IPv4 address: (\d+\.\d+\.\d+\.\d+)', timeout=30)[1].decode() got_port = dut.expect(r"(?:[\s\S]*)Starting server on port: '(\d+)'", timeout=30)[1].decode() @@ -143,6 +150,12 @@ def test_examples_protocol_http_server_lru_purge_enable(dut: Dut) -> None: # Parse IP address of STA logging.info('Waiting to connect with AP') + if dut.app.sdkconfig.get('EXAMPLE_WIFI_SSID_PWD_FROM_STDIN') is True: + env_config = get_env_config('wifi_router') + ap_ssid = env_config['ap_ssid'] + ap_password = env_config['ap_password'] + dut.expect('Please input ssid password:') + dut.write(' '.join([ap_ssid, ap_password])) got_ip = dut.expect(r'IPv4 address: (\d+\.\d+\.\d+\.\d+)', timeout=30)[1].decode() got_port = dut.expect(r"(?:[\s\S]*)Starting server on port: '(\d+)'", timeout=30)[1].decode() diff --git a/examples/protocols/http_server/simple/sdkconfig.ci b/examples/protocols/http_server/simple/sdkconfig.ci index d022d0a55d..e1f72a625c 100644 --- a/examples/protocols/http_server/simple/sdkconfig.ci +++ b/examples/protocols/http_server/simple/sdkconfig.ci @@ -1 +1,2 @@ CONFIG_EXAMPLE_BASIC_AUTH=y +CONFIG_EXAMPLE_WIFI_SSID_PWD_FROM_STDIN=y diff --git a/examples/protocols/http_server/ws_echo_server/pytest_ws_server_example.py b/examples/protocols/http_server/ws_echo_server/pytest_ws_server_example.py index 04ed4b3af6..c76f4030ff 100644 --- a/examples/protocols/http_server/ws_echo_server/pytest_ws_server_example.py +++ b/examples/protocols/http_server/ws_echo_server/pytest_ws_server_example.py @@ -9,6 +9,7 @@ import logging import os import pytest +from common_test_methods import get_env_config from pytest_embedded import Dut try: @@ -62,6 +63,12 @@ def test_examples_protocol_http_ws_echo_server(dut: Dut) -> None: # Parse IP address of STA logging.info('Waiting to connect with AP') + if dut.app.sdkconfig.get('EXAMPLE_WIFI_SSID_PWD_FROM_STDIN') is True: + env_config = get_env_config('wifi_router') + ap_ssid = env_config['ap_ssid'] + ap_password = env_config['ap_password'] + dut.expect('Please input ssid password:') + dut.write(' '.join([ap_ssid, ap_password])) got_ip = dut.expect(r'IPv4 address: (\d+\.\d+\.\d+\.\d+)', timeout=30)[1].decode() got_port = dut.expect(r"Starting server on port: '(\d+)'", timeout=30)[1].decode() diff --git a/examples/protocols/http_server/ws_echo_server/sdkconfig.ci b/examples/protocols/http_server/ws_echo_server/sdkconfig.ci index 757c0adcca..6110153c28 100644 --- a/examples/protocols/http_server/ws_echo_server/sdkconfig.ci +++ b/examples/protocols/http_server/ws_echo_server/sdkconfig.ci @@ -1 +1,2 @@ CONFIG_LOG_DEFAULT_LEVEL_DEBUG=y +CONFIG_EXAMPLE_WIFI_SSID_PWD_FROM_STDIN=y diff --git a/examples/protocols/https_server/simple/pytest_https_server_simple.py b/examples/protocols/https_server/simple/pytest_https_server_simple.py index f86eb3c606..bc86c4a45a 100644 --- a/examples/protocols/https_server/simple/pytest_https_server_simple.py +++ b/examples/protocols/https_server/simple/pytest_https_server_simple.py @@ -9,6 +9,7 @@ import os import ssl import pytest +from common_test_methods import get_env_config from pytest_embedded import Dut server_cert_pem = '-----BEGIN CERTIFICATE-----\n'\ @@ -106,11 +107,16 @@ def test_examples_protocol_https_server_simple(dut: Dut) -> None: bin_size = os.path.getsize(binary_file) logging.info('https_server_simple_bin_size : {}KB'.format(bin_size // 1024)) # start test + logging.info('Waiting to connect with AP') + if dut.app.sdkconfig.get('EXAMPLE_WIFI_SSID_PWD_FROM_STDIN') is True: + env_config = get_env_config('wifi_router') + ap_ssid = env_config['ap_ssid'] + ap_password = env_config['ap_password'] + dut.expect('Please input ssid password:') + dut.write(' '.join([ap_ssid, ap_password])) # Parse IP address and port of the server dut.expect(r'Starting server') got_port = int(dut.expect(r'Server listening on port (\d+)', timeout=30)[1].decode()) - logging.info('Waiting to connect with AP') - got_ip = dut.expect(r'IPv4 address: (\d+\.\d+\.\d+\.\d+)', timeout=30)[1].decode() # Expected logs @@ -174,11 +180,16 @@ def test_examples_protocol_https_server_simple_dynamic_buffers(dut: Dut) -> None # Test with mbedTLS dynamic buffer feature # start test + logging.info('Waiting to connect with AP') + if dut.app.sdkconfig.get('EXAMPLE_WIFI_SSID_PWD_FROM_STDIN') is True: + env_config = get_env_config('wifi_router') + ap_ssid = env_config['ap_ssid'] + ap_password = env_config['ap_password'] + dut.expect('Please input ssid password:') + dut.write(' '.join([ap_ssid, ap_password])) # Parse IP address and port of the server dut.expect(r'Starting server') got_port = int(dut.expect(r'Server listening on port (\d+)', timeout=30)[1].decode()) - logging.info('Waiting to connect with AP') - got_ip = dut.expect(r'IPv4 address: (\d+\.\d+\.\d+\.\d+)', timeout=30)[1].decode() # Expected logs diff --git a/examples/protocols/https_server/simple/sdkconfig.ci b/examples/protocols/https_server/simple/sdkconfig.ci index 084692470b..84ffce91b8 100644 --- a/examples/protocols/https_server/simple/sdkconfig.ci +++ b/examples/protocols/https_server/simple/sdkconfig.ci @@ -1,2 +1,3 @@ CONFIG_ESP_HTTPS_SERVER_ENABLE=y CONFIG_EXAMPLE_ENABLE_HTTPS_USER_CALLBACK=y +CONFIG_EXAMPLE_WIFI_SSID_PWD_FROM_STDIN=y diff --git a/examples/protocols/https_server/simple/sdkconfig.ci.dynamic_buffer b/examples/protocols/https_server/simple/sdkconfig.ci.dynamic_buffer index 506d118f8e..3abca03116 100644 --- a/examples/protocols/https_server/simple/sdkconfig.ci.dynamic_buffer +++ b/examples/protocols/https_server/simple/sdkconfig.ci.dynamic_buffer @@ -1,5 +1,6 @@ CONFIG_ESP_HTTPS_SERVER_ENABLE=y CONFIG_EXAMPLE_ENABLE_HTTPS_USER_CALLBACK=y +CONFIG_EXAMPLE_WIFI_SSID_PWD_FROM_STDIN=y CONFIG_MBEDTLS_DYNAMIC_BUFFER=y CONFIG_MBEDTLS_DYNAMIC_FREE_CONFIG_DATA=y CONFIG_MBEDTLS_DYNAMIC_FREE_CA_CERT=y diff --git a/examples/protocols/https_server/wss_server/pytest_https_wss_server.py b/examples/protocols/https_server/wss_server/pytest_https_wss_server.py index fe3e0b2bd3..552f64e28f 100644 --- a/examples/protocols/https_server/wss_server/pytest_https_wss_server.py +++ b/examples/protocols/https_server/wss_server/pytest_https_wss_server.py @@ -14,6 +14,7 @@ from typing import Any, Optional import pytest import websocket +from common_test_methods import get_env_config from pytest_embedded import Dut OPCODE_TEXT = 0x1 @@ -119,10 +120,15 @@ def test_examples_protocol_https_wss_server(dut: Dut) -> None: logging.info('Starting wss_server test app') + logging.info('Waiting to connect with AP') + if dut.app.sdkconfig.get('EXAMPLE_WIFI_SSID_PWD_FROM_STDIN') is True: + env_config = get_env_config('wifi_router') + ap_ssid = env_config['ap_ssid'] + ap_password = env_config['ap_password'] + dut.expect('Please input ssid password:') + dut.write(' '.join([ap_ssid, ap_password])) # Parse IP address of STA got_port = int(dut.expect(r'Server listening on port (\d+)', timeout=30)[1].decode()) - logging.info('Waiting to connect with AP') - got_ip = dut.expect(r'IPv4 address: (\d+\.\d+\.\d+\.\d+)', timeout=30)[1].decode() logging.info('Got IP : {}'.format(got_ip)) diff --git a/examples/protocols/https_server/wss_server/sdkconfig.ci b/examples/protocols/https_server/wss_server/sdkconfig.ci new file mode 100644 index 0000000000..543e69e76e --- /dev/null +++ b/examples/protocols/https_server/wss_server/sdkconfig.ci @@ -0,0 +1 @@ +CONFIG_EXAMPLE_WIFI_SSID_PWD_FROM_STDIN=y diff --git a/examples/protocols/https_x509_bundle/pytest_https_x509_bundle.py b/examples/protocols/https_x509_bundle/pytest_https_x509_bundle.py index e48eb1050d..b722953a01 100644 --- a/examples/protocols/https_x509_bundle/pytest_https_x509_bundle.py +++ b/examples/protocols/https_x509_bundle/pytest_https_x509_bundle.py @@ -4,6 +4,7 @@ import logging import os import pytest +from common_test_methods import get_env_config from pytest_embedded import Dut @@ -11,7 +12,7 @@ from pytest_embedded import Dut @pytest.mark.esp32c3 @pytest.mark.esp32s2 @pytest.mark.esp32s3 -@pytest.mark.wifi_router +@pytest.mark.wifi_nearby def test_examples_protocol_https_x509_bundle(dut: Dut) -> None: """ steps: | @@ -23,6 +24,14 @@ def test_examples_protocol_https_x509_bundle(dut: Dut) -> None: binary_file = os.path.join(dut.app.binary_path, 'https_x509_bundle.bin') bin_size = os.path.getsize(binary_file) logging.info('https_x509_bundle_bin_size : {}KB'.format(bin_size // 1024)) + # Connect to AP + if dut.app.sdkconfig.get('EXAMPLE_WIFI_SSID_PWD_FROM_STDIN') is True: + env_config = get_env_config('wifi_nearby') + ap_ssid = env_config['ap_ssid'] + ap_password = env_config['ap_password'] + dut.expect('Please input ssid password:') + dut.write(' '.join([ap_ssid, ap_password])) + dut.expect(r'IPv4 address: (\d+\.\d+\.\d+\.\d+)', timeout=30) # start test num_URLS = int(dut.expect(r'Connecting to (\d+) URLs', timeout=30)[1].decode()) dut.expect(r'Connection established to ([\s\S]*)', timeout=30) @@ -33,7 +42,7 @@ def test_examples_protocol_https_x509_bundle(dut: Dut) -> None: @pytest.mark.esp32c3 @pytest.mark.esp32s2 @pytest.mark.esp32s3 -@pytest.mark.wifi_router +@pytest.mark.wifi_nearby @pytest.mark.parametrize('config', ['ssldyn',], indirect=True) def test_examples_protocol_https_x509_bundle_dynamic_buffer(dut: Dut) -> None: # test mbedtls dynamic resource @@ -41,6 +50,14 @@ def test_examples_protocol_https_x509_bundle_dynamic_buffer(dut: Dut) -> None: binary_file = os.path.join(dut.app.binary_path, 'https_x509_bundle.bin') bin_size = os.path.getsize(binary_file) logging.info('https_x509_bundle_bin_size : {}KB'.format(bin_size // 1024)) + # Connect to AP + if dut.app.sdkconfig.get('EXAMPLE_WIFI_SSID_PWD_FROM_STDIN') is True: + env_config = get_env_config('wifi_nearby') + ap_ssid = env_config['ap_ssid'] + ap_password = env_config['ap_password'] + dut.expect('Please input ssid password:') + dut.write(' '.join([ap_ssid, ap_password])) + dut.expect(r'IPv4 address: (\d+\.\d+\.\d+\.\d+)', timeout=30) # start test num_URLS = int(dut.expect(r'Connecting to (\d+) URLs', timeout=30)[1].decode()) dut.expect(r'Connection established to ([\s\S]*)', timeout=30) diff --git a/examples/protocols/https_x509_bundle/sdkconfig.ci b/examples/protocols/https_x509_bundle/sdkconfig.ci index 7011410ad3..cd5b3811fa 100644 --- a/examples/protocols/https_x509_bundle/sdkconfig.ci +++ b/examples/protocols/https_x509_bundle/sdkconfig.ci @@ -1,3 +1,4 @@ CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_NONE=y CONFIG_MBEDTLS_CUSTOM_CERTIFICATE_BUNDLE=y CONFIG_MBEDTLS_CUSTOM_CERTIFICATE_BUNDLE_PATH="certs" +CONFIG_EXAMPLE_WIFI_SSID_PWD_FROM_STDIN=y diff --git a/examples/protocols/https_x509_bundle/sdkconfig.ci.ssldyn b/examples/protocols/https_x509_bundle/sdkconfig.ci.ssldyn index 4854bdde4c..bb5ca1c44d 100644 --- a/examples/protocols/https_x509_bundle/sdkconfig.ci.ssldyn +++ b/examples/protocols/https_x509_bundle/sdkconfig.ci.ssldyn @@ -4,3 +4,4 @@ CONFIG_MBEDTLS_CUSTOM_CERTIFICATE_BUNDLE_PATH="certs" CONFIG_MBEDTLS_DYNAMIC_BUFFER=y CONFIG_MBEDTLS_DYNAMIC_FREE_PEER_CERT=y CONFIG_MBEDTLS_DYNAMIC_FREE_CONFIG_DATA=y +CONFIG_EXAMPLE_WIFI_SSID_PWD_FROM_STDIN=y