mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-03 20:54:32 +02:00
CI: use ssid password from stdin for pytest cases
This commit is contained in:
@@ -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')
|
||||
|
1
examples/protocols/esp_local_ctrl/sdkconfig.ci
Normal file
1
examples/protocols/esp_local_ctrl/sdkconfig.ci
Normal file
@@ -0,0 +1 @@
|
||||
CONFIG_EXAMPLE_WIFI_SSID_PWD_FROM_STDIN=y
|
@@ -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()
|
||||
|
@@ -0,0 +1 @@
|
||||
CONFIG_EXAMPLE_WIFI_SSID_PWD_FROM_STDIN=y
|
@@ -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()
|
||||
|
||||
|
@@ -0,0 +1 @@
|
||||
CONFIG_EXAMPLE_WIFI_SSID_PWD_FROM_STDIN=y
|
@@ -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()
|
||||
|
||||
|
@@ -1 +1,2 @@
|
||||
CONFIG_EXAMPLE_BASIC_AUTH=y
|
||||
CONFIG_EXAMPLE_WIFI_SSID_PWD_FROM_STDIN=y
|
||||
|
@@ -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()
|
||||
|
||||
|
@@ -1 +1,2 @@
|
||||
CONFIG_LOG_DEFAULT_LEVEL_DEBUG=y
|
||||
CONFIG_EXAMPLE_WIFI_SSID_PWD_FROM_STDIN=y
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
|
@@ -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))
|
||||
|
1
examples/protocols/https_server/wss_server/sdkconfig.ci
Normal file
1
examples/protocols/https_server/wss_server/sdkconfig.ci
Normal file
@@ -0,0 +1 @@
|
||||
CONFIG_EXAMPLE_WIFI_SSID_PWD_FROM_STDIN=y
|
@@ -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)
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
|
Reference in New Issue
Block a user