Skip to content

Commit 3e63e9a

Browse files
committed
the rest, I think.
1 parent 1b546b7 commit 3e63e9a

File tree

2 files changed

+54
-15
lines changed

2 files changed

+54
-15
lines changed

src/python_testing/TC_CCTRL.py

+31-5
Original file line numberDiff line numberDiff line change
@@ -188,13 +188,16 @@ async def test_TC_CCTRL_3_1(self):
188188

189189
#self.step(15)
190190
cmd = Clusters.CommissionerControl.Commands.CommissionNode(requestId=good_request_id, responseTimeoutSeconds=30)
191-
resp = await self.send_single_cmd(cmd)
191+
resp: Clusters.CommissionerControl.Commands.ReverseOpenCommissioningWindow = await self.send_single_cmd(cmd)
192192
asserts.assert_equal(type(resp), Clusters.CommissionerControl.Commands.ReverseOpenCommissioningWindow, "Incorrect response type")
193193

194194
#self.step(16)
195-
#TODO: we do not have a direct line to OpenEnhancedCommissioningWindow. Need to add plumbing
196-
# For now, open with anything so the below command is ok
197-
await self.openCommissioningWindow(dev_ctrl=self.TH_server_controller, node_id=self.server_nodeid)
195+
# min commissioning timeout is 3*60 seconds, so use that even though the command said 30.
196+
cmd = Clusters.AdministratorCommissioning.Commands.OpenCommissioningWindow(commissioningTimeout=3*60,
197+
PAKEPasscodeVerifier=resp.PAKEPasscodeVerifier,
198+
discriminator=resp.discriminator,
199+
iterations=resp.iterations, salt=resp.salt)
200+
await self.send_single_cmd(cmd, dev_ctrl=self.TH_server_controller, node_id=self.server_nodeid, endpoint=0, timedRequestTimeoutMs=5000)
198201

199202
#self.step(17)
200203
logging.info("Test now waits for 30 seconds")
@@ -210,9 +213,10 @@ async def test_TC_CCTRL_3_1(self):
210213
await self.send_single_cmd(cmd, dev_ctrl=self.TH_server_controller, node_id=self.server_nodeid, timedRequestTimeoutMs=5000, endpoint=0)
211214

212215
#self.step(20)
216+
print('step 20')
213217
good_request_id = 0x1234567812345678
214218
cmd = Clusters.CommissionerControl.Commands.RequestCommissioningApproval(requestId=good_request_id, vendorId=th_server_vid, productId=th_server_pid, label="Test Ecosystem")
215-
self.send_single_cmd(cmd)
219+
await self.send_single_cmd(cmd)
216220

217221
#self.step(21)
218222
if not self.is_ci:
@@ -227,6 +231,28 @@ async def test_TC_CCTRL_3_1(self):
227231
asserts.assert_equal(new_event[0].Data.clientNodeId, self.matter_test_config.controller_node_id, "Unexpected client node id")
228232
asserts.assert_equal(new_event[0].Data.requestId, good_request_id, "Unexpected request ID")
229233

234+
#self.step(23)
235+
cmd = Clusters.CommissionerControl.Commands.CommissionNode(requestId=good_request_id, responseTimeoutSeconds=30)
236+
resp = await self.send_single_cmd(cmd)
237+
asserts.assert_equal(type(resp), Clusters.CommissionerControl.Commands.ReverseOpenCommissioningWindow, "Incorrect response type")
238+
239+
#self.step(24)
240+
# min commissioning timeout is 3*60 seconds, so use that even though the command said 30.
241+
cmd = Clusters.AdministratorCommissioning.Commands.OpenCommissioningWindow(commissioningTimeout=3*60,
242+
PAKEPasscodeVerifier=resp.PAKEPasscodeVerifier,
243+
discriminator=resp.discriminator,
244+
iterations=resp.iterations, salt=resp.salt)
245+
await self.send_single_cmd(cmd, dev_ctrl=self.TH_server_controller, node_id=self.server_nodeid, endpoint=0, timedRequestTimeoutMs=5000)
246+
247+
#self.step(25)
248+
if not self.is_ci:
249+
time.sleep(30)
250+
251+
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)
252+
#TODO: this should be mocked too.
253+
if not self.is_ci:
254+
asserts.assert_equal(len(th_server_fabrics) + 1, len(th_server_fabrics_new), "Unexpected number of fabrics on TH_SERVER")
255+
230256

231257

232258
if __name__ == "__main__":

src/python_testing/test_testing/test_TC_CCNTL.py

+23-10
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
import os
2020
import sys
21+
import base64
2122
import pathlib
2223
import typing
2324

@@ -42,22 +43,34 @@ def dynamic_invoke_return(*args, **argv):
4243
global invoke_call_count
4344
invoke_call_count += 1
4445

45-
if invoke_call_count == 1: # Commission node with no prior request, return failure
46+
# passcode 20202024
47+
reverse_open = Clusters.CommissionerControl.Commands.ReverseOpenCommissioningWindow(commissioningTimeout=30,
48+
PAKEPasscodeVerifier=b"+w1qZQR05Zn0bc2LDyNaDAhsrhDS5iRHPTN10+EmNx8E2OpIPC4SjWRDQVOgqcbnXdYMlpiZ168xLBqn1fx9659gGK/7f9Yc6GxpoJH8kwAUYAYyLGsYeEBt1kL6kpXjgA==",
49+
discriminator=2222, iterations=10000, salt=base64.b64encode(bytes('SaltyMcSalterson', 'utf-8')))
50+
51+
print(f'invoke call {invoke_call_count}')
52+
if invoke_call_count == 1: # Commission node with no prior request, return failure - step 5
4653
raise InteractionModelError(status=Status.Failure)
47-
elif invoke_call_count == 2: # Commission node over pase - return unsupported access
54+
elif invoke_call_count == 2: # Commission node over pase - return unsupported access - step 6
4855
raise InteractionModelError(status=Status.UnsupportedAccess)
49-
elif invoke_call_count == 3: # request commissioning approval over pase - return unsupported access
56+
elif invoke_call_count == 3: # request commissioning approval over pase - return unsupported access - step 7
5057
raise InteractionModelError(status=Status.UnsupportedAccess)
51-
elif invoke_call_count == 4: # good RequestCommissioningApproval over CASE with bad vid
58+
elif invoke_call_count == 4: # good RequestCommissioningApproval over CASE with bad vid - step 9
5259
return None
53-
elif invoke_call_count == 5: # CommissionNode with bad request id
60+
elif invoke_call_count == 5: # CommissionNode with bad request id - step 12
5461
raise InteractionModelError(status=Status.Failure)
55-
elif invoke_call_count == 6: # CommissionNode with bad timeout (low)
62+
elif invoke_call_count == 6: # CommissionNode with bad timeout (low) - step 13
5663
raise InteractionModelError(status=Status.Failure)
57-
elif invoke_call_count == 7: # CommissionNode with bad timeout (high)
64+
elif invoke_call_count == 7: # CommissionNode with bad timeout (high) - step 14
5865
raise InteractionModelError(status=Status.Failure)
59-
elif invoke_call_count == 8: #CommissionNode
60-
return Clusters.CommissionerControl.Commands.ReverseOpenCommissioningWindow(commissioningTimeout=30, PAKEPasscodeVerifier=b'', discriminator=2222, iterations=10000, salt=bytes('SaltyMcSaltersons', 'utf-8'))
66+
elif invoke_call_count == 8: # CommissionNode - step 15
67+
# passcode 20202024
68+
return reverse_open
69+
elif invoke_call_count == 9: # RequestCommissioningApproval with good vid - step 20
70+
return None
71+
elif invoke_call_count == 10: # CommissionNode - step 23
72+
# passcode 20202024
73+
return reverse_open
6174
else:
6275
raise InteractionModelError(Status.Failure)
6376

@@ -74,7 +87,7 @@ def dynamic_event_return(*args, **argv):
7487
data = Clusters.CommissionerControl.Events.CommissioningRequestResult(requestId=0x1234567887654321, clientNodeId=112233, statusCode=0)
7588
result = Attribute.EventReadResult(Header=header, Status=Status.Success, Data=data)
7689
return [result]
77-
elif event_call_count == 4: # returmed event with new request id
90+
elif event_call_count == 4: # returmed event with new request
7891
header = Attribute.EventHeader(EndpointId=0, ClusterId=Clusters.CommissionerControl.id, EventId=Clusters.CommissionerControl.Events.CommissioningRequestResult.event_id, EventNumber=1)
7992
data = Clusters.CommissionerControl.Events.CommissioningRequestResult(requestId=0x1234567812345678, clientNodeId=112233, statusCode=0)
8093
result = Attribute.EventReadResult(Header=header, Status=Status.Success, Data=data)

0 commit comments

Comments
 (0)