FreeRTOS: HTTPS Client
HTTPS Client v1.0.0 library
Return to main page ↑
iot_tests_https_common.c File Reference

Common definitions for the HTTPS Client unit tests. More...

Macros

#define HTTPS_TEST_GENERIC_RESPONSE_STATUS_LINE   "HTTP/1.1 200 OK\r\n"
 A response status line for generating a test response message. More...
 
#define HTTPS_TEST_GENERIC_RESPONSE_STATUS_LINE_LENGTH   ( sizeof( HTTPS_TEST_GENERIC_RESPONSE_STATUS_LINE ) - 1 )
 The length of the test response status line.
 
#define HTTPS_TEST_GENERIC_HEADER   "header"
 A generic header name for generating a test response message.
 
#define HTTPS_TEST_GENERIC_VALUE   "value"
 A generic header value for generating a test response message.
 
#define MAX_UINT32_DIGITS   ( 10 )
 The maximum digits in a uin32_t; 2^32 = 4294967296 which is 10 digits. More...
 
#define MIN_UINT32_DIGITS   ( 1 )
 The minimum digits in a uin32_t.
 
#define MAX_GENERIC_HEADER_LINE_LENGTH
 The maximum length of a header line used for generating a test HTTP response message. More...
 
#define MIN_GENERIC_HEADER_LINE_LENGTH
 The minimum length of a header line used for generating a test HTTP response message. More...
 
#define HTTPS_TEST_GENERIC_BODY_STARTING_CHAR   'a'
 The starting character in the body for generating a test HTTP response. More...
 
#define NUM_LETTERS_IN_ALPHABET   ( ( int ) 26 )
 The number of letters in the alphabet is used to restart the HTTP response body generation at 'a' again after 'z'.
 

Functions

void _generateHttpResponseMessage (int headerLength, int bodyLength)
 Generate an test HTTP response message with the specified header length and the specified body length. More...
 
void _verifyHttpResponseBody (int bodyLength, uint8_t *pBody, int startIndex)
 Test verify the response body in pBody up to bodyLength. More...
 

Variables

uint8_t _pConnUserBuffer [HTTPS_TEST_CONN_USER_BUFFER_SIZE] = { 0 }
 HTTPS Client connection user buffer to share among the tests. More...
 
uint8_t _pReqUserBuffer [HTTPS_TEST_REQ_USER_BUFFER_SIZE] = { 0 }
 HTTPS Request user buffer to share among the tests. More...
 
uint8_t _pRespUserBuffer [HTTPS_TEST_RESP_USER_BUFFER_SIZE] = { 0 }
 HTTPS Response user buffer to share among the tests. More...
 
uint8_t _pRespBodyBuffer [HTTPS_TEST_RESP_BODY_BUFFER_SIZE] = { 0 }
 HTTPS Response body buffer to share among the tests. More...
 
uint8_t _pRespMessageBuffer [HTTPS_TEST_RESPONSE_MESSAGE_LENGTH] = { 0 }
 An HTTP response message to share among the tests. More...
 

Detailed Description

Common definitions for the HTTPS Client unit tests.

Macro Definition Documentation

◆ HTTPS_TEST_GENERIC_RESPONSE_STATUS_LINE

#define HTTPS_TEST_GENERIC_RESPONSE_STATUS_LINE   "HTTP/1.1 200 OK\r\n"

A response status line for generating a test response message.

The generic response status line and header line information for generating a test HTTP response message header.

◆ MAX_UINT32_DIGITS

#define MAX_UINT32_DIGITS   ( 10 )

The maximum digits in a uin32_t; 2^32 = 4294967296 which is 10 digits.

The maximum and minimum digits in a uint32_t.

This is used to size an array holding some generic headers when generating a test HTTP response message.

◆ MAX_GENERIC_HEADER_LINE_LENGTH

#define MAX_GENERIC_HEADER_LINE_LENGTH
Value:
sizeof( HTTPS_TEST_GENERIC_HEADER ) - 1 \
+ HTTPS_HEADER_FIELD_SEPARATOR_LENGTH \
+ sizeof( HTTPS_TEST_GENERIC_VALUE ) - 1 \
+ HTTPS_END_OF_HEADER_LINES_INDICATOR_LENGTH

The maximum length of a header line used for generating a test HTTP response message.

The maximum and minimum line lengths of a generic HTTP response header of the form "headerN: valueN\r\n".

These are needed for sizing arrays holding some intermediate string processing information when generating a test \ HTTP response message.

◆ MIN_GENERIC_HEADER_LINE_LENGTH

#define MIN_GENERIC_HEADER_LINE_LENGTH
Value:
sizeof( HTTPS_TEST_GENERIC_HEADER ) - 1 \
+ HTTPS_HEADER_FIELD_SEPARATOR_LENGTH \
+ sizeof( HTTPS_TEST_GENERIC_VALUE ) - 1 \
+ HTTPS_END_OF_HEADER_LINES_INDICATOR_LENGTH

The minimum length of a header line used for generating a test HTTP response message.

◆ HTTPS_TEST_GENERIC_BODY_STARTING_CHAR

#define HTTPS_TEST_GENERIC_BODY_STARTING_CHAR   'a'

The starting character in the body for generating a test HTTP response.

Starting character and maximum letters to increment to generate a test HTTP response message body.

Function Documentation

◆ _generateHttpResponseMessage()

void _generateHttpResponseMessage ( int  headerLength,
int  bodyLength 
)

Generate an test HTTP response message with the specified header length and the specified body length.

This generates the test HTTP response message into _pRespMessageBuffer. _pRespMessageBuffer must be zeroed out before calling this routine. The length of _pRespMessageBuffer must not exceed headerLength + bodyLength. The headerLength is the length of the raw HTTP headers includes delimiters like ": " and "\r\n". The length of headerLength must be greater than: "HTTP/1.1 200 OK\r\nContent-Length: <bodyLengthStr>\r\nheader0: value0\r\n\r\n" in order to generate meaningful header data.

◆ _verifyHttpResponseBody()

void _verifyHttpResponseBody ( int  bodyLength,
uint8_t *  pBody,
int  startIndex 
)

Test verify the response body in pBody up to bodyLength.

This will verify that 'a' through 'z' (then repeated) are written properly.

Variable Documentation

◆ _pConnUserBuffer

uint8_t _pConnUserBuffer[HTTPS_TEST_CONN_USER_BUFFER_SIZE] = { 0 }

HTTPS Client connection user buffer to share among the tests.

This variable is extern to save memory. This is acceptable as the HTTPS Client unit tests run sequentially. The user buffers are always overwritten each utilizing test, so data left over affecting other tests is not a concern.

◆ _pReqUserBuffer

uint8_t _pReqUserBuffer[HTTPS_TEST_REQ_USER_BUFFER_SIZE] = { 0 }

HTTPS Request user buffer to share among the tests.

This variable is extern to save memory. This is acceptable as the HTTPS Client unit tests run sequentially. The user buffers are always overwritten each utilizing test, so data left over affecting other tests is not a concern.

◆ _pRespUserBuffer

uint8_t _pRespUserBuffer[HTTPS_TEST_RESP_USER_BUFFER_SIZE] = { 0 }

HTTPS Response user buffer to share among the tests.

This variable is extern to save memory. This is acceptable as the HTTPS Client unit tests run sequentially. The user buffers are always overwritten each utilizing test, so data left over affecting other tests is not a concern.

◆ _pRespBodyBuffer

uint8_t _pRespBodyBuffer[HTTPS_TEST_RESP_BODY_BUFFER_SIZE] = { 0 }

HTTPS Response body buffer to share among the tests.

This variable is extern to save memory. This is acceptable as the HTTPS Client unit tests run sequentially. The user buffers are always overwritten each utilizing test, so data left over affecting other tests is not a concern.

◆ _pRespMessageBuffer

uint8_t _pRespMessageBuffer[HTTPS_TEST_RESPONSE_MESSAGE_LENGTH] = { 0 }

An HTTP response message to share among the tests.

This variable is extern to save memory. This is acceptable as the HTTPS Client unit tests run sequentially. The user buffers are always overwritten each utilizing test, so data left over affecting other tests is not a concern.

MIN_UINT32_DIGITS
#define MIN_UINT32_DIGITS
The minimum digits in a uin32_t.
Definition: iot_tests_https_common.c:46
HTTPS_TEST_GENERIC_HEADER
#define HTTPS_TEST_GENERIC_HEADER
A generic header name for generating a test response message.
Definition: iot_tests_https_common.c:37
MAX_UINT32_DIGITS
#define MAX_UINT32_DIGITS
The maximum digits in a uin32_t; 2^32 = 4294967296 which is 10 digits.
Definition: iot_tests_https_common.c:45
HTTPS_TEST_GENERIC_VALUE
#define HTTPS_TEST_GENERIC_VALUE
A generic header value for generating a test response message.
Definition: iot_tests_https_common.c:38