20
20
import math
21
21
import queue
22
22
import random
23
+ import string
23
24
import time
24
25
from typing import Any , Dict , List , Set
25
26
36
37
#
37
38
38
39
40
+ def generate_controller_name (fabric_index : int , controller_index : int ):
41
+ return f"RD{ fabric_index } { string .ascii_uppercase [controller_index ]} "
42
+
43
+
39
44
class TC_RR_1_1 (MatterBaseTest ):
40
45
def setup_class (self ):
41
46
self ._pseudo_random_generator = random .Random (1234 )
@@ -96,11 +101,6 @@ async def test_TC_RR_1_1(self):
96
101
logging .info ("--> User label cluster not present on any endpoitns" )
97
102
98
103
# Generate list of all clients names
99
- all_names = []
100
- for fabric_idx in range (num_fabrics_to_commission ):
101
- for controller_idx in range (num_controllers_per_fabric ):
102
- all_names .append ("RD%d%s" % (fabric_idx , chr (ord ('A' ) + controller_idx )))
103
- logging .info (f"Client names that will be used: { all_names } " )
104
104
client_list = []
105
105
106
106
# TODO: Shall we also verify SupportedFabrics attribute, and the CapabilityMinima attribute?
@@ -119,7 +119,8 @@ async def test_TC_RR_1_1(self):
119
119
node_ids = [200 + (i * 100 ) for i in range (num_controllers_per_fabric - 1 )]
120
120
121
121
# Prepare clients for first fabric, that includes the default controller
122
- dev_ctrl .name = all_names .pop (0 )
122
+ fabric_index = await self .read_single_attribute_check_success (cluster = Clusters .OperationalCredentials , attribute = Clusters .OperationalCredentials .Attributes .CurrentFabricIndex , dev_ctrl = dev_ctrl )
123
+ dev_ctrl .name = generate_controller_name (fabric_index , 0 )
123
124
client_list .append (dev_ctrl )
124
125
125
126
if num_controllers_per_fabric > 1 :
@@ -130,8 +131,8 @@ async def test_TC_RR_1_1(self):
130
131
privilege = Clusters .AccessControl .Enums .AccessControlEntryPrivilegeEnum .kAdminister ,
131
132
targetNodeId = self .dut_node_id , catTags = [0x0001_0001 ]
132
133
)
133
- for controller in new_controllers :
134
- controller .name = all_names . pop ( 0 )
134
+ for idx , controller in enumerate ( new_controllers ) :
135
+ controller .name = generate_controller_name ( fabric_index , idx + 1 )
135
136
client_list .extend (new_controllers )
136
137
137
138
# Step 1c - Ensure there are no leftover fabrics from another process.
@@ -163,11 +164,11 @@ async def test_TC_RR_1_1(self):
163
164
fabrics : List [Clusters .OperationalCredentials .Structs .FabricDescriptorStruct ] = await self .read_single_attribute (
164
165
dev_ctrl , node_id = self .dut_node_id , endpoint = 0 ,
165
166
attribute = Clusters .OperationalCredentials .Attributes .Fabrics , fabricFiltered = False )
167
+ current_fabric_index = await self .read_single_attribute_check_success (cluster = Clusters .OperationalCredentials , attribute = Clusters .OperationalCredentials .Attributes .CurrentFabricIndex )
166
168
for fabric in fabrics :
167
- if fabric .fabricID == dev_ctrl . fabricId :
169
+ if fabric .fabricIndex == current_fabric_index :
168
170
continue
169
-
170
- # This is not the initial client's fabric, so remove it.
171
+ # This is not the test client's fabric, so remove it.
171
172
await dev_ctrl .SendCommand (
172
173
self .dut_node_id , 0 , Clusters .OperationalCredentials .Commands .RemoveFabric (fabricIndex = fabric .fabricIndex ))
173
174
@@ -184,13 +185,13 @@ async def test_TC_RR_1_1(self):
184
185
new_fabric_admin = new_certificate_authority .NewFabricAdmin (vendorId = 0xFFF1 , fabricId = admin_index )
185
186
186
187
new_admin_ctrl = new_fabric_admin .NewController (nodeId = dev_ctrl .nodeId , catTags = [0x0001_0001 ])
187
- new_admin_ctrl .name = all_names .pop (0 )
188
- client_list .append (new_admin_ctrl )
189
188
await CommissioningBuildingBlocks .AddNOCForNewFabricFromExisting (commissionerDevCtrl = dev_ctrl ,
190
189
newFabricDevCtrl = new_admin_ctrl ,
191
190
existingNodeId = self .dut_node_id ,
192
191
newNodeId = self .dut_node_id )
193
-
192
+ fabric_index = await self .read_single_attribute_check_success (cluster = Clusters .OperationalCredentials , attribute = Clusters .OperationalCredentials .Attributes .CurrentFabricIndex , dev_ctrl = new_admin_ctrl )
193
+ new_admin_ctrl .name = generate_controller_name (fabric_index , 0 )
194
+ client_list .append (new_admin_ctrl )
194
195
if num_controllers_per_fabric > 1 :
195
196
new_controllers = await CommissioningBuildingBlocks .CreateControllersOnFabric (
196
197
fabricAdmin = new_fabric_admin ,
@@ -200,8 +201,8 @@ async def test_TC_RR_1_1(self):
200
201
targetNodeId = self .dut_node_id ,
201
202
catTags = [0x0001_0001 ]
202
203
)
203
- for controller in new_controllers :
204
- controller .name = all_names . pop ( 0 )
204
+ for idx , controller in enumerate ( new_controllers ) :
205
+ controller .name = generate_controller_name ( fabric_index , idx + 1 )
205
206
206
207
client_list .extend (new_controllers )
207
208
@@ -224,10 +225,8 @@ async def test_TC_RR_1_1(self):
224
225
# Step 2: Set the Label field for each fabric and BasicInformation.NodeLabel to 32 characters
225
226
logging .info ("Step 2: Setting the Label field for each fabric and BasicInformation.NodeLabel to 32 characters" )
226
227
227
- for table_idx in range (len (fabric_table )):
228
- # Client is client A for each fabric to set the Label field
229
- fabric = fabric_table [table_idx ]
230
- client_name = "RD%dA" % table_idx
228
+ for fabric in fabric_table :
229
+ client_name = generate_controller_name (fabric .fabricIndex , 0 )
231
230
client = client_by_name [client_name ]
232
231
233
232
# Send the UpdateLabel command
@@ -451,10 +450,8 @@ async def test_TC_RR_1_1(self):
451
450
# Create a list of per-fabric clients to use for filling group resources accross all fabrics.
452
451
fabric_unique_clients : List [Any ] = []
453
452
454
- for table_idx in range (len (fabric_table )):
455
- # Client is client A for each fabric
456
- fabric = fabric_table [table_idx ]
457
- client_name = "RD%dA" % table_idx
453
+ for fabric in fabric_table :
454
+ client_name = generate_controller_name (fabric .fabricIndex , 0 )
458
455
fabric_unique_clients .append (client_by_name [client_name ])
459
456
460
457
# Step 13: Write and verify indicated_max_group_keys_per_fabric group keys to all fabrics.
@@ -696,9 +693,8 @@ async def send_acl(self,
696
693
enable_access_to_group_cluster : bool ,
697
694
fabric_table : List [
698
695
Clusters .OperationalCredentials .Structs .FabricDescriptorStruct ]):
699
- for table_idx , fabric in enumerate (fabric_table ):
700
- # Client is client A for each fabric
701
- client_name = "RD%dA" % table_idx
696
+ for fabric in fabric_table :
697
+ client_name = generate_controller_name (fabric .fabricIndex , 0 )
702
698
client = client_by_name [client_name ]
703
699
704
700
acl = self .build_acl (enable_access_to_group_cluster )
0 commit comments