Add missing validity checks to GroupKeyManagement cluster (#28379)

* Add missing validity checks to GroupKeyManagement cluster

Problem:
 - GroupKeyManagement cluster did not enforce length checks on
   EpochKey0/1/2
 - Some corner cases of checks were not covered.
 - Spec fixed in https://github.com/CHIP-Specifications/connectedhomeip-spec/issues/7342
 - Fixes #28222

This PR:
 - Adds all the missing checks that spec updates imply
 - Adds tests for each of the individual checks
 - Adds improved logging for failures

Testing done:
 - New integration tests added
 - Integration tests pass

* Restyled by clang-format

* Restyled by prettier-yaml

* Add revision 2

* Fix revision 2 setting

* Address comments from @bzbarsky-apple

* Fix unit test

* Restyled by clang-format

* ZAP regen

---------

Co-authored-by: tennessee.carmelveilleux@gmail.com <tennessee@google.com>
Co-authored-by: Restyled.io <commits@restyled.io>
diff --git a/src/app/CommandHandler.cpp b/src/app/CommandHandler.cpp
index 29abc1f..14ad098 100644
--- a/src/app/CommandHandler.cpp
+++ b/src/app/CommandHandler.cpp
@@ -470,6 +470,21 @@
     return AddStatusInternal(aCommandPath, StatusIB(aStatus));
 }
 
+CHIP_ERROR CommandHandler::AddStatusAndLogIfFailure(const ConcreteCommandPath & aCommandPath, const Status aStatus,
+                                                    const char * aMessage)
+{
+    if (aStatus != Status::Success)
+    {
+        ChipLogError(DataManagement,
+                     "Failed to handle on Endpoint=%u Cluster=" ChipLogFormatMEI " Command=" ChipLogFormatMEI
+                     " with " ChipLogFormatIMStatus ": %s",
+                     aCommandPath.mEndpointId, ChipLogValueMEI(aCommandPath.mClusterId), ChipLogValueMEI(aCommandPath.mCommandId),
+                     ChipLogValueIMStatus(aStatus), aMessage);
+    }
+
+    return AddStatus(aCommandPath, aStatus);
+}
+
 CHIP_ERROR CommandHandler::AddClusterSpecificSuccess(const ConcreteCommandPath & aCommandPath, ClusterStatus aClusterStatus)
 {
     return AddStatusInternal(aCommandPath, StatusIB(Status::Success, aClusterStatus));
diff --git a/src/app/CommandHandler.h b/src/app/CommandHandler.h
index cc175a9..e2d2f4a 100644
--- a/src/app/CommandHandler.h
+++ b/src/app/CommandHandler.h
@@ -172,6 +172,11 @@
                                 System::PacketBufferHandle && payload, bool isTimedInvoke);
     CHIP_ERROR AddStatus(const ConcreteCommandPath & aCommandPath, const Protocols::InteractionModel::Status aStatus);
 
+    // Same as AddStatus, but logs that the command represented by aCommandPath failed with the given
+    // error status and error message, if aStatus is an error.
+    CHIP_ERROR AddStatusAndLogIfFailure(const ConcreteCommandPath & aCommandPath, const Protocols::InteractionModel::Status aStatus,
+                                        const char * aMessage);
+
     CHIP_ERROR AddClusterSpecificSuccess(const ConcreteCommandPath & aCommandPath, ClusterStatus aClusterStatus);
 
     CHIP_ERROR AddClusterSpecificFailure(const ConcreteCommandPath & aCommandPath, ClusterStatus aClusterStatus);
diff --git a/src/app/clusters/group-key-mgmt-server/group-key-mgmt-server.cpp b/src/app/clusters/group-key-mgmt-server/group-key-mgmt-server.cpp
index 9f29d0b..8edf881 100644
--- a/src/app/clusters/group-key-mgmt-server/group-key-mgmt-server.cpp
+++ b/src/app/clusters/group-key-mgmt-server/group-key-mgmt-server.cpp
@@ -111,6 +111,7 @@
 
     // TODO: Once there is MCSP support, this may need to change.
     static constexpr bool IsMCSPSupported() { return false; }
+    static constexpr uint16_t kImplementedClusterRevision = 2;
 
     CHIP_ERROR Read(const ConcreteReadAttributePath & aPath, AttributeValueEncoder & aEncoder) override
     {
@@ -119,7 +120,7 @@
         switch (aPath.mAttributeId)
         {
         case GroupKeyManagement::Attributes::ClusterRevision::Id:
-            return ReadClusterRevision(aPath.mEndpointId, aEncoder);
+            return aEncoder.Encode(kImplementedClusterRevision);
         case Attributes::FeatureMap::Id: {
             uint32_t features = 0;
             if (IsMCSPSupported())
@@ -285,6 +286,121 @@
     }
 };
 
+Status
+ValidateKeySetWriteArguments(const chip::app::Clusters::GroupKeyManagement::Commands::KeySetWrite::DecodableType & commandData)
+{
+    // SPEC: If the EpochKey0 field is null or its associated EpochStartTime0 field is null, then this command SHALL fail with an
+    // INVALID_COMMAND status code responded to the client.
+    if (commandData.groupKeySet.epochKey0.IsNull() || commandData.groupKeySet.epochStartTime0.IsNull())
+    {
+        return Status::InvalidCommand;
+    }
+
+    // SPEC: If the EpochStartTime0 is set to 0, then this command SHALL fail with an INVALID_COMMAND status code responded to the
+    // client.
+    if (0 == commandData.groupKeySet.epochStartTime0.Value())
+    {
+        return Status::InvalidCommand;
+    }
+
+    // By now we at least have epochKey0.
+    static_assert(GroupDataProvider::EpochKey::kLengthBytes == 16,
+                  "Expect EpochKey internal data structure to have a length of 16 bytes.");
+
+    // SPEC: If the EpochKey0 field's length is not exactly 16 bytes, then this command SHALL fail with a CONSTRAINT_ERROR status
+    // code responded to the client.
+    if (commandData.groupKeySet.epochKey0.Value().size() != GroupDataProvider::EpochKey::kLengthBytes)
+    {
+        return Status::ConstraintError;
+    }
+
+    // Already known to be false by now
+    bool epoch_key0_is_null    = false;
+    uint64_t epoch_start_time0 = commandData.groupKeySet.epochStartTime0.Value();
+
+    bool epoch_key1_is_null        = commandData.groupKeySet.epochKey1.IsNull();
+    bool epoch_start_time1_is_null = commandData.groupKeySet.epochStartTime1.IsNull();
+
+    uint64_t epoch_start_time1 = 0; // Will be overridden when known to be present.
+
+    // SPEC: If exactly one of the EpochKey1 or EpochStartTime1 is null, rather than both being null, or neither being null, then
+    // this command SHALL fail with an INVALID_COMMAND status code responded to the client.
+    if (epoch_key1_is_null != epoch_start_time1_is_null)
+    {
+        return Status::InvalidCommand;
+    }
+
+    if (!epoch_key1_is_null)
+    {
+        // SPEC: If the EpochKey1 field is not null, then the EpochKey0 field SHALL NOT be null. Otherwise this command SHALL fail
+        // with an INVALID_COMMAND status code responded to the client.
+        if (epoch_key0_is_null)
+        {
+            return Status::InvalidCommand;
+        }
+
+        // SPEC: If the EpochKey1 field is not null, and the field's length is not exactly 16 bytes, then this command SHALL fail
+        // with a CONSTRAINT_ERROR status code responded to the client.
+        if (commandData.groupKeySet.epochKey1.Value().size() != GroupDataProvider::EpochKey::kLengthBytes)
+        {
+            return Status::ConstraintError;
+        }
+
+        // By now, if EpochKey1 was present, we know EpochStartTime1 was also present.
+        epoch_start_time1 = commandData.groupKeySet.epochStartTime1.Value();
+
+        // SPEC: If the EpochKey1 field is not null, its associated EpochStartTime1 field SHALL NOT be null and SHALL contain a
+        // later epoch start time than the epoch start time found in the EpochStartTime0 field. Otherwise this command SHALL fail
+        // with an INVALID_COMMAND status code responded to the client.
+        bool epoch1_later_than_epoch0 = epoch_start_time1 > epoch_start_time0;
+        if (!epoch1_later_than_epoch0)
+        {
+            return Status::InvalidCommand;
+        }
+    }
+
+    bool epoch_key2_is_null        = commandData.groupKeySet.epochKey2.IsNull();
+    bool epoch_start_time2_is_null = commandData.groupKeySet.epochStartTime2.IsNull();
+
+    // SPEC: If exactly one of the EpochKey2 or EpochStartTime2 is null, rather than both being null, or neither being null, then
+    // this command SHALL fail with an INVALID_COMMAND status code responded to the client.
+    if (epoch_key2_is_null != epoch_start_time2_is_null)
+    {
+        return Status::InvalidCommand;
+    }
+
+    if (!epoch_key2_is_null)
+    {
+        // SPEC: If the EpochKey2 field is not null, then the EpochKey1 and EpochKey0 fields SHALL NOT be null. Otherwise this
+        // command SHALL fail with an INVALID_COMMAND status code responded to the client.
+        if (epoch_key0_is_null || epoch_key1_is_null)
+        {
+            return Status::InvalidCommand;
+        }
+
+        // SPEC: If the EpochKey2 field is not null, and the field's length is not exactly 16 bytes, then this command SHALL fail
+        // with a CONSTRAINT_ERROR status code responded to the client.
+        if (commandData.groupKeySet.epochKey2.Value().size() != GroupDataProvider::EpochKey::kLengthBytes)
+        {
+            return Status::ConstraintError;
+        }
+
+        // By now, if EpochKey2 was present, we know EpochStartTime2 was also present.
+        uint64_t epoch_start_time2 = commandData.groupKeySet.epochStartTime2.Value();
+
+        // SPEC: If the EpochKey2 field is not null, its associated EpochStartTime2 field SHALL NOT be null and SHALL contain a
+        // later epoch start time than the epoch start time found in the EpochStartTime1 field. Otherwise this command SHALL fail
+        // with an INVALID_COMMAND status code responded to the client.
+        bool epoch2_later_than_epoch1 = epoch_start_time2 > epoch_start_time1;
+        if (!epoch2_later_than_epoch1)
+        {
+            return Status::InvalidCommand;
+        }
+    }
+
+    return Status::Success;
+}
+
 constexpr uint16_t GroupKeyManagementAttributeAccess::kClusterRevision;
 
 GroupKeyManagementAttributeAccess gAttribute;
@@ -304,12 +420,20 @@
     chip::app::CommandHandler * commandObj, const chip::app::ConcreteCommandPath & commandPath,
     const chip::app::Clusters::GroupKeyManagement::Commands::KeySetWrite::DecodableType & commandData)
 {
-    if (commandData.groupKeySet.epochKey0.IsNull() || commandData.groupKeySet.epochStartTime0.IsNull() ||
-        commandData.groupKeySet.epochKey0.Value().empty() || (0 == commandData.groupKeySet.epochStartTime0.Value()))
+    auto provider = GetGroupDataProvider();
+    auto fabric   = Server::GetInstance().GetFabricTable().FindFabricWithIndex(commandObj->GetAccessingFabricIndex());
+
+    if (nullptr == provider || nullptr == fabric)
     {
-        // If the EpochKey0 field is null or its associated EpochStartTime0 field is null,
-        // then this command SHALL fail with an INVALID_COMMAND
-        commandObj->AddStatus(commandPath, Status::InvalidCommand);
+        commandObj->AddStatusAndLogIfFailure(commandPath, Status::Failure, "Internal consistency error on provider/fabric");
+        return true;
+    }
+
+    // Pre-validate all complex data dependency assumptions about the epoch keys
+    Status status = ValidateKeySetWriteArguments(commandData);
+    if (status != Status::Success)
+    {
+        commandObj->AddStatusAndLogIfFailure(commandPath, status, "Failure to validate KeySet data dependencies.");
         return true;
     }
 
@@ -319,7 +443,8 @@
         // supported by the server, because it is ... a new value unrecognized
         // by a legacy server, then the server SHALL generate a general
         // constraint error
-        commandObj->AddStatus(commandPath, Status::ConstraintError);
+        commandObj->AddStatusAndLogIfFailure(commandPath, Status::ConstraintError,
+                                             "Received unknown GroupKeySecurityPolicyEnum value");
         return true;
     }
 
@@ -330,28 +455,25 @@
         // any action attempting to set CacheAndSync in the
         // GroupKeySecurityPolicy field SHALL fail with an INVALID_COMMAND
         // error.
-        commandObj->AddStatus(commandPath, Status::InvalidCommand);
+        commandObj->AddStatusAndLogIfFailure(commandPath, Status::InvalidCommand,
+                                             "Received a CacheAndSync GroupKeySecurityPolicyEnum when MCSP not supported");
         return true;
     }
 
+    // All flight checks completed: by now we know that non-null keys are all valid and correct size.
+    bool epoch_key1_present = !commandData.groupKeySet.epochKey1.IsNull();
+    bool epoch_key2_present = !commandData.groupKeySet.epochKey2.IsNull();
+
     GroupDataProvider::KeySet keyset(commandData.groupKeySet.groupKeySetID, commandData.groupKeySet.groupKeySecurityPolicy, 0);
 
-    // Epoch Key 0
+    // Epoch Key 0 always present
     keyset.epoch_keys[0].start_time = commandData.groupKeySet.epochStartTime0.Value();
     memcpy(keyset.epoch_keys[0].key, commandData.groupKeySet.epochKey0.Value().data(), GroupDataProvider::EpochKey::kLengthBytes);
     keyset.num_keys_used++;
 
     // Epoch Key 1
-    if (!commandData.groupKeySet.epochKey1.IsNull())
+    if (epoch_key1_present)
     {
-        if (commandData.groupKeySet.epochStartTime1.IsNull() ||
-            commandData.groupKeySet.epochStartTime1.Value() <= commandData.groupKeySet.epochStartTime0.Value())
-        {
-            // If the EpochKey1 field is not null, its associated EpochStartTime1 field SHALL contain
-            // a later epoch start time than the epoch start time found in the EpochStartTime0 field.
-            commandObj->AddStatus(commandPath, Status::InvalidCommand);
-            return true;
-        }
         keyset.epoch_keys[1].start_time = commandData.groupKeySet.epochStartTime1.Value();
         memcpy(keyset.epoch_keys[1].key, commandData.groupKeySet.epochKey1.Value().data(),
                GroupDataProvider::EpochKey::kLengthBytes);
@@ -359,33 +481,14 @@
     }
 
     // Epoch Key 2
-    if (!commandData.groupKeySet.epochKey2.IsNull())
+    if (epoch_key2_present)
     {
-        if (commandData.groupKeySet.epochKey1.IsNull() || commandData.groupKeySet.epochStartTime2.IsNull() ||
-            commandData.groupKeySet.epochStartTime2.Value() <= commandData.groupKeySet.epochStartTime1.Value())
-        {
-            // If the EpochKey2 field is not null then:
-            // * The EpochKey1 field SHALL NOT be null
-            // * Its associated EpochStartTime1 field SHALL contain a later epoch start time
-            //   than the epoch start time found in the EpochStartTime0 field.
-            commandObj->AddStatus(commandPath, Status::InvalidCommand);
-            return true;
-        }
         keyset.epoch_keys[2].start_time = commandData.groupKeySet.epochStartTime2.Value();
         memcpy(keyset.epoch_keys[2].key, commandData.groupKeySet.epochKey2.Value().data(),
                GroupDataProvider::EpochKey::kLengthBytes);
         keyset.num_keys_used++;
     }
 
-    auto provider = GetGroupDataProvider();
-    auto fabric   = Server::GetInstance().GetFabricTable().FindFabricWithIndex(commandObj->GetAccessingFabricIndex());
-
-    if (nullptr == provider || nullptr == fabric)
-    {
-        commandObj->AddStatus(commandPath, Status::Failure);
-        return true;
-    }
-
     uint8_t compressed_fabric_id_buffer[sizeof(uint64_t)];
     MutableByteSpan compressed_fabric_id(compressed_fabric_id_buffer);
     CHIP_ERROR err = fabric->GetCompressedFabricIdBytes(compressed_fabric_id);
@@ -403,7 +506,7 @@
     }
     else
     {
-        ChipLogDetail(Zcl, "GroupKeyManagementCluster: KeySetWrite: %s", err.AsString());
+        ChipLogDetail(Zcl, "GroupKeyManagementCluster: KeySetWrite: %" CHIP_ERROR_FORMAT, err.Format());
     }
 
     // Send response
diff --git a/src/app/tests/suites/TestGroupKeyManagementCluster.yaml b/src/app/tests/suites/TestGroupKeyManagementCluster.yaml
index bc10910..034bdfd 100644
--- a/src/app/tests/suites/TestGroupKeyManagementCluster.yaml
+++ b/src/app/tests/suites/TestGroupKeyManagementCluster.yaml
@@ -74,6 +74,345 @@
           constraints:
               minValue: 3
 
+    # TODO(#28396): Re-enabled when CI wouldn't break on this syntax
+    #
+    #   command: "readAttribute"
+    #   attribute: "ClusterRevision"
+    #   response:
+    #       saveAs: ClusterRevisionValue
+    #       constraints:
+    #           minValue: 1
+    #           maxValue: 2
+    #           type: int16u
+
+    # - label: "Creates a new variable to hold if the cluster revision is == 2"
+    #   cluster: EqualityCommands
+    #   command: UnsignedNumberEquals
+    #   arguments:
+    #       values:
+    #           - name: Value1
+    #             value: ClusterRevisionValue
+    #           - name: Value2
+    #             value: 2
+    #   response:
+    #       - values:
+    #             - name: Equals
+    #               saveAs: ClusterIsRevision2
+
+    ########### KeySetWrite Epoch0 field validations
+    - label: "KeySetWrite with EpochKey0 null fails INVALID_COMMAND"
+      command: "KeySetWrite"
+      arguments:
+          values:
+              - name: "GroupKeySet"
+                value:
+                    {
+                        GroupKeySetID: 0x01a1,
+                        GroupKeySecurityPolicy: 0,
+                        EpochKey0: null,
+                        EpochStartTime0: 1110000,
+                        EpochKey1: null,
+                        EpochStartTime1: null,
+                        EpochKey2: null,
+                        EpochStartTime2: null,
+                    }
+      response:
+          error: INVALID_COMMAND
+
+    - label: "KeySetWrite with EpochStartTime0 null fails INVALID_COMMAND"
+      command: "KeySetWrite"
+      arguments:
+          values:
+              - name: "GroupKeySet"
+                value:
+                    {
+                        GroupKeySetID: 0x01a1,
+                        GroupKeySecurityPolicy: 0,
+                        EpochKey0: "\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf",
+                        EpochStartTime0: null,
+                        EpochKey1: null,
+                        EpochStartTime1: null,
+                        EpochKey2: null,
+                        EpochStartTime2: null,
+                    }
+      response:
+          error: INVALID_COMMAND
+
+    - label:
+          "KeySetWrite with EpochStartTime0 set to zero fails INVALID_COMMAND"
+      command: "KeySetWrite"
+      arguments:
+          values:
+              - name: "GroupKeySet"
+                value:
+                    {
+                        GroupKeySetID: 0x01a1,
+                        GroupKeySecurityPolicy: 0,
+                        EpochKey0: "\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf",
+                        EpochStartTime0: 0,
+                        EpochKey1: null,
+                        EpochStartTime1: null,
+                        EpochKey2: null,
+                        EpochStartTime2: null,
+                    }
+      response:
+          error: INVALID_COMMAND
+
+    - label:
+          "KeySetWrite with EpochKey0 with length 1 != 16 fails with
+          CONSTRAINT_ERROR"
+      # runIf: ClusterIsRevision2
+      command: "KeySetWrite"
+      arguments:
+          values:
+              - name: "GroupKeySet"
+                value:
+                    {
+                        GroupKeySetID: 0x01a1,
+                        GroupKeySecurityPolicy: 0,
+                        EpochKey0: "\xa0",
+                        EpochStartTime0: 1,
+                        EpochKey1: null,
+                        EpochStartTime1: null,
+                        EpochKey2: null,
+                        EpochStartTime2: null,
+                    }
+      response:
+          error: CONSTRAINT_ERROR
+
+    - label:
+          "KeySetWrite with EpochKey0 with length 0 != 16 fails with
+          CONSTRAINT_ERROR"
+      # runIf: ClusterIsRevision2
+      command: "KeySetWrite"
+      arguments:
+          values:
+              - name: "GroupKeySet"
+                value:
+                    {
+                        GroupKeySetID: 0x01a1,
+                        GroupKeySecurityPolicy: 0,
+                        EpochKey0: "",
+                        EpochStartTime0: 1,
+                        EpochKey1: null,
+                        EpochStartTime1: null,
+                        EpochKey2: null,
+                        EpochStartTime2: null,
+                    }
+      response:
+          error: CONSTRAINT_ERROR
+
+    ########### KeySetWrite Epoch1 field validations
+    - label: "KeySetWrite with EpochStartTime1 null fails INVALID_COMMAND"
+      # runIf: ClusterIsRevision2
+      command: "KeySetWrite"
+      arguments:
+          values:
+              - name: "GroupKeySet"
+                value:
+                    {
+                        GroupKeySetID: 0x01a1,
+                        GroupKeySecurityPolicy: 0,
+                        EpochKey0: "\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf",
+                        EpochStartTime0: 1110000,
+                        EpochKey1: "\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf",
+                        EpochStartTime1: null,
+                        EpochKey2: null,
+                        EpochStartTime2: null,
+                    }
+      response:
+          error: INVALID_COMMAND
+
+    - label: "KeySetWrite with EpochKey1 null fails INVALID_COMMAND"
+      command: "KeySetWrite"
+      arguments:
+          values:
+              - name: "GroupKeySet"
+                value:
+                    {
+                        GroupKeySetID: 0x01a1,
+                        GroupKeySecurityPolicy: 0,
+                        EpochKey0: "\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf",
+                        EpochStartTime0: 1110000,
+                        EpochKey1: null,
+                        EpochStartTime1: 1110001,
+                        EpochKey2: null,
+                        EpochStartTime2: null,
+                    }
+      response:
+          error: INVALID_COMMAND
+
+    - label:
+          "KeySetWrite with EpochKey1 with length 1 != 16 fails with
+          CONSTRAINT_ERROR"
+      # runIf: ClusterIsRevision2
+      command: "KeySetWrite"
+      arguments:
+          values:
+              - name: "GroupKeySet"
+                value:
+                    {
+                        GroupKeySetID: 0x01a1,
+                        GroupKeySecurityPolicy: 0,
+                        EpochKey0: "\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf",
+                        EpochStartTime0: 1110000,
+                        EpochKey1: "\xb0",
+                        EpochStartTime1: 1110001,
+                        EpochKey2: null,
+                        EpochStartTime2: null,
+                    }
+      response:
+          error: CONSTRAINT_ERROR
+
+    - label:
+          "KeySetWrite with EpochKey1 with length 0 != 16 fails with
+          CONSTRAINT_ERROR"
+      # runIf: ClusterIsRevision2
+      command: "KeySetWrite"
+      arguments:
+          values:
+              - name: "GroupKeySet"
+                value:
+                    {
+                        GroupKeySetID: 0x01a1,
+                        GroupKeySecurityPolicy: 0,
+                        EpochKey0: "\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf",
+                        EpochStartTime0: 1110000,
+                        EpochKey1: "",
+                        EpochStartTime1: 1110001,
+                        EpochKey2: null,
+                        EpochStartTime2: null,
+                    }
+      response:
+          error: CONSTRAINT_ERROR
+
+    - label:
+          "KeySetWrite with EpochStartTime1 not later than EpochStart0 fails
+          with INVALID_COMMAND"
+      command: "KeySetWrite"
+      arguments:
+          values:
+              - name: "GroupKeySet"
+                value:
+                    {
+                        GroupKeySetID: 0x01a1,
+                        GroupKeySecurityPolicy: 0,
+                        EpochKey0: "\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf",
+                        EpochStartTime0: 1110000,
+                        EpochKey1: "\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf",
+                        EpochStartTime1: 1,
+                        EpochKey2: null,
+                        EpochStartTime2: null,
+                    }
+      response:
+          error: INVALID_COMMAND
+
+    ########### KeySetWrite Epoch2 field validations
+    - label: "KeySetWrite with EpochStartTime2 null fails INVALID_COMMAND"
+      command: "KeySetWrite"
+      # runIf: ClusterIsRevision2
+      arguments:
+          values:
+              - name: "GroupKeySet"
+                value:
+                    {
+                        GroupKeySetID: 0x01a1,
+                        GroupKeySecurityPolicy: 0,
+                        EpochKey0: "\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf",
+                        EpochStartTime0: 1110000,
+                        EpochKey1: "\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf",
+                        EpochStartTime1: 1110001,
+                        EpochKey2: "\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff",
+                        EpochStartTime2: null,
+                    }
+      response:
+          error: INVALID_COMMAND
+
+    - label: "KeySetWrite with EpochKey2 null fails INVALID_COMMAND"
+      command: "KeySetWrite"
+      arguments:
+          values:
+              - name: "GroupKeySet"
+                value:
+                    {
+                        GroupKeySetID: 0x01a1,
+                        GroupKeySecurityPolicy: 0,
+                        EpochKey0: "\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf",
+                        EpochStartTime0: 1110000,
+                        EpochKey1: "\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf",
+                        EpochStartTime1: 1110001,
+                        EpochKey2: null,
+                        EpochStartTime2: 1110002,
+                    }
+      response:
+          error: INVALID_COMMAND
+
+    - label:
+          "KeySetWrite with EpochKey2 with length 1 != 16 fails with
+          CONSTRAINT_ERROR"
+      # runIf: ClusterIsRevision2
+      command: "KeySetWrite"
+      arguments:
+          values:
+              - name: "GroupKeySet"
+                value:
+                    {
+                        GroupKeySetID: 0x01a1,
+                        GroupKeySecurityPolicy: 0,
+                        EpochKey0: "\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf",
+                        EpochStartTime0: 1110000,
+                        EpochKey1: "\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf",
+                        EpochStartTime1: 1110001,
+                        EpochKey2: "\xc0",
+                        EpochStartTime2: 1110002,
+                    }
+      response:
+          error: CONSTRAINT_ERROR
+
+    - label:
+          "KeySetWrite with EpochKey2 with length 0 != 16 fails with
+          CONSTRAINT_ERROR"
+      # runIf: ClusterIsRevision2
+      command: "KeySetWrite"
+      arguments:
+          values:
+              - name: "GroupKeySet"
+                value:
+                    {
+                        GroupKeySetID: 0x01a1,
+                        GroupKeySecurityPolicy: 0,
+                        EpochKey0: "\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf",
+                        EpochStartTime0: 1110000,
+                        EpochKey1: "\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf",
+                        EpochStartTime1: 1110001,
+                        EpochKey2: "",
+                        EpochStartTime2: 1110002,
+                    }
+      response:
+          error: CONSTRAINT_ERROR
+
+    - label:
+          "KeySetWrite with EpochStartTime2 not later than EpochStart1 fails
+          with INVALID_COMMAND"
+      command: "KeySetWrite"
+      arguments:
+          values:
+              - name: "GroupKeySet"
+                value:
+                    {
+                        GroupKeySetID: 0x01a1,
+                        GroupKeySecurityPolicy: 0,
+                        EpochKey0: "\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf",
+                        EpochStartTime0: 1110000,
+                        EpochKey1: "\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf",
+                        EpochStartTime1: 1110001,
+                        EpochKey2: "\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff",
+                        EpochStartTime2: 100,
+                    }
+      response:
+          error: INVALID_COMMAND
+
+    ################ Rest of normal checks for KeySetWrite
     - label: "KeySet Write 1"
       command: "KeySetWrite"
       arguments:
diff --git a/src/controller/tests/data_model/TestCommands.cpp b/src/controller/tests/data_model/TestCommands.cpp
index 5714cc0..f9d1e35 100644
--- a/src/controller/tests/data_model/TestCommands.cpp
+++ b/src/controller/tests/data_model/TestCommands.cpp
@@ -85,8 +85,8 @@
 
         if (DataModel::Decode(aReader, dataRequest) != CHIP_NO_ERROR)
         {
-            ChipLogError(Controller, "Unable to decode the request");
-            apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::Failure);
+            apCommandObj->AddStatusAndLogIfFailure(aCommandPath, Protocols::InteractionModel::Status::Failure,
+                                                   "Unable to decode the request");
             return;
         }
 
@@ -120,7 +120,8 @@
             // test is not really testing what it should.
             for (size_t i = 0; i < 4; ++i)
             {
-                apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::Success);
+                apCommandObj->AddStatusAndLogIfFailure(aCommandPath, Protocols::InteractionModel::Status::Success,
+                                                       "No error but testing AddStatusAndLogIfFailure in success case");
             }
             // And one failure on the end.
             apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::Failure);
diff --git a/zzz_generated/chip-tool/zap-generated/test/Commands.h b/zzz_generated/chip-tool/zap-generated/test/Commands.h
index 7caa483..7198be4 100644
--- a/zzz_generated/chip-tool/zap-generated/test/Commands.h
+++ b/zzz_generated/chip-tool/zap-generated/test/Commands.h
@@ -113404,7 +113404,7 @@
 {
 public:
     TestGroupKeyManagementClusterSuite(CredentialIssuerCommands * credsIssuerConfig) :
-        TestCommand("TestGroupKeyManagementCluster", 48, credsIssuerConfig)
+        TestCommand("TestGroupKeyManagementCluster", 63, credsIssuerConfig)
     {
         AddArgument("nodeId", 0, UINT64_MAX, &mNodeId);
         AddArgument("cluster", &mCluster);
@@ -113471,21 +113471,66 @@
             }
             break;
         case 6:
-            VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0));
+            VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND));
             break;
         case 7:
-            VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0));
+            VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND));
             break;
         case 8:
-            VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0));
+            VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND));
             break;
         case 9:
-            VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0));
+            VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR));
             break;
         case 10:
-            VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0));
+            VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR));
             break;
         case 11:
+            VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND));
+            break;
+        case 12:
+            VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND));
+            break;
+        case 13:
+            VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR));
+            break;
+        case 14:
+            VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR));
+            break;
+        case 15:
+            VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND));
+            break;
+        case 16:
+            VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND));
+            break;
+        case 17:
+            VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND));
+            break;
+        case 18:
+            VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR));
+            break;
+        case 19:
+            VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR));
+            break;
+        case 20:
+            VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND));
+            break;
+        case 21:
+            VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0));
+            break;
+        case 22:
+            VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0));
+            break;
+        case 23:
+            VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0));
+            break;
+        case 24:
+            VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0));
+            break;
+        case 25:
+            VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0));
+            break;
+        case 26:
             VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0));
             {
                 chip::app::Clusters::GroupKeyManagement::Commands::KeySetReadResponse::DecodableType value;
@@ -113506,7 +113551,7 @@
                     CheckValue("groupKeySet.epochStartTime2.Value()", value.groupKeySet.epochStartTime2.Value(), 1110002ULL));
             }
             break;
-        case 12:
+        case 27:
             VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0));
             {
                 chip::app::Clusters::GroupKeyManagement::Commands::KeySetReadAllIndicesResponse::DecodableType value;
@@ -113516,19 +113561,19 @@
                 VerifyOrReturn(CheckConstraintContains("value", value.groupKeySetIDs, 0U));
             }
             break;
-        case 13:
+        case 28:
             VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR));
             break;
-        case 14:
+        case 29:
             VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE));
             break;
-        case 15:
+        case 30:
             VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0));
             break;
-        case 16:
+        case 31:
             VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0));
             break;
-        case 17:
+        case 32:
             VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0));
             {
                 chip::app::DataModel::DecodableList<
@@ -113557,7 +113602,7 @@
                 }
             }
             break;
-        case 18:
+        case 33:
             VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0));
             {
                 chip::app::DataModel::DecodableList<
@@ -113602,7 +113647,7 @@
                 }
             }
             break;
-        case 19:
+        case 34:
             VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0));
             {
                 chip::app::DataModel::DecodableList<
@@ -113631,7 +113676,7 @@
                 }
             }
             break;
-        case 20:
+        case 35:
             VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0));
             {
                 chip::app::DataModel::DecodableList<
@@ -113676,7 +113721,7 @@
                 }
             }
             break;
-        case 21:
+        case 36:
             VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0));
             {
                 chip::app::Clusters::Groups::Commands::AddGroupResponse::DecodableType value;
@@ -113685,7 +113730,7 @@
                 VerifyOrReturn(CheckValue("groupID", value.groupID, 257U));
             }
             break;
-        case 22:
+        case 37:
             VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0));
             {
                 chip::app::Clusters::Groups::Commands::AddGroupResponse::DecodableType value;
@@ -113694,7 +113739,7 @@
                 VerifyOrReturn(CheckValue("groupID", value.groupID, 258U));
             }
             break;
-        case 23:
+        case 38:
             VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0));
             {
                 chip::app::Clusters::Groups::Commands::AddGroupResponse::DecodableType value;
@@ -113703,7 +113748,7 @@
                 VerifyOrReturn(CheckValue("groupID", value.groupID, 259U));
             }
             break;
-        case 24:
+        case 39:
             VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0));
             {
                 chip::app::Clusters::Groups::Commands::AddGroupResponse::DecodableType value;
@@ -113712,7 +113757,7 @@
                 VerifyOrReturn(CheckValue("groupID", value.groupID, 260U));
             }
             break;
-        case 25:
+        case 40:
             VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0));
             {
                 chip::app::Clusters::Groups::Commands::AddGroupResponse::DecodableType value;
@@ -113721,7 +113766,7 @@
                 VerifyOrReturn(CheckValue("groupID", value.groupID, 261U));
             }
             break;
-        case 26:
+        case 41:
             VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0));
             {
                 chip::app::DataModel::DecodableList<
@@ -113790,7 +113835,7 @@
                 }
             }
             break;
-        case 27:
+        case 42:
             VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0));
             {
                 chip::app::DataModel::DecodableList<
@@ -113873,7 +113918,7 @@
                 }
             }
             break;
-        case 28:
+        case 43:
             VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0));
             {
                 chip::app::DataModel::DecodableList<
@@ -113900,7 +113945,7 @@
                 }
             }
             break;
-        case 29:
+        case 44:
             VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0));
             {
                 chip::app::DataModel::DecodableList<
@@ -113983,13 +114028,13 @@
                 }
             }
             break;
-        case 30:
+        case 45:
             VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0));
             break;
-        case 31:
+        case 46:
             VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_NOT_FOUND));
             break;
-        case 32:
+        case 47:
             VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0));
             {
                 chip::app::Clusters::GroupKeyManagement::Commands::KeySetReadResponse::DecodableType value;
@@ -114010,7 +114055,7 @@
                     CheckValue("groupKeySet.epochStartTime2.Value()", value.groupKeySet.epochStartTime2.Value(), 2110002ULL));
             }
             break;
-        case 33:
+        case 48:
             VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0));
             {
                 chip::app::Clusters::GroupKeyManagement::Commands::KeySetReadResponse::DecodableType value;
@@ -114031,7 +114076,7 @@
                     CheckValue("groupKeySet.epochStartTime2.Value()", value.groupKeySet.epochStartTime2.Value(), 2110002ULL));
             }
             break;
-        case 34:
+        case 49:
             VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0));
             {
                 chip::app::Clusters::Groups::Commands::RemoveGroupResponse::DecodableType value;
@@ -114040,7 +114085,7 @@
                 VerifyOrReturn(CheckValue("groupID", value.groupID, 257U));
             }
             break;
-        case 35:
+        case 50:
             VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0));
             {
                 chip::app::DataModel::DecodableList<
@@ -114095,10 +114140,10 @@
                 }
             }
             break;
-        case 36:
+        case 51:
             VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0));
             break;
-        case 37:
+        case 52:
             VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0));
             {
                 chip::app::DataModel::DecodableList<
@@ -114111,28 +114156,28 @@
                 }
             }
             break;
-        case 38:
+        case 53:
             VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0));
             break;
-        case 39:
+        case 54:
             VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_NOT_FOUND));
             break;
-        case 40:
+        case 55:
             VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0));
             break;
-        case 41:
+        case 56:
             VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0));
             break;
-        case 42:
+        case 57:
             VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0));
             break;
-        case 43:
+        case 58:
             VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0));
             break;
-        case 44:
+        case 59:
             VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0));
             break;
-        case 45:
+        case 60:
             VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0));
             {
                 chip::app::DataModel::DecodableList<
@@ -114149,10 +114194,10 @@
                 }
             }
             break;
-        case 46:
+        case 61:
             VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0));
             break;
-        case 47:
+        case 62:
             VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0));
             {
                 chip::app::DataModel::DecodableList<
@@ -114224,7 +114269,430 @@
                                  GroupKeyManagement::Attributes::MaxGroupKeysPerFabric::Id, true, chip::NullOptional);
         }
         case 6: {
-            LogStep(6, "KeySet Write 1");
+            LogStep(6, "KeySetWrite with EpochKey0 null fails INVALID_COMMAND");
+            ListFreer listFreer;
+            chip::app::Clusters::GroupKeyManagement::Commands::KeySetWrite::Type value;
+
+            value.groupKeySet.groupKeySetID = 417U;
+            value.groupKeySet.groupKeySecurityPolicy =
+                static_cast<chip::app::Clusters::GroupKeyManagement::GroupKeySecurityPolicyEnum>(0);
+            value.groupKeySet.epochKey0.SetNull();
+            value.groupKeySet.epochStartTime0.SetNonNull();
+            value.groupKeySet.epochStartTime0.Value() = 1110000ULL;
+            value.groupKeySet.epochKey1.SetNull();
+            value.groupKeySet.epochStartTime1.SetNull();
+            value.groupKeySet.epochKey2.SetNull();
+            value.groupKeySet.epochStartTime2.SetNull();
+
+            return SendCommand(kIdentityAlpha, GetEndpoint(0), GroupKeyManagement::Id,
+                               GroupKeyManagement::Commands::KeySetWrite::Id, value, chip::NullOptional
+
+            );
+        }
+        case 7: {
+            LogStep(7, "KeySetWrite with EpochStartTime0 null fails INVALID_COMMAND");
+            ListFreer listFreer;
+            chip::app::Clusters::GroupKeyManagement::Commands::KeySetWrite::Type value;
+
+            value.groupKeySet.groupKeySetID = 417U;
+            value.groupKeySet.groupKeySecurityPolicy =
+                static_cast<chip::app::Clusters::GroupKeyManagement::GroupKeySecurityPolicyEnum>(0);
+            value.groupKeySet.epochKey0.SetNonNull();
+            value.groupKeySet.epochKey0.Value() = chip::ByteSpan(
+                chip::Uint8::from_const_char(
+                    "\240\241\242\243\244\245\246\247\250\251\252\253\254\255\256\257garbage: not in length on purpose"),
+                16);
+            value.groupKeySet.epochStartTime0.SetNull();
+            value.groupKeySet.epochKey1.SetNull();
+            value.groupKeySet.epochStartTime1.SetNull();
+            value.groupKeySet.epochKey2.SetNull();
+            value.groupKeySet.epochStartTime2.SetNull();
+
+            return SendCommand(kIdentityAlpha, GetEndpoint(0), GroupKeyManagement::Id,
+                               GroupKeyManagement::Commands::KeySetWrite::Id, value, chip::NullOptional
+
+            );
+        }
+        case 8: {
+            LogStep(8, "KeySetWrite with EpochStartTime0 set to zero fails INVALID_COMMAND");
+            ListFreer listFreer;
+            chip::app::Clusters::GroupKeyManagement::Commands::KeySetWrite::Type value;
+
+            value.groupKeySet.groupKeySetID = 417U;
+            value.groupKeySet.groupKeySecurityPolicy =
+                static_cast<chip::app::Clusters::GroupKeyManagement::GroupKeySecurityPolicyEnum>(0);
+            value.groupKeySet.epochKey0.SetNonNull();
+            value.groupKeySet.epochKey0.Value() = chip::ByteSpan(
+                chip::Uint8::from_const_char(
+                    "\240\241\242\243\244\245\246\247\250\251\252\253\254\255\256\257garbage: not in length on purpose"),
+                16);
+            value.groupKeySet.epochStartTime0.SetNonNull();
+            value.groupKeySet.epochStartTime0.Value() = 0ULL;
+            value.groupKeySet.epochKey1.SetNull();
+            value.groupKeySet.epochStartTime1.SetNull();
+            value.groupKeySet.epochKey2.SetNull();
+            value.groupKeySet.epochStartTime2.SetNull();
+
+            return SendCommand(kIdentityAlpha, GetEndpoint(0), GroupKeyManagement::Id,
+                               GroupKeyManagement::Commands::KeySetWrite::Id, value, chip::NullOptional
+
+            );
+        }
+        case 9: {
+            LogStep(9, "KeySetWrite with EpochKey0 with length 1 != 16 fails with CONSTRAINT_ERROR");
+            ListFreer listFreer;
+            chip::app::Clusters::GroupKeyManagement::Commands::KeySetWrite::Type value;
+
+            value.groupKeySet.groupKeySetID = 417U;
+            value.groupKeySet.groupKeySecurityPolicy =
+                static_cast<chip::app::Clusters::GroupKeyManagement::GroupKeySecurityPolicyEnum>(0);
+            value.groupKeySet.epochKey0.SetNonNull();
+            value.groupKeySet.epochKey0.Value() =
+                chip::ByteSpan(chip::Uint8::from_const_char("\240garbage: not in length on purpose"), 1);
+            value.groupKeySet.epochStartTime0.SetNonNull();
+            value.groupKeySet.epochStartTime0.Value() = 1ULL;
+            value.groupKeySet.epochKey1.SetNull();
+            value.groupKeySet.epochStartTime1.SetNull();
+            value.groupKeySet.epochKey2.SetNull();
+            value.groupKeySet.epochStartTime2.SetNull();
+
+            return SendCommand(kIdentityAlpha, GetEndpoint(0), GroupKeyManagement::Id,
+                               GroupKeyManagement::Commands::KeySetWrite::Id, value, chip::NullOptional
+
+            );
+        }
+        case 10: {
+            LogStep(10, "KeySetWrite with EpochKey0 with length 0 != 16 fails with CONSTRAINT_ERROR");
+            ListFreer listFreer;
+            chip::app::Clusters::GroupKeyManagement::Commands::KeySetWrite::Type value;
+
+            value.groupKeySet.groupKeySetID = 417U;
+            value.groupKeySet.groupKeySecurityPolicy =
+                static_cast<chip::app::Clusters::GroupKeyManagement::GroupKeySecurityPolicyEnum>(0);
+            value.groupKeySet.epochKey0.SetNonNull();
+            value.groupKeySet.epochKey0.Value() =
+                chip::ByteSpan(chip::Uint8::from_const_char("garbage: not in length on purpose"), 0);
+            value.groupKeySet.epochStartTime0.SetNonNull();
+            value.groupKeySet.epochStartTime0.Value() = 1ULL;
+            value.groupKeySet.epochKey1.SetNull();
+            value.groupKeySet.epochStartTime1.SetNull();
+            value.groupKeySet.epochKey2.SetNull();
+            value.groupKeySet.epochStartTime2.SetNull();
+
+            return SendCommand(kIdentityAlpha, GetEndpoint(0), GroupKeyManagement::Id,
+                               GroupKeyManagement::Commands::KeySetWrite::Id, value, chip::NullOptional
+
+            );
+        }
+        case 11: {
+            LogStep(11, "KeySetWrite with EpochStartTime1 null fails INVALID_COMMAND");
+            ListFreer listFreer;
+            chip::app::Clusters::GroupKeyManagement::Commands::KeySetWrite::Type value;
+
+            value.groupKeySet.groupKeySetID = 417U;
+            value.groupKeySet.groupKeySecurityPolicy =
+                static_cast<chip::app::Clusters::GroupKeyManagement::GroupKeySecurityPolicyEnum>(0);
+            value.groupKeySet.epochKey0.SetNonNull();
+            value.groupKeySet.epochKey0.Value() = chip::ByteSpan(
+                chip::Uint8::from_const_char(
+                    "\240\241\242\243\244\245\246\247\250\251\252\253\254\255\256\257garbage: not in length on purpose"),
+                16);
+            value.groupKeySet.epochStartTime0.SetNonNull();
+            value.groupKeySet.epochStartTime0.Value() = 1110000ULL;
+            value.groupKeySet.epochKey1.SetNonNull();
+            value.groupKeySet.epochKey1.Value() = chip::ByteSpan(
+                chip::Uint8::from_const_char(
+                    "\260\261\262\263\264\265\266\267\270\271\272\273\274\275\276\277garbage: not in length on purpose"),
+                16);
+            value.groupKeySet.epochStartTime1.SetNull();
+            value.groupKeySet.epochKey2.SetNull();
+            value.groupKeySet.epochStartTime2.SetNull();
+
+            return SendCommand(kIdentityAlpha, GetEndpoint(0), GroupKeyManagement::Id,
+                               GroupKeyManagement::Commands::KeySetWrite::Id, value, chip::NullOptional
+
+            );
+        }
+        case 12: {
+            LogStep(12, "KeySetWrite with EpochKey1 null fails INVALID_COMMAND");
+            ListFreer listFreer;
+            chip::app::Clusters::GroupKeyManagement::Commands::KeySetWrite::Type value;
+
+            value.groupKeySet.groupKeySetID = 417U;
+            value.groupKeySet.groupKeySecurityPolicy =
+                static_cast<chip::app::Clusters::GroupKeyManagement::GroupKeySecurityPolicyEnum>(0);
+            value.groupKeySet.epochKey0.SetNonNull();
+            value.groupKeySet.epochKey0.Value() = chip::ByteSpan(
+                chip::Uint8::from_const_char(
+                    "\240\241\242\243\244\245\246\247\250\251\252\253\254\255\256\257garbage: not in length on purpose"),
+                16);
+            value.groupKeySet.epochStartTime0.SetNonNull();
+            value.groupKeySet.epochStartTime0.Value() = 1110000ULL;
+            value.groupKeySet.epochKey1.SetNull();
+            value.groupKeySet.epochStartTime1.SetNonNull();
+            value.groupKeySet.epochStartTime1.Value() = 1110001ULL;
+            value.groupKeySet.epochKey2.SetNull();
+            value.groupKeySet.epochStartTime2.SetNull();
+
+            return SendCommand(kIdentityAlpha, GetEndpoint(0), GroupKeyManagement::Id,
+                               GroupKeyManagement::Commands::KeySetWrite::Id, value, chip::NullOptional
+
+            );
+        }
+        case 13: {
+            LogStep(13, "KeySetWrite with EpochKey1 with length 1 != 16 fails with CONSTRAINT_ERROR");
+            ListFreer listFreer;
+            chip::app::Clusters::GroupKeyManagement::Commands::KeySetWrite::Type value;
+
+            value.groupKeySet.groupKeySetID = 417U;
+            value.groupKeySet.groupKeySecurityPolicy =
+                static_cast<chip::app::Clusters::GroupKeyManagement::GroupKeySecurityPolicyEnum>(0);
+            value.groupKeySet.epochKey0.SetNonNull();
+            value.groupKeySet.epochKey0.Value() = chip::ByteSpan(
+                chip::Uint8::from_const_char(
+                    "\240\241\242\243\244\245\246\247\250\251\252\253\254\255\256\257garbage: not in length on purpose"),
+                16);
+            value.groupKeySet.epochStartTime0.SetNonNull();
+            value.groupKeySet.epochStartTime0.Value() = 1110000ULL;
+            value.groupKeySet.epochKey1.SetNonNull();
+            value.groupKeySet.epochKey1.Value() =
+                chip::ByteSpan(chip::Uint8::from_const_char("\260garbage: not in length on purpose"), 1);
+            value.groupKeySet.epochStartTime1.SetNonNull();
+            value.groupKeySet.epochStartTime1.Value() = 1110001ULL;
+            value.groupKeySet.epochKey2.SetNull();
+            value.groupKeySet.epochStartTime2.SetNull();
+
+            return SendCommand(kIdentityAlpha, GetEndpoint(0), GroupKeyManagement::Id,
+                               GroupKeyManagement::Commands::KeySetWrite::Id, value, chip::NullOptional
+
+            );
+        }
+        case 14: {
+            LogStep(14, "KeySetWrite with EpochKey1 with length 0 != 16 fails with CONSTRAINT_ERROR");
+            ListFreer listFreer;
+            chip::app::Clusters::GroupKeyManagement::Commands::KeySetWrite::Type value;
+
+            value.groupKeySet.groupKeySetID = 417U;
+            value.groupKeySet.groupKeySecurityPolicy =
+                static_cast<chip::app::Clusters::GroupKeyManagement::GroupKeySecurityPolicyEnum>(0);
+            value.groupKeySet.epochKey0.SetNonNull();
+            value.groupKeySet.epochKey0.Value() = chip::ByteSpan(
+                chip::Uint8::from_const_char(
+                    "\240\241\242\243\244\245\246\247\250\251\252\253\254\255\256\257garbage: not in length on purpose"),
+                16);
+            value.groupKeySet.epochStartTime0.SetNonNull();
+            value.groupKeySet.epochStartTime0.Value() = 1110000ULL;
+            value.groupKeySet.epochKey1.SetNonNull();
+            value.groupKeySet.epochKey1.Value() =
+                chip::ByteSpan(chip::Uint8::from_const_char("garbage: not in length on purpose"), 0);
+            value.groupKeySet.epochStartTime1.SetNonNull();
+            value.groupKeySet.epochStartTime1.Value() = 1110001ULL;
+            value.groupKeySet.epochKey2.SetNull();
+            value.groupKeySet.epochStartTime2.SetNull();
+
+            return SendCommand(kIdentityAlpha, GetEndpoint(0), GroupKeyManagement::Id,
+                               GroupKeyManagement::Commands::KeySetWrite::Id, value, chip::NullOptional
+
+            );
+        }
+        case 15: {
+            LogStep(15, "KeySetWrite with EpochStartTime1 not later than EpochStart0 fails with INVALID_COMMAND");
+            ListFreer listFreer;
+            chip::app::Clusters::GroupKeyManagement::Commands::KeySetWrite::Type value;
+
+            value.groupKeySet.groupKeySetID = 417U;
+            value.groupKeySet.groupKeySecurityPolicy =
+                static_cast<chip::app::Clusters::GroupKeyManagement::GroupKeySecurityPolicyEnum>(0);
+            value.groupKeySet.epochKey0.SetNonNull();
+            value.groupKeySet.epochKey0.Value() = chip::ByteSpan(
+                chip::Uint8::from_const_char(
+                    "\240\241\242\243\244\245\246\247\250\251\252\253\254\255\256\257garbage: not in length on purpose"),
+                16);
+            value.groupKeySet.epochStartTime0.SetNonNull();
+            value.groupKeySet.epochStartTime0.Value() = 1110000ULL;
+            value.groupKeySet.epochKey1.SetNonNull();
+            value.groupKeySet.epochKey1.Value() = chip::ByteSpan(
+                chip::Uint8::from_const_char(
+                    "\260\261\262\263\264\265\266\267\270\271\272\273\274\275\276\277garbage: not in length on purpose"),
+                16);
+            value.groupKeySet.epochStartTime1.SetNonNull();
+            value.groupKeySet.epochStartTime1.Value() = 1ULL;
+            value.groupKeySet.epochKey2.SetNull();
+            value.groupKeySet.epochStartTime2.SetNull();
+
+            return SendCommand(kIdentityAlpha, GetEndpoint(0), GroupKeyManagement::Id,
+                               GroupKeyManagement::Commands::KeySetWrite::Id, value, chip::NullOptional
+
+            );
+        }
+        case 16: {
+            LogStep(16, "KeySetWrite with EpochStartTime2 null fails INVALID_COMMAND");
+            ListFreer listFreer;
+            chip::app::Clusters::GroupKeyManagement::Commands::KeySetWrite::Type value;
+
+            value.groupKeySet.groupKeySetID = 417U;
+            value.groupKeySet.groupKeySecurityPolicy =
+                static_cast<chip::app::Clusters::GroupKeyManagement::GroupKeySecurityPolicyEnum>(0);
+            value.groupKeySet.epochKey0.SetNonNull();
+            value.groupKeySet.epochKey0.Value() = chip::ByteSpan(
+                chip::Uint8::from_const_char(
+                    "\240\241\242\243\244\245\246\247\250\251\252\253\254\255\256\257garbage: not in length on purpose"),
+                16);
+            value.groupKeySet.epochStartTime0.SetNonNull();
+            value.groupKeySet.epochStartTime0.Value() = 1110000ULL;
+            value.groupKeySet.epochKey1.SetNonNull();
+            value.groupKeySet.epochKey1.Value() = chip::ByteSpan(
+                chip::Uint8::from_const_char(
+                    "\260\261\262\263\264\265\266\267\270\271\272\273\274\275\276\277garbage: not in length on purpose"),
+                16);
+            value.groupKeySet.epochStartTime1.SetNonNull();
+            value.groupKeySet.epochStartTime1.Value() = 1110001ULL;
+            value.groupKeySet.epochKey2.SetNonNull();
+            value.groupKeySet.epochKey2.Value() = chip::ByteSpan(
+                chip::Uint8::from_const_char(
+                    "\360\361\362\363\364\365\366\367\370\371\372\373\374\375\376\377garbage: not in length on purpose"),
+                16);
+            value.groupKeySet.epochStartTime2.SetNull();
+
+            return SendCommand(kIdentityAlpha, GetEndpoint(0), GroupKeyManagement::Id,
+                               GroupKeyManagement::Commands::KeySetWrite::Id, value, chip::NullOptional
+
+            );
+        }
+        case 17: {
+            LogStep(17, "KeySetWrite with EpochKey2 null fails INVALID_COMMAND");
+            ListFreer listFreer;
+            chip::app::Clusters::GroupKeyManagement::Commands::KeySetWrite::Type value;
+
+            value.groupKeySet.groupKeySetID = 417U;
+            value.groupKeySet.groupKeySecurityPolicy =
+                static_cast<chip::app::Clusters::GroupKeyManagement::GroupKeySecurityPolicyEnum>(0);
+            value.groupKeySet.epochKey0.SetNonNull();
+            value.groupKeySet.epochKey0.Value() = chip::ByteSpan(
+                chip::Uint8::from_const_char(
+                    "\240\241\242\243\244\245\246\247\250\251\252\253\254\255\256\257garbage: not in length on purpose"),
+                16);
+            value.groupKeySet.epochStartTime0.SetNonNull();
+            value.groupKeySet.epochStartTime0.Value() = 1110000ULL;
+            value.groupKeySet.epochKey1.SetNonNull();
+            value.groupKeySet.epochKey1.Value() = chip::ByteSpan(
+                chip::Uint8::from_const_char(
+                    "\260\261\262\263\264\265\266\267\270\271\272\273\274\275\276\277garbage: not in length on purpose"),
+                16);
+            value.groupKeySet.epochStartTime1.SetNonNull();
+            value.groupKeySet.epochStartTime1.Value() = 1110001ULL;
+            value.groupKeySet.epochKey2.SetNull();
+            value.groupKeySet.epochStartTime2.SetNonNull();
+            value.groupKeySet.epochStartTime2.Value() = 1110002ULL;
+
+            return SendCommand(kIdentityAlpha, GetEndpoint(0), GroupKeyManagement::Id,
+                               GroupKeyManagement::Commands::KeySetWrite::Id, value, chip::NullOptional
+
+            );
+        }
+        case 18: {
+            LogStep(18, "KeySetWrite with EpochKey2 with length 1 != 16 fails with CONSTRAINT_ERROR");
+            ListFreer listFreer;
+            chip::app::Clusters::GroupKeyManagement::Commands::KeySetWrite::Type value;
+
+            value.groupKeySet.groupKeySetID = 417U;
+            value.groupKeySet.groupKeySecurityPolicy =
+                static_cast<chip::app::Clusters::GroupKeyManagement::GroupKeySecurityPolicyEnum>(0);
+            value.groupKeySet.epochKey0.SetNonNull();
+            value.groupKeySet.epochKey0.Value() = chip::ByteSpan(
+                chip::Uint8::from_const_char(
+                    "\240\241\242\243\244\245\246\247\250\251\252\253\254\255\256\257garbage: not in length on purpose"),
+                16);
+            value.groupKeySet.epochStartTime0.SetNonNull();
+            value.groupKeySet.epochStartTime0.Value() = 1110000ULL;
+            value.groupKeySet.epochKey1.SetNonNull();
+            value.groupKeySet.epochKey1.Value() = chip::ByteSpan(
+                chip::Uint8::from_const_char(
+                    "\260\261\262\263\264\265\266\267\270\271\272\273\274\275\276\277garbage: not in length on purpose"),
+                16);
+            value.groupKeySet.epochStartTime1.SetNonNull();
+            value.groupKeySet.epochStartTime1.Value() = 1110001ULL;
+            value.groupKeySet.epochKey2.SetNonNull();
+            value.groupKeySet.epochKey2.Value() =
+                chip::ByteSpan(chip::Uint8::from_const_char("\300garbage: not in length on purpose"), 1);
+            value.groupKeySet.epochStartTime2.SetNonNull();
+            value.groupKeySet.epochStartTime2.Value() = 1110002ULL;
+
+            return SendCommand(kIdentityAlpha, GetEndpoint(0), GroupKeyManagement::Id,
+                               GroupKeyManagement::Commands::KeySetWrite::Id, value, chip::NullOptional
+
+            );
+        }
+        case 19: {
+            LogStep(19, "KeySetWrite with EpochKey2 with length 0 != 16 fails with CONSTRAINT_ERROR");
+            ListFreer listFreer;
+            chip::app::Clusters::GroupKeyManagement::Commands::KeySetWrite::Type value;
+
+            value.groupKeySet.groupKeySetID = 417U;
+            value.groupKeySet.groupKeySecurityPolicy =
+                static_cast<chip::app::Clusters::GroupKeyManagement::GroupKeySecurityPolicyEnum>(0);
+            value.groupKeySet.epochKey0.SetNonNull();
+            value.groupKeySet.epochKey0.Value() = chip::ByteSpan(
+                chip::Uint8::from_const_char(
+                    "\240\241\242\243\244\245\246\247\250\251\252\253\254\255\256\257garbage: not in length on purpose"),
+                16);
+            value.groupKeySet.epochStartTime0.SetNonNull();
+            value.groupKeySet.epochStartTime0.Value() = 1110000ULL;
+            value.groupKeySet.epochKey1.SetNonNull();
+            value.groupKeySet.epochKey1.Value() = chip::ByteSpan(
+                chip::Uint8::from_const_char(
+                    "\260\261\262\263\264\265\266\267\270\271\272\273\274\275\276\277garbage: not in length on purpose"),
+                16);
+            value.groupKeySet.epochStartTime1.SetNonNull();
+            value.groupKeySet.epochStartTime1.Value() = 1110001ULL;
+            value.groupKeySet.epochKey2.SetNonNull();
+            value.groupKeySet.epochKey2.Value() =
+                chip::ByteSpan(chip::Uint8::from_const_char("garbage: not in length on purpose"), 0);
+            value.groupKeySet.epochStartTime2.SetNonNull();
+            value.groupKeySet.epochStartTime2.Value() = 1110002ULL;
+
+            return SendCommand(kIdentityAlpha, GetEndpoint(0), GroupKeyManagement::Id,
+                               GroupKeyManagement::Commands::KeySetWrite::Id, value, chip::NullOptional
+
+            );
+        }
+        case 20: {
+            LogStep(20, "KeySetWrite with EpochStartTime2 not later than EpochStart1 fails with INVALID_COMMAND");
+            ListFreer listFreer;
+            chip::app::Clusters::GroupKeyManagement::Commands::KeySetWrite::Type value;
+
+            value.groupKeySet.groupKeySetID = 417U;
+            value.groupKeySet.groupKeySecurityPolicy =
+                static_cast<chip::app::Clusters::GroupKeyManagement::GroupKeySecurityPolicyEnum>(0);
+            value.groupKeySet.epochKey0.SetNonNull();
+            value.groupKeySet.epochKey0.Value() = chip::ByteSpan(
+                chip::Uint8::from_const_char(
+                    "\240\241\242\243\244\245\246\247\250\251\252\253\254\255\256\257garbage: not in length on purpose"),
+                16);
+            value.groupKeySet.epochStartTime0.SetNonNull();
+            value.groupKeySet.epochStartTime0.Value() = 1110000ULL;
+            value.groupKeySet.epochKey1.SetNonNull();
+            value.groupKeySet.epochKey1.Value() = chip::ByteSpan(
+                chip::Uint8::from_const_char(
+                    "\260\261\262\263\264\265\266\267\270\271\272\273\274\275\276\277garbage: not in length on purpose"),
+                16);
+            value.groupKeySet.epochStartTime1.SetNonNull();
+            value.groupKeySet.epochStartTime1.Value() = 1110001ULL;
+            value.groupKeySet.epochKey2.SetNonNull();
+            value.groupKeySet.epochKey2.Value() = chip::ByteSpan(
+                chip::Uint8::from_const_char(
+                    "\360\361\362\363\364\365\366\367\370\371\372\373\374\375\376\377garbage: not in length on purpose"),
+                16);
+            value.groupKeySet.epochStartTime2.SetNonNull();
+            value.groupKeySet.epochStartTime2.Value() = 100ULL;
+
+            return SendCommand(kIdentityAlpha, GetEndpoint(0), GroupKeyManagement::Id,
+                               GroupKeyManagement::Commands::KeySetWrite::Id, value, chip::NullOptional
+
+            );
+        }
+        case 21: {
+            LogStep(21, "KeySet Write 1");
             ListFreer listFreer;
             chip::app::Clusters::GroupKeyManagement::Commands::KeySetWrite::Type value;
 
@@ -114258,8 +114726,8 @@
 
             );
         }
-        case 7: {
-            LogStep(7, "KeySet Write 2 CacheAndSync");
+        case 22: {
+            LogStep(22, "KeySet Write 2 CacheAndSync");
             VerifyOrDo(!ShouldSkip("GRPKEY.S.F00"), return ContinueOnChipMainThread(CHIP_NO_ERROR));
             ListFreer listFreer;
             chip::app::Clusters::GroupKeyManagement::Commands::KeySetWrite::Type value;
@@ -114294,8 +114762,8 @@
 
             );
         }
-        case 8: {
-            LogStep(8, "KeySet Write 2 TrustFirst");
+        case 23: {
+            LogStep(23, "KeySet Write 2 TrustFirst");
             VerifyOrDo(!ShouldSkip("!GRPKEY.S.F00"), return ContinueOnChipMainThread(CHIP_NO_ERROR));
             ListFreer listFreer;
             chip::app::Clusters::GroupKeyManagement::Commands::KeySetWrite::Type value;
@@ -114330,8 +114798,8 @@
 
             );
         }
-        case 9: {
-            LogStep(9, "KeySet Write 3 CacheAndSync");
+        case 24: {
+            LogStep(24, "KeySet Write 3 CacheAndSync");
             VerifyOrDo(!ShouldSkip("GRPKEY.S.F00"), return ContinueOnChipMainThread(CHIP_NO_ERROR));
             ListFreer listFreer;
             chip::app::Clusters::GroupKeyManagement::Commands::KeySetWrite::Type value;
@@ -114364,8 +114832,8 @@
 
             );
         }
-        case 10: {
-            LogStep(10, "KeySet Write 3 TrustFirst");
+        case 25: {
+            LogStep(25, "KeySet Write 3 TrustFirst");
             VerifyOrDo(!ShouldSkip("!GRPKEY.S.F00"), return ContinueOnChipMainThread(CHIP_NO_ERROR));
             ListFreer listFreer;
             chip::app::Clusters::GroupKeyManagement::Commands::KeySetWrite::Type value;
@@ -114398,8 +114866,8 @@
 
             );
         }
-        case 11: {
-            LogStep(11, "KeySet Read");
+        case 26: {
+            LogStep(26, "KeySet Read");
             ListFreer listFreer;
             chip::app::Clusters::GroupKeyManagement::Commands::KeySetRead::Type value;
             value.groupKeySetID = 417U;
@@ -114408,8 +114876,8 @@
 
             );
         }
-        case 12: {
-            LogStep(12, "KeySet Read All Indices");
+        case 27: {
+            LogStep(27, "KeySet Read All Indices");
             ListFreer listFreer;
             chip::app::Clusters::GroupKeyManagement::Commands::KeySetReadAllIndices::Type value;
             return SendCommand(kIdentityAlpha, GetEndpoint(0), GroupKeyManagement::Id,
@@ -114417,8 +114885,8 @@
 
             );
         }
-        case 13: {
-            LogStep(13, "Write Group Keys (invalid)");
+        case 28: {
+            LogStep(28, "Write Group Keys (invalid)");
             ListFreer listFreer;
             chip::app::DataModel::List<const chip::app::Clusters::GroupKeyManagement::Structs::GroupKeyMapStruct::Type> value;
 
@@ -114436,8 +114904,8 @@
             return WriteAttribute(kIdentityAlpha, GetEndpoint(0), GroupKeyManagement::Id,
                                   GroupKeyManagement::Attributes::GroupKeyMap::Id, value, chip::NullOptional, chip::NullOptional);
         }
-        case 14: {
-            LogStep(14, "Write Group Keys (too many)");
+        case 29: {
+            LogStep(29, "Write Group Keys (too many)");
             ListFreer listFreer;
             chip::app::DataModel::List<const chip::app::Clusters::GroupKeyManagement::Structs::GroupKeyMapStruct::Type> value;
 
@@ -114507,8 +114975,8 @@
             return WriteAttribute(kIdentityAlpha, GetEndpoint(0), GroupKeyManagement::Id,
                                   GroupKeyManagement::Attributes::GroupKeyMap::Id, value, chip::NullOptional, chip::NullOptional);
         }
-        case 15: {
-            LogStep(15, "Write Group Keys on alpha");
+        case 30: {
+            LogStep(30, "Write Group Keys on alpha");
             ListFreer listFreer;
             chip::app::DataModel::List<const chip::app::Clusters::GroupKeyManagement::Structs::GroupKeyMapStruct::Type> value;
 
@@ -114538,8 +115006,8 @@
             return WriteAttribute(kIdentityAlpha, GetEndpoint(0), GroupKeyManagement::Id,
                                   GroupKeyManagement::Attributes::GroupKeyMap::Id, value, chip::NullOptional, chip::NullOptional);
         }
-        case 16: {
-            LogStep(16, "Write Group Keys on beta");
+        case 31: {
+            LogStep(31, "Write Group Keys on beta");
             ListFreer listFreer;
             chip::app::DataModel::List<const chip::app::Clusters::GroupKeyManagement::Structs::GroupKeyMapStruct::Type> value;
 
@@ -114569,28 +115037,28 @@
             return WriteAttribute(kIdentityBeta, GetEndpoint(0), GroupKeyManagement::Id,
                                   GroupKeyManagement::Attributes::GroupKeyMap::Id, value, chip::NullOptional, chip::NullOptional);
         }
-        case 17: {
-            LogStep(17, "Read Group Keys on alpha");
+        case 32: {
+            LogStep(32, "Read Group Keys on alpha");
             return ReadAttribute(kIdentityAlpha, GetEndpoint(0), GroupKeyManagement::Id,
                                  GroupKeyManagement::Attributes::GroupKeyMap::Id, true, chip::NullOptional);
         }
-        case 18: {
-            LogStep(18, "Read Group Keys on alpha without fabric filtering");
+        case 33: {
+            LogStep(33, "Read Group Keys on alpha without fabric filtering");
             return ReadAttribute(kIdentityAlpha, GetEndpoint(0), GroupKeyManagement::Id,
                                  GroupKeyManagement::Attributes::GroupKeyMap::Id, false, chip::NullOptional);
         }
-        case 19: {
-            LogStep(19, "Read Group Keys on beta");
+        case 34: {
+            LogStep(34, "Read Group Keys on beta");
             return ReadAttribute(kIdentityBeta, GetEndpoint(0), GroupKeyManagement::Id,
                                  GroupKeyManagement::Attributes::GroupKeyMap::Id, true, chip::NullOptional);
         }
-        case 20: {
-            LogStep(20, "Read Group Keys on beta without fabric filtering");
+        case 35: {
+            LogStep(35, "Read Group Keys on beta without fabric filtering");
             return ReadAttribute(kIdentityBeta, GetEndpoint(0), GroupKeyManagement::Id,
                                  GroupKeyManagement::Attributes::GroupKeyMap::Id, false, chip::NullOptional);
         }
-        case 21: {
-            LogStep(21, "Add Group 1");
+        case 36: {
+            LogStep(36, "Add Group 1");
             ListFreer listFreer;
             chip::app::Clusters::Groups::Commands::AddGroup::Type value;
             value.groupID   = 257U;
@@ -114599,8 +115067,8 @@
 
             );
         }
-        case 22: {
-            LogStep(22, "Add Group 2");
+        case 37: {
+            LogStep(37, "Add Group 2");
             ListFreer listFreer;
             chip::app::Clusters::Groups::Commands::AddGroup::Type value;
             value.groupID   = 258U;
@@ -114609,8 +115077,8 @@
 
             );
         }
-        case 23: {
-            LogStep(23, "Add Group 3");
+        case 38: {
+            LogStep(38, "Add Group 3");
             ListFreer listFreer;
             chip::app::Clusters::Groups::Commands::AddGroup::Type value;
             value.groupID   = 259U;
@@ -114619,8 +115087,8 @@
 
             );
         }
-        case 24: {
-            LogStep(24, "Add Group 4");
+        case 39: {
+            LogStep(39, "Add Group 4");
             ListFreer listFreer;
             chip::app::Clusters::Groups::Commands::AddGroup::Type value;
             value.groupID   = 260U;
@@ -114629,8 +115097,8 @@
 
             );
         }
-        case 25: {
-            LogStep(25, "Add Group 5");
+        case 40: {
+            LogStep(40, "Add Group 5");
             ListFreer listFreer;
             chip::app::Clusters::Groups::Commands::AddGroup::Type value;
             value.groupID   = 261U;
@@ -114639,28 +115107,28 @@
 
             );
         }
-        case 26: {
-            LogStep(26, "Read GroupTable from alpha");
+        case 41: {
+            LogStep(41, "Read GroupTable from alpha");
             return ReadAttribute(kIdentityAlpha, GetEndpoint(0), GroupKeyManagement::Id,
                                  GroupKeyManagement::Attributes::GroupTable::Id, true, chip::NullOptional);
         }
-        case 27: {
-            LogStep(27, "Read GroupTable from alpha without fabric filtering");
+        case 42: {
+            LogStep(42, "Read GroupTable from alpha without fabric filtering");
             return ReadAttribute(kIdentityAlpha, GetEndpoint(0), GroupKeyManagement::Id,
                                  GroupKeyManagement::Attributes::GroupTable::Id, false, chip::NullOptional);
         }
-        case 28: {
-            LogStep(28, "Read GroupTable from beta");
+        case 43: {
+            LogStep(43, "Read GroupTable from beta");
             return ReadAttribute(kIdentityBeta, GetEndpoint(0), GroupKeyManagement::Id,
                                  GroupKeyManagement::Attributes::GroupTable::Id, true, chip::NullOptional);
         }
-        case 29: {
-            LogStep(29, "Read GroupTable from beta without fabric filtering");
+        case 44: {
+            LogStep(44, "Read GroupTable from beta without fabric filtering");
             return ReadAttribute(kIdentityBeta, GetEndpoint(0), GroupKeyManagement::Id,
                                  GroupKeyManagement::Attributes::GroupTable::Id, false, chip::NullOptional);
         }
-        case 30: {
-            LogStep(30, "KeySet Remove 1");
+        case 45: {
+            LogStep(45, "KeySet Remove 1");
             ListFreer listFreer;
             chip::app::Clusters::GroupKeyManagement::Commands::KeySetRemove::Type value;
             value.groupKeySetID = 417U;
@@ -114669,8 +115137,8 @@
 
             );
         }
-        case 31: {
-            LogStep(31, "KeySet Read (removed)");
+        case 46: {
+            LogStep(46, "KeySet Read (removed)");
             ListFreer listFreer;
             chip::app::Clusters::GroupKeyManagement::Commands::KeySetRead::Type value;
             value.groupKeySetID = 417U;
@@ -114679,8 +115147,8 @@
 
             );
         }
-        case 32: {
-            LogStep(32, "KeySet Read (not removed) CacheAndSync");
+        case 47: {
+            LogStep(47, "KeySet Read (not removed) CacheAndSync");
             VerifyOrDo(!ShouldSkip("GRPKEY.S.F00"), return ContinueOnChipMainThread(CHIP_NO_ERROR));
             ListFreer listFreer;
             chip::app::Clusters::GroupKeyManagement::Commands::KeySetRead::Type value;
@@ -114690,8 +115158,8 @@
 
             );
         }
-        case 33: {
-            LogStep(33, "KeySet Read (not removed) TrustFirst");
+        case 48: {
+            LogStep(48, "KeySet Read (not removed) TrustFirst");
             VerifyOrDo(!ShouldSkip("GRPKEY.S.F00"), return ContinueOnChipMainThread(CHIP_NO_ERROR));
             ListFreer listFreer;
             chip::app::Clusters::GroupKeyManagement::Commands::KeySetRead::Type value;
@@ -114701,8 +115169,8 @@
 
             );
         }
-        case 34: {
-            LogStep(34, "Remove Group 1");
+        case 49: {
+            LogStep(49, "Remove Group 1");
             ListFreer listFreer;
             chip::app::Clusters::Groups::Commands::RemoveGroup::Type value;
             value.groupID = 257U;
@@ -114711,13 +115179,13 @@
 
             );
         }
-        case 35: {
-            LogStep(35, "Read GroupTable 2");
+        case 50: {
+            LogStep(50, "Read GroupTable 2");
             return ReadAttribute(kIdentityAlpha, GetEndpoint(0), GroupKeyManagement::Id,
                                  GroupKeyManagement::Attributes::GroupTable::Id, true, chip::NullOptional);
         }
-        case 36: {
-            LogStep(36, "Remove All");
+        case 51: {
+            LogStep(51, "Remove All");
             ListFreer listFreer;
             chip::app::Clusters::Groups::Commands::RemoveAllGroups::Type value;
             return SendCommand(kIdentityAlpha, GetEndpoint(1), Groups::Id, Groups::Commands::RemoveAllGroups::Id, value,
@@ -114725,13 +115193,13 @@
 
             );
         }
-        case 37: {
-            LogStep(37, "Read GroupTable 3");
+        case 52: {
+            LogStep(52, "Read GroupTable 3");
             return ReadAttribute(kIdentityAlpha, GetEndpoint(0), GroupKeyManagement::Id,
                                  GroupKeyManagement::Attributes::GroupTable::Id, true, chip::NullOptional);
         }
-        case 38: {
-            LogStep(38, "KeySet Remove 2");
+        case 53: {
+            LogStep(53, "KeySet Remove 2");
             ListFreer listFreer;
             chip::app::Clusters::GroupKeyManagement::Commands::KeySetRemove::Type value;
             value.groupKeySetID = 418U;
@@ -114740,8 +115208,8 @@
 
             );
         }
-        case 39: {
-            LogStep(39, "KeySet Read (also removed)");
+        case 54: {
+            LogStep(54, "KeySet Read (also removed)");
             ListFreer listFreer;
             chip::app::Clusters::GroupKeyManagement::Commands::KeySetRead::Type value;
             value.groupKeySetID = 418U;
@@ -114750,8 +115218,8 @@
 
             );
         }
-        case 40: {
-            LogStep(40, "KeySet Write 1");
+        case 55: {
+            LogStep(55, "KeySet Write 1");
             ListFreer listFreer;
             chip::app::Clusters::GroupKeyManagement::Commands::KeySetWrite::Type value;
 
@@ -114785,8 +115253,8 @@
 
             );
         }
-        case 41: {
-            LogStep(41, "KeySet Write 2 CacheAndSync");
+        case 56: {
+            LogStep(56, "KeySet Write 2 CacheAndSync");
             VerifyOrDo(!ShouldSkip("GRPKEY.S.F00"), return ContinueOnChipMainThread(CHIP_NO_ERROR));
             ListFreer listFreer;
             chip::app::Clusters::GroupKeyManagement::Commands::KeySetWrite::Type value;
@@ -114821,8 +115289,8 @@
 
             );
         }
-        case 42: {
-            LogStep(42, "KeySet Write 2 TrustFirst");
+        case 57: {
+            LogStep(57, "KeySet Write 2 TrustFirst");
             VerifyOrDo(!ShouldSkip("!GRPKEY.S.F00"), return ContinueOnChipMainThread(CHIP_NO_ERROR));
             ListFreer listFreer;
             chip::app::Clusters::GroupKeyManagement::Commands::KeySetWrite::Type value;
@@ -114857,8 +115325,8 @@
 
             );
         }
-        case 43: {
-            LogStep(43, "Map Group 1 and Group 2 to KeySet 1 and group 2 to KeySet 2");
+        case 58: {
+            LogStep(58, "Map Group 1 and Group 2 to KeySet 1 and group 2 to KeySet 2");
             ListFreer listFreer;
             chip::app::DataModel::List<const chip::app::Clusters::GroupKeyManagement::Structs::GroupKeyMapStruct::Type> value;
 
@@ -114884,8 +115352,8 @@
             return WriteAttribute(kIdentityAlpha, GetEndpoint(0), GroupKeyManagement::Id,
                                   GroupKeyManagement::Attributes::GroupKeyMap::Id, value, chip::NullOptional, chip::NullOptional);
         }
-        case 44: {
-            LogStep(44, "Remove keyset 1");
+        case 59: {
+            LogStep(59, "Remove keyset 1");
             ListFreer listFreer;
             chip::app::Clusters::GroupKeyManagement::Commands::KeySetRemove::Type value;
             value.groupKeySetID = 417U;
@@ -114894,13 +115362,13 @@
 
             );
         }
-        case 45: {
-            LogStep(45, "TH verifies GroupKeyMap entries for KeySet 1 have been removed");
+        case 60: {
+            LogStep(60, "TH verifies GroupKeyMap entries for KeySet 1 have been removed");
             return ReadAttribute(kIdentityAlpha, GetEndpoint(0), GroupKeyManagement::Id,
                                  GroupKeyManagement::Attributes::GroupKeyMap::Id, true, chip::NullOptional);
         }
-        case 46: {
-            LogStep(46, "Remove keyset 2");
+        case 61: {
+            LogStep(61, "Remove keyset 2");
             ListFreer listFreer;
             chip::app::Clusters::GroupKeyManagement::Commands::KeySetRemove::Type value;
             value.groupKeySetID = 418U;
@@ -114909,8 +115377,8 @@
 
             );
         }
-        case 47: {
-            LogStep(47, "TH verifies GroupKeyMap entries for KeySet 2 have been removed");
+        case 62: {
+            LogStep(62, "TH verifies GroupKeyMap entries for KeySet 2 have been removed");
             return ReadAttribute(kIdentityAlpha, GetEndpoint(0), GroupKeyManagement::Id,
                                  GroupKeyManagement::Attributes::GroupKeyMap::Id, true, chip::NullOptional);
         }
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 a7e81dc..5acafa1 100644
--- a/zzz_generated/darwin-framework-tool/zap-generated/test/Commands.h
+++ b/zzz_generated/darwin-framework-tool/zap-generated/test/Commands.h
@@ -175716,204 +175716,272 @@
             err = TestReadMaxGroupKeysPerFabric_5();
             break;
         case 6:
-            ChipLogProgress(chipTool, " ***** Test Step 6 : KeySet Write 1\n");
-            err = TestKeySetWrite1_6();
+            ChipLogProgress(chipTool, " ***** Test Step 6 : KeySetWrite with EpochKey0 null fails INVALID_COMMAND\n");
+            err = TestKeySetWriteWithEpochKey0NullFailsInvalidCommand_6();
             break;
         case 7:
-            ChipLogProgress(chipTool, " ***** Test Step 7 : KeySet Write 2 CacheAndSync\n");
-            if (ShouldSkip("GRPKEY.S.F00")) {
-                NextTest();
-                return;
-            }
-            err = TestKeySetWrite2CacheAndSync_7();
+            ChipLogProgress(chipTool, " ***** Test Step 7 : KeySetWrite with EpochStartTime0 null fails INVALID_COMMAND\n");
+            err = TestKeySetWriteWithEpochStartTime0NullFailsInvalidCommand_7();
             break;
         case 8:
-            ChipLogProgress(chipTool, " ***** Test Step 8 : KeySet Write 2 TrustFirst\n");
-            if (ShouldSkip("!GRPKEY.S.F00")) {
-                NextTest();
-                return;
-            }
-            err = TestKeySetWrite2TrustFirst_8();
+            ChipLogProgress(chipTool, " ***** Test Step 8 : KeySetWrite with EpochStartTime0 set to zero fails INVALID_COMMAND\n");
+            err = TestKeySetWriteWithEpochStartTime0SetToZeroFailsInvalidCommand_8();
             break;
         case 9:
-            ChipLogProgress(chipTool, " ***** Test Step 9 : KeySet Write 3 CacheAndSync\n");
-            if (ShouldSkip("GRPKEY.S.F00")) {
-                NextTest();
-                return;
-            }
-            err = TestKeySetWrite3CacheAndSync_9();
+            ChipLogProgress(
+                chipTool, " ***** Test Step 9 : KeySetWrite with EpochKey0 with length 1 != 16 fails with CONSTRAINT_ERROR\n");
+            err = TestKeySetWriteWithEpochKey0WithLength116FailsWithConstraintError_9();
             break;
         case 10:
-            ChipLogProgress(chipTool, " ***** Test Step 10 : KeySet Write 3 TrustFirst\n");
-            if (ShouldSkip("!GRPKEY.S.F00")) {
-                NextTest();
-                return;
-            }
-            err = TestKeySetWrite3TrustFirst_10();
+            ChipLogProgress(
+                chipTool, " ***** Test Step 10 : KeySetWrite with EpochKey0 with length 0 != 16 fails with CONSTRAINT_ERROR\n");
+            err = TestKeySetWriteWithEpochKey0WithLength016FailsWithConstraintError_10();
             break;
         case 11:
-            ChipLogProgress(chipTool, " ***** Test Step 11 : KeySet Read\n");
-            err = TestKeySetRead_11();
+            ChipLogProgress(chipTool, " ***** Test Step 11 : KeySetWrite with EpochStartTime1 null fails INVALID_COMMAND\n");
+            err = TestKeySetWriteWithEpochStartTime1NullFailsInvalidCommand_11();
             break;
         case 12:
-            ChipLogProgress(chipTool, " ***** Test Step 12 : KeySet Read All Indices\n");
-            err = TestKeySetReadAllIndices_12();
+            ChipLogProgress(chipTool, " ***** Test Step 12 : KeySetWrite with EpochKey1 null fails INVALID_COMMAND\n");
+            err = TestKeySetWriteWithEpochKey1NullFailsInvalidCommand_12();
             break;
         case 13:
-            ChipLogProgress(chipTool, " ***** Test Step 13 : Write Group Keys (invalid)\n");
-            err = TestWriteGroupKeysInvalid_13();
+            ChipLogProgress(
+                chipTool, " ***** Test Step 13 : KeySetWrite with EpochKey1 with length 1 != 16 fails with CONSTRAINT_ERROR\n");
+            err = TestKeySetWriteWithEpochKey1WithLength116FailsWithConstraintError_13();
             break;
         case 14:
-            ChipLogProgress(chipTool, " ***** Test Step 14 : Write Group Keys (too many)\n");
-            err = TestWriteGroupKeysTooMany_14();
+            ChipLogProgress(
+                chipTool, " ***** Test Step 14 : KeySetWrite with EpochKey1 with length 0 != 16 fails with CONSTRAINT_ERROR\n");
+            err = TestKeySetWriteWithEpochKey1WithLength016FailsWithConstraintError_14();
             break;
         case 15:
-            ChipLogProgress(chipTool, " ***** Test Step 15 : Write Group Keys on alpha\n");
-            err = TestWriteGroupKeysOnAlpha_15();
+            ChipLogProgress(chipTool,
+                " ***** Test Step 15 : KeySetWrite with EpochStartTime1 not later than EpochStart0 fails with INVALID_COMMAND\n");
+            err = TestKeySetWriteWithEpochStartTime1NotLaterThanEpochStart0FailsWithInvalidCommand_15();
             break;
         case 16:
-            ChipLogProgress(chipTool, " ***** Test Step 16 : Write Group Keys on beta\n");
-            err = TestWriteGroupKeysOnBeta_16();
+            ChipLogProgress(chipTool, " ***** Test Step 16 : KeySetWrite with EpochStartTime2 null fails INVALID_COMMAND\n");
+            err = TestKeySetWriteWithEpochStartTime2NullFailsInvalidCommand_16();
             break;
         case 17:
-            ChipLogProgress(chipTool, " ***** Test Step 17 : Read Group Keys on alpha\n");
-            err = TestReadGroupKeysOnAlpha_17();
+            ChipLogProgress(chipTool, " ***** Test Step 17 : KeySetWrite with EpochKey2 null fails INVALID_COMMAND\n");
+            err = TestKeySetWriteWithEpochKey2NullFailsInvalidCommand_17();
             break;
         case 18:
-            ChipLogProgress(chipTool, " ***** Test Step 18 : Read Group Keys on alpha without fabric filtering\n");
-            err = TestReadGroupKeysOnAlphaWithoutFabricFiltering_18();
+            ChipLogProgress(
+                chipTool, " ***** Test Step 18 : KeySetWrite with EpochKey2 with length 1 != 16 fails with CONSTRAINT_ERROR\n");
+            err = TestKeySetWriteWithEpochKey2WithLength116FailsWithConstraintError_18();
             break;
         case 19:
-            ChipLogProgress(chipTool, " ***** Test Step 19 : Read Group Keys on beta\n");
-            err = TestReadGroupKeysOnBeta_19();
+            ChipLogProgress(
+                chipTool, " ***** Test Step 19 : KeySetWrite with EpochKey2 with length 0 != 16 fails with CONSTRAINT_ERROR\n");
+            err = TestKeySetWriteWithEpochKey2WithLength016FailsWithConstraintError_19();
             break;
         case 20:
-            ChipLogProgress(chipTool, " ***** Test Step 20 : Read Group Keys on beta without fabric filtering\n");
-            err = TestReadGroupKeysOnBetaWithoutFabricFiltering_20();
+            ChipLogProgress(chipTool,
+                " ***** Test Step 20 : KeySetWrite with EpochStartTime2 not later than EpochStart1 fails with INVALID_COMMAND\n");
+            err = TestKeySetWriteWithEpochStartTime2NotLaterThanEpochStart1FailsWithInvalidCommand_20();
             break;
         case 21:
-            ChipLogProgress(chipTool, " ***** Test Step 21 : Add Group 1\n");
-            err = TestAddGroup1_21();
+            ChipLogProgress(chipTool, " ***** Test Step 21 : KeySet Write 1\n");
+            err = TestKeySetWrite1_21();
             break;
         case 22:
-            ChipLogProgress(chipTool, " ***** Test Step 22 : Add Group 2\n");
-            err = TestAddGroup2_22();
+            ChipLogProgress(chipTool, " ***** Test Step 22 : KeySet Write 2 CacheAndSync\n");
+            if (ShouldSkip("GRPKEY.S.F00")) {
+                NextTest();
+                return;
+            }
+            err = TestKeySetWrite2CacheAndSync_22();
             break;
         case 23:
-            ChipLogProgress(chipTool, " ***** Test Step 23 : Add Group 3\n");
-            err = TestAddGroup3_23();
-            break;
-        case 24:
-            ChipLogProgress(chipTool, " ***** Test Step 24 : Add Group 4\n");
-            err = TestAddGroup4_24();
-            break;
-        case 25:
-            ChipLogProgress(chipTool, " ***** Test Step 25 : Add Group 5\n");
-            err = TestAddGroup5_25();
-            break;
-        case 26:
-            ChipLogProgress(chipTool, " ***** Test Step 26 : Read GroupTable from alpha\n");
-            err = TestReadGroupTableFromAlpha_26();
-            break;
-        case 27:
-            ChipLogProgress(chipTool, " ***** Test Step 27 : Read GroupTable from alpha without fabric filtering\n");
-            err = TestReadGroupTableFromAlphaWithoutFabricFiltering_27();
-            break;
-        case 28:
-            ChipLogProgress(chipTool, " ***** Test Step 28 : Read GroupTable from beta\n");
-            err = TestReadGroupTableFromBeta_28();
-            break;
-        case 29:
-            ChipLogProgress(chipTool, " ***** Test Step 29 : Read GroupTable from beta without fabric filtering\n");
-            err = TestReadGroupTableFromBetaWithoutFabricFiltering_29();
-            break;
-        case 30:
-            ChipLogProgress(chipTool, " ***** Test Step 30 : KeySet Remove 1\n");
-            err = TestKeySetRemove1_30();
-            break;
-        case 31:
-            ChipLogProgress(chipTool, " ***** Test Step 31 : KeySet Read (removed)\n");
-            err = TestKeySetReadRemoved_31();
-            break;
-        case 32:
-            ChipLogProgress(chipTool, " ***** Test Step 32 : KeySet Read (not removed) CacheAndSync\n");
-            if (ShouldSkip("GRPKEY.S.F00")) {
-                NextTest();
-                return;
-            }
-            err = TestKeySetReadNotRemovedCacheAndSync_32();
-            break;
-        case 33:
-            ChipLogProgress(chipTool, " ***** Test Step 33 : KeySet Read (not removed) TrustFirst\n");
-            if (ShouldSkip("GRPKEY.S.F00")) {
-                NextTest();
-                return;
-            }
-            err = TestKeySetReadNotRemovedTrustFirst_33();
-            break;
-        case 34:
-            ChipLogProgress(chipTool, " ***** Test Step 34 : Remove Group 1\n");
-            err = TestRemoveGroup1_34();
-            break;
-        case 35:
-            ChipLogProgress(chipTool, " ***** Test Step 35 : Read GroupTable 2\n");
-            err = TestReadGroupTable2_35();
-            break;
-        case 36:
-            ChipLogProgress(chipTool, " ***** Test Step 36 : Remove All\n");
-            err = TestRemoveAll_36();
-            break;
-        case 37:
-            ChipLogProgress(chipTool, " ***** Test Step 37 : Read GroupTable 3\n");
-            err = TestReadGroupTable3_37();
-            break;
-        case 38:
-            ChipLogProgress(chipTool, " ***** Test Step 38 : KeySet Remove 2\n");
-            err = TestKeySetRemove2_38();
-            break;
-        case 39:
-            ChipLogProgress(chipTool, " ***** Test Step 39 : KeySet Read (also removed)\n");
-            err = TestKeySetReadAlsoRemoved_39();
-            break;
-        case 40:
-            ChipLogProgress(chipTool, " ***** Test Step 40 : KeySet Write 1\n");
-            err = TestKeySetWrite1_40();
-            break;
-        case 41:
-            ChipLogProgress(chipTool, " ***** Test Step 41 : KeySet Write 2 CacheAndSync\n");
-            if (ShouldSkip("GRPKEY.S.F00")) {
-                NextTest();
-                return;
-            }
-            err = TestKeySetWrite2CacheAndSync_41();
-            break;
-        case 42:
-            ChipLogProgress(chipTool, " ***** Test Step 42 : KeySet Write 2 TrustFirst\n");
+            ChipLogProgress(chipTool, " ***** Test Step 23 : KeySet Write 2 TrustFirst\n");
             if (ShouldSkip("!GRPKEY.S.F00")) {
                 NextTest();
                 return;
             }
-            err = TestKeySetWrite2TrustFirst_42();
+            err = TestKeySetWrite2TrustFirst_23();
+            break;
+        case 24:
+            ChipLogProgress(chipTool, " ***** Test Step 24 : KeySet Write 3 CacheAndSync\n");
+            if (ShouldSkip("GRPKEY.S.F00")) {
+                NextTest();
+                return;
+            }
+            err = TestKeySetWrite3CacheAndSync_24();
+            break;
+        case 25:
+            ChipLogProgress(chipTool, " ***** Test Step 25 : KeySet Write 3 TrustFirst\n");
+            if (ShouldSkip("!GRPKEY.S.F00")) {
+                NextTest();
+                return;
+            }
+            err = TestKeySetWrite3TrustFirst_25();
+            break;
+        case 26:
+            ChipLogProgress(chipTool, " ***** Test Step 26 : KeySet Read\n");
+            err = TestKeySetRead_26();
+            break;
+        case 27:
+            ChipLogProgress(chipTool, " ***** Test Step 27 : KeySet Read All Indices\n");
+            err = TestKeySetReadAllIndices_27();
+            break;
+        case 28:
+            ChipLogProgress(chipTool, " ***** Test Step 28 : Write Group Keys (invalid)\n");
+            err = TestWriteGroupKeysInvalid_28();
+            break;
+        case 29:
+            ChipLogProgress(chipTool, " ***** Test Step 29 : Write Group Keys (too many)\n");
+            err = TestWriteGroupKeysTooMany_29();
+            break;
+        case 30:
+            ChipLogProgress(chipTool, " ***** Test Step 30 : Write Group Keys on alpha\n");
+            err = TestWriteGroupKeysOnAlpha_30();
+            break;
+        case 31:
+            ChipLogProgress(chipTool, " ***** Test Step 31 : Write Group Keys on beta\n");
+            err = TestWriteGroupKeysOnBeta_31();
+            break;
+        case 32:
+            ChipLogProgress(chipTool, " ***** Test Step 32 : Read Group Keys on alpha\n");
+            err = TestReadGroupKeysOnAlpha_32();
+            break;
+        case 33:
+            ChipLogProgress(chipTool, " ***** Test Step 33 : Read Group Keys on alpha without fabric filtering\n");
+            err = TestReadGroupKeysOnAlphaWithoutFabricFiltering_33();
+            break;
+        case 34:
+            ChipLogProgress(chipTool, " ***** Test Step 34 : Read Group Keys on beta\n");
+            err = TestReadGroupKeysOnBeta_34();
+            break;
+        case 35:
+            ChipLogProgress(chipTool, " ***** Test Step 35 : Read Group Keys on beta without fabric filtering\n");
+            err = TestReadGroupKeysOnBetaWithoutFabricFiltering_35();
+            break;
+        case 36:
+            ChipLogProgress(chipTool, " ***** Test Step 36 : Add Group 1\n");
+            err = TestAddGroup1_36();
+            break;
+        case 37:
+            ChipLogProgress(chipTool, " ***** Test Step 37 : Add Group 2\n");
+            err = TestAddGroup2_37();
+            break;
+        case 38:
+            ChipLogProgress(chipTool, " ***** Test Step 38 : Add Group 3\n");
+            err = TestAddGroup3_38();
+            break;
+        case 39:
+            ChipLogProgress(chipTool, " ***** Test Step 39 : Add Group 4\n");
+            err = TestAddGroup4_39();
+            break;
+        case 40:
+            ChipLogProgress(chipTool, " ***** Test Step 40 : Add Group 5\n");
+            err = TestAddGroup5_40();
+            break;
+        case 41:
+            ChipLogProgress(chipTool, " ***** Test Step 41 : Read GroupTable from alpha\n");
+            err = TestReadGroupTableFromAlpha_41();
+            break;
+        case 42:
+            ChipLogProgress(chipTool, " ***** Test Step 42 : Read GroupTable from alpha without fabric filtering\n");
+            err = TestReadGroupTableFromAlphaWithoutFabricFiltering_42();
             break;
         case 43:
-            ChipLogProgress(chipTool, " ***** Test Step 43 : Map Group 1 and Group 2 to KeySet 1 and group 2 to KeySet 2\n");
-            err = TestMapGroup1AndGroup2ToKeySet1AndGroup2ToKeySet2_43();
+            ChipLogProgress(chipTool, " ***** Test Step 43 : Read GroupTable from beta\n");
+            err = TestReadGroupTableFromBeta_43();
             break;
         case 44:
-            ChipLogProgress(chipTool, " ***** Test Step 44 : Remove keyset 1\n");
-            err = TestRemoveKeyset1_44();
+            ChipLogProgress(chipTool, " ***** Test Step 44 : Read GroupTable from beta without fabric filtering\n");
+            err = TestReadGroupTableFromBetaWithoutFabricFiltering_44();
             break;
         case 45:
-            ChipLogProgress(chipTool, " ***** Test Step 45 : TH verifies GroupKeyMap entries for KeySet 1 have been removed\n");
-            err = TestThVerifiesGroupKeyMapEntriesForKeySet1HaveBeenRemoved_45();
+            ChipLogProgress(chipTool, " ***** Test Step 45 : KeySet Remove 1\n");
+            err = TestKeySetRemove1_45();
             break;
         case 46:
-            ChipLogProgress(chipTool, " ***** Test Step 46 : Remove keyset 2\n");
-            err = TestRemoveKeyset2_46();
+            ChipLogProgress(chipTool, " ***** Test Step 46 : KeySet Read (removed)\n");
+            err = TestKeySetReadRemoved_46();
             break;
         case 47:
-            ChipLogProgress(chipTool, " ***** Test Step 47 : TH verifies GroupKeyMap entries for KeySet 2 have been removed\n");
-            err = TestThVerifiesGroupKeyMapEntriesForKeySet2HaveBeenRemoved_47();
+            ChipLogProgress(chipTool, " ***** Test Step 47 : KeySet Read (not removed) CacheAndSync\n");
+            if (ShouldSkip("GRPKEY.S.F00")) {
+                NextTest();
+                return;
+            }
+            err = TestKeySetReadNotRemovedCacheAndSync_47();
+            break;
+        case 48:
+            ChipLogProgress(chipTool, " ***** Test Step 48 : KeySet Read (not removed) TrustFirst\n");
+            if (ShouldSkip("GRPKEY.S.F00")) {
+                NextTest();
+                return;
+            }
+            err = TestKeySetReadNotRemovedTrustFirst_48();
+            break;
+        case 49:
+            ChipLogProgress(chipTool, " ***** Test Step 49 : Remove Group 1\n");
+            err = TestRemoveGroup1_49();
+            break;
+        case 50:
+            ChipLogProgress(chipTool, " ***** Test Step 50 : Read GroupTable 2\n");
+            err = TestReadGroupTable2_50();
+            break;
+        case 51:
+            ChipLogProgress(chipTool, " ***** Test Step 51 : Remove All\n");
+            err = TestRemoveAll_51();
+            break;
+        case 52:
+            ChipLogProgress(chipTool, " ***** Test Step 52 : Read GroupTable 3\n");
+            err = TestReadGroupTable3_52();
+            break;
+        case 53:
+            ChipLogProgress(chipTool, " ***** Test Step 53 : KeySet Remove 2\n");
+            err = TestKeySetRemove2_53();
+            break;
+        case 54:
+            ChipLogProgress(chipTool, " ***** Test Step 54 : KeySet Read (also removed)\n");
+            err = TestKeySetReadAlsoRemoved_54();
+            break;
+        case 55:
+            ChipLogProgress(chipTool, " ***** Test Step 55 : KeySet Write 1\n");
+            err = TestKeySetWrite1_55();
+            break;
+        case 56:
+            ChipLogProgress(chipTool, " ***** Test Step 56 : KeySet Write 2 CacheAndSync\n");
+            if (ShouldSkip("GRPKEY.S.F00")) {
+                NextTest();
+                return;
+            }
+            err = TestKeySetWrite2CacheAndSync_56();
+            break;
+        case 57:
+            ChipLogProgress(chipTool, " ***** Test Step 57 : KeySet Write 2 TrustFirst\n");
+            if (ShouldSkip("!GRPKEY.S.F00")) {
+                NextTest();
+                return;
+            }
+            err = TestKeySetWrite2TrustFirst_57();
+            break;
+        case 58:
+            ChipLogProgress(chipTool, " ***** Test Step 58 : Map Group 1 and Group 2 to KeySet 1 and group 2 to KeySet 2\n");
+            err = TestMapGroup1AndGroup2ToKeySet1AndGroup2ToKeySet2_58();
+            break;
+        case 59:
+            ChipLogProgress(chipTool, " ***** Test Step 59 : Remove keyset 1\n");
+            err = TestRemoveKeyset1_59();
+            break;
+        case 60:
+            ChipLogProgress(chipTool, " ***** Test Step 60 : TH verifies GroupKeyMap entries for KeySet 1 have been removed\n");
+            err = TestThVerifiesGroupKeyMapEntriesForKeySet1HaveBeenRemoved_60();
+            break;
+        case 61:
+            ChipLogProgress(chipTool, " ***** Test Step 61 : Remove keyset 2\n");
+            err = TestRemoveKeyset2_61();
+            break;
+        case 62:
+            ChipLogProgress(chipTool, " ***** Test Step 62 : TH verifies GroupKeyMap entries for KeySet 2 have been removed\n");
+            err = TestThVerifiesGroupKeyMapEntriesForKeySet2HaveBeenRemoved_62();
             break;
         }
 
@@ -175945,49 +176013,49 @@
             VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0));
             break;
         case 6:
-            VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0));
+            VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND));
             break;
         case 7:
-            VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0));
+            VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND));
             break;
         case 8:
-            VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0));
+            VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND));
             break;
         case 9:
-            VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0));
+            VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR));
             break;
         case 10:
-            VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0));
+            VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR));
             break;
         case 11:
-            VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0));
+            VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND));
             break;
         case 12:
-            VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0));
+            VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND));
             break;
         case 13:
             VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR));
             break;
         case 14:
-            VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE));
+            VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR));
             break;
         case 15:
-            VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0));
+            VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND));
             break;
         case 16:
-            VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0));
+            VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND));
             break;
         case 17:
-            VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0));
+            VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND));
             break;
         case 18:
-            VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0));
+            VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR));
             break;
         case 19:
-            VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0));
+            VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR));
             break;
         case 20:
-            VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0));
+            VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND));
             break;
         case 21:
             VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0));
@@ -176011,16 +176079,16 @@
             VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0));
             break;
         case 28:
-            VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0));
+            VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR));
             break;
         case 29:
-            VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0));
+            VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE));
             break;
         case 30:
             VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0));
             break;
         case 31:
-            VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_NOT_FOUND));
+            VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0));
             break;
         case 32:
             VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0));
@@ -176044,7 +176112,7 @@
             VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0));
             break;
         case 39:
-            VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_NOT_FOUND));
+            VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0));
             break;
         case 40:
             VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0));
@@ -176065,11 +176133,56 @@
             VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0));
             break;
         case 46:
-            VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0));
+            VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_NOT_FOUND));
             break;
         case 47:
             VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0));
             break;
+        case 48:
+            VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0));
+            break;
+        case 49:
+            VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0));
+            break;
+        case 50:
+            VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0));
+            break;
+        case 51:
+            VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0));
+            break;
+        case 52:
+            VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0));
+            break;
+        case 53:
+            VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0));
+            break;
+        case 54:
+            VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_NOT_FOUND));
+            break;
+        case 55:
+            VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0));
+            break;
+        case 56:
+            VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0));
+            break;
+        case 57:
+            VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0));
+            break;
+        case 58:
+            VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0));
+            break;
+        case 59:
+            VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0));
+            break;
+        case 60:
+            VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0));
+            break;
+        case 61:
+            VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0));
+            break;
+        case 62:
+            VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0));
+            break;
         }
 
         // Go on to the next test.
@@ -176083,7 +176196,7 @@
 
 private:
     std::atomic_uint16_t mTestIndex;
-    const uint16_t mTestCount = 48;
+    const uint16_t mTestCount = 63;
 
     chip::Optional<chip::NodeId> mNodeId;
     chip::Optional<chip::CharSpan> mCluster;
@@ -176183,7 +176296,620 @@
         return CHIP_NO_ERROR;
     }
 
-    CHIP_ERROR TestKeySetWrite1_6()
+    CHIP_ERROR TestKeySetWriteWithEpochKey0NullFailsInvalidCommand_6()
+    {
+
+        MTRBaseDevice * device = GetDevice("alpha");
+        __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device
+                                                                              endpointID:@(0)
+                                                                                   queue:mCallbackQueue];
+        VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE);
+
+        __auto_type * params = [[MTRGroupKeyManagementClusterKeySetWriteParams alloc] init];
+        params.groupKeySet = [[MTRGroupKeyManagementClusterGroupKeySetStruct alloc] init];
+        ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySetID =
+            [NSNumber numberWithUnsignedShort:417U];
+        ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySecurityPolicy =
+            [NSNumber numberWithUnsignedChar:0U];
+        ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey0 = nil;
+        ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime0 =
+            [NSNumber numberWithUnsignedLongLong:1110000ULL];
+        ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey1 = nil;
+        ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime1 = nil;
+        ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey2 = nil;
+        ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime2 = nil;
+
+        [cluster
+            keySetWriteWithParams:params
+                       completion:^(NSError * _Nullable err) {
+                           NSLog(@"KeySetWrite with EpochKey0 null fails INVALID_COMMAND Error: %@", err);
+
+                           VerifyOrReturn(CheckValue("status",
+                               err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE)
+                                   : 0,
+                               EMBER_ZCL_STATUS_INVALID_COMMAND));
+                           NextTest();
+                       }];
+
+        return CHIP_NO_ERROR;
+    }
+
+    CHIP_ERROR TestKeySetWriteWithEpochStartTime0NullFailsInvalidCommand_7()
+    {
+
+        MTRBaseDevice * device = GetDevice("alpha");
+        __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device
+                                                                              endpointID:@(0)
+                                                                                   queue:mCallbackQueue];
+        VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE);
+
+        __auto_type * params = [[MTRGroupKeyManagementClusterKeySetWriteParams alloc] init];
+        params.groupKeySet = [[MTRGroupKeyManagementClusterGroupKeySetStruct alloc] init];
+        ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySetID =
+            [NSNumber numberWithUnsignedShort:417U];
+        ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySecurityPolicy =
+            [NSNumber numberWithUnsignedChar:0U];
+        ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey0 =
+            [[NSData alloc] initWithBytes:"\240\241\242\243\244\245\246\247\250\251\252\253\254\255\256\257" length:16];
+        ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime0 = nil;
+        ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey1 = nil;
+        ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime1 = nil;
+        ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey2 = nil;
+        ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime2 = nil;
+
+        [cluster
+            keySetWriteWithParams:params
+                       completion:^(NSError * _Nullable err) {
+                           NSLog(@"KeySetWrite with EpochStartTime0 null fails INVALID_COMMAND Error: %@", err);
+
+                           VerifyOrReturn(CheckValue("status",
+                               err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE)
+                                   : 0,
+                               EMBER_ZCL_STATUS_INVALID_COMMAND));
+                           NextTest();
+                       }];
+
+        return CHIP_NO_ERROR;
+    }
+
+    CHIP_ERROR TestKeySetWriteWithEpochStartTime0SetToZeroFailsInvalidCommand_8()
+    {
+
+        MTRBaseDevice * device = GetDevice("alpha");
+        __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device
+                                                                              endpointID:@(0)
+                                                                                   queue:mCallbackQueue];
+        VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE);
+
+        __auto_type * params = [[MTRGroupKeyManagementClusterKeySetWriteParams alloc] init];
+        params.groupKeySet = [[MTRGroupKeyManagementClusterGroupKeySetStruct alloc] init];
+        ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySetID =
+            [NSNumber numberWithUnsignedShort:417U];
+        ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySecurityPolicy =
+            [NSNumber numberWithUnsignedChar:0U];
+        ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey0 =
+            [[NSData alloc] initWithBytes:"\240\241\242\243\244\245\246\247\250\251\252\253\254\255\256\257" length:16];
+        ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime0 =
+            [NSNumber numberWithUnsignedLongLong:0ULL];
+        ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey1 = nil;
+        ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime1 = nil;
+        ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey2 = nil;
+        ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime2 = nil;
+
+        [cluster
+            keySetWriteWithParams:params
+                       completion:^(NSError * _Nullable err) {
+                           NSLog(@"KeySetWrite with EpochStartTime0 set to zero fails INVALID_COMMAND Error: %@", err);
+
+                           VerifyOrReturn(CheckValue("status",
+                               err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE)
+                                   : 0,
+                               EMBER_ZCL_STATUS_INVALID_COMMAND));
+                           NextTest();
+                       }];
+
+        return CHIP_NO_ERROR;
+    }
+
+    CHIP_ERROR TestKeySetWriteWithEpochKey0WithLength116FailsWithConstraintError_9()
+    {
+
+        MTRBaseDevice * device = GetDevice("alpha");
+        __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device
+                                                                              endpointID:@(0)
+                                                                                   queue:mCallbackQueue];
+        VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE);
+
+        __auto_type * params = [[MTRGroupKeyManagementClusterKeySetWriteParams alloc] init];
+        params.groupKeySet = [[MTRGroupKeyManagementClusterGroupKeySetStruct alloc] init];
+        ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySetID =
+            [NSNumber numberWithUnsignedShort:417U];
+        ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySecurityPolicy =
+            [NSNumber numberWithUnsignedChar:0U];
+        ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey0 = [[NSData alloc] initWithBytes:"\240"
+                                                                                                                  length:1];
+        ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime0 =
+            [NSNumber numberWithUnsignedLongLong:1ULL];
+        ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey1 = nil;
+        ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime1 = nil;
+        ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey2 = nil;
+        ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime2 = nil;
+
+        [cluster
+            keySetWriteWithParams:params
+                       completion:^(NSError * _Nullable err) {
+                           NSLog(@"KeySetWrite with EpochKey0 with length 1 != 16 fails with CONSTRAINT_ERROR Error: %@", err);
+
+                           VerifyOrReturn(CheckValue("status",
+                               err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE)
+                                   : 0,
+                               EMBER_ZCL_STATUS_CONSTRAINT_ERROR));
+                           NextTest();
+                       }];
+
+        return CHIP_NO_ERROR;
+    }
+
+    CHIP_ERROR TestKeySetWriteWithEpochKey0WithLength016FailsWithConstraintError_10()
+    {
+
+        MTRBaseDevice * device = GetDevice("alpha");
+        __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device
+                                                                              endpointID:@(0)
+                                                                                   queue:mCallbackQueue];
+        VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE);
+
+        __auto_type * params = [[MTRGroupKeyManagementClusterKeySetWriteParams alloc] init];
+        params.groupKeySet = [[MTRGroupKeyManagementClusterGroupKeySetStruct alloc] init];
+        ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySetID =
+            [NSNumber numberWithUnsignedShort:417U];
+        ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySecurityPolicy =
+            [NSNumber numberWithUnsignedChar:0U];
+        ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey0 = [[NSData alloc] initWithBytes:""
+                                                                                                                  length:0];
+        ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime0 =
+            [NSNumber numberWithUnsignedLongLong:1ULL];
+        ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey1 = nil;
+        ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime1 = nil;
+        ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey2 = nil;
+        ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime2 = nil;
+
+        [cluster
+            keySetWriteWithParams:params
+                       completion:^(NSError * _Nullable err) {
+                           NSLog(@"KeySetWrite with EpochKey0 with length 0 != 16 fails with CONSTRAINT_ERROR Error: %@", err);
+
+                           VerifyOrReturn(CheckValue("status",
+                               err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE)
+                                   : 0,
+                               EMBER_ZCL_STATUS_CONSTRAINT_ERROR));
+                           NextTest();
+                       }];
+
+        return CHIP_NO_ERROR;
+    }
+
+    CHIP_ERROR TestKeySetWriteWithEpochStartTime1NullFailsInvalidCommand_11()
+    {
+
+        MTRBaseDevice * device = GetDevice("alpha");
+        __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device
+                                                                              endpointID:@(0)
+                                                                                   queue:mCallbackQueue];
+        VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE);
+
+        __auto_type * params = [[MTRGroupKeyManagementClusterKeySetWriteParams alloc] init];
+        params.groupKeySet = [[MTRGroupKeyManagementClusterGroupKeySetStruct alloc] init];
+        ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySetID =
+            [NSNumber numberWithUnsignedShort:417U];
+        ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySecurityPolicy =
+            [NSNumber numberWithUnsignedChar:0U];
+        ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey0 =
+            [[NSData alloc] initWithBytes:"\240\241\242\243\244\245\246\247\250\251\252\253\254\255\256\257" length:16];
+        ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime0 =
+            [NSNumber numberWithUnsignedLongLong:1110000ULL];
+        ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey1 =
+            [[NSData alloc] initWithBytes:"\260\261\262\263\264\265\266\267\270\271\272\273\274\275\276\277" length:16];
+        ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime1 = nil;
+        ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey2 = nil;
+        ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime2 = nil;
+
+        [cluster
+            keySetWriteWithParams:params
+                       completion:^(NSError * _Nullable err) {
+                           NSLog(@"KeySetWrite with EpochStartTime1 null fails INVALID_COMMAND Error: %@", err);
+
+                           VerifyOrReturn(CheckValue("status",
+                               err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE)
+                                   : 0,
+                               EMBER_ZCL_STATUS_INVALID_COMMAND));
+                           NextTest();
+                       }];
+
+        return CHIP_NO_ERROR;
+    }
+
+    CHIP_ERROR TestKeySetWriteWithEpochKey1NullFailsInvalidCommand_12()
+    {
+
+        MTRBaseDevice * device = GetDevice("alpha");
+        __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device
+                                                                              endpointID:@(0)
+                                                                                   queue:mCallbackQueue];
+        VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE);
+
+        __auto_type * params = [[MTRGroupKeyManagementClusterKeySetWriteParams alloc] init];
+        params.groupKeySet = [[MTRGroupKeyManagementClusterGroupKeySetStruct alloc] init];
+        ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySetID =
+            [NSNumber numberWithUnsignedShort:417U];
+        ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySecurityPolicy =
+            [NSNumber numberWithUnsignedChar:0U];
+        ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey0 =
+            [[NSData alloc] initWithBytes:"\240\241\242\243\244\245\246\247\250\251\252\253\254\255\256\257" length:16];
+        ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime0 =
+            [NSNumber numberWithUnsignedLongLong:1110000ULL];
+        ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey1 = nil;
+        ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime1 =
+            [NSNumber numberWithUnsignedLongLong:1110001ULL];
+        ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey2 = nil;
+        ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime2 = nil;
+
+        [cluster
+            keySetWriteWithParams:params
+                       completion:^(NSError * _Nullable err) {
+                           NSLog(@"KeySetWrite with EpochKey1 null fails INVALID_COMMAND Error: %@", err);
+
+                           VerifyOrReturn(CheckValue("status",
+                               err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE)
+                                   : 0,
+                               EMBER_ZCL_STATUS_INVALID_COMMAND));
+                           NextTest();
+                       }];
+
+        return CHIP_NO_ERROR;
+    }
+
+    CHIP_ERROR TestKeySetWriteWithEpochKey1WithLength116FailsWithConstraintError_13()
+    {
+
+        MTRBaseDevice * device = GetDevice("alpha");
+        __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device
+                                                                              endpointID:@(0)
+                                                                                   queue:mCallbackQueue];
+        VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE);
+
+        __auto_type * params = [[MTRGroupKeyManagementClusterKeySetWriteParams alloc] init];
+        params.groupKeySet = [[MTRGroupKeyManagementClusterGroupKeySetStruct alloc] init];
+        ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySetID =
+            [NSNumber numberWithUnsignedShort:417U];
+        ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySecurityPolicy =
+            [NSNumber numberWithUnsignedChar:0U];
+        ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey0 =
+            [[NSData alloc] initWithBytes:"\240\241\242\243\244\245\246\247\250\251\252\253\254\255\256\257" length:16];
+        ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime0 =
+            [NSNumber numberWithUnsignedLongLong:1110000ULL];
+        ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey1 = [[NSData alloc] initWithBytes:"\260"
+                                                                                                                  length:1];
+        ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime1 =
+            [NSNumber numberWithUnsignedLongLong:1110001ULL];
+        ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey2 = nil;
+        ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime2 = nil;
+
+        [cluster
+            keySetWriteWithParams:params
+                       completion:^(NSError * _Nullable err) {
+                           NSLog(@"KeySetWrite with EpochKey1 with length 1 != 16 fails with CONSTRAINT_ERROR Error: %@", err);
+
+                           VerifyOrReturn(CheckValue("status",
+                               err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE)
+                                   : 0,
+                               EMBER_ZCL_STATUS_CONSTRAINT_ERROR));
+                           NextTest();
+                       }];
+
+        return CHIP_NO_ERROR;
+    }
+
+    CHIP_ERROR TestKeySetWriteWithEpochKey1WithLength016FailsWithConstraintError_14()
+    {
+
+        MTRBaseDevice * device = GetDevice("alpha");
+        __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device
+                                                                              endpointID:@(0)
+                                                                                   queue:mCallbackQueue];
+        VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE);
+
+        __auto_type * params = [[MTRGroupKeyManagementClusterKeySetWriteParams alloc] init];
+        params.groupKeySet = [[MTRGroupKeyManagementClusterGroupKeySetStruct alloc] init];
+        ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySetID =
+            [NSNumber numberWithUnsignedShort:417U];
+        ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySecurityPolicy =
+            [NSNumber numberWithUnsignedChar:0U];
+        ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey0 =
+            [[NSData alloc] initWithBytes:"\240\241\242\243\244\245\246\247\250\251\252\253\254\255\256\257" length:16];
+        ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime0 =
+            [NSNumber numberWithUnsignedLongLong:1110000ULL];
+        ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey1 = [[NSData alloc] initWithBytes:""
+                                                                                                                  length:0];
+        ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime1 =
+            [NSNumber numberWithUnsignedLongLong:1110001ULL];
+        ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey2 = nil;
+        ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime2 = nil;
+
+        [cluster
+            keySetWriteWithParams:params
+                       completion:^(NSError * _Nullable err) {
+                           NSLog(@"KeySetWrite with EpochKey1 with length 0 != 16 fails with CONSTRAINT_ERROR Error: %@", err);
+
+                           VerifyOrReturn(CheckValue("status",
+                               err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE)
+                                   : 0,
+                               EMBER_ZCL_STATUS_CONSTRAINT_ERROR));
+                           NextTest();
+                       }];
+
+        return CHIP_NO_ERROR;
+    }
+
+    CHIP_ERROR TestKeySetWriteWithEpochStartTime1NotLaterThanEpochStart0FailsWithInvalidCommand_15()
+    {
+
+        MTRBaseDevice * device = GetDevice("alpha");
+        __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device
+                                                                              endpointID:@(0)
+                                                                                   queue:mCallbackQueue];
+        VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE);
+
+        __auto_type * params = [[MTRGroupKeyManagementClusterKeySetWriteParams alloc] init];
+        params.groupKeySet = [[MTRGroupKeyManagementClusterGroupKeySetStruct alloc] init];
+        ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySetID =
+            [NSNumber numberWithUnsignedShort:417U];
+        ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySecurityPolicy =
+            [NSNumber numberWithUnsignedChar:0U];
+        ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey0 =
+            [[NSData alloc] initWithBytes:"\240\241\242\243\244\245\246\247\250\251\252\253\254\255\256\257" length:16];
+        ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime0 =
+            [NSNumber numberWithUnsignedLongLong:1110000ULL];
+        ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey1 =
+            [[NSData alloc] initWithBytes:"\260\261\262\263\264\265\266\267\270\271\272\273\274\275\276\277" length:16];
+        ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime1 =
+            [NSNumber numberWithUnsignedLongLong:1ULL];
+        ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey2 = nil;
+        ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime2 = nil;
+
+        [cluster
+            keySetWriteWithParams:params
+                       completion:^(NSError * _Nullable err) {
+                           NSLog(
+                               @"KeySetWrite with EpochStartTime1 not later than EpochStart0 fails with INVALID_COMMAND Error: %@",
+                               err);
+
+                           VerifyOrReturn(CheckValue("status",
+                               err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE)
+                                   : 0,
+                               EMBER_ZCL_STATUS_INVALID_COMMAND));
+                           NextTest();
+                       }];
+
+        return CHIP_NO_ERROR;
+    }
+
+    CHIP_ERROR TestKeySetWriteWithEpochStartTime2NullFailsInvalidCommand_16()
+    {
+
+        MTRBaseDevice * device = GetDevice("alpha");
+        __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device
+                                                                              endpointID:@(0)
+                                                                                   queue:mCallbackQueue];
+        VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE);
+
+        __auto_type * params = [[MTRGroupKeyManagementClusterKeySetWriteParams alloc] init];
+        params.groupKeySet = [[MTRGroupKeyManagementClusterGroupKeySetStruct alloc] init];
+        ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySetID =
+            [NSNumber numberWithUnsignedShort:417U];
+        ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySecurityPolicy =
+            [NSNumber numberWithUnsignedChar:0U];
+        ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey0 =
+            [[NSData alloc] initWithBytes:"\240\241\242\243\244\245\246\247\250\251\252\253\254\255\256\257" length:16];
+        ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime0 =
+            [NSNumber numberWithUnsignedLongLong:1110000ULL];
+        ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey1 =
+            [[NSData alloc] initWithBytes:"\260\261\262\263\264\265\266\267\270\271\272\273\274\275\276\277" length:16];
+        ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime1 =
+            [NSNumber numberWithUnsignedLongLong:1110001ULL];
+        ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey2 =
+            [[NSData alloc] initWithBytes:"\360\361\362\363\364\365\366\367\370\371\372\373\374\375\376\377" length:16];
+        ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime2 = nil;
+
+        [cluster
+            keySetWriteWithParams:params
+                       completion:^(NSError * _Nullable err) {
+                           NSLog(@"KeySetWrite with EpochStartTime2 null fails INVALID_COMMAND Error: %@", err);
+
+                           VerifyOrReturn(CheckValue("status",
+                               err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE)
+                                   : 0,
+                               EMBER_ZCL_STATUS_INVALID_COMMAND));
+                           NextTest();
+                       }];
+
+        return CHIP_NO_ERROR;
+    }
+
+    CHIP_ERROR TestKeySetWriteWithEpochKey2NullFailsInvalidCommand_17()
+    {
+
+        MTRBaseDevice * device = GetDevice("alpha");
+        __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device
+                                                                              endpointID:@(0)
+                                                                                   queue:mCallbackQueue];
+        VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE);
+
+        __auto_type * params = [[MTRGroupKeyManagementClusterKeySetWriteParams alloc] init];
+        params.groupKeySet = [[MTRGroupKeyManagementClusterGroupKeySetStruct alloc] init];
+        ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySetID =
+            [NSNumber numberWithUnsignedShort:417U];
+        ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySecurityPolicy =
+            [NSNumber numberWithUnsignedChar:0U];
+        ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey0 =
+            [[NSData alloc] initWithBytes:"\240\241\242\243\244\245\246\247\250\251\252\253\254\255\256\257" length:16];
+        ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime0 =
+            [NSNumber numberWithUnsignedLongLong:1110000ULL];
+        ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey1 =
+            [[NSData alloc] initWithBytes:"\260\261\262\263\264\265\266\267\270\271\272\273\274\275\276\277" length:16];
+        ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime1 =
+            [NSNumber numberWithUnsignedLongLong:1110001ULL];
+        ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey2 = nil;
+        ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime2 =
+            [NSNumber numberWithUnsignedLongLong:1110002ULL];
+
+        [cluster
+            keySetWriteWithParams:params
+                       completion:^(NSError * _Nullable err) {
+                           NSLog(@"KeySetWrite with EpochKey2 null fails INVALID_COMMAND Error: %@", err);
+
+                           VerifyOrReturn(CheckValue("status",
+                               err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE)
+                                   : 0,
+                               EMBER_ZCL_STATUS_INVALID_COMMAND));
+                           NextTest();
+                       }];
+
+        return CHIP_NO_ERROR;
+    }
+
+    CHIP_ERROR TestKeySetWriteWithEpochKey2WithLength116FailsWithConstraintError_18()
+    {
+
+        MTRBaseDevice * device = GetDevice("alpha");
+        __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device
+                                                                              endpointID:@(0)
+                                                                                   queue:mCallbackQueue];
+        VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE);
+
+        __auto_type * params = [[MTRGroupKeyManagementClusterKeySetWriteParams alloc] init];
+        params.groupKeySet = [[MTRGroupKeyManagementClusterGroupKeySetStruct alloc] init];
+        ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySetID =
+            [NSNumber numberWithUnsignedShort:417U];
+        ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySecurityPolicy =
+            [NSNumber numberWithUnsignedChar:0U];
+        ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey0 =
+            [[NSData alloc] initWithBytes:"\240\241\242\243\244\245\246\247\250\251\252\253\254\255\256\257" length:16];
+        ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime0 =
+            [NSNumber numberWithUnsignedLongLong:1110000ULL];
+        ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey1 =
+            [[NSData alloc] initWithBytes:"\260\261\262\263\264\265\266\267\270\271\272\273\274\275\276\277" length:16];
+        ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime1 =
+            [NSNumber numberWithUnsignedLongLong:1110001ULL];
+        ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey2 = [[NSData alloc] initWithBytes:"\300"
+                                                                                                                  length:1];
+        ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime2 =
+            [NSNumber numberWithUnsignedLongLong:1110002ULL];
+
+        [cluster
+            keySetWriteWithParams:params
+                       completion:^(NSError * _Nullable err) {
+                           NSLog(@"KeySetWrite with EpochKey2 with length 1 != 16 fails with CONSTRAINT_ERROR Error: %@", err);
+
+                           VerifyOrReturn(CheckValue("status",
+                               err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE)
+                                   : 0,
+                               EMBER_ZCL_STATUS_CONSTRAINT_ERROR));
+                           NextTest();
+                       }];
+
+        return CHIP_NO_ERROR;
+    }
+
+    CHIP_ERROR TestKeySetWriteWithEpochKey2WithLength016FailsWithConstraintError_19()
+    {
+
+        MTRBaseDevice * device = GetDevice("alpha");
+        __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device
+                                                                              endpointID:@(0)
+                                                                                   queue:mCallbackQueue];
+        VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE);
+
+        __auto_type * params = [[MTRGroupKeyManagementClusterKeySetWriteParams alloc] init];
+        params.groupKeySet = [[MTRGroupKeyManagementClusterGroupKeySetStruct alloc] init];
+        ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySetID =
+            [NSNumber numberWithUnsignedShort:417U];
+        ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySecurityPolicy =
+            [NSNumber numberWithUnsignedChar:0U];
+        ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey0 =
+            [[NSData alloc] initWithBytes:"\240\241\242\243\244\245\246\247\250\251\252\253\254\255\256\257" length:16];
+        ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime0 =
+            [NSNumber numberWithUnsignedLongLong:1110000ULL];
+        ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey1 =
+            [[NSData alloc] initWithBytes:"\260\261\262\263\264\265\266\267\270\271\272\273\274\275\276\277" length:16];
+        ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime1 =
+            [NSNumber numberWithUnsignedLongLong:1110001ULL];
+        ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey2 = [[NSData alloc] initWithBytes:""
+                                                                                                                  length:0];
+        ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime2 =
+            [NSNumber numberWithUnsignedLongLong:1110002ULL];
+
+        [cluster
+            keySetWriteWithParams:params
+                       completion:^(NSError * _Nullable err) {
+                           NSLog(@"KeySetWrite with EpochKey2 with length 0 != 16 fails with CONSTRAINT_ERROR Error: %@", err);
+
+                           VerifyOrReturn(CheckValue("status",
+                               err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE)
+                                   : 0,
+                               EMBER_ZCL_STATUS_CONSTRAINT_ERROR));
+                           NextTest();
+                       }];
+
+        return CHIP_NO_ERROR;
+    }
+
+    CHIP_ERROR TestKeySetWriteWithEpochStartTime2NotLaterThanEpochStart1FailsWithInvalidCommand_20()
+    {
+
+        MTRBaseDevice * device = GetDevice("alpha");
+        __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device
+                                                                              endpointID:@(0)
+                                                                                   queue:mCallbackQueue];
+        VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE);
+
+        __auto_type * params = [[MTRGroupKeyManagementClusterKeySetWriteParams alloc] init];
+        params.groupKeySet = [[MTRGroupKeyManagementClusterGroupKeySetStruct alloc] init];
+        ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySetID =
+            [NSNumber numberWithUnsignedShort:417U];
+        ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySecurityPolicy =
+            [NSNumber numberWithUnsignedChar:0U];
+        ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey0 =
+            [[NSData alloc] initWithBytes:"\240\241\242\243\244\245\246\247\250\251\252\253\254\255\256\257" length:16];
+        ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime0 =
+            [NSNumber numberWithUnsignedLongLong:1110000ULL];
+        ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey1 =
+            [[NSData alloc] initWithBytes:"\260\261\262\263\264\265\266\267\270\271\272\273\274\275\276\277" length:16];
+        ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime1 =
+            [NSNumber numberWithUnsignedLongLong:1110001ULL];
+        ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey2 =
+            [[NSData alloc] initWithBytes:"\360\361\362\363\364\365\366\367\370\371\372\373\374\375\376\377" length:16];
+        ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime2 =
+            [NSNumber numberWithUnsignedLongLong:100ULL];
+
+        [cluster
+            keySetWriteWithParams:params
+                       completion:^(NSError * _Nullable err) {
+                           NSLog(
+                               @"KeySetWrite with EpochStartTime2 not later than EpochStart1 fails with INVALID_COMMAND Error: %@",
+                               err);
+
+                           VerifyOrReturn(CheckValue("status",
+                               err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE)
+                                   : 0,
+                               EMBER_ZCL_STATUS_INVALID_COMMAND));
+                           NextTest();
+                       }];
+
+        return CHIP_NO_ERROR;
+    }
+
+    CHIP_ERROR TestKeySetWrite1_21()
     {
 
         MTRBaseDevice * device = GetDevice("alpha");
@@ -176223,7 +176949,7 @@
         return CHIP_NO_ERROR;
     }
 
-    CHIP_ERROR TestKeySetWrite2CacheAndSync_7()
+    CHIP_ERROR TestKeySetWrite2CacheAndSync_22()
     {
 
         MTRBaseDevice * device = GetDevice("alpha");
@@ -176263,7 +176989,7 @@
         return CHIP_NO_ERROR;
     }
 
-    CHIP_ERROR TestKeySetWrite2TrustFirst_8()
+    CHIP_ERROR TestKeySetWrite2TrustFirst_23()
     {
 
         MTRBaseDevice * device = GetDevice("alpha");
@@ -176303,7 +177029,7 @@
         return CHIP_NO_ERROR;
     }
 
-    CHIP_ERROR TestKeySetWrite3CacheAndSync_9()
+    CHIP_ERROR TestKeySetWrite3CacheAndSync_24()
     {
 
         MTRBaseDevice * device = GetDevice("beta");
@@ -176343,7 +177069,7 @@
         return CHIP_NO_ERROR;
     }
 
-    CHIP_ERROR TestKeySetWrite3TrustFirst_10()
+    CHIP_ERROR TestKeySetWrite3TrustFirst_25()
     {
 
         MTRBaseDevice * device = GetDevice("beta");
@@ -176383,7 +177109,7 @@
         return CHIP_NO_ERROR;
     }
 
-    CHIP_ERROR TestKeySetRead_11()
+    CHIP_ERROR TestKeySetRead_26()
     {
 
         MTRBaseDevice * device = GetDevice("alpha");
@@ -176434,7 +177160,7 @@
         return CHIP_NO_ERROR;
     }
 
-    CHIP_ERROR TestKeySetReadAllIndices_12()
+    CHIP_ERROR TestKeySetReadAllIndices_27()
     {
 
         MTRBaseDevice * device = GetDevice("alpha");
@@ -176459,7 +177185,7 @@
         return CHIP_NO_ERROR;
     }
 
-    CHIP_ERROR TestWriteGroupKeysInvalid_13()
+    CHIP_ERROR TestWriteGroupKeysInvalid_28()
     {
 
         MTRBaseDevice * device = GetDevice("alpha");
@@ -176494,7 +177220,7 @@
         return CHIP_NO_ERROR;
     }
 
-    CHIP_ERROR TestWriteGroupKeysTooMany_14()
+    CHIP_ERROR TestWriteGroupKeysTooMany_29()
     {
 
         MTRBaseDevice * device = GetDevice("alpha");
@@ -176594,7 +177320,7 @@
         return CHIP_NO_ERROR;
     }
 
-    CHIP_ERROR TestWriteGroupKeysOnAlpha_15()
+    CHIP_ERROR TestWriteGroupKeysOnAlpha_30()
     {
 
         MTRBaseDevice * device = GetDevice("alpha");
@@ -176640,7 +177366,7 @@
         return CHIP_NO_ERROR;
     }
 
-    CHIP_ERROR TestWriteGroupKeysOnBeta_16()
+    CHIP_ERROR TestWriteGroupKeysOnBeta_31()
     {
 
         MTRBaseDevice * device = GetDevice("beta");
@@ -176686,7 +177412,7 @@
         return CHIP_NO_ERROR;
     }
 
-    CHIP_ERROR TestReadGroupKeysOnAlpha_17()
+    CHIP_ERROR TestReadGroupKeysOnAlpha_32()
     {
 
         MTRBaseDevice * device = GetDevice("alpha");
@@ -176748,7 +177474,7 @@
         return CHIP_NO_ERROR;
     }
 
-    CHIP_ERROR TestReadGroupKeysOnAlphaWithoutFabricFiltering_18()
+    CHIP_ERROR TestReadGroupKeysOnAlphaWithoutFabricFiltering_33()
     {
 
         MTRBaseDevice * device = GetDevice("alpha");
@@ -176842,7 +177568,7 @@
         return CHIP_NO_ERROR;
     }
 
-    CHIP_ERROR TestReadGroupKeysOnBeta_19()
+    CHIP_ERROR TestReadGroupKeysOnBeta_34()
     {
 
         MTRBaseDevice * device = GetDevice("beta");
@@ -176904,7 +177630,7 @@
         return CHIP_NO_ERROR;
     }
 
-    CHIP_ERROR TestReadGroupKeysOnBetaWithoutFabricFiltering_20()
+    CHIP_ERROR TestReadGroupKeysOnBetaWithoutFabricFiltering_35()
     {
 
         MTRBaseDevice * device = GetDevice("beta");
@@ -176998,7 +177724,7 @@
         return CHIP_NO_ERROR;
     }
 
-    CHIP_ERROR TestAddGroup1_21()
+    CHIP_ERROR TestAddGroup1_36()
     {
 
         MTRBaseDevice * device = GetDevice("alpha");
@@ -177030,7 +177756,7 @@
         return CHIP_NO_ERROR;
     }
 
-    CHIP_ERROR TestAddGroup2_22()
+    CHIP_ERROR TestAddGroup2_37()
     {
 
         MTRBaseDevice * device = GetDevice("alpha");
@@ -177062,7 +177788,7 @@
         return CHIP_NO_ERROR;
     }
 
-    CHIP_ERROR TestAddGroup3_23()
+    CHIP_ERROR TestAddGroup3_38()
     {
 
         MTRBaseDevice * device = GetDevice("alpha");
@@ -177094,7 +177820,7 @@
         return CHIP_NO_ERROR;
     }
 
-    CHIP_ERROR TestAddGroup4_24()
+    CHIP_ERROR TestAddGroup4_39()
     {
 
         MTRBaseDevice * device = GetDevice("alpha");
@@ -177126,7 +177852,7 @@
         return CHIP_NO_ERROR;
     }
 
-    CHIP_ERROR TestAddGroup5_25()
+    CHIP_ERROR TestAddGroup5_40()
     {
 
         MTRBaseDevice * device = GetDevice("beta");
@@ -177158,7 +177884,7 @@
         return CHIP_NO_ERROR;
     }
 
-    CHIP_ERROR TestReadGroupTableFromAlpha_26()
+    CHIP_ERROR TestReadGroupTableFromAlpha_41()
     {
 
         MTRBaseDevice * device = GetDevice("alpha");
@@ -177247,7 +177973,7 @@
         return CHIP_NO_ERROR;
     }
 
-    CHIP_ERROR TestReadGroupTableFromAlphaWithoutFabricFiltering_27()
+    CHIP_ERROR TestReadGroupTableFromAlphaWithoutFabricFiltering_42()
     {
 
         MTRBaseDevice * device = GetDevice("alpha");
@@ -177351,7 +178077,7 @@
         return CHIP_NO_ERROR;
     }
 
-    CHIP_ERROR TestReadGroupTableFromBeta_28()
+    CHIP_ERROR TestReadGroupTableFromBeta_43()
     {
 
         MTRBaseDevice * device = GetDevice("beta");
@@ -177395,7 +178121,7 @@
         return CHIP_NO_ERROR;
     }
 
-    CHIP_ERROR TestReadGroupTableFromBetaWithoutFabricFiltering_29()
+    CHIP_ERROR TestReadGroupTableFromBetaWithoutFabricFiltering_44()
     {
 
         MTRBaseDevice * device = GetDevice("beta");
@@ -177499,7 +178225,7 @@
         return CHIP_NO_ERROR;
     }
 
-    CHIP_ERROR TestKeySetRemove1_30()
+    CHIP_ERROR TestKeySetRemove1_45()
     {
 
         MTRBaseDevice * device = GetDevice("alpha");
@@ -177522,7 +178248,7 @@
         return CHIP_NO_ERROR;
     }
 
-    CHIP_ERROR TestKeySetReadRemoved_31()
+    CHIP_ERROR TestKeySetReadRemoved_46()
     {
 
         MTRBaseDevice * device = GetDevice("alpha");
@@ -177549,7 +178275,7 @@
         return CHIP_NO_ERROR;
     }
 
-    CHIP_ERROR TestKeySetReadNotRemovedCacheAndSync_32()
+    CHIP_ERROR TestKeySetReadNotRemovedCacheAndSync_47()
     {
 
         MTRBaseDevice * device = GetDevice("alpha");
@@ -177600,7 +178326,7 @@
         return CHIP_NO_ERROR;
     }
 
-    CHIP_ERROR TestKeySetReadNotRemovedTrustFirst_33()
+    CHIP_ERROR TestKeySetReadNotRemovedTrustFirst_48()
     {
 
         MTRBaseDevice * device = GetDevice("alpha");
@@ -177651,7 +178377,7 @@
         return CHIP_NO_ERROR;
     }
 
-    CHIP_ERROR TestRemoveGroup1_34()
+    CHIP_ERROR TestRemoveGroup1_49()
     {
 
         MTRBaseDevice * device = GetDevice("alpha");
@@ -177682,7 +178408,7 @@
         return CHIP_NO_ERROR;
     }
 
-    CHIP_ERROR TestReadGroupTable2_35()
+    CHIP_ERROR TestReadGroupTable2_50()
     {
 
         MTRBaseDevice * device = GetDevice("alpha");
@@ -177756,7 +178482,7 @@
         return CHIP_NO_ERROR;
     }
 
-    CHIP_ERROR TestRemoveAll_36()
+    CHIP_ERROR TestRemoveAll_51()
     {
 
         MTRBaseDevice * device = GetDevice("alpha");
@@ -177774,7 +178500,7 @@
         return CHIP_NO_ERROR;
     }
 
-    CHIP_ERROR TestReadGroupTable3_37()
+    CHIP_ERROR TestReadGroupTable3_52()
     {
 
         MTRBaseDevice * device = GetDevice("alpha");
@@ -177803,7 +178529,7 @@
         return CHIP_NO_ERROR;
     }
 
-    CHIP_ERROR TestKeySetRemove2_38()
+    CHIP_ERROR TestKeySetRemove2_53()
     {
 
         MTRBaseDevice * device = GetDevice("alpha");
@@ -177826,7 +178552,7 @@
         return CHIP_NO_ERROR;
     }
 
-    CHIP_ERROR TestKeySetReadAlsoRemoved_39()
+    CHIP_ERROR TestKeySetReadAlsoRemoved_54()
     {
 
         MTRBaseDevice * device = GetDevice("alpha");
@@ -177853,7 +178579,7 @@
         return CHIP_NO_ERROR;
     }
 
-    CHIP_ERROR TestKeySetWrite1_40()
+    CHIP_ERROR TestKeySetWrite1_55()
     {
 
         MTRBaseDevice * device = GetDevice("alpha");
@@ -177893,7 +178619,7 @@
         return CHIP_NO_ERROR;
     }
 
-    CHIP_ERROR TestKeySetWrite2CacheAndSync_41()
+    CHIP_ERROR TestKeySetWrite2CacheAndSync_56()
     {
 
         MTRBaseDevice * device = GetDevice("alpha");
@@ -177933,7 +178659,7 @@
         return CHIP_NO_ERROR;
     }
 
-    CHIP_ERROR TestKeySetWrite2TrustFirst_42()
+    CHIP_ERROR TestKeySetWrite2TrustFirst_57()
     {
 
         MTRBaseDevice * device = GetDevice("alpha");
@@ -177973,7 +178699,7 @@
         return CHIP_NO_ERROR;
     }
 
-    CHIP_ERROR TestMapGroup1AndGroup2ToKeySet1AndGroup2ToKeySet2_43()
+    CHIP_ERROR TestMapGroup1AndGroup2ToKeySet1AndGroup2ToKeySet2_58()
     {
 
         MTRBaseDevice * device = GetDevice("alpha");
@@ -178014,7 +178740,7 @@
         return CHIP_NO_ERROR;
     }
 
-    CHIP_ERROR TestRemoveKeyset1_44()
+    CHIP_ERROR TestRemoveKeyset1_59()
     {
 
         MTRBaseDevice * device = GetDevice("alpha");
@@ -178037,7 +178763,7 @@
         return CHIP_NO_ERROR;
     }
 
-    CHIP_ERROR TestThVerifiesGroupKeyMapEntriesForKeySet1HaveBeenRemoved_45()
+    CHIP_ERROR TestThVerifiesGroupKeyMapEntriesForKeySet1HaveBeenRemoved_60()
     {
 
         MTRBaseDevice * device = GetDevice("alpha");
@@ -178075,7 +178801,7 @@
         return CHIP_NO_ERROR;
     }
 
-    CHIP_ERROR TestRemoveKeyset2_46()
+    CHIP_ERROR TestRemoveKeyset2_61()
     {
 
         MTRBaseDevice * device = GetDevice("alpha");
@@ -178098,7 +178824,7 @@
         return CHIP_NO_ERROR;
     }
 
-    CHIP_ERROR TestThVerifiesGroupKeyMapEntriesForKeySet2HaveBeenRemoved_47()
+    CHIP_ERROR TestThVerifiesGroupKeyMapEntriesForKeySet2HaveBeenRemoved_62()
     {
 
         MTRBaseDevice * device = GetDevice("alpha");