@@ -26,6 +26,7 @@ extern "C" {
2626#include " attribute_store_defined_attribute_types.h"
2727#include " zwave_command_class_association_types.h"
2828#include " zap-types.h"
29+ #include " zwave_command_class_version_types.h"
2930
3031// ZPC Components
3132#include " zpc_attribute_store_type_registration.h"
@@ -48,6 +49,9 @@ extern "C" {
4849// Attribute macro, shortening those long defines for attribute types:
4950#define ATTRIBUTE (type ) ATTRIBUTE_COMMAND_CLASS_USER_CREDENTIAL_##type
5051
52+ // Useful definitions
53+ attribute_store::attribute cpp_endpoint_node;
54+
5155// Header declarations
5256void mock_deletion_user_mqtt_topic (user_credential_user_unique_id_t user_id);
5357void mock_deletion_cred_mqtt_topic (user_credential_user_unique_id_t user_id,
@@ -86,6 +90,7 @@ uic_mqtt_dotdot_user_credential_credential_learn_stop_callback_t credential_lear
8690uic_mqtt_dotdot_user_credential_credential_association_callback_t credential_association_command = NULL ;
8791uic_mqtt_dotdot_user_credential_get_user_checksum_callback_t get_user_checksum_command = NULL ;
8892uic_mqtt_dotdot_user_credential_get_credential_checksum_callback_t get_credential_checksum_command = NULL ;
93+ uic_mqtt_dotdot_user_credential_get_all_users_checksum_callback_t get_all_users_checksum_command = NULL ;
8994// clang-format on
9095
9196// Stub functions for intercepting callback registration.
@@ -210,6 +215,15 @@ void uic_mqtt_dotdot_user_credential_get_credential_checksum_callback_set_stub(
210215 get_credential_checksum_command = callback;
211216}
212217
218+ void uic_mqtt_dotdot_user_credential_get_all_users_checksum_callback_set_stub (
219+ const uic_mqtt_dotdot_user_credential_get_all_users_checksum_callback_t
220+ callback,
221+ int cmock_num_calls)
222+ {
223+ get_all_users_checksum_command = callback;
224+ }
225+
226+
213227// / Setup the test suite (called once before all test_xxx functions are called)
214228void suiteSetUp ()
215229{
@@ -293,6 +307,7 @@ void setUp()
293307 uic_mqtt_dotdot_user_credential_get_user_checksum_callback_set_Stub (&uic_mqtt_dotdot_user_credential_get_user_checksum_callback_set_stub);
294308 // Credential checksum
295309 uic_mqtt_dotdot_user_credential_get_credential_checksum_callback_set_Stub (&uic_mqtt_dotdot_user_credential_get_credential_checksum_callback_set_stub);
310+ uic_mqtt_dotdot_user_credential_get_all_users_checksum_callback_set_Stub (&uic_mqtt_dotdot_user_credential_get_all_users_checksum_callback_set_stub);
296311 // clang-format on
297312
298313 // Run the component init
@@ -303,6 +318,17 @@ void setUp()
303318 setup_user_capabilities ();
304319 // Need to call this after init() to have the mqtt callback initialized
305320 setup_cred_capabilities ();
321+
322+ // Setup helper
323+ cpp_endpoint_node = attribute_store::attribute (endpoint_id_node);
324+ }
325+
326+ void set_version (zwave_cc_version_t version)
327+ {
328+ // Set the version
329+ cpp_endpoint_node
330+ .emplace_node (ATTRIBUTE (VERSION))
331+ .set_reported (version);
306332}
307333
308334// ///////////////////////////////////////////////////////////////////////
@@ -2352,6 +2378,57 @@ void test_user_credential_cluster_test_credential_checksum_happy_case()
23522378 " Checksum node reported value should be not defined" );
23532379}
23542380
2381+
2382+ void test_user_credential_cluster_test_all_users_checksum_happy_case ()
2383+ {
2384+ set_version (1 );
2385+
2386+ // Command not supported yet (default user capabilities SUPPORT_ALL_USERS_CHECKSUM set to 0)
2387+ TEST_ASSERT_EQUAL_MESSAGE (
2388+ SL_STATUS_FAIL,
2389+ get_all_users_checksum_command (supporting_node_unid,
2390+ endpoint_id,
2391+ UIC_MQTT_DOTDOT_CALLBACK_TYPE_SUPPORT_CHECK),
2392+ " Not supported yet since we are missing the capability" );
2393+
2394+ cpp_endpoint_node.child_by_type (ATTRIBUTE (SUPPORT_ALL_USERS_CHECKSUM))
2395+ .set_reported <uint8_t >(1 );
2396+
2397+ TEST_ASSERT_EQUAL_MESSAGE (
2398+ SL_STATUS_OK,
2399+ get_all_users_checksum_command (supporting_node_unid,
2400+ endpoint_id,
2401+ UIC_MQTT_DOTDOT_CALLBACK_TYPE_NORMAL),
2402+ " Should be able to setup attribute store for get_all_users_checksum" );
2403+
2404+ auto checksum_node
2405+ = cpp_endpoint_node.child_by_type (ATTRIBUTE (ALL_USERS_CHECKSUM));
2406+
2407+ TEST_ASSERT_TRUE_MESSAGE (
2408+ checksum_node.is_valid (),
2409+ " All users checksum node should exists" );
2410+
2411+ checksum_node.set_desired <uint16_t >(1312 );
2412+ checksum_node.set_reported <uint16_t >(12 );
2413+
2414+ // Try a second time to see if we clear the attributes
2415+ TEST_ASSERT_EQUAL_MESSAGE (
2416+ SL_STATUS_OK,
2417+ get_all_users_checksum_command (supporting_node_unid,
2418+ endpoint_id,
2419+ UIC_MQTT_DOTDOT_CALLBACK_TYPE_NORMAL),
2420+ " Should be able to setup attribute store for get_all_users_checksum" );
2421+
2422+ TEST_ASSERT_FALSE_MESSAGE (
2423+ checksum_node.desired_exists (),
2424+ " Checksum node desired value should NOT exists" );
2425+
2426+ TEST_ASSERT_FALSE_MESSAGE (
2427+ checksum_node.reported_exists (),
2428+ " Checksum node reported value should NOT exists" );
2429+ }
2430+
2431+
23552432// /////////////////////////////////////////////////
23562433// Support tests
23572434// /////////////////////////////////////////////////
0 commit comments