diff --git a/c-utility b/c-utility index 6b64328a1b..c9da788c89 160000 --- a/c-utility +++ b/c-utility @@ -1 +1 @@ -Subproject commit 6b64328a1b46129a13d4e12e0afc9e79e39c031b +Subproject commit c9da788c89c2e58c7c3c6dc0c61b0d2f000ecc5a diff --git a/deps/uhttp b/deps/uhttp index 98b7bddc5b..aacf44274f 160000 --- a/deps/uhttp +++ b/deps/uhttp @@ -1 +1 @@ -Subproject commit 98b7bddc5b517457a2dbd66cb5071218a2fd6f60 +Subproject commit aacf44274fb744dd3d8155b22ac82f10b15b453c diff --git a/iothub_client/devdoc/requirement_docs/iothub_authorization.md b/iothub_client/devdoc/requirement_docs/iothub_authorization.md index fcdc17922c..3c3f398cba 100644 --- a/iothub_client/devdoc/requirement_docs/iothub_authorization.md +++ b/iothub_client/devdoc/requirement_docs/iothub_authorization.md @@ -20,7 +20,7 @@ DEFINE_ENUM(IOTHUB_CREDENTIAL_TYPE, IOTHUB_CREDENTIAL_TYPE_VALUES); MOCKABLE_FUNCTION(, IOTHUB_AUTHORIZATION_HANDLE, IoTHubClient_Auth_Create, const char*, device_key, const char*, device_id, const char*, device_sas_token); MOCKABLE_FUNCTION(, void, IoTHubClient_Auth_Destroy, IOTHUB_AUTHORIZATION_HANDLE, handle); MOCKABLE_FUNCTION(, IOTHUB_CREDENTIAL_TYPE, IoTHubClient_Auth_Get_Credential_Type, IOTHUB_AUTHORIZATION_HANDLE, handle); -MOCKABLE_FUNCTION(, char*, IoTHubClient_Auth_Get_SasToken, IOTHUB_AUTHORIZATION_HANDLE, handle, const char*, scope, size_t, expiry_time_relative_seconds); +MOCKABLE_FUNCTION(, char*, IoTHubClient_Auth_Get_SasToken, IOTHUB_AUTHORIZATION_HANDLE, handle, const char*, scope, uint64_t, expiry_time_relative_seconds); MOCKABLE_FUNCTION(, const char*, IoTHubClient_Auth_Get_DeviceId, IOTHUB_AUTHORIZATION_HANDLE, handle); MOCKABLE_FUNCTION(, const char*, IoTHubClient_Auth_Get_ModuleId, IOTHUB_AUTHORIZATION_HANDLE, handle); MOCKABLE_FUNCTION(, bool, IoTHubClient_Auth_Is_SasToken_Valid, IOTHUB_AUTHORIZATION_HANDLE, handle); @@ -69,7 +69,7 @@ extern IOTHUB_CREDENTIAL_TYPE IoTHub_Auth_Get_Credential_Type(IOTHUB_AUTHORIZATI ## IoTHubClient_Auth_Get_SasToken ```c -extern char* IoTHubClient_Auth_Get_SasToken(IOTHUB_AUTHORIZATION_HANDLE handle, const char* scope, size_t expiry_time_relative_seconds); +extern char* IoTHubClient_Auth_Get_SasToken(IOTHUB_AUTHORIZATION_HANDLE handle, const char* scope, uint64_t expiry_time_relative_seconds); ``` **SRS_IoTHub_Authorization_07_009: [** if `handle` or `scope` are NULL, `IoTHubClient_Auth_Get_SasToken` shall return NULL. **]** diff --git a/iothub_client/inc/internal/iothub_client_authorization.h b/iothub_client/inc/internal/iothub_client_authorization.h index bf8cf81010..663a183c31 100644 --- a/iothub_client/inc/internal/iothub_client_authorization.h +++ b/iothub_client/inc/internal/iothub_client_authorization.h @@ -41,15 +41,15 @@ MOCKABLE_FUNCTION(, IOTHUB_AUTHORIZATION_HANDLE, IoTHubClient_Auth_CreateFromDev MOCKABLE_FUNCTION(, void, IoTHubClient_Auth_Destroy, IOTHUB_AUTHORIZATION_HANDLE, handle); MOCKABLE_FUNCTION(, IOTHUB_CREDENTIAL_TYPE, IoTHubClient_Auth_Set_x509_Type, IOTHUB_AUTHORIZATION_HANDLE, handle, bool, enable_x509); MOCKABLE_FUNCTION(, IOTHUB_CREDENTIAL_TYPE, IoTHubClient_Auth_Get_Credential_Type, IOTHUB_AUTHORIZATION_HANDLE, handle); -MOCKABLE_FUNCTION(, char*, IoTHubClient_Auth_Get_SasToken, IOTHUB_AUTHORIZATION_HANDLE, handle, const char*, scope, size_t, expiry_time_relative_seconds, const char*, key_name); +MOCKABLE_FUNCTION(, char*, IoTHubClient_Auth_Get_SasToken, IOTHUB_AUTHORIZATION_HANDLE, handle, const char*, scope, uint64_t, expiry_time_relative_seconds, const char*, key_name); MOCKABLE_FUNCTION(, int, IoTHubClient_Auth_Set_xio_Certificate, IOTHUB_AUTHORIZATION_HANDLE, handle, XIO_HANDLE, xio); MOCKABLE_FUNCTION(, const char*, IoTHubClient_Auth_Get_DeviceId, IOTHUB_AUTHORIZATION_HANDLE, handle); MOCKABLE_FUNCTION(, const char*, IoTHubClient_Auth_Get_ModuleId, IOTHUB_AUTHORIZATION_HANDLE, handle); MOCKABLE_FUNCTION(, const char*, IoTHubClient_Auth_Get_DeviceKey, IOTHUB_AUTHORIZATION_HANDLE, handle); MOCKABLE_FUNCTION(, SAS_TOKEN_STATUS, IoTHubClient_Auth_Is_SasToken_Valid, IOTHUB_AUTHORIZATION_HANDLE, handle); MOCKABLE_FUNCTION(, int, IoTHubClient_Auth_Get_x509_info, IOTHUB_AUTHORIZATION_HANDLE, handle, char**, x509_cert, char**, x509_key); -MOCKABLE_FUNCTION(, int, IoTHubClient_Auth_Set_SasToken_Expiry, IOTHUB_AUTHORIZATION_HANDLE, handle, size_t, expiry_time_seconds); -MOCKABLE_FUNCTION(, size_t, IoTHubClient_Auth_Get_SasToken_Expiry, IOTHUB_AUTHORIZATION_HANDLE, handle); +MOCKABLE_FUNCTION(, int, IoTHubClient_Auth_Set_SasToken_Expiry, IOTHUB_AUTHORIZATION_HANDLE, handle, uint64_t, expiry_time_seconds); +MOCKABLE_FUNCTION(, uint64_t, IoTHubClient_Auth_Get_SasToken_Expiry, IOTHUB_AUTHORIZATION_HANDLE, handle); #ifdef USE_EDGE_MODULES diff --git a/iothub_client/src/iothub_client_authorization.c b/iothub_client/src/iothub_client_authorization.c index 5b248cf6d2..c09b5cb291 100644 --- a/iothub_client/src/iothub_client_authorization.c +++ b/iothub_client/src/iothub_client_authorization.c @@ -30,14 +30,14 @@ typedef struct IOTHUB_AUTHORIZATION_DATA_TAG char* device_key; char* device_id; char* module_id; - size_t token_expiry_time_sec; + uint64_t token_expiry_time_sec; IOTHUB_CREDENTIAL_TYPE cred_type; #ifdef USE_PROV_MODULE IOTHUB_SECURITY_HANDLE device_auth_handle; #endif } IOTHUB_AUTHORIZATION_DATA; -static int get_seconds_since_epoch(size_t* seconds) +static int get_seconds_since_epoch(uint64_t* seconds) { int result; time_t current_time; @@ -48,7 +48,7 @@ static int get_seconds_since_epoch(size_t* seconds) } else { - *seconds = (size_t)get_difftime(current_time, (time_t)0); + *seconds = (uint64_t)get_difftime(current_time, (time_t)0); result = 0; } return result; @@ -383,7 +383,7 @@ IOTHUB_CREDENTIAL_TYPE IoTHubClient_Auth_Get_Credential_Type(IOTHUB_AUTHORIZATIO return result; } -char* IoTHubClient_Auth_Get_SasToken(IOTHUB_AUTHORIZATION_HANDLE handle, const char* scope, size_t expiry_time_relative_seconds, const char* key_name) +char* IoTHubClient_Auth_Get_SasToken(IOTHUB_AUTHORIZATION_HANDLE handle, const char* scope, uint64_t expiry_time_relative_seconds, const char* key_name) { char* result; (void)expiry_time_relative_seconds; @@ -399,7 +399,7 @@ char* IoTHubClient_Auth_Get_SasToken(IOTHUB_AUTHORIZATION_HANDLE handle, const c { #ifdef USE_PROV_MODULE DEVICE_AUTH_CREDENTIAL_INFO dev_auth_cred; - size_t sec_since_epoch; + uint64_t sec_since_epoch; if (get_seconds_since_epoch(&sec_since_epoch) != 0) { @@ -409,7 +409,7 @@ char* IoTHubClient_Auth_Get_SasToken(IOTHUB_AUTHORIZATION_HANDLE handle, const c else { memset(&dev_auth_cred, 0, sizeof(DEVICE_AUTH_CREDENTIAL_INFO)); - size_t expiry_time = sec_since_epoch + handle->token_expiry_time_sec; + uint64_t expiry_time = sec_since_epoch + handle->token_expiry_time_sec; dev_auth_cred.sas_info.expiry_seconds = expiry_time; dev_auth_cred.sas_info.token_scope = scope; dev_auth_cred.sas_info.key_name = key_name; @@ -464,7 +464,7 @@ char* IoTHubClient_Auth_Get_SasToken(IOTHUB_AUTHORIZATION_HANDLE handle, const c else { STRING_HANDLE sas_token; - size_t sec_since_epoch; + uint64_t sec_since_epoch; /* Codes_SRS_IoTHub_Authorization_07_010: [ IoTHubClient_Auth_Get_SasToken` shall construct the expiration time using the handle->token_expiry_time_sec added to epoch time. ] */ if (get_seconds_since_epoch(&sec_since_epoch) != 0) @@ -476,7 +476,7 @@ char* IoTHubClient_Auth_Get_SasToken(IOTHUB_AUTHORIZATION_HANDLE handle, const c else { /* Codes_SRS_IoTHub_Authorization_07_011: [ IoTHubClient_Auth_Get_ConnString shall call SASToken_CreateString to construct the sas token. ] */ - size_t expiry_time = sec_since_epoch + handle->token_expiry_time_sec; + uint64_t expiry_time = sec_since_epoch + handle->token_expiry_time_sec; if ( (sas_token = SASToken_CreateString(handle->device_key, scope, key_name, expiry_time)) == NULL) { /* Codes_SRS_IoTHub_Authorization_07_020: [ If any error is encountered IoTHubClient_Auth_Get_ConnString shall return NULL. ] */ @@ -690,7 +690,7 @@ char* IoTHubClient_Auth_Get_TrustBundle(IOTHUB_AUTHORIZATION_HANDLE handle, cons } #endif -int IoTHubClient_Auth_Set_SasToken_Expiry(IOTHUB_AUTHORIZATION_HANDLE handle, size_t expiry_time_seconds) +int IoTHubClient_Auth_Set_SasToken_Expiry(IOTHUB_AUTHORIZATION_HANDLE handle, uint64_t expiry_time_seconds) { int result; if (handle == NULL) @@ -712,9 +712,9 @@ int IoTHubClient_Auth_Set_SasToken_Expiry(IOTHUB_AUTHORIZATION_HANDLE handle, si return result; } -size_t IoTHubClient_Auth_Get_SasToken_Expiry(IOTHUB_AUTHORIZATION_HANDLE handle) +uint64_t IoTHubClient_Auth_Get_SasToken_Expiry(IOTHUB_AUTHORIZATION_HANDLE handle) { - size_t result; + uint64_t result; if (handle == NULL) { LogError("Invalid handle value handle: NULL"); diff --git a/iothub_client/src/iothub_client_core_ll.c b/iothub_client/src/iothub_client_core_ll.c index 2d42870663..32a1e8ab0b 100755 --- a/iothub_client/src/iothub_client_core_ll.c +++ b/iothub_client/src/iothub_client_core_ll.c @@ -2347,7 +2347,8 @@ IOTHUB_CLIENT_RESULT IoTHubClientCore_LL_SetOption(IOTHUB_CLIENT_CORE_LL_HANDLE // if this becomes necessary else if (strcmp(optionName, OPTION_SAS_TOKEN_REFRESH_TIME) == 0 || strcmp(optionName, OPTION_SAS_TOKEN_LIFETIME) == 0) { - if (IoTHubClient_Auth_Set_SasToken_Expiry(handleData->authorization_module, *(size_t*)value) != 0) + // API compat: while IoTHubClient_Auth_Set_SasToken_Expiry accepts uint64_t, we cannot change the public API. + if (IoTHubClient_Auth_Set_SasToken_Expiry(handleData->authorization_module, (uint64_t)(*(size_t*)value)) != 0) { LogError("Failed setting the Token Expiry time"); result = IOTHUB_CLIENT_ERROR; diff --git a/iothub_client/src/iothub_client_ll_uploadtoblob.c b/iothub_client/src/iothub_client_ll_uploadtoblob.c index d2fec99f95..9cb306c884 100644 --- a/iothub_client/src/iothub_client_ll_uploadtoblob.c +++ b/iothub_client/src/iothub_client_ll_uploadtoblob.c @@ -436,7 +436,7 @@ static int IoTHubClient_LL_UploadToBlob_step1and2(IOTHUB_CLIENT_LL_UPLOADTOBLOB_ } else { - size_t expiry = (size_t)(difftime(curr_time, 0) + 3600); + uint64_t expiry = (uint64_t)(difftime(curr_time, 0) + 3600); char* sas_token = IoTHubClient_Auth_Get_SasToken(upload_data->authorization_module, STRING_c_str(uri_resource), expiry, EMPTY_STRING); if (sas_token == NULL) { diff --git a/iothub_client/src/iothubtransport_amqp_cbs_auth.c b/iothub_client/src/iothubtransport_amqp_cbs_auth.c index a1ae071420..325c51bb83 100644 --- a/iothub_client/src/iothubtransport_amqp_cbs_auth.c +++ b/iothub_client/src/iothubtransport_amqp_cbs_auth.c @@ -29,7 +29,7 @@ typedef struct AUTHENTICATION_INSTANCE_TAG ON_AUTHENTICATION_ERROR_CALLBACK on_error_callback; void* on_error_callback_context; - size_t cbs_request_timeout_secs; + uint64_t cbs_request_timeout_secs; AUTHENTICATION_STATE state; CBS_HANDLE cbs_handle; @@ -88,7 +88,7 @@ static int verify_cbs_put_token_timeout(AUTHENTICATION_INSTANCE* instance, bool* LogError("Failed verifying if cbs_put_token has timed out (get_time failed)"); } // Codes_SRS_IOTHUBTRANSPORT_AMQP_AUTH_09_083: [authentication_do_work() shall check for authentication timeout comparing the current time since `instance->current_sas_token_put_time` to `instance->cbs_request_timeout_secs`] - else if ((uint32_t)get_difftime(current_time, instance->current_sas_token_put_time) >= instance->cbs_request_timeout_secs) + else if ((uint64_t)get_difftime(current_time, instance->current_sas_token_put_time) >= instance->cbs_request_timeout_secs) { *is_timed_out = true; result = RESULT_OK; @@ -106,7 +106,7 @@ static int verify_cbs_put_token_timeout(AUTHENTICATION_INSTANCE* instance, bool* static int verify_sas_token_refresh_timeout(AUTHENTICATION_INSTANCE* instance, bool* is_timed_out) { int result; - size_t sas_token_expiry; + uint64_t sas_token_expiry; if (instance->current_sas_token_put_time == INDEFINITE_TIME) { @@ -126,7 +126,7 @@ static int verify_sas_token_refresh_timeout(AUTHENTICATION_INSTANCE* instance, b result = MU_FAILURE; LogError("Failed verifying if SAS token refresh timed out (get_time failed)"); } - else if ((uint32_t)get_difftime(current_time, instance->current_sas_token_put_time) >= (sas_token_expiry*SAS_REFRESH_MULTIPLIER)) + else if ((uint64_t)get_difftime(current_time, instance->current_sas_token_put_time) >= (sas_token_expiry*SAS_REFRESH_MULTIPLIER)) { *is_timed_out = true; result = RESULT_OK; diff --git a/iothub_client/src/iothubtransport_mqtt_common.c b/iothub_client/src/iothubtransport_mqtt_common.c index 6224e110ee..57b974e962 100644 --- a/iothub_client/src/iothubtransport_mqtt_common.c +++ b/iothub_client/src/iothubtransport_mqtt_common.c @@ -2641,7 +2641,7 @@ static int UpdateMqttConnectionStateIfNeeded(PMQTTTRANSPORT_HANDLE_DATA transpor // If the credential type is not an x509 certificate then we shall renew the Sas_Token if (cred_type != IOTHUB_CREDENTIAL_TYPE_X509 && cred_type != IOTHUB_CREDENTIAL_TYPE_X509_ECC) { - size_t sas_token_expiry = IoTHubClient_Auth_Get_SasToken_Expiry(transport_data->authorization_module); + uint64_t sas_token_expiry = IoTHubClient_Auth_Get_SasToken_Expiry(transport_data->authorization_module); if ((current_time - transport_data->mqtt_connect_time) / 1000 > (sas_token_expiry*SAS_REFRESH_MULTIPLIER)) { /* Codes_SRS_IOTHUB_TRANSPORT_MQTT_COMMON_07_058: [ If the sas token has timed out IoTHubTransport_MQTT_Common_DoWork shall disconnect from the mqtt client and destroy the transport information and wait for reconnect. ] */ diff --git a/iothub_client/tests/iothub_client_authorization_ut/iothub_client_authorization_ut.c b/iothub_client/tests/iothub_client_authorization_ut/iothub_client_authorization_ut.c index b2890afa91..184406b107 100644 --- a/iothub_client/tests/iothub_client_authorization_ut/iothub_client_authorization_ut.c +++ b/iothub_client/tests/iothub_client_authorization_ut/iothub_client_authorization_ut.c @@ -2,9 +2,11 @@ // Licensed under the MIT license. See LICENSE file in the project root for full license information. #ifdef __cplusplus -#include +#include +#include #else #include +#include #endif static void* my_gballoc_malloc(size_t size) @@ -20,6 +22,7 @@ static void my_gballoc_free(void* ptr) #include "testrunnerswitcher.h" #include "umock_c/umock_c.h" #include "umock_c/umocktypes_charptr.h" +#include "umock_c/umocktypes_stdint.h" #include "umock_c/umock_c_negative_tests.h" #include "azure_macro_utils/macro_utils.h" @@ -51,7 +54,7 @@ static const char* TEST_STRING_VALUE = "Test_string_value"; static const char* TEST_KEYNAME_VALUE = "Test_keyname_value"; static const char* TEST_REG_CERT = "Test_certificate"; static const char* TEST_REG_PK = "Test_private_key"; -static size_t TEST_EXPIRY_TIME = 1; +static uint64_t TEST_EXPIRY_TIME = 1; #define TEST_TIME_VALUE (time_t)123456 @@ -72,7 +75,7 @@ static int my_mallocAndStrcpy_s(char** destination, const char* source) return 0; } -static STRING_HANDLE my_SASToken_CreateString(const char* key, const char* scope, const char* keyName, size_t expiry) +static STRING_HANDLE my_SASToken_CreateString(const char* key, const char* scope, const char* keyName, uint64_t expiry) { (void)key; (void)scope; @@ -135,6 +138,9 @@ TEST_SUITE_INITIALIZE(suite_init) (void)umock_c_init(on_umock_c_error); + result = umocktypes_stdint_register_types(); + ASSERT_ARE_EQUAL(int, 0, result, "umocktypes_stdint_register_types"); + result = umocktypes_charptr_register_types(); ASSERT_ARE_EQUAL(int, 0, result); @@ -1023,7 +1029,7 @@ TEST_FUNCTION(IoTHubClient_Auth_Set_SasToken_Expiry_handle_NULL_fail) TEST_FUNCTION(IoTHubClient_Auth_Set_SasToken_Expiry_succeed) { - size_t expiry_time = 4800; + uint64_t expiry_time = 4800; //arrange IOTHUB_AUTHORIZATION_HANDLE handle = IoTHubClient_Auth_Create(NULL, DEVICE_ID, TEST_SAS_TOKEN, NULL); @@ -1034,7 +1040,7 @@ TEST_FUNCTION(IoTHubClient_Auth_Set_SasToken_Expiry_succeed) //assert ASSERT_ARE_EQUAL(int, 0, result); - ASSERT_ARE_EQUAL(size_t, expiry_time, IoTHubClient_Auth_Get_SasToken_Expiry(handle), "Sas Token Expiry time not set correctly"); + ASSERT_ARE_EQUAL(uint64_t, expiry_time, IoTHubClient_Auth_Get_SasToken_Expiry(handle), "Sas Token Expiry time not set correctly"); ASSERT_ARE_EQUAL(char_ptr, umock_c_get_expected_calls(), umock_c_get_actual_calls()); //cleanup @@ -1046,10 +1052,10 @@ TEST_FUNCTION(IoTHubClient_Auth_Get_SasToken_Expiry_handle_NULL_fail) //arrange //act - size_t result = IoTHubClient_Auth_Get_SasToken_Expiry(NULL); + uint64_t result = IoTHubClient_Auth_Get_SasToken_Expiry(NULL); //assert - ASSERT_ARE_EQUAL(size_t, 0, result); + ASSERT_ARE_EQUAL(uint64_t, 0, result); ASSERT_ARE_EQUAL(char_ptr, umock_c_get_expected_calls(), umock_c_get_actual_calls()); //cleanup @@ -1057,7 +1063,7 @@ TEST_FUNCTION(IoTHubClient_Auth_Get_SasToken_Expiry_handle_NULL_fail) TEST_FUNCTION(IoTHubClient_Auth_Get_SasToken_Expiry_succeed) { - size_t expiry_time = 4800; + uint64_t expiry_time = 4800; //arrange IOTHUB_AUTHORIZATION_HANDLE handle = IoTHubClient_Auth_Create(NULL, DEVICE_ID, TEST_SAS_TOKEN, NULL); @@ -1065,10 +1071,10 @@ TEST_FUNCTION(IoTHubClient_Auth_Get_SasToken_Expiry_succeed) umock_c_reset_all_calls(); //act - size_t result = IoTHubClient_Auth_Get_SasToken_Expiry(handle); + uint64_t result = IoTHubClient_Auth_Get_SasToken_Expiry(handle); //assert - ASSERT_ARE_EQUAL(size_t, expiry_time, result); + ASSERT_ARE_EQUAL(uint64_t, expiry_time, result); ASSERT_ARE_EQUAL(char_ptr, umock_c_get_expected_calls(), umock_c_get_actual_calls()); //cleanup diff --git a/iothub_client/tests/iothubclient_edge_ut/iothubclient_edge_ut.c b/iothub_client/tests/iothubclient_edge_ut/iothubclient_edge_ut.c index addac08a6a..78b004d3a7 100644 --- a/iothub_client/tests/iothubclient_edge_ut/iothubclient_edge_ut.c +++ b/iothub_client/tests/iothubclient_edge_ut/iothubclient_edge_ut.c @@ -222,7 +222,7 @@ static char* my_json_serialize_to_string(const JSON_Value* value) return newstr; } -static char* my_IoTHubClient_Auth_Get_SasToken(IOTHUB_AUTHORIZATION_HANDLE handle, const char* scope, size_t expiry_time_relative_seconds, const char* key_name) +static char* my_IoTHubClient_Auth_Get_SasToken(IOTHUB_AUTHORIZATION_HANDLE handle, const char* scope, uint64_t expiry_time_relative_seconds, const char* key_name) { (void)handle; (void)expiry_time_relative_seconds; diff --git a/iothub_client/tests/iothubclient_ll_u2b_ut/iothub_client_ll_u2b_ut.c b/iothub_client/tests/iothubclient_ll_u2b_ut/iothub_client_ll_u2b_ut.c index 5667d20892..ef08bb24a4 100644 --- a/iothub_client/tests/iothubclient_ll_u2b_ut/iothub_client_ll_u2b_ut.c +++ b/iothub_client/tests/iothubclient_ll_u2b_ut/iothub_client_ll_u2b_ut.c @@ -29,6 +29,7 @@ static void* my_gballoc_calloc(size_t nmemb, size_t size) #include "azure_macro_utils/macro_utils.h" #include "umock_c/umock_c.h" #include "umock_c/umocktypes_charptr.h" +#include "umock_c/umocktypes_stdint.h" #include "umock_c/umock_c_negative_tests.h" #include "umock_c/umocktypes.h" #include "umock_c/umocktypes_c.h" @@ -270,7 +271,7 @@ static int my_mallocAndStrcpy_s(char** destination, const char* source) return 0; } -static char* my_IoTHubClient_Auth_Get_SasToken(IOTHUB_AUTHORIZATION_HANDLE handle, const char* scope, size_t expiry_time_relative_seconds, const char* key_name) +static char* my_IoTHubClient_Auth_Get_SasToken(IOTHUB_AUTHORIZATION_HANDLE handle, const char* scope, uint64_t expiry_time_relative_seconds, const char* key_name) { (void)handle; (void)scope; @@ -475,6 +476,9 @@ TEST_SUITE_INITIALIZE(TestClassInitialize) umock_c_init(on_umock_c_error); + int result = umocktypes_stdint_register_types(); + ASSERT_ARE_EQUAL(int, 0, result, "umocktypes_stdint_register_types"); + umocktypes_charptr_register_types(); REGISTER_TYPE(HTTPAPI_RESULT, HTTPAPI_RESULT); diff --git a/iothub_client/tests/iothubtransport_amqp_cbs_auth_ut/iothubtransport_amqp_cbs_auth_ut.c b/iothub_client/tests/iothubtransport_amqp_cbs_auth_ut/iothubtransport_amqp_cbs_auth_ut.c index 1da3e7e303..0ca5a92b86 100644 --- a/iothub_client/tests/iothubtransport_amqp_cbs_auth_ut/iothubtransport_amqp_cbs_auth_ut.c +++ b/iothub_client/tests/iothubtransport_amqp_cbs_auth_ut/iothubtransport_amqp_cbs_auth_ut.c @@ -159,7 +159,7 @@ static int TEST_cbs_put_token_async(CBS_HANDLE cbs, const char* type, const char return TEST_cbs_put_token_async_return; } -static char* TEST_IoTHubClient_Auth_Get_SasToken(IOTHUB_AUTHORIZATION_HANDLE handle, const char* scope, size_t expiry_time_relative_seconds, const char* keyname) +static char* TEST_IoTHubClient_Auth_Get_SasToken(IOTHUB_AUTHORIZATION_HANDLE handle, const char* scope, uint64_t expiry_time_relative_seconds, const char* keyname) { (void)handle; (void)scope; @@ -280,8 +280,8 @@ typedef struct AUTHENTICATION_DO_WORK_EXPECTED_STATE_TAG bool is_sas_token_refresh_in_progress; time_t current_sas_token_put_time; STRING_HANDLE sas_token_to_use; - size_t sastoken_expiration_time; - size_t sas_token_refresh_time_in_seconds; + uint64_t sastoken_expiration_time; + uint64_t sas_token_refresh_time_in_seconds; } AUTHENTICATION_DO_WORK_EXPECTED_STATE; static AUTHENTICATION_DO_WORK_EXPECTED_STATE g_auth_do_work_exp_state; @@ -952,7 +952,7 @@ TEST_FUNCTION(authentication_do_work_AUTHENTICATION_STATE_STARTING_success) AUTHENTICATION_DO_WORK_EXPECTED_STATE *exp_state = get_do_work_expected_state_struct(); exp_state->current_state = AUTHENTICATION_STATE_STARTING; //exp_state - exp_state->sastoken_expiration_time = (size_t)(difftime(current_time, (time_t)0) + DEFAULT_SAS_TOKEN_LIFETIME_SECS); + exp_state->sastoken_expiration_time = (uint64_t)(difftime(current_time, (time_t)0) + DEFAULT_SAS_TOKEN_LIFETIME_SECS); umock_c_reset_all_calls(); set_expected_calls_for_authentication_do_work(config, handle, current_time, exp_state, IOTHUB_CREDENTIAL_TYPE_DEVICE_KEY); @@ -1049,7 +1049,7 @@ TEST_FUNCTION(authentication_do_work_DEVICE_KEYS_primary_key_only_fallback) AUTHENTICATION_DO_WORK_EXPECTED_STATE *exp_state = get_do_work_expected_state_struct(); exp_state->current_state = AUTHENTICATION_STATE_STARTING; exp_state->sas_token_to_use = TEST_PRIMARY_DEVICE_KEY_STRING_HANDLE; - exp_state->sastoken_expiration_time = (size_t)(difftime(current_time, (time_t)0) + DEFAULT_SAS_TOKEN_LIFETIME_SECS); + exp_state->sastoken_expiration_time = (uint64_t)(difftime(current_time, (time_t)0) + DEFAULT_SAS_TOKEN_LIFETIME_SECS); crank_authentication_do_work(config, handle, current_time, exp_state, IOTHUB_CREDENTIAL_TYPE_DEVICE_KEY); ASSERT_ARE_EQUAL(char_ptr, umock_c_get_expected_calls(), umock_c_get_actual_calls()); @@ -1285,7 +1285,7 @@ TEST_FUNCTION(authentication_do_work_DEVICE_KEYS_sas_token_refresh_check) AUTHENTICATION_DO_WORK_EXPECTED_STATE *exp_state = get_do_work_expected_state_struct(); exp_state->current_state = AUTHENTICATION_STATE_STARTING; exp_state->sas_token_to_use = TEST_PRIMARY_DEVICE_KEY_STRING_HANDLE; - exp_state->sastoken_expiration_time = (size_t)(difftime(current_time, (time_t)0) + DEFAULT_SAS_TOKEN_LIFETIME_SECS); + exp_state->sastoken_expiration_time = (uint64_t)(difftime(current_time, (time_t)0) + DEFAULT_SAS_TOKEN_LIFETIME_SECS); crank_authentication_do_work(config, handle, current_time, exp_state, IOTHUB_CREDENTIAL_TYPE_DEVICE_KEY); saved_cbs_put_token_on_operation_complete(saved_cbs_put_token_context, CBS_OPERATION_RESULT_OK, 0, "all good"); @@ -1324,7 +1324,7 @@ TEST_FUNCTION(authentication_do_work_DEVICE_AUTH_sas_token_refresh_check) AUTHENTICATION_DO_WORK_EXPECTED_STATE *exp_state = get_do_work_expected_state_struct(); exp_state->current_state = AUTHENTICATION_STATE_STARTING; exp_state->sas_token_to_use = TEST_PRIMARY_DEVICE_KEY_STRING_HANDLE; - exp_state->sastoken_expiration_time = (size_t)(difftime(current_time, (time_t)0) + DEFAULT_SAS_TOKEN_LIFETIME_SECS); + exp_state->sastoken_expiration_time = (uint64_t)(difftime(current_time, (time_t)0) + DEFAULT_SAS_TOKEN_LIFETIME_SECS); crank_authentication_do_work(config, handle, current_time, exp_state, IOTHUB_CREDENTIAL_TYPE_DEVICE_AUTH); saved_cbs_put_token_on_operation_complete(saved_cbs_put_token_context, CBS_OPERATION_RESULT_OK, 0, "all good"); @@ -1367,7 +1367,7 @@ TEST_FUNCTION(authentication_do_work_DEVICE_KEYS_sas_token_refresh) AUTHENTICATION_DO_WORK_EXPECTED_STATE *exp_state = get_do_work_expected_state_struct(); exp_state->current_state = AUTHENTICATION_STATE_STARTING; exp_state->sas_token_to_use = TEST_PRIMARY_DEVICE_KEY_STRING_HANDLE; - exp_state->sastoken_expiration_time = (size_t)(difftime(current_time, (time_t)0) + DEFAULT_SAS_TOKEN_LIFETIME_SECS); + exp_state->sastoken_expiration_time = (uint64_t)(difftime(current_time, (time_t)0) + DEFAULT_SAS_TOKEN_LIFETIME_SECS); crank_authentication_do_work(config, handle, current_time, exp_state, IOTHUB_CREDENTIAL_TYPE_DEVICE_KEY); saved_cbs_put_token_on_operation_complete(saved_cbs_put_token_context, CBS_OPERATION_RESULT_OK, 0, "all good"); @@ -1375,7 +1375,7 @@ TEST_FUNCTION(authentication_do_work_DEVICE_KEYS_sas_token_refresh) exp_state->current_state = AUTHENTICATION_STATE_STARTED; exp_state->current_sas_token_put_time = current_time; exp_state->sas_token_refresh_time_in_seconds = 10; - exp_state->sastoken_expiration_time = (size_t)(difftime(next_time, (time_t)0) + 123); + exp_state->sastoken_expiration_time = (uint64_t)(difftime(next_time, (time_t)0) + 123); umock_c_reset_all_calls(); set_expected_calls_for_authentication_do_work(config, handle, next_time, exp_state, IOTHUB_CREDENTIAL_TYPE_DEVICE_KEY); @@ -1440,7 +1440,7 @@ TEST_FUNCTION(authentication_do_work_first_auth_times_out) AUTHENTICATION_CONFIG* config = get_auth_config(USE_DEVICE_SAS_TOKEN); AUTHENTICATION_HANDLE handle = create_and_start_authentication(config, false); - size_t timeout_secs = 10; + uint64_t timeout_secs = 10; int result = authentication_set_option(handle, AUTHENTICATION_OPTION_CBS_REQUEST_TIMEOUT_SECS, &timeout_secs); ASSERT_ARE_EQUAL(int, 0, result); diff --git a/iothub_client/tests/iothubtransport_mqtt_common_ut/iothubtransport_mqtt_common_ut.c b/iothub_client/tests/iothubtransport_mqtt_common_ut/iothubtransport_mqtt_common_ut.c index c39b02b8f0..1f84fbb1a0 100644 --- a/iothub_client/tests/iothubtransport_mqtt_common_ut/iothubtransport_mqtt_common_ut.c +++ b/iothub_client/tests/iothubtransport_mqtt_common_ut/iothubtransport_mqtt_common_ut.c @@ -355,7 +355,7 @@ extern "C" } #endif -static char* my_IoTHubClient_Auth_Get_SasToken(IOTHUB_AUTHORIZATION_HANDLE handle, const char* scope, size_t expiry_time_relative_seconds, const char* keyname) +static char* my_IoTHubClient_Auth_Get_SasToken(IOTHUB_AUTHORIZATION_HANDLE handle, const char* scope, uint64_t expiry_time_relative_seconds, const char* keyname) { (void)handle; (void)scope; @@ -566,7 +566,7 @@ static void my_STRING_TOKENIZER_destroy(STRING_TOKENIZER_HANDLE handle) my_gballoc_free(handle); } -static STRING_HANDLE my_SASToken_Create(STRING_HANDLE key, STRING_HANDLE scope, STRING_HANDLE keyName, size_t expiry) +static STRING_HANDLE my_SASToken_Create(STRING_HANDLE key, STRING_HANDLE scope, STRING_HANDLE keyName, uint64_t expiry) { (void)key; (void)scope; diff --git a/iothub_client/tests/iothubtransportamqp_methods_ut/real_crt_abstractions.c b/iothub_client/tests/iothubtransportamqp_methods_ut/real_crt_abstractions.c index 1f77884a42..28928d1473 100644 --- a/iothub_client/tests/iothubtransportamqp_methods_ut/real_crt_abstractions.c +++ b/iothub_client/tests/iothubtransportamqp_methods_ut/real_crt_abstractions.c @@ -4,6 +4,7 @@ #define mallocAndStrcpy_s real_mallocAndStrcpy_s #define unsignedIntToString real_unsignedIntToString #define size_tToString real_size_tToString +#define uint64_tToString real_uint64_tToString #define GBALLOC_H diff --git a/iothub_service_client/tests/iothub_msging_ll_ut/iothub_messaging_ll_ut.c b/iothub_service_client/tests/iothub_msging_ll_ut/iothub_messaging_ll_ut.c index 97f881afeb..c8c8053860 100644 --- a/iothub_service_client/tests/iothub_msging_ll_ut/iothub_messaging_ll_ut.c +++ b/iothub_service_client/tests/iothub_msging_ll_ut/iothub_messaging_ll_ut.c @@ -245,7 +245,7 @@ static int my_message_get_body_amqp_data_in_place(MESSAGE_HANDLE message, size_t return 0; } -static STRING_HANDLE my_SASToken_Create(STRING_HANDLE key, STRING_HANDLE scope, STRING_HANDLE keyName, size_t expiry) +static STRING_HANDLE my_SASToken_Create(STRING_HANDLE key, STRING_HANDLE scope, STRING_HANDLE keyName, uint64_t expiry) { (void)key; (void)scope; diff --git a/provisioning_client/deps/utpm b/provisioning_client/deps/utpm index 97a1df8eed..add08a8e72 160000 --- a/provisioning_client/deps/utpm +++ b/provisioning_client/deps/utpm @@ -1 +1 @@ -Subproject commit 97a1df8eedd86780493d3ecc3f8a231c8b939dac +Subproject commit add08a8e72ac3a76c26c9c49ca6e46194de67bb9 diff --git a/provisioning_client/tests/device_auth_emulator_ut/device_auth_emulator_ut.c b/provisioning_client/tests/device_auth_emulator_ut/device_auth_emulator_ut.c index c10310e4dc..3fae5f13bb 100644 --- a/provisioning_client/tests/device_auth_emulator_ut/device_auth_emulator_ut.c +++ b/provisioning_client/tests/device_auth_emulator_ut/device_auth_emulator_ut.c @@ -178,7 +178,7 @@ static void my_STRING_delete(STRING_HANDLE handle) my_gballoc_free(handle); } -static STRING_HANDLE my_SASToken_Create(STRING_HANDLE key, STRING_HANDLE scope, STRING_HANDLE keyName, size_t expiry) +static STRING_HANDLE my_SASToken_Create(STRING_HANDLE key, STRING_HANDLE scope, STRING_HANDLE keyName, uint64_t expiry) { (void)key, (void)scope, (void)keyName, (void)expiry; return (STRING_HANDLE)my_gballoc_malloc(1); diff --git a/provisioning_client/tests/prov_device_client_ll_ut/prov_device_client_ll_ut.c b/provisioning_client/tests/prov_device_client_ll_ut/prov_device_client_ll_ut.c index aae3962e64..5abf21381e 100644 --- a/provisioning_client/tests/prov_device_client_ll_ut/prov_device_client_ll_ut.c +++ b/provisioning_client/tests/prov_device_client_ll_ut/prov_device_client_ll_ut.c @@ -373,7 +373,7 @@ static STRING_HANDLE my_STRING_construct(const char* psz) return (STRING_HANDLE)my_gballoc_malloc(1); } -static STRING_HANDLE my_SASToken_Create(STRING_HANDLE key, STRING_HANDLE scope, STRING_HANDLE keyName, size_t expiry) +static STRING_HANDLE my_SASToken_Create(STRING_HANDLE key, STRING_HANDLE scope, STRING_HANDLE keyName, uint64_t expiry) { (void)key; (void)scope; diff --git a/provisioning_service_client/tests/provisioning_service_client_ut/provisioning_service_client_ut.c b/provisioning_service_client/tests/provisioning_service_client_ut/provisioning_service_client_ut.c index 74e380aaa9..23c5a013f1 100644 --- a/provisioning_service_client/tests/provisioning_service_client_ut/provisioning_service_client_ut.c +++ b/provisioning_service_client/tests/provisioning_service_client_ut/provisioning_service_client_ut.c @@ -24,6 +24,7 @@ static void real_free(void* ptr) #include "umock_c/umock_c.h" #include "umock_c/umocktypes_bool.h" #include "umock_c/umock_c_negative_tests.h" +#include "umock_c/umocktypes_stdint.h" #define ENABLE_MOCKS #include "azure_c_shared_utility/gballoc.h" @@ -300,7 +301,7 @@ static void my_STRING_delete(STRING_HANDLE handle) real_free(handle); } -static STRING_HANDLE my_SASToken_CreateString(const char* key, const char* scope, const char* keyName, size_t expiry) { +static STRING_HANDLE my_SASToken_CreateString(const char* key, const char* scope, const char* keyName, uint64_t expiry) { (void)key; (void)scope; (void)keyName; @@ -692,6 +693,9 @@ TEST_SUITE_INITIALIZE(TestClassInitialize) umock_c_init(on_umock_c_error); umocktypes_bool_register_types(); + int result = umocktypes_stdint_register_types(); + ASSERT_ARE_EQUAL(int, 0, result, "umocktypes_stdint_register_types"); + register_global_mock_alias_types(); register_global_mock_hooks(); register_global_mock_returns(); diff --git a/serializer/tests/serializer_dt_ut/real_crt_abstractions.h b/serializer/tests/serializer_dt_ut/real_crt_abstractions.h index 9c49fc8746..a8d3a553ba 100644 --- a/serializer/tests/serializer_dt_ut/real_crt_abstractions.h +++ b/serializer/tests/serializer_dt_ut/real_crt_abstractions.h @@ -7,6 +7,7 @@ #define mallocAndStrcpy_s real_mallocAndStrcpy_s #define unsignedIntToString real_unsignedIntToString #define size_tToString real_size_tToString +#define uint64_tToString uint64_size_tToString #undef CRT_ABSTRACTIONS_H #include "azure_c_shared_utility/crt_abstractions.h" @@ -15,6 +16,7 @@ #undef mallocAndStrcpy_s #undef unsignedIntToString #undef size_tToString +#undef uint64_tToString #endif #undef CRT_ABSTRACTIONS_H diff --git a/uamqp b/uamqp index 5f4665cfb6..b996050ef1 160000 --- a/uamqp +++ b/uamqp @@ -1 +1 @@ -Subproject commit 5f4665cfb6569f175f18b7adfc0a5f8ccf35cdc8 +Subproject commit b996050ef11a6ac2f01b6343f81c360729504173 diff --git a/umqtt b/umqtt index 254261e02d..dc337c4b81 160000 --- a/umqtt +++ b/umqtt @@ -1 +1 @@ -Subproject commit 254261e02d36275a955df0cb7d213c0a1813f8b5 +Subproject commit dc337c4b81d1dbac6dd4e6964d9534427b8fa796