diff --git a/src/app/clusters/scenes-server/SceneHandlerImpl.cpp b/src/app/clusters/scenes-server/SceneHandlerImpl.cpp index c29d1bbd5d27e8..96975bfcb5f869 100644 --- a/src/app/clusters/scenes-server/SceneHandlerImpl.cpp +++ b/src/app/clusters/scenes-server/SceneHandlerImpl.cpp @@ -20,6 +20,27 @@ namespace chip { namespace scenes { +namespace { + +/// ValideAttribute +/// @brief Validate the attribute exists for a given cluster +/// @param[in] clusterID Cluster ID +/// @param[in] attID Attribute ID +/// @return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE if the attribute does not exist for a given cluster or is not scenable +// TODO: Assess if we also want to throw an error if the attribute value is out of range +// TODO: Add check for "S" quality to determine if the attribute is scenable once suported : +// https://github.com/project-chip/connectedhomeip/issues/24177 +CHIP_ERROR ValideAttribute(EndpointId endpoint, ClusterId cluster, AttributeId attributeId) +{ + uint16_t attIndex = emberAfGetServerAttributeIndexByAttributeId(endpoint, cluster, attributeId); + if (attIndex == UINT16_MAX) + { + return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE; + } + return CHIP_NO_ERROR; +} +} // namespace + CHIP_ERROR DefaultSceneHandlerImpl::EncodeAttributeValueList(const List & aVlist, MutableByteSpan & serializedBytes) { @@ -58,6 +79,7 @@ DefaultSceneHandlerImpl::SerializeAdd(EndpointId endpoint, const ExtensionFieldS auto pair_iterator = extensionFieldSet.attributeValueList.begin(); while (pair_iterator.Next()) { + ReturnErrorOnFailure(ValideAttribute(endpoint, extensionFieldSet.clusterID, pair_iterator.GetValue().attributeID)); aVPairs[pairCount] = pair_iterator.GetValue(); pairCount++; } diff --git a/src/app/clusters/scenes-server/scenes-server.cpp b/src/app/clusters/scenes-server/scenes-server.cpp index d05d7da84f9a53..d23b1ccf1e61d8 100644 --- a/src/app/clusters/scenes-server/scenes-server.cpp +++ b/src/app/clusters/scenes-server/scenes-server.cpp @@ -70,6 +70,10 @@ CHIP_ERROR AddResponseOnError(CommandHandlerInterface::HandlerContext & ctx, Res { resp.status = to_underlying(Protocols::InteractionModel::Status::ResourceExhausted); } + else if (CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE == err) + { + resp.status = to_underlying(Protocols::InteractionModel::Status::InvalidCommand); + } else { resp.status = to_underlying(StatusIB(err).mStatus); diff --git a/src/app/tests/suites/certification/Test_TC_S_2_2.yaml b/src/app/tests/suites/certification/Test_TC_S_2_2.yaml index 02407f8807d993..5c0b83062bbca2 100644 --- a/src/app/tests/suites/certification/Test_TC_S_2_2.yaml +++ b/src/app/tests/suites/certification/Test_TC_S_2_2.yaml @@ -431,6 +431,21 @@ tests: - name: "SceneID" value: 0x01 + - label: + "Step 4e: TH sends a RecallScene command to DUT with the GroupID field + set to GI (Where GI is a group currently absent from the group table) + and the SceneID field set to 0x01." + PICS: S.S.C05.Rsp + command: "RecallScene" + arguments: + values: + - name: "GroupID" + value: GI + - name: "SceneID" + value: 0x01 + response: + error: INVALID_COMMAND + - label: "Step 5a: TH sends a ViewScene command to DUT with the GroupID field set to G1 and the SceneID field set to 0x01." @@ -773,6 +788,150 @@ tests: - name: "SceneID" value: 0x01 + - label: + "Step 8f: TH sends a AddScene command to DUT with the GroupID field + set to G1, the SceneID field set to 0x01, the TransitionTime field set + to 1000 (1s) and extension field sets holding an invalid + ExtensionField (Invalid attribute ID for given cluster). This should + fail and return a status of 0x85 (INVALID_COMMAND)." + PICS: S.S.C00.Rsp && PICS_SDK_CI_ONLY + command: "AddScene" + arguments: + values: + - name: "GroupID" + value: G1 + - name: "SceneID" + value: 0x01 + - name: "TransitionTime" + value: 1000 + - name: "SceneName" + value: "Scene1" + - name: "ExtensionFieldSets" + value: + [ + { + ClusterID: 0x0006, + AttributeValueList: + [{ AttributeID: 0xFFFF, AttributeValue: 0x01 }], + }, + ] + response: + values: + - name: "Status" + value: 0x85 + - name: "GroupID" + value: G1 + - name: "SceneID" + value: 0x01 + + - label: + "Step 8f: TH sends a AddScene command to DUT with the GroupID field + set to G1, the SceneID field set to 0x01, the TransitionTime field set + to 1000 (1s) and extension field sets holding an invalid + ExtensionField (Invalid attribute ID for given cluster). This should + fail and return a status of 0x85 (INVALID_COMMAND)." + verification: | + ./chip-tool scenesmanagement add-scene 0x0001 0x01 1000 "scene name" '[{"clusterID": "0x006", "attributeValueList":[{"attributeID": "0xFFFF", "attributeValue": "0x01"}]}]' 1 1 + + Verify DUT sends a AddSceneResponse command to TH with the Status field set to 0x85 (INVALID_COMMAND), the GroupID field set to G1 and the SceneID field set to 0x01 on the TH(Chip-tool) + Log and below is the sample log provided for the raspi platform: + + [1706763610.675038][4232:4234] CHIP:DMG: }, + [1706763610.675108][4232:4234] CHIP:DMG: Received Command Response Data, Endpoint=1 Cluster=0x0000_0062 Command=0x0000_0000 + [1706763610.675134][4232:4234] CHIP:TOO: Endpoint: 1 Cluster: 0x0000_0062 Command 0x0000_0000 + [1706763610.675187][4232:4234] CHIP:TOO: AddSceneResponse: { + [1706763610.675215][4232:4234] CHIP:TOO: status: 133 + [1706763610.675229][4232:4234] CHIP:TOO: groupID: 1 + [1706763610.675244][4232:4234] CHIP:TOO: sceneID: 1 + [1706763610.675258][4232:4234] CHIP:TOO: } + cluster: "LogCommands" + command: "UserPrompt" + PICS: PICS_SKIP_SAMPLE_APP + arguments: + values: + - name: "message" + value: + "Please execute the add scene command with an invalid + extensionfieldsets due to an Attribute not existing on a + cluster on DUT and enter 'y' if the command returned a + status of 0x85 (INVALID_COMMAND)" + - name: "expectedValue" + value: "y" + + - label: + "Step 8g: TH sends a AddScene command to DUT with the GroupID field + set to G1, the SceneID field set to 0x01, the TransitionTime field set + to 1000 (1s) and extension field sets holding an invalid + ExtensionField (Unscenable attribute ID for given cluster). This + should fail and return a status of 0x85 (INVALID_COMMAND)." + ## TODO: Enable once scenability check is possible, see issue: https://github.com/project-chip/connectedhomeip/issues/24177 + PICS: S.S.C00.Rsp && PICS_SDK_CI_ONLY + command: "AddScene" + arguments: + values: + - name: "GroupID" + value: G1 + - name: "SceneID" + value: 0x01 + - name: "TransitionTime" + value: 1000 + - name: "SceneName" + value: "Scene1" + - name: "ExtensionFieldSets" + value: + [ + { + ClusterID: 0x0006, + AttributeValueList: + [{ AttributeID: 0x4001, AttributeValue: 0x01 }], + }, + ] + response: + values: + - name: "Status" + value: 0x85 + - name: "GroupID" + value: G1 + - name: "SceneID" + value: 0x01 + disabled: true + + - label: + "Step 8g: TH sends a AddScene command to DUT with the GroupID field + set to G1, the SceneID field set to 0x01, the TransitionTime field set + to 1000 (1s) and extension field sets holding an invalid + ExtensionField (Unscenable attribute ID for given cluster). This + should fail and return a status of 0x85 (INVALID_COMMAND)." + ## TODO: Enable once scenability check is possible, see issue: https://github.com/project-chip/connectedhomeip/issues/24177 + verification: | + ./chip-tool scenesmanagement add-scene 0x0001 0x01 1000 "scene name" '[{"clusterID": "0x006", "attributeValueList":[{"attributeID": "0x4001", "attributeValue": "0x01"}]}]' 1 1 + + Verify DUT sends a AddSceneResponse command to TH with the Status field set to 0x85 (INVALID_COMMAND), the GroupID field set to G1 and the SceneID field set to 0x01 on the TH(Chip-tool) + Log and below is the sample log provided for the raspi platform: + + [1706763610.675038][4232:4234] CHIP:DMG: }, + [1706763610.675108][4232:4234] CHIP:DMG: Received Command Response Data, Endpoint=1 Cluster=0x0000_0062 Command=0x0000_0000 + [1706763610.675134][4232:4234] CHIP:TOO: Endpoint: 1 Cluster: 0x0000_0062 Command 0x0000_0000 + [1706763610.675187][4232:4234] CHIP:TOO: AddSceneResponse: { + [1706763610.675215][4232:4234] CHIP:TOO: status: 133 + [1706763610.675229][4232:4234] CHIP:TOO: groupID: 1 + [1706763610.675244][4232:4234] CHIP:TOO: sceneID: 1 + [1706763610.675258][4232:4234] CHIP:TOO: } + cluster: "LogCommands" + command: "UserPrompt" + PICS: PICS_SKIP_SAMPLE_APP + arguments: + values: + - name: "message" + value: + "Please execute the add scene command with an invalid + extensionfieldsets due to a non sceneable attribute not in + an extensionfieldset on DUT and enter 'y' if the command + returned a status of 0x85 (INVALID_COMMAND)" + - name: "expectedValue" + value: "y" + disabled: true + - label: "Step 9a: TH sends a RemoveScene command to DUT with the GroupID field set to G1 and the SceneID field set to 0x01." diff --git a/src/app/tests/suites/certification/Test_TC_S_2_3.yaml b/src/app/tests/suites/certification/Test_TC_S_2_3.yaml index 859204e549f7b2..9d26de9cca2bcc 100644 --- a/src/app/tests/suites/certification/Test_TC_S_2_3.yaml +++ b/src/app/tests/suites/certification/Test_TC_S_2_3.yaml @@ -705,6 +705,81 @@ tests: - name: "SceneID" value: 0x03 + - label: + "Step 6f: TH sends a StoreScene command to to group G1 with the + GroupID field set to G1 and the SceneID field set to 0x03." + PICS: S.S.C04.Rsp + command: "StoreScene" + groupId: G1 + arguments: + values: + - name: "GroupID" + value: G1 + - name: "SceneID" + value: 0x03 + + - label: + "Step 6g: TH sends a ViewScene command to DUT with the GroupID field + set to G1 and the SceneID field set to 0x03." + PICS: S.S.C01.Rsp && PICS_SDK_CI_ONLY + command: "ViewScene" + arguments: + values: + - name: "GroupID" + value: G1 + - name: "SceneID" + value: 0x03 + response: + values: + - name: "Status" + value: 0x00 + - name: "GroupID" + value: G1 + - name: "SceneID" + value: 0x03 + + - label: + "Step 6h: TH sends a RemoveScene command to group G1 with the GroupID + field set to G1 and the SceneID field set to 0x03." + PICS: S.S.C02.Rsp + command: "RemoveScene" + groupId: G1 + arguments: + values: + - name: "GroupID" + value: G1 + - name: "SceneID" + value: 0x03 + + - label: "Wait 1+ s to give CI time to process the RemoveScene command." + PICS: PICS_SDK_CI_ONLY + cluster: "DelayCommands" + command: "WaitForMs" + arguments: + values: + - name: "ms" + value: 1250 + + - label: + "Step 6i: TH sends a ViewScene command to DUT with the GroupID field + set to G1 and the SceneID field set to 0x03." + PICS: S.S.C01.Rsp + command: "ViewScene" + arguments: + values: + - name: "GroupID" + value: G1 + - name: "SceneID" + value: 0x03 + response: + values: + - name: "Status" + value: 0x8b + - name: "GroupID" + value: G1 + - name: "SceneID" + value: 0x03 + - label: "Step 7a: TH sends a CopyScene command to DUT with the mode field set to 0x00, the group identifier from field set to G1, the scene