pytest_https_x509_bundle.py 2.5 KB

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