Skip to content

Commit 0fff849

Browse files
Implemented missing yaml tests cases and added EFS validation in SceneHandlerImpl
1 parent 27a478f commit 0fff849

File tree

4 files changed

+260
-0
lines changed

4 files changed

+260
-0
lines changed

src/app/clusters/scenes-server/SceneHandlerImpl.cpp

+22
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,27 @@
2020
namespace chip {
2121
namespace scenes {
2222

23+
namespace {
24+
25+
/// ValideAttribute
26+
/// @brief Validate the attribute exists for a given cluster
27+
/// @param[in] clusterID Cluster ID
28+
/// @param[in] attID Attribute ID
29+
/// @return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE if the attribute does not exist for a given cluster or is not scenable
30+
// TODO: Assess if we also want to throw an error if the attribute value is out of range
31+
// TODO: Add check for "S" quality to determine if the attribute is scenable once suported :
32+
// https://github.com/project-chip/connectedhomeip/issues/24177
33+
CHIP_ERROR ValideAttribute(EndpointId endpoint, ClusterId cluster, AttributeId attributeId)
34+
{
35+
uint16_t attIndex = emberAfGetServerAttributeIndexByAttributeId(endpoint, cluster, attributeId);
36+
if (attIndex == UINT16_MAX)
37+
{
38+
return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE;
39+
}
40+
return CHIP_NO_ERROR;
41+
}
42+
} // namespace
43+
2344
CHIP_ERROR
2445
DefaultSceneHandlerImpl::EncodeAttributeValueList(const List<AttributeValuePairType> & aVlist, MutableByteSpan & serializedBytes)
2546
{
@@ -58,6 +79,7 @@ DefaultSceneHandlerImpl::SerializeAdd(EndpointId endpoint, const ExtensionFieldS
5879
auto pair_iterator = extensionFieldSet.attributeValueList.begin();
5980
while (pair_iterator.Next())
6081
{
82+
ReturnErrorOnFailure(ValideAttribute(endpoint, extensionFieldSet.clusterID, pair_iterator.GetValue().attributeID));
6183
aVPairs[pairCount] = pair_iterator.GetValue();
6284
pairCount++;
6385
}

src/app/clusters/scenes-server/scenes-server.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,10 @@ CHIP_ERROR AddResponseOnError(CommandHandlerInterface::HandlerContext & ctx, Res
7070
{
7171
resp.status = to_underlying(Protocols::InteractionModel::Status::ResourceExhausted);
7272
}
73+
else if (CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE == err)
74+
{
75+
resp.status = to_underlying(Protocols::InteractionModel::Status::InvalidCommand);
76+
}
7377
else
7478
{
7579
resp.status = to_underlying(StatusIB(err).mStatus);

src/app/tests/suites/certification/Test_TC_S_2_2.yaml

+159
Original file line numberDiff line numberDiff line change
@@ -431,6 +431,21 @@ tests:
431431
- name: "SceneID"
432432
value: 0x01
433433

434+
- label:
435+
"Step 4e: TH sends a RecallScene command to DUT with the GroupID field
436+
set to GI (Where GI is a group currently absent from the group table)
437+
and the SceneID field set to 0x01."
438+
PICS: S.S.C05.Rsp
439+
command: "RecallScene"
440+
arguments:
441+
values:
442+
- name: "GroupID"
443+
value: GI
444+
- name: "SceneID"
445+
value: 0x01
446+
response:
447+
error: INVALID_COMMAND
448+
434449
- label:
435450
"Step 5a: TH sends a ViewScene command to DUT with the GroupID field
436451
set to G1 and the SceneID field set to 0x01."
@@ -773,6 +788,150 @@ tests:
773788
- name: "SceneID"
774789
value: 0x01
775790

791+
- label:
792+
"Step 8f: TH sends a AddScene command to DUT with the GroupID field
793+
set to G1, the SceneID field set to 0x01, the TransitionTime field set
794+
to 1000 (1s) and extension field sets holding an invalid
795+
ExtensionField (Invalid attribute ID for given cluster). This should
796+
fail and return a status of 0x85 (INVALID_COMMAND)."
797+
PICS: S.S.C00.Rsp && PICS_SDK_CI_ONLY
798+
command: "AddScene"
799+
arguments:
800+
values:
801+
- name: "GroupID"
802+
value: G1
803+
- name: "SceneID"
804+
value: 0x01
805+
- name: "TransitionTime"
806+
value: 1000
807+
- name: "SceneName"
808+
value: "Scene1"
809+
- name: "ExtensionFieldSets"
810+
value:
811+
[
812+
{
813+
ClusterID: 0x0006,
814+
AttributeValueList:
815+
[{ AttributeID: 0xFFFF, AttributeValue: 0x01 }],
816+
},
817+
]
818+
response:
819+
values:
820+
- name: "Status"
821+
value: 0x85
822+
- name: "GroupID"
823+
value: G1
824+
- name: "SceneID"
825+
value: 0x01
826+
827+
- label:
828+
"Step 8f: TH sends a AddScene command to DUT with the GroupID field
829+
set to G1, the SceneID field set to 0x01, the TransitionTime field set
830+
to 1000 (1s) and extension field sets holding an invalid
831+
ExtensionField (Invalid attribute ID for given cluster). This should
832+
fail and return a status of 0x85 (INVALID_COMMAND)."
833+
verification: |
834+
./chip-tool scenesmanagement add-scene 0x0001 0x01 1000 "scene name" '[{"clusterID": "0x006", "attributeValueList":[{"attributeID": "0xFFFF", "attributeValue": "0x01"}]}]' 1 1
835+
836+
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)
837+
Log and below is the sample log provided for the raspi platform:
838+
839+
[1706763610.675038][4232:4234] CHIP:DMG: },
840+
[1706763610.675108][4232:4234] CHIP:DMG: Received Command Response Data, Endpoint=1 Cluster=0x0000_0062 Command=0x0000_0000
841+
[1706763610.675134][4232:4234] CHIP:TOO: Endpoint: 1 Cluster: 0x0000_0062 Command 0x0000_0000
842+
[1706763610.675187][4232:4234] CHIP:TOO: AddSceneResponse: {
843+
[1706763610.675215][4232:4234] CHIP:TOO: status: 133
844+
[1706763610.675229][4232:4234] CHIP:TOO: groupID: 1
845+
[1706763610.675244][4232:4234] CHIP:TOO: sceneID: 1
846+
[1706763610.675258][4232:4234] CHIP:TOO: }
847+
cluster: "LogCommands"
848+
command: "UserPrompt"
849+
PICS: PICS_SKIP_SAMPLE_APP
850+
arguments:
851+
values:
852+
- name: "message"
853+
value:
854+
"Please execute the add scene command with an invalid
855+
extensionfieldsets due to an Attribute not existing on a
856+
cluster on DUT and enter 'y' if the command returned a
857+
status of 0x85 (INVALID_COMMAND)"
858+
- name: "expectedValue"
859+
value: "y"
860+
861+
- label:
862+
"Step 8g: TH sends a AddScene command to DUT with the GroupID field
863+
set to G1, the SceneID field set to 0x01, the TransitionTime field set
864+
to 1000 (1s) and extension field sets holding an invalid
865+
ExtensionField (Unscenable attribute ID for given cluster). This
866+
should fail and return a status of 0x85 (INVALID_COMMAND)."
867+
## TODO: Enable once scenability check is possible, see issue: https://github.com/project-chip/connectedhomeip/issues/24177
868+
PICS: S.S.C00.Rsp && PICS_SDK_CI_ONLY
869+
command: "AddScene"
870+
arguments:
871+
values:
872+
- name: "GroupID"
873+
value: G1
874+
- name: "SceneID"
875+
value: 0x01
876+
- name: "TransitionTime"
877+
value: 1000
878+
- name: "SceneName"
879+
value: "Scene1"
880+
- name: "ExtensionFieldSets"
881+
value:
882+
[
883+
{
884+
ClusterID: 0x0006,
885+
AttributeValueList:
886+
[{ AttributeID: 0x4001, AttributeValue: 0x01 }],
887+
},
888+
]
889+
response:
890+
values:
891+
- name: "Status"
892+
value: 0x85
893+
- name: "GroupID"
894+
value: G1
895+
- name: "SceneID"
896+
value: 0x01
897+
disabled: true
898+
899+
- label:
900+
"Step 8g: TH sends a AddScene command to DUT with the GroupID field
901+
set to G1, the SceneID field set to 0x01, the TransitionTime field set
902+
to 1000 (1s) and extension field sets holding an invalid
903+
ExtensionField (Unscenable attribute ID for given cluster). This
904+
should fail and return a status of 0x85 (INVALID_COMMAND)."
905+
## TODO: Enable once scenability check is possible, see issue: https://github.com/project-chip/connectedhomeip/issues/24177
906+
verification: |
907+
./chip-tool scenesmanagement add-scene 0x0001 0x01 1000 "scene name" '[{"clusterID": "0x006", "attributeValueList":[{"attributeID": "0x4001", "attributeValue": "0x01"}]}]' 1 1
908+
909+
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)
910+
Log and below is the sample log provided for the raspi platform:
911+
912+
[1706763610.675038][4232:4234] CHIP:DMG: },
913+
[1706763610.675108][4232:4234] CHIP:DMG: Received Command Response Data, Endpoint=1 Cluster=0x0000_0062 Command=0x0000_0000
914+
[1706763610.675134][4232:4234] CHIP:TOO: Endpoint: 1 Cluster: 0x0000_0062 Command 0x0000_0000
915+
[1706763610.675187][4232:4234] CHIP:TOO: AddSceneResponse: {
916+
[1706763610.675215][4232:4234] CHIP:TOO: status: 133
917+
[1706763610.675229][4232:4234] CHIP:TOO: groupID: 1
918+
[1706763610.675244][4232:4234] CHIP:TOO: sceneID: 1
919+
[1706763610.675258][4232:4234] CHIP:TOO: }
920+
cluster: "LogCommands"
921+
command: "UserPrompt"
922+
PICS: PICS_SKIP_SAMPLE_APP
923+
arguments:
924+
values:
925+
- name: "message"
926+
value:
927+
"Please execute the add scene command with an invalid
928+
extensionfieldsets due to a non sceneable attribute not in
929+
an extensionfieldset on DUT and enter 'y' if the command
930+
returned a status of 0x85 (INVALID_COMMAND)"
931+
- name: "expectedValue"
932+
value: "y"
933+
disabled: true
934+
776935
- label:
777936
"Step 9a: TH sends a RemoveScene command to DUT with the GroupID field
778937
set to G1 and the SceneID field set to 0x01."

src/app/tests/suites/certification/Test_TC_S_2_3.yaml

+75
Original file line numberDiff line numberDiff line change
@@ -705,6 +705,81 @@ tests:
705705
- name: "SceneID"
706706
value: 0x03
707707

708+
- label:
709+
"Step 6f: TH sends a StoreScene command to to group G1 with the
710+
GroupID field set to G1 and the SceneID field set to 0x03."
711+
PICS: S.S.C04.Rsp
712+
command: "StoreScene"
713+
groupId: G1
714+
arguments:
715+
values:
716+
- name: "GroupID"
717+
value: G1
718+
- name: "SceneID"
719+
value: 0x03
720+
721+
- label:
722+
"Step 6g: TH sends a ViewScene command to DUT with the GroupID field
723+
set to G1 and the SceneID field set to 0x03."
724+
PICS: S.S.C01.Rsp && PICS_SDK_CI_ONLY
725+
command: "ViewScene"
726+
arguments:
727+
values:
728+
- name: "GroupID"
729+
value: G1
730+
- name: "SceneID"
731+
value: 0x03
732+
response:
733+
values:
734+
- name: "Status"
735+
value: 0x00
736+
- name: "GroupID"
737+
value: G1
738+
- name: "SceneID"
739+
value: 0x03
740+
741+
- label:
742+
"Step 6h: TH sends a RemoveScene command to group G1 with the GroupID
743+
field set to G1 and the SceneID field set to 0x03."
744+
PICS: S.S.C02.Rsp
745+
command: "RemoveScene"
746+
groupId: G1
747+
arguments:
748+
values:
749+
- name: "GroupID"
750+
value: G1
751+
- name: "SceneID"
752+
value: 0x03
753+
754+
- label: "Wait 1+ s to give CI time to process the RemoveScene command."
755+
PICS: PICS_SDK_CI_ONLY
756+
cluster: "DelayCommands"
757+
command: "WaitForMs"
758+
arguments:
759+
values:
760+
- name: "ms"
761+
value: 1250
762+
763+
- label:
764+
"Step 6i: TH sends a ViewScene command to DUT with the GroupID field
765+
set to G1 and the SceneID field set to 0x03."
766+
PICS: S.S.C01.Rsp
767+
command: "ViewScene"
768+
arguments:
769+
values:
770+
- name: "GroupID"
771+
value: G1
772+
- name: "SceneID"
773+
value: 0x03
774+
response:
775+
values:
776+
- name: "Status"
777+
value: 0x8b
778+
- name: "GroupID"
779+
value: G1
780+
- name: "SceneID"
781+
value: 0x03
782+
708783
- label:
709784
"Step 7a: TH sends a CopyScene command to DUT with the mode field set
710785
to 0x00, the group identifier from field set to G1, the scene

0 commit comments

Comments
 (0)