pytest_https_x509_bundle.py 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. # SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
  2. # SPDX-License-Identifier: Unlicense OR CC0-1.0
  3. import logging
  4. import os
  5. import pytest
  6. from common_test_methods import get_env_config_variable
  7. from pytest_embedded import Dut
  8. @pytest.mark.esp32
  9. @pytest.mark.ethernet
  10. def test_examples_protocol_https_x509_bundle(dut: Dut) -> None:
  11. """
  12. steps: |
  13. 1. join AP
  14. 2. connect to multiple URLs
  15. 3. send http request
  16. """
  17. # check and log bin size
  18. binary_file = os.path.join(dut.app.binary_path, 'https_x509_bundle.bin')
  19. bin_size = os.path.getsize(binary_file)
  20. logging.info('https_x509_bundle_bin_size : {}KB'.format(bin_size // 1024))
  21. # Connect to AP
  22. if dut.app.sdkconfig.get('EXAMPLE_WIFI_SSID_PWD_FROM_STDIN') is True:
  23. dut.expect('Please input ssid password:')
  24. env_name = 'wifi_ap'
  25. ap_ssid = get_env_config_variable(env_name, 'ap_ssid')
  26. ap_password = get_env_config_variable(env_name, 'ap_password')
  27. dut.write(f'{ap_ssid} {ap_password}')
  28. dut.expect(r'IPv4 address: (\d+\.\d+\.\d+\.\d+)[^\d]', timeout=30)
  29. # start test
  30. num_URLS = int(dut.expect(r'Connecting to (\d+) URLs', timeout=30)[1].decode())
  31. dut.expect(r'Connection established to ([\s\S]*)', timeout=30)
  32. dut.expect('Completed {} connections'.format(num_URLS), timeout=60)
  33. @pytest.mark.esp32
  34. @pytest.mark.ethernet
  35. @pytest.mark.parametrize('config', ['ssldyn',], indirect=True)
  36. def test_examples_protocol_https_x509_bundle_dynamic_buffer(dut: Dut) -> None:
  37. # test mbedtls dynamic resource
  38. # check and log bin size
  39. binary_file = os.path.join(dut.app.binary_path, 'https_x509_bundle.bin')
  40. bin_size = os.path.getsize(binary_file)
  41. logging.info('https_x509_bundle_bin_size : {}KB'.format(bin_size // 1024))
  42. # Connect to AP
  43. if dut.app.sdkconfig.get('EXAMPLE_WIFI_SSID_PWD_FROM_STDIN') is True:
  44. dut.expect('Please input ssid password:')
  45. env_name = 'wifi_ap'
  46. ap_ssid = get_env_config_variable(env_name, 'ap_ssid')
  47. ap_password = get_env_config_variable(env_name, 'ap_password')
  48. dut.write(f'{ap_ssid} {ap_password}')
  49. dut.expect(r'IPv4 address: (\d+\.\d+\.\d+\.\d+)[^\d]', timeout=30)
  50. # start test
  51. num_URLS = int(dut.expect(r'Connecting to (\d+) URLs', timeout=30)[1].decode())
  52. dut.expect(r'Connection established to ([\s\S]*)', timeout=30)
  53. dut.expect('Completed {} connections'.format(num_URLS), timeout=60)