From cb8f7d8cd393947878508f74f4662ce912918af9 Mon Sep 17 00:00:00 2001 From: "Josh V [Apple]" Date: Fri, 4 Feb 2022 13:50:39 -0800 Subject: [PATCH] Separate manual tests from CI tests (#14672) * Add Manual Test category. * Generated Code. --- .../chip-tool/templates/tests-commands.zapt | 17 + examples/chip-tool/templates/tests.js | 37 +- .../chip-tool/zap-generated/test/Commands.h | 2312 +++++++++-------- 3 files changed, 1204 insertions(+), 1162 deletions(-) diff --git a/examples/chip-tool/templates/tests-commands.zapt b/examples/chip-tool/templates/tests-commands.zapt index f8df5cc8f75c6c..2de258f9c4b42e 100644 --- a/examples/chip-tool/templates/tests-commands.zapt +++ b/examples/chip-tool/templates/tests-commands.zapt @@ -21,7 +21,20 @@ public: } }; +class ManualTestList : public Command +{ +public: + ManualTestList() : Command("list-manual") {}; + CHIP_ERROR Run() override + { + {{#chip_tests (getManualTests)}}printf("{{filename}}\n");{{/chip_tests}} + + return CHIP_NO_ERROR; + } +}; + {{>test_cluster tests=(getTests) credsIssuerConfigArg=true}} +{{>test_cluster tests=(getManualTests) credsIssuerConfigArg=true}} void registerCommandsTests(Commands & commands, CredentialIssuerCommands * credsIssuerConfig) { @@ -29,9 +42,13 @@ void registerCommandsTests(Commands & commands, CredentialIssuerCommands * creds commands_list clusterCommands = { make_unique(), + make_unique(), {{#chip_tests (getTests)}} make_unique<{{filename}}>(credsIssuerConfig), {{/chip_tests}} + {{#chip_tests (getManualTests)}} + make_unique<{{filename}}>(credsIssuerConfig), + {{/chip_tests}} }; commands.Register(clusterName, clusterCommands); diff --git a/examples/chip-tool/templates/tests.js b/examples/chip-tool/templates/tests.js index e099c988c9b84f..579fda699c8623 100644 --- a/examples/chip-tool/templates/tests.js +++ b/examples/chip-tool/templates/tests.js @@ -15,6 +15,29 @@ * limitations under the License. */ +function getManualTests() +{ + const DeviceDiscovery = [ + 'Test_TC_DD_1_5', + 'Test_TC_DD_1_6', + 'Test_TC_DD_1_7', + 'Test_TC_DD_1_8', + 'Test_TC_DD_1_9', + ]; + + const Groups = [ + 'TestGroupDemoCommand', + 'TestGroupDemoConfig', + ]; + + const tests = [ + DeviceDiscovery, // + Groups, // + + ]; + return tests.flat(1); +} + function getTests() { const BinaryInput = [ @@ -58,14 +81,6 @@ function getTests() 'Test_TC_CC_9_3', ]; - const DeviceDiscovery = [ - 'Test_TC_DD_1_5', - 'Test_TC_DD_1_6', - 'Test_TC_DD_1_7', - 'Test_TC_DD_1_8', - 'Test_TC_DD_1_9', - ]; - const DeviceManagement = [ 'Test_TC_DM_1_1', 'Test_TC_DM_3_1', @@ -256,8 +271,6 @@ function getTests() const Groups = [ 'TestGroupMessaging', 'TestGroupsCluster', - 'TestGroupDemoCommand', - 'TestGroupDemoConfig', 'TestGroupKeyManagementCluster', ]; @@ -266,7 +279,6 @@ function getTests() BooleanState, // BridgedActions, // ColorControl, // - DeviceDiscovery, // DeviceManagement, // ElectricalMeasurement, // EthernetNetworkDiagnostics, // @@ -300,4 +312,5 @@ function getTests() // // Module exports // -exports.getTests = getTests; +exports.getTests = getTests; +exports.getManualTests = getManualTests; diff --git a/zzz_generated/chip-tool/zap-generated/test/Commands.h b/zzz_generated/chip-tool/zap-generated/test/Commands.h index 582c8fbba796e6..2ce3bd59367f0a 100644 --- a/zzz_generated/chip-tool/zap-generated/test/Commands.h +++ b/zzz_generated/chip-tool/zap-generated/test/Commands.h @@ -61,11 +61,6 @@ class TestList : public Command printf("Test_TC_CC_9_1\n"); printf("Test_TC_CC_9_2\n"); printf("Test_TC_CC_9_3\n"); - printf("Test_TC_DD_1_5\n"); - printf("Test_TC_DD_1_6\n"); - printf("Test_TC_DD_1_7\n"); - printf("Test_TC_DD_1_8\n"); - printf("Test_TC_DD_1_9\n"); printf("Test_TC_DM_1_1\n"); printf("Test_TC_DM_3_1\n"); printf("Test_TC_DM_2_2\n"); @@ -180,9 +175,25 @@ class TestList : public Command printf("DL_Schedules\n"); printf("TestGroupMessaging\n"); printf("TestGroupsCluster\n"); + printf("TestGroupKeyManagementCluster\n"); + + return CHIP_NO_ERROR; + } +}; + +class ManualTestList : public Command +{ +public: + ManualTestList() : Command("list-manual"){}; + CHIP_ERROR Run() override + { + printf("Test_TC_DD_1_5\n"); + printf("Test_TC_DD_1_6\n"); + printf("Test_TC_DD_1_7\n"); + printf("Test_TC_DD_1_8\n"); + printf("Test_TC_DD_1_9\n"); printf("TestGroupDemoCommand\n"); printf("TestGroupDemoConfig\n"); - printf("TestGroupKeyManagementCluster\n"); return CHIP_NO_ERROR; } @@ -16221,406 +16232,6 @@ class Test_TC_CC_9_3 : public TestCommand void OnSuccessResponse_14() { NextTest(); } }; -class Test_TC_DD_1_5 : public TestCommand -{ -public: - Test_TC_DD_1_5(CredentialIssuerCommands * credsIssuerConfig) : TestCommand("Test_TC_DD_1_5", credsIssuerConfig), mTestIndex(0) - { - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - } - - ~Test_TC_DD_1_5() {} - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) - { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_DD_1_5\n"); - } - - if (mTestCount == mTestIndex) - { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_DD_1_5\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) - { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1\n"); - err = TestStep1_0(); - break; - } - - if (CHIP_NO_ERROR != err) - { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 1; - - chip::Optional mCluster; - chip::Optional mEndpoint; - - // - // Tests methods - // - - CHIP_ERROR TestStep1_0() - { - SetIdentity(kIdentityAlpha); - return Log("Verify that the onboarding payload for NFC tags SHALL use NDEF URI Record Type Definition as defined by NFC " - "Forum in URI Record Type Definition RTD URI"); - } -}; - -class Test_TC_DD_1_6 : public TestCommand -{ -public: - Test_TC_DD_1_6(CredentialIssuerCommands * credsIssuerConfig) : TestCommand("Test_TC_DD_1_6", credsIssuerConfig), mTestIndex(0) - { - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - } - - ~Test_TC_DD_1_6() {} - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) - { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_DD_1_6\n"); - } - - if (mTestCount == mTestIndex) - { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_DD_1_6\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) - { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1\n"); - err = TestStep1_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1 verification\n"); - err = TestStep1Verification_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2 verificaiton\n"); - err = TestStep2Verificaiton_2(); - break; - } - - if (CHIP_NO_ERROR != err) - { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 3; - - chip::Optional mCluster; - chip::Optional mEndpoint; - - // - // Tests methods - // - - CHIP_ERROR TestStep1_0() - { - SetIdentity(kIdentityAlpha); - return Log("Scan the DUTs QR code using a QR code reader"); - } - - CHIP_ERROR TestStep1Verification_1() - { - SetIdentity(kIdentityAlpha); - return Log( - "Verify the QR code gets scanned successfully and the QR code must be of sufficient size and contrast respective to " - "surface material as to be readable with standard readers such as smartphones in normal lighting conditions"); - } - - CHIP_ERROR TestStep2Verificaiton_2() - { - SetIdentity(kIdentityAlpha); - return Log("Verify QR code version is 1 or higher"); - } -}; - -class Test_TC_DD_1_7 : public TestCommand -{ -public: - Test_TC_DD_1_7(CredentialIssuerCommands * credsIssuerConfig) : TestCommand("Test_TC_DD_1_7", credsIssuerConfig), mTestIndex(0) - { - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - } - - ~Test_TC_DD_1_7() {} - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) - { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_DD_1_7\n"); - } - - if (mTestCount == mTestIndex) - { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_DD_1_7\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) - { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Precondition\n"); - err = TestPrecondition_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1\n"); - err = TestStep1_1(); - break; - } - - if (CHIP_NO_ERROR != err) - { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 2; - - chip::Optional mCluster; - chip::Optional mEndpoint; - - // - // Tests methods - // - - CHIP_ERROR TestPrecondition_0() - { - SetIdentity(kIdentityAlpha); - return Log("Verify manual pairing code is printed on the device or in additional provided materials"); - } - - CHIP_ERROR TestStep1_1() - { - SetIdentity(kIdentityAlpha); - return Log("Verify that the Manual Pairing Code should be printed using a minimum font size of 6 points typically " - "producing a typeface height of 2.1 mm"); - } -}; - -class Test_TC_DD_1_8 : public TestCommand -{ -public: - Test_TC_DD_1_8(CredentialIssuerCommands * credsIssuerConfig) : TestCommand("Test_TC_DD_1_8", credsIssuerConfig), mTestIndex(0) - { - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - } - - ~Test_TC_DD_1_8() {} - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) - { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_DD_1_8\n"); - } - - if (mTestCount == mTestIndex) - { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_DD_1_8\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) - { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1\n"); - err = TestStep1_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1 verification\n"); - err = TestStep1Verification_1(); - break; - } - - if (CHIP_NO_ERROR != err) - { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 2; - - chip::Optional mCluster; - chip::Optional mEndpoint; - - // - // Tests methods - // - - CHIP_ERROR TestStep1_0() - { - SetIdentity(kIdentityAlpha); - return Log("Scan the device QR code using DUT"); - } - - CHIP_ERROR TestStep1Verification_1() - { - SetIdentity(kIdentityAlpha); - return Log("Verify the DUT is able to scan and parse the QR code successfully to onboard the device onto the CHIP network"); - } -}; - -class Test_TC_DD_1_9 : public TestCommand -{ -public: - Test_TC_DD_1_9(CredentialIssuerCommands * credsIssuerConfig) : TestCommand("Test_TC_DD_1_9", credsIssuerConfig), mTestIndex(0) - { - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - } - - ~Test_TC_DD_1_9() {} - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) - { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_DD_1_9\n"); - } - - if (mTestCount == mTestIndex) - { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_DD_1_9\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) - { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Precondition\n"); - err = TestPrecondition_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1\n"); - err = TestStep1_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 1 verification\n"); - err = TestStep1Verification_2(); - break; - } - - if (CHIP_NO_ERROR != err) - { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 3; - - chip::Optional mCluster; - chip::Optional mEndpoint; - - // - // Tests methods - // - - CHIP_ERROR TestPrecondition_0() - { - SetIdentity(kIdentityAlpha); - return Log("Verify that the manual pairing code is printed on the device or in additional provided materials"); - } - - CHIP_ERROR TestStep1_1() - { - SetIdentity(kIdentityAlpha); - return Log("Provide the 11 digit or 21 digit pairing code from the Device in text speech or any format supported by DUT"); - } - - CHIP_ERROR TestStep1Verification_2() - { - SetIdentity(kIdentityAlpha); - return Log( - "Verify that the manual pairing code can be provided to DUT and parsed to onboard the device onto the CHIP network"); - } -}; - class Test_TC_DM_1_1 : public TestCommand { public: @@ -84833,17 +84444,17 @@ class TestGroupsCluster : public TestCommand } }; -class TestGroupDemoCommand : public TestCommand +class TestGroupKeyManagementCluster : public TestCommand { public: - TestGroupDemoCommand(CredentialIssuerCommands * credsIssuerConfig) : - TestCommand("TestGroupDemoCommand", credsIssuerConfig), mTestIndex(0) + TestGroupKeyManagementCluster(CredentialIssuerCommands * credsIssuerConfig) : + TestCommand("TestGroupKeyManagementCluster", credsIssuerConfig), mTestIndex(0) { AddArgument("cluster", &mCluster); AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); } - ~TestGroupDemoCommand() {} + ~TestGroupKeyManagementCluster() {} /////////// TestCommand Interface ///////// void NextTest() override @@ -84852,12 +84463,12 @@ class TestGroupDemoCommand : public TestCommand if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: TestGroupDemoCommand\n"); + ChipLogProgress(chipTool, " **** Test Start: TestGroupKeyManagementCluster\n"); } if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: TestGroupDemoCommand\n"); + ChipLogProgress(chipTool, " **** Test Complete: TestGroupKeyManagementCluster\n"); SetCommandExitStatus(CHIP_NO_ERROR); return; } @@ -84875,84 +84486,68 @@ class TestGroupDemoCommand : public TestCommand err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); break; case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Turn On the light to see attribute change\n"); - err = TestTurnOnTheLightToSeeAttributeChange_1(); + ChipLogProgress(chipTool, " ***** Test Step 1 : Read maxGroupsPerFabric\n"); + err = TestReadMaxGroupsPerFabric_1(); break; case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Wait 100ms\n"); - err = TestWait100ms_2(); + ChipLogProgress(chipTool, " ***** Test Step 2 : Read maxGroupKeysPerFabric\n"); + err = TestReadMaxGroupKeysPerFabric_2(); break; case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Turn Off the light to see attribute change\n"); - err = TestTurnOffTheLightToSeeAttributeChange_3(); + ChipLogProgress(chipTool, " ***** Test Step 3 : Add Group 1\n"); + err = TestAddGroup1_3(); break; case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Wait 100ms\n"); - err = TestWait100ms_4(); + ChipLogProgress(chipTool, " ***** Test Step 4 : Add Group 2\n"); + err = TestAddGroup2_4(); break; case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Turn On the light to see attribute change\n"); - err = TestTurnOnTheLightToSeeAttributeChange_5(); + ChipLogProgress(chipTool, " ***** Test Step 5 : KeySet Write 1\n"); + err = TestKeySetWrite1_5(); break; case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Wait 100ms\n"); - err = TestWait100ms_6(); + ChipLogProgress(chipTool, " ***** Test Step 6 : KeySet Write 2\n"); + err = TestKeySetWrite2_6(); break; case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Turn Off the light to see attribute change\n"); - err = TestTurnOffTheLightToSeeAttributeChange_7(); + ChipLogProgress(chipTool, " ***** Test Step 7 : KeySet Read\n"); + err = TestKeySetRead_7(); break; case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Wait 100ms\n"); - err = TestWait100ms_8(); + ChipLogProgress(chipTool, " ***** Test Step 8 : Write Group Keys\n"); + err = TestWriteGroupKeys_8(); break; case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Turn On the light to see attribute change\n"); - err = TestTurnOnTheLightToSeeAttributeChange_9(); + ChipLogProgress(chipTool, " ***** Test Step 9 : Read Group Keys\n"); + err = TestReadGroupKeys_9(); break; case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Wait 100ms\n"); - err = TestWait100ms_10(); + ChipLogProgress(chipTool, " ***** Test Step 10 : Read GroupTable\n"); + err = TestReadGroupTable_10(); break; case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Turn Off the light to see attribute change\n"); - err = TestTurnOffTheLightToSeeAttributeChange_11(); + ChipLogProgress(chipTool, " ***** Test Step 11 : KeySet Remove 1\n"); + err = TestKeySetRemove1_11(); break; case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Wait 100ms\n"); - err = TestWait100ms_12(); + ChipLogProgress(chipTool, " ***** Test Step 12 : KeySet Read (removed)\n"); + err = TestKeySetReadRemoved_12(); break; case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Turn On the light to see attribute change\n"); - err = TestTurnOnTheLightToSeeAttributeChange_13(); + ChipLogProgress(chipTool, " ***** Test Step 13 : KeySet Read (not removed)\n"); + err = TestKeySetReadNotRemoved_13(); break; case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Wait 100ms\n"); - err = TestWait100ms_14(); + ChipLogProgress(chipTool, " ***** Test Step 14 : Remove All\n"); + err = TestRemoveAll_14(); break; case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Turn Off the light to see attribute change\n"); - err = TestTurnOffTheLightToSeeAttributeChange_15(); + ChipLogProgress(chipTool, " ***** Test Step 15 : KeySet Remove 2\n"); + err = TestKeySetRemove2_15(); break; case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Wait 100ms\n"); - err = TestWait100ms_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Turn On the light to see attribute change\n"); - err = TestTurnOnTheLightToSeeAttributeChange_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Wait 100ms\n"); - err = TestWait100ms_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Turn Off the light to see attribute change\n"); - err = TestTurnOffTheLightToSeeAttributeChange_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Wait 100ms\n"); - err = TestWait100ms_20(); + ChipLogProgress(chipTool, " ***** Test Step 16 : KeySet Read (also removed)\n"); + err = TestKeySetReadAlsoRemoved_16(); break; } @@ -84965,413 +84560,659 @@ class TestGroupDemoCommand : public TestCommand private: std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 21; + const uint16_t mTestCount = 17; chip::Optional mCluster; chip::Optional mEndpoint; - // - // Tests methods - // + static void OnFailureCallback_1(void * context, CHIP_ERROR error) + { + (static_cast(context))->OnFailureResponse_1(error); + } - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() + static void OnSuccessCallback_1(void * context, uint16_t maxGroupsPerFabric) { - SetIdentity(kIdentityAlpha); - return WaitForCommissionee(); + (static_cast(context))->OnSuccessResponse_1(maxGroupsPerFabric); } - CHIP_ERROR TestTurnOnTheLightToSeeAttributeChange_1() + static void OnFailureCallback_2(void * context, CHIP_ERROR error) { - const chip::GroupId groupId = 4660; - using RequestType = chip::app::Clusters::OnOff::Commands::On::Type; + (static_cast(context))->OnFailureResponse_2(error); + } - RequestType request; + static void OnSuccessCallback_2(void * context, uint16_t maxGroupKeysPerFabric) + { + (static_cast(context))->OnSuccessResponse_2(maxGroupKeysPerFabric); + } - auto success = [](void * context, const typename RequestType::ResponseType & data) { - (static_cast(context))->OnSuccessResponse_1(); - }; + static void OnFailureCallback_8(void * context, CHIP_ERROR error) + { + (static_cast(context))->OnFailureResponse_8(error); + } - auto failure = [](void * context, CHIP_ERROR error) { - (static_cast(context))->OnFailureResponse_1(error); - }; + static void OnSuccessCallback_8(void * context) + { + (static_cast(context))->OnSuccessResponse_8(); + } - auto done = [](void * context) { (static_cast(context))->OnDoneResponse_1(); }; + static void OnFailureCallback_9(void * context, CHIP_ERROR error) + { + (static_cast(context))->OnFailureResponse_9(error); + } - ReturnErrorOnFailure( - chip::Controller::InvokeGroupCommand(mDevices[kIdentityAlpha], this, success, failure, done, groupId, request)); - return CHIP_NO_ERROR; + static void + OnSuccessCallback_9(void * context, + const chip::app::DataModel::DecodableList< + chip::app::Clusters::GroupKeyManagement::Structs::GroupKeyMapStruct::DecodableType> & groupKeyMap) + { + (static_cast(context))->OnSuccessResponse_9(groupKeyMap); } - void OnFailureResponse_1(CHIP_ERROR error) + static void OnFailureCallback_10(void * context, CHIP_ERROR error) { - chip::app::StatusIB status(error); - ThrowFailureResponse(); + (static_cast(context))->OnFailureResponse_10(error); } - void OnSuccessResponse_1() { NextTest(); } + static void + OnSuccessCallback_10(void * context, + const chip::app::DataModel::DecodableList< + chip::app::Clusters::GroupKeyManagement::Structs::GroupInfoMapStruct::DecodableType> & groupTable) + { + (static_cast(context))->OnSuccessResponse_10(groupTable); + } - void OnDoneResponse_1() { NextTest(); } + // + // Tests methods + // - CHIP_ERROR TestWait100ms_2() + CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() { SetIdentity(kIdentityAlpha); - return WaitForMs(1000); + return WaitForCommissionee(); } - CHIP_ERROR TestTurnOffTheLightToSeeAttributeChange_3() + CHIP_ERROR TestReadMaxGroupsPerFabric_1() { - const chip::GroupId groupId = 4660; - using RequestType = chip::app::Clusters::OnOff::Commands::Off::Type; - - RequestType request; - - auto success = [](void * context, const typename RequestType::ResponseType & data) { - (static_cast(context))->OnSuccessResponse_3(); - }; - - auto failure = [](void * context, CHIP_ERROR error) { - (static_cast(context))->OnFailureResponse_3(error); - }; - - auto done = [](void * context) { (static_cast(context))->OnDoneResponse_3(); }; + const chip::EndpointId endpoint = mEndpoint.HasValue() ? mEndpoint.Value() : 0; + chip::Controller::GroupKeyManagementClusterTest cluster; + cluster.Associate(mDevices[kIdentityAlpha], endpoint); ReturnErrorOnFailure( - chip::Controller::InvokeGroupCommand(mDevices[kIdentityAlpha], this, success, failure, done, groupId, request)); + cluster.ReadAttribute( + this, OnSuccessCallback_1, OnFailureCallback_1)); return CHIP_NO_ERROR; } - void OnFailureResponse_3(CHIP_ERROR error) + void OnFailureResponse_1(CHIP_ERROR error) { chip::app::StatusIB status(error); ThrowFailureResponse(); } - void OnSuccessResponse_3() { NextTest(); } - - void OnDoneResponse_3() { NextTest(); } - - CHIP_ERROR TestWait100ms_4() + void OnSuccessResponse_1(uint16_t maxGroupsPerFabric) { - SetIdentity(kIdentityAlpha); - return WaitForMs(1000); + VerifyOrReturn(CheckConstraintMinValue("maxGroupsPerFabric", maxGroupsPerFabric, 2U)); + NextTest(); } - CHIP_ERROR TestTurnOnTheLightToSeeAttributeChange_5() + CHIP_ERROR TestReadMaxGroupKeysPerFabric_2() { - const chip::GroupId groupId = 4660; - using RequestType = chip::app::Clusters::OnOff::Commands::On::Type; - - RequestType request; - - auto success = [](void * context, const typename RequestType::ResponseType & data) { - (static_cast(context))->OnSuccessResponse_5(); - }; - - auto failure = [](void * context, CHIP_ERROR error) { - (static_cast(context))->OnFailureResponse_5(error); - }; - - auto done = [](void * context) { (static_cast(context))->OnDoneResponse_5(); }; + const chip::EndpointId endpoint = mEndpoint.HasValue() ? mEndpoint.Value() : 0; + chip::Controller::GroupKeyManagementClusterTest cluster; + cluster.Associate(mDevices[kIdentityAlpha], endpoint); ReturnErrorOnFailure( - chip::Controller::InvokeGroupCommand(mDevices[kIdentityAlpha], this, success, failure, done, groupId, request)); + cluster.ReadAttribute( + this, OnSuccessCallback_2, OnFailureCallback_2)); return CHIP_NO_ERROR; } - void OnFailureResponse_5(CHIP_ERROR error) + void OnFailureResponse_2(CHIP_ERROR error) { chip::app::StatusIB status(error); ThrowFailureResponse(); } - void OnSuccessResponse_5() { NextTest(); } - - void OnDoneResponse_5() { NextTest(); } - - CHIP_ERROR TestWait100ms_6() + void OnSuccessResponse_2(uint16_t maxGroupKeysPerFabric) { - SetIdentity(kIdentityAlpha); - return WaitForMs(1000); + VerifyOrReturn(CheckValue("maxGroupKeysPerFabric", maxGroupKeysPerFabric, 2U)); + + NextTest(); } - CHIP_ERROR TestTurnOffTheLightToSeeAttributeChange_7() + CHIP_ERROR TestAddGroup1_3() { - const chip::GroupId groupId = 4660; - using RequestType = chip::app::Clusters::OnOff::Commands::Off::Type; + const chip::EndpointId endpoint = mEndpoint.HasValue() ? mEndpoint.Value() : 1; + using RequestType = chip::app::Clusters::Groups::Commands::AddGroup::Type; RequestType request; + request.groupId = 257U; + request.groupName = chip::Span("Group #1garbage: not in length on purpose", 8); auto success = [](void * context, const typename RequestType::ResponseType & data) { - (static_cast(context))->OnSuccessResponse_7(); + (static_cast(context))->OnSuccessResponse_3(data.status, data.groupId); }; auto failure = [](void * context, CHIP_ERROR error) { - (static_cast(context))->OnFailureResponse_7(error); + (static_cast(context))->OnFailureResponse_3(error); }; - auto done = [](void * context) { (static_cast(context))->OnDoneResponse_7(); }; - - ReturnErrorOnFailure( - chip::Controller::InvokeGroupCommand(mDevices[kIdentityAlpha], this, success, failure, done, groupId, request)); + ReturnErrorOnFailure(chip::Controller::InvokeCommand(mDevices[kIdentityAlpha], this, success, failure, endpoint, request)); return CHIP_NO_ERROR; } - void OnFailureResponse_7(CHIP_ERROR error) + void OnFailureResponse_3(CHIP_ERROR error) { chip::app::StatusIB status(error); ThrowFailureResponse(); } - void OnSuccessResponse_7() { NextTest(); } + void OnSuccessResponse_3(uint8_t status, uint16_t groupId) + { + VerifyOrReturn(CheckValue("status", status, 0)); - void OnDoneResponse_7() { NextTest(); } + VerifyOrReturn(CheckValue("groupId", groupId, 257U)); - CHIP_ERROR TestWait100ms_8() - { - SetIdentity(kIdentityAlpha); - return WaitForMs(1000); + NextTest(); } - CHIP_ERROR TestTurnOnTheLightToSeeAttributeChange_9() + CHIP_ERROR TestAddGroup2_4() { - const chip::GroupId groupId = 4660; - using RequestType = chip::app::Clusters::OnOff::Commands::On::Type; + const chip::EndpointId endpoint = mEndpoint.HasValue() ? mEndpoint.Value() : 1; + using RequestType = chip::app::Clusters::Groups::Commands::AddGroup::Type; RequestType request; + request.groupId = 258U; + request.groupName = chip::Span("Group #2garbage: not in length on purpose", 8); auto success = [](void * context, const typename RequestType::ResponseType & data) { - (static_cast(context))->OnSuccessResponse_9(); + (static_cast(context))->OnSuccessResponse_4(data.status, data.groupId); }; auto failure = [](void * context, CHIP_ERROR error) { - (static_cast(context))->OnFailureResponse_9(error); + (static_cast(context))->OnFailureResponse_4(error); }; - auto done = [](void * context) { (static_cast(context))->OnDoneResponse_9(); }; - - ReturnErrorOnFailure( - chip::Controller::InvokeGroupCommand(mDevices[kIdentityAlpha], this, success, failure, done, groupId, request)); + ReturnErrorOnFailure(chip::Controller::InvokeCommand(mDevices[kIdentityAlpha], this, success, failure, endpoint, request)); return CHIP_NO_ERROR; } - void OnFailureResponse_9(CHIP_ERROR error) + void OnFailureResponse_4(CHIP_ERROR error) { chip::app::StatusIB status(error); ThrowFailureResponse(); } - void OnSuccessResponse_9() { NextTest(); } + void OnSuccessResponse_4(uint8_t status, uint16_t groupId) + { + VerifyOrReturn(CheckValue("status", status, 0)); - void OnDoneResponse_9() { NextTest(); } + VerifyOrReturn(CheckValue("groupId", groupId, 258U)); - CHIP_ERROR TestWait100ms_10() - { - SetIdentity(kIdentityAlpha); - return WaitForMs(1000); + NextTest(); } - CHIP_ERROR TestTurnOffTheLightToSeeAttributeChange_11() + CHIP_ERROR TestKeySetWrite1_5() { - const chip::GroupId groupId = 4660; - using RequestType = chip::app::Clusters::OnOff::Commands::Off::Type; + const chip::EndpointId endpoint = mEndpoint.HasValue() ? mEndpoint.Value() : 0; + using RequestType = chip::app::Clusters::GroupKeyManagement::Commands::KeySetWrite::Type; RequestType request; + request.groupKeySet.groupKeySetID = 417U; + request.groupKeySet.groupKeySecurityPolicy = + static_cast(0); + request.groupKeySet.epochKey0.SetNonNull(); + request.groupKeySet.epochKey0.Value() = + chip::ByteSpan(chip::Uint8::from_const_char( + "\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xafgarbage: not in length on purpose"), + 16); + request.groupKeySet.epochStartTime0.SetNonNull(); + request.groupKeySet.epochStartTime0.Value() = 1110000ULL; + request.groupKeySet.epochKey1.SetNonNull(); + request.groupKeySet.epochKey1.Value() = + chip::ByteSpan(chip::Uint8::from_const_char( + "\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbfgarbage: not in length on purpose"), + 16); + request.groupKeySet.epochStartTime1.SetNonNull(); + request.groupKeySet.epochStartTime1.Value() = 1110001ULL; + request.groupKeySet.epochKey2.SetNonNull(); + request.groupKeySet.epochKey2.Value() = + chip::ByteSpan(chip::Uint8::from_const_char( + "\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcfgarbage: not in length on purpose"), + 16); + request.groupKeySet.epochStartTime2.SetNonNull(); + request.groupKeySet.epochStartTime2.Value() = 1110002ULL; + auto success = [](void * context, const typename RequestType::ResponseType & data) { - (static_cast(context))->OnSuccessResponse_11(); + (static_cast(context))->OnSuccessResponse_5(); }; auto failure = [](void * context, CHIP_ERROR error) { - (static_cast(context))->OnFailureResponse_11(error); + (static_cast(context))->OnFailureResponse_5(error); }; - auto done = [](void * context) { (static_cast(context))->OnDoneResponse_11(); }; - - ReturnErrorOnFailure( - chip::Controller::InvokeGroupCommand(mDevices[kIdentityAlpha], this, success, failure, done, groupId, request)); + ReturnErrorOnFailure(chip::Controller::InvokeCommand(mDevices[kIdentityAlpha], this, success, failure, endpoint, request)); return CHIP_NO_ERROR; } - void OnFailureResponse_11(CHIP_ERROR error) + void OnFailureResponse_5(CHIP_ERROR error) { chip::app::StatusIB status(error); ThrowFailureResponse(); } - void OnSuccessResponse_11() { NextTest(); } - - void OnDoneResponse_11() { NextTest(); } - - CHIP_ERROR TestWait100ms_12() - { - SetIdentity(kIdentityAlpha); - return WaitForMs(1000); - } + void OnSuccessResponse_5() { NextTest(); } - CHIP_ERROR TestTurnOnTheLightToSeeAttributeChange_13() + CHIP_ERROR TestKeySetWrite2_6() { - const chip::GroupId groupId = 4660; - using RequestType = chip::app::Clusters::OnOff::Commands::On::Type; + const chip::EndpointId endpoint = mEndpoint.HasValue() ? mEndpoint.Value() : 0; + using RequestType = chip::app::Clusters::GroupKeyManagement::Commands::KeySetWrite::Type; RequestType request; + request.groupKeySet.groupKeySetID = 418U; + request.groupKeySet.groupKeySecurityPolicy = + static_cast(1); + request.groupKeySet.epochKey0.SetNonNull(); + request.groupKeySet.epochKey0.Value() = + chip::ByteSpan(chip::Uint8::from_const_char( + "\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdfgarbage: not in length on purpose"), + 16); + request.groupKeySet.epochStartTime0.SetNonNull(); + request.groupKeySet.epochStartTime0.Value() = 2110000ULL; + request.groupKeySet.epochKey1.SetNonNull(); + request.groupKeySet.epochKey1.Value() = + chip::ByteSpan(chip::Uint8::from_const_char( + "\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xefgarbage: not in length on purpose"), + 16); + request.groupKeySet.epochStartTime1.SetNonNull(); + request.groupKeySet.epochStartTime1.Value() = 2110001ULL; + request.groupKeySet.epochKey2.SetNonNull(); + request.groupKeySet.epochKey2.Value() = + chip::ByteSpan(chip::Uint8::from_const_char( + "\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xffgarbage: not in length on purpose"), + 16); + request.groupKeySet.epochStartTime2.SetNonNull(); + request.groupKeySet.epochStartTime2.Value() = 2110002ULL; + auto success = [](void * context, const typename RequestType::ResponseType & data) { - (static_cast(context))->OnSuccessResponse_13(); + (static_cast(context))->OnSuccessResponse_6(); }; auto failure = [](void * context, CHIP_ERROR error) { - (static_cast(context))->OnFailureResponse_13(error); + (static_cast(context))->OnFailureResponse_6(error); }; - auto done = [](void * context) { (static_cast(context))->OnDoneResponse_13(); }; - - ReturnErrorOnFailure( - chip::Controller::InvokeGroupCommand(mDevices[kIdentityAlpha], this, success, failure, done, groupId, request)); + ReturnErrorOnFailure(chip::Controller::InvokeCommand(mDevices[kIdentityAlpha], this, success, failure, endpoint, request)); return CHIP_NO_ERROR; } - void OnFailureResponse_13(CHIP_ERROR error) + void OnFailureResponse_6(CHIP_ERROR error) { chip::app::StatusIB status(error); ThrowFailureResponse(); } - void OnSuccessResponse_13() { NextTest(); } - - void OnDoneResponse_13() { NextTest(); } - - CHIP_ERROR TestWait100ms_14() - { - SetIdentity(kIdentityAlpha); - return WaitForMs(1000); - } + void OnSuccessResponse_6() { NextTest(); } - CHIP_ERROR TestTurnOffTheLightToSeeAttributeChange_15() + CHIP_ERROR TestKeySetRead_7() { - const chip::GroupId groupId = 4660; - using RequestType = chip::app::Clusters::OnOff::Commands::Off::Type; + const chip::EndpointId endpoint = mEndpoint.HasValue() ? mEndpoint.Value() : 0; + using RequestType = chip::app::Clusters::GroupKeyManagement::Commands::KeySetRead::Type; RequestType request; + request.groupKeySetID = 417U; auto success = [](void * context, const typename RequestType::ResponseType & data) { - (static_cast(context))->OnSuccessResponse_15(); + (static_cast(context))->OnSuccessResponse_7(data.groupKeySet); }; auto failure = [](void * context, CHIP_ERROR error) { - (static_cast(context))->OnFailureResponse_15(error); + (static_cast(context))->OnFailureResponse_7(error); }; - auto done = [](void * context) { (static_cast(context))->OnDoneResponse_15(); }; - - ReturnErrorOnFailure( - chip::Controller::InvokeGroupCommand(mDevices[kIdentityAlpha], this, success, failure, done, groupId, request)); + ReturnErrorOnFailure(chip::Controller::InvokeCommand(mDevices[kIdentityAlpha], this, success, failure, endpoint, request)); return CHIP_NO_ERROR; } - void OnFailureResponse_15(CHIP_ERROR error) + void OnFailureResponse_7(CHIP_ERROR error) { chip::app::StatusIB status(error); ThrowFailureResponse(); } - void OnSuccessResponse_15() { NextTest(); } - - void OnDoneResponse_15() { NextTest(); } - - CHIP_ERROR TestWait100ms_16() + void OnSuccessResponse_7(const chip::app::Clusters::GroupKeyManagement::Structs::GroupKeySetStruct::DecodableType & groupKeySet) { - SetIdentity(kIdentityAlpha); - return WaitForMs(1000); + VerifyOrReturn(CheckValue("groupKeySet.groupKeySetID", groupKeySet.groupKeySetID, 417U)); + VerifyOrReturn(CheckValue("groupKeySet.groupKeySecurityPolicy", groupKeySet.groupKeySecurityPolicy, 0)); + VerifyOrReturn(CheckValueNull("groupKeySet.epochKey0", groupKeySet.epochKey0)); + VerifyOrReturn(CheckValueNonNull("groupKeySet.epochStartTime0", groupKeySet.epochStartTime0)); + VerifyOrReturn(CheckValue("groupKeySet.epochStartTime0.Value()", groupKeySet.epochStartTime0.Value(), 1110000ULL)); + VerifyOrReturn(CheckValueNull("groupKeySet.epochKey1", groupKeySet.epochKey1)); + VerifyOrReturn(CheckValueNonNull("groupKeySet.epochStartTime1", groupKeySet.epochStartTime1)); + VerifyOrReturn(CheckValue("groupKeySet.epochStartTime1.Value()", groupKeySet.epochStartTime1.Value(), 1110001ULL)); + VerifyOrReturn(CheckValueNull("groupKeySet.epochKey2", groupKeySet.epochKey2)); + VerifyOrReturn(CheckValueNonNull("groupKeySet.epochStartTime2", groupKeySet.epochStartTime2)); + VerifyOrReturn(CheckValue("groupKeySet.epochStartTime2.Value()", groupKeySet.epochStartTime2.Value(), 1110002ULL)); + + NextTest(); } - CHIP_ERROR TestTurnOnTheLightToSeeAttributeChange_17() + CHIP_ERROR TestWriteGroupKeys_8() { - const chip::GroupId groupId = 4660; - using RequestType = chip::app::Clusters::OnOff::Commands::On::Type; + const chip::EndpointId endpoint = mEndpoint.HasValue() ? mEndpoint.Value() : 0; + chip::Controller::GroupKeyManagementClusterTest cluster; + cluster.Associate(mDevices[kIdentityAlpha], endpoint); - RequestType request; + chip::app::DataModel::List + groupKeyMapArgument; - auto success = [](void * context, const typename RequestType::ResponseType & data) { - (static_cast(context))->OnSuccessResponse_17(); - }; + chip::app::Clusters::GroupKeyManagement::Structs::GroupKeyMapStruct::Type groupKeyMapList_0[2]; - auto failure = [](void * context, CHIP_ERROR error) { - (static_cast(context))->OnFailureResponse_17(error); - }; + groupKeyMapList_0[0].fabricIndex = 1; + groupKeyMapList_0[0].groupId = 257U; + groupKeyMapList_0[0].groupKeySetID = 417U; - auto done = [](void * context) { (static_cast(context))->OnDoneResponse_17(); }; + groupKeyMapList_0[1].fabricIndex = 1; + groupKeyMapList_0[1].groupId = 258U; + groupKeyMapList_0[1].groupKeySetID = 418U; - ReturnErrorOnFailure( - chip::Controller::InvokeGroupCommand(mDevices[kIdentityAlpha], this, success, failure, done, groupId, request)); + groupKeyMapArgument = groupKeyMapList_0; + + ReturnErrorOnFailure(cluster.WriteAttribute( + groupKeyMapArgument, this, OnSuccessCallback_8, OnFailureCallback_8)); return CHIP_NO_ERROR; } - void OnFailureResponse_17(CHIP_ERROR error) + void OnFailureResponse_8(CHIP_ERROR error) { chip::app::StatusIB status(error); ThrowFailureResponse(); } - void OnSuccessResponse_17() { NextTest(); } - - void OnDoneResponse_17() { NextTest(); } - - CHIP_ERROR TestWait100ms_18() - { - SetIdentity(kIdentityAlpha); - return WaitForMs(1000); - } + void OnSuccessResponse_8() { NextTest(); } - CHIP_ERROR TestTurnOffTheLightToSeeAttributeChange_19() + CHIP_ERROR TestReadGroupKeys_9() { - const chip::GroupId groupId = 4660; - using RequestType = chip::app::Clusters::OnOff::Commands::Off::Type; - - RequestType request; - - auto success = [](void * context, const typename RequestType::ResponseType & data) { - (static_cast(context))->OnSuccessResponse_19(); - }; - - auto failure = [](void * context, CHIP_ERROR error) { - (static_cast(context))->OnFailureResponse_19(error); - }; - - auto done = [](void * context) { (static_cast(context))->OnDoneResponse_19(); }; + const chip::EndpointId endpoint = mEndpoint.HasValue() ? mEndpoint.Value() : 0; + chip::Controller::GroupKeyManagementClusterTest cluster; + cluster.Associate(mDevices[kIdentityAlpha], endpoint); - ReturnErrorOnFailure( - chip::Controller::InvokeGroupCommand(mDevices[kIdentityAlpha], this, success, failure, done, groupId, request)); + ReturnErrorOnFailure(cluster.ReadAttribute( + this, OnSuccessCallback_9, OnFailureCallback_9)); return CHIP_NO_ERROR; } - void OnFailureResponse_19(CHIP_ERROR error) + void OnFailureResponse_9(CHIP_ERROR error) { chip::app::StatusIB status(error); ThrowFailureResponse(); } - void OnSuccessResponse_19() { NextTest(); } - - void OnDoneResponse_19() { NextTest(); } - - CHIP_ERROR TestWait100ms_20() + void OnSuccessResponse_9(const chip::app::DataModel::DecodableList< + chip::app::Clusters::GroupKeyManagement::Structs::GroupKeyMapStruct::DecodableType> & groupKeyMap) { - SetIdentity(kIdentityAlpha); - return WaitForMs(1000); + { + auto iter_0 = groupKeyMap.begin(); + VerifyOrReturn(CheckNextListItemDecodes("groupKeyMap", iter_0, 0)); + VerifyOrReturn(CheckValue("groupKeyMap[0].fabricIndex", iter_0.GetValue().fabricIndex, 1)); + VerifyOrReturn(CheckValue("groupKeyMap[0].groupId", iter_0.GetValue().groupId, 257U)); + VerifyOrReturn(CheckValue("groupKeyMap[0].groupKeySetID", iter_0.GetValue().groupKeySetID, 417U)); + VerifyOrReturn(CheckNextListItemDecodes("groupKeyMap", iter_0, 1)); + VerifyOrReturn(CheckValue("groupKeyMap[1].fabricIndex", iter_0.GetValue().fabricIndex, 1)); + VerifyOrReturn(CheckValue("groupKeyMap[1].groupId", iter_0.GetValue().groupId, 258U)); + VerifyOrReturn(CheckValue("groupKeyMap[1].groupKeySetID", iter_0.GetValue().groupKeySetID, 418U)); + VerifyOrReturn(CheckNoMoreListItems("groupKeyMap", iter_0, 2)); + } + + NextTest(); + } + + CHIP_ERROR TestReadGroupTable_10() + { + const chip::EndpointId endpoint = mEndpoint.HasValue() ? mEndpoint.Value() : 0; + chip::Controller::GroupKeyManagementClusterTest cluster; + cluster.Associate(mDevices[kIdentityAlpha], endpoint); + + ReturnErrorOnFailure(cluster.ReadAttribute( + this, OnSuccessCallback_10, OnFailureCallback_10)); + return CHIP_NO_ERROR; + } + + void OnFailureResponse_10(CHIP_ERROR error) + { + chip::app::StatusIB status(error); + ThrowFailureResponse(); + } + + void OnSuccessResponse_10(const chip::app::DataModel::DecodableList< + chip::app::Clusters::GroupKeyManagement::Structs::GroupInfoMapStruct::DecodableType> & groupTable) + { + { + auto iter_0 = groupTable.begin(); + VerifyOrReturn(CheckNextListItemDecodes("groupTable", iter_0, 0)); + VerifyOrReturn(CheckValue("groupTable[0].fabricIndex", iter_0.GetValue().fabricIndex, 1)); + VerifyOrReturn(CheckValue("groupTable[0].groupId", iter_0.GetValue().groupId, 257U)); + VerifyOrReturn(CheckValuePresent("groupTable[0].groupName", iter_0.GetValue().groupName)); + VerifyOrReturn(CheckValueAsString("groupTable[0].groupName.Value()", iter_0.GetValue().groupName.Value(), + chip::CharSpan("Group #1", 8))); + VerifyOrReturn(CheckNextListItemDecodes("groupTable", iter_0, 1)); + VerifyOrReturn(CheckValue("groupTable[1].fabricIndex", iter_0.GetValue().fabricIndex, 1)); + VerifyOrReturn(CheckValue("groupTable[1].groupId", iter_0.GetValue().groupId, 258U)); + VerifyOrReturn(CheckValuePresent("groupTable[1].groupName", iter_0.GetValue().groupName)); + VerifyOrReturn(CheckValueAsString("groupTable[1].groupName.Value()", iter_0.GetValue().groupName.Value(), + chip::CharSpan("Group #2", 8))); + VerifyOrReturn(CheckNoMoreListItems("groupTable", iter_0, 2)); + } + + NextTest(); + } + + CHIP_ERROR TestKeySetRemove1_11() + { + const chip::EndpointId endpoint = mEndpoint.HasValue() ? mEndpoint.Value() : 0; + using RequestType = chip::app::Clusters::GroupKeyManagement::Commands::KeySetRemove::Type; + + RequestType request; + request.groupKeySetID = 417U; + + auto success = [](void * context, const typename RequestType::ResponseType & data) { + (static_cast(context))->OnSuccessResponse_11(); + }; + + auto failure = [](void * context, CHIP_ERROR error) { + (static_cast(context))->OnFailureResponse_11(error); + }; + + ReturnErrorOnFailure(chip::Controller::InvokeCommand(mDevices[kIdentityAlpha], this, success, failure, endpoint, request)); + return CHIP_NO_ERROR; + } + + void OnFailureResponse_11(CHIP_ERROR error) + { + chip::app::StatusIB status(error); + ThrowFailureResponse(); + } + + void OnSuccessResponse_11() { NextTest(); } + + CHIP_ERROR TestKeySetReadRemoved_12() + { + const chip::EndpointId endpoint = mEndpoint.HasValue() ? mEndpoint.Value() : 0; + using RequestType = chip::app::Clusters::GroupKeyManagement::Commands::KeySetRead::Type; + + RequestType request; + request.groupKeySetID = 417U; + + auto success = [](void * context, const typename RequestType::ResponseType & data) { + (static_cast(context))->OnSuccessResponse_12(data.groupKeySet); + }; + + auto failure = [](void * context, CHIP_ERROR error) { + (static_cast(context))->OnFailureResponse_12(error); + }; + + ReturnErrorOnFailure(chip::Controller::InvokeCommand(mDevices[kIdentityAlpha], this, success, failure, endpoint, request)); + return CHIP_NO_ERROR; + } + + void OnFailureResponse_12(CHIP_ERROR error) + { + chip::app::StatusIB status(error); + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_NOT_FOUND)); + NextTest(); + } + + void + OnSuccessResponse_12(const chip::app::Clusters::GroupKeyManagement::Structs::GroupKeySetStruct::DecodableType & groupKeySet) + { + ThrowSuccessResponse(); + } + + CHIP_ERROR TestKeySetReadNotRemoved_13() + { + const chip::EndpointId endpoint = mEndpoint.HasValue() ? mEndpoint.Value() : 0; + using RequestType = chip::app::Clusters::GroupKeyManagement::Commands::KeySetRead::Type; + + RequestType request; + request.groupKeySetID = 418U; + + auto success = [](void * context, const typename RequestType::ResponseType & data) { + (static_cast(context))->OnSuccessResponse_13(data.groupKeySet); + }; + + auto failure = [](void * context, CHIP_ERROR error) { + (static_cast(context))->OnFailureResponse_13(error); + }; + + ReturnErrorOnFailure(chip::Controller::InvokeCommand(mDevices[kIdentityAlpha], this, success, failure, endpoint, request)); + return CHIP_NO_ERROR; + } + + void OnFailureResponse_13(CHIP_ERROR error) + { + chip::app::StatusIB status(error); + ThrowFailureResponse(); + } + + void + OnSuccessResponse_13(const chip::app::Clusters::GroupKeyManagement::Structs::GroupKeySetStruct::DecodableType & groupKeySet) + { + VerifyOrReturn(CheckValue("groupKeySet.groupKeySetID", groupKeySet.groupKeySetID, 418U)); + VerifyOrReturn(CheckValue("groupKeySet.groupKeySecurityPolicy", groupKeySet.groupKeySecurityPolicy, 1)); + VerifyOrReturn(CheckValueNull("groupKeySet.epochKey0", groupKeySet.epochKey0)); + VerifyOrReturn(CheckValueNonNull("groupKeySet.epochStartTime0", groupKeySet.epochStartTime0)); + VerifyOrReturn(CheckValue("groupKeySet.epochStartTime0.Value()", groupKeySet.epochStartTime0.Value(), 2110000ULL)); + VerifyOrReturn(CheckValueNull("groupKeySet.epochKey1", groupKeySet.epochKey1)); + VerifyOrReturn(CheckValueNonNull("groupKeySet.epochStartTime1", groupKeySet.epochStartTime1)); + VerifyOrReturn(CheckValue("groupKeySet.epochStartTime1.Value()", groupKeySet.epochStartTime1.Value(), 2110001ULL)); + VerifyOrReturn(CheckValueNull("groupKeySet.epochKey2", groupKeySet.epochKey2)); + VerifyOrReturn(CheckValueNonNull("groupKeySet.epochStartTime2", groupKeySet.epochStartTime2)); + VerifyOrReturn(CheckValue("groupKeySet.epochStartTime2.Value()", groupKeySet.epochStartTime2.Value(), 2110002ULL)); + + NextTest(); + } + + CHIP_ERROR TestRemoveAll_14() + { + const chip::EndpointId endpoint = mEndpoint.HasValue() ? mEndpoint.Value() : 1; + using RequestType = chip::app::Clusters::Groups::Commands::RemoveAllGroups::Type; + + RequestType request; + + auto success = [](void * context, const typename RequestType::ResponseType & data) { + (static_cast(context))->OnSuccessResponse_14(); + }; + + auto failure = [](void * context, CHIP_ERROR error) { + (static_cast(context))->OnFailureResponse_14(error); + }; + + ReturnErrorOnFailure(chip::Controller::InvokeCommand(mDevices[kIdentityAlpha], this, success, failure, endpoint, request)); + return CHIP_NO_ERROR; + } + + void OnFailureResponse_14(CHIP_ERROR error) + { + chip::app::StatusIB status(error); + ThrowFailureResponse(); + } + + void OnSuccessResponse_14() { NextTest(); } + + CHIP_ERROR TestKeySetRemove2_15() + { + const chip::EndpointId endpoint = mEndpoint.HasValue() ? mEndpoint.Value() : 0; + using RequestType = chip::app::Clusters::GroupKeyManagement::Commands::KeySetRemove::Type; + + RequestType request; + request.groupKeySetID = 418U; + + auto success = [](void * context, const typename RequestType::ResponseType & data) { + (static_cast(context))->OnSuccessResponse_15(); + }; + + auto failure = [](void * context, CHIP_ERROR error) { + (static_cast(context))->OnFailureResponse_15(error); + }; + + ReturnErrorOnFailure(chip::Controller::InvokeCommand(mDevices[kIdentityAlpha], this, success, failure, endpoint, request)); + return CHIP_NO_ERROR; + } + + void OnFailureResponse_15(CHIP_ERROR error) + { + chip::app::StatusIB status(error); + ThrowFailureResponse(); + } + + void OnSuccessResponse_15() { NextTest(); } + + CHIP_ERROR TestKeySetReadAlsoRemoved_16() + { + const chip::EndpointId endpoint = mEndpoint.HasValue() ? mEndpoint.Value() : 0; + using RequestType = chip::app::Clusters::GroupKeyManagement::Commands::KeySetRead::Type; + + RequestType request; + request.groupKeySetID = 418U; + + auto success = [](void * context, const typename RequestType::ResponseType & data) { + (static_cast(context))->OnSuccessResponse_16(data.groupKeySet); + }; + + auto failure = [](void * context, CHIP_ERROR error) { + (static_cast(context))->OnFailureResponse_16(error); + }; + + ReturnErrorOnFailure(chip::Controller::InvokeCommand(mDevices[kIdentityAlpha], this, success, failure, endpoint, request)); + return CHIP_NO_ERROR; + } + + void OnFailureResponse_16(CHIP_ERROR error) + { + chip::app::StatusIB status(error); + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_NOT_FOUND)); + NextTest(); + } + + void + OnSuccessResponse_16(const chip::app::Clusters::GroupKeyManagement::Structs::GroupKeySetStruct::DecodableType & groupKeySet) + { + ThrowSuccessResponse(); } }; -class TestGroupDemoConfig : public TestCommand +class Test_TC_DD_1_5 : public TestCommand { public: - TestGroupDemoConfig(CredentialIssuerCommands * credsIssuerConfig) : - TestCommand("TestGroupDemoConfig", credsIssuerConfig), mTestIndex(0) + Test_TC_DD_1_5(CredentialIssuerCommands * credsIssuerConfig) : TestCommand("Test_TC_DD_1_5", credsIssuerConfig), mTestIndex(0) { AddArgument("cluster", &mCluster); AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); } - ~TestGroupDemoConfig() {} + ~Test_TC_DD_1_5() {} /////////// TestCommand Interface ///////// void NextTest() override @@ -85380,12 +85221,12 @@ class TestGroupDemoConfig : public TestCommand if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: TestGroupDemoConfig\n"); + ChipLogProgress(chipTool, " **** Test Start: Test_TC_DD_1_5\n"); } if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: TestGroupDemoConfig\n"); + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_DD_1_5\n"); SetCommandExitStatus(CHIP_NO_ERROR); return; } @@ -85399,12 +85240,8 @@ class TestGroupDemoConfig : public TestCommand switch (mTestIndex++) { case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Add Group 1 - endpoint 1\n"); - err = TestAddGroup1Endpoint1_1(); + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1\n"); + err = TestStep1_0(); break; } @@ -85417,7 +85254,7 @@ class TestGroupDemoConfig : public TestCommand private: std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 2; + const uint16_t mTestCount = 1; chip::Optional mCluster; chip::Optional mEndpoint; @@ -85426,60 +85263,113 @@ class TestGroupDemoConfig : public TestCommand // Tests methods // - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() + CHIP_ERROR TestStep1_0() { SetIdentity(kIdentityAlpha); - return WaitForCommissionee(); + return Log("Verify that the onboarding payload for NFC tags SHALL use NDEF URI Record Type Definition as defined by NFC " + "Forum in URI Record Type Definition RTD URI"); } +}; - CHIP_ERROR TestAddGroup1Endpoint1_1() +class Test_TC_DD_1_6 : public TestCommand +{ +public: + Test_TC_DD_1_6(CredentialIssuerCommands * credsIssuerConfig) : TestCommand("Test_TC_DD_1_6", credsIssuerConfig), mTestIndex(0) { - const chip::EndpointId endpoint = mEndpoint.HasValue() ? mEndpoint.Value() : 1; - using RequestType = chip::app::Clusters::Groups::Commands::AddGroup::Type; + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + } - RequestType request; - request.groupId = 4660U; - request.groupName = chip::Span("Group #1garbage: not in length on purpose", 8); + ~Test_TC_DD_1_6() {} - auto success = [](void * context, const typename RequestType::ResponseType & data) { - (static_cast(context))->OnSuccessResponse_1(data.status, data.groupId); - }; + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; - auto failure = [](void * context, CHIP_ERROR error) { - (static_cast(context))->OnFailureResponse_1(error); - }; + if (0 == mTestIndex) + { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_DD_1_6\n"); + } - ReturnErrorOnFailure(chip::Controller::InvokeCommand(mDevices[kIdentityAlpha], this, success, failure, endpoint, request)); - return CHIP_NO_ERROR; + if (mTestCount == mTestIndex) + { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_DD_1_6\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) + { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1\n"); + err = TestStep1_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1 verification\n"); + err = TestStep1Verification_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2 verificaiton\n"); + err = TestStep2Verificaiton_2(); + break; + } + + if (CHIP_NO_ERROR != err) + { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } } - void OnFailureResponse_1(CHIP_ERROR error) +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 3; + + chip::Optional mCluster; + chip::Optional mEndpoint; + + // + // Tests methods + // + + CHIP_ERROR TestStep1_0() { - chip::app::StatusIB status(error); - ThrowFailureResponse(); + SetIdentity(kIdentityAlpha); + return Log("Scan the DUTs QR code using a QR code reader"); } - void OnSuccessResponse_1(uint8_t status, uint16_t groupId) + CHIP_ERROR TestStep1Verification_1() { - VerifyOrReturn(CheckValue("status", status, 0)); - - VerifyOrReturn(CheckValue("groupId", groupId, 4660U)); + SetIdentity(kIdentityAlpha); + return Log( + "Verify the QR code gets scanned successfully and the QR code must be of sufficient size and contrast respective to " + "surface material as to be readable with standard readers such as smartphones in normal lighting conditions"); + } - NextTest(); + CHIP_ERROR TestStep2Verificaiton_2() + { + SetIdentity(kIdentityAlpha); + return Log("Verify QR code version is 1 or higher"); } }; -class TestGroupKeyManagementCluster : public TestCommand +class Test_TC_DD_1_7 : public TestCommand { public: - TestGroupKeyManagementCluster(CredentialIssuerCommands * credsIssuerConfig) : - TestCommand("TestGroupKeyManagementCluster", credsIssuerConfig), mTestIndex(0) + Test_TC_DD_1_7(CredentialIssuerCommands * credsIssuerConfig) : TestCommand("Test_TC_DD_1_7", credsIssuerConfig), mTestIndex(0) { AddArgument("cluster", &mCluster); AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); } - ~TestGroupKeyManagementCluster() {} + ~Test_TC_DD_1_7() {} /////////// TestCommand Interface ///////// void NextTest() override @@ -85488,12 +85378,12 @@ class TestGroupKeyManagementCluster : public TestCommand if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: TestGroupKeyManagementCluster\n"); + ChipLogProgress(chipTool, " **** Test Start: Test_TC_DD_1_7\n"); } if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: TestGroupKeyManagementCluster\n"); + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_DD_1_7\n"); SetCommandExitStatus(CHIP_NO_ERROR); return; } @@ -85507,72 +85397,12 @@ class TestGroupKeyManagementCluster : public TestCommand switch (mTestIndex++) { case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); + ChipLogProgress(chipTool, " ***** Test Step 0 : Precondition\n"); + err = TestPrecondition_0(); break; case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Read maxGroupsPerFabric\n"); - err = TestReadMaxGroupsPerFabric_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Read maxGroupKeysPerFabric\n"); - err = TestReadMaxGroupKeysPerFabric_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Add Group 1\n"); - err = TestAddGroup1_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Add Group 2\n"); - err = TestAddGroup2_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : KeySet Write 1\n"); - err = TestKeySetWrite1_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : KeySet Write 2\n"); - err = TestKeySetWrite2_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : KeySet Read\n"); - err = TestKeySetRead_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Write Group Keys\n"); - err = TestWriteGroupKeys_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Read Group Keys\n"); - err = TestReadGroupKeys_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Read GroupTable\n"); - err = TestReadGroupTable_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : KeySet Remove 1\n"); - err = TestKeySetRemove1_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : KeySet Read (removed)\n"); - err = TestKeySetReadRemoved_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : KeySet Read (not removed)\n"); - err = TestKeySetReadNotRemoved_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Remove All\n"); - err = TestRemoveAll_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : KeySet Remove 2\n"); - err = TestKeySetRemove2_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : KeySet Read (also removed)\n"); - err = TestKeySetReadAlsoRemoved_16(); + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1\n"); + err = TestStep1_1(); break; } @@ -85585,472 +85415,550 @@ class TestGroupKeyManagementCluster : public TestCommand private: std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 17; + const uint16_t mTestCount = 2; chip::Optional mCluster; chip::Optional mEndpoint; - static void OnFailureCallback_1(void * context, CHIP_ERROR error) - { - (static_cast(context))->OnFailureResponse_1(error); - } + // + // Tests methods + // - static void OnSuccessCallback_1(void * context, uint16_t maxGroupsPerFabric) + CHIP_ERROR TestPrecondition_0() { - (static_cast(context))->OnSuccessResponse_1(maxGroupsPerFabric); + SetIdentity(kIdentityAlpha); + return Log("Verify manual pairing code is printed on the device or in additional provided materials"); } - static void OnFailureCallback_2(void * context, CHIP_ERROR error) + CHIP_ERROR TestStep1_1() { - (static_cast(context))->OnFailureResponse_2(error); + SetIdentity(kIdentityAlpha); + return Log("Verify that the Manual Pairing Code should be printed using a minimum font size of 6 points typically " + "producing a typeface height of 2.1 mm"); } +}; - static void OnSuccessCallback_2(void * context, uint16_t maxGroupKeysPerFabric) +class Test_TC_DD_1_8 : public TestCommand +{ +public: + Test_TC_DD_1_8(CredentialIssuerCommands * credsIssuerConfig) : TestCommand("Test_TC_DD_1_8", credsIssuerConfig), mTestIndex(0) { - (static_cast(context))->OnSuccessResponse_2(maxGroupKeysPerFabric); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); } - static void OnFailureCallback_8(void * context, CHIP_ERROR error) - { - (static_cast(context))->OnFailureResponse_8(error); - } + ~Test_TC_DD_1_8() {} - static void OnSuccessCallback_8(void * context) + /////////// TestCommand Interface ///////// + void NextTest() override { - (static_cast(context))->OnSuccessResponse_8(); - } + CHIP_ERROR err = CHIP_NO_ERROR; - static void OnFailureCallback_9(void * context, CHIP_ERROR error) - { - (static_cast(context))->OnFailureResponse_9(error); - } + if (0 == mTestIndex) + { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_DD_1_8\n"); + } - static void - OnSuccessCallback_9(void * context, - const chip::app::DataModel::DecodableList< - chip::app::Clusters::GroupKeyManagement::Structs::GroupKeyMapStruct::DecodableType> & groupKeyMap) - { - (static_cast(context))->OnSuccessResponse_9(groupKeyMap); - } + if (mTestCount == mTestIndex) + { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_DD_1_8\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } - static void OnFailureCallback_10(void * context, CHIP_ERROR error) - { - (static_cast(context))->OnFailureResponse_10(error); - } + Wait(); - static void - OnSuccessCallback_10(void * context, - const chip::app::DataModel::DecodableList< - chip::app::Clusters::GroupKeyManagement::Structs::GroupInfoMapStruct::DecodableType> & groupTable) - { - (static_cast(context))->OnSuccessResponse_10(groupTable); + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) + { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1\n"); + err = TestStep1_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1 verification\n"); + err = TestStep1Verification_1(); + break; + } + + if (CHIP_NO_ERROR != err) + { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } } +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 2; + + chip::Optional mCluster; + chip::Optional mEndpoint; + // // Tests methods // - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() + CHIP_ERROR TestStep1_0() { SetIdentity(kIdentityAlpha); - return WaitForCommissionee(); + return Log("Scan the device QR code using DUT"); } - CHIP_ERROR TestReadMaxGroupsPerFabric_1() + CHIP_ERROR TestStep1Verification_1() { - const chip::EndpointId endpoint = mEndpoint.HasValue() ? mEndpoint.Value() : 0; - chip::Controller::GroupKeyManagementClusterTest cluster; - cluster.Associate(mDevices[kIdentityAlpha], endpoint); - - ReturnErrorOnFailure( - cluster.ReadAttribute( - this, OnSuccessCallback_1, OnFailureCallback_1)); - return CHIP_NO_ERROR; + SetIdentity(kIdentityAlpha); + return Log("Verify the DUT is able to scan and parse the QR code successfully to onboard the device onto the CHIP network"); } +}; - void OnFailureResponse_1(CHIP_ERROR error) +class Test_TC_DD_1_9 : public TestCommand +{ +public: + Test_TC_DD_1_9(CredentialIssuerCommands * credsIssuerConfig) : TestCommand("Test_TC_DD_1_9", credsIssuerConfig), mTestIndex(0) { - chip::app::StatusIB status(error); - ThrowFailureResponse(); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); } - void OnSuccessResponse_1(uint16_t maxGroupsPerFabric) - { - VerifyOrReturn(CheckConstraintMinValue("maxGroupsPerFabric", maxGroupsPerFabric, 2U)); - NextTest(); - } + ~Test_TC_DD_1_9() {} - CHIP_ERROR TestReadMaxGroupKeysPerFabric_2() + /////////// TestCommand Interface ///////// + void NextTest() override { - const chip::EndpointId endpoint = mEndpoint.HasValue() ? mEndpoint.Value() : 0; - chip::Controller::GroupKeyManagementClusterTest cluster; - cluster.Associate(mDevices[kIdentityAlpha], endpoint); - - ReturnErrorOnFailure( - cluster.ReadAttribute( - this, OnSuccessCallback_2, OnFailureCallback_2)); - return CHIP_NO_ERROR; - } + CHIP_ERROR err = CHIP_NO_ERROR; - void OnFailureResponse_2(CHIP_ERROR error) - { - chip::app::StatusIB status(error); - ThrowFailureResponse(); - } + if (0 == mTestIndex) + { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_DD_1_9\n"); + } - void OnSuccessResponse_2(uint16_t maxGroupKeysPerFabric) - { - VerifyOrReturn(CheckValue("maxGroupKeysPerFabric", maxGroupKeysPerFabric, 2U)); + if (mTestCount == mTestIndex) + { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_DD_1_9\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } - NextTest(); - } + Wait(); - CHIP_ERROR TestAddGroup1_3() - { - const chip::EndpointId endpoint = mEndpoint.HasValue() ? mEndpoint.Value() : 1; - using RequestType = chip::app::Clusters::Groups::Commands::AddGroup::Type; + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) + { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Precondition\n"); + err = TestPrecondition_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1\n"); + err = TestStep1_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 1 verification\n"); + err = TestStep1Verification_2(); + break; + } - RequestType request; - request.groupId = 257U; - request.groupName = chip::Span("Group #1garbage: not in length on purpose", 8); + if (CHIP_NO_ERROR != err) + { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } - auto success = [](void * context, const typename RequestType::ResponseType & data) { - (static_cast(context))->OnSuccessResponse_3(data.status, data.groupId); - }; +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 3; - auto failure = [](void * context, CHIP_ERROR error) { - (static_cast(context))->OnFailureResponse_3(error); - }; + chip::Optional mCluster; + chip::Optional mEndpoint; - ReturnErrorOnFailure(chip::Controller::InvokeCommand(mDevices[kIdentityAlpha], this, success, failure, endpoint, request)); - return CHIP_NO_ERROR; - } + // + // Tests methods + // - void OnFailureResponse_3(CHIP_ERROR error) + CHIP_ERROR TestPrecondition_0() { - chip::app::StatusIB status(error); - ThrowFailureResponse(); + SetIdentity(kIdentityAlpha); + return Log("Verify that the manual pairing code is printed on the device or in additional provided materials"); } - void OnSuccessResponse_3(uint8_t status, uint16_t groupId) + CHIP_ERROR TestStep1_1() { - VerifyOrReturn(CheckValue("status", status, 0)); - - VerifyOrReturn(CheckValue("groupId", groupId, 257U)); - - NextTest(); + SetIdentity(kIdentityAlpha); + return Log("Provide the 11 digit or 21 digit pairing code from the Device in text speech or any format supported by DUT"); } - CHIP_ERROR TestAddGroup2_4() + CHIP_ERROR TestStep1Verification_2() { - const chip::EndpointId endpoint = mEndpoint.HasValue() ? mEndpoint.Value() : 1; - using RequestType = chip::app::Clusters::Groups::Commands::AddGroup::Type; - - RequestType request; - request.groupId = 258U; - request.groupName = chip::Span("Group #2garbage: not in length on purpose", 8); - - auto success = [](void * context, const typename RequestType::ResponseType & data) { - (static_cast(context))->OnSuccessResponse_4(data.status, data.groupId); - }; - - auto failure = [](void * context, CHIP_ERROR error) { - (static_cast(context))->OnFailureResponse_4(error); - }; - - ReturnErrorOnFailure(chip::Controller::InvokeCommand(mDevices[kIdentityAlpha], this, success, failure, endpoint, request)); - return CHIP_NO_ERROR; + SetIdentity(kIdentityAlpha); + return Log( + "Verify that the manual pairing code can be provided to DUT and parsed to onboard the device onto the CHIP network"); } +}; - void OnFailureResponse_4(CHIP_ERROR error) +class TestGroupDemoCommand : public TestCommand +{ +public: + TestGroupDemoCommand(CredentialIssuerCommands * credsIssuerConfig) : + TestCommand("TestGroupDemoCommand", credsIssuerConfig), mTestIndex(0) { - chip::app::StatusIB status(error); - ThrowFailureResponse(); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); } - void OnSuccessResponse_4(uint8_t status, uint16_t groupId) + ~TestGroupDemoCommand() {} + + /////////// TestCommand Interface ///////// + void NextTest() override { - VerifyOrReturn(CheckValue("status", status, 0)); + CHIP_ERROR err = CHIP_NO_ERROR; - VerifyOrReturn(CheckValue("groupId", groupId, 258U)); + if (0 == mTestIndex) + { + ChipLogProgress(chipTool, " **** Test Start: TestGroupDemoCommand\n"); + } - NextTest(); - } + if (mTestCount == mTestIndex) + { + ChipLogProgress(chipTool, " **** Test Complete: TestGroupDemoCommand\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } - CHIP_ERROR TestKeySetWrite1_5() - { - const chip::EndpointId endpoint = mEndpoint.HasValue() ? mEndpoint.Value() : 0; - using RequestType = chip::app::Clusters::GroupKeyManagement::Commands::KeySetWrite::Type; + Wait(); - RequestType request; + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) + { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); + err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Turn On the light to see attribute change\n"); + err = TestTurnOnTheLightToSeeAttributeChange_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Wait 100ms\n"); + err = TestWait100ms_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Turn Off the light to see attribute change\n"); + err = TestTurnOffTheLightToSeeAttributeChange_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Wait 100ms\n"); + err = TestWait100ms_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Turn On the light to see attribute change\n"); + err = TestTurnOnTheLightToSeeAttributeChange_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Wait 100ms\n"); + err = TestWait100ms_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Turn Off the light to see attribute change\n"); + err = TestTurnOffTheLightToSeeAttributeChange_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Wait 100ms\n"); + err = TestWait100ms_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Turn On the light to see attribute change\n"); + err = TestTurnOnTheLightToSeeAttributeChange_9(); + break; + case 10: + ChipLogProgress(chipTool, " ***** Test Step 10 : Wait 100ms\n"); + err = TestWait100ms_10(); + break; + case 11: + ChipLogProgress(chipTool, " ***** Test Step 11 : Turn Off the light to see attribute change\n"); + err = TestTurnOffTheLightToSeeAttributeChange_11(); + break; + case 12: + ChipLogProgress(chipTool, " ***** Test Step 12 : Wait 100ms\n"); + err = TestWait100ms_12(); + break; + case 13: + ChipLogProgress(chipTool, " ***** Test Step 13 : Turn On the light to see attribute change\n"); + err = TestTurnOnTheLightToSeeAttributeChange_13(); + break; + case 14: + ChipLogProgress(chipTool, " ***** Test Step 14 : Wait 100ms\n"); + err = TestWait100ms_14(); + break; + case 15: + ChipLogProgress(chipTool, " ***** Test Step 15 : Turn Off the light to see attribute change\n"); + err = TestTurnOffTheLightToSeeAttributeChange_15(); + break; + case 16: + ChipLogProgress(chipTool, " ***** Test Step 16 : Wait 100ms\n"); + err = TestWait100ms_16(); + break; + case 17: + ChipLogProgress(chipTool, " ***** Test Step 17 : Turn On the light to see attribute change\n"); + err = TestTurnOnTheLightToSeeAttributeChange_17(); + break; + case 18: + ChipLogProgress(chipTool, " ***** Test Step 18 : Wait 100ms\n"); + err = TestWait100ms_18(); + break; + case 19: + ChipLogProgress(chipTool, " ***** Test Step 19 : Turn Off the light to see attribute change\n"); + err = TestTurnOffTheLightToSeeAttributeChange_19(); + break; + case 20: + ChipLogProgress(chipTool, " ***** Test Step 20 : Wait 100ms\n"); + err = TestWait100ms_20(); + break; + } - request.groupKeySet.groupKeySetID = 417U; - request.groupKeySet.groupKeySecurityPolicy = - static_cast(0); - request.groupKeySet.epochKey0.SetNonNull(); - request.groupKeySet.epochKey0.Value() = - chip::ByteSpan(chip::Uint8::from_const_char( - "\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xafgarbage: not in length on purpose"), - 16); - request.groupKeySet.epochStartTime0.SetNonNull(); - request.groupKeySet.epochStartTime0.Value() = 1110000ULL; - request.groupKeySet.epochKey1.SetNonNull(); - request.groupKeySet.epochKey1.Value() = - chip::ByteSpan(chip::Uint8::from_const_char( - "\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbfgarbage: not in length on purpose"), - 16); - request.groupKeySet.epochStartTime1.SetNonNull(); - request.groupKeySet.epochStartTime1.Value() = 1110001ULL; - request.groupKeySet.epochKey2.SetNonNull(); - request.groupKeySet.epochKey2.Value() = - chip::ByteSpan(chip::Uint8::from_const_char( - "\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcfgarbage: not in length on purpose"), - 16); - request.groupKeySet.epochStartTime2.SetNonNull(); - request.groupKeySet.epochStartTime2.Value() = 1110002ULL; + if (CHIP_NO_ERROR != err) + { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 21; + + chip::Optional mCluster; + chip::Optional mEndpoint; + + // + // Tests methods + // + + CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() + { + SetIdentity(kIdentityAlpha); + return WaitForCommissionee(); + } + + CHIP_ERROR TestTurnOnTheLightToSeeAttributeChange_1() + { + const chip::GroupId groupId = 4660; + using RequestType = chip::app::Clusters::OnOff::Commands::On::Type; + + RequestType request; auto success = [](void * context, const typename RequestType::ResponseType & data) { - (static_cast(context))->OnSuccessResponse_5(); + (static_cast(context))->OnSuccessResponse_1(); }; auto failure = [](void * context, CHIP_ERROR error) { - (static_cast(context))->OnFailureResponse_5(error); + (static_cast(context))->OnFailureResponse_1(error); }; - ReturnErrorOnFailure(chip::Controller::InvokeCommand(mDevices[kIdentityAlpha], this, success, failure, endpoint, request)); + auto done = [](void * context) { (static_cast(context))->OnDoneResponse_1(); }; + + ReturnErrorOnFailure( + chip::Controller::InvokeGroupCommand(mDevices[kIdentityAlpha], this, success, failure, done, groupId, request)); return CHIP_NO_ERROR; } - void OnFailureResponse_5(CHIP_ERROR error) + void OnFailureResponse_1(CHIP_ERROR error) { chip::app::StatusIB status(error); ThrowFailureResponse(); } - void OnSuccessResponse_5() { NextTest(); } + void OnSuccessResponse_1() { NextTest(); } - CHIP_ERROR TestKeySetWrite2_6() + void OnDoneResponse_1() { NextTest(); } + + CHIP_ERROR TestWait100ms_2() { - const chip::EndpointId endpoint = mEndpoint.HasValue() ? mEndpoint.Value() : 0; - using RequestType = chip::app::Clusters::GroupKeyManagement::Commands::KeySetWrite::Type; + SetIdentity(kIdentityAlpha); + return WaitForMs(1000); + } - RequestType request; + CHIP_ERROR TestTurnOffTheLightToSeeAttributeChange_3() + { + const chip::GroupId groupId = 4660; + using RequestType = chip::app::Clusters::OnOff::Commands::Off::Type; - request.groupKeySet.groupKeySetID = 418U; - request.groupKeySet.groupKeySecurityPolicy = - static_cast(1); - request.groupKeySet.epochKey0.SetNonNull(); - request.groupKeySet.epochKey0.Value() = - chip::ByteSpan(chip::Uint8::from_const_char( - "\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdfgarbage: not in length on purpose"), - 16); - request.groupKeySet.epochStartTime0.SetNonNull(); - request.groupKeySet.epochStartTime0.Value() = 2110000ULL; - request.groupKeySet.epochKey1.SetNonNull(); - request.groupKeySet.epochKey1.Value() = - chip::ByteSpan(chip::Uint8::from_const_char( - "\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xefgarbage: not in length on purpose"), - 16); - request.groupKeySet.epochStartTime1.SetNonNull(); - request.groupKeySet.epochStartTime1.Value() = 2110001ULL; - request.groupKeySet.epochKey2.SetNonNull(); - request.groupKeySet.epochKey2.Value() = - chip::ByteSpan(chip::Uint8::from_const_char( - "\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xffgarbage: not in length on purpose"), - 16); - request.groupKeySet.epochStartTime2.SetNonNull(); - request.groupKeySet.epochStartTime2.Value() = 2110002ULL; + RequestType request; auto success = [](void * context, const typename RequestType::ResponseType & data) { - (static_cast(context))->OnSuccessResponse_6(); + (static_cast(context))->OnSuccessResponse_3(); }; auto failure = [](void * context, CHIP_ERROR error) { - (static_cast(context))->OnFailureResponse_6(error); + (static_cast(context))->OnFailureResponse_3(error); }; - ReturnErrorOnFailure(chip::Controller::InvokeCommand(mDevices[kIdentityAlpha], this, success, failure, endpoint, request)); + auto done = [](void * context) { (static_cast(context))->OnDoneResponse_3(); }; + + ReturnErrorOnFailure( + chip::Controller::InvokeGroupCommand(mDevices[kIdentityAlpha], this, success, failure, done, groupId, request)); return CHIP_NO_ERROR; } - void OnFailureResponse_6(CHIP_ERROR error) + void OnFailureResponse_3(CHIP_ERROR error) { chip::app::StatusIB status(error); ThrowFailureResponse(); } - void OnSuccessResponse_6() { NextTest(); } + void OnSuccessResponse_3() { NextTest(); } - CHIP_ERROR TestKeySetRead_7() + void OnDoneResponse_3() { NextTest(); } + + CHIP_ERROR TestWait100ms_4() { - const chip::EndpointId endpoint = mEndpoint.HasValue() ? mEndpoint.Value() : 0; - using RequestType = chip::app::Clusters::GroupKeyManagement::Commands::KeySetRead::Type; + SetIdentity(kIdentityAlpha); + return WaitForMs(1000); + } + + CHIP_ERROR TestTurnOnTheLightToSeeAttributeChange_5() + { + const chip::GroupId groupId = 4660; + using RequestType = chip::app::Clusters::OnOff::Commands::On::Type; RequestType request; - request.groupKeySetID = 417U; auto success = [](void * context, const typename RequestType::ResponseType & data) { - (static_cast(context))->OnSuccessResponse_7(data.groupKeySet); + (static_cast(context))->OnSuccessResponse_5(); }; auto failure = [](void * context, CHIP_ERROR error) { - (static_cast(context))->OnFailureResponse_7(error); + (static_cast(context))->OnFailureResponse_5(error); }; - ReturnErrorOnFailure(chip::Controller::InvokeCommand(mDevices[kIdentityAlpha], this, success, failure, endpoint, request)); + auto done = [](void * context) { (static_cast(context))->OnDoneResponse_5(); }; + + ReturnErrorOnFailure( + chip::Controller::InvokeGroupCommand(mDevices[kIdentityAlpha], this, success, failure, done, groupId, request)); return CHIP_NO_ERROR; } - void OnFailureResponse_7(CHIP_ERROR error) + void OnFailureResponse_5(CHIP_ERROR error) { chip::app::StatusIB status(error); ThrowFailureResponse(); } - void OnSuccessResponse_7(const chip::app::Clusters::GroupKeyManagement::Structs::GroupKeySetStruct::DecodableType & groupKeySet) - { - VerifyOrReturn(CheckValue("groupKeySet.groupKeySetID", groupKeySet.groupKeySetID, 417U)); - VerifyOrReturn(CheckValue("groupKeySet.groupKeySecurityPolicy", groupKeySet.groupKeySecurityPolicy, 0)); - VerifyOrReturn(CheckValueNull("groupKeySet.epochKey0", groupKeySet.epochKey0)); - VerifyOrReturn(CheckValueNonNull("groupKeySet.epochStartTime0", groupKeySet.epochStartTime0)); - VerifyOrReturn(CheckValue("groupKeySet.epochStartTime0.Value()", groupKeySet.epochStartTime0.Value(), 1110000ULL)); - VerifyOrReturn(CheckValueNull("groupKeySet.epochKey1", groupKeySet.epochKey1)); - VerifyOrReturn(CheckValueNonNull("groupKeySet.epochStartTime1", groupKeySet.epochStartTime1)); - VerifyOrReturn(CheckValue("groupKeySet.epochStartTime1.Value()", groupKeySet.epochStartTime1.Value(), 1110001ULL)); - VerifyOrReturn(CheckValueNull("groupKeySet.epochKey2", groupKeySet.epochKey2)); - VerifyOrReturn(CheckValueNonNull("groupKeySet.epochStartTime2", groupKeySet.epochStartTime2)); - VerifyOrReturn(CheckValue("groupKeySet.epochStartTime2.Value()", groupKeySet.epochStartTime2.Value(), 1110002ULL)); + void OnSuccessResponse_5() { NextTest(); } - NextTest(); - } + void OnDoneResponse_5() { NextTest(); } - CHIP_ERROR TestWriteGroupKeys_8() + CHIP_ERROR TestWait100ms_6() { - const chip::EndpointId endpoint = mEndpoint.HasValue() ? mEndpoint.Value() : 0; - chip::Controller::GroupKeyManagementClusterTest cluster; - cluster.Associate(mDevices[kIdentityAlpha], endpoint); + SetIdentity(kIdentityAlpha); + return WaitForMs(1000); + } - chip::app::DataModel::List - groupKeyMapArgument; + CHIP_ERROR TestTurnOffTheLightToSeeAttributeChange_7() + { + const chip::GroupId groupId = 4660; + using RequestType = chip::app::Clusters::OnOff::Commands::Off::Type; - chip::app::Clusters::GroupKeyManagement::Structs::GroupKeyMapStruct::Type groupKeyMapList_0[2]; + RequestType request; - groupKeyMapList_0[0].fabricIndex = 1; - groupKeyMapList_0[0].groupId = 257U; - groupKeyMapList_0[0].groupKeySetID = 417U; + auto success = [](void * context, const typename RequestType::ResponseType & data) { + (static_cast(context))->OnSuccessResponse_7(); + }; - groupKeyMapList_0[1].fabricIndex = 1; - groupKeyMapList_0[1].groupId = 258U; - groupKeyMapList_0[1].groupKeySetID = 418U; + auto failure = [](void * context, CHIP_ERROR error) { + (static_cast(context))->OnFailureResponse_7(error); + }; - groupKeyMapArgument = groupKeyMapList_0; + auto done = [](void * context) { (static_cast(context))->OnDoneResponse_7(); }; - ReturnErrorOnFailure(cluster.WriteAttribute( - groupKeyMapArgument, this, OnSuccessCallback_8, OnFailureCallback_8)); + ReturnErrorOnFailure( + chip::Controller::InvokeGroupCommand(mDevices[kIdentityAlpha], this, success, failure, done, groupId, request)); return CHIP_NO_ERROR; } - void OnFailureResponse_8(CHIP_ERROR error) + void OnFailureResponse_7(CHIP_ERROR error) { chip::app::StatusIB status(error); ThrowFailureResponse(); } - void OnSuccessResponse_8() { NextTest(); } - - CHIP_ERROR TestReadGroupKeys_9() - { - const chip::EndpointId endpoint = mEndpoint.HasValue() ? mEndpoint.Value() : 0; - chip::Controller::GroupKeyManagementClusterTest cluster; - cluster.Associate(mDevices[kIdentityAlpha], endpoint); + void OnSuccessResponse_7() { NextTest(); } - ReturnErrorOnFailure(cluster.ReadAttribute( - this, OnSuccessCallback_9, OnFailureCallback_9)); - return CHIP_NO_ERROR; - } + void OnDoneResponse_7() { NextTest(); } - void OnFailureResponse_9(CHIP_ERROR error) + CHIP_ERROR TestWait100ms_8() { - chip::app::StatusIB status(error); - ThrowFailureResponse(); + SetIdentity(kIdentityAlpha); + return WaitForMs(1000); } - void OnSuccessResponse_9(const chip::app::DataModel::DecodableList< - chip::app::Clusters::GroupKeyManagement::Structs::GroupKeyMapStruct::DecodableType> & groupKeyMap) + CHIP_ERROR TestTurnOnTheLightToSeeAttributeChange_9() { - { - auto iter_0 = groupKeyMap.begin(); - VerifyOrReturn(CheckNextListItemDecodes("groupKeyMap", iter_0, 0)); - VerifyOrReturn(CheckValue("groupKeyMap[0].fabricIndex", iter_0.GetValue().fabricIndex, 1)); - VerifyOrReturn(CheckValue("groupKeyMap[0].groupId", iter_0.GetValue().groupId, 257U)); - VerifyOrReturn(CheckValue("groupKeyMap[0].groupKeySetID", iter_0.GetValue().groupKeySetID, 417U)); - VerifyOrReturn(CheckNextListItemDecodes("groupKeyMap", iter_0, 1)); - VerifyOrReturn(CheckValue("groupKeyMap[1].fabricIndex", iter_0.GetValue().fabricIndex, 1)); - VerifyOrReturn(CheckValue("groupKeyMap[1].groupId", iter_0.GetValue().groupId, 258U)); - VerifyOrReturn(CheckValue("groupKeyMap[1].groupKeySetID", iter_0.GetValue().groupKeySetID, 418U)); - VerifyOrReturn(CheckNoMoreListItems("groupKeyMap", iter_0, 2)); - } + const chip::GroupId groupId = 4660; + using RequestType = chip::app::Clusters::OnOff::Commands::On::Type; - NextTest(); - } + RequestType request; - CHIP_ERROR TestReadGroupTable_10() - { - const chip::EndpointId endpoint = mEndpoint.HasValue() ? mEndpoint.Value() : 0; - chip::Controller::GroupKeyManagementClusterTest cluster; - cluster.Associate(mDevices[kIdentityAlpha], endpoint); + auto success = [](void * context, const typename RequestType::ResponseType & data) { + (static_cast(context))->OnSuccessResponse_9(); + }; - ReturnErrorOnFailure(cluster.ReadAttribute( - this, OnSuccessCallback_10, OnFailureCallback_10)); + auto failure = [](void * context, CHIP_ERROR error) { + (static_cast(context))->OnFailureResponse_9(error); + }; + + auto done = [](void * context) { (static_cast(context))->OnDoneResponse_9(); }; + + ReturnErrorOnFailure( + chip::Controller::InvokeGroupCommand(mDevices[kIdentityAlpha], this, success, failure, done, groupId, request)); return CHIP_NO_ERROR; } - void OnFailureResponse_10(CHIP_ERROR error) + void OnFailureResponse_9(CHIP_ERROR error) { chip::app::StatusIB status(error); ThrowFailureResponse(); } - void OnSuccessResponse_10(const chip::app::DataModel::DecodableList< - chip::app::Clusters::GroupKeyManagement::Structs::GroupInfoMapStruct::DecodableType> & groupTable) - { - { - auto iter_0 = groupTable.begin(); - VerifyOrReturn(CheckNextListItemDecodes("groupTable", iter_0, 0)); - VerifyOrReturn(CheckValue("groupTable[0].fabricIndex", iter_0.GetValue().fabricIndex, 1)); - VerifyOrReturn(CheckValue("groupTable[0].groupId", iter_0.GetValue().groupId, 257U)); - VerifyOrReturn(CheckValuePresent("groupTable[0].groupName", iter_0.GetValue().groupName)); - VerifyOrReturn(CheckValueAsString("groupTable[0].groupName.Value()", iter_0.GetValue().groupName.Value(), - chip::CharSpan("Group #1", 8))); - VerifyOrReturn(CheckNextListItemDecodes("groupTable", iter_0, 1)); - VerifyOrReturn(CheckValue("groupTable[1].fabricIndex", iter_0.GetValue().fabricIndex, 1)); - VerifyOrReturn(CheckValue("groupTable[1].groupId", iter_0.GetValue().groupId, 258U)); - VerifyOrReturn(CheckValuePresent("groupTable[1].groupName", iter_0.GetValue().groupName)); - VerifyOrReturn(CheckValueAsString("groupTable[1].groupName.Value()", iter_0.GetValue().groupName.Value(), - chip::CharSpan("Group #2", 8))); - VerifyOrReturn(CheckNoMoreListItems("groupTable", iter_0, 2)); - } + void OnSuccessResponse_9() { NextTest(); } - NextTest(); + void OnDoneResponse_9() { NextTest(); } + + CHIP_ERROR TestWait100ms_10() + { + SetIdentity(kIdentityAlpha); + return WaitForMs(1000); } - CHIP_ERROR TestKeySetRemove1_11() + CHIP_ERROR TestTurnOffTheLightToSeeAttributeChange_11() { - const chip::EndpointId endpoint = mEndpoint.HasValue() ? mEndpoint.Value() : 0; - using RequestType = chip::app::Clusters::GroupKeyManagement::Commands::KeySetRemove::Type; + const chip::GroupId groupId = 4660; + using RequestType = chip::app::Clusters::OnOff::Commands::Off::Type; RequestType request; - request.groupKeySetID = 417U; auto success = [](void * context, const typename RequestType::ResponseType & data) { - (static_cast(context))->OnSuccessResponse_11(); + (static_cast(context))->OnSuccessResponse_11(); }; auto failure = [](void * context, CHIP_ERROR error) { - (static_cast(context))->OnFailureResponse_11(error); + (static_cast(context))->OnFailureResponse_11(error); }; - ReturnErrorOnFailure(chip::Controller::InvokeCommand(mDevices[kIdentityAlpha], this, success, failure, endpoint, request)); + auto done = [](void * context) { (static_cast(context))->OnDoneResponse_11(); }; + + ReturnErrorOnFailure( + chip::Controller::InvokeGroupCommand(mDevices[kIdentityAlpha], this, success, failure, done, groupId, request)); return CHIP_NO_ERROR; } @@ -86062,169 +85970,272 @@ class TestGroupKeyManagementCluster : public TestCommand void OnSuccessResponse_11() { NextTest(); } - CHIP_ERROR TestKeySetReadRemoved_12() + void OnDoneResponse_11() { NextTest(); } + + CHIP_ERROR TestWait100ms_12() { - const chip::EndpointId endpoint = mEndpoint.HasValue() ? mEndpoint.Value() : 0; - using RequestType = chip::app::Clusters::GroupKeyManagement::Commands::KeySetRead::Type; + SetIdentity(kIdentityAlpha); + return WaitForMs(1000); + } + + CHIP_ERROR TestTurnOnTheLightToSeeAttributeChange_13() + { + const chip::GroupId groupId = 4660; + using RequestType = chip::app::Clusters::OnOff::Commands::On::Type; RequestType request; - request.groupKeySetID = 417U; auto success = [](void * context, const typename RequestType::ResponseType & data) { - (static_cast(context))->OnSuccessResponse_12(data.groupKeySet); + (static_cast(context))->OnSuccessResponse_13(); }; auto failure = [](void * context, CHIP_ERROR error) { - (static_cast(context))->OnFailureResponse_12(error); + (static_cast(context))->OnFailureResponse_13(error); }; - ReturnErrorOnFailure(chip::Controller::InvokeCommand(mDevices[kIdentityAlpha], this, success, failure, endpoint, request)); + auto done = [](void * context) { (static_cast(context))->OnDoneResponse_13(); }; + + ReturnErrorOnFailure( + chip::Controller::InvokeGroupCommand(mDevices[kIdentityAlpha], this, success, failure, done, groupId, request)); return CHIP_NO_ERROR; } - void OnFailureResponse_12(CHIP_ERROR error) + void OnFailureResponse_13(CHIP_ERROR error) { chip::app::StatusIB status(error); - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_NOT_FOUND)); - NextTest(); + ThrowFailureResponse(); } - void - OnSuccessResponse_12(const chip::app::Clusters::GroupKeyManagement::Structs::GroupKeySetStruct::DecodableType & groupKeySet) + void OnSuccessResponse_13() { NextTest(); } + + void OnDoneResponse_13() { NextTest(); } + + CHIP_ERROR TestWait100ms_14() { - ThrowSuccessResponse(); + SetIdentity(kIdentityAlpha); + return WaitForMs(1000); } - CHIP_ERROR TestKeySetReadNotRemoved_13() + CHIP_ERROR TestTurnOffTheLightToSeeAttributeChange_15() { - const chip::EndpointId endpoint = mEndpoint.HasValue() ? mEndpoint.Value() : 0; - using RequestType = chip::app::Clusters::GroupKeyManagement::Commands::KeySetRead::Type; + const chip::GroupId groupId = 4660; + using RequestType = chip::app::Clusters::OnOff::Commands::Off::Type; RequestType request; - request.groupKeySetID = 418U; auto success = [](void * context, const typename RequestType::ResponseType & data) { - (static_cast(context))->OnSuccessResponse_13(data.groupKeySet); + (static_cast(context))->OnSuccessResponse_15(); }; auto failure = [](void * context, CHIP_ERROR error) { - (static_cast(context))->OnFailureResponse_13(error); + (static_cast(context))->OnFailureResponse_15(error); }; - ReturnErrorOnFailure(chip::Controller::InvokeCommand(mDevices[kIdentityAlpha], this, success, failure, endpoint, request)); + auto done = [](void * context) { (static_cast(context))->OnDoneResponse_15(); }; + + ReturnErrorOnFailure( + chip::Controller::InvokeGroupCommand(mDevices[kIdentityAlpha], this, success, failure, done, groupId, request)); return CHIP_NO_ERROR; } - void OnFailureResponse_13(CHIP_ERROR error) + void OnFailureResponse_15(CHIP_ERROR error) { chip::app::StatusIB status(error); ThrowFailureResponse(); } - void - OnSuccessResponse_13(const chip::app::Clusters::GroupKeyManagement::Structs::GroupKeySetStruct::DecodableType & groupKeySet) - { - VerifyOrReturn(CheckValue("groupKeySet.groupKeySetID", groupKeySet.groupKeySetID, 418U)); - VerifyOrReturn(CheckValue("groupKeySet.groupKeySecurityPolicy", groupKeySet.groupKeySecurityPolicy, 1)); - VerifyOrReturn(CheckValueNull("groupKeySet.epochKey0", groupKeySet.epochKey0)); - VerifyOrReturn(CheckValueNonNull("groupKeySet.epochStartTime0", groupKeySet.epochStartTime0)); - VerifyOrReturn(CheckValue("groupKeySet.epochStartTime0.Value()", groupKeySet.epochStartTime0.Value(), 2110000ULL)); - VerifyOrReturn(CheckValueNull("groupKeySet.epochKey1", groupKeySet.epochKey1)); - VerifyOrReturn(CheckValueNonNull("groupKeySet.epochStartTime1", groupKeySet.epochStartTime1)); - VerifyOrReturn(CheckValue("groupKeySet.epochStartTime1.Value()", groupKeySet.epochStartTime1.Value(), 2110001ULL)); - VerifyOrReturn(CheckValueNull("groupKeySet.epochKey2", groupKeySet.epochKey2)); - VerifyOrReturn(CheckValueNonNull("groupKeySet.epochStartTime2", groupKeySet.epochStartTime2)); - VerifyOrReturn(CheckValue("groupKeySet.epochStartTime2.Value()", groupKeySet.epochStartTime2.Value(), 2110002ULL)); + void OnSuccessResponse_15() { NextTest(); } - NextTest(); + void OnDoneResponse_15() { NextTest(); } + + CHIP_ERROR TestWait100ms_16() + { + SetIdentity(kIdentityAlpha); + return WaitForMs(1000); } - CHIP_ERROR TestRemoveAll_14() + CHIP_ERROR TestTurnOnTheLightToSeeAttributeChange_17() { - const chip::EndpointId endpoint = mEndpoint.HasValue() ? mEndpoint.Value() : 1; - using RequestType = chip::app::Clusters::Groups::Commands::RemoveAllGroups::Type; + const chip::GroupId groupId = 4660; + using RequestType = chip::app::Clusters::OnOff::Commands::On::Type; RequestType request; auto success = [](void * context, const typename RequestType::ResponseType & data) { - (static_cast(context))->OnSuccessResponse_14(); + (static_cast(context))->OnSuccessResponse_17(); }; auto failure = [](void * context, CHIP_ERROR error) { - (static_cast(context))->OnFailureResponse_14(error); + (static_cast(context))->OnFailureResponse_17(error); }; - ReturnErrorOnFailure(chip::Controller::InvokeCommand(mDevices[kIdentityAlpha], this, success, failure, endpoint, request)); + auto done = [](void * context) { (static_cast(context))->OnDoneResponse_17(); }; + + ReturnErrorOnFailure( + chip::Controller::InvokeGroupCommand(mDevices[kIdentityAlpha], this, success, failure, done, groupId, request)); return CHIP_NO_ERROR; } - void OnFailureResponse_14(CHIP_ERROR error) + void OnFailureResponse_17(CHIP_ERROR error) { chip::app::StatusIB status(error); ThrowFailureResponse(); } - void OnSuccessResponse_14() { NextTest(); } + void OnSuccessResponse_17() { NextTest(); } - CHIP_ERROR TestKeySetRemove2_15() + void OnDoneResponse_17() { NextTest(); } + + CHIP_ERROR TestWait100ms_18() { - const chip::EndpointId endpoint = mEndpoint.HasValue() ? mEndpoint.Value() : 0; - using RequestType = chip::app::Clusters::GroupKeyManagement::Commands::KeySetRemove::Type; + SetIdentity(kIdentityAlpha); + return WaitForMs(1000); + } + + CHIP_ERROR TestTurnOffTheLightToSeeAttributeChange_19() + { + const chip::GroupId groupId = 4660; + using RequestType = chip::app::Clusters::OnOff::Commands::Off::Type; RequestType request; - request.groupKeySetID = 418U; auto success = [](void * context, const typename RequestType::ResponseType & data) { - (static_cast(context))->OnSuccessResponse_15(); + (static_cast(context))->OnSuccessResponse_19(); }; auto failure = [](void * context, CHIP_ERROR error) { - (static_cast(context))->OnFailureResponse_15(error); + (static_cast(context))->OnFailureResponse_19(error); }; - ReturnErrorOnFailure(chip::Controller::InvokeCommand(mDevices[kIdentityAlpha], this, success, failure, endpoint, request)); + auto done = [](void * context) { (static_cast(context))->OnDoneResponse_19(); }; + + ReturnErrorOnFailure( + chip::Controller::InvokeGroupCommand(mDevices[kIdentityAlpha], this, success, failure, done, groupId, request)); return CHIP_NO_ERROR; } - void OnFailureResponse_15(CHIP_ERROR error) + void OnFailureResponse_19(CHIP_ERROR error) { chip::app::StatusIB status(error); ThrowFailureResponse(); } - void OnSuccessResponse_15() { NextTest(); } + void OnSuccessResponse_19() { NextTest(); } - CHIP_ERROR TestKeySetReadAlsoRemoved_16() + void OnDoneResponse_19() { NextTest(); } + + CHIP_ERROR TestWait100ms_20() { - const chip::EndpointId endpoint = mEndpoint.HasValue() ? mEndpoint.Value() : 0; - using RequestType = chip::app::Clusters::GroupKeyManagement::Commands::KeySetRead::Type; + SetIdentity(kIdentityAlpha); + return WaitForMs(1000); + } +}; + +class TestGroupDemoConfig : public TestCommand +{ +public: + TestGroupDemoConfig(CredentialIssuerCommands * credsIssuerConfig) : + TestCommand("TestGroupDemoConfig", credsIssuerConfig), mTestIndex(0) + { + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + } + + ~TestGroupDemoConfig() {} + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) + { + ChipLogProgress(chipTool, " **** Test Start: TestGroupDemoConfig\n"); + } + + if (mTestCount == mTestIndex) + { + ChipLogProgress(chipTool, " **** Test Complete: TestGroupDemoConfig\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) + { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); + err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Add Group 1 - endpoint 1\n"); + err = TestAddGroup1Endpoint1_1(); + break; + } + + if (CHIP_NO_ERROR != err) + { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 2; + + chip::Optional mCluster; + chip::Optional mEndpoint; + + // + // Tests methods + // + + CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() + { + SetIdentity(kIdentityAlpha); + return WaitForCommissionee(); + } + + CHIP_ERROR TestAddGroup1Endpoint1_1() + { + const chip::EndpointId endpoint = mEndpoint.HasValue() ? mEndpoint.Value() : 1; + using RequestType = chip::app::Clusters::Groups::Commands::AddGroup::Type; RequestType request; - request.groupKeySetID = 418U; + request.groupId = 4660U; + request.groupName = chip::Span("Group #1garbage: not in length on purpose", 8); auto success = [](void * context, const typename RequestType::ResponseType & data) { - (static_cast(context))->OnSuccessResponse_16(data.groupKeySet); + (static_cast(context))->OnSuccessResponse_1(data.status, data.groupId); }; auto failure = [](void * context, CHIP_ERROR error) { - (static_cast(context))->OnFailureResponse_16(error); + (static_cast(context))->OnFailureResponse_1(error); }; ReturnErrorOnFailure(chip::Controller::InvokeCommand(mDevices[kIdentityAlpha], this, success, failure, endpoint, request)); return CHIP_NO_ERROR; } - void OnFailureResponse_16(CHIP_ERROR error) + void OnFailureResponse_1(CHIP_ERROR error) { chip::app::StatusIB status(error); - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_NOT_FOUND)); - NextTest(); + ThrowFailureResponse(); } - void - OnSuccessResponse_16(const chip::app::Clusters::GroupKeyManagement::Structs::GroupKeySetStruct::DecodableType & groupKeySet) + void OnSuccessResponse_1(uint8_t status, uint16_t groupId) { - ThrowSuccessResponse(); + VerifyOrReturn(CheckValue("status", status, 0)); + + VerifyOrReturn(CheckValue("groupId", groupId, 4660U)); + + NextTest(); } }; @@ -86234,6 +86245,7 @@ void registerCommandsTests(Commands & commands, CredentialIssuerCommands * creds commands_list clusterCommands = { make_unique(), + make_unique(), make_unique(credsIssuerConfig), make_unique(credsIssuerConfig), make_unique(credsIssuerConfig), @@ -86263,11 +86275,6 @@ void registerCommandsTests(Commands & commands, CredentialIssuerCommands * creds make_unique(credsIssuerConfig), make_unique(credsIssuerConfig), make_unique(credsIssuerConfig), - make_unique(credsIssuerConfig), - make_unique(credsIssuerConfig), - make_unique(credsIssuerConfig), - make_unique(credsIssuerConfig), - make_unique(credsIssuerConfig), make_unique(credsIssuerConfig), make_unique(credsIssuerConfig), make_unique(credsIssuerConfig), @@ -86382,9 +86389,14 @@ void registerCommandsTests(Commands & commands, CredentialIssuerCommands * creds make_unique(credsIssuerConfig), make_unique(credsIssuerConfig), make_unique(credsIssuerConfig), + make_unique(credsIssuerConfig), + make_unique(credsIssuerConfig), + make_unique(credsIssuerConfig), + make_unique(credsIssuerConfig), + make_unique(credsIssuerConfig), + make_unique(credsIssuerConfig), make_unique(credsIssuerConfig), make_unique(credsIssuerConfig), - make_unique(credsIssuerConfig), }; commands.Register(clusterName, clusterCommands);