FreeRTOS:
HTTPS Client
HTTPS Client v1.0.0 library
|
Return to main page ↑ |
Tests for IotHttpsClient_SendAsync(). in iot_https_client.h. More...
Data Structures | |
struct | _asyncVerificationParams_t |
Context to the HTTP asynchronous workflow callbacks to verify operation. More... | |
Macros | |
#define | HTTPS_TEST_ASYNC_TIMEOUT_MS ( ( uint32_t ) 30000 ) |
Timeout for all requests to finish on a single connection. | |
#define | HTTPS_TEST_MAX_ASYNC_REQUESTS ( 3 ) |
The maximum number of asynchronous requests on the same connection. More... | |
#define | HTTPS_TEST_NETWORK_RECEIVE_CALLBACK_WAIT_MS ( ( uint32_t ) 300 ) |
Wait time before the network receive callback is invoked. More... | |
Functions | |
static void | _invokeNetworkReceiveCallback (void *pArgument) |
thread that invokes the _networkReceiveCallback internal to the library. | |
static size_t | _networkSendSuccess (void *pConnection, const uint8_t *pMessage, size_t messageLength) |
Network abstraction send function that succeeds. More... | |
static size_t | _networkSendFailHeaders (void *pConnection, const uint8_t *pMessage, size_t messageLength) |
Network abstraction send function that fails sending the HTTP headers. | |
static size_t | _networkSendFailBody (void *pConnection, const uint8_t *pMessage, size_t messageLength) |
Network abstraction send function that fails sending the HTTP body. | |
static size_t | _networkReceiveFailHeaders (void *pConnection, uint8_t *pBuffer, size_t bytesRequested) |
Network abstraction receive function that fails when sending the HTTP headers. | |
static size_t | _networkReceiveFailBody (void *pConnection, uint8_t *pBuffer, size_t bytesRequested) |
Network abstraction receive function that fails when sending the HTTP body. | |
static size_t | _httpParserExecuteFailHeaders (http_parser *parser, const http_parser_settings *settings, const char *data, size_t len) |
Mock the http parser execution failing when parsing the HTTP headers buffer. | |
static size_t | _httpParserExecuteFailBody (http_parser *parser, const http_parser_settings *settings, const char *data, size_t len) |
Mock the http parser execution failing when parsing the HTTP body buffer. | |
size_t | _networkSendFailsOnSecondHeaderSend (void *pConnection, const uint8_t *pMessage, size_t messageLength) |
A network send function that fails on the second call to receive the headers. | |
static size_t | _networkSendSuccessWithSettingParseFailForHeaders (void *pConnection, const uint8_t *pMessage, size_t messageLength) |
Network send success that replaces the _httpsResponse_t.httpParserInfo.parseFunc with one for the current test. More... | |
static size_t | _networkSendSuccessWithSettingParseFailForBody (void *pConnection, const uint8_t *pMessage, size_t messageLength) |
Network send success that replaces the _httpsResponse_t.httpParserInfo.parseFunc with one for the current test. More... | |
static void | _appendHeaderCallback (void *pPrivData, IotHttpsRequestHandle_t reqHandle) |
Asynchronous IotHttpsClientCallbacks_t.appendHeaderCallback implementation to share among the tests. | |
static void | _writeCallback (void *pPrivData, IotHttpsRequestHandle_t reqHandle) |
Asynchronous IotHttpsClientCallbacks_t.writeCallback implementation to share among the tests. | |
static void | _readReadyCallback (void *pPrivData, IotHttpsResponseHandle_t respHandle, IotHttpsReturnCode_t rc, uint16_t status) |
Asynchronous IotHttpsClientCallbacks_t.readReadyCallback implementation to share among the tests. | |
static void | _responseCompleteCallback (void *pPrivData, IotHttpsResponseHandle_t respHandle, IotHttpsReturnCode_t rc, uint16_t status) |
Asynchronous IotHttpsClientCallbacks_t.responseCompleteCallback implementation to share among the tests. | |
static void | _connectionClosedCallback (void *pPrivData, IotHttpsConnectionHandle_t connHandle, IotHttpsReturnCode_t rc) |
Asynchronous IotHttpsClientCallbacks_t.connectionClosedCallback implementation to share among the tests. | |
static void | _errorCallback (void *pPrivData, IotHttpsRequestHandle_t reqHandle, IotHttpsResponseHandle_t respHandle, IotHttpsReturnCode_t rc) |
Asynchronous IotHttpsClientCallbacks_t.errorCallback implementation to share among the tests. | |
static void | _appendHeaderCallbackThatCancels (void *pPrivData, IotHttpsRequestHandle_t reqHandle) |
Asynchronous IotHttpsClientCallbacks_t.appendHeaderCallback implementation that cancels the request. | |
static void | _writeCallbackThatCancels (void *pPrivData, IotHttpsRequestHandle_t reqHandle) |
Asynchronous IotHttpsClientCallbacks_t.writeCallback implementation that cancels the request. | |
static void | _readReadyCallbackThatCancels (void *pPrivData, IotHttpsResponseHandle_t respHandle, IotHttpsReturnCode_t rc, uint16_t status) |
Asynchronous IotHttpsClientCallbacks_t.readReadyCallback implementation that cancels the request. | |
TEST_GROUP (HTTPS_Client_Unit_Async) | |
Test group for HTTPS Client Async Unit tests. | |
TEST_SETUP (HTTPS_Client_Unit_Async) | |
Test setup for the HTTP Client Async unit tests. | |
TEST_TEAR_DOWN (HTTPS_Client_Unit_Async) | |
Test teardown for the HTTP Client Async unit tests. | |
TEST_GROUP_RUNNER (HTTPS_Client_Unit_Async) | |
Test group runner for HTTPS Client function IotHttpsClient_SendAsync. | |
TEST (HTTPS_Client_Unit_Async, SendAsyncInvalidParameters) | |
TEST (HTTPS_Client_Unit_Async, SendAsyncFailureSendingHeaders) | |
Verify the correct asynchronous workflow when the headers fails to send on the network. | |
TEST (HTTPS_Client_Unit_Async, SendAsyncFailureSendingBody) | |
Verify the correct asynchronous workflow when the body fails to send on the network. | |
TEST (HTTPS_Client_Unit_Async, SendAsyncFailureReceivingHeaders) | |
Verify the correct asynchronous workflow when the headers fail to be received on the network. | |
TEST (HTTPS_Client_Unit_Async, SendAsyncFailureReceivingBody) | |
Verify the correct asynchronous workflow when the body fails to be received on the network. | |
TEST (HTTPS_Client_Unit_Async, SendAsyncFailureParsingHeaders) | |
Verify the correct asynchronous workflow when the response headers received fail parsing. | |
TEST (HTTPS_Client_Unit_Async, SendAsyncFailureParsingBody) | |
Verify the correct asynchronous workflow when the response body received fails parsing. | |
TEST (HTTPS_Client_Unit_Async, SendAsyncSomeBodyInHeaderBuffer) | |
Verify that the response body is received correctly when part of it received into the header buffer. | |
TEST (HTTPS_Client_Unit_Async, SendAsyncSomeHeaderInBodyBuffer) | |
Verify that the response body is received correctly when there are some headers received into the body buffer. | |
TEST (HTTPS_Client_Unit_Async, SendAsyncEntireResponseInHeaderBuffer) | |
Verify that the response body is received correctly when the whole response is received into the header buffer. | |
TEST (HTTPS_Client_Unit_Async, SendAsyncBodyTooLarge) | |
Verify that the IotHttpsClientCallbacks_t.readReadyCallback is invoked multiple times when the body is too large to fit into the buffer supplied to read. | |
TEST (HTTPS_Client_Unit_Async, SendAsyncIgnoreResponseBody) | |
Verify a successful asynchronous workflow when the IotHttpsClientCallbacks_t.readReadyCallback is set to NULL. | |
TEST (HTTPS_Client_Unit_Async, SendAsyncCancelBeforeScheduled) | |
Verify the asynchronous workflow when the request is cancelled before it is scheduled. | |
TEST (HTTPS_Client_Unit_Async, SendAsyncCancelDuringAppendHeaderCallback) | |
Verify the asynchronous workflow when the request is cancelled during the IotHttpsClientCallbacks_t.appendHeaderCallback. | |
TEST (HTTPS_Client_Unit_Async, SendAsyncCancelDuringWriteCallback) | |
Verify the asynchronous workflow when the request is cancelled during the IotHttpsClientCallbacks_t.writeCallback. | |
TEST (HTTPS_Client_Unit_Async, SendAsyncCancelDuringReadReadyCallback) | |
Verify the asynchronous workflow when the request is cancelled during the IotHttpsClientCallbacks_t.readReadyCallback. | |
TEST (HTTPS_Client_Unit_Async, SendAsyncMultipleRequestsSuccess) | |
Verify the data received when scheduling multiple asynchronous requests in the happy path case. | |
TEST (HTTPS_Client_Unit_Async, SendAsyncMultipleRequestsSecondHasNetworkSendFailure) | |
Verify that all pending requests after are not sent when the first request on the connection has a network send failure. More... | |
TEST (HTTPS_Client_Unit_Async, SendAsyncMultipleRequestsFirstHasNetworkReceiveFailure) | |
Verify that all pending requests after are not sent when the first request on the connection has a network receive failure. | |
TEST (HTTPS_Client_Unit_Async, SendAsyncMultipleRequestsFirstHasParsingFailure) | |
Verify that all pending requests after are not sent when the first request on the connection has a failure to parse the response. | |
TEST (HTTPS_Client_Unit_Async, SendAsyncMultipleRequestsFirstIsNonPersistent) | |
Verify that all pending requests after are not sent when the first request on the connection is non-persistent. | |
TEST (HTTPS_Client_Unit_Async, SendAsyncMultipleRequestsFirstIgnoresPresentResponseBody) | |
Verify that all pending requests after read the response body correct when the first response ignores it. More... | |
TEST (HTTPS_Client_Unit_Async, SendAsyncMultipleRequestsOneGetsCancelled) | |
Verify that when an earlier request gets cancelled the requests after still get schedule to run. | |
TEST (HTTPS_Client_Unit_Async, SendAsyncChunkedResponse) | |
Test receiving a chunked HTTP response message in the asynchronous workflow. | |
Variables | |
static _asyncVerificationParams_t | _verifParams = { 0 } |
Asynchronous workflow callback context to share among the tests. More... | |
static uint8_t | _pAsyncRespUserBuffers [HTTPS_TEST_MAX_ASYNC_REQUESTS][HTTPS_TEST_RESP_USER_BUFFER_SIZE] = { 0 } |
HTTPS response user buffers for scheduling multiple requests. More... | |
static uint8_t | _pAsyncReqUserBuffers [HTTPS_TEST_MAX_ASYNC_REQUESTS][HTTPS_TEST_REQ_USER_BUFFER_SIZE] = { 0 } |
HTTPS request user buffers for scheduling multiple requests. | |
static IotHttpsRequestInfo_t | _pAsyncReqInfos [HTTPS_TEST_MAX_ASYNC_REQUESTS] = { 0 } |
HTTPS request information configuration for scheduling multiple requests. More... | |
static IotHttpsResponseInfo_t | _pAsyncRespInfos [HTTPS_TEST_MAX_ASYNC_REQUESTS] = { 0 } |
HTTPS response information configuration for scheduling multiple requests. | |
static IotHttpsRequestHandle_t | _pAsyncRequestHandles [HTTPS_TEST_MAX_ASYNC_REQUESTS] |
Request handles for scheduling multiple requests. More... | |
static IotHttpsResponseHandle_t | _pAsyncResponseHandles [HTTPS_TEST_MAX_ASYNC_REQUESTS] |
Response handles for scheduling multiple requests. | |
static IotHttpsAsyncInfo_t | _asyncInfoBase |
A base IotHttpsAsyncInfo_t to copy to each of the request information configurations for each request. More... | |
static IotHttpsRequestInfo_t | _reqInfoBase |
A base IotHttpsRequestInfo_t to copy to each of the request information configurations for each request. More... | |
static IotHttpsResponseInfo_t | _respInfoBase |
A IotHttpsResponseInfo_t for an asynchronous response. More... | |
Tests for IotHttpsClient_SendAsync(). in iot_https_client.h.
#define HTTPS_TEST_MAX_ASYNC_REQUESTS ( 3 ) |
The maximum number of asynchronous requests on the same connection.
This is used to separate the user buffers needed for each request.
#define HTTPS_TEST_NETWORK_RECEIVE_CALLBACK_WAIT_MS ( ( uint32_t ) 300 ) |
Wait time before the network receive callback is invoked.
This wait time is to mimic not only response being received on the network, but also needs to incorporate the time it takes to complete sending the request.
|
static |
Network abstraction send function that succeeds.
Because the network send succeeded we mimic the network by starting a thread to envoke the network receive callback.
|
static |
Network send success that replaces the _httpsResponse_t.httpParserInfo.parseFunc with one for the current test.
This function relies on _httpsResponse_t.pHttpsResponse getting set, in the currently processing _httpsResponse_t, before the network send function is called.
|
static |
Network send success that replaces the _httpsResponse_t.httpParserInfo.parseFunc with one for the current test.
This function relies on _httpsResponse_t.pHttpsResponse getting set, in the currently processing _httpsResponse_t, before the network send function is called.
TEST | ( | HTTPS_Client_Unit_Async | , |
SendAsyncInvalidParameters | |||
) |
Tests IotHttpsClient_SendAsync() with various invalid parameters.
TEST | ( | HTTPS_Client_Unit_Async | , |
SendAsyncMultipleRequestsSecondHasNetworkSendFailure | |||
) |
Verify that all pending requests after are not sent when the first request on the connection has a network send failure.
This test relies on there being some request after the one with a network failure to send. Since the send happens soon after the first request is schedule, this test does the send failure on the second request. With the 300 ms (HTTPS_TEST_NETWORK_RECEIVE_CALLBACK_WAIT_MS) this is enough time to schedule another one or more requests after to verify that requests following do get dropped.
TEST | ( | HTTPS_Client_Unit_Async | , |
SendAsyncMultipleRequestsFirstIgnoresPresentResponseBody | |||
) |
Verify that all pending requests after read the response body correct when the first response ignores it.
This test makes sure the response flushing is working so that the workflow is not corrupted.
|
static |
Asynchronous workflow callback context to share among the tests.
This is reset during TEST_SETUP.
|
static |
HTTPS response user buffers for scheduling multiple requests.
HTTPS response and request user buffers for scheduling multiple requests.
|
static |
HTTPS request information configuration for scheduling multiple requests.
HTTPS request and response information configrations for scheduling multiple requests.
|
static |
Request handles for scheduling multiple requests.
HTTPS request and response handles for scheduling multiple requests.
Each of these handles corresponse to each of the user buffers _pAsyncRespUserBuffers and _pAsyncReqUserBuffers.
|
static |
A base IotHttpsAsyncInfo_t to copy to each of the request information configurations for each request.
The tests will replace callbacks in .callbacks as needed and add pPrivData as need for the test.
|
static |
A base IotHttpsRequestInfo_t to copy to each of the request information configurations for each request.
|
static |
A IotHttpsResponseInfo_t for an asynchronous response.