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

Full integration tests for the HTTPS Client library. More...

#include "iot_config.h"
#include "iot_init.h"
#include "private/iot_https_internal.h"
#include "iot_https_utils.h"
#include <IOT_TEST_NETWORK_HEADER>
#include "unity_fixture.h"
#include "aws_test_utils.h"

Data Structures

struct  _asyncVerificationParams_t
 Context to the HTTP asynchronous workflow callbacks to verify operation. More...
 

Macros

#define IOT_TEST_HTTPS_SERVER_HOST_NAME   "postman-echo.com"
 The DNS resolvable host name of the server to perform testing. More...
 
#define IOT_TEST_HTTPS_PORT   ( ( uint16_t ) 80 )
 The socket port of the server to connect to.
 
#define IOT_TEST_HTTPS_ALPN_PROTOCOLS   NULL
 ALPN protocols string.
 
#define IOT_TEST_HTTPS_ROOT_CA
 Root certificate authority to verify the server connecting to. More...
 
#define IOT_TEST_HTTPS_CLIENT_CERTIFICATE   keyCLIENT_CERTIFICATE_PEM
 Client certificate configuration. More...
 
#define IOT_TEST_HTTPS_CLIENT_PRIVATE_KEY   keyCLIENT_PRIVATE_KEY_PEM
 Client private key configuration.
 
#define IOT_TEST_HTTPS_SYNC_TIMEOUT_MS   ( ( uint32_t ) 10000 )
 Timeout in milliseconds for tests that synchronously send HTTP requests. More...
 
#define IOT_TEST_HTTPS_ASYNC_TIMEOUT_MS   ( ( uint32_t ) 10000 )
 Timeout in milliseconds for tests asynchronously sending HTTP requests. More...
 
#define IOT_TEST_HTTPS_INITIAL_CONNECTION_RETRY_DELAY   ( ( uint32_t ) 300 )
 The initial delay in milliseconds that is doubled each retry of server connection.
 
#define IOT_TEST_HTTPS_CONNECTION_NUM_RETRIES   ( ( int32_t ) 3 )
 The amount of times to retry the server connection if it fails.
 
#define HTTPS_TEST_CONN_USER_BUFFER_SIZE   ( 512 )
 The size of the connection user buffer to use among the tests.
 
#define HTTPS_TEST_REQ_USER_BUFFER_SIZE   ( 512 )
 The size of the request user buffer to use among the tests.
 
#define HTTPS_TEST_RESP_USER_BUFFER_SIZE   ( 512 )
 The size of the respons user buffer to use among the tests.
 
#define HTTPS_TEST_RESP_BODY_BUFFER_SIZE   ( 512 )
 The size of the response body buffer to use among the tests.
 
#define HTTPS_TEST_GET_REQUEST_PATH   "/get"
 The HTTP path for the get request.
 
#define HTTPS_TEST_PUT_REQUEST_PATH   "/put"
 The HTTP path for the put request.
 
#define HTTPS_TEST_POST_REQUEST_PATH   "/post"
 The HTTP path for the post request.
 
#define HTTPS_TEST_MESSAGE_BODY
 The HTTP post and put message body data. More...
 
#define HTTPS_TEST_MESSAGE_BODY_LENGTH   ( sizeof( HTTPS_TEST_MESSAGE_BODY ) - 1 )
 The length of the HTTP test request message body.
 

Functions

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 _testRequestSynchronous (bool isNonPersistent, IotHttpsMethod_t method)
 Send a GET request synchronously and verify the results.
 
static void _testRequestAsynchronous (bool isNonPersistent, IotHttpsMethod_t method)
 Send a GET request asynchronously and verify the results.
 
 TEST_GROUP (HTTPS_Client_System)
 Test group for HTTPS Client system tests.
 
 TEST_SETUP (HTTPS_Client_System)
 Test setup for the HTTP Client system tests.
 
 TEST_TEAR_DOWN (HTTPS_Client_System)
 Test teardown for the HTTP Client system tests.
 
 TEST_GROUP_RUNNER (HTTPS_Client_System)
 Test group runner for HTTPS Client System integration tests.
 
 TEST (HTTPS_Client_System, GetRequestSynchronousPersistent)
 Verify a persistent GET request to the test server sent synchronously.
 
 TEST (HTTPS_Client_System, GetRequestSynchronousNonPersistent)
 Verify a non-persistent GET request to the test server sent synchronously.
 
 TEST (HTTPS_Client_System, GetRequestAsynchronousPersistent)
 Verify a GET request to the test server sent asynchronously.
 
 TEST (HTTPS_Client_System, GetRequestAsynchronousNonPersistent)
 Verify a GET request to the test server sent asynchronously.
 
 TEST (HTTPS_Client_System, HeadRequestSynchronousPersistent)
 Verify a persistent HEAD request to the test server sent synchronously.
 
 TEST (HTTPS_Client_System, HeadRequestSynchronousNonPersistent)
 Verify a non-persistent HEAD request to the test server sent synchronously.
 
 TEST (HTTPS_Client_System, HeadRequestAsynchronousPersistent)
 Verify a HEAD request to the test server sent asynchronously.
 
 TEST (HTTPS_Client_System, HeadRequestAsynchronousNonPersistent)
 Verify a HEAD request to the test server sent asynchronously.
 
 TEST (HTTPS_Client_System, PutRequestSynchronousPersistent)
 Verify a persistent PUT request to the test server sent synchronously.
 
 TEST (HTTPS_Client_System, PutRequestSynchronousNonPersistent)
 Verify a non-persistent PUT request to the test server sent synchronously.
 
 TEST (HTTPS_Client_System, PutRequestAsynchronousPersistent)
 Verify a PUT request to the test server sent asynchronously.
 
 TEST (HTTPS_Client_System, PutRequestAsynchronousNonPersistent)
 Verify a PUT request to the test server sent asynchronously.
 
 TEST (HTTPS_Client_System, PostRequestSynchronousPersistent)
 Verify a persistent POST request to the test server sent synchronously.
 
 TEST (HTTPS_Client_System, PostRequestSynchronousNonPersistent)
 Verify a non-persistent POST request to the test server sent synchronously.
 
 TEST (HTTPS_Client_System, PostRequestAsynchronousPersistent)
 Verify a POST request to the test server sent asynchronously.
 
 TEST (HTTPS_Client_System, PostRequestAsynchronousNonPersistent)
 Verify a POST request to the test server sent asynchronously.
 

Variables

static uint8_t _pConnUserBuffer [HTTPS_TEST_CONN_USER_BUFFER_SIZE] = { 0 }
 HTTPS Client connection user buffer to share among the tests.
 
static uint8_t _pReqUserBuffer [HTTPS_TEST_REQ_USER_BUFFER_SIZE] = { 0 }
 HTTPS Request user buffer to share among the tests.
 
static uint8_t _pRespUserBuffer [HTTPS_TEST_RESP_USER_BUFFER_SIZE] = { 0 }
 HTTPS Response user buffer to share among the tests.
 
static uint8_t _pRespBodyBuffer [HTTPS_TEST_RESP_BODY_BUFFER_SIZE] = { 0 }
 HTTPS Response body buffer to share among the tests.
 
static IotHttpsConnectionInfo_t _connInfo
 A IotHttpsConnectionInfo_t to share among the tests. More...
 

Detailed Description

Full integration tests for the HTTPS Client library.

Macro Definition Documentation

◆ IOT_TEST_HTTPS_SERVER_HOST_NAME

#define IOT_TEST_HTTPS_SERVER_HOST_NAME   "postman-echo.com"

The DNS resolvable host name of the server to perform testing.

This address MUST NOT start with http:// or https://.

◆ IOT_TEST_HTTPS_ROOT_CA

#define IOT_TEST_HTTPS_ROOT_CA
Value:
"-----BEGIN CERTIFICATE-----\n" \
"MIIEDzCCAvegAwIBAgIBADANBgkqhkiG9w0BAQUFADBoMQswCQYDVQQGEwJVUzEl\n" \
"MCMGA1UEChMcU3RhcmZpZWxkIFRlY2hub2xvZ2llcywgSW5jLjEyMDAGA1UECxMp\n" \
"U3RhcmZpZWxkIENsYXNzIDIgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwHhcNMDQw\n" \
"NjI5MTczOTE2WhcNMzQwNjI5MTczOTE2WjBoMQswCQYDVQQGEwJVUzElMCMGA1UE\n" \
"ChMcU3RhcmZpZWxkIFRlY2hub2xvZ2llcywgSW5jLjEyMDAGA1UECxMpU3RhcmZp\n" \
"ZWxkIENsYXNzIDIgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwggEgMA0GCSqGSIb3\n" \
"DQEBAQUAA4IBDQAwggEIAoIBAQC3Msj+6XGmBIWtDBFk385N78gDGIc/oav7PKaf\n" \
"8MOh2tTYbitTkPskpD6E8J7oX+zlJ0T1KKY/e97gKvDIr1MvnsoFAZMej2YcOadN\n" \
"+lq2cwQlZut3f+dZxkqZJRRU6ybH838Z1TBwj6+wRir/resp7defqgSHo9T5iaU0\n" \
"X9tDkYI22WY8sbi5gv2cOj4QyDvvBmVmepsZGD3/cVE8MC5fvj13c7JdBmzDI1aa\n" \
"K4UmkhynArPkPw2vCHmCuDY96pzTNbO8acr1zJ3o/WSNF4Azbl5KXZnJHoe0nRrA\n" \
"1W4TNSNe35tfPe/W93bC6j67eA0cQmdrBNj41tpvi/JEoAGrAgEDo4HFMIHCMB0G\n" \
"A1UdDgQWBBS/X7fRzt0fhvRbVazc1xDCDqmI5zCBkgYDVR0jBIGKMIGHgBS/X7fR\n" \
"zt0fhvRbVazc1xDCDqmI56FspGowaDELMAkGA1UEBhMCVVMxJTAjBgNVBAoTHFN0\n" \
"YXJmaWVsZCBUZWNobm9sb2dpZXMsIEluYy4xMjAwBgNVBAsTKVN0YXJmaWVsZCBD\n" \
"bGFzcyAyIENlcnRpZmljYXRpb24gQXV0aG9yaXR5ggEAMAwGA1UdEwQFMAMBAf8w\n" \
"DQYJKoZIhvcNAQEFBQADggEBAAWdP4id0ckaVaGsafPzWdqbAYcaT1epoXkJKtv3\n" \
"L7IezMdeatiDh6GX70k1PncGQVhiv45YuApnP+yz3SFmH8lU+nLMPUxA2IGvd56D\n" \
"eruix/U0F47ZEUD0/CwqTRV/p2JdLiXTAAsgGh1o+Re49L2L7ShZ3U0WixeDyLJl\n" \
"xy16paq8U4Zt3VekyvggQQto8PT7dL5WXXp59fkdheMtlb71cZBDzI0fmgAKhynp\n" \
"VSJYACPq4xJDKVtHCN2MQWplBqjlIapBtJUhlbl90TSrE9atvNziPTnNvT51cKEY\n" \
"WQPJIrSPnNVeKtelttQKbfi3QBFGmh95DmK/D5fs4C8fF5Q=\n" \
"-----END CERTIFICATE-----"

Root certificate authority to verify the server connecting to.

◆ IOT_TEST_HTTPS_CLIENT_CERTIFICATE

#define IOT_TEST_HTTPS_CLIENT_CERTIFICATE   keyCLIENT_CERTIFICATE_PEM

Client certificate configuration.

Client certificate and private key configurations.

With PKCS #11 provisioning of the internally stored keys these parameters are deprecated.

◆ IOT_TEST_HTTPS_SYNC_TIMEOUT_MS

#define IOT_TEST_HTTPS_SYNC_TIMEOUT_MS   ( ( uint32_t ) 10000 )

Timeout in milliseconds for tests that synchronously send HTTP requests.

This timeout encompasses the waiting time for the both sending of the request and receiving the response.

◆ IOT_TEST_HTTPS_ASYNC_TIMEOUT_MS

#define IOT_TEST_HTTPS_ASYNC_TIMEOUT_MS   ( ( uint32_t ) 10000 )

Timeout in milliseconds for tests asynchronously sending HTTP requests.

This timeout is use to wait for the asynchronous test to finish.

◆ HTTPS_TEST_MESSAGE_BODY

#define HTTPS_TEST_MESSAGE_BODY
Value:
"{\r\b" \
" \"data\":\"data\"\r\n" \
"}"

The HTTP post and put message body data.

Variable Documentation

◆ _connInfo

IotHttpsConnectionInfo_t _connInfo
static
Initial value:
=
{
.addressLen = sizeof( IOT_TEST_HTTPS_SERVER_HOST_NAME ) - 1,
.flags = 0,
.userBuffer.pBuffer = _pConnUserBuffer,
.userBuffer.bufferLen = sizeof( _pConnUserBuffer ),
.pNetworkInterface = NULL
}

A IotHttpsConnectionInfo_t to share among the tests.

_pConnUserBuffer
static uint8_t _pConnUserBuffer[HTTPS_TEST_CONN_USER_BUFFER_SIZE]
HTTPS Client connection user buffer to share among the tests.
Definition: iot_tests_https_system.c:218
IOT_TEST_HTTPS_SERVER_HOST_NAME
#define IOT_TEST_HTTPS_SERVER_HOST_NAME
The DNS resolvable host name of the server to perform testing.
Definition: iot_tests_https_system.c:58
IOT_TEST_HTTPS_PORT
#define IOT_TEST_HTTPS_PORT
The socket port of the server to connect to.
Definition: iot_tests_https_system.c:68