4646
4747class TC_CADMIN_1_5 (CADMINBaseTest ):
4848
49- async def commission_on_network (self , setup_code : int , discriminator : int , expected_error : int = 0 ):
49+ async def commission_on_network_expect_error (self , setup_code : int , discriminator : int ):
5050 # This is expected to error as steps 4 and 7 expects timeout issue or pase connection error to occur due to commissioning window being closed already
51- if expected_error == 50 :
52- with asserts .assert_raises (ChipStackError ) as cm :
53- await self .th2 .CommissionOnNetwork (
54- nodeId = self .dut_node_id , setupPinCode = setup_code ,
55- filterType = ChipDeviceCtrl .DiscoveryFilterType .LONG_DISCRIMINATOR , filter = discriminator )
56- asserts .assert_true (int (cm .exception .code ) == expected_error ,
57- 'Unexpected error code returned from Commissioning Attempt' )
58-
59- else :
60- try :
61- await self .th2 .CommissionOnNetwork (
62- nodeId = self .dut_node_id , setupPinCode = setup_code ,
63- filterType = ChipDeviceCtrl .DiscoveryFilterType .LONG_DISCRIMINATOR , filter = discriminator )
64-
65- except asyncio .CancelledError :
66- # This is expected to fail due to timeout, however there is no code to validate here, so just passing since the correct exception was raised to get to this point
67- pass
51+ # The two errors here correspond to either a failure to find the device on dns-sd because it's no longer advertising or a failure to connect
52+ # over PASE (in the case where we have a cached address and attempt a connection). Both of these are indications that the commissioning window
53+ # is properly closed, which is what this function is expecting.
54+ try :
55+ await self .th2 .CommissionOnNetwork (
56+ nodeId = self .dut_node_id , setupPinCode = setup_code ,
57+ filterType = ChipDeviceCtrl .DiscoveryFilterType .LONG_DISCRIMINATOR , filter = discriminator )
58+ asserts .fail ("Unexpected success when commissioning" )
59+ except ChipStackError as cm : # chipstack-ok
60+ asserts .assert_equal (cm .err , ChipDeviceCtrl .CHIP_ERROR_TIMEOUT ,
61+ 'Unexpected error code returned from Commissioning Attempt' )
62+ except asyncio .exceptions .CancelledError :
63+ pass
6864
6965 def steps_TC_CADMIN_1_5 (self ) -> list [TestStep ]:
7066 return [
@@ -128,10 +124,11 @@ async def test_TC_CADMIN_1_5(self):
128124 expected_discriminator = params .randomDiscriminator
129125 )
130126 logging .info (f"Successfully found service with CM={ service .txt .get ('CM' )} , D={ service .txt .get ('D' )} " )
127+ logging .info ("Test will now sleep for 190s while waiting for commissioning window to time out ... " )
131128 await asyncio .sleep (190 )
132129
133130 self .step (4 )
134- await self .commission_on_network (setup_code = params .commissioningParameters .setupPinCode , discriminator = params .randomDiscriminator )
131+ await self .commission_on_network_expect_error (setup_code = params .commissioningParameters .setupPinCode , discriminator = params .randomDiscriminator )
135132
136133 self .step (5 )
137134 params2 = await self .open_commissioning_window (dev_ctrl = self .th1 , timeout = 180 , node_id = self .dut_node_id )
@@ -142,7 +139,7 @@ async def test_TC_CADMIN_1_5(self):
142139 await asyncio .sleep (1 )
143140
144141 self .step (7 )
145- await self .commission_on_network (setup_code = params2 .commissioningParameters .setupPinCode , discriminator = params2 .randomDiscriminator , expected_error = 0x00000032 )
142+ await self .commission_on_network_expect_error (setup_code = params2 .commissioningParameters .setupPinCode , discriminator = params2 .randomDiscriminator )
146143
147144 self .step (8 )
148145 try :
0 commit comments