diff --git a/src/app/CommandHandler.cpp b/src/app/CommandHandler.cpp index 29abc1f321a9bd..a34a7c6af7fae4 100644 --- a/src/app/CommandHandler.cpp +++ b/src/app/CommandHandler.cpp @@ -470,6 +470,19 @@ CHIP_ERROR CommandHandler::AddStatus(const ConcreteCommandPath & aCommandPath, c return AddStatusInternal(aCommandPath, StatusIB(aStatus)); } +CHIP_ERROR CommandHandler::AddStatusAndLogIfFailure(const ConcreteCommandPath & aCommandPath, const Status aStatus, const char* message) +{ + 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), message); + + } + + 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 cc175a9a125cd8..7058541d465ca1 100644 --- a/src/app/CommandHandler.h +++ b/src/app/CommandHandler.h @@ -172,6 +172,9 @@ class CommandHandler : public Messaging::ExchangeDelegate System::PacketBufferHandle && payload, bool isTimedInvoke); CHIP_ERROR AddStatus(const ConcreteCommandPath & aCommandPath, const Protocols::InteractionModel::Status aStatus); + // Same as AddStatus, but logs that `aCommandName` failed with the given error status, on error. + CHIP_ERROR AddStatusAndLogIfFailure(const ConcreteCommandPath & aCommandPath, const Protocols::InteractionModel::Status aStatus, const char* aCommandName); + 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 9f29d0b25a6966..890cf3cff2d2bc 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 @@ -285,6 +285,106 @@ class GroupKeyManagementAttributeAccess : public AttributeAccessInterface } }; +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 +404,20 @@ bool emberAfGroupKeyManagementClusterKeySetWriteCallback( 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) + { + 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) { - // 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 to validate KeySet data dependencies."); return true; } @@ -319,7 +427,7 @@ bool emberAfGroupKeyManagementClusterKeySetWriteCallback( // 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 +438,24 @@ bool emberAfGroupKeyManagementClusterKeySetWriteCallback( // 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 +463,14 @@ bool emberAfGroupKeyManagementClusterKeySetWriteCallback( } // 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 +488,7 @@ bool emberAfGroupKeyManagementClusterKeySetWriteCallback( } 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 bc1091050d828a..9ce9574b821c63 100644 --- a/src/app/tests/suites/TestGroupKeyManagementCluster.yaml +++ b/src/app/tests/suites/TestGroupKeyManagementCluster.yaml @@ -74,6 +74,295 @@ tests: constraints: minValue: 3 + ########### 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" + 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" + 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" + 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" + 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" + 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" + 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" + 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" + 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 5714cc0f9877a7..09c89b5ef669b7 100644 --- a/src/controller/tests/data_model/TestCommands.cpp +++ b/src/controller/tests/data_model/TestCommands.cpp @@ -85,8 +85,7 @@ void DispatchSingleClusterCommand(const ConcreteCommandPath & aCommandPath, chip 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 +119,7 @@ void DispatchSingleClusterCommand(const ConcreteCommandPath & aCommandPath, chip // test is not really testing what it should. for (size_t i = 0; i < 4; ++i) { - apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::Success); + apCommandObj->AddStatusAndLogIfError(aCommandPath, Protocols::InteractionModel::Status::Success, "No error but testing AddStatusAndLogIfError in success case"); } // And one failure on the end. apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::Failure);