From 8f77caa6375c980ba85a1da430f6c64120dff760 Mon Sep 17 00:00:00 2001 From: Laukik Hase Date: Wed, 30 Mar 2022 18:46:07 +0530 Subject: [PATCH] https_server: Fix example test failure - Closed the client connection gracefully for the https server callback check to pass in test - Made some functions static in the example --- examples/protocols/https_server/simple/example_test.py | 5 +++-- examples/protocols/https_server/simple/main/main.c | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/examples/protocols/https_server/simple/example_test.py b/examples/protocols/https_server/simple/example_test.py index 53bcc7e7e7..9b7c0e049b 100644 --- a/examples/protocols/https_server/simple/example_test.py +++ b/examples/protocols/https_server/simple/example_test.py @@ -141,11 +141,13 @@ def test_examples_protocol_https_server_simple(env, extra_data): # type: (tiny_ resp = conn.getresponse() dut1.expect('performing session handshake') got_resp = resp.read().decode('utf-8') - # Close the connection if got_resp != success_response: Utility.console_log('Response obtained does not match with correct response') raise RuntimeError('Failed to test SSL connection') + # Close the connection + conn.close() + Utility.console_log('Checking user callback: Obtaining client certificate...') serial_number = dut1.expect(re.compile(r'serial number(.*)'), timeout=5)[0] @@ -158,7 +160,6 @@ def test_examples_protocol_https_server_simple(env, extra_data): # type: (tiny_ Utility.console_log('Correct response obtained') Utility.console_log('SSL connection test successful\nClosing the connection') - conn.close() if __name__ == '__main__': diff --git a/examples/protocols/https_server/simple/main/main.c b/examples/protocols/https_server/simple/main/main.c index 6aca0a8f25..c578cb8e04 100644 --- a/examples/protocols/https_server/simple/main/main.c +++ b/examples/protocols/https_server/simple/main/main.c @@ -37,7 +37,7 @@ static esp_err_t root_get_handler(httpd_req_t *req) #if CONFIG_EXAMPLE_ENABLE_HTTPS_USER_CALLBACK -void print_peer_cert_info(const mbedtls_ssl_context *ssl) +static void print_peer_cert_info(const mbedtls_ssl_context *ssl) { const mbedtls_x509_crt *cert; const size_t buf_size = 1024; @@ -72,7 +72,7 @@ void print_peer_cert_info(const mbedtls_ssl_context *ssl) * The config option is found here - Component config → ESP-TLS * */ -void https_server_user_callback(esp_https_server_user_cb_arg_t *user_cb) +static void https_server_user_callback(esp_https_server_user_cb_arg_t *user_cb) { ESP_LOGI(TAG, "User callback invoked!");