example.py 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. # Copyright 2015-2017 Espressif Systems (Shanghai) PTE LTD
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License at
  6. #
  7. # http:#www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software
  10. # distributed under the License is distributed on an "AS IS" BASIS,
  11. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. # See the License for the specific language governing permissions and
  13. # limitations under the License.
  14. """ example of writing test with TinyTestFW """
  15. import re
  16. import ttfw_idf
  17. from tiny_test_fw import TinyFW
  18. @ttfw_idf.idf_example_test(env_tag='Example_WIFI')
  19. def test_examples_protocol_https_request(env, extra_data):
  20. """
  21. steps: |
  22. 1. join AP
  23. 2. connect to www.howsmyssl.com:443
  24. 3. send http request
  25. """
  26. dut1 = env.get_dut('https_request', 'examples/protocols/https_request', dut_class=ttfw_idf.ESP32DUT)
  27. dut1.start_app()
  28. dut1.expect(re.compile(r'Connecting to www.howsmyssl.com:443'), timeout=30)
  29. dut1.expect('Performing the SSL/TLS handshake')
  30. dut1.expect('Certificate verified.', timeout=15)
  31. dut1.expect_all(re.compile(r'Cipher suite is TLS-ECDHE-RSA-WITH-AES-128-GCM-SHA256'),
  32. 'Reading HTTP response',
  33. timeout=20)
  34. dut1.expect(re.compile(r'Completed (\d) requests'))
  35. if __name__ == '__main__':
  36. TinyFW.set_default_config(env_config_file='EnvConfigTemplate.yml', dut=ttfw_idf.IDFDUT)
  37. test_examples_protocol_https_request()