-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: Implement remaining TC acknowledgement test cases 2.9-2.11
Implements remaining test cases for Terms & Conditions acknowledgement verification: - TC-*-2.9: TCAcknowledgements reset after fabric removal - TC-*-2.10: Required terms validation - TC-*-2.11: Post-commission TC updates This completes the test coverage for TC acknowledgement verification, following up on the previous implementation of test cases 2.5-2.8. The new test cases verify: - TC state after fabric removal - Protection of required terms - Ability to update TC version and acknowledgements post-commissioning Testing: Test cases implemented according to test plan specifications. Each test verifies specific TC acknowledgement behaviors.
- Loading branch information
1 parent
0bf6099
commit 98a4ec8
Showing
7 changed files
with
719 additions
and
148 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,146 @@ | ||
# | ||
# Copyright (c) 2025 Project CHIP Authors | ||
# All rights reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
|
||
# === BEGIN CI TEST ARGUMENTS === | ||
# test-runner-runs: run1 | ||
# test-runner-run/run1/app: ${TERMS_AND_CONDITIONS_APP} | ||
# test-runner-run/run1/factoryreset: True | ||
# test-runner-run/run1/quiet: True | ||
# test-runner-run/run1/app-args: --KVS kvs1 --tc-min-required-version 1 --tc-required-acknowledgements 1 | ||
# test-runner-run/run1/script-args: --in-test-commissioning-method on-network --qr-code MT:-24J0AFN00KA0648G00 --trace-to json:log | ||
# === END CI TEST ARGUMENTS === | ||
|
||
import chip.clusters as Clusters | ||
from chip import ChipDeviceCtrl | ||
from chip.commissioning import ROOT_ENDPOINT_ID | ||
from chip.testing.matter_testing import MatterBaseTest, TestStep, async_test_body, default_matter_test_main | ||
from mobly import asserts | ||
|
||
|
||
class TC_CGEN_2_10(MatterBaseTest): | ||
def desc_TC_CGEN_2_10(self) -> str: | ||
return "[TC-CGEN-2.10] Verification that required terms can't be unset from TCAcknowledgements with SetTCAcknowledgements [DUT as Server]" | ||
|
||
def steps_TC_CGEN_2_10(self) -> list[TestStep]: | ||
return [ | ||
TestStep(1, "Read TCAcceptedVersion attribute"), | ||
TestStep(2, "Read TCAcknowledgements attribute"), | ||
TestStep(3, "Send SetTCAcknowledgements with TCVersion=0 and TCUserResponse=65535"), | ||
TestStep(4, "Verify TCAcceptedVersion unchanged"), | ||
TestStep(5, "Verify TCAcknowledgements unchanged"), | ||
TestStep(6, "Send SetTCAcknowledgements with TCVersion=acceptedVersion+1 and TCUserResponse=0"), | ||
TestStep(7, "Verify TCAcceptedVersion unchanged"), | ||
TestStep(8, "Verify TCAcknowledgements unchanged") | ||
] | ||
|
||
@async_test_body | ||
async def test_TC_CGEN_2_10(self): | ||
commissioner: ChipDeviceCtrl.ChipDeviceController = self.default_controller | ||
|
||
# Step 1: Read TCAcceptedVersion | ||
self.step(1) | ||
response = await commissioner.ReadAttribute( | ||
nodeid=self.dut_node_id, | ||
attributes=[(ROOT_ENDPOINT_ID, Clusters.GeneralCommissioning.Attributes.TCAcceptedVersion)]) | ||
accepted_version = response[ROOT_ENDPOINT_ID][Clusters.GeneralCommissioning][Clusters.GeneralCommissioning.Attributes.TCAcceptedVersion] | ||
|
||
# Step 2: Read TCAcknowledgements | ||
self.step(2) | ||
response = await commissioner.ReadAttribute( | ||
nodeid=self.dut_node_id, | ||
attributes=[(ROOT_ENDPOINT_ID, Clusters.GeneralCommissioning.Attributes.TCAcknowledgements)]) | ||
user_acknowledgements = response[ROOT_ENDPOINT_ID][Clusters.GeneralCommissioning][Clusters.GeneralCommissioning.Attributes.TCAcknowledgements] | ||
|
||
# Step 3: Send SetTCAcknowledgements with invalid version | ||
self.step(3) | ||
response = await commissioner.SendCommand( | ||
nodeid=self.dut_node_id, | ||
endpoint=ROOT_ENDPOINT_ID, | ||
payload=Clusters.GeneralCommissioning.Commands.SetTCAcknowledgements( | ||
TCVersion=0, | ||
TCUserResponse=65535), | ||
timedRequestTimeoutMs=1000) | ||
|
||
# Verify TCMinVersionNotMet error | ||
asserts.assert_equal( | ||
response.errorCode, | ||
Clusters.GeneralCommissioning.Enums.CommissioningErrorEnum.kTCMinVersionNotMet, | ||
'Expected TCMinVersionNotMet error') | ||
|
||
# Step 4: Verify TCAcceptedVersion unchanged | ||
self.step(4) | ||
response = await commissioner.ReadAttribute( | ||
nodeid=self.dut_node_id, | ||
attributes=[(ROOT_ENDPOINT_ID, Clusters.GeneralCommissioning.Attributes.TCAcceptedVersion)]) | ||
current_version = response[ROOT_ENDPOINT_ID][Clusters.GeneralCommissioning][Clusters.GeneralCommissioning.Attributes.TCAcceptedVersion] | ||
asserts.assert_equal( | ||
current_version, | ||
accepted_version, | ||
'TCAcceptedVersion changed unexpectedly') | ||
|
||
# Step 5: Verify TCAcknowledgements unchanged | ||
self.step(5) | ||
response = await commissioner.ReadAttribute( | ||
nodeid=self.dut_node_id, | ||
attributes=[(ROOT_ENDPOINT_ID, Clusters.GeneralCommissioning.Attributes.TCAcknowledgements)]) | ||
current_acknowledgements = response[ROOT_ENDPOINT_ID][Clusters.GeneralCommissioning][Clusters.GeneralCommissioning.Attributes.TCAcknowledgements] | ||
asserts.assert_equal( | ||
current_acknowledgements, | ||
user_acknowledgements, | ||
'TCAcknowledgements changed unexpectedly') | ||
|
||
# Step 6: Send SetTCAcknowledgements with invalid response | ||
self.step(6) | ||
response = await commissioner.SendCommand( | ||
nodeid=self.dut_node_id, | ||
endpoint=ROOT_ENDPOINT_ID, | ||
payload=Clusters.GeneralCommissioning.Commands.SetTCAcknowledgements( | ||
TCVersion=accepted_version + 1, | ||
TCUserResponse=0), | ||
timedRequestTimeoutMs=1000) | ||
|
||
# Verify RequiredTCNotAccepted error | ||
asserts.assert_equal( | ||
response.errorCode, | ||
Clusters.GeneralCommissioning.Enums.CommissioningErrorEnum.kRequiredTCNotAccepted, | ||
'Expected RequiredTCNotAccepted error') | ||
|
||
# Step 7: Verify TCAcceptedVersion still unchanged | ||
self.step(7) | ||
response = await commissioner.ReadAttribute( | ||
nodeid=self.dut_node_id, | ||
attributes=[(ROOT_ENDPOINT_ID, Clusters.GeneralCommissioning.Attributes.TCAcceptedVersion)]) | ||
current_version = response[ROOT_ENDPOINT_ID][Clusters.GeneralCommissioning][Clusters.GeneralCommissioning.Attributes.TCAcceptedVersion] | ||
asserts.assert_equal( | ||
current_version, | ||
accepted_version, | ||
'TCAcceptedVersion changed unexpectedly after second attempt') | ||
|
||
# Step 8: Verify TCAcknowledgements still unchanged | ||
self.step(8) | ||
response = await commissioner.ReadAttribute( | ||
nodeid=self.dut_node_id, | ||
attributes=[(ROOT_ENDPOINT_ID, Clusters.GeneralCommissioning.Attributes.TCAcknowledgements)]) | ||
current_acknowledgements = response[ROOT_ENDPOINT_ID][Clusters.GeneralCommissioning][Clusters.GeneralCommissioning.Attributes.TCAcknowledgements] | ||
asserts.assert_equal( | ||
current_acknowledgements, | ||
user_acknowledgements, | ||
'TCAcknowledgements changed unexpectedly after second attempt') | ||
|
||
|
||
if __name__ == "__main__": | ||
default_matter_test_main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,146 @@ | ||
# | ||
# Copyright (c) 2025 Project CHIP Authors | ||
# All rights reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
|
||
# === BEGIN CI TEST ARGUMENTS === | ||
# test-runner-runs: run1 | ||
# test-runner-run/run1/app: ${TERMS_AND_CONDITIONS_APP} | ||
# test-runner-run/run1/factoryreset: True | ||
# test-runner-run/run1/quiet: True | ||
# test-runner-run/run1/app-args: --KVS kvs1 --tc-min-required-version 1 --tc-required-acknowledgements 1 | ||
# test-runner-run/run1/script-args: --in-test-commissioning-method on-network --qr-code MT:-24J0AFN00KA0648G00 --trace-to json:log | ||
# === END CI TEST ARGUMENTS === | ||
|
||
import chip.clusters as Clusters | ||
from chip import ChipDeviceCtrl | ||
from chip.commissioning import ROOT_ENDPOINT_ID | ||
from chip.testing.matter_testing import MatterBaseTest, TestStep, async_test_body, default_matter_test_main | ||
from mobly import asserts | ||
|
||
|
||
class TC_CGEN_2_11(MatterBaseTest): | ||
def desc_TC_CGEN_2_11(self) -> str: | ||
return "[TC-CGEN-2.11] Verification that TCAcknowledgements and TCAcceptedVersion can be updated after being commissioned [DUT as Server]" | ||
|
||
def steps_TC_CGEN_2_11(self) -> list[TestStep]: | ||
return [ | ||
TestStep(1, "TH begins commissioning the DUT with PASE, failsafe setup, and basic configuration"), | ||
TestStep(2, "TH sends SetTCAcknowledgements with initial TC values"), | ||
TestStep(3, "TH sends CommissioningComplete to DUT"), | ||
TestStep(4, "TH sends SetTCAcknowledgements with updated TC version"), | ||
TestStep(5, "Verify TCAcceptedVersion is updated"), | ||
TestStep(6, "TH sends SetTCAcknowledgements with maximum acknowledgements"), | ||
TestStep(7, "Verify TCAcknowledgements is updated") | ||
] | ||
|
||
@async_test_body | ||
async def test_TC_CGEN_2_11(self): | ||
commissioner: ChipDeviceCtrl.ChipDeviceController = self.default_controller | ||
|
||
# Step 1: Begin commissioning with PASE and failsafe | ||
self.step(1) | ||
commissioner.SetSkipCommissioningComplete(True) | ||
self.matter_test_config.commissioning_method = self.matter_test_config.in_test_commissioning_method | ||
await self.commission_devices() | ||
|
||
# Step 2: Send initial SetTCAcknowledgements | ||
self.step(2) | ||
response = await commissioner.SendCommand( | ||
nodeid=self.dut_node_id, | ||
endpoint=ROOT_ENDPOINT_ID, | ||
payload=Clusters.GeneralCommissioning.Commands.SetTCAcknowledgements( | ||
TCVersion=self.pixit['CGEN']['TCRevision'], | ||
TCUserResponse=self.pixit['CGEN']['RequiredTCAcknowledgements']), | ||
timedRequestTimeoutMs=1000) | ||
|
||
# Verify initial SetTCAcknowledgements response | ||
asserts.assert_equal( | ||
response.errorCode, | ||
Clusters.GeneralCommissioning.Enums.CommissioningErrorEnum.kOk, | ||
'Initial SetTCAcknowledgements failed') | ||
|
||
# Step 3: Send CommissioningComplete | ||
self.step(3) | ||
response = await commissioner.SendCommand( | ||
nodeid=self.dut_node_id, | ||
endpoint=ROOT_ENDPOINT_ID, | ||
payload=Clusters.GeneralCommissioning.Commands.CommissioningComplete(), | ||
timedRequestTimeoutMs=1000) | ||
|
||
# Verify CommissioningComplete response | ||
asserts.assert_equal( | ||
response.errorCode, | ||
Clusters.GeneralCommissioning.Enums.CommissioningErrorEnum.kOk, | ||
'CommissioningComplete failed') | ||
|
||
# Step 4: Send SetTCAcknowledgements with updated version | ||
self.step(4) | ||
updated_tc_version = self.pixit['CGEN']['TCRevision'] + 1 | ||
response = await commissioner.SendCommand( | ||
nodeid=self.dut_node_id, | ||
endpoint=ROOT_ENDPOINT_ID, | ||
payload=Clusters.GeneralCommissioning.Commands.SetTCAcknowledgements( | ||
TCVersion=updated_tc_version, | ||
TCUserResponse=self.pixit['CGEN']['RequiredTCAcknowledgements']), | ||
timedRequestTimeoutMs=1000) | ||
|
||
# Verify SetTCAcknowledgements response with updated version | ||
asserts.assert_equal( | ||
response.errorCode, | ||
Clusters.GeneralCommissioning.Enums.CommissioningErrorEnum.kOk, | ||
'SetTCAcknowledgements with updated version failed') | ||
|
||
# Step 5: Verify TCAcceptedVersion is updated | ||
self.step(5) | ||
response = await commissioner.ReadAttribute( | ||
nodeid=self.dut_node_id, | ||
attributes=[(ROOT_ENDPOINT_ID, Clusters.GeneralCommissioning.Attributes.TCAcceptedVersion)]) | ||
current_version = response[ROOT_ENDPOINT_ID][Clusters.GeneralCommissioning][Clusters.GeneralCommissioning.Attributes.TCAcceptedVersion] | ||
asserts.assert_equal( | ||
current_version, | ||
updated_tc_version, | ||
'TCAcceptedVersion not updated correctly') | ||
|
||
# Step 6: Send SetTCAcknowledgements with maximum acknowledgements | ||
self.step(6) | ||
response = await commissioner.SendCommand( | ||
nodeid=self.dut_node_id, | ||
endpoint=ROOT_ENDPOINT_ID, | ||
payload=Clusters.GeneralCommissioning.Commands.SetTCAcknowledgements( | ||
TCVersion=updated_tc_version, | ||
TCUserResponse=65535), | ||
timedRequestTimeoutMs=1000) | ||
|
||
# Verify SetTCAcknowledgements response with maximum acknowledgements | ||
asserts.assert_equal( | ||
response.errorCode, | ||
Clusters.GeneralCommissioning.Enums.CommissioningErrorEnum.kOk, | ||
'SetTCAcknowledgements with maximum acknowledgements failed') | ||
|
||
# Step 7: Verify TCAcknowledgements is updated | ||
self.step(7) | ||
response = await commissioner.ReadAttribute( | ||
nodeid=self.dut_node_id, | ||
attributes=[(ROOT_ENDPOINT_ID, Clusters.GeneralCommissioning.Attributes.TCAcknowledgements)]) | ||
current_acknowledgements = response[ROOT_ENDPOINT_ID][Clusters.GeneralCommissioning][Clusters.GeneralCommissioning.Attributes.TCAcknowledgements] | ||
asserts.assert_equal( | ||
current_acknowledgements, | ||
65535, | ||
'TCAcknowledgements not updated to maximum value') | ||
|
||
|
||
if __name__ == "__main__": | ||
default_matter_test_main() |
Oops, something went wrong.