From 1402550cc7c12419d571eec67e04f482d5c36594 Mon Sep 17 00:00:00 2001 From: C Freeman Date: Wed, 22 May 2024 12:35:56 -0400 Subject: [PATCH] TC-SC-3.6: Add precondition to remove extra fabrics (#33503) * TC-SC-3.6: Add precondition to remove extra fabrics Before commissioning the other fabrics, remove pre-existing fabrics from the device because the TH does not have the ability to check for subscriptions from them. Note that this change means that any pre-exisiting fabrics on the device WILL NOT BE THERE after this test. This is the same behaviour as in RR-1.1. Test: Tested against all-clusters app. chip-tool pairing onnetwork-long 0x12344321 20202021 3840 chip-tool pairing open-commissioning-window 0x12344321 0 900 10000 3840 python src/python_testing/TC_SC_3_6.py --commissioning-method on-network \ --discriminator 3840 --passcode 20202021 Results (only relevant logs): [MatterTest] 05-17 07:54:32.981 INFO Pre-condition: Remove all pre-existing fabrics on the device that do not belong to the TH ... [MatterTest] 05-17 07:54:32.994 INFO Removing extra fabric at 1 from device. ... INFO:root:Final result: PASS ! * add missing import --- src/python_testing/TC_SC_3_6.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/python_testing/TC_SC_3_6.py b/src/python_testing/TC_SC_3_6.py index a6994cbf288539..ec09d4bb8e815e 100644 --- a/src/python_testing/TC_SC_3_6.py +++ b/src/python_testing/TC_SC_3_6.py @@ -20,6 +20,7 @@ import queue import time from threading import Event +from typing import List import chip.clusters as Clusters from chip.clusters import ClusterObjects as ClustersObjects @@ -123,6 +124,24 @@ async def test_TC_SC_3_6(self): ) asserts.assert_greater_equal(capability_minima.caseSessionsPerFabric, 3) + logging.info("Pre-condition: Remove all pre-existing fabrics on the device that do not belong to the TH") + commissioned_fabric_count: int = await self.read_single_attribute( + dev_ctrl, node_id=self.dut_node_id, + endpoint=0, attribute=Clusters.OperationalCredentials.Attributes.CommissionedFabrics) + + if commissioned_fabric_count > 1: + fabrics: List[Clusters.OperationalCredentials.Structs.FabricDescriptorStruct] = await self.read_single_attribute( + dev_ctrl, node_id=self.dut_node_id, endpoint=0, + attribute=Clusters.OperationalCredentials.Attributes.Fabrics, fabricFiltered=False) + current_fabric_index = await self.read_single_attribute_check_success(cluster=Clusters.OperationalCredentials, attribute=Clusters.OperationalCredentials.Attributes.CurrentFabricIndex) + for fabric in fabrics: + if fabric.fabricIndex == current_fabric_index: + continue + # This is not the test client's fabric, so remove it. + logging.info(f"Removing extra fabric at {fabric.fabricIndex} from device.") + await dev_ctrl.SendCommand( + self.dut_node_id, 0, Clusters.OperationalCredentials.Commands.RemoveFabric(fabricIndex=fabric.fabricIndex)) + logging.info("Pre-conditions: use existing fabric to configure new fabrics so that total is %d fabrics" % num_fabrics_to_commission)