|
FreeRTOS:
HTTPS Client
HTTPS Client v1.0.0 library
|
| Return to main page ↑ |
Tests for IotHttpsClient_SendSync() in iot_https_client.h. More...
Macros | |
| #define | HTTPS_TEST_SYNC_TIMEOUT_MS ( ( uint32_t ) 30000 ) |
| Timeout for IotHttpsClient_SendSync() for all tests. | |
| #define | HTTPS_TEST_NETWORK_RECEIVE_CALLBACK_WAIT_MS ( ( uint32_t ) 300 ) |
| Wait time before the network receive callback is invoked. More... | |
| #define | HTTPS_TEST_SMALL_RESPONSE_UP_TO_CARRIAGE_RETURN "HTTP/1.1 200 OK\r\nheader0: value0\r\nheader1: value1\r" |
| A test response from the network that goes up to a carriage return in the HTTP response headers. More... | |
| #define | HTTPS_TEST_SMALL_RESPONSE_UP_TO_NEWLINE "HTTP/1.1 200 OK\r\nheader0: value0\r\nheader1: value1\r\n" |
| A test response from the network that goes up to a newline in the HTTP response headers. | |
| #define | HTTPS_TEST_SMALL_RESPONSE_UP_TO_COLON "HTTP/1.1 200 OK\r\nheader0: value0\r\nheader1:" |
| A test response from the network that goes up to a colon in the HTTP response headers. | |
| #define | HTTPS_TEST_SMALL_RESPONSE_UP_TO_SPACE "HTTP/1.1 200 OK\r\nheader0: value0\r\nheader1: " |
| A test response from the network that goes up to the space after a colon in the HTTP response headers. | |
| #define | HTTPS_TEST_SMALL_RESPONSE_UP_TO_SPACE_IN_BETWEEN_VALUE "HTTP/1.1 200 OK\r\nheader0: value0\r\nheader1: value1\r\nheader2: value2 " |
| A test response from the network that goes up to the space that is after a header value in the HTTP response headers. | |
| #define | HTTPS_TEST_HEADER1 "header1" |
| The string literal for a header field named "header1". This is for test result checking. | |
| #define | HTTPS_TEST_HEADER1_PLUS_COLON "header1:" |
| The string literal for a header field named "header1" including the colon after. | |
| #define | HTTPS_TEST_HEADER1_PLUS_SPACE "header1: " |
| The string literal for a header field named "header1" including the colon and space after. | |
| #define | HTTPS_TEST_HEADER2 "header2" |
| The string literal for a header field named "header2". This is for test result checking. | |
| #define | HTTPS_TEST_HEADER_VALUE1 "value1" |
| The string literal for a header value named "value1". | |
| #define | HTTPS_TEST_HEADER_VALUE2_PLUS_SPACE "value2 " |
| The string literal for a header value named "value2.". | |
| #define | HTTPS_TEST_HEADER_VALUE2_VALUE2A "value2 value2a" |
| The string literal a header value that contains two strings separated by a space. | |
| #define | HTTPS_TEST_HEADER_VALUE1_PLUS_CARRIAGE_RETURN "value1\r" |
| the string literal for a header value with the carriage return following it. | |
| #define | HTTPS_TEST_HEADER_VALUE1_PLUS_NEWLINE "value1\r\n" |
| the string ltieral for a header value with the carriage return and newline following it. | |
Functions | |
| static void | _invokeNetworkReceiveCallback (void *pArgument) |
| thread that invokes the _networkReceiveCallback internal to the library. | |
| 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. | |
| 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 | _networkSendSuccess (void *pConnection, const uint8_t *pMessage, size_t messageLength) |
| Network abstraction send function that succeeds. More... | |
| 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 | _networkSendSuccessWithSettingParseFailForHeaders (void *pConnection, const uint8_t *pMessage, size_t messageLength) |
| Network send success that replaces the _httpsResponse_t.httpParserInfo.parseFunc with one from this 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 from this test. More... | |
| TEST_GROUP (HTTPS_Client_Unit_Sync) | |
| Test group for HTTPS Client Sync Unit tests. | |
| TEST_SETUP (HTTPS_Client_Unit_Sync) | |
| Test setup for HTTPS Client Sync Unit tests. | |
| TEST_TEAR_DOWN (HTTPS_Client_Unit_Sync) | |
| Test tear down for HTTPS Client Sync Unit tests.. | |
| TEST_GROUP_RUNNER (HTTPS_Client_Unit_Sync) | |
| Test group runner for HTTPS Client IotHttpsClient_SendSync. | |
| TEST (HTTPS_Client_Unit_Sync, SendSyncInvalidParameters) | |
| Test various invalid parameters input into IotHttpsClient_SendSync(). | |
| TEST (HTTPS_Client_Unit_Sync, SendSyncFailureSendingHeaders) | |
| Test failures to send over the network the request headers. | |
| TEST (HTTPS_Client_Unit_Sync, SendSyncFailureSendingBody) | |
| Test failures to send over the network the request body. | |
| TEST (HTTPS_Client_Unit_Sync, SendSyncFailureReceivingHeaders) | |
| Test failures to receive over the network the response headers. | |
| TEST (HTTPS_Client_Unit_Sync, SendSyncFailureReceivingBody) | |
| Test failures to receive over the network response body. | |
| TEST (HTTPS_Client_Unit_Sync, SendSyncFailureParsingHeaders) | |
| Test failure to parse over the network the response headers. | |
| TEST (HTTPS_Client_Unit_Sync, SendSyncFailureParsingBody) | |
| Test failure to parse over the network the response body. | |
| TEST (HTTPS_Client_Unit_Sync, SendSyncSomeBodyInHeaderBuffer) | |
| Test that we receive the HTTP response body correctly when part of it is network received into the header buffer. | |
| TEST (HTTPS_Client_Unit_Sync, SendSyncSomeHeaderInBodyBuffer) | |
| Test that we receive the HTTP response body correctly when network received headers spill over into the body buffer. | |
| TEST (HTTPS_Client_Unit_Sync, SendSyncEntireResponseInHeaderBuffer) | |
| Test that we receive the HTTP response body correctly all of the body is network received into the header buffer. | |
| TEST (HTTPS_Client_Unit_Sync, SendSyncBodyTooLarge) | |
| Test that we return the correct error code when the HTTP response body is too large to fit into the configured body buffer. | |
| TEST (HTTPS_Client_Unit_Sync, SendSyncBodyBufferNull) | |
| Test a successful synchronous workflow when the body buffer is configured as NULL, but HTTP response body is received on the network. | |
| TEST (HTTPS_Client_Unit_Sync, SendSyncPersistentRequest) | |
| TEST (HTTPS_Client_Unit_Sync, SendSyncNonPersistentRequest) | |
| TEST (HTTPS_Client_Unit_Sync, SendSyncHeadersEndsWithCarriageReturnSeparator) | |
| Test that we have the correct header data when it ends on the carriage return of the end of the header lines separator. More... | |
| TEST (HTTPS_Client_Unit_Sync, SendSyncHeadersEndsWithNewlineSeparator) | |
| Test that we have the correct header data when it ends on the newline of the end of the header lines separator. More... | |
| TEST (HTTPS_Client_Unit_Sync, SendSyncHeadersEndsWithColonSeparator) | |
| Test that we have the correct header data when it ends on the colon character of the header field value separator. More... | |
| TEST (HTTPS_Client_Unit_Sync, SendSyncHeadersEndsWithSpaceSeparator) | |
| Test that we have the correct header data when it ends on the space character of the header field value separator. More... | |
| TEST (HTTPS_Client_Unit_Sync, SendSyncHeadersEndsWithSpaceAfterHeaderValue) | |
| TEST (HTTPS_Client_Unit_Sync, SendSyncChunkedResponse) | |
| Test receiving a chunked HTTP response message. | |
Variables | |
| static IotHttpsConnectionHandle_t | _receiveCallbackConnHandle = IOT_HTTPS_CONNECTION_HANDLE_INITIALIZER |
| The connection handle that is needed by tests that are testing a workflow that involves receiving data on the network. More... | |
| static bool | _alreadyCreatedReceiveCallbackThread = false |
| Flag indicating that the _invokeNetworkReceiveCallback task was already created. More... | |
| static IotHttpsRequestHandle_t | _currentlySendingRequestHandle = IOT_HTTPS_REQUEST_HANDLE_INITIALIZER |
| The request handle that is currently being serviced in the current tests network receive callback. More... | |
| static IotHttpsSyncInfo_t | _syncRequestInfo |
| A IotHttpsSyncInfo_t for requests to share among the tests. More... | |
| static IotHttpsSyncInfo_t | _syncResponseInfo |
| A IotHttpsSyncInfo_t for responses to share among the tests. More... | |
| static IotHttpsRequestInfo_t | _reqInfo |
| A IotHttpsRequestInfo_t to share among the tests. More... | |
| static IotHttpsResponseInfo_t | _respInfo |
| A IotHttpsResponseInfo_t to share among the tests. More... | |
Tests for IotHttpsClient_SendSync() in iot_https_client.h.
| #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.
| #define HTTPS_TEST_SMALL_RESPONSE_UP_TO_CARRIAGE_RETURN "HTTP/1.1 200 OK\r\nheader0: value0\r\nheader1: value1\r" |
A test response from the network that goes up to a carriage return in the HTTP response headers.
Definitions for part of the small HTTP test response.
Theser are used to verify behavior when the header buffer ends with just a part of the HTTP response headers.
|
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 from this 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 from this 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_Sync | , |
| SendSyncPersistentRequest | |||
| ) |
Test for a successful synchronous workflow that the connection stays open when the request is persistent.
| TEST | ( | HTTPS_Client_Unit_Sync | , |
| SendSyncNonPersistentRequest | |||
| ) |
Test for a successful synchronous workflow that the connection closes when the request is non-persistent.
| TEST | ( | HTTPS_Client_Unit_Sync | , |
| SendSyncHeadersEndsWithCarriageReturnSeparator | |||
| ) |
Test that we have the correct header data when it ends on the carriage return of the end of the header lines separator.
The end of the header lines separator is "\r\n". This test is important because it makes sure that the pHeaderCur pointer in the internal response context is updated even though the http-parser callback does not notify the library of these characters.
These tests are separated into difference cases so that I can easily free the memory allocated.
| TEST | ( | HTTPS_Client_Unit_Sync | , |
| SendSyncHeadersEndsWithNewlineSeparator | |||
| ) |
Test that we have the correct header data when it ends on the newline of the end of the header lines separator.
The end of the header lines separator is "\r\n". This test is important because it makes sure that the pHeaderCur pointer in the internal response context is updated even though the http-parser callback does not notify the library of these characters.
These tests are separated into difference cases so that I can easily free the memory allocated.
| TEST | ( | HTTPS_Client_Unit_Sync | , |
| SendSyncHeadersEndsWithColonSeparator | |||
| ) |
Test that we have the correct header data when it ends on the colon character of the header field value separator.
The header field value separator is ": ". This test is important because it makes sure that the pHeaderCur pointer in the internal response context is updated even though the http-parser callback does not notify the library of these characters.
These tests are separated into difference cases so that I can easily free the memory allocated.
| TEST | ( | HTTPS_Client_Unit_Sync | , |
| SendSyncHeadersEndsWithSpaceSeparator | |||
| ) |
Test that we have the correct header data when it ends on the space character of the header field value separator.
The header field value separator is ": ". This test is important because it makes sure that the pHeaderCur pointer in the internal response context is updated even though the http-parser callback does not notify the library of these characters.
These tests are separated into difference cases so that I can easily free the memory allocated.
| TEST | ( | HTTPS_Client_Unit_Sync | , |
| SendSyncHeadersEndsWithSpaceAfterHeaderValue | |||
| ) |
Test that when the header buffer ends on a space after a header value that this space is treated as parted of the header value.
|
static |
The connection handle that is needed by tests that are testing a workflow that involves receiving data on the network.
HTTP tests run sequentially, so there is no race condition here.
|
static |
Flag indicating that the _invokeNetworkReceiveCallback task was already created.
This is reset to false before each test. This is set during tests that are testing a workflow that involes receiving data on the network.
We do not want to create two tasks that invoke the network receive callback. That is incorrect behavior of the network receive callback.
HTTP tests run sequentially, so there is no race condition here.
This is used for tests sending and receiving one response.
|
static |
The request handle that is currently being serviced in the current tests network receive callback.
This is needed to replace the parseFunc, in the corresponding response, with a unit test mock. This is needed to check if the network receive or network send buffer is the start of the header or the body buffers to get proper failure coverage. This is needed to check if the network receive buffer is the start of the header buffer, so that we can receive part of the response.
|
static |
A IotHttpsSyncInfo_t for requests to share among the tests.
IotHttpsSyncInfo_t for requests and response to share among the tests.
Even though the method is a GET method for the test _reqInfo, we apply a request body for unit testing purposes. A request body is allowed for a GET method according to the HTTP specification, although it is pointless in practice.
|
static |
A IotHttpsSyncInfo_t for responses to share among the tests.
|
static |
A IotHttpsRequestInfo_t to share among the tests.
|
static |
A IotHttpsResponseInfo_t to share among the tests.