Go to the documentation of this file.
30 #ifndef IOT_TESTS_HTTPS_COMMON_H_
31 #define IOT_TESTS_HTTPS_COMMON_H_
34 #include "iot_config.h"
43 #include "private/iot_https_internal.h"
49 #include "aws_clientcredential.h"
50 #include "aws_clientcredential_keys.h"
53 #include "unity_fixture.h"
60 #define HTTPS_TEST_PORT ( ( uint16_t ) 443 )
65 #define HTTPS_TEST_ADDRESS "www.amazon.com "
70 #define HTTPS_TEST_PATH "/path.txt"
75 #define HTTPS_TEST_ALPN_PROTOCOL "http/1.1"
80 #define HTTPS_TEST_ROOT_CA \
81 "-----BEGIN CERTIFICATE-----\n" \
82 "MIIDdzCCAl+gAwIBAgIEAgAAuTANBgkqhkiG9w0BAQUFADBaMQswCQYDVQQGEwJJ\n" \
83 "RTESMBAGA1UEChMJQmFsdGltb3JlMRMwEQYDVQQLEwpDeWJlclRydXN0MSIwIAYD\n" \
84 "VQQDExlCYWx0aW1vcmUgQ3liZXJUcnVzdCBSb290MB4XDTAwMDUxMjE4NDYwMFoX\n" \
85 "DTI1MDUxMjIzNTkwMFowWjELMAkGA1UEBhMCSUUxEjAQBgNVBAoTCUJhbHRpbW9y\n" \
86 "ZTETMBEGA1UECxMKQ3liZXJUcnVzdDEiMCAGA1UEAxMZQmFsdGltb3JlIEN5YmVy\n" \
87 "VHJ1c3QgUm9vdDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAKMEuyKr\n" \
88 "mD1X6CZymrV51Cni4eiVgLGw41uOKymaZN+hXe2wCQVt2yguzmKiYv60iNoS6zjr\n" \
89 "IZ3AQSsBUnuId9Mcj8e6uYi1agnnc+gRQKfRzMpijS3ljwumUNKoUMMo6vWrJYeK\n" \
90 "mpYcqWe4PwzV9/lSEy/CG9VwcPCPwBLKBsua4dnKM3p31vjsufFoREJIE9LAwqSu\n" \
91 "XmD+tqYF/LTdB1kC1FkYmGP1pWPgkAx9XbIGevOF6uvUA65ehD5f/xXtabz5OTZy\n" \
92 "dc93Uk3zyZAsuT3lySNTPx8kmCFcB5kpvcY67Oduhjprl3RjM71oGDHweI12v/ye\n" \
93 "jl0qhqdNkNwnGjkCAwEAAaNFMEMwHQYDVR0OBBYEFOWdWTCCR1jMrPoIVDaGezq1\n" \
94 "BE3wMBIGA1UdEwEB/wQIMAYBAf8CAQMwDgYDVR0PAQH/BAQDAgEGMA0GCSqGSIb3\n" \
95 "DQEBBQUAA4IBAQCFDF2O5G9RaEIFoN27TyclhAO992T9Ldcw46QQF+vaKSm2eT92\n" \
96 "9hkTI7gQCvlYpNRhcL0EYWoSihfVCr3FvDB81ukMJY2GQE/szKN+OMY3EU/t3Wgx\n" \
97 "jkzSswF07r51XgdIGn9w/xZchMB5hbgF/X++ZRGjD8ACtPhSNzkE1akxehi/oCr0\n" \
98 "Epn3o0WC4zxe9Z2etciefC7IpJ5OCBRLbf1wbWsaY71k5h+3zvDyny67G7fyUIhz\n" \
99 "ksLi4xaNmjICq44Y3ekQEe5+NauQrz4wlHrQMz2nZQ/1/I6eYs9HRCwBXbsdtTLS\n" \
100 "R9I4LtD+gdwyah617jzV/OeBHRnDJELqYzmp\n" \
101 "-----END CERTIFICATE-----\n"
107 #define HTTPS_TEST_CONN_USER_BUFFER_SIZE ( sizeof( _httpsConnection_t ) )
112 #define HTTPS_TEST_REQ_USER_BUFFER_SIZE ( 512 )
119 #define HTTPS_TEST_RESP_USER_BUFFER_SIZE ( sizeof( _httpsResponse_t ) + 128 )
124 #define HTTPS_TEST_RESP_BODY_BUFFER_SIZE ( 256 )
132 #define HTTPS_TEST_RESPONSE_MESSAGE_LENGTH ( 1024 )
137 #define HTTPS_TEST_RESP_HEADER_BUFFER_LENGTH ( HTTPS_TEST_RESP_USER_BUFFER_SIZE - sizeof( _httpsResponse_t ) )
142 #define HTTPS_TEST_REQUEST_BODY \
143 "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore " \
144 "magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo" \
145 " consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla paria" \
146 "tur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est lab" \
148 #define HTTPS_TEST_REQUEST_BODY_LENGTH ( sizeof( HTTPS_TEST_REQUEST_BODY ) - 1 )
153 #define HTTPS_TEST_SMALL_RESPONSE \
154 "HTTP/1.1 200 OK\r\nheader0: value0\r\nheader1: value1\r\n" \
155 "header2: value2 value2a\r\nContent-Length: 26\r\n\r\nabcdefghijklmnopqrstuvwxyz"
156 #define HTTPS_TEST_SMALL_RESPONSE_LENGTH ( sizeof( HTTPS_TEST_SMALL_RESPONSE ) - 1 )
161 #define HTTPS_TEST_CHUNKED_RESPONSE \
162 "HTTP/1.1 403 Forbidden\r\n" \
163 "header0: value0\r\n" \
164 "header1: value1\r\n" \
165 "Transfer-Encoding: chunked\r\n" \
175 #define HTTPS_TEST_CHUNKED_RESPONSE_BODY_LENGTH ( 0xB + 0xC + 3 )
249 .pClientCert = keyCLIENT_CERTIFICATE_PEM,
250 .clientCertLen =
sizeof( keyCLIENT_CERTIFICATE_PEM ),
251 .pPrivateKey = keyCLIENT_PRIVATE_KEY_PEM,
252 .privateKeyLen =
sizeof( keyCLIENT_PRIVATE_KEY_PEM ),
264 void * pCredentialInfo,
265 void ** pConnection )
267 ( void ) pConnectionInfo;
268 ( void ) pCredentialInfo;
269 ( void ) pConnection;
279 IotNetworkReceiveCallback_t receiveCallback,
282 ( void ) pConnection;
283 ( void ) receiveCallback;
337 ( void ) pConnection;
351 ( void ) pConnection;
364 size_t bytesRequested )
369 ( void ) pConnection;
371 ( void ) bytesRequested;
373 if( responseMessageLengthLeft < bytesRequested )
375 copyLen = responseMessageLengthLeft;
379 copyLen = bytesRequested;
uint8_t _pReqUserBuffer[HTTPS_TEST_REQ_USER_BUFFER_SIZE]
HTTPS Request user buffer to share among the tests.
Definition: iot_tests_https_common.c:93
#define IOT_HTTPS_RESPONSE_HANDLE_INITIALIZER
Initializer for IotHttpsResponseHandle_t.
Definition: iot_https_types.h:194
IotNetworkError_t(* setReceiveCallback)(void *pConnection, IotNetworkReceiveCallback_t receiveCallback, void *pContext)
IotNetworkError_t(* create)(void *pConnectionInfo, void *pCredentialInfo, void **pConnection)
static IotNetworkError_t _networkCloseSuccess(void *pConnection)
Network Abstraction close function that succeeds.
Definition: iot_tests_https_common.h:335
struct _httpsResponse * IotHttpsResponseHandle_t
Opaque handle of an HTTP response.
Definition: iot_https_types.h:280
HTTP request configuration.
Definition: iot_https_types.h:796
HTTP request configuration.
Definition: iot_https_types.h:884
struct _httpsRequest * IotHttpsRequestHandle_t
Opaque handle of an HTTP request.
Definition: iot_https_types.h:263
#define IOT_HTTPS_CONNECTION_HANDLE_INITIALIZER
Initializer for IotHttpsConnectionHandle_t.
Definition: iot_https_types.h:190
struct _httpsConnection * IotHttpsConnectionHandle_t
Opaque handle of an HTTP connection.
Definition: iot_https_types.h:248
uint8_t _pRespMessageBuffer[HTTPS_TEST_RESPONSE_MESSAGE_LENGTH]
An HTTP response message to share among the tests.
Definition: iot_tests_https_common.c:120
IotHttpsReturnCode_t IotHttpsClient_InitializeRequest(IotHttpsRequestHandle_t *pReqHandle, IotHttpsRequestInfo_t *pReqInfo)
Initializes the request by adding a formatted Request-Line to the start of HTTPS request header buffe...
Definition: iot_https_client.c:2731
static size_t _networkReceiveSuccess(void *pConnection, uint8_t *pBuffer, size_t bytesRequested)
Network abstraction receive function that succeeds.
Definition: iot_tests_https_common.h:362
static IotHttpsResponseHandle_t _getRespHandle(IotHttpsResponseInfo_t *pRespInfo, IotHttpsRequestHandle_t reqHandle)
Get a valid response handle using _pRespUserBuffer, and respInfoGET.
Definition: iot_tests_https_common.h:321
#define HTTPS_TEST_RESP_BODY_BUFFER_SIZE
The size of the response body buffer to use among the tests.
Definition: iot_tests_https_common.h:124
const char * pAddress
Remote server address that is DNS discoverable.
Definition: iot_https_types.h:727
static IotNetworkError_t _setReceiveCallbackSuccess(void *pConnection, IotNetworkReceiveCallback_t receiveCallback, void *pContext)
Network Abstraction setReceiveCallback that succeeds.
Definition: iot_tests_https_common.h:278
static IotNetworkError_t _networkCreateSuccess(void *pConnectionInfo, void *pCredentialInfo, void **pConnection)
Network Abstraction create function that succeeds.
Definition: iot_tests_https_common.h:263
#define HTTPS_TEST_REQ_USER_BUFFER_SIZE
The size of the request user buffer to use among the tests.
Definition: iot_tests_https_common.h:112
#define HTTPS_TEST_ALPN_PROTOCOL
Test HTTP/1.1 protocol to share among the tests.
Definition: iot_tests_https_common.h:75
#define HTTPS_TEST_PORT
Test TLS TCP port.
Definition: iot_tests_https_common.h:60
#define HTTPS_TEST_RESP_USER_BUFFER_SIZE
The size of the response user buffer to use among the tests.
Definition: iot_tests_https_common.h:119
static uint32_t _nextRespMessageBufferByteToReceive
The current place in _pRespMessageBuffer to receive the next byte.
Definition: iot_tests_https_common.h:229
void _generateHttpResponseMessage(int headerLength, int bodyLength)
Generate an test HTTP response message with the specified header length and the specified body length...
Definition: iot_tests_https_common.c:125
IotHttpsReturnCode_t IotHttpsClient_Connect(IotHttpsConnectionHandle_t *pConnHandle, IotHttpsConnectionInfo_t *pConnInfo)
Explicitly connect to the HTTPS server given the connection configuration pConnConfig.
Definition: iot_https_client.c:2589
Declares the functions that provide access to the internal functions and variables of the HTTPS Clien...
static IotHttpsRequestHandle_t _getReqHandle(IotHttpsRequestInfo_t *pReqInfo)
Get a valid request handle with the input pReqInfo.
Definition: iot_tests_https_common.h:308
static IotNetworkInterface_t _networkInterface
An IotNetworkInterface_t to share among the tests.
Definition: iot_tests_https_common.h:235
#define HTTPS_TEST_CONN_USER_BUFFER_SIZE
The size of the connection user buffer to use among the tests.
Definition: iot_tests_https_common.h:107
#define HTTPS_TEST_RESPONSE_MESSAGE_LENGTH
The maximum length of the HTTP response message buffer shared among the test.
Definition: iot_tests_https_common.h:132
#define IOT_HTTPS_REQUEST_HANDLE_INITIALIZER
Initializer for IotHttpsRequestHandle_t.
Definition: iot_https_types.h:192
static IotHttpsConnectionHandle_t _getConnHandle(void)
Get a valid connected state intialized connection handle using _pConnUserBuffer and _connInfo.
Definition: iot_tests_https_common.h:293
#define HTTPS_TEST_ROOT_CA
Baltimore Cybertrust root CA to share among the tests.
Definition: iot_tests_https_common.h:80
uint8_t _pRespBodyBuffer[HTTPS_TEST_RESP_BODY_BUFFER_SIZE]
HTTPS Response body buffer to share among the tests.
Definition: iot_tests_https_common.c:111
static IotNetworkError_t _networkDestroySuccess(void *pConnection)
Network abstraction destroy function that succeeds.
Definition: iot_tests_https_common.h:349
IotHttpsReturnCode_t IotTestHttps_initializeResponse(IotHttpsResponseHandle_t *pRespHandle, IotHttpsResponseInfo_t *pRespInfo, IotHttpsRequestHandle_t reqHandle)
Test access function for _initializeResponse.
Definition: iot_test_access_https_client.c:38
uint8_t _pConnUserBuffer[HTTPS_TEST_CONN_USER_BUFFER_SIZE]
HTTPS Client connection user buffer to share among the tests.
Definition: iot_tests_https_common.c:84
static IotHttpsConnectionInfo_t _connInfo
A IotHttpsConnectionInfo_t to share among the tests.
Definition: iot_tests_https_common.h:240
void _verifyHttpResponseBody(int bodyLength, uint8_t *pBody, int startIndex)
Test verify the response body in pBody up to bodyLength.
Definition: iot_tests_https_common.c:235
#define HTTPS_TEST_ADDRESS
Test address to share among the tests.
Definition: iot_tests_https_common.h:65
HTTP connection configuration.
Definition: iot_https_types.h:721
uint8_t _pRespUserBuffer[HTTPS_TEST_RESP_USER_BUFFER_SIZE]
HTTPS Response user buffer to share among the tests.
Definition: iot_tests_https_common.c:102