From ef75ba49c7e466781f1a0b466880ee7d403a3ab2 Mon Sep 17 00:00:00 2001 From: Ricardo Casallas <77841255+rcasallas-silabs@users.noreply.github.com> Date: Thu, 1 Sep 2022 13:06:53 -0400 Subject: [PATCH] Bugfix: Group key map validation fixed. (#22303) * Bugfix: Group key map validation fixed. * Group Data Provider: Added missing MaxGroupKeysPerFabric validation. --- .../suites/TestGroupKeyManagementCluster.yaml | 19 +- src/credentials/GroupDataProviderImpl.cpp | 8 +- .../tests/TestGroupDataProvider.cpp | 12 +- src/lib/core/CHIPConfig.h | 2 +- .../chip-tool/zap-generated/test/Commands.h | 134 +++++++++----- .../zap-generated/test/Commands.h | 169 ++++++++++++------ 6 files changed, 235 insertions(+), 109 deletions(-) diff --git a/src/app/tests/suites/TestGroupKeyManagementCluster.yaml b/src/app/tests/suites/TestGroupKeyManagementCluster.yaml index ced7cc065d63ac..d7e9d95b24cf0a 100644 --- a/src/app/tests/suites/TestGroupKeyManagementCluster.yaml +++ b/src/app/tests/suites/TestGroupKeyManagementCluster.yaml @@ -39,7 +39,8 @@ tests: command: "readAttribute" attribute: "maxGroupKeysPerFabric" response: - value: 2 + constraints: + minValue: 3 - label: "KeySet Write 1" command: "KeySetWrite" @@ -112,6 +113,20 @@ tests: response: error: CONSTRAINT_ERROR + - label: "Write Group Keys (too many)" + command: "writeAttribute" + attribute: "GroupKeyMap" + arguments: + value: + [ + { FabricIndex: 1, GroupId: 0x0101, GroupKeySetID: 0x01a1 }, + { FabricIndex: 1, GroupId: 0x0101, GroupKeySetID: 0x01a2 }, + { FabricIndex: 1, GroupId: 0x0102, GroupKeySetID: 0x01a1 }, + { FabricIndex: 1, GroupId: 0x0102, GroupKeySetID: 0x01a2 }, + ] + response: + error: FAILURE + - label: "Write Group Keys" command: "writeAttribute" attribute: "GroupKeyMap" @@ -119,6 +134,7 @@ tests: value: [ { FabricIndex: 1, GroupId: 0x0101, GroupKeySetID: 0x01a1 }, + { FabricIndex: 1, GroupId: 0x0102, GroupKeySetID: 0x01a1 }, { FabricIndex: 1, GroupId: 0x0102, GroupKeySetID: 0x01a2 }, ] @@ -129,6 +145,7 @@ tests: value: [ { FabricIndex: 1, GroupId: 0x0101, GroupKeySetID: 0x01a1 }, + { FabricIndex: 1, GroupId: 0x0102, GroupKeySetID: 0x01a1 }, { FabricIndex: 1, GroupId: 0x0102, GroupKeySetID: 0x01a2 }, ] diff --git a/src/credentials/GroupDataProviderImpl.cpp b/src/credentials/GroupDataProviderImpl.cpp index 0626a8e73baa97..e88c4cece5933e 100644 --- a/src/credentials/GroupDataProviderImpl.cpp +++ b/src/credentials/GroupDataProviderImpl.cpp @@ -414,6 +414,7 @@ struct GroupData : public GroupDataProvider::GroupInfo, PersistentData(next))); return writer.EndContainer(container); } + CHIP_ERROR Deserialize(TLV::TLVReader & reader) override { ReturnErrorOnFailure(reader.Next(TLV::AnonymousTag())); @@ -1420,7 +1421,7 @@ CHIP_ERROR GroupDataProviderImpl::SetGroupKeyAt(chip::FabricIndex fabric_index, // Insert last VerifyOrReturnError(fabric.map_count == index, CHIP_ERROR_INVALID_ARGUMENT); - VerifyOrReturnError(fabric.map_count < mMaxGroupKeysPerFabric, CHIP_ERROR_INVALID_LIST_LENGTH); + VerifyOrReturnError(fabric.map_count < mMaxGroupsPerFabric, CHIP_ERROR_INVALID_LIST_LENGTH); map.next = 0; ReturnErrorOnFailure(map.Save(mStorage)); @@ -1603,7 +1604,10 @@ CHIP_ERROR GroupDataProviderImpl::SetKeySet(chip::FabricIndex fabric_index, cons return keyset.Save(mStorage); } - // New keyset, insert first + // New keyset + VerifyOrReturnError(fabric.keyset_count < mMaxGroupKeysPerFabric, CHIP_ERROR_INVALID_LIST_LENGTH); + + // Insert first keyset.next = fabric.first_keyset; ReturnErrorOnFailure(keyset.Save(mStorage)); // Update fabric diff --git a/src/credentials/tests/TestGroupDataProvider.cpp b/src/credentials/tests/TestGroupDataProvider.cpp index c2aad08820982e..70093996bacda9 100644 --- a/src/credentials/tests/TestGroupDataProvider.cpp +++ b/src/credentials/tests/TestGroupDataProvider.cpp @@ -48,7 +48,7 @@ static const size_t kSize1 = strlen(kValue1) + 1; static const size_t kSize2 = strlen(kValue2) + 1; constexpr uint16_t kMaxGroupsPerFabric = 5; -constexpr uint16_t kMaxGroupKeysPerFabric = 8; +constexpr uint16_t kMaxGroupKeysPerFabric = 4; // If test cases covering more than 2 fabrics are added, update `ResetProvider` function. constexpr chip::FabricIndex kFabric1 = 1; @@ -93,6 +93,7 @@ constexpr uint16_t kKeysetId0 = 0x0; constexpr uint16_t kKeysetId1 = 0x1111; constexpr uint16_t kKeysetId2 = 0x2222; constexpr uint16_t kKeysetId3 = 0x3333; +constexpr uint16_t kKeysetId4 = 0x4444; static const GroupInfo kGroupInfo1_1(kGroup1, "Group-1.1"); static const GroupInfo kGroupInfo1_2(kGroup2, "Group-1.2"); @@ -123,6 +124,7 @@ static KeySet kKeySet0(kKeysetId0, SecurityPolicy::kCacheAndSync, 3); static KeySet kKeySet1(kKeysetId1, SecurityPolicy::kTrustFirst, 1); static KeySet kKeySet2(kKeysetId2, SecurityPolicy::kTrustFirst, 2); static KeySet kKeySet3(kKeysetId3, SecurityPolicy::kCacheAndSync, 3); +static KeySet kKeySet4(kKeysetId4, SecurityPolicy::kTrustFirst, 1); uint8_t kZeroKey[EpochKey::kLengthBytes] = { 0 }; @@ -673,9 +675,7 @@ void TestGroupKeyIterator(nlTestSuite * apSuite, void * apContext) NL_TEST_ASSERT(apSuite, CHIP_NO_ERROR == provider->SetGroupKeyAt(kFabric1, 2, kGroup3Keyset2)); NL_TEST_ASSERT(apSuite, CHIP_NO_ERROR == provider->SetGroupKeyAt(kFabric1, 3, kGroup3Keyset3)); NL_TEST_ASSERT(apSuite, CHIP_NO_ERROR == provider->SetGroupKeyAt(kFabric1, 4, kGroup1Keyset0)); - NL_TEST_ASSERT(apSuite, CHIP_NO_ERROR == provider->SetGroupKeyAt(kFabric1, 5, kGroup1Keyset1)); - NL_TEST_ASSERT(apSuite, CHIP_NO_ERROR == provider->SetGroupKeyAt(kFabric1, 6, kGroup1Keyset2)); - NL_TEST_ASSERT(apSuite, CHIP_NO_ERROR == provider->SetGroupKeyAt(kFabric1, 7, kGroup1Keyset3)); + NL_TEST_ASSERT(apSuite, CHIP_NO_ERROR != provider->SetGroupKeyAt(kFabric1, 5, kGroup1Keyset1)); NL_TEST_ASSERT(apSuite, CHIP_NO_ERROR == provider->SetGroupKeyAt(kFabric2, 0, kGroup2Keyset0)); NL_TEST_ASSERT(apSuite, CHIP_NO_ERROR == provider->SetGroupKeyAt(kFabric2, 1, kGroup2Keyset1)); @@ -684,8 +684,7 @@ void TestGroupKeyIterator(nlTestSuite * apSuite, void * apContext) // Iterate fabric 1 - GroupKey expected_f1[] = { kGroup3Keyset0, kGroup3Keyset1, kGroup3Keyset2, kGroup3Keyset3, - kGroup1Keyset0, kGroup1Keyset1, kGroup1Keyset2, kGroup1Keyset3 }; + GroupKey expected_f1[] = { kGroup3Keyset0, kGroup3Keyset1, kGroup3Keyset2, kGroup3Keyset3, kGroup1Keyset0 }; size_t expected_f1_count = sizeof(expected_f1) / sizeof(GroupKey); auto it = provider->IterateGroupKeys(kFabric1); @@ -738,6 +737,7 @@ void TestKeySets(nlTestSuite * apSuite, void * apContext) NL_TEST_ASSERT(apSuite, CHIP_NO_ERROR == provider->SetKeySet(kFabric1, kCompressedFabricId1, kKeySet0)); NL_TEST_ASSERT(apSuite, CHIP_NO_ERROR == provider->SetKeySet(kFabric1, kCompressedFabricId1, kKeySet2)); NL_TEST_ASSERT(apSuite, CHIP_NO_ERROR == provider->SetKeySet(kFabric1, kCompressedFabricId1, kKeySet3)); + NL_TEST_ASSERT(apSuite, CHIP_NO_ERROR != provider->SetKeySet(kFabric1, kCompressedFabricId1, kKeySet4)); NL_TEST_ASSERT(apSuite, CHIP_NO_ERROR == provider->SetKeySet(kFabric2, kCompressedFabricId2, kKeySet3)); NL_TEST_ASSERT(apSuite, CHIP_NO_ERROR == provider->SetKeySet(kFabric2, kCompressedFabricId2, kKeySet0)); NL_TEST_ASSERT(apSuite, CHIP_NO_ERROR == provider->SetKeySet(kFabric2, kCompressedFabricId2, kKeySet2)); diff --git a/src/lib/core/CHIPConfig.h b/src/lib/core/CHIPConfig.h index d43b4332c61023..95fea208f584b2 100644 --- a/src/lib/core/CHIPConfig.h +++ b/src/lib/core/CHIPConfig.h @@ -978,7 +978,7 @@ extern const char CHIP_NON_PRODUCTION_MARKER[]; * Binds to number of KeySet entries to support per fabric (Need at least 1 for Identity Protection Key) */ #ifndef CHIP_CONFIG_MAX_GROUP_KEYS_PER_FABRIC -#define CHIP_CONFIG_MAX_GROUP_KEYS_PER_FABRIC 2 +#define CHIP_CONFIG_MAX_GROUP_KEYS_PER_FABRIC 3 #endif #if CHIP_CONFIG_MAX_GROUP_KEYS_PER_FABRIC < 1 diff --git a/zzz_generated/chip-tool/zap-generated/test/Commands.h b/zzz_generated/chip-tool/zap-generated/test/Commands.h index 74a1682286d97f..c0067aecfcdab7 100644 --- a/zzz_generated/chip-tool/zap-generated/test/Commands.h +++ b/zzz_generated/chip-tool/zap-generated/test/Commands.h @@ -73750,7 +73750,7 @@ class TestGroupKeyManagementClusterSuite : public TestCommand { public: TestGroupKeyManagementClusterSuite(CredentialIssuerCommands * credsIssuerConfig) : - TestCommand("TestGroupKeyManagementCluster", 21, credsIssuerConfig) + TestCommand("TestGroupKeyManagementCluster", 22, credsIssuerConfig) { AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); AddArgument("cluster", &mCluster); @@ -73800,7 +73800,7 @@ class TestGroupKeyManagementClusterSuite : public TestCommand { uint16_t value; VerifyOrReturn(CheckDecodeValue(chip::app::DataModel::Decode(*data, value))); - VerifyOrReturn(CheckValue("maxGroupKeysPerFabric", value, 2U)); + VerifyOrReturn(CheckConstraintMinValue("value", value, 3U)); } break; case 3: @@ -73834,9 +73834,12 @@ class TestGroupKeyManagementClusterSuite : public TestCommand VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); break; case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); break; case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 9: VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); { chip::app::DataModel::DecodableList< @@ -73851,13 +73854,17 @@ class TestGroupKeyManagementClusterSuite : public TestCommand VerifyOrReturn(CheckValue("groupKeyMap[0].fabricIndex", iter_0.GetValue().fabricIndex, 1U)); VerifyOrReturn(CheckNextListItemDecodes("groupKeyMap", iter_0, 1)); VerifyOrReturn(CheckValue("groupKeyMap[1].groupId", iter_0.GetValue().groupId, 258U)); - VerifyOrReturn(CheckValue("groupKeyMap[1].groupKeySetID", iter_0.GetValue().groupKeySetID, 418U)); + VerifyOrReturn(CheckValue("groupKeyMap[1].groupKeySetID", iter_0.GetValue().groupKeySetID, 417U)); VerifyOrReturn(CheckValue("groupKeyMap[1].fabricIndex", iter_0.GetValue().fabricIndex, 1U)); - VerifyOrReturn(CheckNoMoreListItems("groupKeyMap", iter_0, 2)); + VerifyOrReturn(CheckNextListItemDecodes("groupKeyMap", iter_0, 2)); + VerifyOrReturn(CheckValue("groupKeyMap[2].groupId", iter_0.GetValue().groupId, 258U)); + VerifyOrReturn(CheckValue("groupKeyMap[2].groupKeySetID", iter_0.GetValue().groupKeySetID, 418U)); + VerifyOrReturn(CheckValue("groupKeyMap[2].fabricIndex", iter_0.GetValue().fabricIndex, 1U)); + VerifyOrReturn(CheckNoMoreListItems("groupKeyMap", iter_0, 3)); } } break; - case 9: + case 10: VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); { chip::app::Clusters::Groups::Commands::AddGroupResponse::DecodableType value; @@ -73866,7 +73873,7 @@ class TestGroupKeyManagementClusterSuite : public TestCommand VerifyOrReturn(CheckValue("groupId", value.groupId, 257U)); } break; - case 10: + case 11: VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); { chip::app::Clusters::Groups::Commands::AddGroupResponse::DecodableType value; @@ -73875,7 +73882,7 @@ class TestGroupKeyManagementClusterSuite : public TestCommand VerifyOrReturn(CheckValue("groupId", value.groupId, 258U)); } break; - case 11: + case 12: VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); { chip::app::DataModel::DecodableList< @@ -73900,13 +73907,13 @@ class TestGroupKeyManagementClusterSuite : public TestCommand } } break; - case 12: + case 13: VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); break; - case 13: + case 14: VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_NOT_FOUND)); break; - case 14: + case 15: VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); { chip::app::Clusters::GroupKeyManagement::Commands::KeySetReadResponse::DecodableType value; @@ -73927,7 +73934,7 @@ class TestGroupKeyManagementClusterSuite : public TestCommand CheckValue("groupKeySet.epochStartTime2.Value()", value.groupKeySet.epochStartTime2.Value(), 2110002ULL)); } break; - case 15: + case 16: VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); { chip::app::Clusters::Groups::Commands::RemoveGroupResponse::DecodableType value; @@ -73936,7 +73943,7 @@ class TestGroupKeyManagementClusterSuite : public TestCommand VerifyOrReturn(CheckValue("groupId", value.groupId, 257U)); } break; - case 16: + case 17: VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); { chip::app::DataModel::DecodableList< @@ -73955,10 +73962,10 @@ class TestGroupKeyManagementClusterSuite : public TestCommand } } break; - case 17: + case 18: VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); break; - case 18: + case 19: VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); { chip::app::DataModel::DecodableList< @@ -73971,10 +73978,10 @@ class TestGroupKeyManagementClusterSuite : public TestCommand } } break; - case 19: + case 20: VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); break; - case 20: + case 21: VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_NOT_FOUND)); break; default: @@ -74109,35 +74116,70 @@ class TestGroupKeyManagementClusterSuite : public TestCommand GroupKeyManagement::Attributes::GroupKeyMap::Id, value, chip::NullOptional, chip::NullOptional); } case 7: { - LogStep(7, "Write Group Keys"); + LogStep(7, "Write Group Keys (too many)"); ListFreer listFreer; chip::app::DataModel::List value; { - auto * listHolder_0 = new ListHolder(2); + auto * listHolder_0 = new ListHolder(4); listFreer.add(listHolder_0); listHolder_0->mList[0].groupId = 257U; listHolder_0->mList[0].groupKeySetID = 417U; listHolder_0->mList[0].fabricIndex = 1U; - listHolder_0->mList[1].groupId = 258U; + listHolder_0->mList[1].groupId = 257U; listHolder_0->mList[1].groupKeySetID = 418U; listHolder_0->mList[1].fabricIndex = 1U; + listHolder_0->mList[2].groupId = 258U; + listHolder_0->mList[2].groupKeySetID = 417U; + listHolder_0->mList[2].fabricIndex = 1U; + + listHolder_0->mList[3].groupId = 258U; + listHolder_0->mList[3].groupKeySetID = 418U; + listHolder_0->mList[3].fabricIndex = 1U; + value = chip::app::DataModel::List( - listHolder_0->mList, 2); + listHolder_0->mList, 4); } return WriteAttribute(kIdentityAlpha, GetEndpoint(0), GroupKeyManagement::Id, GroupKeyManagement::Attributes::GroupKeyMap::Id, value, chip::NullOptional, chip::NullOptional); } case 8: { - LogStep(8, "Read Group Keys"); + LogStep(8, "Write Group Keys"); + ListFreer listFreer; + chip::app::DataModel::List value; + + { + auto * listHolder_0 = new ListHolder(3); + listFreer.add(listHolder_0); + + listHolder_0->mList[0].groupId = 257U; + listHolder_0->mList[0].groupKeySetID = 417U; + listHolder_0->mList[0].fabricIndex = 1U; + + listHolder_0->mList[1].groupId = 258U; + listHolder_0->mList[1].groupKeySetID = 417U; + listHolder_0->mList[1].fabricIndex = 1U; + + listHolder_0->mList[2].groupId = 258U; + listHolder_0->mList[2].groupKeySetID = 418U; + listHolder_0->mList[2].fabricIndex = 1U; + + value = chip::app::DataModel::List( + listHolder_0->mList, 3); + } + return WriteAttribute(kIdentityAlpha, GetEndpoint(0), GroupKeyManagement::Id, + GroupKeyManagement::Attributes::GroupKeyMap::Id, value, chip::NullOptional, chip::NullOptional); + } + case 9: { + LogStep(9, "Read Group Keys"); return ReadAttribute(kIdentityAlpha, GetEndpoint(0), GroupKeyManagement::Id, GroupKeyManagement::Attributes::GroupKeyMap::Id, true, chip::NullOptional); } - case 9: { - LogStep(9, "Add Group 1"); + case 10: { + LogStep(10, "Add Group 1"); ListFreer listFreer; chip::app::Clusters::Groups::Commands::AddGroup::Type value; value.groupId = 257U; @@ -74146,8 +74188,8 @@ class TestGroupKeyManagementClusterSuite : public TestCommand ); } - case 10: { - LogStep(10, "Add Group 2"); + case 11: { + LogStep(11, "Add Group 2"); ListFreer listFreer; chip::app::Clusters::Groups::Commands::AddGroup::Type value; value.groupId = 258U; @@ -74156,13 +74198,13 @@ class TestGroupKeyManagementClusterSuite : public TestCommand ); } - case 11: { - LogStep(11, "Read GroupTable"); + case 12: { + LogStep(12, "Read GroupTable"); return ReadAttribute(kIdentityAlpha, GetEndpoint(0), GroupKeyManagement::Id, GroupKeyManagement::Attributes::GroupTable::Id, true, chip::NullOptional); } - case 12: { - LogStep(12, "KeySet Remove 1"); + case 13: { + LogStep(13, "KeySet Remove 1"); ListFreer listFreer; chip::app::Clusters::GroupKeyManagement::Commands::KeySetRemove::Type value; value.groupKeySetID = 417U; @@ -74171,8 +74213,8 @@ class TestGroupKeyManagementClusterSuite : public TestCommand ); } - case 13: { - LogStep(13, "KeySet Read (removed)"); + case 14: { + LogStep(14, "KeySet Read (removed)"); ListFreer listFreer; chip::app::Clusters::GroupKeyManagement::Commands::KeySetRead::Type value; value.groupKeySetID = 417U; @@ -74181,8 +74223,8 @@ class TestGroupKeyManagementClusterSuite : public TestCommand ); } - case 14: { - LogStep(14, "KeySet Read (not removed)"); + case 15: { + LogStep(15, "KeySet Read (not removed)"); ListFreer listFreer; chip::app::Clusters::GroupKeyManagement::Commands::KeySetRead::Type value; value.groupKeySetID = 418U; @@ -74191,8 +74233,8 @@ class TestGroupKeyManagementClusterSuite : public TestCommand ); } - case 15: { - LogStep(15, "Remove Group 1"); + case 16: { + LogStep(16, "Remove Group 1"); ListFreer listFreer; chip::app::Clusters::Groups::Commands::RemoveGroup::Type value; value.groupId = 257U; @@ -74201,13 +74243,13 @@ class TestGroupKeyManagementClusterSuite : public TestCommand ); } - case 16: { - LogStep(16, "Read GroupTable 2"); + case 17: { + LogStep(17, "Read GroupTable 2"); return ReadAttribute(kIdentityAlpha, GetEndpoint(0), GroupKeyManagement::Id, GroupKeyManagement::Attributes::GroupTable::Id, true, chip::NullOptional); } - case 17: { - LogStep(17, "Remove All"); + case 18: { + LogStep(18, "Remove All"); ListFreer listFreer; chip::app::Clusters::Groups::Commands::RemoveAllGroups::Type value; return SendCommand(kIdentityAlpha, GetEndpoint(1), Groups::Id, Groups::Commands::RemoveAllGroups::Id, value, @@ -74215,13 +74257,13 @@ class TestGroupKeyManagementClusterSuite : public TestCommand ); } - case 18: { - LogStep(18, "Read GroupTable 3"); + case 19: { + LogStep(19, "Read GroupTable 3"); return ReadAttribute(kIdentityAlpha, GetEndpoint(0), GroupKeyManagement::Id, GroupKeyManagement::Attributes::GroupTable::Id, true, chip::NullOptional); } - case 19: { - LogStep(19, "KeySet Remove 2"); + case 20: { + LogStep(20, "KeySet Remove 2"); ListFreer listFreer; chip::app::Clusters::GroupKeyManagement::Commands::KeySetRemove::Type value; value.groupKeySetID = 418U; @@ -74230,8 +74272,8 @@ class TestGroupKeyManagementClusterSuite : public TestCommand ); } - case 20: { - LogStep(20, "KeySet Read (also removed)"); + case 21: { + LogStep(21, "KeySet Read (also removed)"); ListFreer listFreer; chip::app::Clusters::GroupKeyManagement::Commands::KeySetRead::Type value; value.groupKeySetID = 418U; diff --git a/zzz_generated/darwin-framework-tool/zap-generated/test/Commands.h b/zzz_generated/darwin-framework-tool/zap-generated/test/Commands.h index b65f871936e8d3..31200ce26ae7b1 100644 --- a/zzz_generated/darwin-framework-tool/zap-generated/test/Commands.h +++ b/zzz_generated/darwin-framework-tool/zap-generated/test/Commands.h @@ -127213,60 +127213,64 @@ class TestGroupKeyManagementCluster : public TestCommandBridge { err = TestWriteGroupKeysInvalid_6(); break; case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Write Group Keys\n"); - err = TestWriteGroupKeys_7(); + ChipLogProgress(chipTool, " ***** Test Step 7 : Write Group Keys (too many)\n"); + err = TestWriteGroupKeysTooMany_7(); break; case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Read Group Keys\n"); - err = TestReadGroupKeys_8(); + ChipLogProgress(chipTool, " ***** Test Step 8 : Write Group Keys\n"); + err = TestWriteGroupKeys_8(); break; case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Add Group 1\n"); - err = TestAddGroup1_9(); + ChipLogProgress(chipTool, " ***** Test Step 9 : Read Group Keys\n"); + err = TestReadGroupKeys_9(); break; case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Add Group 2\n"); - err = TestAddGroup2_10(); + ChipLogProgress(chipTool, " ***** Test Step 10 : Add Group 1\n"); + err = TestAddGroup1_10(); break; case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Read GroupTable\n"); - err = TestReadGroupTable_11(); + ChipLogProgress(chipTool, " ***** Test Step 11 : Add Group 2\n"); + err = TestAddGroup2_11(); break; case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : KeySet Remove 1\n"); - err = TestKeySetRemove1_12(); + ChipLogProgress(chipTool, " ***** Test Step 12 : Read GroupTable\n"); + err = TestReadGroupTable_12(); break; case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : KeySet Read (removed)\n"); - err = TestKeySetReadRemoved_13(); + ChipLogProgress(chipTool, " ***** Test Step 13 : KeySet Remove 1\n"); + err = TestKeySetRemove1_13(); break; case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : KeySet Read (not removed)\n"); - err = TestKeySetReadNotRemoved_14(); + ChipLogProgress(chipTool, " ***** Test Step 14 : KeySet Read (removed)\n"); + err = TestKeySetReadRemoved_14(); break; case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Remove Group 1\n"); - err = TestRemoveGroup1_15(); + ChipLogProgress(chipTool, " ***** Test Step 15 : KeySet Read (not removed)\n"); + err = TestKeySetReadNotRemoved_15(); break; case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Read GroupTable 2\n"); - err = TestReadGroupTable2_16(); + ChipLogProgress(chipTool, " ***** Test Step 16 : Remove Group 1\n"); + err = TestRemoveGroup1_16(); break; case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Remove All\n"); - err = TestRemoveAll_17(); + ChipLogProgress(chipTool, " ***** Test Step 17 : Read GroupTable 2\n"); + err = TestReadGroupTable2_17(); break; case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Read GroupTable 3\n"); - err = TestReadGroupTable3_18(); + ChipLogProgress(chipTool, " ***** Test Step 18 : Remove All\n"); + err = TestRemoveAll_18(); break; case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : KeySet Remove 2\n"); - err = TestKeySetRemove2_19(); + ChipLogProgress(chipTool, " ***** Test Step 19 : Read GroupTable 3\n"); + err = TestReadGroupTable3_19(); break; case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : KeySet Read (also removed)\n"); - err = TestKeySetReadAlsoRemoved_20(); + ChipLogProgress(chipTool, " ***** Test Step 20 : KeySet Remove 2\n"); + err = TestKeySetRemove2_20(); + break; + case 21: + ChipLogProgress(chipTool, " ***** Test Step 21 : KeySet Read (also removed)\n"); + err = TestKeySetReadAlsoRemoved_21(); break; } @@ -127301,7 +127305,7 @@ class TestGroupKeyManagementCluster : public TestCommandBridge { VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); break; case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); break; case 8: VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); @@ -127319,10 +127323,10 @@ class TestGroupKeyManagementCluster : public TestCommandBridge { VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); break; case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_NOT_FOUND)); + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); break; case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_NOT_FOUND)); break; case 15: VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); @@ -127340,6 +127344,9 @@ class TestGroupKeyManagementCluster : public TestCommandBridge { VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); break; case 20: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 21: VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_NOT_FOUND)); break; } @@ -127355,7 +127362,7 @@ class TestGroupKeyManagementCluster : public TestCommandBridge { private: std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 21; + const uint16_t mTestCount = 22; chip::Optional mNodeId; chip::Optional mCluster; @@ -127403,10 +127410,7 @@ class TestGroupKeyManagementCluster : public TestCommandBridge { VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - { - id actualValue = value; - VerifyOrReturn(CheckValue("MaxGroupKeysPerFabric", actualValue, 2U)); - } + VerifyOrReturn(CheckConstraintMinValue("maxGroupKeysPerFabric", [value unsignedShortValue], 3U)); NextTest(); }]; @@ -127575,7 +127579,7 @@ class TestGroupKeyManagementCluster : public TestCommandBridge { return CHIP_NO_ERROR; } - CHIP_ERROR TestWriteGroupKeys_7() + CHIP_ERROR TestWriteGroupKeysTooMany_7() { MTRBaseDevice * device = GetDevice("alpha"); MTRBaseClusterGroupKeyManagement * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device @@ -127592,10 +127596,63 @@ class TestGroupKeyManagementCluster : public TestCommandBridge { ((MTRGroupKeyManagementClusterGroupKeyMapStruct *) temp_0[0]).fabricIndex = [NSNumber numberWithUnsignedChar:1U]; temp_0[1] = [[MTRGroupKeyManagementClusterGroupKeyMapStruct alloc] init]; - ((MTRGroupKeyManagementClusterGroupKeyMapStruct *) temp_0[1]).groupId = [NSNumber numberWithUnsignedShort:258U]; + ((MTRGroupKeyManagementClusterGroupKeyMapStruct *) temp_0[1]).groupId = [NSNumber numberWithUnsignedShort:257U]; ((MTRGroupKeyManagementClusterGroupKeyMapStruct *) temp_0[1]).groupKeySetID = [NSNumber numberWithUnsignedShort:418U]; ((MTRGroupKeyManagementClusterGroupKeyMapStruct *) temp_0[1]).fabricIndex = [NSNumber numberWithUnsignedChar:1U]; + temp_0[2] = [[MTRGroupKeyManagementClusterGroupKeyMapStruct alloc] init]; + ((MTRGroupKeyManagementClusterGroupKeyMapStruct *) temp_0[2]).groupId = [NSNumber numberWithUnsignedShort:258U]; + ((MTRGroupKeyManagementClusterGroupKeyMapStruct *) temp_0[2]).groupKeySetID = [NSNumber numberWithUnsignedShort:417U]; + ((MTRGroupKeyManagementClusterGroupKeyMapStruct *) temp_0[2]).fabricIndex = [NSNumber numberWithUnsignedChar:1U]; + + temp_0[3] = [[MTRGroupKeyManagementClusterGroupKeyMapStruct alloc] init]; + ((MTRGroupKeyManagementClusterGroupKeyMapStruct *) temp_0[3]).groupId = [NSNumber numberWithUnsignedShort:258U]; + ((MTRGroupKeyManagementClusterGroupKeyMapStruct *) temp_0[3]).groupKeySetID = [NSNumber numberWithUnsignedShort:418U]; + ((MTRGroupKeyManagementClusterGroupKeyMapStruct *) temp_0[3]).fabricIndex = [NSNumber numberWithUnsignedChar:1U]; + + groupKeyMapArgument = temp_0; + } + [cluster writeAttributeGroupKeyMapWithValue:groupKeyMapArgument + completionHandler:^(NSError * _Nullable err) { + NSLog(@"Write Group Keys (too many) Error: %@", err); + + VerifyOrReturn(CheckValue("status", + err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code + : EMBER_ZCL_STATUS_FAILURE) + : 0, + EMBER_ZCL_STATUS_FAILURE)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteGroupKeys_8() + { + MTRBaseDevice * device = GetDevice("alpha"); + MTRBaseClusterGroupKeyManagement * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device + endpoint:0 + queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id groupKeyMapArgument; + { + NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; + temp_0[0] = [[MTRGroupKeyManagementClusterGroupKeyMapStruct alloc] init]; + ((MTRGroupKeyManagementClusterGroupKeyMapStruct *) temp_0[0]).groupId = [NSNumber numberWithUnsignedShort:257U]; + ((MTRGroupKeyManagementClusterGroupKeyMapStruct *) temp_0[0]).groupKeySetID = [NSNumber numberWithUnsignedShort:417U]; + ((MTRGroupKeyManagementClusterGroupKeyMapStruct *) temp_0[0]).fabricIndex = [NSNumber numberWithUnsignedChar:1U]; + + temp_0[1] = [[MTRGroupKeyManagementClusterGroupKeyMapStruct alloc] init]; + ((MTRGroupKeyManagementClusterGroupKeyMapStruct *) temp_0[1]).groupId = [NSNumber numberWithUnsignedShort:258U]; + ((MTRGroupKeyManagementClusterGroupKeyMapStruct *) temp_0[1]).groupKeySetID = [NSNumber numberWithUnsignedShort:417U]; + ((MTRGroupKeyManagementClusterGroupKeyMapStruct *) temp_0[1]).fabricIndex = [NSNumber numberWithUnsignedChar:1U]; + + temp_0[2] = [[MTRGroupKeyManagementClusterGroupKeyMapStruct alloc] init]; + ((MTRGroupKeyManagementClusterGroupKeyMapStruct *) temp_0[2]).groupId = [NSNumber numberWithUnsignedShort:258U]; + ((MTRGroupKeyManagementClusterGroupKeyMapStruct *) temp_0[2]).groupKeySetID = [NSNumber numberWithUnsignedShort:418U]; + ((MTRGroupKeyManagementClusterGroupKeyMapStruct *) temp_0[2]).fabricIndex = [NSNumber numberWithUnsignedChar:1U]; + groupKeyMapArgument = temp_0; } [cluster writeAttributeGroupKeyMapWithValue:groupKeyMapArgument @@ -127610,7 +127667,7 @@ class TestGroupKeyManagementCluster : public TestCommandBridge { return CHIP_NO_ERROR; } - CHIP_ERROR TestReadGroupKeys_8() + CHIP_ERROR TestReadGroupKeys_9() { MTRBaseDevice * device = GetDevice("alpha"); MTRBaseClusterGroupKeyManagement * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device @@ -127629,7 +127686,7 @@ class TestGroupKeyManagementCluster : public TestCommandBridge { { id actualValue = value; - VerifyOrReturn(CheckValue("GroupKeyMap", [actualValue count], static_cast(2))); + VerifyOrReturn(CheckValue("GroupKeyMap", [actualValue count], static_cast(3))); VerifyOrReturn(CheckValue("GroupId", ((MTRGroupKeyManagementClusterGroupKeyMapStruct *) actualValue[0]).groupId, 257U)); VerifyOrReturn(CheckValue("GroupKeySetID", @@ -127639,9 +127696,15 @@ class TestGroupKeyManagementCluster : public TestCommandBridge { VerifyOrReturn(CheckValue("GroupId", ((MTRGroupKeyManagementClusterGroupKeyMapStruct *) actualValue[1]).groupId, 258U)); VerifyOrReturn(CheckValue("GroupKeySetID", - ((MTRGroupKeyManagementClusterGroupKeyMapStruct *) actualValue[1]).groupKeySetID, 418U)); + ((MTRGroupKeyManagementClusterGroupKeyMapStruct *) actualValue[1]).groupKeySetID, 417U)); VerifyOrReturn(CheckValue("FabricIndex", ((MTRGroupKeyManagementClusterGroupKeyMapStruct *) actualValue[1]).fabricIndex, 1U)); + VerifyOrReturn(CheckValue("GroupId", + ((MTRGroupKeyManagementClusterGroupKeyMapStruct *) actualValue[2]).groupId, 258U)); + VerifyOrReturn(CheckValue("GroupKeySetID", + ((MTRGroupKeyManagementClusterGroupKeyMapStruct *) actualValue[2]).groupKeySetID, 418U)); + VerifyOrReturn(CheckValue("FabricIndex", + ((MTRGroupKeyManagementClusterGroupKeyMapStruct *) actualValue[2]).fabricIndex, 1U)); } NextTest(); @@ -127650,7 +127713,7 @@ class TestGroupKeyManagementCluster : public TestCommandBridge { return CHIP_NO_ERROR; } - CHIP_ERROR TestAddGroup1_9() + CHIP_ERROR TestAddGroup1_10() { MTRBaseDevice * device = GetDevice("alpha"); MTRBaseClusterGroups * cluster = [[MTRBaseClusterGroups alloc] initWithDevice:device endpoint:1 queue:mCallbackQueue]; @@ -127681,7 +127744,7 @@ class TestGroupKeyManagementCluster : public TestCommandBridge { return CHIP_NO_ERROR; } - CHIP_ERROR TestAddGroup2_10() + CHIP_ERROR TestAddGroup2_11() { MTRBaseDevice * device = GetDevice("alpha"); MTRBaseClusterGroups * cluster = [[MTRBaseClusterGroups alloc] initWithDevice:device endpoint:1 queue:mCallbackQueue]; @@ -127712,7 +127775,7 @@ class TestGroupKeyManagementCluster : public TestCommandBridge { return CHIP_NO_ERROR; } - CHIP_ERROR TestReadGroupTable_11() + CHIP_ERROR TestReadGroupTable_12() { MTRBaseDevice * device = GetDevice("alpha"); MTRBaseClusterGroupKeyManagement * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device @@ -127753,7 +127816,7 @@ class TestGroupKeyManagementCluster : public TestCommandBridge { return CHIP_NO_ERROR; } - CHIP_ERROR TestKeySetRemove1_12() + CHIP_ERROR TestKeySetRemove1_13() { MTRBaseDevice * device = GetDevice("alpha"); MTRBaseClusterGroupKeyManagement * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device @@ -127775,7 +127838,7 @@ class TestGroupKeyManagementCluster : public TestCommandBridge { return CHIP_NO_ERROR; } - CHIP_ERROR TestKeySetReadRemoved_13() + CHIP_ERROR TestKeySetReadRemoved_14() { MTRBaseDevice * device = GetDevice("alpha"); MTRBaseClusterGroupKeyManagement * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device @@ -127800,7 +127863,7 @@ class TestGroupKeyManagementCluster : public TestCommandBridge { return CHIP_NO_ERROR; } - CHIP_ERROR TestKeySetReadNotRemoved_14() + CHIP_ERROR TestKeySetReadNotRemoved_15() { MTRBaseDevice * device = GetDevice("alpha"); MTRBaseClusterGroupKeyManagement * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device @@ -127850,7 +127913,7 @@ class TestGroupKeyManagementCluster : public TestCommandBridge { return CHIP_NO_ERROR; } - CHIP_ERROR TestRemoveGroup1_15() + CHIP_ERROR TestRemoveGroup1_16() { MTRBaseDevice * device = GetDevice("alpha"); MTRBaseClusterGroups * cluster = [[MTRBaseClusterGroups alloc] initWithDevice:device endpoint:1 queue:mCallbackQueue]; @@ -127880,7 +127943,7 @@ class TestGroupKeyManagementCluster : public TestCommandBridge { return CHIP_NO_ERROR; } - CHIP_ERROR TestReadGroupTable2_16() + CHIP_ERROR TestReadGroupTable2_17() { MTRBaseDevice * device = GetDevice("alpha"); MTRBaseClusterGroupKeyManagement * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device @@ -127914,7 +127977,7 @@ class TestGroupKeyManagementCluster : public TestCommandBridge { return CHIP_NO_ERROR; } - CHIP_ERROR TestRemoveAll_17() + CHIP_ERROR TestRemoveAll_18() { MTRBaseDevice * device = GetDevice("alpha"); MTRBaseClusterGroups * cluster = [[MTRBaseClusterGroups alloc] initWithDevice:device endpoint:1 queue:mCallbackQueue]; @@ -127931,7 +127994,7 @@ class TestGroupKeyManagementCluster : public TestCommandBridge { return CHIP_NO_ERROR; } - CHIP_ERROR TestReadGroupTable3_18() + CHIP_ERROR TestReadGroupTable3_19() { MTRBaseDevice * device = GetDevice("alpha"); MTRBaseClusterGroupKeyManagement * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device @@ -127958,7 +128021,7 @@ class TestGroupKeyManagementCluster : public TestCommandBridge { return CHIP_NO_ERROR; } - CHIP_ERROR TestKeySetRemove2_19() + CHIP_ERROR TestKeySetRemove2_20() { MTRBaseDevice * device = GetDevice("alpha"); MTRBaseClusterGroupKeyManagement * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device @@ -127980,7 +128043,7 @@ class TestGroupKeyManagementCluster : public TestCommandBridge { return CHIP_NO_ERROR; } - CHIP_ERROR TestKeySetReadAlsoRemoved_20() + CHIP_ERROR TestKeySetReadAlsoRemoved_21() { MTRBaseDevice * device = GetDevice("alpha"); MTRBaseClusterGroupKeyManagement * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device