Rework registration id to be able to be set from set option

This commit is contained in:
Jelani 2018-02-21 20:42:48 +00:00 коммит произвёл Azure IoT Builder
Родитель 0e9a144f2b
Коммит f1d1ead952
21 изменённых файлов: 444 добавлений и 379 удалений

Просмотреть файл

@ -38,6 +38,8 @@ DEFINE_ENUM(PROV_DEVICE_RESULT, PROV_DEVICE_RESULT_VALUE);
DEFINE_ENUM(PROV_DEVICE_REG_STATUS, PROV_DEVICE_REG_STATUS_VALUES);
static const char* const PROV_REGISTRATION_ID = "registration_id";
typedef void(*PROV_DEVICE_CLIENT_REGISTER_DEVICE_CALLBACK)(PROV_DEVICE_RESULT register_result, const char* iothub_uri, const char* device_id, void* user_context);
typedef void(*PROV_DEVICE_CLIENT_REGISTER_STATUS_CALLBACK)(PROV_DEVICE_REG_STATUS reg_status, void* user_context);

Просмотреть файл

@ -60,9 +60,9 @@ extern "C" {
typedef PROV_JSON_INFO*(*PROV_TRANSPORT_JSON_PARSE)(const char* json_document, void* user_ctx);
typedef PROV_DEVICE_TRANSPORT_HANDLE(*pfprov_transport_create)(const char* uri, TRANSPORT_HSM_TYPE type, const char* scope_id, const char* registration_id, const char* api_version);
typedef PROV_DEVICE_TRANSPORT_HANDLE(*pfprov_transport_create)(const char* uri, TRANSPORT_HSM_TYPE type, const char* scope_id, const char* api_version);
typedef void(*pfprov_transport_destroy)(PROV_DEVICE_TRANSPORT_HANDLE handle);
typedef int(*pfprov_transport_open)(PROV_DEVICE_TRANSPORT_HANDLE handle, BUFFER_HANDLE ek, BUFFER_HANDLE srk, PROV_DEVICE_TRANSPORT_REGISTER_CALLBACK data_callback, void* user_ctx, PROV_DEVICE_TRANSPORT_STATUS_CALLBACK status_cb, void* status_ctx);
typedef int(*pfprov_transport_open)(PROV_DEVICE_TRANSPORT_HANDLE handle, const char* registration_id, BUFFER_HANDLE ek, BUFFER_HANDLE srk, PROV_DEVICE_TRANSPORT_REGISTER_CALLBACK data_callback, void* user_ctx, PROV_DEVICE_TRANSPORT_STATUS_CALLBACK status_cb, void* status_ctx);
typedef int(*pfprov_transport_close)(PROV_DEVICE_TRANSPORT_HANDLE handle);
typedef int(*pfprov_transport_register_device)(PROV_DEVICE_TRANSPORT_HANDLE handle, PROV_TRANSPORT_CHALLENGE_CALLBACK reg_challenge_cb, void* user_ctx, PROV_TRANSPORT_JSON_PARSE json_parse_cb, void* json_ctx);

Просмотреть файл

@ -27,9 +27,9 @@ typedef struct PROV_TRANSPORT_IO_INFO_TAG
typedef PROV_TRANSPORT_IO_INFO*(*PROV_AMQP_TRANSPORT_IO)(const char* fully_qualified_name, SASL_MECHANISM_HANDLE* sasl_mechanism, const HTTP_PROXY_OPTIONS* proxy_info);
MOCKABLE_FUNCTION(, PROV_DEVICE_TRANSPORT_HANDLE, prov_transport_common_amqp_create, const char*, uri, TRANSPORT_HSM_TYPE, type, const char*, scope_id, const char*, registration_id, const char*, api_version, PROV_AMQP_TRANSPORT_IO, transport_io);
MOCKABLE_FUNCTION(, PROV_DEVICE_TRANSPORT_HANDLE, prov_transport_common_amqp_create, const char*, uri, TRANSPORT_HSM_TYPE, type, const char*, scope_id, const char*, api_version, PROV_AMQP_TRANSPORT_IO, transport_io);
MOCKABLE_FUNCTION(, void, prov_transport_common_amqp_destroy, PROV_DEVICE_TRANSPORT_HANDLE, handle);
MOCKABLE_FUNCTION(, int, prov_transport_common_amqp_open, PROV_DEVICE_TRANSPORT_HANDLE, handle, BUFFER_HANDLE, ek, BUFFER_HANDLE, srk, PROV_DEVICE_TRANSPORT_REGISTER_CALLBACK, data_callback, void*, user_ctx, PROV_DEVICE_TRANSPORT_STATUS_CALLBACK, status_cb, void*, status_ctx);
MOCKABLE_FUNCTION(, int, prov_transport_common_amqp_open, PROV_DEVICE_TRANSPORT_HANDLE, handle, const char*, registration_id, BUFFER_HANDLE, ek, BUFFER_HANDLE, srk, PROV_DEVICE_TRANSPORT_REGISTER_CALLBACK, data_callback, void*, user_ctx, PROV_DEVICE_TRANSPORT_STATUS_CALLBACK, status_cb, void*, status_ctx);
MOCKABLE_FUNCTION(, int, prov_transport_common_amqp_close, PROV_DEVICE_TRANSPORT_HANDLE, handle);
MOCKABLE_FUNCTION(, int, prov_transport_common_amqp_register_device, PROV_DEVICE_TRANSPORT_HANDLE, handle, PROV_TRANSPORT_CHALLENGE_CALLBACK, reg_challenge_cb, void*, user_ctx, PROV_TRANSPORT_JSON_PARSE, json_parse_cb, void*, json_ctx);
MOCKABLE_FUNCTION(, int, prov_transport_common_amqp_get_operation_status, PROV_DEVICE_TRANSPORT_HANDLE, handle);

Просмотреть файл

@ -20,9 +20,9 @@ extern "C" {
typedef XIO_HANDLE(*PROV_MQTT_TRANSPORT_IO)(const char* fully_qualified_name, const HTTP_PROXY_OPTIONS* proxy_info);
MOCKABLE_FUNCTION(, PROV_DEVICE_TRANSPORT_HANDLE, prov_transport_common_mqtt_create, const char*, uri, TRANSPORT_HSM_TYPE, type, const char*, scope_id, const char*, registration_id, const char*, api_version, PROV_MQTT_TRANSPORT_IO, transport_io);
MOCKABLE_FUNCTION(, PROV_DEVICE_TRANSPORT_HANDLE, prov_transport_common_mqtt_create, const char*, uri, TRANSPORT_HSM_TYPE, type, const char*, scope_id, const char*, api_version, PROV_MQTT_TRANSPORT_IO, transport_io);
MOCKABLE_FUNCTION(, void, prov_transport_common_mqtt_destroy, PROV_DEVICE_TRANSPORT_HANDLE, handle);
MOCKABLE_FUNCTION(, int, prov_transport_common_mqtt_open, PROV_DEVICE_TRANSPORT_HANDLE, handle, BUFFER_HANDLE, ek, BUFFER_HANDLE, srk, PROV_DEVICE_TRANSPORT_REGISTER_CALLBACK, data_callback, void*, user_ctx, PROV_DEVICE_TRANSPORT_STATUS_CALLBACK, status_cb, void*, status_ctx);
MOCKABLE_FUNCTION(, int, prov_transport_common_mqtt_open, PROV_DEVICE_TRANSPORT_HANDLE, handle, const char*, registration_id, BUFFER_HANDLE, ek, BUFFER_HANDLE, srk, PROV_DEVICE_TRANSPORT_REGISTER_CALLBACK, data_callback, void*, user_ctx, PROV_DEVICE_TRANSPORT_STATUS_CALLBACK, status_cb, void*, status_ctx);
MOCKABLE_FUNCTION(, int, prov_transport_common_mqtt_close, PROV_DEVICE_TRANSPORT_HANDLE, handle);
MOCKABLE_FUNCTION(, int, prov_transport_common_mqtt_register_device, PROV_DEVICE_TRANSPORT_HANDLE, handle, PROV_TRANSPORT_CHALLENGE_CALLBACK, reg_challenge_cb, void*, user_ctx, PROV_TRANSPORT_JSON_PARSE, json_parse_cb, void*, json_ctx);
MOCKABLE_FUNCTION(, int, prov_transport_common_mqtt_get_operation_status, PROV_DEVICE_TRANSPORT_HANDLE, handle);

Просмотреть файл

@ -23,7 +23,6 @@
#include "azure_prov_client/prov_client_const.h"
static const char* OPTION_LOG_TRACE = "logtrace";
static const char* PROV_REGISTRATION_ID = "registration_id";
static const char* JSON_NODE_STATUS = "status";
static const char* JSON_NODE_REG_STATUS = "registrationState";
@ -85,6 +84,7 @@ typedef struct PROV_INSTANCE_INFO_TAG
tickcounter_ms_t timeout_value;
char* registration_id;
bool user_supplied_reg_id;
PROV_AUTH_HANDLE prov_auth_handle;
@ -562,14 +562,6 @@ PROV_DEVICE_LL_HANDLE Prov_Device_LL_Create(const char* uri, const char* id_scop
destroy_instance(result);
result = NULL;
}
/* Codes_SRS_PROV_CLIENT_07_035: [ Prov_Device_LL_Create shall store the registration_id from the security module. ] */
else if ((result->registration_id = prov_auth_get_registration_id(result->prov_auth_handle)) == NULL)
{
/* Codes_SRS_PROV_CLIENT_07_003: [ If any error is encountered, Prov_Device_LL_CreateFromUri shall return NULL. ] */
LogError("failure: Unable to retrieve registration Id from device auth.");
destroy_instance(result);
result = NULL;
}
else if ((result->tick_counter = tickcounter_create()) == NULL)
{
LogError("failure: allocating tickcounter");
@ -588,7 +580,7 @@ PROV_DEVICE_LL_HANDLE Prov_Device_LL_Create(const char* uri, const char* id_scop
hsm_type = TRANSPORT_HSM_TYPE_X509;
}
if ((result->transport_handle = result->prov_transport_protocol->prov_transport_create(uri, hsm_type, result->scope_id, result->registration_id, PROV_API_VERSION)) == NULL)
if ((result->transport_handle = result->prov_transport_protocol->prov_transport_create(uri, hsm_type, result->scope_id, PROV_API_VERSION)) == NULL)
{
/* Codes_SRS_PROV_CLIENT_07_003: [ If any error is encountered, Prov_Device_LL_CreateFromUri shall return NULL. ] */
LogError("failed calling into transport create");
@ -621,6 +613,13 @@ PROV_DEVICE_RESULT Prov_Device_LL_Register_Device(PROV_DEVICE_LL_HANDLE handle,
LogError("Invalid parameter specified handle: %p register_callback: %p", handle, register_callback);
result = PROV_DEVICE_RESULT_INVALID_ARG;
}
/* Codes_SRS_PROV_CLIENT_07_035: [ Prov_Device_LL_Create shall store the registration_id from the security module. ] */
else if (handle->registration_id == NULL && (handle->registration_id = prov_auth_get_registration_id(handle->prov_auth_handle)) == NULL)
{
/* Codes_SRS_PROV_CLIENT_07_003: [ If any error is encountered, Prov_Device_LL_CreateFromUri shall return NULL. ] */
LogError("failure: Unable to retrieve registration Id from device auth.");
result = PROV_DEVICE_RESULT_ERROR;
}
else
{
BUFFER_HANDLE ek_value = NULL;
@ -629,6 +628,11 @@ PROV_DEVICE_RESULT Prov_Device_LL_Register_Device(PROV_DEVICE_LL_HANDLE handle,
if (handle->prov_state != CLIENT_STATE_READY)
{
LogError("state is invalid");
if (!handle->user_supplied_reg_id)
{
free(handle->registration_id);
handle->registration_id = NULL;
}
result = PROV_DEVICE_RESULT_ERROR;
}
else
@ -638,11 +642,21 @@ PROV_DEVICE_RESULT Prov_Device_LL_Register_Device(PROV_DEVICE_LL_HANDLE handle,
if ((ek_value = prov_auth_get_endorsement_key(handle->prov_auth_handle)) == NULL)
{
LogError("Could not get endorsement key from tpm");
if (!handle->user_supplied_reg_id)
{
free(handle->registration_id);
handle->registration_id = NULL;
}
result = PROV_DEVICE_RESULT_ERROR;
}
else if ((srk_value = prov_auth_get_storage_key(handle->prov_auth_handle)) == NULL)
{
LogError("Could not get storage root key from tpm");
if (!handle->user_supplied_reg_id)
{
free(handle->registration_id);
handle->registration_id = NULL;
}
result = PROV_DEVICE_RESULT_ERROR;
BUFFER_delete(ek_value);
}
@ -658,11 +672,21 @@ PROV_DEVICE_RESULT Prov_Device_LL_Register_Device(PROV_DEVICE_LL_HANDLE handle,
if ((x509_cert = prov_auth_get_certificate(handle->prov_auth_handle)) == NULL)
{
LogError("Could not get the x509 certificate");
if (!handle->user_supplied_reg_id)
{
free(handle->registration_id);
handle->registration_id = NULL;
}
result = PROV_DEVICE_RESULT_ERROR;
}
else if ((x509_private_key = prov_auth_get_alias_key(handle->prov_auth_handle)) == NULL)
{
LogError("Could not get the x509 alias key");
if (!handle->user_supplied_reg_id)
{
free(handle->registration_id);
handle->registration_id = NULL;
}
free(x509_cert);
result = PROV_DEVICE_RESULT_ERROR;
}
@ -671,6 +695,11 @@ PROV_DEVICE_RESULT Prov_Device_LL_Register_Device(PROV_DEVICE_LL_HANDLE handle,
if (handle->prov_transport_protocol->prov_transport_x509_cert(handle->transport_handle, x509_cert, x509_private_key) != 0)
{
LogError("unable to set the x509 certificate information on transport");
if (!handle->user_supplied_reg_id)
{
free(handle->registration_id);
handle->registration_id = NULL;
}
result = PROV_DEVICE_RESULT_ERROR;
}
else
@ -691,9 +720,14 @@ PROV_DEVICE_RESULT Prov_Device_LL_Register_Device(PROV_DEVICE_LL_HANDLE handle,
handle->register_status_cb = reg_status_cb;
handle->status_user_ctx = status_ctx;
if (handle->prov_transport_protocol->prov_transport_open(handle->transport_handle, ek_value, srk_value, on_transport_registration_data, handle, on_transport_status, handle) != 0)
if (handle->prov_transport_protocol->prov_transport_open(handle->transport_handle, handle->registration_id, ek_value, srk_value, on_transport_registration_data, handle, on_transport_status, handle) != 0)
{
LogError("Failure establishing connection");
if (!handle->user_supplied_reg_id)
{
free(handle->registration_id);
handle->registration_id = NULL;
}
handle->register_callback = NULL;
handle->user_context = NULL;
@ -889,6 +923,7 @@ PROV_DEVICE_RESULT Prov_Device_LL_SetOption(PROV_DEVICE_LL_HANDLE handle, const
}
else
{
handle->user_supplied_reg_id = true;
result = PROV_DEVICE_RESULT_OK;
}
}

Просмотреть файл

@ -270,7 +270,7 @@ static CONCRETE_SASL_MECHANISM_HANDLE prov_sasltpm_create(void* config)
else if (config_info->scope_id == NULL || mallocAndStrcpy_s(&result->scope_id, config_info->scope_id) != 0)
{
/* Codes_SRS_PROV_SASL_TPM_07_004: [ if SASL_TPM_CONFIG_INFO, challenge_cb, endorsement_key, storage_root_key, or hostname, registration_id is NULL, prov_sasltpm_create shall fail and return NULL. ] */
LogError("Failure copying registration_id");
LogError("Failure copying scope Id");
cleanup_sasl_data(result);
result = NULL;
}

Просмотреть файл

@ -107,10 +107,10 @@ static PROV_TRANSPORT_IO_INFO* amqp_transport_io(const char* fqdn, SASL_MECHANIS
return result;
}
PROV_DEVICE_TRANSPORT_HANDLE prov_transport_amqp_create(const char* uri, TRANSPORT_HSM_TYPE type, const char* scope_id, const char* registration_id, const char* api_version)
PROV_DEVICE_TRANSPORT_HANDLE prov_transport_amqp_create(const char* uri, TRANSPORT_HSM_TYPE type, const char* scope_id, const char* api_version)
{
/* Codes_PROV_TRANSPORT_AMQP_CLIENT_07_001: [ prov_transport_amqp_create shall call the prov_transport_common_amqp_create function with amqp_transport_io transport IO estabishment. ] */
return prov_transport_common_amqp_create(uri, type, scope_id, registration_id, api_version, amqp_transport_io);
return prov_transport_common_amqp_create(uri, type, scope_id, api_version, amqp_transport_io);
}
void prov_transport_amqp_destroy(PROV_DEVICE_TRANSPORT_HANDLE handle)
@ -119,10 +119,10 @@ void prov_transport_amqp_destroy(PROV_DEVICE_TRANSPORT_HANDLE handle)
prov_transport_common_amqp_destroy(handle);
}
int prov_transport_amqp_open(PROV_DEVICE_TRANSPORT_HANDLE handle, BUFFER_HANDLE ek, BUFFER_HANDLE srk, PROV_DEVICE_TRANSPORT_REGISTER_CALLBACK data_callback, void* user_ctx, PROV_DEVICE_TRANSPORT_STATUS_CALLBACK status_cb, void* status_ctx)
int prov_transport_amqp_open(PROV_DEVICE_TRANSPORT_HANDLE handle, const char* registration_id, BUFFER_HANDLE ek, BUFFER_HANDLE srk, PROV_DEVICE_TRANSPORT_REGISTER_CALLBACK data_callback, void* user_ctx, PROV_DEVICE_TRANSPORT_STATUS_CALLBACK status_cb, void* status_ctx)
{
/* Codes_PROV_TRANSPORT_AMQP_CLIENT_07_003: [ prov_transport_amqp_open shall invoke the prov_transport_common_amqp_open method ] */
return prov_transport_common_amqp_open(handle, ek, srk, data_callback, user_ctx, status_cb, status_ctx);
return prov_transport_common_amqp_open(handle, registration_id, ek, srk, data_callback, user_ctx, status_cb, status_ctx);
}
int prov_transport_amqp_close(PROV_DEVICE_TRANSPORT_HANDLE handle)

Просмотреть файл

@ -855,13 +855,13 @@ void cleanup_amqp_data(PROV_TRANSPORT_AMQP_INFO* amqp_info)
free(amqp_info);
}
PROV_DEVICE_TRANSPORT_HANDLE prov_transport_common_amqp_create(const char* uri, TRANSPORT_HSM_TYPE type, const char* scope_id, const char* registration_id, const char* api_version, PROV_AMQP_TRANSPORT_IO transport_io)
PROV_DEVICE_TRANSPORT_HANDLE prov_transport_common_amqp_create(const char* uri, TRANSPORT_HSM_TYPE type, const char* scope_id, const char* api_version, PROV_AMQP_TRANSPORT_IO transport_io)
{
PROV_TRANSPORT_AMQP_INFO* result;
if (uri == NULL || scope_id == NULL || registration_id == NULL || api_version == NULL || transport_io == NULL)
if (uri == NULL || scope_id == NULL || api_version == NULL || transport_io == NULL)
{
/* Codes_PROV_TRANSPORT_AMQP_COMMON_07_001: [ If uri, scope_id, registration_id, api_version, or transport_io is NULL, prov_transport_common_amqp_create shall return NULL. ] */
LogError("Invalid parameter specified uri: %p, scope_id: %p, registration_id: %p, api_version: %p, transport_io: %p", uri, scope_id, registration_id, api_version, transport_io);
LogError("Invalid parameter specified uri: %p, scope_id: %p, api_version: %p, transport_io: %p", uri, scope_id, api_version, transport_io);
result = NULL;
}
else
@ -883,13 +883,6 @@ PROV_DEVICE_TRANSPORT_HANDLE prov_transport_common_amqp_create(const char* uri,
free(result);
result = NULL;
}
else if (mallocAndStrcpy_s(&result->registration_id, registration_id) != 0)
{
/* Codes_PROV_TRANSPORT_AMQP_COMMON_07_002: [ If any error is encountered, prov_transport_common_amqp_create shall return NULL. ] */
LogError("failure constructing registration Id");
cleanup_amqp_data(result);
result = NULL;
}
else if (mallocAndStrcpy_s(&result->api_version, api_version) != 0)
{
/* Codes_PROV_TRANSPORT_AMQP_COMMON_07_002: [ If any error is encountered, prov_transport_common_amqp_create shall return NULL. ] */
@ -926,14 +919,14 @@ void prov_transport_common_amqp_destroy(PROV_DEVICE_TRANSPORT_HANDLE handle)
}
}
int prov_transport_common_amqp_open(PROV_DEVICE_TRANSPORT_HANDLE handle, BUFFER_HANDLE ek, BUFFER_HANDLE srk, PROV_DEVICE_TRANSPORT_REGISTER_CALLBACK data_callback, void* user_ctx, PROV_DEVICE_TRANSPORT_STATUS_CALLBACK status_cb, void* status_ctx)
int prov_transport_common_amqp_open(PROV_DEVICE_TRANSPORT_HANDLE handle, const char* registration_id, BUFFER_HANDLE ek, BUFFER_HANDLE srk, PROV_DEVICE_TRANSPORT_REGISTER_CALLBACK data_callback, void* user_ctx, PROV_DEVICE_TRANSPORT_STATUS_CALLBACK status_cb, void* status_ctx)
{
int result;
PROV_TRANSPORT_AMQP_INFO* amqp_info = (PROV_TRANSPORT_AMQP_INFO*)handle;
if (amqp_info == NULL || data_callback == NULL || status_cb == NULL)
if (amqp_info == NULL || data_callback == NULL || status_cb == NULL || registration_id == NULL)
{
/* Codes_PROV_TRANSPORT_AMQP_COMMON_07_007: [ If handle, data_callback, or status_cb is NULL, prov_transport_common_amqp_open shall return a non-zero value. ] */
LogError("Invalid parameter specified handle: %p, data_callback: %p, status_cb: %p", handle, data_callback, status_cb);
LogError("Invalid parameter specified handle: %p, data_callback: %p, status_cb: %p, registration_id: %p", handle, data_callback, status_cb, registration_id);
result = __FAILURE__;
}
else if ( (amqp_info->hsm_type == TRANSPORT_HSM_TYPE_TPM) && (ek == NULL || srk == NULL) )
@ -957,6 +950,16 @@ int prov_transport_common_amqp_open(PROV_DEVICE_TRANSPORT_HANDLE handle, BUFFER_
amqp_info->ek = NULL;
result = __FAILURE__;
}
else if (mallocAndStrcpy_s(&amqp_info->registration_id, registration_id) != 0)
{
/* Codes_PROV_TRANSPORT_HTTP_CLIENT_07_003: [ If any error is encountered prov_transport_http_create shall return NULL. ] */
LogError("failure constructing registration Id");
BUFFER_delete(amqp_info->ek);
amqp_info->ek = NULL;
BUFFER_delete(amqp_info->srk);
amqp_info->srk = NULL;
result = __FAILURE__;
}
else
{
/* Codes_PROV_TRANSPORT_AMQP_COMMON_07_010: [ When complete prov_transport_common_amqp_open shall send a status callback of PROV_DEVICE_TRANSPORT_STATUS_CONNECTED.] */
@ -988,6 +991,9 @@ int prov_transport_common_amqp_close(PROV_DEVICE_TRANSPORT_HANDLE handle)
BUFFER_delete(amqp_info->srk);
amqp_info->srk = NULL;
free(amqp_info->registration_id);
amqp_info->registration_id = NULL;
/* Codes_PROV_TRANSPORT_AMQP_COMMON_07_012: [ prov_transport_common_amqp_close shall close all links and connection associated with amqp communication. ] */
messagesender_close(amqp_info->msg_sender);
messagereceiver_close(amqp_info->msg_receiver);

Просмотреть файл

@ -127,10 +127,10 @@ static PROV_TRANSPORT_IO_INFO* amqp_transport_ws_io(const char* fqdn, SASL_MECHA
return result;
}
PROV_DEVICE_TRANSPORT_HANDLE prov_transport_amqp_ws_create(const char* uri, TRANSPORT_HSM_TYPE type, const char* scope_id, const char* registration_id, const char* api_version)
PROV_DEVICE_TRANSPORT_HANDLE prov_transport_amqp_ws_create(const char* uri, TRANSPORT_HSM_TYPE type, const char* scope_id, const char* api_version)
{
/* Codes_PROV_TRANSPORT_AMQP_WS_CLIENT_07_001: [ prov_transport_amqp_ws_create shall call the prov_transport_common_amqp_create function with amqp_transport_ws_io transport IO estabishment. ] */
return prov_transport_common_amqp_create(uri, type, scope_id, registration_id, api_version, amqp_transport_ws_io);
return prov_transport_common_amqp_create(uri, type, scope_id, api_version, amqp_transport_ws_io);
}
void prov_transport_amqp_ws_destroy(PROV_DEVICE_TRANSPORT_HANDLE handle)
@ -139,10 +139,10 @@ void prov_transport_amqp_ws_destroy(PROV_DEVICE_TRANSPORT_HANDLE handle)
prov_transport_common_amqp_destroy(handle);
}
int prov_transport_amqp_ws_open(PROV_DEVICE_TRANSPORT_HANDLE handle, BUFFER_HANDLE ek, BUFFER_HANDLE srk, PROV_DEVICE_TRANSPORT_REGISTER_CALLBACK data_callback, void* user_ctx, PROV_DEVICE_TRANSPORT_STATUS_CALLBACK status_cb, void* status_ctx)
int prov_transport_amqp_ws_open(PROV_DEVICE_TRANSPORT_HANDLE handle, const char* registration_id, BUFFER_HANDLE ek, BUFFER_HANDLE srk, PROV_DEVICE_TRANSPORT_REGISTER_CALLBACK data_callback, void* user_ctx, PROV_DEVICE_TRANSPORT_STATUS_CALLBACK status_cb, void* status_ctx)
{
/* Codes_PROV_TRANSPORT_AMQP_WS_CLIENT_07_003: [ prov_transport_amqp_ws_open shall invoke the prov_transport_common_amqp_open method ] */
return prov_transport_common_amqp_open(handle, ek, srk, data_callback, user_ctx, status_cb, status_ctx);
return prov_transport_common_amqp_open(handle, registration_id, ek, srk, data_callback, user_ctx, status_cb, status_ctx);
}
int prov_transport_amqp_ws_close(PROV_DEVICE_TRANSPORT_HANDLE handle)

Просмотреть файл

@ -602,13 +602,13 @@ static int create_connection(PROV_TRANSPORT_HTTP_INFO* http_info)
return result;
}
PROV_DEVICE_TRANSPORT_HANDLE prov_transport_http_create(const char* uri, TRANSPORT_HSM_TYPE type, const char* scope_id, const char* registration_id, const char* api_version)
PROV_DEVICE_TRANSPORT_HANDLE prov_transport_http_create(const char* uri, TRANSPORT_HSM_TYPE type, const char* scope_id, const char* api_version)
{
PROV_TRANSPORT_HTTP_INFO* result;
if (uri == NULL || scope_id == NULL || registration_id == NULL || api_version == NULL)
if (uri == NULL || scope_id == NULL || api_version == NULL)
{
/* Codes_PROV_TRANSPORT_HTTP_CLIENT_07_001: [ If uri, scope_id, registration_id or api_version are NULL prov_transport_http_create shall return NULL. ] */
LogError("Invalid parameter specified uri: %p, scope_id: %p, registration_id: %p, api_version: %p", uri, scope_id, registration_id, api_version);
LogError("Invalid parameter specified uri: %p, scope_id: %p, api_version: %p", uri, scope_id, api_version);
result = NULL;
}
else
@ -630,13 +630,6 @@ PROV_DEVICE_TRANSPORT_HANDLE prov_transport_http_create(const char* uri, TRANSPO
free(result);
result = NULL;
}
else if (mallocAndStrcpy_s(&result->registration_id, registration_id) != 0)
{
/* Codes_PROV_TRANSPORT_HTTP_CLIENT_07_003: [ If any error is encountered prov_transport_http_create shall return NULL. ] */
LogError("failure constructing registration Id");
free_allocated_data(result);
result = NULL;
}
else if (mallocAndStrcpy_s(&result->api_version, api_version) != 0)
{
/* Codes_PROV_TRANSPORT_HTTP_CLIENT_07_003: [ If any error is encountered prov_transport_http_create shall return NULL. ] */
@ -672,14 +665,14 @@ void prov_transport_http_destroy(PROV_DEVICE_TRANSPORT_HANDLE handle)
}
}
int prov_transport_http_open(PROV_DEVICE_TRANSPORT_HANDLE handle, BUFFER_HANDLE ek, BUFFER_HANDLE srk, PROV_DEVICE_TRANSPORT_REGISTER_CALLBACK data_callback, void* user_ctx, PROV_DEVICE_TRANSPORT_STATUS_CALLBACK status_cb, void* status_ctx)
int prov_transport_http_open(PROV_DEVICE_TRANSPORT_HANDLE handle, const char* registration_id, BUFFER_HANDLE ek, BUFFER_HANDLE srk, PROV_DEVICE_TRANSPORT_REGISTER_CALLBACK data_callback, void* user_ctx, PROV_DEVICE_TRANSPORT_STATUS_CALLBACK status_cb, void* status_ctx)
{
int result;
PROV_TRANSPORT_HTTP_INFO* http_info = (PROV_TRANSPORT_HTTP_INFO*)handle;
if (http_info == NULL || data_callback == NULL || status_cb == NULL)
if (http_info == NULL || data_callback == NULL || status_cb == NULL || registration_id == NULL)
{
/* Codes_PROV_TRANSPORT_HTTP_CLIENT_07_008: [ If the argument handle, data_callback, or status_cb are NULL, prov_transport_http_open shall return a non-zero value. ] */
LogError("Invalid parameter specified handle: %p, data_callback: %p, status_cb: %p", handle, data_callback, status_cb);
LogError("Invalid parameter specified handle: %p, data_callback: %p, status_cb: %p, registration_id: %p", handle, data_callback, status_cb, registration_id);
result = __FAILURE__;
}
else if (http_info->hsm_type == TRANSPORT_HSM_TYPE_TPM && (ek == NULL || srk == NULL))
@ -699,6 +692,16 @@ int prov_transport_http_open(PROV_DEVICE_TRANSPORT_HANDLE handle, BUFFER_HANDLE
http_info->ek = NULL;
result = __FAILURE__;
}
else if (mallocAndStrcpy_s(&http_info->registration_id, registration_id) != 0)
{
/* Codes_PROV_TRANSPORT_HTTP_CLIENT_07_003: [ If any error is encountered prov_transport_http_create shall return NULL. ] */
LogError("failure constructing registration Id");
BUFFER_delete(http_info->ek);
http_info->ek = NULL;
BUFFER_delete(http_info->srk);
http_info->srk = NULL;
result = __FAILURE__;
}
else
{
http_info->register_data_cb = data_callback;
@ -724,6 +727,8 @@ int prov_transport_http_open(PROV_DEVICE_TRANSPORT_HANDLE handle, BUFFER_HANDLE
http_info->user_ctx = NULL;
http_info->status_cb = NULL;
http_info->status_ctx = NULL;
free(http_info->registration_id);
http_info->registration_id = NULL;
result = __FAILURE__;
}
else
@ -754,6 +759,8 @@ int prov_transport_http_close(PROV_DEVICE_TRANSPORT_HANDLE handle)
http_info->ek = NULL;
BUFFER_delete(http_info->srk);
http_info->srk = NULL;
free(http_info->registration_id);
http_info->registration_id = NULL;
uhttp_client_close(http_info->http_client, NULL, NULL);
uhttp_client_dowork(http_info->http_client);

Просмотреть файл

@ -64,10 +64,10 @@ static XIO_HANDLE mqtt_transport_io(const char* fqdn, const HTTP_PROXY_OPTIONS*
return result;
}
PROV_DEVICE_TRANSPORT_HANDLE prov_transport_mqtt_create(const char* uri, TRANSPORT_HSM_TYPE type, const char* scope_id, const char* registration_id, const char* api_version)
PROV_DEVICE_TRANSPORT_HANDLE prov_transport_mqtt_create(const char* uri, TRANSPORT_HSM_TYPE type, const char* scope_id, const char* api_version)
{
/* Codes_PROV_TRANSPORT_MQTT_CLIENT_07_001: [ prov_transport_mqtt_create shall call the prov_transport_common_mqtt_create function with mqtt_transport_io transport IO estabishment. ] */
return prov_transport_common_mqtt_create(uri, type, scope_id, registration_id, api_version, mqtt_transport_io);
return prov_transport_common_mqtt_create(uri, type, scope_id, api_version, mqtt_transport_io);
}
void prov_transport_mqtt_destroy(PROV_DEVICE_TRANSPORT_HANDLE handle)
@ -76,10 +76,10 @@ void prov_transport_mqtt_destroy(PROV_DEVICE_TRANSPORT_HANDLE handle)
prov_transport_common_mqtt_destroy(handle);
}
int prov_transport_mqtt_open(PROV_DEVICE_TRANSPORT_HANDLE handle, BUFFER_HANDLE ek, BUFFER_HANDLE srk, PROV_DEVICE_TRANSPORT_REGISTER_CALLBACK data_callback, void* user_ctx, PROV_DEVICE_TRANSPORT_STATUS_CALLBACK status_cb, void* status_ctx)
int prov_transport_mqtt_open(PROV_DEVICE_TRANSPORT_HANDLE handle, const char* registration_id, BUFFER_HANDLE ek, BUFFER_HANDLE srk, PROV_DEVICE_TRANSPORT_REGISTER_CALLBACK data_callback, void* user_ctx, PROV_DEVICE_TRANSPORT_STATUS_CALLBACK status_cb, void* status_ctx)
{
/* Codes_PROV_TRANSPORT_MQTT_CLIENT_07_003: [ prov_transport_mqtt_open shall invoke the prov_transport_common_mqtt_open method ] */
return prov_transport_common_mqtt_open(handle, ek, srk, data_callback, user_ctx, status_cb, status_ctx);
return prov_transport_common_mqtt_open(handle, registration_id, ek, srk, data_callback, user_ctx, status_cb, status_ctx);
}
int prov_transport_mqtt_close(PROV_DEVICE_TRANSPORT_HANDLE handle)

Просмотреть файл

@ -576,13 +576,13 @@ void cleanup_mqtt_data(PROV_TRANSPORT_MQTT_INFO* mqtt_info)
free(mqtt_info);
}
PROV_DEVICE_TRANSPORT_HANDLE prov_transport_common_mqtt_create(const char* uri, TRANSPORT_HSM_TYPE type, const char* scope_id, const char* registration_id, const char* api_version, PROV_MQTT_TRANSPORT_IO transport_io)
PROV_DEVICE_TRANSPORT_HANDLE prov_transport_common_mqtt_create(const char* uri, TRANSPORT_HSM_TYPE type, const char* scope_id, const char* api_version, PROV_MQTT_TRANSPORT_IO transport_io)
{
PROV_TRANSPORT_MQTT_INFO* result;
if (uri == NULL || scope_id == NULL || registration_id == NULL || api_version == NULL || transport_io == NULL)
if (uri == NULL || scope_id == NULL || api_version == NULL || transport_io == NULL)
{
/* Codes_PROV_TRANSPORT_MQTT_COMMON_07_001: [ If uri, scope_id, registration_id, api_version, or transport_io is NULL, prov_transport_common_mqtt_create shall return NULL. ] */
LogError("Invalid parameter specified uri: %p, scope_id: %p, registration_id: %p, api_version: %p, transport_io: %p", uri, scope_id, registration_id, api_version, transport_io);
LogError("Invalid parameter specified uri: %p, scope_id: %p, api_version: %p, transport_io: %p", uri, scope_id, api_version, transport_io);
result = NULL;
}
else if (type == TRANSPORT_HSM_TYPE_TPM)
@ -610,13 +610,6 @@ PROV_DEVICE_TRANSPORT_HANDLE prov_transport_common_mqtt_create(const char* uri,
free(result);
result = NULL;
}
else if (mallocAndStrcpy_s(&result->registration_id, registration_id) != 0)
{
/* Codes_PROV_TRANSPORT_MQTT_COMMON_07_002: [ If any error is encountered, prov_transport_common_mqtt_create shall return NULL. ] */
LogError("failure constructing registration Id");
cleanup_mqtt_data(result);
result = NULL;
}
else if (mallocAndStrcpy_s(&result->api_version, api_version) != 0)
{
/* Codes_PROV_TRANSPORT_MQTT_COMMON_07_002: [ If any error is encountered, prov_transport_common_mqtt_create shall return NULL. ] */
@ -662,14 +655,14 @@ void prov_transport_common_mqtt_destroy(PROV_DEVICE_TRANSPORT_HANDLE handle)
}
}
int prov_transport_common_mqtt_open(PROV_DEVICE_TRANSPORT_HANDLE handle, BUFFER_HANDLE ek, BUFFER_HANDLE srk, PROV_DEVICE_TRANSPORT_REGISTER_CALLBACK data_callback, void* user_ctx, PROV_DEVICE_TRANSPORT_STATUS_CALLBACK status_cb, void* status_ctx)
int prov_transport_common_mqtt_open(PROV_DEVICE_TRANSPORT_HANDLE handle, const char* registration_id, BUFFER_HANDLE ek, BUFFER_HANDLE srk, PROV_DEVICE_TRANSPORT_REGISTER_CALLBACK data_callback, void* user_ctx, PROV_DEVICE_TRANSPORT_STATUS_CALLBACK status_cb, void* status_ctx)
{
int result;
PROV_TRANSPORT_MQTT_INFO* mqtt_info = (PROV_TRANSPORT_MQTT_INFO*)handle;
if (mqtt_info == NULL || data_callback == NULL || status_cb == NULL)
if (mqtt_info == NULL || data_callback == NULL || status_cb == NULL || registration_id == NULL)
{
/* Tests_PROV_TRANSPORT_MQTT_COMMON_07_007: [ If handle, data_callback, or status_cb is NULL, prov_transport_common_mqtt_open shall return a non-zero value. ] */
LogError("Invalid parameter specified handle: %p, data_callback: %p, status_cb: %p", handle, data_callback, status_cb);
LogError("Invalid parameter specified handle: %p, data_callback: %p, status_cb: %p, registration_id: %p", handle, data_callback, status_cb, registration_id);
result = __FAILURE__;
}
else if ( (mqtt_info->hsm_type == TRANSPORT_HSM_TYPE_TPM) && (ek == NULL || srk == NULL) )
@ -693,6 +686,16 @@ int prov_transport_common_mqtt_open(PROV_DEVICE_TRANSPORT_HANDLE handle, BUFFER_
mqtt_info->ek = NULL;
result = __FAILURE__;
}
else if (mallocAndStrcpy_s(&mqtt_info->registration_id, registration_id) != 0)
{
/* Codes_PROV_TRANSPORT_HTTP_CLIENT_07_003: [ If any error is encountered prov_transport_http_create shall return NULL. ] */
LogError("failure constructing registration Id");
BUFFER_delete(mqtt_info->ek);
mqtt_info->ek = NULL;
BUFFER_delete(mqtt_info->srk);
mqtt_info->srk = NULL;
result = __FAILURE__;
}
else
{
mqtt_info->register_data_cb = data_callback;
@ -721,6 +724,8 @@ int prov_transport_common_mqtt_close(PROV_DEVICE_TRANSPORT_HANDLE handle)
mqtt_info->ek = NULL;
BUFFER_delete(mqtt_info->srk);
mqtt_info->srk = NULL;
free(mqtt_info->registration_id);
mqtt_info->registration_id = NULL;
/* Tests_PROV_TRANSPORT_MQTT_COMMON_07_012: [ prov_transport_common_mqtt_close shall close all connection associated with mqtt communication. ] */
if (mqtt_client_disconnect(mqtt_info->mqtt_client, NULL, NULL) == 0)

Просмотреть файл

@ -80,10 +80,10 @@ static XIO_HANDLE mqtt_transport_ws_io(const char* fqdn, const HTTP_PROXY_OPTION
return result;
}
PROV_DEVICE_TRANSPORT_HANDLE prov_transport_mqtt_ws_create(const char* uri, TRANSPORT_HSM_TYPE type, const char* scope_id, const char* registration_id, const char* api_version)
PROV_DEVICE_TRANSPORT_HANDLE prov_transport_mqtt_ws_create(const char* uri, TRANSPORT_HSM_TYPE type, const char* scope_id, const char* api_version)
{
/* Codes_PROV_TRANSPORT_MQTT_WS_CLIENT_07_001: [ prov_transport_mqtt_ws_create shall call the prov_trans_common_mqtt_create function with mqtt_transport_ws_io transport IO estabishment. ] */
return prov_transport_common_mqtt_create(uri, type, scope_id, registration_id, api_version, mqtt_transport_ws_io);
return prov_transport_common_mqtt_create(uri, type, scope_id, api_version, mqtt_transport_ws_io);
}
void prov_transport_mqtt_ws_destroy(PROV_DEVICE_TRANSPORT_HANDLE handle)
@ -92,10 +92,10 @@ void prov_transport_mqtt_ws_destroy(PROV_DEVICE_TRANSPORT_HANDLE handle)
prov_transport_common_mqtt_destroy(handle);
}
int prov_transport_mqtt_ws_open(PROV_DEVICE_TRANSPORT_HANDLE handle, BUFFER_HANDLE ek, BUFFER_HANDLE srk, PROV_DEVICE_TRANSPORT_REGISTER_CALLBACK data_callback, void* user_ctx, PROV_DEVICE_TRANSPORT_STATUS_CALLBACK status_cb, void* status_ctx)
int prov_transport_mqtt_ws_open(PROV_DEVICE_TRANSPORT_HANDLE handle, const char* registration_id, BUFFER_HANDLE ek, BUFFER_HANDLE srk, PROV_DEVICE_TRANSPORT_REGISTER_CALLBACK data_callback, void* user_ctx, PROV_DEVICE_TRANSPORT_STATUS_CALLBACK status_cb, void* status_ctx)
{
/* Codes_PROV_TRANSPORT_MQTT_WS_CLIENT_07_003: [ prov_transport_mqtt_ws_open shall invoke the prov_transport_common_mqtt_open method ] */
return prov_transport_common_mqtt_open(handle, ek, srk, data_callback, user_ctx, status_cb, status_ctx);
return prov_transport_common_mqtt_open(handle, registration_id, ek, srk, data_callback, user_ctx, status_cb, status_ctx);
}
int prov_transport_mqtt_ws_close(PROV_DEVICE_TRANSPORT_HANDLE handle)

Просмотреть файл

@ -52,9 +52,9 @@ MOCKABLE_FUNCTION(, void, on_prov_register_device_callback, PROV_DEVICE_RESULT,
MOCKABLE_FUNCTION(, void, on_prov_register_status_callback, PROV_DEVICE_REG_STATUS, reg_status, void*, user_context);
MOCKABLE_FUNCTION(, char*, on_prov_transport_challenge_cb, const unsigned char*, nonce, size_t, nonce_len, const char*, key_name, void*, user_ctx);
MOCKABLE_FUNCTION(, PROV_DEVICE_TRANSPORT_HANDLE, prov_transport_create, const char*, uri, TRANSPORT_HSM_TYPE, type, const char*, scope_id, const char*, registration_id, const char*, prov_api_version);
MOCKABLE_FUNCTION(, PROV_DEVICE_TRANSPORT_HANDLE, prov_transport_create, const char*, uri, TRANSPORT_HSM_TYPE, type, const char*, scope_id, const char*, prov_api_version);
MOCKABLE_FUNCTION(, void, prov_transport_destroy, PROV_DEVICE_TRANSPORT_HANDLE, handle);
MOCKABLE_FUNCTION(, int, prov_transport_open, PROV_DEVICE_TRANSPORT_HANDLE, handle, BUFFER_HANDLE, ek, BUFFER_HANDLE, srk, PROV_DEVICE_TRANSPORT_REGISTER_CALLBACK, data_callback, void*, user_ctx, PROV_DEVICE_TRANSPORT_STATUS_CALLBACK, status_cb, void*, status_ctx);
MOCKABLE_FUNCTION(, int, prov_transport_open, PROV_DEVICE_TRANSPORT_HANDLE, handle, const char*, registration_id, BUFFER_HANDLE, ek, BUFFER_HANDLE, srk, PROV_DEVICE_TRANSPORT_REGISTER_CALLBACK, data_callback, void*, user_ctx, PROV_DEVICE_TRANSPORT_STATUS_CALLBACK, status_cb, void*, status_ctx);
MOCKABLE_FUNCTION(, int, prov_transport_close, PROV_DEVICE_TRANSPORT_HANDLE, handle);
MOCKABLE_FUNCTION(, int, prov_transport_register_device, PROV_DEVICE_TRANSPORT_HANDLE, handle, PROV_TRANSPORT_CHALLENGE_CALLBACK, reg_challenge_cb, void*, user_ctx, PROV_TRANSPORT_JSON_PARSE, json_parse_cb, void*, json_ctx);
MOCKABLE_FUNCTION(, int, prov_transport_get_operation_status, PROV_DEVICE_TRANSPORT_HANDLE, handle);
@ -225,12 +225,11 @@ static void my_BUFFER_delete(BUFFER_HANDLE handle)
my_gballoc_free(handle);
}
static PROV_DEVICE_TRANSPORT_HANDLE my_prov_transport_create(const char* uri, TRANSPORT_HSM_TYPE type, const char* scope_id, const char* registration_id, const char* prov_api_version)
static PROV_DEVICE_TRANSPORT_HANDLE my_prov_transport_create(const char* uri, TRANSPORT_HSM_TYPE type, const char* scope_id, const char* prov_api_version)
{
(void)type;
(void)uri;
(void)scope_id;
(void)registration_id;
(void)prov_api_version;
return (PROV_DEVICE_TRANSPORT_HANDLE)my_gballoc_malloc(1);
}
@ -240,11 +239,12 @@ static void my_prov_transport_destroy(PROV_DEVICE_TRANSPORT_HANDLE handle)
my_gballoc_free(handle);
}
static int my_prov_transport_open(PROV_DEVICE_TRANSPORT_HANDLE handle, BUFFER_HANDLE ek, BUFFER_HANDLE srk, PROV_DEVICE_TRANSPORT_REGISTER_CALLBACK data_callback, void* user_ctx, PROV_DEVICE_TRANSPORT_STATUS_CALLBACK status_cb, void* status_ctx)
static int my_prov_transport_open(PROV_DEVICE_TRANSPORT_HANDLE handle, const char* registration_id, BUFFER_HANDLE ek, BUFFER_HANDLE srk, PROV_DEVICE_TRANSPORT_REGISTER_CALLBACK data_callback, void* user_ctx, PROV_DEVICE_TRANSPORT_STATUS_CALLBACK status_cb, void* status_ctx)
{
(void)handle;
(void)ek;
(void)srk;
(void)registration_id;
g_registration_callback = data_callback;
g_registration_ctx = user_ctx;
g_status_callback = status_cb;
@ -546,14 +546,14 @@ BEGIN_TEST_SUITE(prov_device_client_ll_ut)
STRICT_EXPECTED_CALL(gballoc_malloc(IGNORED_NUM_ARG));
STRICT_EXPECTED_CALL(mallocAndStrcpy_s(IGNORED_PTR_ARG, IGNORED_NUM_ARG));
STRICT_EXPECTED_CALL(prov_auth_create());
STRICT_EXPECTED_CALL(prov_auth_get_registration_id(IGNORED_PTR_ARG));
STRICT_EXPECTED_CALL(tickcounter_create());
STRICT_EXPECTED_CALL(prov_auth_get_type(IGNORED_PTR_ARG)).SetReturn(type);
STRICT_EXPECTED_CALL(prov_transport_create(IGNORED_PTR_ARG, type == PROV_AUTH_TYPE_TPM ? TRANSPORT_HSM_TYPE_TPM : TRANSPORT_HSM_TYPE_X509, IGNORED_PTR_ARG, IGNORED_PTR_ARG, IGNORED_PTR_ARG));
STRICT_EXPECTED_CALL(prov_transport_create(IGNORED_PTR_ARG, type == PROV_AUTH_TYPE_TPM ? TRANSPORT_HSM_TYPE_TPM : TRANSPORT_HSM_TYPE_X509, IGNORED_PTR_ARG, IGNORED_PTR_ARG));
}
static void setup_Prov_Device_LL_Register_Device_mocks(bool tpm)
{
STRICT_EXPECTED_CALL(prov_auth_get_registration_id(IGNORED_PTR_ARG));
if (tpm)
{
STRICT_EXPECTED_CALL(prov_auth_get_endorsement_key(IGNORED_PTR_ARG));
@ -567,7 +567,7 @@ BEGIN_TEST_SUITE(prov_device_client_ll_ut)
STRICT_EXPECTED_CALL(gballoc_free(IGNORED_PTR_ARG));
STRICT_EXPECTED_CALL(gballoc_free(IGNORED_PTR_ARG));
}
STRICT_EXPECTED_CALL(prov_transport_open(IGNORED_PTR_ARG, IGNORED_PTR_ARG, IGNORED_PTR_ARG, IGNORED_PTR_ARG, IGNORED_PTR_ARG, IGNORED_PTR_ARG, IGNORED_PTR_ARG));
STRICT_EXPECTED_CALL(prov_transport_open(IGNORED_PTR_ARG, IGNORED_PTR_ARG, IGNORED_PTR_ARG, IGNORED_PTR_ARG, IGNORED_PTR_ARG, IGNORED_PTR_ARG, IGNORED_PTR_ARG, IGNORED_PTR_ARG));
STRICT_EXPECTED_CALL(BUFFER_delete(IGNORED_PTR_ARG));
STRICT_EXPECTED_CALL(BUFFER_delete(IGNORED_PTR_ARG));
}
@ -703,7 +703,7 @@ BEGIN_TEST_SUITE(prov_device_client_ll_ut)
umock_c_negative_tests_snapshot();
size_t calls_cannot_fail[] = { 5 };
size_t calls_cannot_fail[] = { 4 };
//act
size_t count = umock_c_negative_tests_call_count();
@ -848,7 +848,7 @@ BEGIN_TEST_SUITE(prov_device_client_ll_ut)
umock_c_negative_tests_snapshot();
size_t calls_cannot_fail[] = { 3, 4 };
size_t calls_cannot_fail[] = { 4, 5 };
//act
size_t count = umock_c_negative_tests_call_count();
@ -891,7 +891,7 @@ BEGIN_TEST_SUITE(prov_device_client_ll_ut)
umock_c_negative_tests_snapshot();
size_t calls_cannot_fail[] = { 3, 4, 6, 7 };
size_t calls_cannot_fail[] = { 4, 5, 7, 8 };
//act
size_t count = umock_c_negative_tests_call_count();
@ -1741,7 +1741,6 @@ BEGIN_TEST_SUITE(prov_device_client_ll_ut)
PROV_DEVICE_LL_HANDLE handle = Prov_Device_LL_Create(TEST_PROV_URI, TEST_SCOPE_ID, trans_provider);
umock_c_reset_all_calls();
STRICT_EXPECTED_CALL(gballoc_free(IGNORED_PTR_ARG));
STRICT_EXPECTED_CALL(mallocAndStrcpy_s(IGNORED_PTR_ARG, IGNORED_PTR_ARG));
STRICT_EXPECTED_CALL(prov_auth_set_registration_id(IGNORED_PTR_ARG, IGNORED_PTR_ARG));

Просмотреть файл

@ -85,12 +85,11 @@ IMPLEMENT_UMOCK_C_ENUM_TYPE(PROV_DEVICE_TRANSPORT_STATUS, PROV_DEVICE_TRANSPORT_
TEST_DEFINE_ENUM_TYPE(TRANSPORT_HSM_TYPE, HSM_AUTH_TYPE_VALUES);
IMPLEMENT_UMOCK_C_ENUM_TYPE(TRANSPORT_HSM_TYPE, HSM_AUTH_TYPE_VALUES);
static PROV_DEVICE_TRANSPORT_HANDLE my_prov_transport_common_amqp_create(const char* uri, TRANSPORT_HSM_TYPE type, const char* scope_id, const char* registration_id, const char* dps_api_version, PROV_AMQP_TRANSPORT_IO transport_io)
static PROV_DEVICE_TRANSPORT_HANDLE my_prov_transport_common_amqp_create(const char* uri, TRANSPORT_HSM_TYPE type, const char* scope_id, const char* dps_api_version, PROV_AMQP_TRANSPORT_IO transport_io)
{
(void)uri;
(void)type;
(void)scope_id;
(void)registration_id;
(void)dps_api_version;
g_transport_io = transport_io;
@ -211,10 +210,10 @@ BEGIN_TEST_SUITE(prov_transport_amqp_client_ut)
TEST_FUNCTION(prov_transport_amqp_create_succeed)
{
//arrange
STRICT_EXPECTED_CALL(prov_transport_common_amqp_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_REGISTRATION_ID_VALUE, TEST_DPS_API_VALUE, IGNORED_PTR_ARG));
STRICT_EXPECTED_CALL(prov_transport_common_amqp_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_DPS_API_VALUE, IGNORED_PTR_ARG));
//act
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_amqp_transport_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_REGISTRATION_ID_VALUE, TEST_DPS_API_VALUE);
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_amqp_transport_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_DPS_API_VALUE);
//assert
ASSERT_IS_NOT_NULL(handle);
@ -230,7 +229,7 @@ BEGIN_TEST_SUITE(prov_transport_amqp_client_ut)
{
SASL_MECHANISM_HANDLE sasl_mechanism = { 0 };
PROV_TRANSPORT_IO_INFO* dps_io_info;
(void)prov_amqp_transport_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_REGISTRATION_ID_VALUE, TEST_DPS_API_VALUE);
(void)prov_amqp_transport_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_DPS_API_VALUE);
umock_c_reset_all_calls();
//arrange
@ -256,7 +255,7 @@ BEGIN_TEST_SUITE(prov_transport_amqp_client_ut)
TEST_FUNCTION(prov_amqp_transport_ws_io_x509_succeed)
{
PROV_TRANSPORT_IO_INFO* dps_io_info;
(void)prov_amqp_transport_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_X509, TEST_SCOPE_ID_VALUE, TEST_REGISTRATION_ID_VALUE, TEST_DPS_API_VALUE);
(void)prov_amqp_transport_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_X509, TEST_SCOPE_ID_VALUE, TEST_DPS_API_VALUE);
umock_c_reset_all_calls();
//arrange
@ -281,7 +280,7 @@ BEGIN_TEST_SUITE(prov_transport_amqp_client_ut)
{
SASL_MECHANISM_HANDLE sasl_mechanism = { 0 };
PROV_TRANSPORT_IO_INFO* dps_io_info;
(void)prov_amqp_transport_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_REGISTRATION_ID_VALUE, TEST_DPS_API_VALUE);
(void)prov_amqp_transport_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_DPS_API_VALUE);
umock_c_reset_all_calls();
int negativeTestsInitResult = umock_c_negative_tests_init();
@ -332,7 +331,7 @@ BEGIN_TEST_SUITE(prov_transport_amqp_client_ut)
SASL_MECHANISM_HANDLE sasl_mechanism = { 0 };
HTTP_PROXY_OPTIONS proxy_info;
PROV_TRANSPORT_IO_INFO* dps_io_info;
(void)prov_amqp_transport_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_REGISTRATION_ID_VALUE, TEST_DPS_API_VALUE);
(void)prov_amqp_transport_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_DPS_API_VALUE);
umock_c_reset_all_calls();
//arrange
@ -378,10 +377,10 @@ BEGIN_TEST_SUITE(prov_transport_amqp_client_ut)
TEST_FUNCTION(prov_transport_amqp_open_succeed)
{
//arrange
STRICT_EXPECTED_CALL(prov_transport_common_amqp_open(TEST_DPS_HANDLE, TEST_BUFFER_VALUE, TEST_BUFFER_VALUE, on_transport_register_data_cb, NULL, on_transport_status_cb, NULL));
STRICT_EXPECTED_CALL(prov_transport_common_amqp_open(TEST_DPS_HANDLE, TEST_REGISTRATION_ID_VALUE, TEST_BUFFER_VALUE, TEST_BUFFER_VALUE, on_transport_register_data_cb, NULL, on_transport_status_cb, NULL));
//act
int result = prov_amqp_transport_open(TEST_DPS_HANDLE, TEST_BUFFER_VALUE, TEST_BUFFER_VALUE, on_transport_register_data_cb, NULL, on_transport_status_cb, NULL);
int result = prov_amqp_transport_open(TEST_DPS_HANDLE, TEST_REGISTRATION_ID_VALUE, TEST_BUFFER_VALUE, TEST_BUFFER_VALUE, on_transport_register_data_cb, NULL, on_transport_status_cb, NULL);
//assert
ASSERT_ARE_EQUAL(int, 0, result);

Просмотреть файл

@ -730,7 +730,6 @@ BEGIN_TEST_SUITE(prov_transport_amqp_common_ut)
{
STRICT_EXPECTED_CALL(gballoc_malloc(IGNORED_NUM_ARG));
STRICT_EXPECTED_CALL(mallocAndStrcpy_s(IGNORED_PTR_ARG, TEST_URI_VALUE));
STRICT_EXPECTED_CALL(mallocAndStrcpy_s(IGNORED_PTR_ARG, TEST_REGISTRATION_ID_VALUE));
STRICT_EXPECTED_CALL(mallocAndStrcpy_s(IGNORED_PTR_ARG, TEST_DPS_API_VALUE));
STRICT_EXPECTED_CALL(mallocAndStrcpy_s(IGNORED_PTR_ARG, TEST_SCOPE_ID_VALUE));
}
@ -741,7 +740,7 @@ BEGIN_TEST_SUITE(prov_transport_amqp_common_ut)
//arrange
//act
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_amqp_create(NULL, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_REGISTRATION_ID_VALUE, TEST_DPS_API_VALUE, on_transport_io);
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_amqp_create(NULL, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_DPS_API_VALUE, on_transport_io);
//assert
ASSERT_IS_NULL(handle);
@ -756,23 +755,7 @@ BEGIN_TEST_SUITE(prov_transport_amqp_common_ut)
//arrange
//act
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_amqp_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, NULL, TEST_REGISTRATION_ID_VALUE, TEST_DPS_API_VALUE, on_transport_io);
//assert
ASSERT_IS_NULL(handle);
ASSERT_ARE_EQUAL(char_ptr, umock_c_get_expected_calls(), umock_c_get_actual_calls());
//cleanup
prov_transport_common_amqp_destroy(handle);
}
/* Tests_PROV_TRANSPORT_AMQP_COMMON_07_001: [ If uri, scope_id, registration_id, dps_api_version, or transport_io is NULL, prov_transport_common_amqp_create shall return NULL. ] */
TEST_FUNCTION(prov_transport_common_amqp_create_registration_id_NULL_fail)
{
//arrange
//act
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_amqp_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, NULL, TEST_DPS_API_VALUE, on_transport_io);
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_amqp_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, NULL, TEST_DPS_API_VALUE, on_transport_io);
//assert
ASSERT_IS_NULL(handle);
@ -788,7 +771,7 @@ BEGIN_TEST_SUITE(prov_transport_amqp_common_ut)
//arrange
//act
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_amqp_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_REGISTRATION_ID_VALUE, NULL, on_transport_io);
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_amqp_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, NULL, on_transport_io);
//assert
ASSERT_IS_NULL(handle);
@ -804,7 +787,7 @@ BEGIN_TEST_SUITE(prov_transport_amqp_common_ut)
//arrange
//act
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_amqp_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_REGISTRATION_ID_VALUE, TEST_DPS_API_VALUE, NULL);
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_amqp_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_DPS_API_VALUE, NULL);
//assert
ASSERT_IS_NULL(handle);
@ -836,7 +819,7 @@ BEGIN_TEST_SUITE(prov_transport_amqp_common_ut)
sprintf(tmp_msg, "prov_transport_common_amqp_create failure in test %zu/%zu", index, count);
//act
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_amqp_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_REGISTRATION_ID_VALUE, TEST_DPS_API_VALUE, on_transport_io);
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_amqp_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_DPS_API_VALUE, on_transport_io);
//assert
ASSERT_IS_NULL_WITH_MSG(handle, tmp_msg);
@ -853,7 +836,7 @@ BEGIN_TEST_SUITE(prov_transport_amqp_common_ut)
setup_prov_transport_common_amqp_create_mocks();
//act
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_amqp_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_REGISTRATION_ID_VALUE, TEST_DPS_API_VALUE, on_transport_io);
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_amqp_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_DPS_API_VALUE, on_transport_io);
//assert
ASSERT_IS_NOT_NULL(handle);
@ -880,7 +863,7 @@ BEGIN_TEST_SUITE(prov_transport_amqp_common_ut)
/* Tests_PROV_TRANSPORT_AMQP_COMMON_07_006: [ prov_transport_common_amqp_destroy shall free all resources used in this module. ] */
TEST_FUNCTION(prov_transport_common_amqp_destroy_succeed)
{
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_amqp_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_REGISTRATION_ID_VALUE, TEST_DPS_API_VALUE, on_transport_io);
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_amqp_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_DPS_API_VALUE, on_transport_io);
umock_c_reset_all_calls();
//arrange
@ -914,7 +897,7 @@ BEGIN_TEST_SUITE(prov_transport_amqp_common_ut)
//arrange
//act
int result = prov_transport_common_amqp_open(NULL, TEST_BUFFER_VALUE, TEST_BUFFER_VALUE, on_transport_register_data_cb, NULL, on_transport_status_cb, NULL);
int result = prov_transport_common_amqp_open(NULL, TEST_REGISTRATION_ID_VALUE, TEST_BUFFER_VALUE, TEST_BUFFER_VALUE, on_transport_register_data_cb, NULL, on_transport_status_cb, NULL);
//assert
ASSERT_ARE_NOT_EQUAL(int, 0, result);
@ -923,16 +906,34 @@ BEGIN_TEST_SUITE(prov_transport_amqp_common_ut)
//cleanup
}
/* Tests_PROV_TRANSPORT_AMQP_COMMON_07_007: [ If handle, data_callback, or status_cb is NULL, prov_transport_common_amqp_open shall return a non-zero value. ] */
TEST_FUNCTION(prov_transport_common_amqp_open_data_callback_NULL_fail)
TEST_FUNCTION(prov_transport_common_amqp_open_registration_id_NULL_fail)
{
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_amqp_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_REGISTRATION_ID_VALUE, TEST_DPS_API_VALUE, on_transport_io);
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_amqp_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_DPS_API_VALUE, on_transport_io);
umock_c_reset_all_calls();
//arrange
//act
int result = prov_transport_common_amqp_open(handle, TEST_BUFFER_VALUE, TEST_BUFFER_VALUE, NULL, NULL, on_transport_status_cb, NULL);
int result = prov_transport_common_amqp_open(handle, NULL, TEST_BUFFER_VALUE, TEST_BUFFER_VALUE, NULL, NULL, on_transport_status_cb, NULL);
//assert
ASSERT_ARE_NOT_EQUAL(int, 0, result);
ASSERT_ARE_EQUAL(char_ptr, umock_c_get_expected_calls(), umock_c_get_actual_calls());
//cleanup
prov_transport_common_amqp_destroy(handle);
}
/* Tests_PROV_TRANSPORT_AMQP_COMMON_07_007: [ If handle, data_callback, or status_cb is NULL, prov_transport_common_amqp_open shall return a non-zero value. ] */
TEST_FUNCTION(prov_transport_common_amqp_open_data_callback_NULL_fail)
{
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_amqp_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_DPS_API_VALUE, on_transport_io);
umock_c_reset_all_calls();
//arrange
//act
int result = prov_transport_common_amqp_open(handle, TEST_REGISTRATION_ID_VALUE, TEST_BUFFER_VALUE, TEST_BUFFER_VALUE, NULL, NULL, on_transport_status_cb, NULL);
//assert
ASSERT_ARE_NOT_EQUAL(int, 0, result);
@ -945,13 +946,13 @@ BEGIN_TEST_SUITE(prov_transport_amqp_common_ut)
/* Tests_PROV_TRANSPORT_AMQP_COMMON_07_007: [ If handle, data_callback, or status_cb is NULL, prov_transport_common_amqp_open shall return a non-zero value. ] */
TEST_FUNCTION(prov_transport_common_amqp_open_status_callback_NULL_fail)
{
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_amqp_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_REGISTRATION_ID_VALUE, TEST_DPS_API_VALUE, on_transport_io);
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_amqp_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_DPS_API_VALUE, on_transport_io);
umock_c_reset_all_calls();
//arrange
//act
int result = prov_transport_common_amqp_open(handle, TEST_BUFFER_VALUE, TEST_BUFFER_VALUE, on_transport_register_data_cb, NULL, NULL, NULL);
int result = prov_transport_common_amqp_open(handle, TEST_REGISTRATION_ID_VALUE, TEST_BUFFER_VALUE, TEST_BUFFER_VALUE, on_transport_register_data_cb, NULL, NULL, NULL);
//assert
ASSERT_ARE_NOT_EQUAL(int, 0, result);
@ -964,13 +965,13 @@ BEGIN_TEST_SUITE(prov_transport_amqp_common_ut)
/* Tests_PROV_TRANSPORT_AMQP_COMMON_07_008: [ If hsm_type is TRANSPORT_HSM_TYPE_TPM and ek or srk is NULL, prov_transport_common_amqp_open shall return a non-zero value. ] */
TEST_FUNCTION(prov_transport_common_amqp_open_ek_NULL_fail)
{
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_amqp_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_REGISTRATION_ID_VALUE, TEST_DPS_API_VALUE, on_transport_io);
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_amqp_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_DPS_API_VALUE, on_transport_io);
umock_c_reset_all_calls();
//arrange
//act
int result = prov_transport_common_amqp_open(handle, NULL, TEST_BUFFER_VALUE, on_transport_register_data_cb, NULL, on_transport_status_cb, NULL);
int result = prov_transport_common_amqp_open(handle, TEST_REGISTRATION_ID_VALUE, NULL, TEST_BUFFER_VALUE, on_transport_register_data_cb, NULL, on_transport_status_cb, NULL);
//assert
ASSERT_ARE_NOT_EQUAL(int, 0, result);
@ -983,13 +984,13 @@ BEGIN_TEST_SUITE(prov_transport_amqp_common_ut)
/* Tests_PROV_TRANSPORT_AMQP_COMMON_07_008: [ If hsm_type is TRANSPORT_HSM_TYPE_TPM and ek or srk is NULL, prov_transport_common_amqp_open shall return a non-zero value. ] */
TEST_FUNCTION(prov_transport_common_amqp_open_srk_NULL_fail)
{
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_amqp_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_REGISTRATION_ID_VALUE, TEST_DPS_API_VALUE, on_transport_io);
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_amqp_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_DPS_API_VALUE, on_transport_io);
umock_c_reset_all_calls();
//arrange
//act
int result = prov_transport_common_amqp_open(handle, TEST_BUFFER_VALUE, NULL, on_transport_register_data_cb, NULL, on_transport_status_cb, NULL);
int result = prov_transport_common_amqp_open(handle, TEST_REGISTRATION_ID_VALUE, TEST_BUFFER_VALUE, NULL, on_transport_register_data_cb, NULL, on_transport_status_cb, NULL);
//assert
ASSERT_ARE_NOT_EQUAL(int, 0, result);
@ -1003,16 +1004,17 @@ BEGIN_TEST_SUITE(prov_transport_amqp_common_ut)
/* Tests_PROV_TRANSPORT_AMQP_COMMON_07_009: [ prov_transport_common_amqp_open shall clone the ek and srk values.] */
TEST_FUNCTION(prov_transport_common_amqp_open_succeed)
{
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_amqp_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_REGISTRATION_ID_VALUE, TEST_DPS_API_VALUE, on_transport_io);
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_amqp_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_DPS_API_VALUE, on_transport_io);
umock_c_reset_all_calls();
//arrange
STRICT_EXPECTED_CALL(BUFFER_clone(IGNORED_PTR_ARG));
STRICT_EXPECTED_CALL(BUFFER_clone(IGNORED_PTR_ARG));
STRICT_EXPECTED_CALL(mallocAndStrcpy_s(IGNORED_PTR_ARG, TEST_REGISTRATION_ID_VALUE));
STRICT_EXPECTED_CALL(on_transport_status_cb(PROV_DEVICE_TRANSPORT_STATUS_CONNECTED, IGNORED_PTR_ARG));
//act
int result = prov_transport_common_amqp_open(handle, TEST_BUFFER_VALUE, TEST_BUFFER_VALUE, on_transport_register_data_cb, NULL, on_transport_status_cb, NULL);
int result = prov_transport_common_amqp_open(handle, TEST_REGISTRATION_ID_VALUE, TEST_BUFFER_VALUE, TEST_BUFFER_VALUE, on_transport_register_data_cb, NULL, on_transport_status_cb, NULL);
//assert
ASSERT_ARE_EQUAL(int, 0, result);
@ -1026,7 +1028,7 @@ BEGIN_TEST_SUITE(prov_transport_amqp_common_ut)
/* Tests_PROV_TRANSPORT_AMQP_COMMON_07_041: [ If a failure is encountered, prov_transport_common_amqp_open shall return a non-zero value. ] */
TEST_FUNCTION(prov_transport_common_amqp_open_fail)
{
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_amqp_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_REGISTRATION_ID_VALUE, TEST_DPS_API_VALUE, on_transport_io);
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_amqp_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_DPS_API_VALUE, on_transport_io);
umock_c_reset_all_calls();
int negativeTestsInitResult = umock_c_negative_tests_init();
@ -1056,7 +1058,7 @@ BEGIN_TEST_SUITE(prov_transport_amqp_common_ut)
char tmp_msg[64];
sprintf(tmp_msg, "prov_transport_common_amqp_open failure in test %zu/%zu", index, count);
int result = prov_transport_common_amqp_open(handle, TEST_BUFFER_VALUE, TEST_BUFFER_VALUE, on_transport_register_data_cb, NULL, on_transport_status_cb, NULL);
int result = prov_transport_common_amqp_open(handle, TEST_REGISTRATION_ID_VALUE, TEST_BUFFER_VALUE, TEST_BUFFER_VALUE, on_transport_register_data_cb, NULL, on_transport_status_cb, NULL);
//assert
ASSERT_ARE_NOT_EQUAL_WITH_MSG(int, 0, result, tmp_msg);
@ -1071,14 +1073,15 @@ BEGIN_TEST_SUITE(prov_transport_amqp_common_ut)
/* Tests_PROV_TRANSPORT_AMQP_COMMON_07_009: [ prov_transport_common_amqp_open shall clone the ek and srk values.] */
TEST_FUNCTION(prov_transport_common_amqp_open_x509_succeed)
{
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_amqp_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_X509, TEST_SCOPE_ID_VALUE, TEST_REGISTRATION_ID_VALUE, TEST_DPS_API_VALUE, on_transport_io);
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_amqp_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_X509, TEST_SCOPE_ID_VALUE, TEST_DPS_API_VALUE, on_transport_io);
umock_c_reset_all_calls();
//arrange
STRICT_EXPECTED_CALL(mallocAndStrcpy_s(IGNORED_PTR_ARG, TEST_REGISTRATION_ID_VALUE));
STRICT_EXPECTED_CALL(on_transport_status_cb(PROV_DEVICE_TRANSPORT_STATUS_CONNECTED, IGNORED_PTR_ARG));
//act
int result = prov_transport_common_amqp_open(handle, NULL, NULL, on_transport_register_data_cb, NULL, on_transport_status_cb, NULL);
int result = prov_transport_common_amqp_open(handle, TEST_REGISTRATION_ID_VALUE, NULL, NULL, on_transport_register_data_cb, NULL, on_transport_status_cb, NULL);
//assert
ASSERT_ARE_EQUAL(int, 0, result);
@ -1108,12 +1111,13 @@ BEGIN_TEST_SUITE(prov_transport_amqp_common_ut)
/* Tests_PROV_TRANSPORT_AMQP_COMMON_07_013: [ On success prov_transport_common_amqp_close shall return a zero value. ] */
TEST_FUNCTION(prov_transport_amqp_close_succeed)
{
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_amqp_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_X509, TEST_SCOPE_ID_VALUE, TEST_REGISTRATION_ID_VALUE, TEST_DPS_API_VALUE, on_transport_io);
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_amqp_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_X509, TEST_SCOPE_ID_VALUE, TEST_DPS_API_VALUE, on_transport_io);
umock_c_reset_all_calls();
//arrange
STRICT_EXPECTED_CALL(BUFFER_delete(IGNORED_PTR_ARG));
STRICT_EXPECTED_CALL(BUFFER_delete(IGNORED_PTR_ARG));
STRICT_EXPECTED_CALL(gballoc_free(IGNORED_PTR_ARG));
STRICT_EXPECTED_CALL(messagesender_close(IGNORED_PTR_ARG));
STRICT_EXPECTED_CALL(messagereceiver_close(IGNORED_PTR_ARG));
@ -1155,7 +1159,7 @@ BEGIN_TEST_SUITE(prov_transport_amqp_common_ut)
/* Tests_PROV_TRANSPORT_AMQP_COMMON_07_015: [ If hsm_type is of type TRANSPORT_HSM_TYPE_TPM and reg_challenge_cb is NULL, prov_transport_common_amqp_register_device shall return a non-zero value. ] */
TEST_FUNCTION(prov_transport_common_amqp_register_device_challenge_NULL_succeed)
{
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_amqp_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_REGISTRATION_ID_VALUE, TEST_DPS_API_VALUE, on_transport_io);
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_amqp_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_DPS_API_VALUE, on_transport_io);
umock_c_reset_all_calls();
//arrange
@ -1174,7 +1178,7 @@ BEGIN_TEST_SUITE(prov_transport_amqp_common_ut)
/* Tests_PROV_TRANSPORT_AMQP_COMMON_07_015: [ If hsm_type is of type TRANSPORT_HSM_TYPE_TPM and reg_challenge_cb is NULL, prov_transport_common_amqp_register_device shall return a non-zero value. ] */
TEST_FUNCTION(prov_transport_common_amqp_register_device_x509_challenge_NULL_succeed)
{
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_amqp_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_X509, TEST_SCOPE_ID_VALUE, TEST_REGISTRATION_ID_VALUE, TEST_DPS_API_VALUE, on_transport_io);
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_amqp_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_X509, TEST_SCOPE_ID_VALUE, TEST_DPS_API_VALUE, on_transport_io);
umock_c_reset_all_calls();
//arrange
@ -1193,7 +1197,7 @@ BEGIN_TEST_SUITE(prov_transport_amqp_common_ut)
/* Tests_PROV_TRANSPORT_AMQP_COMMON_07_017: [ On success prov_transport_common_amqp_register_device shall return a zero value. ] */
TEST_FUNCTION(prov_transport_common_amqp_register_device_succeed)
{
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_amqp_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_X509, TEST_SCOPE_ID_VALUE, TEST_REGISTRATION_ID_VALUE, TEST_DPS_API_VALUE, on_transport_io);
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_amqp_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_X509, TEST_SCOPE_ID_VALUE, TEST_DPS_API_VALUE, on_transport_io);
umock_c_reset_all_calls();
//arrange
@ -1212,7 +1216,7 @@ BEGIN_TEST_SUITE(prov_transport_amqp_common_ut)
/* Tests_PROV_TRANSPORT_AMQP_COMMON_07_061: [ If the transport_state is TRANSPORT_CLIENT_STATE_REG_SEND or the the operation_id is NULL, prov_transport_common_amqp_register_device shall return a non-zero value. ] */
TEST_FUNCTION(prov_transport_common_amqp_register_device_twice_fail)
{
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_amqp_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_X509, TEST_SCOPE_ID_VALUE, TEST_REGISTRATION_ID_VALUE, TEST_DPS_API_VALUE, on_transport_io);
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_amqp_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_X509, TEST_SCOPE_ID_VALUE, TEST_DPS_API_VALUE, on_transport_io);
(void)prov_transport_common_amqp_register_device(handle, on_transport_challenge_callback, NULL, on_transport_json_parse, NULL);
umock_c_reset_all_calls();
@ -1247,7 +1251,7 @@ BEGIN_TEST_SUITE(prov_transport_amqp_common_ut)
/* Tests_PROV_TRANSPORT_AMQP_COMMON_07_019: [ If the operation_id is NULL, prov_transport_common_amqp_get_operation_status shall return a non-zero value. ] */
TEST_FUNCTION(prov_transport_common_amqp_get_operation_status_operation_id_zero_fail)
{
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_amqp_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_X509, TEST_SCOPE_ID_VALUE, TEST_REGISTRATION_ID_VALUE, TEST_DPS_API_VALUE, on_transport_io);
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_amqp_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_X509, TEST_SCOPE_ID_VALUE, TEST_DPS_API_VALUE, on_transport_io);
umock_c_reset_all_calls();
//arrange
@ -1268,8 +1272,8 @@ BEGIN_TEST_SUITE(prov_transport_amqp_common_ut)
TEST_FUNCTION(prov_transport_common_amqp_get_operation_status_success)
{
int result;
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_amqp_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_REGISTRATION_ID_VALUE, TEST_DPS_API_VALUE, on_transport_io);
(void)prov_transport_common_amqp_open(handle, TEST_BUFFER_VALUE, TEST_BUFFER_VALUE, on_transport_register_data_cb, NULL, on_transport_status_cb, NULL);
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_amqp_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_DPS_API_VALUE, on_transport_io);
(void)prov_transport_common_amqp_open(handle, TEST_REGISTRATION_ID_VALUE, TEST_BUFFER_VALUE, TEST_BUFFER_VALUE, on_transport_register_data_cb, NULL, on_transport_status_cb, NULL);
(void)prov_transport_common_amqp_register_device(handle, on_transport_challenge_callback, NULL, on_transport_json_parse, NULL);
prov_transport_common_amqp_dowork(handle);
g_msg_sndr_state_changed(g_msg_sndr_state_changed_ctx, MESSAGE_SENDER_STATE_OPEN, MESSAGE_SENDER_STATE_OPENING);
@ -1298,8 +1302,8 @@ BEGIN_TEST_SUITE(prov_transport_amqp_common_ut)
TEST_FUNCTION(prov_transport_common_amqp_challenge_cb_user_ctx_NULL_fail)
{
char* result;
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_amqp_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_REGISTRATION_ID_VALUE, TEST_DPS_API_VALUE, on_transport_io);
(void)prov_transport_common_amqp_open(handle, TEST_BUFFER_VALUE, TEST_BUFFER_VALUE, on_transport_register_data_cb, NULL, on_transport_status_cb, NULL);
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_amqp_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_DPS_API_VALUE, on_transport_io);
(void)prov_transport_common_amqp_open(handle, TEST_REGISTRATION_ID_VALUE, TEST_BUFFER_VALUE, TEST_BUFFER_VALUE, on_transport_register_data_cb, NULL, on_transport_status_cb, NULL);
prov_transport_common_amqp_dowork(handle);
umock_c_reset_all_calls();
@ -1321,8 +1325,8 @@ BEGIN_TEST_SUITE(prov_transport_amqp_common_ut)
TEST_FUNCTION(prov_transport_common_amqp_challenge_cb_NULL_fail)
{
char* result;
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_amqp_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_REGISTRATION_ID_VALUE, TEST_DPS_API_VALUE, on_transport_io);
(void)prov_transport_common_amqp_open(handle, TEST_BUFFER_VALUE, TEST_BUFFER_VALUE, on_transport_register_data_cb, NULL, on_transport_status_cb, NULL);
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_amqp_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_DPS_API_VALUE, on_transport_io);
(void)prov_transport_common_amqp_open(handle, TEST_REGISTRATION_ID_VALUE, TEST_BUFFER_VALUE, TEST_BUFFER_VALUE, on_transport_register_data_cb, NULL, on_transport_status_cb, NULL);
prov_transport_common_amqp_dowork(handle);
umock_c_reset_all_calls();
@ -1344,8 +1348,8 @@ BEGIN_TEST_SUITE(prov_transport_amqp_common_ut)
TEST_FUNCTION(prov_transport_common_amqp_challenge_cb_succeed)
{
char* result;
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_amqp_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_REGISTRATION_ID_VALUE, TEST_DPS_API_VALUE, on_transport_io);
(void)prov_transport_common_amqp_open(handle, TEST_BUFFER_VALUE, TEST_BUFFER_VALUE, on_transport_register_data_cb, NULL, on_transport_status_cb, NULL);
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_amqp_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_DPS_API_VALUE, on_transport_io);
(void)prov_transport_common_amqp_open(handle, TEST_REGISTRATION_ID_VALUE, TEST_BUFFER_VALUE, TEST_BUFFER_VALUE, on_transport_register_data_cb, NULL, on_transport_status_cb, NULL);
(void)prov_transport_common_amqp_register_device(handle, on_transport_challenge_callback, NULL, on_transport_json_parse, NULL);
prov_transport_common_amqp_dowork(handle);
umock_c_reset_all_calls();
@ -1372,8 +1376,8 @@ BEGIN_TEST_SUITE(prov_transport_amqp_common_ut)
TEST_FUNCTION(prov_transport_common_amqp_challenge_cb_fail)
{
char* result;
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_amqp_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_REGISTRATION_ID_VALUE, TEST_DPS_API_VALUE, on_transport_io);
(void)prov_transport_common_amqp_open(handle, TEST_BUFFER_VALUE, TEST_BUFFER_VALUE, on_transport_register_data_cb, NULL, on_transport_status_cb, NULL);
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_amqp_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_DPS_API_VALUE, on_transport_io);
(void)prov_transport_common_amqp_open(handle, TEST_REGISTRATION_ID_VALUE, TEST_BUFFER_VALUE, TEST_BUFFER_VALUE, on_transport_register_data_cb, NULL, on_transport_status_cb, NULL);
(void)prov_transport_common_amqp_register_device(handle, on_transport_challenge_callback, NULL, on_transport_json_parse, NULL);
prov_transport_common_amqp_dowork(handle);
umock_c_reset_all_calls();
@ -1412,8 +1416,8 @@ BEGIN_TEST_SUITE(prov_transport_amqp_common_ut)
/* Tests_PROV_TRANSPORT_AMQP_COMMON_07_047: [ If the amqp_state is AMQP_STATE_DISCONNECTED prov_transport_common_amqp_dowork shall attempt to connect the amqp connections and links. ] */
TEST_FUNCTION(prov_transport_common_amqp_dowork_connected_succeed)
{
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_amqp_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_REGISTRATION_ID_VALUE, TEST_DPS_API_VALUE, on_transport_io);
(void)prov_transport_common_amqp_open(handle, TEST_BUFFER_VALUE, TEST_BUFFER_VALUE, on_transport_register_data_cb, NULL, on_transport_status_cb, NULL);
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_amqp_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_DPS_API_VALUE, on_transport_io);
(void)prov_transport_common_amqp_open(handle, TEST_REGISTRATION_ID_VALUE, TEST_BUFFER_VALUE, TEST_BUFFER_VALUE, on_transport_register_data_cb, NULL, on_transport_status_cb, NULL);
umock_c_reset_all_calls();
//arrange
@ -1433,9 +1437,9 @@ BEGIN_TEST_SUITE(prov_transport_amqp_common_ut)
/* Tests_PROV_TRANSPORT_AMQP_COMMON_07_047: [ If the amqp_state is AMQP_STATE_DISCONNECTED prov_transport_common_amqp_dowork shall attempt to connect the amqp connections and links. ] */
TEST_FUNCTION(prov_transport_common_amqp_dowork_x509_connected_succeed)
{
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_amqp_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_X509, TEST_SCOPE_ID_VALUE, TEST_REGISTRATION_ID_VALUE, TEST_DPS_API_VALUE, on_transport_io);
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_amqp_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_X509, TEST_SCOPE_ID_VALUE, TEST_DPS_API_VALUE, on_transport_io);
(void)prov_transport_common_amqp_x509_cert(handle, TEST_X509_CERT_VALUE, TEST_PRIVATE_KEY_VALUE);
(void)prov_transport_common_amqp_open(handle, TEST_BUFFER_VALUE, TEST_BUFFER_VALUE, on_transport_register_data_cb, NULL, on_transport_status_cb, NULL);
(void)prov_transport_common_amqp_open(handle, TEST_REGISTRATION_ID_VALUE, TEST_BUFFER_VALUE, TEST_BUFFER_VALUE, on_transport_register_data_cb, NULL, on_transport_status_cb, NULL);
umock_c_reset_all_calls();
g_use_x509 = true;
@ -1457,8 +1461,8 @@ BEGIN_TEST_SUITE(prov_transport_amqp_common_ut)
/* Tests_PROV_TRANSPORT_AMQP_COMMON_07_052: [ Once the uamqp reciever and sender link are connected the amqp_state shall be set to AMQP_STATE_CONNECTED ] */
TEST_FUNCTION(prov_transport_common_amqp_dowork_idle_succeed)
{
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_amqp_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_REGISTRATION_ID_VALUE, TEST_DPS_API_VALUE, on_transport_io);
(void)prov_transport_common_amqp_open(handle, TEST_BUFFER_VALUE, TEST_BUFFER_VALUE, on_transport_register_data_cb, NULL, on_transport_status_cb, NULL);
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_amqp_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_DPS_API_VALUE, on_transport_io);
(void)prov_transport_common_amqp_open(handle, TEST_REGISTRATION_ID_VALUE, TEST_BUFFER_VALUE, TEST_BUFFER_VALUE, on_transport_register_data_cb, NULL, on_transport_status_cb, NULL);
prov_transport_common_amqp_dowork(handle);
g_msg_sndr_state_changed(g_msg_sndr_state_changed_ctx, MESSAGE_SENDER_STATE_OPEN, MESSAGE_SENDER_STATE_OPENING);
g_msg_rcvr_state_changed(g_msg_rcvr_state_changed_ctx, MESSAGE_RECEIVER_STATE_OPEN, MESSAGE_RECEIVER_STATE_OPENING);
@ -1482,8 +1486,8 @@ BEGIN_TEST_SUITE(prov_transport_amqp_common_ut)
/* Tests_PROV_TRANSPORT_AMQP_COMMON_07_053: [ When then transport_state is set to TRANSPORT_CLIENT_STATE_REG_SEND, prov_transport_common_amqp_dowork shall send a AMQP_REGISTER_ME message ] */
TEST_FUNCTION(prov_transport_common_amqp_dowork_register_succeed)
{
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_amqp_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_REGISTRATION_ID_VALUE, TEST_DPS_API_VALUE, on_transport_io);
(void)prov_transport_common_amqp_open(handle, TEST_BUFFER_VALUE, TEST_BUFFER_VALUE, on_transport_register_data_cb, NULL, on_transport_status_cb, NULL);
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_amqp_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_DPS_API_VALUE, on_transport_io);
(void)prov_transport_common_amqp_open(handle, TEST_REGISTRATION_ID_VALUE, TEST_BUFFER_VALUE, TEST_BUFFER_VALUE, on_transport_register_data_cb, NULL, on_transport_status_cb, NULL);
(void)prov_transport_common_amqp_register_device(handle, on_transport_challenge_callback, NULL, on_transport_json_parse, NULL);
prov_transport_common_amqp_dowork(handle);
g_msg_sndr_state_changed(g_msg_sndr_state_changed_ctx, MESSAGE_SENDER_STATE_OPEN, MESSAGE_SENDER_STATE_OPENING);
@ -1512,8 +1516,8 @@ BEGIN_TEST_SUITE(prov_transport_amqp_common_ut)
TEST_FUNCTION(prov_transport_common_amqp_dowork_register_recv_succeed)
{
AMQP_VALUE result;
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_amqp_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_REGISTRATION_ID_VALUE, TEST_DPS_API_VALUE, on_transport_io);
(void)prov_transport_common_amqp_open(handle, TEST_BUFFER_VALUE, TEST_BUFFER_VALUE, on_transport_register_data_cb, NULL, on_transport_status_cb, NULL);
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_amqp_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_DPS_API_VALUE, on_transport_io);
(void)prov_transport_common_amqp_open(handle, TEST_REGISTRATION_ID_VALUE, TEST_BUFFER_VALUE, TEST_BUFFER_VALUE, on_transport_register_data_cb, NULL, on_transport_status_cb, NULL);
(void)prov_transport_common_amqp_register_device(handle, on_transport_challenge_callback, NULL, on_transport_json_parse, NULL);
prov_transport_common_amqp_dowork(handle);
g_msg_sndr_state_changed(g_msg_sndr_state_changed_ctx, MESSAGE_SENDER_STATE_OPEN, MESSAGE_SENDER_STATE_OPENING);
@ -1540,8 +1544,8 @@ BEGIN_TEST_SUITE(prov_transport_amqp_common_ut)
{
AMQP_VALUE result;
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_amqp_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_REGISTRATION_ID_VALUE, TEST_DPS_API_VALUE, on_transport_io);
(void)prov_transport_common_amqp_open(handle, TEST_BUFFER_VALUE, TEST_BUFFER_VALUE, on_transport_register_data_cb, NULL, on_transport_status_cb, NULL);
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_amqp_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_DPS_API_VALUE, on_transport_io);
(void)prov_transport_common_amqp_open(handle, TEST_REGISTRATION_ID_VALUE, TEST_BUFFER_VALUE, TEST_BUFFER_VALUE, on_transport_register_data_cb, NULL, on_transport_status_cb, NULL);
(void)prov_transport_common_amqp_register_device(handle, on_transport_challenge_callback, NULL, on_transport_json_parse, NULL);
prov_transport_common_amqp_dowork(handle);
g_msg_sndr_state_changed(g_msg_sndr_state_changed_ctx, MESSAGE_SENDER_STATE_OPEN, MESSAGE_SENDER_STATE_OPENING);
@ -1569,8 +1573,8 @@ BEGIN_TEST_SUITE(prov_transport_amqp_common_ut)
/* Tests_PROV_TRANSPORT_AMQP_COMMON_07_056: [ Upon successful sending of a AMQP_OPERATION_STATUS message, prov_transport_common_amqp_dowork shall set the transport_state to TRANSPORT_CLIENT_STATE_STATUS_SENT ] */
TEST_FUNCTION(prov_transport_common_amqp_dowork_send_status_succeed)
{
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_amqp_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_REGISTRATION_ID_VALUE, TEST_DPS_API_VALUE, on_transport_io);
(void)prov_transport_common_amqp_open(handle, TEST_BUFFER_VALUE, TEST_BUFFER_VALUE, on_transport_register_data_cb, NULL, on_transport_status_cb, NULL);
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_amqp_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_DPS_API_VALUE, on_transport_io);
(void)prov_transport_common_amqp_open(handle, TEST_REGISTRATION_ID_VALUE, TEST_BUFFER_VALUE, TEST_BUFFER_VALUE, on_transport_register_data_cb, NULL, on_transport_status_cb, NULL);
(void)prov_transport_common_amqp_register_device(handle, on_transport_challenge_callback, NULL, on_transport_json_parse, NULL);
prov_transport_common_amqp_dowork(handle);
g_msg_sndr_state_changed(g_msg_sndr_state_changed_ctx, MESSAGE_SENDER_STATE_OPEN, MESSAGE_SENDER_STATE_OPENING);
@ -1599,8 +1603,8 @@ BEGIN_TEST_SUITE(prov_transport_amqp_common_ut)
TEST_FUNCTION(prov_transport_common_amqp_dowork_device_assigned_succeed)
{
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_amqp_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_REGISTRATION_ID_VALUE, TEST_DPS_API_VALUE, on_transport_io);
(void)prov_transport_common_amqp_open(handle, TEST_BUFFER_VALUE, TEST_BUFFER_VALUE, on_transport_register_data_cb, NULL, on_transport_status_cb, NULL);
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_amqp_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_DPS_API_VALUE, on_transport_io);
(void)prov_transport_common_amqp_open(handle, TEST_REGISTRATION_ID_VALUE, TEST_BUFFER_VALUE, TEST_BUFFER_VALUE, on_transport_register_data_cb, NULL, on_transport_status_cb, NULL);
(void)prov_transport_common_amqp_register_device(handle, on_transport_challenge_callback, NULL, on_transport_json_parse, NULL);
prov_transport_common_amqp_dowork(handle);
g_msg_sndr_state_changed(g_msg_sndr_state_changed_ctx, MESSAGE_SENDER_STATE_OPEN, MESSAGE_SENDER_STATE_OPENING);
@ -1633,8 +1637,8 @@ BEGIN_TEST_SUITE(prov_transport_amqp_common_ut)
/* Tests_PROV_TRANSPORT_AMQP_COMMON_07_049: [ If any error is encountered prov_transport_common_amqp_dowork shall set the amqp_state to AMQP_STATE_ERROR and the transport_state to TRANSPORT_CLIENT_STATE_ERROR. ] */
TEST_FUNCTION(prov_transport_common_amqp_dowork_register_fail)
{
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_amqp_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_REGISTRATION_ID_VALUE, TEST_DPS_API_VALUE, on_transport_io);
(void)prov_transport_common_amqp_open(handle, TEST_BUFFER_VALUE, TEST_BUFFER_VALUE, on_transport_register_data_cb, NULL, on_transport_status_cb, NULL);
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_amqp_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_DPS_API_VALUE, on_transport_io);
(void)prov_transport_common_amqp_open(handle, TEST_REGISTRATION_ID_VALUE, TEST_BUFFER_VALUE, TEST_BUFFER_VALUE, on_transport_register_data_cb, NULL, on_transport_status_cb, NULL);
(void)prov_transport_common_amqp_register_device(handle, on_transport_challenge_callback, NULL, on_transport_json_parse, NULL);
prov_transport_common_amqp_dowork(handle);
g_msg_rcvr_state_changed(g_msg_rcvr_state_changed_ctx, MESSAGE_RECEIVER_STATE_OPEN, MESSAGE_RECEIVER_STATE_OPENING);
@ -1681,7 +1685,7 @@ BEGIN_TEST_SUITE(prov_transport_amqp_common_ut)
/* Tests_PROV_TRANSPORT_AMQP_COMMON_07_049: [ If any error is encountered prov_transport_common_amqp_dowork shall set the amqp_state to AMQP_STATE_ERROR and the transport_state to TRANSPORT_CLIENT_STATE_ERROR. ] */
TEST_FUNCTION(prov_transport_common_amqp_dowork_disconnected_fail)
{
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_amqp_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_REGISTRATION_ID_VALUE, TEST_DPS_API_VALUE, on_transport_io);
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_amqp_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_DPS_API_VALUE, on_transport_io);
umock_c_reset_all_calls();
int negativeTestsInitResult = umock_c_negative_tests_init();
@ -1703,7 +1707,7 @@ BEGIN_TEST_SUITE(prov_transport_amqp_common_ut)
continue;
}
(void)prov_transport_common_amqp_open(handle, TEST_BUFFER_VALUE, TEST_BUFFER_VALUE, on_transport_register_data_cb, NULL, on_transport_status_cb, NULL);
(void)prov_transport_common_amqp_open(handle, TEST_REGISTRATION_ID_VALUE, TEST_BUFFER_VALUE, TEST_BUFFER_VALUE, on_transport_register_data_cb, NULL, on_transport_status_cb, NULL);
umock_c_negative_tests_reset();
umock_c_negative_tests_fail_call(index);
@ -1723,8 +1727,8 @@ BEGIN_TEST_SUITE(prov_transport_amqp_common_ut)
/* Tests_PROV_TRANSPORT_AMQP_COMMON_07_052: [ Once the uamqp reciever and sender link are connected the amqp_state shall be set to AMQP_STATE_CONNECTED ] */
TEST_FUNCTION(prov_transport_common_amqp_msg_recv_state_change_open_succeed)
{
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_amqp_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_REGISTRATION_ID_VALUE, TEST_DPS_API_VALUE, on_transport_io);
(void)prov_transport_common_amqp_open(handle, TEST_BUFFER_VALUE, TEST_BUFFER_VALUE, on_transport_register_data_cb, NULL, on_transport_status_cb, NULL);
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_amqp_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_DPS_API_VALUE, on_transport_io);
(void)prov_transport_common_amqp_open(handle, TEST_REGISTRATION_ID_VALUE, TEST_BUFFER_VALUE, TEST_BUFFER_VALUE, on_transport_register_data_cb, NULL, on_transport_status_cb, NULL);
prov_transport_common_amqp_dowork(handle);
umock_c_reset_all_calls();
@ -1743,8 +1747,8 @@ BEGIN_TEST_SUITE(prov_transport_amqp_common_ut)
TEST_FUNCTION(prov_transport_common_amqp_msg_recv_state_change_error_succeed)
{
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_amqp_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_REGISTRATION_ID_VALUE, TEST_DPS_API_VALUE, on_transport_io);
(void)prov_transport_common_amqp_open(handle, TEST_BUFFER_VALUE, TEST_BUFFER_VALUE, on_transport_register_data_cb, NULL, on_transport_status_cb, NULL);
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_amqp_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_DPS_API_VALUE, on_transport_io);
(void)prov_transport_common_amqp_open(handle, TEST_REGISTRATION_ID_VALUE, TEST_BUFFER_VALUE, TEST_BUFFER_VALUE, on_transport_register_data_cb, NULL, on_transport_status_cb, NULL);
prov_transport_common_amqp_dowork(handle);
umock_c_reset_all_calls();
@ -1766,8 +1770,8 @@ BEGIN_TEST_SUITE(prov_transport_amqp_common_ut)
TEST_FUNCTION(prov_transport_common_amqp_msg_recv_state_change_user_ctx_NULL_fail)
{
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_amqp_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_REGISTRATION_ID_VALUE, TEST_DPS_API_VALUE, on_transport_io);
(void)prov_transport_common_amqp_open(handle, TEST_BUFFER_VALUE, TEST_BUFFER_VALUE, on_transport_register_data_cb, NULL, on_transport_status_cb, NULL);
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_amqp_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_DPS_API_VALUE, on_transport_io);
(void)prov_transport_common_amqp_open(handle, TEST_REGISTRATION_ID_VALUE, TEST_BUFFER_VALUE, TEST_BUFFER_VALUE, on_transport_register_data_cb, NULL, on_transport_status_cb, NULL);
prov_transport_common_amqp_dowork(handle);
umock_c_reset_all_calls();
@ -1787,8 +1791,8 @@ BEGIN_TEST_SUITE(prov_transport_amqp_common_ut)
/* Tests_PROV_TRANSPORT_AMQP_COMMON_07_052: [ Once the uamqp reciever and sender link are connected the amqp_state shall be set to AMQP_STATE_CONNECTED ] */
TEST_FUNCTION(prov_transport_common_amqp_msg_sender_state_change_open_succeed)
{
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_amqp_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_REGISTRATION_ID_VALUE, TEST_DPS_API_VALUE, on_transport_io);
(void)prov_transport_common_amqp_open(handle, TEST_BUFFER_VALUE, TEST_BUFFER_VALUE, on_transport_register_data_cb, NULL, on_transport_status_cb, NULL);
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_amqp_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_DPS_API_VALUE, on_transport_io);
(void)prov_transport_common_amqp_open(handle, TEST_REGISTRATION_ID_VALUE, TEST_BUFFER_VALUE, TEST_BUFFER_VALUE, on_transport_register_data_cb, NULL, on_transport_status_cb, NULL);
prov_transport_common_amqp_dowork(handle);
umock_c_reset_all_calls();
@ -1807,8 +1811,8 @@ BEGIN_TEST_SUITE(prov_transport_amqp_common_ut)
TEST_FUNCTION(prov_transport_common_amqp_msg_sender_state_change_error_succeed)
{
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_amqp_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_REGISTRATION_ID_VALUE, TEST_DPS_API_VALUE, on_transport_io);
(void)prov_transport_common_amqp_open(handle, TEST_BUFFER_VALUE, TEST_BUFFER_VALUE, on_transport_register_data_cb, NULL, on_transport_status_cb, NULL);
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_amqp_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_DPS_API_VALUE, on_transport_io);
(void)prov_transport_common_amqp_open(handle, TEST_REGISTRATION_ID_VALUE, TEST_BUFFER_VALUE, TEST_BUFFER_VALUE, on_transport_register_data_cb, NULL, on_transport_status_cb, NULL);
prov_transport_common_amqp_dowork(handle);
umock_c_reset_all_calls();
@ -1827,8 +1831,8 @@ BEGIN_TEST_SUITE(prov_transport_amqp_common_ut)
TEST_FUNCTION(prov_transport_common_amqp_msg_sender_state_change_user_ctx_NULL_succeed)
{
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_amqp_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_REGISTRATION_ID_VALUE, TEST_DPS_API_VALUE, on_transport_io);
(void)prov_transport_common_amqp_open(handle, TEST_BUFFER_VALUE, TEST_BUFFER_VALUE, on_transport_register_data_cb, NULL, on_transport_status_cb, NULL);
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_amqp_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_DPS_API_VALUE, on_transport_io);
(void)prov_transport_common_amqp_open(handle, TEST_REGISTRATION_ID_VALUE, TEST_BUFFER_VALUE, TEST_BUFFER_VALUE, on_transport_register_data_cb, NULL, on_transport_status_cb, NULL);
prov_transport_common_amqp_dowork(handle);
umock_c_reset_all_calls();
@ -1864,7 +1868,7 @@ BEGIN_TEST_SUITE(prov_transport_amqp_common_ut)
/* Tests_PROV_TRANSPORT_AMQP_COMMON_07_025: [ On success prov_transport_common_amqp_set_trace shall return a zero value. ] */
TEST_FUNCTION(prov_transport_common_amqp_set_trace_succeed)
{
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_amqp_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_REGISTRATION_ID_VALUE, TEST_DPS_API_VALUE, on_transport_io);
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_amqp_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_DPS_API_VALUE, on_transport_io);
umock_c_reset_all_calls();
//arrange
@ -1899,7 +1903,7 @@ BEGIN_TEST_SUITE(prov_transport_amqp_common_ut)
/* Tests_PROV_TRANSPORT_AMQP_COMMON_07_029: [ On success prov_transport_common_amqp_x509_cert shall return a zero value. ] */
TEST_FUNCTION(prov_transport_common_amqp_x509_cert_succeed)
{
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_amqp_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_REGISTRATION_ID_VALUE, TEST_DPS_API_VALUE, on_transport_io);
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_amqp_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_DPS_API_VALUE, on_transport_io);
umock_c_reset_all_calls();
//arrange
@ -1920,7 +1924,7 @@ BEGIN_TEST_SUITE(prov_transport_amqp_common_ut)
/* Tests_PROV_TRANSPORT_AMQP_COMMON_07_028: [ On any failure prov_transport_common_amqp_x509_cert, shall return a non-zero value. ] */
TEST_FUNCTION(prov_transport_common_amqp_x509_cert_fail)
{
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_amqp_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_REGISTRATION_ID_VALUE, TEST_DPS_API_VALUE, on_transport_io);
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_amqp_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_DPS_API_VALUE, on_transport_io);
umock_c_reset_all_calls();
int negativeTestsInitResult = umock_c_negative_tests_init();
@ -1971,7 +1975,7 @@ BEGIN_TEST_SUITE(prov_transport_amqp_common_ut)
/* Tests_PROV_TRANSPORT_AMQP_COMMON_07_030: [ If handle or certificate is NULL, prov_transport_common_amqp_set_trusted_cert shall return a non-zero value. ] */
TEST_FUNCTION(prov_transport_common_amqp_set_trusted_cert_cert_NULL_fail)
{
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_amqp_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_REGISTRATION_ID_VALUE, TEST_DPS_API_VALUE, on_transport_io);
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_amqp_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_DPS_API_VALUE, on_transport_io);
umock_c_reset_all_calls();
//arrange
@ -1991,7 +1995,7 @@ BEGIN_TEST_SUITE(prov_transport_amqp_common_ut)
/* Tests_PROV_TRANSPORT_AMQP_COMMON_07_033: [ On success prov_transport_common_amqp_set_trusted_cert shall return a zero value. ] */
TEST_FUNCTION(prov_transport_common_amqp_set_trusted_cert_succeed)
{
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_amqp_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_REGISTRATION_ID_VALUE, TEST_DPS_API_VALUE, on_transport_io);
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_amqp_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_DPS_API_VALUE, on_transport_io);
umock_c_reset_all_calls();
//arrange
@ -2011,7 +2015,7 @@ BEGIN_TEST_SUITE(prov_transport_amqp_common_ut)
/* Tests_PROV_TRANSPORT_AMQP_COMMON_07_032: [ On any failure prov_transport_common_amqp_set_trusted_cert, shall return a non-zero value. ] */
TEST_FUNCTION(prov_transport_common_amqp_set_trusted_cert_fail)
{
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_amqp_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_REGISTRATION_ID_VALUE, TEST_DPS_API_VALUE, on_transport_io);
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_amqp_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_DPS_API_VALUE, on_transport_io);
umock_c_reset_all_calls();
//arrange
@ -2049,7 +2053,7 @@ BEGIN_TEST_SUITE(prov_transport_amqp_common_ut)
/* Tests_PROV_TRANSPORT_AMQP_COMMON_07_034: [ If handle or proxy_options is NULL, prov_transport_common_amqp_set_proxy shall return a non-zero value. ]*/
TEST_FUNCTION(prov_transport_common_amqp_set_proxy_proxy_NULL_fail)
{
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_amqp_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_REGISTRATION_ID_VALUE, TEST_DPS_API_VALUE, on_transport_io);
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_amqp_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_DPS_API_VALUE, on_transport_io);
umock_c_reset_all_calls();
//arrange
@ -2069,7 +2073,7 @@ BEGIN_TEST_SUITE(prov_transport_amqp_common_ut)
TEST_FUNCTION(prov_transport_common_amqp_set_proxy_no_username_fail)
{
HTTP_PROXY_OPTIONS proxy_options = { 0 };
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_amqp_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_REGISTRATION_ID_VALUE, TEST_DPS_API_VALUE, on_transport_io);
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_amqp_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_DPS_API_VALUE, on_transport_io);
umock_c_reset_all_calls();
//arrange
@ -2093,7 +2097,7 @@ BEGIN_TEST_SUITE(prov_transport_amqp_common_ut)
TEST_FUNCTION(prov_transport_common_amqp_set_proxy_2_succeed)
{
HTTP_PROXY_OPTIONS proxy_options = { 0 };
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_amqp_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_REGISTRATION_ID_VALUE, TEST_DPS_API_VALUE, on_transport_io);
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_amqp_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_DPS_API_VALUE, on_transport_io);
umock_c_reset_all_calls();
//arrange
@ -2121,7 +2125,7 @@ BEGIN_TEST_SUITE(prov_transport_amqp_common_ut)
TEST_FUNCTION(prov_transport_common_amqp_set_proxy_hostname_NULL_fail)
{
HTTP_PROXY_OPTIONS proxy_options = { 0 };
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_amqp_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_REGISTRATION_ID_VALUE, TEST_DPS_API_VALUE, on_transport_io);
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_amqp_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_DPS_API_VALUE, on_transport_io);
umock_c_reset_all_calls();
//arrange
@ -2142,7 +2146,7 @@ BEGIN_TEST_SUITE(prov_transport_amqp_common_ut)
TEST_FUNCTION(prov_transport_common_amqp_set_proxy_fail)
{
HTTP_PROXY_OPTIONS proxy_options = { 0 };
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_amqp_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_REGISTRATION_ID_VALUE, TEST_DPS_API_VALUE, on_transport_io);
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_amqp_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_DPS_API_VALUE, on_transport_io);
umock_c_reset_all_calls();
int negativeTestsInitResult = umock_c_negative_tests_init();
@ -2186,7 +2190,7 @@ BEGIN_TEST_SUITE(prov_transport_amqp_common_ut)
TEST_FUNCTION(prov_transport_common_amqp_set_proxy_succeed)
{
HTTP_PROXY_OPTIONS proxy_options = { 0 };
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_amqp_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_REGISTRATION_ID_VALUE, TEST_DPS_API_VALUE, on_transport_io);
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_amqp_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_DPS_API_VALUE, on_transport_io);
umock_c_reset_all_calls();
//arrange
@ -2212,7 +2216,7 @@ BEGIN_TEST_SUITE(prov_transport_amqp_common_ut)
TEST_FUNCTION(prov_transport_common_amqp_set_proxy_twice_succeed)
{
HTTP_PROXY_OPTIONS proxy_options = { 0 };
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_amqp_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_REGISTRATION_ID_VALUE, TEST_DPS_API_VALUE, on_transport_io);
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_amqp_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_DPS_API_VALUE, on_transport_io);
proxy_options.host_address = TEST_HOST_ADDRESS_VALUE;
proxy_options.port = 443;

Просмотреть файл

@ -86,12 +86,11 @@ IMPLEMENT_UMOCK_C_ENUM_TYPE(PROV_DEVICE_TRANSPORT_STATUS, PROV_DEVICE_TRANSPORT_
TEST_DEFINE_ENUM_TYPE(TRANSPORT_HSM_TYPE, HSM_AUTH_TYPE_VALUES);
IMPLEMENT_UMOCK_C_ENUM_TYPE(TRANSPORT_HSM_TYPE, HSM_AUTH_TYPE_VALUES);
static PROV_DEVICE_TRANSPORT_HANDLE my_prov_transport_common_amqp_create(const char* uri, TRANSPORT_HSM_TYPE type, const char* scope_id, const char* registration_id, const char* dps_api_version, PROV_AMQP_TRANSPORT_IO transport_io)
static PROV_DEVICE_TRANSPORT_HANDLE my_prov_transport_common_amqp_create(const char* uri, TRANSPORT_HSM_TYPE type, const char* scope_id, const char* dps_api_version, PROV_AMQP_TRANSPORT_IO transport_io)
{
(void)uri;
(void)type;
(void)scope_id;
(void)registration_id;
(void)dps_api_version;
g_transport_io = transport_io;
@ -215,10 +214,10 @@ BEGIN_TEST_SUITE(prov_transport_amqp_ws_client_ut)
TEST_FUNCTION(prov_transport_amqp_create_succeed)
{
//arrange
STRICT_EXPECTED_CALL(prov_transport_common_amqp_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_REGISTRATION_ID_VALUE, TEST_DPS_API_VALUE, IGNORED_PTR_ARG));
STRICT_EXPECTED_CALL(prov_transport_common_amqp_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_DPS_API_VALUE, IGNORED_PTR_ARG));
//act
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_amqp_ws_transport_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_REGISTRATION_ID_VALUE, TEST_DPS_API_VALUE);
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_amqp_ws_transport_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_DPS_API_VALUE);
//assert
ASSERT_IS_NOT_NULL(handle);
@ -234,7 +233,7 @@ BEGIN_TEST_SUITE(prov_transport_amqp_ws_client_ut)
{
SASL_MECHANISM_HANDLE sasl_mechanism = { 0 };
PROV_TRANSPORT_IO_INFO* dps_io_info;
(void)prov_amqp_ws_transport_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_REGISTRATION_ID_VALUE, TEST_DPS_API_VALUE);
(void)prov_amqp_ws_transport_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_DPS_API_VALUE);
umock_c_reset_all_calls();
//arrange
@ -263,7 +262,7 @@ BEGIN_TEST_SUITE(prov_transport_amqp_ws_client_ut)
TEST_FUNCTION(prov_amqp_transport_ws_io_x509_succeed)
{
PROV_TRANSPORT_IO_INFO* dps_io_info;
(void)prov_amqp_ws_transport_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_X509, TEST_SCOPE_ID_VALUE, TEST_REGISTRATION_ID_VALUE, TEST_DPS_API_VALUE);
(void)prov_amqp_ws_transport_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_X509, TEST_SCOPE_ID_VALUE, TEST_DPS_API_VALUE);
umock_c_reset_all_calls();
//arrange
@ -291,7 +290,7 @@ BEGIN_TEST_SUITE(prov_transport_amqp_ws_client_ut)
{
SASL_MECHANISM_HANDLE sasl_mechanism = { 0 };
PROV_TRANSPORT_IO_INFO* dps_io_info;
(void)prov_amqp_ws_transport_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_REGISTRATION_ID_VALUE, TEST_DPS_API_VALUE);
(void)prov_amqp_ws_transport_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_DPS_API_VALUE);
umock_c_reset_all_calls();
int negativeTestsInitResult = umock_c_negative_tests_init();
@ -343,7 +342,7 @@ BEGIN_TEST_SUITE(prov_transport_amqp_ws_client_ut)
SASL_MECHANISM_HANDLE sasl_mechanism = { 0 };
HTTP_PROXY_OPTIONS proxy_info;
PROV_TRANSPORT_IO_INFO* dps_io_info;
(void)prov_amqp_ws_transport_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_REGISTRATION_ID_VALUE, TEST_DPS_API_VALUE);
(void)prov_amqp_ws_transport_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_DPS_API_VALUE);
umock_c_reset_all_calls();
//arrange
@ -392,10 +391,10 @@ BEGIN_TEST_SUITE(prov_transport_amqp_ws_client_ut)
TEST_FUNCTION(prov_transport_amqp_open_succeed)
{
//arrange
STRICT_EXPECTED_CALL(prov_transport_common_amqp_open(TEST_DPS_HANDLE, TEST_BUFFER_VALUE, TEST_BUFFER_VALUE, on_transport_register_data_cb, NULL, on_transport_status_cb, NULL));
STRICT_EXPECTED_CALL(prov_transport_common_amqp_open(TEST_DPS_HANDLE, TEST_REGISTRATION_ID_VALUE, TEST_BUFFER_VALUE, TEST_BUFFER_VALUE, on_transport_register_data_cb, NULL, on_transport_status_cb, NULL));
//act
int result = prov_amqp_ws_transport_open(TEST_DPS_HANDLE, TEST_BUFFER_VALUE, TEST_BUFFER_VALUE, on_transport_register_data_cb, NULL, on_transport_status_cb, NULL);
int result = prov_amqp_ws_transport_open(TEST_DPS_HANDLE, TEST_REGISTRATION_ID_VALUE, TEST_BUFFER_VALUE, TEST_BUFFER_VALUE, on_transport_register_data_cb, NULL, on_transport_status_cb, NULL);
//assert
ASSERT_ARE_EQUAL(int, 0, result);

Просмотреть файл

@ -544,7 +544,6 @@ BEGIN_TEST_SUITE(prov_transport_http_client_ut)
{
STRICT_EXPECTED_CALL(gballoc_malloc(IGNORED_NUM_ARG));
STRICT_EXPECTED_CALL(mallocAndStrcpy_s(IGNORED_PTR_ARG, TEST_URI_VALUE));
STRICT_EXPECTED_CALL(mallocAndStrcpy_s(IGNORED_PTR_ARG, TEST_REGISTRATION_ID_VALUE));
STRICT_EXPECTED_CALL(mallocAndStrcpy_s(IGNORED_PTR_ARG, TEST_DPS_API_VALUE));
STRICT_EXPECTED_CALL(mallocAndStrcpy_s(IGNORED_PTR_ARG, TEST_SCOPE_ID_VALUE));
}
@ -556,6 +555,7 @@ BEGIN_TEST_SUITE(prov_transport_http_client_ut)
STRICT_EXPECTED_CALL(BUFFER_clone(IGNORED_NUM_ARG));
STRICT_EXPECTED_CALL(BUFFER_clone(IGNORED_NUM_ARG));
}
STRICT_EXPECTED_CALL(mallocAndStrcpy_s(IGNORED_PTR_ARG, TEST_REGISTRATION_ID_VALUE));
STRICT_EXPECTED_CALL(platform_get_default_tlsio());
STRICT_EXPECTED_CALL(uhttp_client_create(IGNORED_PTR_ARG, IGNORED_PTR_ARG, IGNORED_PTR_ARG, IGNORED_PTR_ARG));
STRICT_EXPECTED_CALL(uhttp_client_set_trace(IGNORED_PTR_ARG, false, true));
@ -624,7 +624,7 @@ BEGIN_TEST_SUITE(prov_transport_http_client_ut)
//arrange
//act
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_dev_http_transport_create(NULL, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_REGISTRATION_ID_VALUE, TEST_DPS_API_VALUE);
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_dev_http_transport_create(NULL, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_DPS_API_VALUE);
//assert
ASSERT_IS_NULL(handle);
@ -640,22 +640,7 @@ BEGIN_TEST_SUITE(prov_transport_http_client_ut)
//arrange
//act
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_dev_http_transport_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, NULL, TEST_REGISTRATION_ID_VALUE, TEST_DPS_API_VALUE);
//assert
ASSERT_IS_NULL(handle);
ASSERT_ARE_EQUAL(char_ptr, umock_c_get_expected_calls(), umock_c_get_actual_calls());
//cleanup
}
/* Tests_PROV_TRANSPORT_HTTP_CLIENT_07_001: [ If uri, scope_id, registration_id or dps_api_version are NULL prov_transport_http_create shall return NULL. ] */
TEST_FUNCTION(prov_transport_http_create_registration_id_NULL_fail)
{
//arrange
//act
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_dev_http_transport_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, NULL, TEST_DPS_API_VALUE);
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_dev_http_transport_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, NULL, TEST_DPS_API_VALUE);
//assert
ASSERT_IS_NULL(handle);
@ -670,7 +655,7 @@ BEGIN_TEST_SUITE(prov_transport_http_client_ut)
//arrange
//act
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_dev_http_transport_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_REGISTRATION_ID_VALUE, NULL);
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_dev_http_transport_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, NULL);
//assert
ASSERT_IS_NULL(handle);
@ -687,7 +672,7 @@ BEGIN_TEST_SUITE(prov_transport_http_client_ut)
setup_prov_transport_http_create_mocks();
//act
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_dev_http_transport_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_REGISTRATION_ID_VALUE, TEST_DPS_API_VALUE);
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_dev_http_transport_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_DPS_API_VALUE);
//assert
ASSERT_IS_NOT_NULL(handle);
@ -718,7 +703,7 @@ BEGIN_TEST_SUITE(prov_transport_http_client_ut)
char tmp_msg[128];
sprintf(tmp_msg, "prov_dev_http_transport_create failure in test %zu/%zu", index, count);
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_dev_http_transport_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_REGISTRATION_ID_VALUE, TEST_DPS_API_VALUE);
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_dev_http_transport_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_DPS_API_VALUE);
//assert
ASSERT_IS_NULL_WITH_MSG(handle, tmp_msg);
@ -747,7 +732,7 @@ BEGIN_TEST_SUITE(prov_transport_http_client_ut)
TEST_FUNCTION(prov_dev_http_transport_destroy_succeed)
{
//arrange
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_dev_http_transport_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_REGISTRATION_ID_VALUE, TEST_DPS_API_VALUE);
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_dev_http_transport_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_DPS_API_VALUE);
umock_c_reset_all_calls();
setup_free_allocated_data_mocks();
@ -765,11 +750,11 @@ BEGIN_TEST_SUITE(prov_transport_http_client_ut)
TEST_FUNCTION(prov_transport_open_handle_NULL_fail)
{
//arrange
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_dev_http_transport_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_REGISTRATION_ID_VALUE, TEST_DPS_API_VALUE);
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_dev_http_transport_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_DPS_API_VALUE);
umock_c_reset_all_calls();
//act
int result = prov_dev_http_transport_open(NULL, TEST_BUFFER_VALUE, TEST_BUFFER_VALUE, on_transport_register_data_cb, NULL, on_transport_status_cb, NULL);
int result = prov_dev_http_transport_open(NULL, TEST_REGISTRATION_ID_VALUE, TEST_BUFFER_VALUE, TEST_BUFFER_VALUE, on_transport_register_data_cb, NULL, on_transport_status_cb, NULL);
//assert
ASSERT_ARE_NOT_EQUAL(int, 0, result);
@ -783,11 +768,11 @@ BEGIN_TEST_SUITE(prov_transport_http_client_ut)
TEST_FUNCTION(prov_transport_open_register_data_NULL_fail)
{
//arrange
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_dev_http_transport_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_REGISTRATION_ID_VALUE, TEST_DPS_API_VALUE);
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_dev_http_transport_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_DPS_API_VALUE);
umock_c_reset_all_calls();
//act
int result = prov_dev_http_transport_open(handle, TEST_BUFFER_VALUE, TEST_BUFFER_VALUE, NULL, NULL, on_transport_status_cb, NULL);
int result = prov_dev_http_transport_open(handle, TEST_REGISTRATION_ID_VALUE, TEST_BUFFER_VALUE, TEST_BUFFER_VALUE, NULL, NULL, on_transport_status_cb, NULL);
//assert
ASSERT_ARE_NOT_EQUAL(int, 0, result);
@ -800,11 +785,11 @@ BEGIN_TEST_SUITE(prov_transport_http_client_ut)
TEST_FUNCTION(prov_transport_open_tpm_status_cb_NULL_fail)
{
//arrange
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_dev_http_transport_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_REGISTRATION_ID_VALUE, TEST_DPS_API_VALUE);
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_dev_http_transport_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_DPS_API_VALUE);
umock_c_reset_all_calls();
//act
int result = prov_dev_http_transport_open(handle, TEST_BUFFER_VALUE, TEST_BUFFER_VALUE, on_transport_register_data_cb, NULL, NULL, NULL);
int result = prov_dev_http_transport_open(handle, TEST_REGISTRATION_ID_VALUE, TEST_BUFFER_VALUE, TEST_BUFFER_VALUE, on_transport_register_data_cb, NULL, NULL, NULL);
//assert
ASSERT_ARE_NOT_EQUAL(int, 0, result);
@ -817,11 +802,11 @@ BEGIN_TEST_SUITE(prov_transport_http_client_ut)
TEST_FUNCTION(prov_transport_open_tpm_ek_NULL_succeed)
{
//arrange
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_dev_http_transport_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_REGISTRATION_ID_VALUE, TEST_DPS_API_VALUE);
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_dev_http_transport_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_DPS_API_VALUE);
umock_c_reset_all_calls();
//act
int result = prov_dev_http_transport_open(handle, NULL, TEST_BUFFER_VALUE, on_transport_register_data_cb, NULL, on_transport_status_cb, NULL);
int result = prov_dev_http_transport_open(handle, TEST_REGISTRATION_ID_VALUE, NULL, TEST_BUFFER_VALUE, on_transport_register_data_cb, NULL, on_transport_status_cb, NULL);
//assert
ASSERT_ARE_NOT_EQUAL(int, 0, result);
@ -834,11 +819,29 @@ BEGIN_TEST_SUITE(prov_transport_http_client_ut)
TEST_FUNCTION(prov_transport_open_tpm_srk_NULL_succeed)
{
//arrange
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_dev_http_transport_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_REGISTRATION_ID_VALUE, TEST_DPS_API_VALUE);
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_dev_http_transport_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_DPS_API_VALUE);
umock_c_reset_all_calls();
//act
int result = prov_dev_http_transport_open(handle, TEST_BUFFER_VALUE, NULL, on_transport_register_data_cb, NULL, on_transport_status_cb, NULL);
int result = prov_dev_http_transport_open(handle, TEST_REGISTRATION_ID_VALUE, TEST_BUFFER_VALUE, NULL, on_transport_register_data_cb, NULL, on_transport_status_cb, NULL);
//assert
ASSERT_ARE_NOT_EQUAL(int, 0, result);
ASSERT_ARE_EQUAL(char_ptr, umock_c_get_expected_calls(), umock_c_get_actual_calls());
//cleanup
prov_dev_http_transport_destroy(handle);
}
/* Tests_PROV_TRANSPORT_HTTP_CLIENT_07_001: [ If uri, scope_id, registration_id or dps_api_version are NULL prov_transport_http_create shall return NULL. ] */
TEST_FUNCTION(prov_transport_http_open_registration_id_NULL_fail)
{
//arrange
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_dev_http_transport_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_DPS_API_VALUE);
umock_c_reset_all_calls();
//act
int result = prov_dev_http_transport_open(handle, NULL, TEST_BUFFER_VALUE, TEST_BUFFER_VALUE, on_transport_register_data_cb, NULL, on_transport_status_cb, NULL);
//assert
ASSERT_ARE_NOT_EQUAL(int, 0, result);
@ -855,13 +858,13 @@ BEGIN_TEST_SUITE(prov_transport_http_client_ut)
TEST_FUNCTION(prov_transport_open_tpm_succeed)
{
//arrange
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_dev_http_transport_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_REGISTRATION_ID_VALUE, TEST_DPS_API_VALUE);
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_dev_http_transport_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_DPS_API_VALUE);
umock_c_reset_all_calls();
setup_prov_dev_http_transport_open_mocks(true);
//act
int result = prov_dev_http_transport_open(handle, TEST_BUFFER_VALUE, TEST_BUFFER_VALUE, on_transport_register_data_cb, NULL, on_transport_status_cb, NULL);
int result = prov_dev_http_transport_open(handle, TEST_REGISTRATION_ID_VALUE, TEST_BUFFER_VALUE, TEST_BUFFER_VALUE, on_transport_register_data_cb, NULL, on_transport_status_cb, NULL);
//assert
ASSERT_ARE_EQUAL(int, 0, result);
@ -875,15 +878,17 @@ BEGIN_TEST_SUITE(prov_transport_http_client_ut)
TEST_FUNCTION(prov_transport_open_x509_certs_NULL_succeed)
{
//arrange
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_dev_http_transport_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_X509, TEST_SCOPE_ID_VALUE, TEST_REGISTRATION_ID_VALUE, TEST_DPS_API_VALUE);
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_dev_http_transport_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_X509, TEST_SCOPE_ID_VALUE, TEST_DPS_API_VALUE);
umock_c_reset_all_calls();
STRICT_EXPECTED_CALL(mallocAndStrcpy_s(IGNORED_PTR_ARG, TEST_REGISTRATION_ID_VALUE));
STRICT_EXPECTED_CALL(platform_get_default_tlsio());
STRICT_EXPECTED_CALL(uhttp_client_create(IGNORED_PTR_ARG, IGNORED_PTR_ARG, IGNORED_PTR_ARG, IGNORED_PTR_ARG));
STRICT_EXPECTED_CALL(uhttp_client_set_trace(IGNORED_PTR_ARG, false, true));
STRICT_EXPECTED_CALL(gballoc_free(IGNORED_PTR_ARG));
//act
int result = prov_dev_http_transport_open(handle, NULL, NULL, on_transport_register_data_cb, NULL, on_transport_status_cb, NULL);
int result = prov_dev_http_transport_open(handle, TEST_REGISTRATION_ID_VALUE, NULL, NULL, on_transport_register_data_cb, NULL, on_transport_status_cb, NULL);
//assert
ASSERT_ARE_NOT_EQUAL(int, 0, result);
@ -897,14 +902,14 @@ BEGIN_TEST_SUITE(prov_transport_http_client_ut)
TEST_FUNCTION(prov_transport_open_x509_succeed)
{
//arrange
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_dev_http_transport_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_X509, TEST_SCOPE_ID_VALUE, TEST_REGISTRATION_ID_VALUE, TEST_DPS_API_VALUE);
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_dev_http_transport_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_X509, TEST_SCOPE_ID_VALUE, TEST_DPS_API_VALUE);
(void)prov_dev_http_transport_x509_cert(handle, TEST_CERT_VALUE, TEST_PRIVATE_KEY_VALUE);
umock_c_reset_all_calls();
setup_prov_dev_http_transport_open_mocks(false);
//act
int result = prov_dev_http_transport_open(handle, NULL, NULL, on_transport_register_data_cb, NULL, on_transport_status_cb, NULL);
int result = prov_dev_http_transport_open(handle, TEST_REGISTRATION_ID_VALUE, NULL, NULL, on_transport_register_data_cb, NULL, on_transport_status_cb, NULL);
//assert
ASSERT_ARE_EQUAL(int, 0, result);
@ -919,7 +924,7 @@ BEGIN_TEST_SUITE(prov_transport_http_client_ut)
TEST_FUNCTION(prov_transport_open_fail)
{
//arrange
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_dev_http_transport_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_REGISTRATION_ID_VALUE, TEST_DPS_API_VALUE);
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_dev_http_transport_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_DPS_API_VALUE);
umock_c_reset_all_calls();
int negativeTestsInitResult = umock_c_negative_tests_init();
@ -929,7 +934,7 @@ BEGIN_TEST_SUITE(prov_transport_http_client_ut)
umock_c_negative_tests_snapshot();
size_t calls_cannot_fail[] = { 4 };
size_t calls_cannot_fail[] = { 5 };
//act
size_t count = umock_c_negative_tests_call_count();
@ -946,7 +951,7 @@ BEGIN_TEST_SUITE(prov_transport_http_client_ut)
char tmp_msg[128];
sprintf(tmp_msg, "prov_dev_http_transport_open failure in test %zu/%zu", index, count);
int result = prov_dev_http_transport_open(handle, TEST_BUFFER_VALUE, TEST_BUFFER_VALUE, on_transport_register_data_cb, NULL, on_transport_status_cb, NULL);
int result = prov_dev_http_transport_open(handle, TEST_REGISTRATION_ID_VALUE, TEST_BUFFER_VALUE, TEST_BUFFER_VALUE, on_transport_register_data_cb, NULL, on_transport_status_cb, NULL);
//assert
ASSERT_ARE_NOT_EQUAL_WITH_MSG(int, 0, result, tmp_msg);
@ -977,12 +982,13 @@ BEGIN_TEST_SUITE(prov_transport_http_client_ut)
TEST_FUNCTION(prov_dev_http_transport_close_succeed)
{
//arrange
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_dev_http_transport_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_REGISTRATION_ID_VALUE, TEST_DPS_API_VALUE);
(void)prov_dev_http_transport_open(handle, TEST_BUFFER_VALUE, TEST_BUFFER_VALUE, on_transport_register_data_cb, NULL, on_transport_status_cb, NULL);
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_dev_http_transport_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_DPS_API_VALUE);
(void)prov_dev_http_transport_open(handle, TEST_REGISTRATION_ID_VALUE, TEST_BUFFER_VALUE, TEST_BUFFER_VALUE, on_transport_register_data_cb, NULL, on_transport_status_cb, NULL);
umock_c_reset_all_calls();
STRICT_EXPECTED_CALL(BUFFER_delete(IGNORED_PTR_ARG));
STRICT_EXPECTED_CALL(BUFFER_delete(IGNORED_PTR_ARG));
STRICT_EXPECTED_CALL(gballoc_free(IGNORED_PTR_ARG));
STRICT_EXPECTED_CALL(uhttp_client_close(IGNORED_PTR_ARG, IGNORED_PTR_ARG, IGNORED_PTR_ARG));
STRICT_EXPECTED_CALL(uhttp_client_dowork(IGNORED_PTR_ARG));
STRICT_EXPECTED_CALL(uhttp_client_destroy(IGNORED_PTR_ARG));
@ -1019,8 +1025,8 @@ BEGIN_TEST_SUITE(prov_transport_http_client_ut)
int result;
//arrange
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_dev_http_transport_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_REGISTRATION_ID_VALUE, TEST_DPS_API_VALUE);
(void)prov_dev_http_transport_open(handle, TEST_BUFFER_VALUE, TEST_BUFFER_VALUE, on_transport_register_data_cb, NULL, on_transport_status_cb, NULL);
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_dev_http_transport_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_DPS_API_VALUE);
(void)prov_dev_http_transport_open(handle, TEST_REGISTRATION_ID_VALUE, TEST_BUFFER_VALUE, TEST_BUFFER_VALUE, on_transport_register_data_cb, NULL, on_transport_status_cb, NULL);
umock_c_reset_all_calls();
//act
@ -1038,8 +1044,8 @@ BEGIN_TEST_SUITE(prov_transport_http_client_ut)
TEST_FUNCTION(prov_transport_http_reply_recv_succeed)
{
//arrange
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_dev_http_transport_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_REGISTRATION_ID_VALUE, TEST_DPS_API_VALUE);
(void)prov_dev_http_transport_open(handle, TEST_BUFFER_VALUE, TEST_BUFFER_VALUE, on_transport_register_data_cb, NULL, on_transport_status_cb, NULL);
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_dev_http_transport_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_DPS_API_VALUE);
(void)prov_dev_http_transport_open(handle, TEST_REGISTRATION_ID_VALUE, TEST_BUFFER_VALUE, TEST_BUFFER_VALUE, on_transport_register_data_cb, NULL, on_transport_status_cb, NULL);
(void)prov_dev_http_transport_register_device(handle, on_transport_challenge_callback, NULL, on_transport_json_parse, NULL);
g_on_http_open(g_http_open_ctx, HTTP_CALLBACK_REASON_OK);
prov_dev_http_transport_dowork(handle);
@ -1076,7 +1082,7 @@ BEGIN_TEST_SUITE(prov_transport_http_client_ut)
TEST_FUNCTION(prov_transport_http_get_operation_status_sas_token_NULL_fail)
{
//arrange
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_dev_http_transport_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_REGISTRATION_ID_VALUE, TEST_DPS_API_VALUE);
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_dev_http_transport_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_DPS_API_VALUE);
umock_c_reset_all_calls();
//act
@ -1098,8 +1104,8 @@ BEGIN_TEST_SUITE(prov_transport_http_client_ut)
TEST_FUNCTION(prov_transport_http_get_operation_status_succeed)
{
//arrange
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_dev_http_transport_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_REGISTRATION_ID_VALUE, TEST_DPS_API_VALUE);
(void)prov_dev_http_transport_open(handle, TEST_BUFFER_VALUE, TEST_BUFFER_VALUE, on_transport_register_data_cb, NULL, on_transport_status_cb, NULL);
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_dev_http_transport_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_DPS_API_VALUE);
(void)prov_dev_http_transport_open(handle, TEST_REGISTRATION_ID_VALUE, TEST_BUFFER_VALUE, TEST_BUFFER_VALUE, on_transport_register_data_cb, NULL, on_transport_status_cb, NULL);
(void)prov_dev_http_transport_register_device(handle, on_transport_challenge_callback, NULL, on_transport_json_parse, NULL);
g_on_http_open(g_http_open_ctx, HTTP_CALLBACK_REASON_OK);
prov_dev_http_transport_dowork(handle);
@ -1135,8 +1141,8 @@ BEGIN_TEST_SUITE(prov_transport_http_client_ut)
int negativeTestsInitResult = umock_c_negative_tests_init();
ASSERT_ARE_EQUAL(int, 0, negativeTestsInitResult);
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_dev_http_transport_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_REGISTRATION_ID_VALUE, TEST_DPS_API_VALUE);
(void)prov_dev_http_transport_open(handle, TEST_BUFFER_VALUE, TEST_BUFFER_VALUE, on_transport_register_data_cb, NULL, on_transport_status_cb, NULL);
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_dev_http_transport_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_DPS_API_VALUE);
(void)prov_dev_http_transport_open(handle, TEST_REGISTRATION_ID_VALUE, TEST_BUFFER_VALUE, TEST_BUFFER_VALUE, on_transport_register_data_cb, NULL, on_transport_status_cb, NULL);
(void)prov_dev_http_transport_register_device(handle, on_transport_challenge_callback, NULL, on_transport_json_parse, NULL);
g_on_http_open(g_http_open_ctx, HTTP_CALLBACK_REASON_OK);
prov_dev_http_transport_dowork(handle);
@ -1186,8 +1192,8 @@ BEGIN_TEST_SUITE(prov_transport_http_client_ut)
TEST_FUNCTION(prov_transport_http_dowork_succeed)
{
//arrange
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_dev_http_transport_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_REGISTRATION_ID_VALUE, TEST_DPS_API_VALUE);
(void)prov_dev_http_transport_open(handle, TEST_BUFFER_VALUE, TEST_BUFFER_VALUE, on_transport_register_data_cb, NULL, on_transport_status_cb, NULL);
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_dev_http_transport_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_DPS_API_VALUE);
(void)prov_dev_http_transport_open(handle, TEST_REGISTRATION_ID_VALUE, TEST_BUFFER_VALUE, TEST_BUFFER_VALUE, on_transport_register_data_cb, NULL, on_transport_status_cb, NULL);
(void)prov_dev_http_transport_register_device(handle, on_transport_challenge_callback, NULL, on_transport_json_parse, NULL);
g_on_http_open(g_http_open_ctx, HTTP_CALLBACK_REASON_OK);
prov_dev_http_transport_dowork(handle);
@ -1221,8 +1227,8 @@ BEGIN_TEST_SUITE(prov_transport_http_client_ut)
TEST_FUNCTION(prov_transport_http_dowork_unauthorized_succeed)
{
//arrange
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_dev_http_transport_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_REGISTRATION_ID_VALUE, TEST_DPS_API_VALUE);
(void)prov_dev_http_transport_open(handle, TEST_BUFFER_VALUE, TEST_BUFFER_VALUE, on_transport_register_data_cb, NULL, on_transport_status_cb, NULL);
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_dev_http_transport_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_DPS_API_VALUE);
(void)prov_dev_http_transport_open(handle, TEST_REGISTRATION_ID_VALUE, TEST_BUFFER_VALUE, TEST_BUFFER_VALUE, on_transport_register_data_cb, NULL, on_transport_status_cb, NULL);
(void)prov_dev_http_transport_register_device(handle, on_transport_challenge_callback, NULL, on_transport_json_parse, NULL);
g_on_http_open(g_http_open_ctx, HTTP_CALLBACK_REASON_OK);
// Send Registration here
@ -1258,8 +1264,8 @@ BEGIN_TEST_SUITE(prov_transport_http_client_ut)
TEST_FUNCTION(prov_transport_http_dowork_assigning_succeed)
{
//arrange
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_dev_http_transport_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_REGISTRATION_ID_VALUE, TEST_DPS_API_VALUE);
(void)prov_dev_http_transport_open(handle, TEST_BUFFER_VALUE, TEST_BUFFER_VALUE, on_transport_register_data_cb, NULL, on_transport_status_cb, NULL);
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_dev_http_transport_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_DPS_API_VALUE);
(void)prov_dev_http_transport_open(handle, TEST_REGISTRATION_ID_VALUE, TEST_BUFFER_VALUE, TEST_BUFFER_VALUE, on_transport_register_data_cb, NULL, on_transport_status_cb, NULL);
(void)prov_dev_http_transport_register_device(handle, on_transport_challenge_callback, NULL, on_transport_json_parse, NULL);
g_on_http_open(g_http_open_ctx, HTTP_CALLBACK_REASON_OK);
// Send Registration here
@ -1290,8 +1296,8 @@ BEGIN_TEST_SUITE(prov_transport_http_client_ut)
TEST_FUNCTION(prov_transport_http_dowork_error)
{
//arrange
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_dev_http_transport_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_REGISTRATION_ID_VALUE, TEST_DPS_API_VALUE);
(void)prov_dev_http_transport_open(handle, TEST_BUFFER_VALUE, TEST_BUFFER_VALUE, on_transport_register_data_cb, NULL, on_transport_status_cb, NULL);
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_dev_http_transport_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_DPS_API_VALUE);
(void)prov_dev_http_transport_open(handle, TEST_REGISTRATION_ID_VALUE, TEST_BUFFER_VALUE, TEST_BUFFER_VALUE, on_transport_register_data_cb, NULL, on_transport_status_cb, NULL);
(void)prov_dev_http_transport_register_device(handle, on_transport_challenge_callback, NULL, on_transport_json_parse, NULL);
g_on_http_open(g_http_open_ctx, HTTP_CALLBACK_REASON_OK);
prov_dev_http_transport_dowork(handle);
@ -1332,8 +1338,8 @@ BEGIN_TEST_SUITE(prov_transport_http_client_ut)
TEST_FUNCTION(prov_transport_http_set_trace_succeed)
{
//arrange
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_dev_http_transport_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_REGISTRATION_ID_VALUE, TEST_DPS_API_VALUE);
(void)prov_dev_http_transport_open(handle, TEST_BUFFER_VALUE, TEST_BUFFER_VALUE, on_transport_register_data_cb, NULL, on_transport_status_cb, NULL);
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_dev_http_transport_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_DPS_API_VALUE);
(void)prov_dev_http_transport_open(handle, TEST_REGISTRATION_ID_VALUE, TEST_BUFFER_VALUE, TEST_BUFFER_VALUE, on_transport_register_data_cb, NULL, on_transport_status_cb, NULL);
umock_c_reset_all_calls();
STRICT_EXPECTED_CALL(uhttp_client_set_trace(IGNORED_PTR_ARG, true, true));
@ -1354,7 +1360,7 @@ BEGIN_TEST_SUITE(prov_transport_http_client_ut)
TEST_FUNCTION(prov_transport_http_set_trace_http_not_open_succeed)
{
//arrange
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_dev_http_transport_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_REGISTRATION_ID_VALUE, TEST_DPS_API_VALUE);
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_dev_http_transport_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_DPS_API_VALUE);
umock_c_reset_all_calls();
//act
@ -1389,7 +1395,7 @@ BEGIN_TEST_SUITE(prov_transport_http_client_ut)
TEST_FUNCTION(prov_dev_http_transport_x509_cert_succeed)
{
//arrange
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_dev_http_transport_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_REGISTRATION_ID_VALUE, TEST_DPS_API_VALUE);
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_dev_http_transport_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_DPS_API_VALUE);
umock_c_reset_all_calls();
STRICT_EXPECTED_CALL(mallocAndStrcpy_s(IGNORED_PTR_ARG, IGNORED_PTR_ARG));
@ -1413,7 +1419,7 @@ BEGIN_TEST_SUITE(prov_transport_http_client_ut)
TEST_FUNCTION(prov_transport_http_set_trusted_cert_succeed)
{
//arrange
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_dev_http_transport_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_REGISTRATION_ID_VALUE, TEST_DPS_API_VALUE);
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_dev_http_transport_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_DPS_API_VALUE);
umock_c_reset_all_calls();
STRICT_EXPECTED_CALL(mallocAndStrcpy_s(IGNORED_PTR_ARG, IGNORED_PTR_ARG));
@ -1434,7 +1440,7 @@ BEGIN_TEST_SUITE(prov_transport_http_client_ut)
TEST_FUNCTION(prov_transport_http_set_trusted_cert_fail)
{
//arrange
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_dev_http_transport_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_REGISTRATION_ID_VALUE, TEST_DPS_API_VALUE);
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_dev_http_transport_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_DPS_API_VALUE);
umock_c_reset_all_calls();
STRICT_EXPECTED_CALL(mallocAndStrcpy_s(IGNORED_PTR_ARG, IGNORED_PTR_ARG)).SetReturn(__LINE__);
@ -1474,7 +1480,7 @@ BEGIN_TEST_SUITE(prov_transport_http_client_ut)
TEST_FUNCTION(prov_transport_http_set_proxy_proxy_opt_NULL_fail)
{
//arrange
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_dev_http_transport_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_REGISTRATION_ID_VALUE, TEST_DPS_API_VALUE);
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_dev_http_transport_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_DPS_API_VALUE);
umock_c_reset_all_calls();
//act
@ -1494,7 +1500,7 @@ BEGIN_TEST_SUITE(prov_transport_http_client_ut)
{
//arrange
HTTP_PROXY_OPTIONS proxy_options = { 0 };
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_dev_http_transport_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_REGISTRATION_ID_VALUE, TEST_DPS_API_VALUE);
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_dev_http_transport_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_DPS_API_VALUE);
umock_c_reset_all_calls();
//act
@ -1515,7 +1521,7 @@ BEGIN_TEST_SUITE(prov_transport_http_client_ut)
{
//arrange
HTTP_PROXY_OPTIONS proxy_options = { 0 };
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_dev_http_transport_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_REGISTRATION_ID_VALUE, TEST_DPS_API_VALUE);
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_dev_http_transport_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_DPS_API_VALUE);
umock_c_reset_all_calls();
STRICT_EXPECTED_CALL(mallocAndStrcpy_s(IGNORED_PTR_ARG, IGNORED_PTR_ARG));
@ -1539,7 +1545,7 @@ BEGIN_TEST_SUITE(prov_transport_http_client_ut)
{
//arrange
HTTP_PROXY_OPTIONS proxy_options = { 0 };
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_dev_http_transport_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_REGISTRATION_ID_VALUE, TEST_DPS_API_VALUE);
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_dev_http_transport_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_DPS_API_VALUE);
umock_c_reset_all_calls();
STRICT_EXPECTED_CALL(mallocAndStrcpy_s(IGNORED_PTR_ARG, IGNORED_PTR_ARG));
@ -1567,7 +1573,7 @@ BEGIN_TEST_SUITE(prov_transport_http_client_ut)
{
//arrange
HTTP_PROXY_OPTIONS proxy_options = { 0 };
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_dev_http_transport_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_REGISTRATION_ID_VALUE, TEST_DPS_API_VALUE);
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_dev_http_transport_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_DPS_API_VALUE);
umock_c_reset_all_calls();
//act
@ -1590,7 +1596,7 @@ BEGIN_TEST_SUITE(prov_transport_http_client_ut)
{
//arrange
HTTP_PROXY_OPTIONS proxy_options = { 0 };
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_dev_http_transport_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_REGISTRATION_ID_VALUE, TEST_DPS_API_VALUE);
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_dev_http_transport_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_DPS_API_VALUE);
umock_c_reset_all_calls();
int negativeTestsInitResult = umock_c_negative_tests_init();

Просмотреть файл

@ -85,12 +85,11 @@ IMPLEMENT_UMOCK_C_ENUM_TYPE(PROV_DEVICE_TRANSPORT_STATUS, PROV_DEVICE_TRANSPORT_
TEST_DEFINE_ENUM_TYPE(TRANSPORT_HSM_TYPE, HSM_AUTH_TYPE_VALUES);
IMPLEMENT_UMOCK_C_ENUM_TYPE(TRANSPORT_HSM_TYPE, HSM_AUTH_TYPE_VALUES);
static PROV_DEVICE_TRANSPORT_HANDLE my_prov_transport_common_mqtt_create(const char* uri, TRANSPORT_HSM_TYPE type, const char* scope_id, const char* registration_id, const char* dps_api_version, PROV_MQTT_TRANSPORT_IO transport_io)
static PROV_DEVICE_TRANSPORT_HANDLE my_prov_transport_common_mqtt_create(const char* uri, TRANSPORT_HSM_TYPE type, const char* scope_id, const char* dps_api_version, PROV_MQTT_TRANSPORT_IO transport_io)
{
(void)uri;
(void)type;
(void)scope_id;
(void)registration_id;
(void)dps_api_version;
g_transport_io = transport_io;
@ -195,10 +194,10 @@ BEGIN_TEST_SUITE(prov_transport_mqtt_client_ut)
TEST_FUNCTION(prov_transport_mqtt_create_succeed)
{
//arrange
STRICT_EXPECTED_CALL(prov_transport_common_mqtt_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_REGISTRATION_ID_VALUE, TEST_DPS_API_VALUE, IGNORED_PTR_ARG));
STRICT_EXPECTED_CALL(prov_transport_common_mqtt_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_DPS_API_VALUE, IGNORED_PTR_ARG));
//act
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_mqtt_transport_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_REGISTRATION_ID_VALUE, TEST_DPS_API_VALUE);
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_mqtt_transport_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_DPS_API_VALUE);
//assert
ASSERT_IS_NOT_NULL(handle);
@ -211,7 +210,7 @@ BEGIN_TEST_SUITE(prov_transport_mqtt_client_ut)
TEST_FUNCTION(mqtt_transport_io_succeed)
{
XIO_HANDLE dps_io_info;
(void)prov_mqtt_transport_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_REGISTRATION_ID_VALUE, TEST_DPS_API_VALUE);
(void)prov_mqtt_transport_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_DPS_API_VALUE);
umock_c_reset_all_calls();
//arrange
@ -233,7 +232,7 @@ BEGIN_TEST_SUITE(prov_transport_mqtt_client_ut)
TEST_FUNCTION(mqtt_transport_ws_io_x509_succeed)
{
XIO_HANDLE dps_io_info;
(void)prov_mqtt_transport_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_X509, TEST_SCOPE_ID_VALUE, TEST_REGISTRATION_ID_VALUE, TEST_DPS_API_VALUE);
(void)prov_mqtt_transport_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_X509, TEST_SCOPE_ID_VALUE, TEST_DPS_API_VALUE);
umock_c_reset_all_calls();
//arrange
@ -255,7 +254,7 @@ BEGIN_TEST_SUITE(prov_transport_mqtt_client_ut)
TEST_FUNCTION(mqtt_transport_io_fail)
{
XIO_HANDLE dps_io_info;
(void)prov_mqtt_transport_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_REGISTRATION_ID_VALUE, TEST_DPS_API_VALUE);
(void)prov_mqtt_transport_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_DPS_API_VALUE);
umock_c_reset_all_calls();
int negativeTestsInitResult = umock_c_negative_tests_init();
@ -294,7 +293,7 @@ BEGIN_TEST_SUITE(prov_transport_mqtt_client_ut)
{
HTTP_PROXY_OPTIONS proxy_info;
XIO_HANDLE dps_io_info;
(void)prov_mqtt_transport_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_REGISTRATION_ID_VALUE, TEST_DPS_API_VALUE);
(void)prov_mqtt_transport_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_DPS_API_VALUE);
umock_c_reset_all_calls();
//arrange
@ -336,10 +335,10 @@ BEGIN_TEST_SUITE(prov_transport_mqtt_client_ut)
TEST_FUNCTION(prov_transport_mqtt_open_succeed)
{
//arrange
STRICT_EXPECTED_CALL(prov_transport_common_mqtt_open(TEST_DPS_HANDLE, TEST_BUFFER_VALUE, TEST_BUFFER_VALUE, on_transport_register_data_cb, NULL, on_transport_status_cb, NULL));
STRICT_EXPECTED_CALL(prov_transport_common_mqtt_open(TEST_DPS_HANDLE, TEST_REGISTRATION_ID_VALUE, TEST_BUFFER_VALUE, TEST_BUFFER_VALUE, on_transport_register_data_cb, NULL, on_transport_status_cb, NULL));
//act
int result = prov_mqtt_transport_open(TEST_DPS_HANDLE, TEST_BUFFER_VALUE, TEST_BUFFER_VALUE, on_transport_register_data_cb, NULL, on_transport_status_cb, NULL);
int result = prov_mqtt_transport_open(TEST_DPS_HANDLE, TEST_REGISTRATION_ID_VALUE, TEST_BUFFER_VALUE, TEST_BUFFER_VALUE, on_transport_register_data_cb, NULL, on_transport_status_cb, NULL);
//assert
ASSERT_ARE_EQUAL(int, 0, result);

Просмотреть файл

@ -341,7 +341,6 @@ BEGIN_TEST_SUITE(prov_transport_mqtt_common_ut)
REGISTER_GLOBAL_MOCK_HOOK(mqttmessage_getApplicationMsg, my_mqttmessage_getApplicationMsg);
REGISTER_GLOBAL_MOCK_FAIL_RETURN(mqttmessage_getApplicationMsg, NULL);
REGISTER_GLOBAL_MOCK_HOOK(on_transport_challenge_callback, my_on_transport_challenge_callback);
REGISTER_GLOBAL_MOCK_FAIL_RETURN(on_transport_challenge_callback, NULL);
REGISTER_GLOBAL_MOCK_HOOK(on_transport_json_parse, my_on_transport_json_parse);
@ -383,7 +382,6 @@ BEGIN_TEST_SUITE(prov_transport_mqtt_common_ut)
{
STRICT_EXPECTED_CALL(gballoc_malloc(IGNORED_NUM_ARG));
STRICT_EXPECTED_CALL(mallocAndStrcpy_s(IGNORED_PTR_ARG, TEST_URI_VALUE));
STRICT_EXPECTED_CALL(mallocAndStrcpy_s(IGNORED_PTR_ARG, TEST_REGISTRATION_ID_VALUE));
STRICT_EXPECTED_CALL(mallocAndStrcpy_s(IGNORED_PTR_ARG, TEST_DPS_API_VALUE));
STRICT_EXPECTED_CALL(mallocAndStrcpy_s(IGNORED_PTR_ARG, TEST_SCOPE_ID_VALUE));
STRICT_EXPECTED_CALL(mqtt_client_init(IGNORED_PTR_ARG, IGNORED_PTR_ARG, IGNORED_PTR_ARG, IGNORED_PTR_ARG, IGNORED_PTR_ARG));
@ -443,7 +441,7 @@ BEGIN_TEST_SUITE(prov_transport_mqtt_common_ut)
//arrange
//act
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_mqtt_create(NULL, TRANSPORT_HSM_TYPE_X509, TEST_SCOPE_ID_VALUE, TEST_REGISTRATION_ID_VALUE, TEST_DPS_API_VALUE, on_mqtt_transport_io);
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_mqtt_create(NULL, TRANSPORT_HSM_TYPE_X509, TEST_SCOPE_ID_VALUE, TEST_DPS_API_VALUE, on_mqtt_transport_io);
//assert
ASSERT_IS_NULL(handle);
@ -458,23 +456,7 @@ BEGIN_TEST_SUITE(prov_transport_mqtt_common_ut)
//arrange
//act
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_mqtt_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_X509, NULL, TEST_REGISTRATION_ID_VALUE, TEST_DPS_API_VALUE, on_mqtt_transport_io);
//assert
ASSERT_IS_NULL(handle);
ASSERT_ARE_EQUAL(char_ptr, umock_c_get_expected_calls(), umock_c_get_actual_calls());
//cleanup
prov_transport_common_mqtt_destroy(handle);
}
/* Tests_PROV_TRANSPORT_MQTT_COMMON_07_001: [ If uri, scope_id, registration_id, dps_api_version, or transport_io is NULL, prov_transport_common_mqtt_create shall return NULL. ] */
TEST_FUNCTION(prov_transport_common_mqtt_create_registration_id_NULL_fail)
{
//arrange
//act
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_mqtt_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_X509, TEST_SCOPE_ID_VALUE, NULL, TEST_DPS_API_VALUE, on_mqtt_transport_io);
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_mqtt_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_X509, NULL, TEST_DPS_API_VALUE, on_mqtt_transport_io);
//assert
ASSERT_IS_NULL(handle);
@ -490,7 +472,7 @@ BEGIN_TEST_SUITE(prov_transport_mqtt_common_ut)
//arrange
//act
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_mqtt_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_X509, TEST_SCOPE_ID_VALUE, TEST_REGISTRATION_ID_VALUE, NULL, on_mqtt_transport_io);
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_mqtt_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_X509, TEST_SCOPE_ID_VALUE, NULL, on_mqtt_transport_io);
//assert
ASSERT_IS_NULL(handle);
@ -506,7 +488,7 @@ BEGIN_TEST_SUITE(prov_transport_mqtt_common_ut)
//arrange
//act
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_mqtt_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_X509, TEST_SCOPE_ID_VALUE, TEST_REGISTRATION_ID_VALUE, TEST_DPS_API_VALUE, NULL);
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_mqtt_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_X509, TEST_SCOPE_ID_VALUE, TEST_DPS_API_VALUE, NULL);
//assert
ASSERT_IS_NULL(handle);
@ -537,7 +519,7 @@ BEGIN_TEST_SUITE(prov_transport_mqtt_common_ut)
sprintf(tmp_msg, "prov_transport_common_mqtt_create failure in test %zu/%zu", index, count);
//act
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_mqtt_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_X509, TEST_SCOPE_ID_VALUE, TEST_REGISTRATION_ID_VALUE, TEST_DPS_API_VALUE, on_mqtt_transport_io);
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_mqtt_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_X509, TEST_SCOPE_ID_VALUE, TEST_DPS_API_VALUE, on_mqtt_transport_io);
//assert
ASSERT_IS_NULL_WITH_MSG(handle, tmp_msg);
@ -553,7 +535,7 @@ BEGIN_TEST_SUITE(prov_transport_mqtt_common_ut)
//arrange
//act
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_mqtt_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_REGISTRATION_ID_VALUE, TEST_DPS_API_VALUE, on_mqtt_transport_io);
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_mqtt_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_DPS_API_VALUE, on_mqtt_transport_io);
//assert
ASSERT_IS_NULL(handle);
@ -570,7 +552,7 @@ BEGIN_TEST_SUITE(prov_transport_mqtt_common_ut)
setup_prov_transport_common_mqtt_create_mocks();
//act
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_mqtt_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_X509, TEST_SCOPE_ID_VALUE, TEST_REGISTRATION_ID_VALUE, TEST_DPS_API_VALUE, on_mqtt_transport_io);
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_mqtt_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_X509, TEST_SCOPE_ID_VALUE, TEST_DPS_API_VALUE, on_mqtt_transport_io);
//assert
ASSERT_IS_NOT_NULL(handle);
@ -597,7 +579,7 @@ BEGIN_TEST_SUITE(prov_transport_mqtt_common_ut)
/* Tests_PROV_TRANSPORT_MQTT_COMMON_07_006: [ prov_transport_common_mqtt_destroy shall free all resources used in this module. ] */
TEST_FUNCTION(prov_transport_common_mqtt_destroy_succeed)
{
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_mqtt_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_X509, TEST_SCOPE_ID_VALUE, TEST_REGISTRATION_ID_VALUE, TEST_DPS_API_VALUE, on_mqtt_transport_io);
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_mqtt_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_X509, TEST_SCOPE_ID_VALUE, TEST_DPS_API_VALUE, on_mqtt_transport_io);
umock_c_reset_all_calls();
//arrange
@ -632,7 +614,7 @@ BEGIN_TEST_SUITE(prov_transport_mqtt_common_ut)
//arrange
//act
int result = prov_transport_common_mqtt_open(NULL, TEST_BUFFER_VALUE, TEST_BUFFER_VALUE, on_transport_register_data_cb, NULL, on_transport_status_cb, NULL);
int result = prov_transport_common_mqtt_open(NULL, TEST_REGISTRATION_ID_VALUE, TEST_BUFFER_VALUE, TEST_BUFFER_VALUE, on_transport_register_data_cb, NULL, on_transport_status_cb, NULL);
//assert
ASSERT_ARE_NOT_EQUAL(int, 0, result);
@ -641,16 +623,35 @@ BEGIN_TEST_SUITE(prov_transport_mqtt_common_ut)
//cleanup
}
/* Tests_PROV_TRANSPORT_MQTT_COMMON_07_007: [ If handle, data_callback, or status_cb is NULL, prov_transport_common_mqtt_open shall return a non-zero value. ] */
TEST_FUNCTION(prov_transport_common_mqtt_open_data_callback_NULL_fail)
/* Tests_PROV_TRANSPORT_MQTT_COMMON_07_001: [ If uri, scope_id, registration_id, dps_api_version, or transport_io is NULL, prov_transport_common_mqtt_create shall return NULL. ] */
TEST_FUNCTION(prov_transport_common_mqtt_open_registration_id_NULL_fail)
{
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_mqtt_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_X509, TEST_SCOPE_ID_VALUE, TEST_REGISTRATION_ID_VALUE, TEST_DPS_API_VALUE, on_mqtt_transport_io);
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_mqtt_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_X509, TEST_SCOPE_ID_VALUE, TEST_DPS_API_VALUE, on_mqtt_transport_io);
umock_c_reset_all_calls();
//arrange
//act
int result = prov_transport_common_mqtt_open(handle, TEST_BUFFER_VALUE, TEST_BUFFER_VALUE, NULL, NULL, on_transport_status_cb, NULL);
int result = prov_transport_common_mqtt_open(handle, TEST_REGISTRATION_ID_VALUE, TEST_BUFFER_VALUE, TEST_BUFFER_VALUE, NULL, NULL, on_transport_status_cb, NULL);
//assert
ASSERT_ARE_NOT_EQUAL(int, 0, result);
ASSERT_ARE_EQUAL(char_ptr, umock_c_get_expected_calls(), umock_c_get_actual_calls());
//cleanup
prov_transport_common_mqtt_destroy(handle);
}
/* Tests_PROV_TRANSPORT_MQTT_COMMON_07_007: [ If handle, data_callback, or status_cb is NULL, prov_transport_common_mqtt_open shall return a non-zero value. ] */
TEST_FUNCTION(prov_transport_common_mqtt_open_data_callback_NULL_fail)
{
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_mqtt_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_X509, TEST_SCOPE_ID_VALUE, TEST_DPS_API_VALUE, on_mqtt_transport_io);
umock_c_reset_all_calls();
//arrange
//act
int result = prov_transport_common_mqtt_open(handle, TEST_REGISTRATION_ID_VALUE, TEST_BUFFER_VALUE, TEST_BUFFER_VALUE, NULL, NULL, on_transport_status_cb, NULL);
//assert
ASSERT_ARE_NOT_EQUAL(int, 0, result);
@ -663,13 +664,13 @@ BEGIN_TEST_SUITE(prov_transport_mqtt_common_ut)
/* Tests_PROV_TRANSPORT_MQTT_COMMON_07_007: [ If handle, data_callback, or status_cb is NULL, prov_transport_common_mqtt_open shall return a non-zero value. ] */
TEST_FUNCTION(prov_transport_common_mqtt_open_status_callback_NULL_fail)
{
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_mqtt_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_X509, TEST_SCOPE_ID_VALUE, TEST_REGISTRATION_ID_VALUE, TEST_DPS_API_VALUE, on_mqtt_transport_io);
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_mqtt_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_X509, TEST_SCOPE_ID_VALUE, TEST_DPS_API_VALUE, on_mqtt_transport_io);
umock_c_reset_all_calls();
//arrange
//act
int result = prov_transport_common_mqtt_open(handle, TEST_BUFFER_VALUE, TEST_BUFFER_VALUE, on_transport_register_data_cb, NULL, NULL, NULL);
int result = prov_transport_common_mqtt_open(handle, TEST_REGISTRATION_ID_VALUE, TEST_BUFFER_VALUE, TEST_BUFFER_VALUE, on_transport_register_data_cb, NULL, NULL, NULL);
//assert
ASSERT_ARE_NOT_EQUAL(int, 0, result);
@ -682,13 +683,13 @@ BEGIN_TEST_SUITE(prov_transport_mqtt_common_ut)
/* Tests_PROV_TRANSPORT_MQTT_COMMON_07_008: [ If hsm_type is TRANSPORT_HSM_TYPE_TPM and ek or srk is NULL, prov_transport_common_mqtt_open shall return a non-zero value. ] */
TEST_FUNCTION(prov_transport_common_mqtt_open_ek_NULL_fail)
{
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_mqtt_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_REGISTRATION_ID_VALUE, TEST_DPS_API_VALUE, on_mqtt_transport_io);
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_mqtt_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_DPS_API_VALUE, on_mqtt_transport_io);
umock_c_reset_all_calls();
//arrange
//act
int result = prov_transport_common_mqtt_open(handle, NULL, TEST_BUFFER_VALUE, on_transport_register_data_cb, NULL, on_transport_status_cb, NULL);
int result = prov_transport_common_mqtt_open(handle, TEST_REGISTRATION_ID_VALUE, NULL, TEST_BUFFER_VALUE, on_transport_register_data_cb, NULL, on_transport_status_cb, NULL);
//assert
ASSERT_ARE_NOT_EQUAL(int, 0, result);
@ -701,13 +702,13 @@ BEGIN_TEST_SUITE(prov_transport_mqtt_common_ut)
/* Tests_PROV_TRANSPORT_MQTT_COMMON_07_008: [ If hsm_type is TRANSPORT_HSM_TYPE_TPM and ek or srk is NULL, prov_transport_common_mqtt_open shall return a non-zero value. ] */
TEST_FUNCTION(prov_transport_common_mqtt_open_srk_NULL_fail)
{
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_mqtt_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_REGISTRATION_ID_VALUE, TEST_DPS_API_VALUE, on_mqtt_transport_io);
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_mqtt_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_DPS_API_VALUE, on_mqtt_transport_io);
umock_c_reset_all_calls();
//arrange
//act
int result = prov_transport_common_mqtt_open(handle, TEST_BUFFER_VALUE, NULL, on_transport_register_data_cb, NULL, on_transport_status_cb, NULL);
int result = prov_transport_common_mqtt_open(handle, TEST_REGISTRATION_ID_VALUE, TEST_BUFFER_VALUE, NULL, on_transport_register_data_cb, NULL, on_transport_status_cb, NULL);
//assert
ASSERT_ARE_NOT_EQUAL(int, 0, result);
@ -720,15 +721,16 @@ BEGIN_TEST_SUITE(prov_transport_mqtt_common_ut)
/* Tests_PROV_TRANSPORT_MQTT_COMMON_07_009: [ prov_transport_common_mqtt_open shall clone the ek and srk values.] */
TEST_FUNCTION(prov_transport_common_mqtt_open_succeed)
{
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_mqtt_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_X509, TEST_SCOPE_ID_VALUE, TEST_REGISTRATION_ID_VALUE, TEST_DPS_API_VALUE, on_mqtt_transport_io);
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_mqtt_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_X509, TEST_SCOPE_ID_VALUE, TEST_DPS_API_VALUE, on_mqtt_transport_io);
umock_c_reset_all_calls();
//arrange
STRICT_EXPECTED_CALL(BUFFER_clone(IGNORED_PTR_ARG));
STRICT_EXPECTED_CALL(BUFFER_clone(IGNORED_PTR_ARG));
STRICT_EXPECTED_CALL(mallocAndStrcpy_s(IGNORED_PTR_ARG, TEST_REGISTRATION_ID_VALUE));
//act
int result = prov_transport_common_mqtt_open(handle, TEST_BUFFER_VALUE, TEST_BUFFER_VALUE, on_transport_register_data_cb, NULL, on_transport_status_cb, NULL);
int result = prov_transport_common_mqtt_open(handle, TEST_REGISTRATION_ID_VALUE, TEST_BUFFER_VALUE, TEST_BUFFER_VALUE, on_transport_register_data_cb, NULL, on_transport_status_cb, NULL);
//assert
ASSERT_ARE_EQUAL(int, 0, result);
@ -742,7 +744,7 @@ BEGIN_TEST_SUITE(prov_transport_mqtt_common_ut)
/* Tests_PROV_TRANSPORT_MQTT_COMMON_07_041: [ If a failure is encountered, prov_transport_common_mqtt_open shall return a non-zero value. ] */
TEST_FUNCTION(prov_transport_common_mqtt_open_fail)
{
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_mqtt_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_X509, TEST_SCOPE_ID_VALUE, TEST_REGISTRATION_ID_VALUE, TEST_DPS_API_VALUE, on_mqtt_transport_io);
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_mqtt_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_X509, TEST_SCOPE_ID_VALUE, TEST_DPS_API_VALUE, on_mqtt_transport_io);
umock_c_reset_all_calls();
int negativeTestsInitResult = umock_c_negative_tests_init();
@ -751,6 +753,7 @@ BEGIN_TEST_SUITE(prov_transport_mqtt_common_ut)
//arrange
STRICT_EXPECTED_CALL(BUFFER_clone(IGNORED_PTR_ARG));
STRICT_EXPECTED_CALL(BUFFER_clone(IGNORED_PTR_ARG));
STRICT_EXPECTED_CALL(mallocAndStrcpy_s(IGNORED_PTR_ARG, TEST_REGISTRATION_ID_VALUE));
umock_c_negative_tests_snapshot();
@ -771,7 +774,7 @@ BEGIN_TEST_SUITE(prov_transport_mqtt_common_ut)
char tmp_msg[64];
sprintf(tmp_msg, "prov_transport_common_mqtt_open failure in test %zu/%zu", index, count);
int result = prov_transport_common_mqtt_open(handle, TEST_BUFFER_VALUE, TEST_BUFFER_VALUE, on_transport_register_data_cb, NULL, on_transport_status_cb, NULL);
int result = prov_transport_common_mqtt_open(handle, TEST_REGISTRATION_ID_VALUE, TEST_BUFFER_VALUE, TEST_BUFFER_VALUE, on_transport_register_data_cb, NULL, on_transport_status_cb, NULL);
//assert
ASSERT_ARE_NOT_EQUAL_WITH_MSG(int, 0, result, tmp_msg);
@ -785,13 +788,14 @@ BEGIN_TEST_SUITE(prov_transport_mqtt_common_ut)
/* Tests_PROV_TRANSPORT_MQTT_COMMON_07_009: [ prov_transport_common_mqtt_open shall clone the ek and srk values.] */
TEST_FUNCTION(prov_transport_common_mqtt_open_x509_succeed)
{
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_mqtt_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_X509, TEST_SCOPE_ID_VALUE, TEST_REGISTRATION_ID_VALUE, TEST_DPS_API_VALUE, on_mqtt_transport_io);
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_mqtt_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_X509, TEST_SCOPE_ID_VALUE, TEST_DPS_API_VALUE, on_mqtt_transport_io);
umock_c_reset_all_calls();
//arrange
STRICT_EXPECTED_CALL(mallocAndStrcpy_s(IGNORED_PTR_ARG, TEST_REGISTRATION_ID_VALUE));
//act
int result = prov_transport_common_mqtt_open(handle, NULL, NULL, on_transport_register_data_cb, NULL, on_transport_status_cb, NULL);
int result = prov_transport_common_mqtt_open(handle, TEST_REGISTRATION_ID_VALUE, NULL, NULL, on_transport_register_data_cb, NULL, on_transport_status_cb, NULL);
//assert
ASSERT_ARE_EQUAL(int, 0, result);
@ -821,12 +825,13 @@ BEGIN_TEST_SUITE(prov_transport_mqtt_common_ut)
/* Tests_PROV_TRANSPORT_MQTT_COMMON_07_013: [ On success prov_transport_common_mqtt_close shall return a zero value. ] */
TEST_FUNCTION(prov_transport_amqp_close_succeed)
{
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_mqtt_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_X509, TEST_SCOPE_ID_VALUE, TEST_REGISTRATION_ID_VALUE, TEST_DPS_API_VALUE, on_mqtt_transport_io);
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_mqtt_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_X509, TEST_SCOPE_ID_VALUE, TEST_DPS_API_VALUE, on_mqtt_transport_io);
umock_c_reset_all_calls();
//arrange
STRICT_EXPECTED_CALL(BUFFER_delete(IGNORED_PTR_ARG));
STRICT_EXPECTED_CALL(BUFFER_delete(IGNORED_PTR_ARG));
STRICT_EXPECTED_CALL(gballoc_free(IGNORED_PTR_ARG));
STRICT_EXPECTED_CALL(mqtt_client_disconnect(IGNORED_PTR_ARG, NULL, NULL));
STRICT_EXPECTED_CALL(mqtt_client_dowork(IGNORED_PTR_ARG));
STRICT_EXPECTED_CALL(xio_destroy(IGNORED_PTR_ARG));
@ -860,7 +865,7 @@ BEGIN_TEST_SUITE(prov_transport_mqtt_common_ut)
/* Tests_PROV_TRANSPORT_MQTT_COMMON_07_015: [ If hsm_type is of type TRANSPORT_HSM_TYPE_TPM and reg_challenge_cb is NULL, prov_transport_common_mqtt_register_device shall return a non-zero value. ] */
TEST_FUNCTION(prov_transport_common_mqtt_register_device_challenge_NULL_succeed)
{
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_mqtt_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_REGISTRATION_ID_VALUE, TEST_DPS_API_VALUE, on_mqtt_transport_io);
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_mqtt_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_DPS_API_VALUE, on_mqtt_transport_io);
umock_c_reset_all_calls();
//arrange
@ -879,7 +884,7 @@ BEGIN_TEST_SUITE(prov_transport_mqtt_common_ut)
/* Tests_PROV_TRANSPORT_MQTT_COMMON_07_015: [ If hsm_type is of type TRANSPORT_HSM_TYPE_TPM and reg_challenge_cb is NULL, prov_transport_common_mqtt_register_device shall return a non-zero value. ] */
TEST_FUNCTION(prov_transport_common_mqtt_register_device_x509_challenge_NULL_succeed)
{
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_mqtt_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_X509, TEST_SCOPE_ID_VALUE, TEST_REGISTRATION_ID_VALUE, TEST_DPS_API_VALUE, on_mqtt_transport_io);
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_mqtt_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_X509, TEST_SCOPE_ID_VALUE, TEST_DPS_API_VALUE, on_mqtt_transport_io);
umock_c_reset_all_calls();
//arrange
@ -898,7 +903,7 @@ BEGIN_TEST_SUITE(prov_transport_mqtt_common_ut)
/* Tests_PROV_TRANSPORT_MQTT_COMMON_07_017: [ On success prov_transport_common_mqtt_register_device shall return a zero value. ] */
TEST_FUNCTION(prov_transport_common_mqtt_register_device_succeed)
{
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_mqtt_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_X509, TEST_SCOPE_ID_VALUE, TEST_REGISTRATION_ID_VALUE, TEST_DPS_API_VALUE, on_mqtt_transport_io);
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_mqtt_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_X509, TEST_SCOPE_ID_VALUE, TEST_DPS_API_VALUE, on_mqtt_transport_io);
umock_c_reset_all_calls();
//arrange
@ -917,7 +922,7 @@ BEGIN_TEST_SUITE(prov_transport_mqtt_common_ut)
/* Tests_PROV_TRANSPORT_MQTT_COMMON_07_061: [ If the transport_state is TRANSPORT_CLIENT_STATE_REG_SEND or the the operation_id is NULL, prov_transport_common_mqtt_register_device shall return a non-zero value. ] */
TEST_FUNCTION(prov_transport_common_mqtt_register_device_twice_fail)
{
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_mqtt_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_X509, TEST_SCOPE_ID_VALUE, TEST_REGISTRATION_ID_VALUE, TEST_DPS_API_VALUE, on_mqtt_transport_io);
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_mqtt_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_X509, TEST_SCOPE_ID_VALUE, TEST_DPS_API_VALUE, on_mqtt_transport_io);
(void)prov_transport_common_mqtt_register_device(handle, on_transport_challenge_callback, NULL, on_transport_json_parse, NULL);
umock_c_reset_all_calls();
@ -952,7 +957,7 @@ BEGIN_TEST_SUITE(prov_transport_mqtt_common_ut)
/* Tests_PROV_TRANSPORT_MQTT_COMMON_07_019: [ If the operation_id is NULL, prov_transport_common_mqtt_get_operation_status shall return a non-zero value. ] */
TEST_FUNCTION(prov_transport_common_mqtt_get_operation_status_operation_id_zero_fail)
{
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_mqtt_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_X509, TEST_SCOPE_ID_VALUE, TEST_REGISTRATION_ID_VALUE, TEST_DPS_API_VALUE, on_mqtt_transport_io);
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_mqtt_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_X509, TEST_SCOPE_ID_VALUE, TEST_DPS_API_VALUE, on_mqtt_transport_io);
umock_c_reset_all_calls();
//arrange
@ -980,9 +985,9 @@ BEGIN_TEST_SUITE(prov_transport_mqtt_common_ut)
suback.qosCount = 1;
suback.qosReturn = QosValue;
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_mqtt_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_X509, TEST_SCOPE_ID_VALUE, TEST_REGISTRATION_ID_VALUE, TEST_DPS_API_VALUE, on_mqtt_transport_io);
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_mqtt_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_X509, TEST_SCOPE_ID_VALUE, TEST_DPS_API_VALUE, on_mqtt_transport_io);
(void)prov_transport_common_mqtt_x509_cert(handle, TEST_X509_CERT_VALUE, TEST_PRIVATE_KEY_VALUE);
(void)prov_transport_common_mqtt_open(handle, TEST_BUFFER_VALUE, TEST_BUFFER_VALUE, on_transport_register_data_cb, NULL, on_transport_status_cb, NULL);
(void)prov_transport_common_mqtt_open(handle, TEST_REGISTRATION_ID_VALUE, TEST_BUFFER_VALUE, TEST_BUFFER_VALUE, on_transport_register_data_cb, NULL, on_transport_status_cb, NULL);
(void)prov_transport_common_mqtt_register_device(handle, on_transport_challenge_callback, NULL, on_transport_json_parse, NULL);
prov_transport_common_mqtt_dowork(handle);
g_operation_cb(TEST_MQTT_CLIENT_HANDLE, MQTT_CLIENT_ON_CONNACK, &connack, g_msg_recv_callback_context);
@ -1027,7 +1032,7 @@ BEGIN_TEST_SUITE(prov_transport_mqtt_common_ut)
/* Tests_PROV_TRANSPORT_MQTT_COMMON_07_049: [ If any error is encountered prov_transport_common_mqtt_dowork shall set the mqtt_state to MQTT_STATE_ERROR and the transport_state to TRANSPORT_CLIENT_STATE_ERROR. ] */
TEST_FUNCTION(prov_transport_common_mqtt_dowork_x509_connected_fail)
{
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_mqtt_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_X509, TEST_SCOPE_ID_VALUE, TEST_REGISTRATION_ID_VALUE, TEST_DPS_API_VALUE, on_mqtt_transport_io);
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_mqtt_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_X509, TEST_SCOPE_ID_VALUE, TEST_DPS_API_VALUE, on_mqtt_transport_io);
(void)prov_transport_common_mqtt_x509_cert(handle, TEST_X509_CERT_VALUE, TEST_PRIVATE_KEY_VALUE);
umock_c_reset_all_calls();
g_use_x509 = true;
@ -1050,7 +1055,7 @@ BEGIN_TEST_SUITE(prov_transport_mqtt_common_ut)
continue;
}
(void)prov_transport_common_mqtt_open(handle, TEST_BUFFER_VALUE, TEST_BUFFER_VALUE, on_transport_register_data_cb, NULL, on_transport_status_cb, NULL);
(void)prov_transport_common_mqtt_open(handle, TEST_REGISTRATION_ID_VALUE, TEST_BUFFER_VALUE, TEST_BUFFER_VALUE, on_transport_register_data_cb, NULL, on_transport_status_cb, NULL);
umock_c_negative_tests_reset();
umock_c_negative_tests_fail_call(index);
@ -1074,9 +1079,9 @@ BEGIN_TEST_SUITE(prov_transport_mqtt_common_ut)
/* Tests_PROV_TRANSPORT_MQTT_COMMON_07_047: [ If the mqtt_state is MQTT_STATE_DISCONNECTED prov_transport_common_mqtt_dowork shall attempt to connect the mqtt connections. ] */
TEST_FUNCTION(prov_transport_common_mqtt_dowork_x509_connected_succeed)
{
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_mqtt_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_X509, TEST_SCOPE_ID_VALUE, TEST_REGISTRATION_ID_VALUE, TEST_DPS_API_VALUE, on_mqtt_transport_io);
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_mqtt_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_X509, TEST_SCOPE_ID_VALUE, TEST_DPS_API_VALUE, on_mqtt_transport_io);
(void)prov_transport_common_mqtt_x509_cert(handle, TEST_X509_CERT_VALUE, TEST_PRIVATE_KEY_VALUE);
(void)prov_transport_common_mqtt_open(handle, TEST_BUFFER_VALUE, TEST_BUFFER_VALUE, on_transport_register_data_cb, NULL, on_transport_status_cb, NULL);
(void)prov_transport_common_mqtt_open(handle, TEST_REGISTRATION_ID_VALUE, TEST_BUFFER_VALUE, TEST_BUFFER_VALUE, on_transport_register_data_cb, NULL, on_transport_status_cb, NULL);
umock_c_reset_all_calls();
g_use_x509 = true;
@ -1104,9 +1109,9 @@ BEGIN_TEST_SUITE(prov_transport_mqtt_common_ut)
suback.qosCount = 1;
suback.qosReturn = QosValue;
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_mqtt_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_X509, TEST_SCOPE_ID_VALUE, TEST_REGISTRATION_ID_VALUE, TEST_DPS_API_VALUE, on_mqtt_transport_io);
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_mqtt_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_X509, TEST_SCOPE_ID_VALUE, TEST_DPS_API_VALUE, on_mqtt_transport_io);
(void)prov_transport_common_mqtt_x509_cert(handle, TEST_X509_CERT_VALUE, TEST_PRIVATE_KEY_VALUE);
(void)prov_transport_common_mqtt_open(handle, TEST_BUFFER_VALUE, TEST_BUFFER_VALUE, on_transport_register_data_cb, NULL, on_transport_status_cb, NULL);
(void)prov_transport_common_mqtt_open(handle, TEST_REGISTRATION_ID_VALUE, TEST_BUFFER_VALUE, TEST_BUFFER_VALUE, on_transport_register_data_cb, NULL, on_transport_status_cb, NULL);
prov_transport_common_mqtt_dowork(handle);
g_operation_cb(TEST_MQTT_CLIENT_HANDLE, MQTT_CLIENT_ON_CONNACK, &connack, g_msg_recv_callback_context);
prov_transport_common_mqtt_dowork(handle);
@ -1132,9 +1137,9 @@ BEGIN_TEST_SUITE(prov_transport_mqtt_common_ut)
{
CONNECT_ACK connack = { true, CONNECTION_ACCEPTED };
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_mqtt_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_X509, TEST_SCOPE_ID_VALUE, TEST_REGISTRATION_ID_VALUE, TEST_DPS_API_VALUE, on_mqtt_transport_io);
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_mqtt_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_X509, TEST_SCOPE_ID_VALUE, TEST_DPS_API_VALUE, on_mqtt_transport_io);
(void)prov_transport_common_mqtt_x509_cert(handle, TEST_X509_CERT_VALUE, TEST_PRIVATE_KEY_VALUE);
(void)prov_transport_common_mqtt_open(handle, TEST_BUFFER_VALUE, TEST_BUFFER_VALUE, on_transport_register_data_cb, NULL, on_transport_status_cb, NULL);
(void)prov_transport_common_mqtt_open(handle, TEST_REGISTRATION_ID_VALUE, TEST_BUFFER_VALUE, TEST_BUFFER_VALUE, on_transport_register_data_cb, NULL, on_transport_status_cb, NULL);
(void)prov_transport_common_mqtt_register_device(handle, on_transport_challenge_callback, NULL, on_transport_json_parse, NULL);
prov_transport_common_mqtt_dowork(handle);
g_operation_cb(TEST_MQTT_CLIENT_HANDLE, MQTT_CLIENT_ON_CONNACK, &connack, g_msg_recv_callback_context);
@ -1163,9 +1168,9 @@ BEGIN_TEST_SUITE(prov_transport_mqtt_common_ut)
{
CONNECT_ACK connack = { true, CONNECTION_ACCEPTED };
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_mqtt_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_X509, TEST_SCOPE_ID_VALUE, TEST_REGISTRATION_ID_VALUE, TEST_DPS_API_VALUE, on_mqtt_transport_io);
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_mqtt_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_X509, TEST_SCOPE_ID_VALUE, TEST_DPS_API_VALUE, on_mqtt_transport_io);
(void)prov_transport_common_mqtt_x509_cert(handle, TEST_X509_CERT_VALUE, TEST_PRIVATE_KEY_VALUE);
(void)prov_transport_common_mqtt_open(handle, TEST_BUFFER_VALUE, TEST_BUFFER_VALUE, on_transport_register_data_cb, NULL, on_transport_status_cb, NULL);
(void)prov_transport_common_mqtt_open(handle, TEST_REGISTRATION_ID_VALUE, TEST_BUFFER_VALUE, TEST_BUFFER_VALUE, on_transport_register_data_cb, NULL, on_transport_status_cb, NULL);
(void)prov_transport_common_mqtt_register_device(handle, on_transport_challenge_callback, NULL, on_transport_json_parse, NULL);
prov_transport_common_mqtt_dowork(handle);
g_operation_cb(TEST_MQTT_CLIENT_HANDLE, MQTT_CLIENT_ON_CONNACK, &connack, g_msg_recv_callback_context);
@ -1201,9 +1206,9 @@ BEGIN_TEST_SUITE(prov_transport_mqtt_common_ut)
suback.qosCount = 1;
suback.qosReturn = QosValue;
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_mqtt_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_X509, TEST_SCOPE_ID_VALUE, TEST_REGISTRATION_ID_VALUE, TEST_DPS_API_VALUE, on_mqtt_transport_io);
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_mqtt_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_X509, TEST_SCOPE_ID_VALUE, TEST_DPS_API_VALUE, on_mqtt_transport_io);
(void)prov_transport_common_mqtt_x509_cert(handle, TEST_X509_CERT_VALUE, TEST_PRIVATE_KEY_VALUE);
(void)prov_transport_common_mqtt_open(handle, TEST_BUFFER_VALUE, TEST_BUFFER_VALUE, on_transport_register_data_cb, NULL, on_transport_status_cb, NULL);
(void)prov_transport_common_mqtt_open(handle, TEST_REGISTRATION_ID_VALUE, TEST_BUFFER_VALUE, TEST_BUFFER_VALUE, on_transport_register_data_cb, NULL, on_transport_status_cb, NULL);
(void)prov_transport_common_mqtt_register_device(handle, on_transport_challenge_callback, NULL, on_transport_json_parse, NULL);
prov_transport_common_mqtt_dowork(handle);
g_operation_cb(TEST_MQTT_CLIENT_HANDLE, MQTT_CLIENT_ON_CONNACK, &connack, g_msg_recv_callback_context);
@ -1238,9 +1243,9 @@ BEGIN_TEST_SUITE(prov_transport_mqtt_common_ut)
suback.qosCount = 1;
suback.qosReturn = QosValue;
handle = prov_transport_common_mqtt_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_X509, TEST_SCOPE_ID_VALUE, TEST_REGISTRATION_ID_VALUE, TEST_DPS_API_VALUE, on_mqtt_transport_io);
handle = prov_transport_common_mqtt_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_X509, TEST_SCOPE_ID_VALUE, TEST_DPS_API_VALUE, on_mqtt_transport_io);
(void)prov_transport_common_mqtt_x509_cert(handle, TEST_X509_CERT_VALUE, TEST_PRIVATE_KEY_VALUE);
(void)prov_transport_common_mqtt_open(handle, TEST_BUFFER_VALUE, TEST_BUFFER_VALUE, on_transport_register_data_cb, NULL, on_transport_status_cb, NULL);
(void)prov_transport_common_mqtt_open(handle, TEST_REGISTRATION_ID_VALUE, TEST_BUFFER_VALUE, TEST_BUFFER_VALUE, on_transport_register_data_cb, NULL, on_transport_status_cb, NULL);
(void)prov_transport_common_mqtt_register_device(handle, on_transport_challenge_callback, NULL, on_transport_json_parse, NULL);
prov_transport_common_mqtt_dowork(handle);
g_operation_cb(TEST_MQTT_CLIENT_HANDLE, MQTT_CLIENT_ON_CONNACK, &connack, g_msg_recv_callback_context);
@ -1277,9 +1282,9 @@ BEGIN_TEST_SUITE(prov_transport_mqtt_common_ut)
suback.qosCount = 1;
suback.qosReturn = QosValue;
handle = prov_transport_common_mqtt_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_X509, TEST_SCOPE_ID_VALUE, TEST_REGISTRATION_ID_VALUE, TEST_DPS_API_VALUE, on_mqtt_transport_io);
handle = prov_transport_common_mqtt_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_X509, TEST_SCOPE_ID_VALUE, TEST_DPS_API_VALUE, on_mqtt_transport_io);
(void)prov_transport_common_mqtt_x509_cert(handle, TEST_X509_CERT_VALUE, TEST_PRIVATE_KEY_VALUE);
(void)prov_transport_common_mqtt_open(handle, TEST_BUFFER_VALUE, TEST_BUFFER_VALUE, on_transport_register_data_cb, NULL, on_transport_status_cb, NULL);
(void)prov_transport_common_mqtt_open(handle, TEST_REGISTRATION_ID_VALUE, TEST_BUFFER_VALUE, TEST_BUFFER_VALUE, on_transport_register_data_cb, NULL, on_transport_status_cb, NULL);
(void)prov_transport_common_mqtt_register_device(handle, on_transport_challenge_callback, NULL, on_transport_json_parse, NULL);
prov_transport_common_mqtt_dowork(handle);
g_operation_cb(TEST_MQTT_CLIENT_HANDLE, MQTT_CLIENT_ON_CONNACK, &connack, g_msg_recv_callback_context);
@ -1326,7 +1331,7 @@ BEGIN_TEST_SUITE(prov_transport_mqtt_common_ut)
/* Tests_PROV_TRANSPORT_MQTT_COMMON_07_025: [ On success prov_transport_common_mqtt_set_trace shall return a zero value. ] */
TEST_FUNCTION(prov_transport_common_mqtt_set_trace_succeed)
{
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_mqtt_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_X509, TEST_SCOPE_ID_VALUE, TEST_REGISTRATION_ID_VALUE, TEST_DPS_API_VALUE, on_mqtt_transport_io);
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_mqtt_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_X509, TEST_SCOPE_ID_VALUE, TEST_DPS_API_VALUE, on_mqtt_transport_io);
umock_c_reset_all_calls();
//arrange
@ -1362,7 +1367,7 @@ BEGIN_TEST_SUITE(prov_transport_mqtt_common_ut)
/* Tests_PROV_TRANSPORT_MQTT_COMMON_07_029: [ On success prov_transport_common_mqtt_x509_cert shall return a zero value. ] */
TEST_FUNCTION(prov_transport_common_mqtt_x509_cert_succeed)
{
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_mqtt_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_X509, TEST_SCOPE_ID_VALUE, TEST_REGISTRATION_ID_VALUE, TEST_DPS_API_VALUE, on_mqtt_transport_io);
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_mqtt_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_X509, TEST_SCOPE_ID_VALUE, TEST_DPS_API_VALUE, on_mqtt_transport_io);
umock_c_reset_all_calls();
//arrange
@ -1383,7 +1388,7 @@ BEGIN_TEST_SUITE(prov_transport_mqtt_common_ut)
/* Tests_PROV_TRANSPORT_MQTT_COMMON_07_028: [ On any failure prov_transport_common_mqtt_x509_cert, shall return a non-zero value. ] */
TEST_FUNCTION(prov_transport_common_mqtt_x509_cert_fail)
{
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_mqtt_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_X509, TEST_SCOPE_ID_VALUE, TEST_REGISTRATION_ID_VALUE, TEST_DPS_API_VALUE, on_mqtt_transport_io);
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_mqtt_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_X509, TEST_SCOPE_ID_VALUE, TEST_DPS_API_VALUE, on_mqtt_transport_io);
umock_c_reset_all_calls();
int negativeTestsInitResult = umock_c_negative_tests_init();
@ -1434,7 +1439,7 @@ BEGIN_TEST_SUITE(prov_transport_mqtt_common_ut)
/* Tests_PROV_TRANSPORT_MQTT_COMMON_07_030: [ If handle or certificate is NULL, prov_transport_common_mqtt_set_trusted_cert shall return a non-zero value. ] */
TEST_FUNCTION(prov_transport_common_mqtt_set_trusted_cert_cert_NULL_fail)
{
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_mqtt_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_X509, TEST_SCOPE_ID_VALUE, TEST_REGISTRATION_ID_VALUE, TEST_DPS_API_VALUE, on_mqtt_transport_io);
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_mqtt_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_X509, TEST_SCOPE_ID_VALUE, TEST_DPS_API_VALUE, on_mqtt_transport_io);
umock_c_reset_all_calls();
//arrange
@ -1454,7 +1459,7 @@ BEGIN_TEST_SUITE(prov_transport_mqtt_common_ut)
/* Tests_PROV_TRANSPORT_MQTT_COMMON_07_033: [ On success prov_transport_common_mqtt_set_trusted_cert shall return a zero value. ] */
TEST_FUNCTION(prov_transport_common_mqtt_set_trusted_cert_succeed)
{
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_mqtt_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_X509, TEST_SCOPE_ID_VALUE, TEST_REGISTRATION_ID_VALUE, TEST_DPS_API_VALUE, on_mqtt_transport_io);
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_mqtt_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_X509, TEST_SCOPE_ID_VALUE, TEST_DPS_API_VALUE, on_mqtt_transport_io);
umock_c_reset_all_calls();
//arrange
@ -1474,7 +1479,7 @@ BEGIN_TEST_SUITE(prov_transport_mqtt_common_ut)
/* Tests_PROV_TRANSPORT_MQTT_COMMON_07_032: [ On any failure prov_transport_common_mqtt_set_trusted_cert, shall return a non-zero value. ] */
TEST_FUNCTION(prov_transport_common_mqtt_set_trusted_cert_fail)
{
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_mqtt_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_X509, TEST_SCOPE_ID_VALUE, TEST_REGISTRATION_ID_VALUE, TEST_DPS_API_VALUE, on_mqtt_transport_io);
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_mqtt_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_X509, TEST_SCOPE_ID_VALUE, TEST_DPS_API_VALUE, on_mqtt_transport_io);
umock_c_reset_all_calls();
//arrange
@ -1512,7 +1517,7 @@ BEGIN_TEST_SUITE(prov_transport_mqtt_common_ut)
/* Tests_PROV_TRANSPORT_MQTT_COMMON_07_034: [ If handle or proxy_options is NULL, prov_transport_common_mqtt_set_proxy shall return a non-zero value. ]*/
TEST_FUNCTION(prov_transport_common_mqtt_set_proxy_proxy_NULL_fail)
{
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_mqtt_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_X509, TEST_SCOPE_ID_VALUE, TEST_REGISTRATION_ID_VALUE, TEST_DPS_API_VALUE, on_mqtt_transport_io);
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_mqtt_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_X509, TEST_SCOPE_ID_VALUE, TEST_DPS_API_VALUE, on_mqtt_transport_io);
umock_c_reset_all_calls();
//arrange
@ -1532,7 +1537,7 @@ BEGIN_TEST_SUITE(prov_transport_mqtt_common_ut)
TEST_FUNCTION(prov_transport_common_mqtt_set_proxy_no_username_fail)
{
HTTP_PROXY_OPTIONS proxy_options = { 0 };
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_mqtt_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_X509, TEST_SCOPE_ID_VALUE, TEST_REGISTRATION_ID_VALUE, TEST_DPS_API_VALUE, on_mqtt_transport_io);
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_mqtt_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_X509, TEST_SCOPE_ID_VALUE, TEST_DPS_API_VALUE, on_mqtt_transport_io);
umock_c_reset_all_calls();
//arrange
@ -1556,7 +1561,7 @@ BEGIN_TEST_SUITE(prov_transport_mqtt_common_ut)
TEST_FUNCTION(prov_transport_common_mqtt_set_proxy_2_succeed)
{
HTTP_PROXY_OPTIONS proxy_options = { 0 };
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_mqtt_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_X509, TEST_SCOPE_ID_VALUE, TEST_REGISTRATION_ID_VALUE, TEST_DPS_API_VALUE, on_mqtt_transport_io);
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_mqtt_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_X509, TEST_SCOPE_ID_VALUE, TEST_DPS_API_VALUE, on_mqtt_transport_io);
umock_c_reset_all_calls();
//arrange
@ -1584,7 +1589,7 @@ BEGIN_TEST_SUITE(prov_transport_mqtt_common_ut)
TEST_FUNCTION(prov_transport_common_mqtt_set_proxy_hostname_NULL_fail)
{
HTTP_PROXY_OPTIONS proxy_options = { 0 };
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_mqtt_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_X509, TEST_SCOPE_ID_VALUE, TEST_REGISTRATION_ID_VALUE, TEST_DPS_API_VALUE, on_mqtt_transport_io);
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_mqtt_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_X509, TEST_SCOPE_ID_VALUE, TEST_DPS_API_VALUE, on_mqtt_transport_io);
umock_c_reset_all_calls();
//arrange
@ -1605,7 +1610,7 @@ BEGIN_TEST_SUITE(prov_transport_mqtt_common_ut)
TEST_FUNCTION(prov_transport_common_mqtt_set_proxy_fail)
{
HTTP_PROXY_OPTIONS proxy_options = { 0 };
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_mqtt_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_X509, TEST_SCOPE_ID_VALUE, TEST_REGISTRATION_ID_VALUE, TEST_DPS_API_VALUE, on_mqtt_transport_io);
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_mqtt_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_X509, TEST_SCOPE_ID_VALUE, TEST_DPS_API_VALUE, on_mqtt_transport_io);
umock_c_reset_all_calls();
int negativeTestsInitResult = umock_c_negative_tests_init();
@ -1649,7 +1654,7 @@ BEGIN_TEST_SUITE(prov_transport_mqtt_common_ut)
TEST_FUNCTION(prov_transport_common_mqtt_set_proxy_succeed)
{
HTTP_PROXY_OPTIONS proxy_options = { 0 };
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_mqtt_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_X509, TEST_SCOPE_ID_VALUE, TEST_REGISTRATION_ID_VALUE, TEST_DPS_API_VALUE, on_mqtt_transport_io);
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_mqtt_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_X509, TEST_SCOPE_ID_VALUE, TEST_DPS_API_VALUE, on_mqtt_transport_io);
umock_c_reset_all_calls();
//arrange
@ -1675,7 +1680,7 @@ BEGIN_TEST_SUITE(prov_transport_mqtt_common_ut)
TEST_FUNCTION(prov_transport_common_mqtt_set_proxy_twice_succeed)
{
HTTP_PROXY_OPTIONS proxy_options = { 0 };
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_mqtt_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_X509, TEST_SCOPE_ID_VALUE, TEST_REGISTRATION_ID_VALUE, TEST_DPS_API_VALUE, on_mqtt_transport_io);
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_transport_common_mqtt_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_X509, TEST_SCOPE_ID_VALUE, TEST_DPS_API_VALUE, on_mqtt_transport_io);
proxy_options.host_address = TEST_HOST_ADDRESS_VALUE;
proxy_options.port = 443;

Просмотреть файл

@ -86,12 +86,11 @@ IMPLEMENT_UMOCK_C_ENUM_TYPE(PROV_DEVICE_TRANSPORT_STATUS, PROV_DEVICE_TRANSPORT_
TEST_DEFINE_ENUM_TYPE(TRANSPORT_HSM_TYPE, HSM_AUTH_TYPE_VALUES);
IMPLEMENT_UMOCK_C_ENUM_TYPE(TRANSPORT_HSM_TYPE, HSM_AUTH_TYPE_VALUES);
static PROV_DEVICE_TRANSPORT_HANDLE my_prov_transport_common_mqtt_create(const char* uri, TRANSPORT_HSM_TYPE type, const char* scope_id, const char* registration_id, const char* dps_api_version, PROV_MQTT_TRANSPORT_IO transport_io)
static PROV_DEVICE_TRANSPORT_HANDLE my_prov_transport_common_mqtt_create(const char* uri, TRANSPORT_HSM_TYPE type, const char* scope_id, const char* dps_api_version, PROV_MQTT_TRANSPORT_IO transport_io)
{
(void)uri;
(void)type;
(void)scope_id;
(void)registration_id;
(void)dps_api_version;
g_transport_io = transport_io;
@ -200,10 +199,10 @@ BEGIN_TEST_SUITE(prov_transport_mqtt_ws_client_ut)
TEST_FUNCTION(prov_transport_mqtt_ws_create_succeed)
{
//arrange
STRICT_EXPECTED_CALL(prov_transport_common_mqtt_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_REGISTRATION_ID_VALUE, TEST_DPS_API_VALUE, IGNORED_PTR_ARG));
STRICT_EXPECTED_CALL(prov_transport_common_mqtt_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_DPS_API_VALUE, IGNORED_PTR_ARG));
//act
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_mqtt_ws_transport_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_REGISTRATION_ID_VALUE, TEST_DPS_API_VALUE);
PROV_DEVICE_TRANSPORT_HANDLE handle = prov_mqtt_ws_transport_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_DPS_API_VALUE);
//assert
ASSERT_IS_NOT_NULL(handle);
@ -216,7 +215,7 @@ BEGIN_TEST_SUITE(prov_transport_mqtt_ws_client_ut)
TEST_FUNCTION(mqtt_transport_ws_io_succeed)
{
XIO_HANDLE dps_io_info;
(void)prov_mqtt_ws_transport_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_REGISTRATION_ID_VALUE, TEST_DPS_API_VALUE);
(void)prov_mqtt_ws_transport_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_DPS_API_VALUE);
umock_c_reset_all_calls();
//arrange
@ -239,7 +238,7 @@ BEGIN_TEST_SUITE(prov_transport_mqtt_ws_client_ut)
TEST_FUNCTION(mqtt_transport_ws_io_x509_succeed)
{
XIO_HANDLE dps_io_info;
(void)prov_mqtt_ws_transport_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_X509, TEST_SCOPE_ID_VALUE, TEST_REGISTRATION_ID_VALUE, TEST_DPS_API_VALUE);
(void)prov_mqtt_ws_transport_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_X509, TEST_SCOPE_ID_VALUE, TEST_DPS_API_VALUE);
umock_c_reset_all_calls();
//arrange
@ -262,7 +261,7 @@ BEGIN_TEST_SUITE(prov_transport_mqtt_ws_client_ut)
TEST_FUNCTION(mqtt_transport_ws_io_fail)
{
XIO_HANDLE dps_io_info;
(void)prov_mqtt_ws_transport_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_REGISTRATION_ID_VALUE, TEST_DPS_API_VALUE);
(void)prov_mqtt_ws_transport_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_DPS_API_VALUE);
umock_c_reset_all_calls();
int negativeTestsInitResult = umock_c_negative_tests_init();
@ -302,7 +301,7 @@ BEGIN_TEST_SUITE(prov_transport_mqtt_ws_client_ut)
{
HTTP_PROXY_OPTIONS proxy_info;
XIO_HANDLE dps_io_info;
(void)prov_mqtt_ws_transport_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_REGISTRATION_ID_VALUE, TEST_DPS_API_VALUE);
(void)prov_mqtt_ws_transport_create(TEST_URI_VALUE, TRANSPORT_HSM_TYPE_TPM, TEST_SCOPE_ID_VALUE, TEST_DPS_API_VALUE);
umock_c_reset_all_calls();
//arrange
@ -345,10 +344,10 @@ BEGIN_TEST_SUITE(prov_transport_mqtt_ws_client_ut)
TEST_FUNCTION(prov_transport_mqtt_ws_open_succeed)
{
//arrange
STRICT_EXPECTED_CALL(prov_transport_common_mqtt_open(TEST_DPS_HANDLE, TEST_BUFFER_VALUE, TEST_BUFFER_VALUE, on_transport_register_data_cb, NULL, on_transport_status_cb, NULL));
STRICT_EXPECTED_CALL(prov_transport_common_mqtt_open(TEST_DPS_HANDLE, TEST_REGISTRATION_ID_VALUE, TEST_BUFFER_VALUE, TEST_BUFFER_VALUE, on_transport_register_data_cb, NULL, on_transport_status_cb, NULL));
//act
int result = prov_mqtt_ws_transport_open(TEST_DPS_HANDLE, TEST_BUFFER_VALUE, TEST_BUFFER_VALUE, on_transport_register_data_cb, NULL, on_transport_status_cb, NULL);
int result = prov_mqtt_ws_transport_open(TEST_DPS_HANDLE, TEST_REGISTRATION_ID_VALUE, TEST_BUFFER_VALUE, TEST_BUFFER_VALUE, on_transport_register_data_cb, NULL, on_transport_status_cb, NULL);
//assert
ASSERT_ARE_EQUAL(int, 0, result);