Skip to content

Commit

Permalink
feat(testing): Add PICS guard for Terms & Conditions test steps
Browse files Browse the repository at this point in the history
- Wrap test steps in PICS guard checks for "CGEN.S" and "CGEN.S.F00(TC)"
- Ensure test steps only execute when Terms & Conditions feature flag is enabled
- Maintain test logic while adding conditional execution based on PICS support
  • Loading branch information
swan-amazon committed Jan 22, 2025
1 parent 28565c1 commit 451e82c
Show file tree
Hide file tree
Showing 8 changed files with 221 additions and 39 deletions.
9 changes: 8 additions & 1 deletion src/app/tests/suites/certification/ci-pics-values
Original file line number Diff line number Diff line change
Expand Up @@ -729,6 +729,7 @@ SWTCH.C.AO-READ=0
SWTCH.C.AO-WRITE=0

# General Commissioning Cluster
CGEN.C=1
CGEN.S=1
CGEN.S.A0000=1
CGEN.S.A0001=1
Expand All @@ -742,7 +743,13 @@ CGEN.S.C03.Tx=1
CGEN.S.C04.Rsp=1
CGEN.S.C05.Tx=1

CGEN.C=1
#Feature
CGEN.S.F00(TC)=1

#PIXIT
PIXIT.CGEN.FailsafeExpiryLengthSeconds=0
PIXIT.CGEN.RequiredTCAcknowledgements=1
PIXIT.CGEN.TCRevision=1

# LAUNDRY WASHER MODE CLUSTER
LWM.S=1
Expand Down
22 changes: 21 additions & 1 deletion src/python_testing/TC_CGEN_2_10.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
# --custom-flow 2
# --capabilities 6
# script-args:
# --commissioning-method on-network
# --PICS src/app/tests/suites/certification/ci-pics-values
# --in-test-commissioning-method on-network
# --tc-version-to-simulate 1
# --tc-user-response-to-simulate 1
# --qr-code MT:-24J0AFN00KA0648G00
Expand All @@ -46,8 +47,13 @@ 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 pics_TC_CGEN_2_10(self) -> list[str]:
""" This function returns a list of PICS for this test case that must be True for the test to be run"""
return ["CGEN.S", "CGEN.S.F00(TC)"]

def steps_TC_CGEN_2_10(self) -> list[TestStep]:
return [
TestStep(0, description="", expectation="", is_commissioning=False),
TestStep(1, "TH reads from the DUT the attribute TCAcceptedVersion. Store the value as acceptedVersion."),
TestStep(2, "TH reads from the DUT the attribute TCAcknowledgements. Store the value as userAcknowledgements."),
TestStep(3, "TH Sends the SetTCAcknowledgements command to the DUT with the fields set as follows:\n* TCVersion: 0\n* TCUserResponse: 65535"),
Expand All @@ -61,8 +67,22 @@ def steps_TC_CGEN_2_10(self) -> list[TestStep]:
@async_test_body
async def test_TC_CGEN_2_10(self):
commissioner: ChipDeviceCtrl.ChipDeviceController = self.default_controller

self.step(0)
if not self.pics_guard(self.check_pics("CGEN.S.F00(TC)")):
self.skip_all_remaining_steps(1)
return

# Step 1: Begin commissioning with PASE and failsafe
commissioner.SetSkipCommissioningComplete(True)
self.matter_test_config.commissioning_method = self.matter_test_config.in_test_commissioning_method
self.matter_test_config.tc_version_to_simulate = None
self.matter_test_config.tc_user_response_to_simulate = None
await self.commission_devices()

# await self.commission_devices()
# self.skip_all_remaining_steps(1)
# return
# Step 1: Read TCAcceptedVersion
self.step(1)
response = await commissioner.ReadAttribute(nodeid=self.dut_node_id, attributes=[(ROOT_ENDPOINT_ID, Clusters.GeneralCommissioning.Attributes.TCAcceptedVersion)])
Expand Down
33 changes: 29 additions & 4 deletions src/python_testing/TC_CGEN_2_11.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,11 @@
# --custom-flow 2
# --capabilities 6
# script-args:
# --PICS src/app/tests/suites/certification/ci-pics-values
# --in-test-commissioning-method on-network
# --tc-version-to-simulate 1
# --tc-user-response-to-simulate 1
# --int-arg PIXIT.CGEN.FailsafeExpiryLengthSeconds:900
# --int-arg PIXIT.CGEN.RequiredTCAcknowledgements:1
# --int-arg PIXIT.CGEN.TCRevision:1
# --qr-code MT:-24J0AFN00KA0648G00
# --trace-to json:log
# factoryreset: True
Expand All @@ -46,8 +48,13 @@ 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 pics_TC_CGEN_2_11(self) -> list[str]:
""" This function returns a list of PICS for this test case that must be True for the test to be run"""
return ["CGEN.S", "CGEN.S.F00(TC)"]

def steps_TC_CGEN_2_11(self) -> list[TestStep]:
return [
TestStep(0, description="", expectation="", is_commissioning=False),
TestStep(1, "TH begins commissioning the DUT and performs the following steps in order:\n* Security setup using PASE\n* Setup fail-safe timer, with ExpiryLengthSeconds field set to PIXIT.CGEN.FailsafeExpiryLengthSeconds and the Breadcrumb value as 1\n* Configure information- UTC time, regulatory, etc."),
TestStep(2, "TH sends SetTCAcknowledgements to DUT with the following values:\n* TCVersion: PIXIT.CGEN.TCRevision\n* TCUserResponse: PIXIT.CGEN.RequiredTCAcknowledgements"),
TestStep(3, "TH sends CommissioningComplete to DUT."),
Expand All @@ -60,8 +67,14 @@ def steps_TC_CGEN_2_11(self) -> list[TestStep]:
@async_test_body
async def test_TC_CGEN_2_11(self):
commissioner: ChipDeviceCtrl.ChipDeviceController = self.default_controller
tc_version_to_simulate: int = self.matter_test_config.tc_version_to_simulate
tc_user_response_to_simulate: int = self.matter_test_config.tc_user_response_to_simulate
failsafe_expiry_length_seconds = self.matter_test_config.global_test_params['PIXIT.CGEN.FailsafeExpiryLengthSeconds']
tc_version_to_simulate = self.matter_test_config.global_test_params['PIXIT.CGEN.TCRevision']
tc_user_response_to_simulate = self.matter_test_config.global_test_params['PIXIT.CGEN.RequiredTCAcknowledgements']

self.step(0)
if not self.pics_guard(self.check_pics("CGEN.S.F00(TC)")):
self.skip_all_remaining_steps(1)
return

# Step 1: Begin commissioning with PASE and failsafe
self.step(1)
Expand All @@ -71,6 +84,18 @@ async def test_TC_CGEN_2_11(self):
self.matter_test_config.tc_user_response_to_simulate = None
await self.commission_devices()

response = await commissioner.SendCommand(
nodeid=self.dut_node_id,
endpoint=ROOT_ENDPOINT_ID,
payload=Clusters.GeneralCommissioning.Commands.ArmFailSafe(
expiryLengthSeconds=failsafe_expiry_length_seconds, breadcrumb=1),
)
asserts.assert_equal(
response.errorCode,
Clusters.GeneralCommissioning.Enums.CommissioningErrorEnum.kOk,
"ArmFailSafeResponse error code is not OK.",
)

# Step 2: Send initial SetTCAcknowledgements
self.step(2)
response = await commissioner.SendCommand(
Expand Down
34 changes: 30 additions & 4 deletions src/python_testing/TC_CGEN_2_5.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,11 @@
# --custom-flow 2
# --capabilities 6
# script-args:
# --PICS src/app/tests/suites/certification/ci-pics-values
# --in-test-commissioning-method on-network
# --tc-version-to-simulate 1
# --tc-user-response-to-simulate 1
# --int-arg PIXIT.CGEN.FailsafeExpiryLengthSeconds:900
# --int-arg PIXIT.CGEN.RequiredTCAcknowledgements:1
# --int-arg PIXIT.CGEN.TCRevision:1
# --qr-code MT:-24J0AFN00KA0648G00
# --trace-to json:log
# factoryreset: True
Expand All @@ -47,8 +49,13 @@ class TC_CGEN_2_5(MatterBaseTest):
def desc_TC_CGEN_2_5(self) -> str:
return "[TC-CGEN-2.5] Verification for SetTCAcknowledgements [DUT as Server]"

def pics_TC_CGEN_2_5(self) -> list[str]:
""" This function returns a list of PICS for this test case that must be True for the test to be run"""
return ["CGEN.S", "CGEN.S.F00(TC)"]

def steps_TC_CGEN_2_5(self) -> list[TestStep]:
return [
TestStep(0, description="", expectation="", is_commissioning=False),
TestStep(1, "TH begins commissioning the DUT and performs the following steps in order:\n* Security setup using PASE\n* Setup fail-safe timer, with ExpiryLengthSeconds field set to PIXIT.CGEN.FailsafeExpiryLengthSeconds and the Breadcrumb value as 1\n* Configure information- UTC time, regulatory, etc."),
TestStep(2, "TH reads TCAcknowledgementsRequired attribute from the DUT"),
TestStep(3, "TH reads TCUpdateDeadline attribute from the DUT"),
Expand All @@ -66,8 +73,15 @@ def steps_TC_CGEN_2_5(self) -> list[TestStep]:
@async_test_body
async def test_TC_CGEN_2_5(self):
commissioner: ChipDeviceCtrl.ChipDeviceController = self.default_controller
tc_version_to_simulate: int = self.matter_test_config.tc_version_to_simulate
tc_user_response_to_simulate: int = self.matter_test_config.tc_user_response_to_simulate

failsafe_expiry_length_seconds = self.matter_test_config.global_test_params['PIXIT.CGEN.FailsafeExpiryLengthSeconds']
tc_version_to_simulate = self.matter_test_config.global_test_params['PIXIT.CGEN.TCRevision']
tc_user_response_to_simulate = self.matter_test_config.global_test_params['PIXIT.CGEN.RequiredTCAcknowledgements']

self.step(0)
if not self.pics_guard(self.check_pics("CGEN.S.F00(TC)")):
self.skip_all_remaining_steps(1)
return

# Step 1: Begin commissioning with PASE and failsafe
self.step(1)
Expand All @@ -77,6 +91,18 @@ async def test_TC_CGEN_2_5(self):
self.matter_test_config.tc_user_response_to_simulate = None
await self.commission_devices()

response = await commissioner.SendCommand(
nodeid=self.dut_node_id,
endpoint=ROOT_ENDPOINT_ID,
payload=Clusters.GeneralCommissioning.Commands.ArmFailSafe(
expiryLengthSeconds=failsafe_expiry_length_seconds, breadcrumb=1),
)
asserts.assert_equal(
response.errorCode,
Clusters.GeneralCommissioning.Enums.CommissioningErrorEnum.kOk,
"ArmFailSafeResponse error code is not OK.",
)

# Step 2: Read TCAcknowledgementsRequired
self.step(2)
response = await commissioner.ReadAttribute(nodeid=self.dut_node_id, attributes=[(ROOT_ENDPOINT_ID, Clusters.GeneralCommissioning.Attributes.TCAcknowledgementsRequired)])
Expand Down
11 changes: 11 additions & 0 deletions src/python_testing/TC_CGEN_2_6.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
# --custom-flow 2
# --capabilities 6
# script-args:
# --PICS src/app/tests/suites/certification/ci-pics-values
# --in-test-commissioning-method on-network
# --qr-code MT:-24J0AFN00KA0648G00
# --trace-to json:log
Expand All @@ -44,8 +45,13 @@ class TC_CGEN_2_6(MatterBaseTest):
def desc_TC_CGEN_2_6(self) -> str:
return "[TC-CGEN-2.6] Verification for CommissioningComplete no terms accepted when required [DUT as Server]"

def pics_TC_CGEN_2_6(self) -> list[str]:
""" This function returns a list of PICS for this test case that must be True for the test to be run"""
return ["CGEN.S", "CGEN.S.F00(TC)"]

def steps_TC_CGEN_2_6(self) -> list[TestStep]:
return [
TestStep(0, description="", expectation="", is_commissioning=False),
TestStep(1, "TH starts commissioning the DUT. It performs all commissioning steps from 'Device discovery and establish commissioning channel' to 'Security setup using CASE', except for TC configuration with SetTCAcknowledgements."),
TestStep(2, "TH sends CommissioningComplete to DUT."),
]
Expand All @@ -54,6 +60,11 @@ def steps_TC_CGEN_2_6(self) -> list[TestStep]:
async def test_TC_CGEN_2_6(self):
commissioner: ChipDeviceCtrl.ChipDeviceController = self.default_controller

self.step(0)
if not self.pics_guard(self.check_pics("CGEN.S.F00(TC)")):
self.skip_all_remaining_steps(1)
return

# Step 1: Commission device without setting TC acknowledgements
self.step(1)
# Don't set TCs for the next commissioning and skip CommissioningComplete so we can manually call CommissioningComplete to check the response error code
Expand Down
33 changes: 29 additions & 4 deletions src/python_testing/TC_CGEN_2_7.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,11 @@
# --custom-flow 2
# --capabilities 6
# script-args:
# --PICS src/app/tests/suites/certification/ci-pics-values
# --in-test-commissioning-method on-network
# --tc-version-to-simulate 1
# --tc-user-response-to-simulate 1
# --int-arg PIXIT.CGEN.FailsafeExpiryLengthSeconds:900
# --int-arg PIXIT.CGEN.RequiredTCAcknowledgements:1
# --int-arg PIXIT.CGEN.TCRevision:1
# --qr-code MT:-24J0AFN00KA0648G00
# --trace-to json:log
# factoryreset: True
Expand All @@ -46,8 +48,13 @@ class TC_CGEN_2_7(MatterBaseTest):
def desc_TC_CGEN_2_7(self) -> str:
return "[TC-CGEN-2.7] Verification for CommissioningComplete when SetTCAcknowledgements provides invalid terms [DUT as Server]"

def pics_TC_CGEN_2_7(self) -> list[str]:
""" This function returns a list of PICS for this test case that must be True for the test to be run"""
return ["CGEN.S", "CGEN.S.F00(TC)"]

def steps_TC_CGEN_2_7(self) -> list[TestStep]:
return [
TestStep(0, description="", expectation="", is_commissioning=False),
TestStep(1, "TH begins commissioning the DUT and performs the following steps in order:\n* Security setup using PASE\n* Setup fail-safe timer, with ExpiryLengthSeconds field set to PIXIT.CGEN.FailsafeExpiryLengthSeconds and the Breadcrumb value as 1\n* Configure information- UTC time, regulatory, etc."),
TestStep(2, "TH reads from the DUT the attribute TCMinRequiredVersion. Store the value as minVersion."),
TestStep(3, "TH sends SetTCAcknowledgements to DUT with the following values:\n* TCVersion: minVersion\n* TCUserResponse: 0"),
Expand All @@ -60,8 +67,14 @@ def steps_TC_CGEN_2_7(self) -> list[TestStep]:
@async_test_body
async def test_TC_CGEN_2_7(self):
commissioner: ChipDeviceCtrl.ChipDeviceController = self.default_controller
tc_version_to_simulate: int = self.matter_test_config.tc_version_to_simulate
tc_user_response_to_simulate: int = self.matter_test_config.tc_user_response_to_simulate
failsafe_expiry_length_seconds = self.matter_test_config.global_test_params['PIXIT.CGEN.FailsafeExpiryLengthSeconds']
tc_version_to_simulate = self.matter_test_config.global_test_params['PIXIT.CGEN.TCRevision']
tc_user_response_to_simulate = self.matter_test_config.global_test_params['PIXIT.CGEN.RequiredTCAcknowledgements']

self.step(0)
if not self.pics_guard(self.check_pics("CGEN.S.F00(TC)")):
self.skip_all_remaining_steps(1)
return

# Step 1: Begin commissioning with PASE and failsafe
self.step(1)
Expand All @@ -71,6 +84,18 @@ async def test_TC_CGEN_2_7(self):
self.matter_test_config.tc_user_response_to_simulate = None
await self.commission_devices()

response = await commissioner.SendCommand(
nodeid=self.dut_node_id,
endpoint=ROOT_ENDPOINT_ID,
payload=Clusters.GeneralCommissioning.Commands.ArmFailSafe(
expiryLengthSeconds=failsafe_expiry_length_seconds, breadcrumb=1),
)
asserts.assert_equal(
response.errorCode,
Clusters.GeneralCommissioning.Enums.CommissioningErrorEnum.kOk,
"ArmFailSafeResponse error code is not OK.",
)

# Step 2: Read TCMinRequiredVersion
self.step(2)
response = await commissioner.ReadAttribute(nodeid=self.dut_node_id, attributes=[(ROOT_ENDPOINT_ID, Clusters.GeneralCommissioning.Attributes.TCMinRequiredVersion)])
Expand Down
42 changes: 35 additions & 7 deletions src/python_testing/TC_CGEN_2_8.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,11 @@
# --custom-flow 2
# --capabilities 6
# script-args:
# --PICS src/app/tests/suites/certification/ci-pics-values
# --in-test-commissioning-method on-network
# --tc-version-to-simulate 1
# --tc-user-response-to-simulate 1
# --int-arg PIXIT.CGEN.FailsafeExpiryLengthSeconds:900
# --int-arg PIXIT.CGEN.RequiredTCAcknowledgements:1
# --int-arg PIXIT.CGEN.TCRevision:1
# --qr-code MT:-24J0AFN00KA0648G00
# --trace-to json:log
# factoryreset: True
Expand All @@ -46,8 +48,13 @@ class TC_CGEN_2_8(MatterBaseTest):
def desc_TC_CGEN_2_8(self) -> str:
return "[TC-CGEN-2.8] Verification that TCAcknowledgements is reset after Factory Reset [DUT as Server]"

def pics_TC_CGEN_2_8(self) -> list[str]:
""" This function returns a list of PICS for this test case that must be True for the test to be run"""
return ["CGEN.S", "CGEN.S.F00(TC)"]

def steps_TC_CGEN_2_8(self) -> list[TestStep]:
return [
TestStep(0, description="", expectation="", is_commissioning=False),
TestStep(1, "TH begins commissioning the DUT and performs the following steps in order:\n* Security setup using PASE\n* Setup fail-safe timer, with ExpiryLengthSeconds field set to PIXIT.CGEN.FailsafeExpiryLengthSeconds and the Breadcrumb value as 1\n* Configure information- UTC time, regulatory, etc."),
TestStep(2, "TH sends SetTCAcknowledgements to DUT with the following values:\n* TCVersion: PIXIT.CGEN.TCRevision\n* TCUserResponse: PIXIT.CGEN.RequiredTCAcknowledgements"),
TestStep(3, "TH continues commissioning steps with the DUT and performs steps 'Operation CSR exchange' through 'Security setup using CASE'"),
Expand All @@ -61,17 +68,35 @@ def steps_TC_CGEN_2_8(self) -> list[TestStep]:
@async_test_body
async def test_TC_CGEN_2_8(self):
commissioner: ChipDeviceCtrl.ChipDeviceController = self.default_controller
tc_version_to_simulate: int = self.matter_test_config.tc_version_to_simulate
tc_user_response_to_simulate: int = self.matter_test_config.tc_user_response_to_simulate
failsafe_expiry_length_seconds = self.matter_test_config.global_test_params['PIXIT.CGEN.FailsafeExpiryLengthSeconds']
tc_version_to_simulate = self.matter_test_config.global_test_params['PIXIT.CGEN.TCRevision']
tc_user_response_to_simulate = self.matter_test_config.global_test_params['PIXIT.CGEN.RequiredTCAcknowledgements']

self.step(0)
if not self.pics_guard(self.check_pics("CGEN.S.F00(TC)")):
self.skip_all_remaining_steps(1)
return

# Steps 1-4: Initial commissioning with TC acknowledgements
# 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
self.matter_test_config.tc_version_to_simulate = None
self.matter_test_config.tc_user_response_to_simulate = None
await self.commission_devices()

response = await commissioner.SendCommand(
nodeid=self.dut_node_id,
endpoint=ROOT_ENDPOINT_ID,
payload=Clusters.GeneralCommissioning.Commands.ArmFailSafe(
expiryLengthSeconds=failsafe_expiry_length_seconds, breadcrumb=1),
)
asserts.assert_equal(
response.errorCode,
Clusters.GeneralCommissioning.Enums.CommissioningErrorEnum.kOk,
"ArmFailSafeResponse error code is not OK.",
)

# Step 2: Send SetTCAcknowledgements
self.step(2)
response = await commissioner.SendCommand(
Expand Down Expand Up @@ -107,14 +132,17 @@ async def test_TC_CGEN_2_8(self):
# Step 5: Factory reset is handled by test runner configuration
self.step(5)

# Step 6: Put device in commissioning mode
# Step 6: Put device in commissioning mode (requiring user input, so skip in CI)
self.step(6)
if not self.check_pics('PICS_USER_PROMPT'):
self.skip_all_remaining_steps(7)
return

self.wait_for_user_input(prompt_msg="Set the DUT into commissioning mode")

# Step 7: Commission without TC acknowledgements
self.step(7)
commissioner.SetSkipCommissioningComplete(True)
self.matter_test_config.commissioning_method = self.matter_test_config.in_test_commissioning_method
self.matter_test_config.tc_version_to_simulate = None
self.matter_test_config.tc_user_response_to_simulate = None
await self.commission_devices()
Expand Down
Loading

0 comments on commit 451e82c

Please sign in to comment.