Skip to content

Commit 032502e

Browse files
committed
minor updates to latest testplan spec
1 parent 168c69c commit 032502e

File tree

2 files changed

+85
-42
lines changed

2 files changed

+85
-42
lines changed

src/python_testing/TC_CCTRL.py

+72-31
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232

3333
import chip.clusters as Clusters
3434
import chip.exceptions
35-
from matter_testing_support import MatterBaseTest, default_matter_test_main, per_endpoint_test, has_cluster, async_test_body
35+
from matter_testing_support import MatterBaseTest, TestStep, default_matter_test_main, per_endpoint_test, has_cluster, async_test_body
3636
from mobly import asserts
3737
from chip.interaction_model import InteractionModelError, Status
3838

@@ -88,22 +88,55 @@ def teardown_class(self):
8888
os.remove(self.kvs)
8989
super().teardown_class()
9090

91+
92+
def steps_TC_CCTRL_2_2(self) -> list[TestStep]:
93+
steps = [TestStep(1, "Get number of fabrics from TH_SERVER", is_commissioning=True),
94+
TestStep(2, "Reading Attribute VendorId from TH_SERVER"),
95+
TestStep(3, "Reading Attribute ProductId from TH_SERVER"),
96+
TestStep(4, "Reading Event CommissioningRequestResult from DUT"),
97+
TestStep(5, "Send CommissionNode command to DUT with CASE session"),
98+
TestStep(6, "Send OpenCommissioningWindow command on Administrator Commissioning Cluster to DUT with CASE session"),
99+
TestStep(7, "Send CommissionNode command to DUT with PASE session"),
100+
TestStep(8, "Send RequestCommissioningApproval command to DUT with PASE session"),
101+
TestStep(9, "Send RevokeCommissioning command on Administrator Commissioning Cluster to DUT with CASE session"),
102+
TestStep(10, "Reading Event CommissioningRequestResult from DUT, confirm no new events"),
103+
TestStep(11, "Send RequestCommissioningApproval command to DUT with CASE session with incorrect vendorID"),
104+
TestStep(12, "(Manual Step) Approve Commissioning Approval Request on DUT using method indicated by the manufacturer"),
105+
TestStep(13, "Reading Event CommissioningRequestResult from DUT, confirm one new event"),
106+
TestStep(14, "Send CommissionNode command to DUT with CASE session, with invalid RequestId"),
107+
TestStep(15, "Send CommissionNode command to DUT with CASE session, with invalid ResponseTimeoutSeconds too low"),
108+
TestStep(16, "Send CommissionNode command to DUT with CASE session, with invalid ResponseTimeoutSeconds too high"),
109+
TestStep(17, "Send CommissionNode command to DUT with CASE session, with valid parameters"),
110+
TestStep(18, "Send OpenCommissioningWindow command on Administrator Commissioning Cluster sent to TH_SERVER"),
111+
TestStep(19, "Wait for DUT to fail commissioning TH_SERVER, 30 seconds"),
112+
TestStep(20, "Get number of fabrics from TH_SERVER"),
113+
TestStep(21, "Send RevokeCommissioning command on Administrator Commissioning Cluster sent to TH_SERVER"),
114+
TestStep(22, "Send RequestCommissioningApproval command to DUT with CASE session with correct vendorID"),
115+
TestStep(23, "(Manual Step) Approve Commissioning Approval Request on DUT using method indicated by the manufacturer"),
116+
TestStep(24, "Reading Event CommissioningRequestResult from DUT, confirm one new event"),
117+
TestStep(25, "Send CommissionNode command to DUT with CASE session, with valid parameters"),
118+
TestStep(26, "Send OpenCommissioningWindow command on Administrator Commissioning Cluster sent to TH_SERVER"),
119+
TestStep(27, "Wait for DUT to successfully commission TH_SERVER, 30 seconds"),
120+
TestStep(28, "Get number of fabrics from TH_SERVER, verify DUT successfully commissioned TH_SERVER")]
121+
122+
return steps
123+
91124
@per_endpoint_test(has_cluster(Clusters.CommissionerControl))
92125
async def test_TC_CCTRL_2_2(self):
93126
self.is_ci = self.check_pics('PICS_SDK_CI_ONLY')
94127

95-
#self.step(1)
128+
self.step(1)
96129
th_server_fabrics = await self.read_single_attribute_check_success(cluster=Clusters.OperationalCredentials, attribute=Clusters.OperationalCredentials.Attributes.Fabrics, dev_ctrl=self.TH_server_controller, node_id=self.server_nodeid, endpoint=0)
97-
#self.step(2)
130+
self.step(2)
98131
th_server_vid = await self.read_single_attribute_check_success(cluster=Clusters.BasicInformation, attribute=Clusters.BasicInformation.Attributes.VendorID, dev_ctrl=self.TH_server_controller, node_id=self.server_nodeid, endpoint=0)
99-
#self.step(3)
132+
self.step(3)
100133
th_server_pid = await self.read_single_attribute_check_success(cluster=Clusters.BasicInformation, attribute=Clusters.BasicInformation.Attributes.ProductID, dev_ctrl=self.TH_server_controller, node_id=self.server_nodeid, endpoint=0)
101134

102-
#self.step(4)
135+
self.step(4)
103136
event_path = [(self.matter_test_config.endpoint, Clusters.CommissionerControl.Events.CommissioningRequestResult, 1)]
104137
events = await self.default_controller.ReadEvent(nodeid=self.dut_node_id, events=event_path)
105138

106-
#self.step(5)
139+
self.step(5)
107140
ipaddr = ipaddress.IPv6Address('::1')
108141
cmd = Clusters.CommissionerControl.Commands.CommissionNode(requestId=1, responseTimeoutSeconds=30, ipAddress=ipaddr.packed, port=self.port)
109142
try:
@@ -112,8 +145,9 @@ async def test_TC_CCTRL_2_2(self):
112145
except InteractionModelError as e:
113146
asserts.assert_equal(e.status, Status.Failure, "Incorrect error returned")
114147

115-
#self.step(6)
148+
self.step(6)
116149
params = await self.openCommissioningWindow(dev_ctrl=self.default_controller, node_id=self.dut_node_id)
150+
self.step(7)
117151
pase_nodeid = self.dut_node_id + 1
118152
await self.default_controller.FindOrEstablishPASESession(setupCode=params.commissioningParameters.setupQRCode, nodeid=pase_nodeid)
119153
try:
@@ -122,7 +156,7 @@ async def test_TC_CCTRL_2_2(self):
122156
except InteractionModelError as e:
123157
asserts.assert_equal(e.status, Status.UnsupportedAccess, "Incorrect error returned")
124158

125-
# self.step(7)
159+
self.step(8)
126160
good_request_id = 0x1234567887654321
127161
cmd = Clusters.CommissionerControl.Commands.RequestCommissioningApproval(requestId=good_request_id, vendorId=th_server_vid, productId=th_server_pid)
128162
try:
@@ -131,26 +165,32 @@ async def test_TC_CCTRL_2_2(self):
131165
except InteractionModelError as e:
132166
asserts.assert_equal(e.status, Status.UnsupportedAccess, "Incorrect error returned")
133167

134-
#self.step(8)
168+
self.step(9)
169+
cmd = Clusters.AdministratorCommissioning.Commands.RevokeCommissioning()
170+
# If no exception is raised, this is success
171+
await self.send_single_cmd(cmd)
172+
173+
self.step(10)
135174
if not events:
136175
new_event = await self.default_controller.ReadEvent(nodeid=self.dut_node_id, events=event_path)
137176
else:
138177
event_nums = [e.Header.EventNumber for e in events]
139178
new_event = await self.default_controller.ReadEvent(nodeid=self.dut_node_id, events=event_path, eventNumberFilter=max(event_nums)+1)
140179
asserts.assert_equal(new_event, [], "Unexpected event")
141180

142-
143-
#self.step(9)
144-
bad_vid = 0x6006
145-
cmd = Clusters.CommissionerControl.Commands.RequestCommissioningApproval(requestId=good_request_id, vendorId=bad_vid, productId=th_server_pid)
181+
self.step(11)
182+
# There should be nothing on the TH that uses VID 0x6006 as this is a real vendor ID.
183+
not_th_server_vid = 0x6006
184+
asserts.assert_not_equal(not_th_server_vid, th_server_vid, "Test implementation assumption incorrect")
185+
cmd = Clusters.CommissionerControl.Commands.RequestCommissioningApproval(requestId=good_request_id, vendorId=not_th_server_vid, productId=th_server_pid)
146186
# If no exception is raised, this is success
147187
await self.send_single_cmd(cmd)
148188

149-
#self.step(10)
189+
self.step(12)
150190
if not self.is_ci:
151191
self.wait_for_use_input("Approve Commissioning approval request using manufacturer specified mechanism")
152192

153-
#self.step(11)
193+
self.step(13)
154194
if not events:
155195
new_event = await self.default_controller.ReadEvent(nodeid=self.dut_node_id, events=event_path)
156196
else:
@@ -161,7 +201,7 @@ async def test_TC_CCTRL_2_2(self):
161201
asserts.assert_equal(new_event[0].Data.clientNodeId, self.matter_test_config.controller_node_id, "Unexpected client node id")
162202
asserts.assert_equal(new_event[0].Data.requestId, good_request_id, "Unexpected request ID")
163203

164-
#self.step(12)
204+
self.step(14)
165205
bad_request_id = 0x1234567887654322
166206
cmd = Clusters.CommissionerControl.Commands.CommissionNode(requestId=bad_request_id, responseTimeoutSeconds=30)
167207
try:
@@ -170,59 +210,59 @@ async def test_TC_CCTRL_2_2(self):
170210
except InteractionModelError as e:
171211
asserts.assert_equal(e.status, Status.Failure, "Incorrect error returned")
172212

173-
#self.step(13)
213+
self.step(15)
174214
cmd = Clusters.CommissionerControl.Commands.CommissionNode(requestId=good_request_id, responseTimeoutSeconds=29)
175215
try:
176216
await self.send_single_cmd(cmd=cmd)
177217
asserts.fail("Unexpected success on CommissionNode")
178218
except InteractionModelError as e:
179219
asserts.assert_equal(e.status, Status.Failure, "Incorrect error returned")
180220

181-
#self.step(14)
221+
self.step(16)
182222
cmd = Clusters.CommissionerControl.Commands.CommissionNode(requestId=good_request_id, responseTimeoutSeconds=121)
183223
try:
184224
await self.send_single_cmd(cmd=cmd)
185225
asserts.fail("Unexpected success on CommissionNode")
186226
except InteractionModelError as e:
187227
asserts.assert_equal(e.status, Status.Failure, "Incorrect error returned")
188228

189-
#self.step(15)
229+
self.step(17)
190230
cmd = Clusters.CommissionerControl.Commands.CommissionNode(requestId=good_request_id, responseTimeoutSeconds=30)
191231
resp: Clusters.CommissionerControl.Commands.ReverseOpenCommissioningWindow = await self.send_single_cmd(cmd)
192232
asserts.assert_equal(type(resp), Clusters.CommissionerControl.Commands.ReverseOpenCommissioningWindow, "Incorrect response type")
193233

194-
#self.step(16)
234+
self.step(18)
195235
# min commissioning timeout is 3*60 seconds, so use that even though the command said 30.
196236
cmd = Clusters.AdministratorCommissioning.Commands.OpenCommissioningWindow(commissioningTimeout=3*60,
197237
PAKEPasscodeVerifier=resp.PAKEPasscodeVerifier,
198238
discriminator=resp.discriminator,
199239
iterations=resp.iterations, salt=resp.salt)
200240
await self.send_single_cmd(cmd, dev_ctrl=self.TH_server_controller, node_id=self.server_nodeid, endpoint=0, timedRequestTimeoutMs=5000)
201241

202-
#self.step(17)
242+
self.step(19)
203243
logging.info("Test now waits for 30 seconds")
204-
#time.sleep(30)
244+
if not self.is_ci:
245+
time.sleep(30)
205246

206-
#self.step(18)
247+
self.step(20)
207248
print(f'server node id {self.server_nodeid}')
208249
th_server_fabrics_new = await self.read_single_attribute_check_success(cluster=Clusters.OperationalCredentials, attribute=Clusters.OperationalCredentials.Attributes.Fabrics, dev_ctrl=self.TH_server_controller, node_id=self.server_nodeid, endpoint=0)
209250
asserts.assert_equal(len(th_server_fabrics), len(th_server_fabrics_new), "Unexpected number of fabrics on TH_SERVER")
210251

211-
#self.step(19)
252+
self.step(21)
212253
cmd = Clusters.AdministratorCommissioning.Commands.RevokeCommissioning()
213254
await self.send_single_cmd(cmd, dev_ctrl=self.TH_server_controller, node_id=self.server_nodeid, timedRequestTimeoutMs=5000, endpoint=0)
214255

215-
#self.step(20)
216-
print('step 20')
256+
self.step(22)
217257
good_request_id = 0x1234567812345678
218258
cmd = Clusters.CommissionerControl.Commands.RequestCommissioningApproval(requestId=good_request_id, vendorId=th_server_vid, productId=th_server_pid, label="Test Ecosystem")
219259
await self.send_single_cmd(cmd)
220260

221-
#self.step(21)
261+
self.step(23)
222262
if not self.is_ci:
223263
self.wait_for_use_input("Approve Commissioning approval request using manufacturer specified mechanism")
224264

225-
#self.step(22)
265+
self.step(24)
226266
events = new_event
227267
event_nums = [e.Header.EventNumber for e in events]
228268
new_event = await self.default_controller.ReadEvent(nodeid=self.dut_node_id, events=event_path, eventNumberFilter=max(event_nums)+1)
@@ -231,23 +271,24 @@ async def test_TC_CCTRL_2_2(self):
231271
asserts.assert_equal(new_event[0].Data.clientNodeId, self.matter_test_config.controller_node_id, "Unexpected client node id")
232272
asserts.assert_equal(new_event[0].Data.requestId, good_request_id, "Unexpected request ID")
233273

234-
#self.step(23)
274+
self.step(25)
235275
cmd = Clusters.CommissionerControl.Commands.CommissionNode(requestId=good_request_id, responseTimeoutSeconds=30)
236276
resp = await self.send_single_cmd(cmd)
237277
asserts.assert_equal(type(resp), Clusters.CommissionerControl.Commands.ReverseOpenCommissioningWindow, "Incorrect response type")
238278

239-
#self.step(24)
279+
self.step(26)
240280
# min commissioning timeout is 3*60 seconds, so use that even though the command said 30.
241281
cmd = Clusters.AdministratorCommissioning.Commands.OpenCommissioningWindow(commissioningTimeout=3*60,
242282
PAKEPasscodeVerifier=resp.PAKEPasscodeVerifier,
243283
discriminator=resp.discriminator,
244284
iterations=resp.iterations, salt=resp.salt)
245285
await self.send_single_cmd(cmd, dev_ctrl=self.TH_server_controller, node_id=self.server_nodeid, endpoint=0, timedRequestTimeoutMs=5000)
246286

247-
#self.step(25)
287+
self.step(27)
248288
if not self.is_ci:
249289
time.sleep(30)
250290

291+
self.step(28)
251292
th_server_fabrics_new = await self.read_single_attribute_check_success(cluster=Clusters.OperationalCredentials, attribute=Clusters.OperationalCredentials.Attributes.Fabrics, dev_ctrl=self.TH_server_controller, node_id=self.server_nodeid, endpoint=0)
252293
#TODO: this should be mocked too.
253294
if not self.is_ci:

src/python_testing/test_testing/test_TC_CCNTL.py

+13-11
Original file line numberDiff line numberDiff line change
@@ -51,24 +51,26 @@ def dynamic_invoke_return(*args, **argv):
5151
print(f'invoke call {invoke_call_count}')
5252
if invoke_call_count == 1: # Commission node with no prior request, return failure - step 5
5353
raise InteractionModelError(status=Status.Failure)
54-
elif invoke_call_count == 2: # Commission node over pase - return unsupported access - step 6
54+
elif invoke_call_count == 2: # Commission node over pase - return unsupported access - step 7
5555
raise InteractionModelError(status=Status.UnsupportedAccess)
56-
elif invoke_call_count == 3: # request commissioning approval over pase - return unsupported access - step 7
56+
elif invoke_call_count == 3: # request commissioning approval over pase - return unsupported access - step 8
5757
raise InteractionModelError(status=Status.UnsupportedAccess)
58-
elif invoke_call_count == 4: # good RequestCommissioningApproval over CASE with bad vid - step 9
58+
elif invoke_call_count == 4: # good RevokeCommissioning over CASE with bad vid - step 9
5959
return None
60-
elif invoke_call_count == 5: # CommissionNode with bad request id - step 12
60+
elif invoke_call_count == 5: # good RequestCommissioningApproval over CASE with bad vid - step 10
61+
return None
62+
elif invoke_call_count == 6: # CommissionNode with bad request id - step 14
6163
raise InteractionModelError(status=Status.Failure)
62-
elif invoke_call_count == 6: # CommissionNode with bad timeout (low) - step 13
64+
elif invoke_call_count == 7: # CommissionNode with bad timeout (low) - step 15
6365
raise InteractionModelError(status=Status.Failure)
64-
elif invoke_call_count == 7: # CommissionNode with bad timeout (high) - step 14
66+
elif invoke_call_count == 8: # CommissionNode with bad timeout (high) - step 16
6567
raise InteractionModelError(status=Status.Failure)
66-
elif invoke_call_count == 8: # CommissionNode - step 15
68+
elif invoke_call_count == 9: # CommissionNode - step 17
6769
# passcode 20202024
6870
return reverse_open
69-
elif invoke_call_count == 9: # RequestCommissioningApproval with good vid - step 20
71+
elif invoke_call_count == 10: # RequestCommissioningApproval with good vid - step 22
7072
return None
71-
elif invoke_call_count == 10: # CommissionNode - step 23
73+
elif invoke_call_count == 11: # CommissionNode - step 25
7274
# passcode 20202024
7375
return reverse_open
7476
else:
@@ -87,7 +89,7 @@ def dynamic_event_return(*args, **argv):
8789
data = Clusters.CommissionerControl.Events.CommissioningRequestResult(requestId=0x1234567887654321, clientNodeId=112233, statusCode=0)
8890
result = Attribute.EventReadResult(Header=header, Status=Status.Success, Data=data)
8991
return [result]
90-
elif event_call_count == 4: # returmed event with new request
92+
elif event_call_count == 4: # returned event with new request
9193
header = Attribute.EventHeader(EndpointId=0, ClusterId=Clusters.CommissionerControl.id, EventId=Clusters.CommissionerControl.Events.CommissioningRequestResult.event_id, EventNumber=1)
9294
data = Clusters.CommissionerControl.Events.CommissioningRequestResult(requestId=0x1234567812345678, clientNodeId=112233, statusCode=0)
9395
result = Attribute.EventReadResult(Header=header, Status=Status.Success, Data=data)
@@ -140,7 +142,7 @@ def main():
140142
print(f'paa = {paa_path}')
141143

142144
pics = {"PICS_SDK_CI_ONLY": True }
143-
test_runner = MyMock('TC_CCTRL', 'TC_CCTRL', 'test_TC_CCTRL_3_1', 1, paa_trust_store_path=paa_path, pics=pics)
145+
test_runner = MyMock('TC_CCTRL', 'TC_CCTRL', 'test_TC_CCTRL_2_2', 1, paa_trust_store_path=paa_path, pics=pics)
144146

145147
test_runner.run_test_with_mock(dynamic_invoke_return, dynamic_event_return, wildcard())
146148
test_runner.Shutdown()

0 commit comments

Comments
 (0)