Skip to content

Commit

Permalink
Add tests for TC-SC-5.1/2 (#24454)
Browse files Browse the repository at this point in the history
* Add tests for TC-SC-5.1/2

Also add key material to match.

* Restyled by clang-format

* Restyled by prettier-yaml

* Groups uses GroupID. GroupKeyManagement uses GroupId

...and GroupID. For fun.

* Fix formatting.

Co-authored-by: Restyled.io <[email protected]>
  • Loading branch information
cecille and restyled-commits authored Jan 25, 2023
1 parent bf91152 commit e1400a9
Show file tree
Hide file tree
Showing 7 changed files with 2,558 additions and 853 deletions.
747 changes: 216 additions & 531 deletions src/app/tests/suites/certification/Test_TC_SC_5_1.yaml

Large diffs are not rendered by default.

158 changes: 126 additions & 32 deletions src/app/tests/suites/certification/Test_TC_SC_5_2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,47 +20,141 @@ PICS:

config:
nodeId: 0x12344321
cluster: "Basic Information"
endpoint: 0
cluster: "Groups"
# Users should set endpoint value on the command line to PIXIT.G.ENDPOINT
endpoint: 1

tests:
- label: "Precondition"
verification: |
DUT and TH are commissioned.
- label: "Wait for the commissioned device to be retrieved"
cluster: "DelayCommands"
command: "WaitForCommissionee"
arguments:
values:
- name: "nodeId"
value: nodeId

DUT and TH are part of a common group.- Run TC-SC-5.1 to establish this precondition
- label: "TH adds ACL Operate privileges for Group 0x0103"
cluster: "Access Control"
endpoint: 0
command: "writeAttribute"
attribute: "ACL"
arguments:
value:
[
{
FabricIndex: 1,
Privilege: 5,
AuthMode: 2,
Subjects: [commissionerNodeId],
Targets: null,
},
{
FabricIndex: 1,
Privilege: 3,
AuthMode: 3,
Subjects: [0x0103],
Targets: null,
},
]

DUT supports the Identify cluster
disabled: true
- label: "TH sends KeySetWrite command with TH key"
cluster: "Group Key Management"
endpoint: 0
command: "KeySetWrite"
arguments:
values:
- name: GroupKeySet
value:
{
GroupKeySetID: 0x01a3,
GroupKeySecurityPolicy: 0,
EpochKey0: "0xd0d1d2d3d4d5d6d7d8d9dadbdcdddedf",
EpochStartTime0: 2220000,
EpochKey1: "0xd1d1d2d3d4d5d6d7d8d9dadbdcdddedf",
EpochStartTime1: 2220001,
EpochKey2: "0xd2d1d2d3d4d5d6d7d8d9dadbdcdddedf",
EpochStartTime2: 2220002,
}

- label: "TH writes ACL entry by setting AuthMode as Group to DUT"
verification: |
As this step is executed in the TC-SC-5.1, we can skip this step during execution.
disabled: true
- label: "TH binds GroupId to GroupKeySet"
cluster: "Group Key Management"
endpoint: 0
command: "writeAttribute"
attribute: "GroupKeyMap"
arguments:
value: [{ FabricIndex: 1, GroupId: 0x0103, GroupKeySetID: 0x01a3 }]

- label:
"TH sends a multicast Identify command with the IdentifyTime set to
0x0078 (120s) to DUT with GroupID and PIXIT.G.ENDPOINT"
PICS: I.S.C00.Rsp
verification: |
./chip-tool identify identify 0x0078 0xffffffffffff0001 1
- label: "TH sends RemoveAllGroups command"
command: "RemoveAllGroups"

Verify Identify command on the TH(chip-tool) Log and below is the sample log provided for the raspi platform:
- label: "TH sends AddGroup command"
command: "AddGroup"
arguments:
values:
- name: GroupID
value: 0x0103
- name: GroupName
value: "Test Group"

- label: "TH sends ViewGroup command using group messaging"
PICS: G.S.F00
command: "ViewGroup"
groupId: 0x0103
arguments:
values:
- name: GroupID
value: 0x0103
response:
values:
- name: Status
value: 0
- name: GroupID
value: 0x0103
- name: GroupName
value: "Test Group"

[1657785273.973231][1618:1623] CHIP:DL: HandlePlatformSpecificBLEEvent 32784[1657785273.973291][1618:1623] CHIP:TOO: Sending command to group 0x1
[1657785273.973316][1618:1623] CHIP:TOO: Sending cluster (0x00000003) command (0x00000000) on Group 1
disabled: true
- label: "TH sends ViewGroup command using group messaging"
PICS: "!(G.S.F00)"
command: "ViewGroup"
groupId: 0x0103
arguments:
values:
- name: GroupID
value: 0x0103
response:
values:
- name: Status
value: 0
- name: GroupID
value: 0x0103
- name: GroupName
value: ""

- label:
"TH reads immediately IdentifyTime attribute from DUT on the
PIXIT.G.ENDPOINT set by DUT"
PICS: I.S.A0000
verification: |
./chip-tool identify read identify-time 1 1
- label: "TH removes the GroupKeySet"
cluster: "Group Key Management"
endpoint: 0
command: "KeySetRemove"
arguments:
values:
- name: GroupKeySetID
value: 0x01a3

Verify Identify time is approximately equal to 0x0078 (120s),on the TH(chip-tool) Log and below is the sample log provided for the raspi platform:
- label: "TH cleans up groups using RemoveAllGroups command"
command: "RemoveAllGroups"

[1657785288.647504][1624:1629] CHIP:TOO: Endpoint: 1 Cluster: 0x0000_0003 Attribute 0x0000_0000 DataVersion: 1130139861
[1657785288.647621][1624:1629] CHIP:TOO: identify time: 120
disabled: true
- label: "TH removes ACL Operate privileges for Group 0x0103"
cluster: "Access Control"
endpoint: 0
command: "writeAttribute"
attribute: "ACL"
arguments:
value:
[
{
FabricIndex: 1,
Privilege: 5,
AuthMode: 2,
Subjects: [commissionerNodeId],
Targets: null,
},
]
2 changes: 1 addition & 1 deletion src/app/tests/suites/ciTests.json
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@
],
"PowerSourceConfiguration": ["Test_TC_PSCFG_1_1", "Test_TC_PSCFG_2_1"],
"RelativeHumidityMeasurement": ["Test_TC_RH_1_1", "Test_TC_RH_2_1"],
"SecureChannel": [],
"SecureChannel": ["Test_TC_SC_5_1", "Test_TC_SC_5_2"],
"Switch": ["Test_TC_SWTCH_1_1", "Test_TC_SWTCH_2_1"],
"TemperatureMeasurement": ["Test_TC_TMP_1_1", "Test_TC_TMP_2_1"],
"Thermostat": [
Expand Down
2 changes: 0 additions & 2 deletions src/app/tests/suites/manualTests.json
Original file line number Diff line number Diff line change
Expand Up @@ -227,8 +227,6 @@
"Test_TC_SC_4_8",
"Test_TC_SC_4_9",
"Test_TC_SC_4_10",
"Test_TC_SC_5_1",
"Test_TC_SC_5_2",
"Test_TC_SC_5_3",
"Test_TC_SC_6_1"
],
Expand Down
18 changes: 18 additions & 0 deletions src/lib/support/TestGroupData.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,10 @@ inline CHIP_ERROR InitData(chip::Credentials::GroupDataProvider * provider, chip
{
static const chip::GroupId kGroup1 = 0x0101;
static const chip::GroupId kGroup2 = 0x0102;
static const chip::GroupId kGroup3 = 0x0103;
static const chip::KeysetId kKeySet1 = 0x01a1;
static const chip::KeysetId kKeySet2 = 0x01a2;
static const chip::KeysetId kKeySet3 = 0x01a3;

// Groups

Expand All @@ -57,6 +59,10 @@ inline CHIP_ERROR InitData(chip::Credentials::GroupDataProvider * provider, chip
ReturnErrorOnFailure(provider->SetGroupInfo(fabric_index, group2));
ReturnErrorOnFailure(provider->AddEndpoint(fabric_index, group2.group_id, 0));

const chip::Credentials::GroupDataProvider::GroupInfo group3(kGroup3, "Group #3");
ReturnErrorOnFailure(provider->SetGroupInfo(fabric_index, group3));
ReturnErrorOnFailure(provider->AddEndpoint(fabric_index, group3.group_id, 0));

// Key Sets

chip::Credentials::GroupDataProvider::KeySet keyset1(kKeySet1,
Expand All @@ -81,8 +87,20 @@ inline CHIP_ERROR InitData(chip::Credentials::GroupDataProvider * provider, chip
err = provider->SetKeySet(fabric_index, compressed_fabric_id, keyset2);
ReturnErrorOnFailure(err);

chip::Credentials::GroupDataProvider::KeySet keyset3(kKeySet3,
chip::Credentials::GroupDataProvider::SecurityPolicy::kTrustFirst, 3);
const chip::Credentials::GroupDataProvider::EpochKey epoch_keys3[] = {
{ 2220000, { 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf } },
{ 2220001, { 0xd1, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf } },
{ 2220002, { 0xd2, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf } },
};
memcpy(keyset3.epoch_keys, epoch_keys3, sizeof(epoch_keys3));
err = provider->SetKeySet(fabric_index, compressed_fabric_id, keyset3);
ReturnErrorOnFailure(err);

provider->SetGroupKeyAt(fabric_index, 0, chip::Credentials::GroupDataProvider::GroupKey(kGroup1, kKeySet1));
provider->SetGroupKeyAt(fabric_index, 1, chip::Credentials::GroupDataProvider::GroupKey(kGroup2, kKeySet2));
provider->SetGroupKeyAt(fabric_index, 2, chip::Credentials::GroupDataProvider::GroupKey(kGroup3, kKeySet3));

return CHIP_NO_ERROR;
}
Expand Down
Loading

0 comments on commit e1400a9

Please sign in to comment.