From 4e175143a65dfd75541cea0bb38f97f024bb2cd1 Mon Sep 17 00:00:00 2001 From: Jake Ororke Date: Tue, 17 Sep 2024 12:35:09 -0700 Subject: [PATCH 01/10] [Test] Creating TC_CADMIN_1_22 and TC_CADMIN_1_24: - Created CADMIN_1_22 python test module following steps in PR here: - Created CADMIN_1_24 python test module following steps in PR here: - Removed following yaml test modules: -- Test_TC_CADMIN_1_21.yaml, Test_TC_CADMIN_1_22.yaml, Test_TC_CADMIN_1_23.yaml, Test_TC_CADMIN_1_24.yaml --- .../certification/Test_TC_CADMIN_1_21.yaml | 123 ----------- .../certification/Test_TC_CADMIN_1_22.yaml | 199 ------------------ .../certification/Test_TC_CADMIN_1_23.yaml | 124 ----------- .../certification/Test_TC_CADMIN_1_24.yaml | 199 ------------------ src/python_testing/TC_CADMIN_1_22.py | 138 ++++++++++++ src/python_testing/TC_CADMIN_1_24.py | 139 ++++++++++++ 6 files changed, 277 insertions(+), 645 deletions(-) delete mode 100644 src/app/tests/suites/certification/Test_TC_CADMIN_1_21.yaml delete mode 100644 src/app/tests/suites/certification/Test_TC_CADMIN_1_22.yaml delete mode 100644 src/app/tests/suites/certification/Test_TC_CADMIN_1_23.yaml delete mode 100644 src/app/tests/suites/certification/Test_TC_CADMIN_1_24.yaml create mode 100644 src/python_testing/TC_CADMIN_1_22.py create mode 100644 src/python_testing/TC_CADMIN_1_24.py diff --git a/src/app/tests/suites/certification/Test_TC_CADMIN_1_21.yaml b/src/app/tests/suites/certification/Test_TC_CADMIN_1_21.yaml deleted file mode 100644 index f6e7332a9d1f91..00000000000000 --- a/src/app/tests/suites/certification/Test_TC_CADMIN_1_21.yaml +++ /dev/null @@ -1,123 +0,0 @@ -# Copyright (c) 2021 Project CHIP Authors -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -name: - 30.1.21. [TC-CADMIN-1.21] Open commissioning window - durations max and - max+1 [BCM] [DUT - Commissionee] - -PICS: - - CADMIN.S - - CADMIN.S.F00 - -config: - nodeId: 0x12344321 - timeout: 950 - endpoint: 0 - payload: - type: char_string - defaultValue: "MT:-24J0AFN00KA0648G00" - -tests: - - label: "Precondition: Reset Devices to factory defaults" - PICS: PICS_SDK_CI_ONLY - cluster: "SystemCommands" - command: "FactoryReset" - - - label: "Precondition: Reset Devices to factory defaults" - verification: | - Reset Devices to factory defaults - cluster: "LogCommands" - command: "UserPrompt" - PICS: PICS_SKIP_SAMPLE_APP - arguments: - values: - - name: "message" - value: "Factory Reset the DUT and enter 'y' after success" - - name: "expectedValue" - value: "y" - - - label: "Step 1: TH_CR1 starts a commissioning process with DUT_CE" - cluster: "CommissionerCommands" - command: "PairWithCode" - PICS: CADMIN.S - arguments: - values: - - name: "nodeId" - value: nodeId - - name: "payload" - value: payload - - - label: "Step 1: TH_CR1 commissioned with DUT_CE" - cluster: "DelayCommands" - command: "WaitForCommissionee" - PICS: CADMIN.S - arguments: - values: - - name: "nodeId" - value: nodeId - - - label: - "Step 2: TH_CR1 opens a commissioning window on DUT_CE using BCM with - a value of 900 seconds" - cluster: "Administrator Commissioning" - command: "OpenBasicCommissioningWindow" - timedInteractionTimeoutMs: 10000 - PICS: CADMIN.S.C01.Rsp - arguments: - values: - - name: "CommissioningTimeout" - value: 900 - - - label: "Step 3: Wait 901 seconds for commissioning Window to be closed" - PICS: CADMIN.S.C01.Rsp - cluster: "DelayCommands" - command: "WaitForMs" - arguments: - values: - - name: "ms" - value: 901000 - - - label: - "Step 4: TH_CR1 reads the window status to verify the DUT_CE window is - closed" - cluster: "Administrator Commissioning" - command: "readAttribute" - attribute: "WindowStatus" - PICS: CADMIN.S.A0000 - response: - value: 0 - - - label: - "Step 5: TH_CR1 opens a commissioning window on DUT_CE using BCM with - a value of 901 seconds" - cluster: "Administrator Commissioning" - command: "OpenBasicCommissioningWindow" - PICS: CADMIN.S.C01.Rsp - timedInteractionTimeoutMs: 10000 - arguments: - values: - - name: "CommissioningTimeout" - value: 901 - response: - error: INVALID_COMMAND - - - label: - "Step 6: TH_CR1 reads the window status to verify the DUT_CE window is - closed" - cluster: "Administrator Commissioning" - command: "readAttribute" - attribute: "WindowStatus" - PICS: CADMIN.S.A0000 - response: - value: 0 diff --git a/src/app/tests/suites/certification/Test_TC_CADMIN_1_22.yaml b/src/app/tests/suites/certification/Test_TC_CADMIN_1_22.yaml deleted file mode 100644 index 4b94b6518a7529..00000000000000 --- a/src/app/tests/suites/certification/Test_TC_CADMIN_1_22.yaml +++ /dev/null @@ -1,199 +0,0 @@ -# Copyright (c) 2021 Project CHIP Authors -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -name: - 30.1.22. [TC-CADMIN-1.22] Open commissioning window - durations max and - max+1 [ECM] [DUT - Commissionee] - -PICS: - - CADMIN.S - -config: - nodeId: 0x12344321 - timeout: 950 - endpoint: 0 - payload: - type: char_string - defaultValue: "MT:-24J0AFN00KA0648G00" - discriminator: - type: int16u - defaultValue: 3840 - PakeVerifier: - type: octet_string - defaultValue: "hex:b96170aae803346884724fe9a3b287c30330c2a660375d17bb205a8cf1aecb350457f8ab79ee253ab6a8e46bb09e543ae422736de501e3db37d441fe344920d09548e4c18240630c4ff4913c53513839b7c07fcc0627a1b8573a149fcd1fa466cf" - -tests: - - label: "Precondition: Reset Devices to factory defaults" - cluster: "SystemCommands" - PICS: PICS_SDK_CI_ONLY - command: "FactoryReset" - - - label: "Precondition: Reset Devices to factory defaults" - verification: | - Reset Devices to factory defaults - cluster: "LogCommands" - command: "UserPrompt" - PICS: PICS_SKIP_SAMPLE_APP - arguments: - values: - - name: "message" - value: "Factory Reset the DUT and enter 'y' after success" - - name: "expectedValue" - value: "y" - - - label: "Step 1: TH_CR1 starts a commissioning process with DUT_CE" - cluster: "CommissionerCommands" - command: "PairWithCode" - PICS: CADMIN.S - arguments: - values: - - name: "nodeId" - value: nodeId - - name: "payload" - value: payload - - - label: "Step 1: TH_CR1 commissioned with DUT_CE" - cluster: "DelayCommands" - command: "WaitForCommissionee" - PICS: CADMIN.S.C00.Rsp - arguments: - values: - - name: "nodeId" - value: nodeId - - - label: - "Step 2: TH_CR1 opens a commissioning window on DUT_CE using ECM with - a value of 900 seconds" - verification: | - On TH_CR1 - (chip tool), open commissioning window - - ./chip-tool pairing open-commissioning-window 1 1 900 1000 3840 - - Verify Manual pairing code on TH_CR1(chip-tool) Log - - [1635925713.966786][9695:9700] CHIP:SC: Success status report received. Session was established - [1635925713.966839][9695:9700] CHIP:IN: New secure session created for device 0x0000000000000001, key 33!! - [1635925713.966938][9695:9700] CHIP:CTL: OpenCommissioningWindow for device ID 1 - [1635925713.972601][9695:9700] CHIP:DMG: ICR moving to [AddingComm] - [1635925713.972705][9695:9700] CHIP:DMG: ICR moving to [AddedComma] - [1635925713.972815][9695:9700] CHIP:IN: Prepared encrypted message 0xaaaad9b57d10 to 0x0000000000000001 of type 0x8 and protocolId (0, 1) on exchange 31056i with MessageCounter:0. - [1635925713.972876][9695:9700] CHIP:IN: Sending encrypted msg 0xaaaad9b57d10 with MessageCounter:0 to 0x0000000000000001 at monotonic time: 13449459 msec - [1635925713.973006][9695:9700] CHIP:DMG: ICR moving to [CommandSen] - [1635925713.973061][9695:9700] CHIP:CTL: Manual pairing code: [35484132896] - [1635925713.973120][9695:9700] CHIP:CTL: SetupQRCode: [MT:00000CQM00A7F87ZT10] - [1635925713.973178][9695:9700] CHIP:EM: Sending Standalone Ack for MessageCounter:1964916542 on exchange 31055i - cluster: "LogCommands" - command: "UserPrompt" - PICS: PICS_SKIP_SAMPLE_APP && CADMIN.S.C00.Rsp - arguments: - values: - - name: "message" - value: "Enter 'y' after success" - - name: "expectedValue" - value: "y" - - - label: - "Step 2a: TH_CR1 opens a commissioning window on DUT_CE using ECM with - a value of 900 seconds" - cluster: "Administrator Commissioning" - command: "OpenCommissioningWindow" - PICS: CADMIN.S.C00.Rsp && PICS_SDK_CI_ONLY - timedInteractionTimeoutMs: 10000 - arguments: - values: - - name: "CommissioningTimeout" - value: 900 - - name: "PAKEPasscodeVerifier" - value: PakeVerifier - - name: "Discriminator" - value: discriminator - - name: "Iterations" - value: 1000 - - name: "Salt" - value: "SPAKE2P Key Salt" - - - label: "Step 3: Wait for commissioning Window to 901 seconds" - PICS: CADMIN.S.C00.Rsp - cluster: "DelayCommands" - command: "WaitForMs" - arguments: - values: - - name: "ms" - value: 901000 - - - label: - "Step 4: TH_CR1 reads the window status to verify the DUT_CE window is - closed" - cluster: "Administrator Commissioning" - command: "readAttribute" - attribute: "WindowStatus" - PICS: CADMIN.S.A0000 - response: - value: 0 - - - label: - "Step 5: TH_CR1 opens a commissioning window on DUT_CE using ECM with - a value of 901 seconds" - verification: | - On TH_CR1 (chip tool), open commissioning window - - ./chip-tool pairing open-commissioning-window 1 1 901 2000 3841 - - Verify DUT_CE responds General error 0x85 on TH_CR1 (chip-tool) log - - CHIP:DMG: Received Command Response Status for Endpoint=0 Cluster=0x0000_003C Command=0x0000_0001 Status=0x85 - [1652860801.225084][9512:9517] CHIP:TOO: Error: IM Error 0x00000585: General error: 0x85 (INVALID_COMMAND) - [1652860801.225173][9512:9517] CHIP:DMG: ICR moving to [AwaitingDe] - [1652860801.225294][9512:9517] CHIP:EM: Sending Standalone Ack for MessageCounter:4191961 on exchange 37827i - cluster: "LogCommands" - command: "UserPrompt" - PICS: PICS_SKIP_SAMPLE_APP && CADMIN.S.C00.Rsp - arguments: - values: - - name: "message" - value: "Enter 'y' after success" - - name: "expectedValue" - value: "y" - - - label: - "Step 5a: TH_CR1 opens a commissioning window on DUT_CE using ECM with - a value of 901 seconds" - cluster: "Administrator Commissioning" - command: "OpenCommissioningWindow" - PICS: CADMIN.S.C00.Rsp && PICS_SDK_CI_ONLY - timedInteractionTimeoutMs: 10000 - arguments: - values: - - name: "CommissioningTimeout" - value: 901 - - name: "PAKEPasscodeVerifier" - value: PakeVerifier - - name: "Discriminator" - value: discriminator - - name: "Iterations" - value: 1000 - - name: "Salt" - value: "SPAKE2P Key Salt" - response: - error: INVALID_COMMAND - - - label: - "Step 6: TH_CR1 reads the window status to verify the DUT_CE window is - closed" - cluster: "Administrator Commissioning" - command: "readAttribute" - attribute: "WindowStatus" - PICS: CADMIN.S.A0000 - response: - value: 0 diff --git a/src/app/tests/suites/certification/Test_TC_CADMIN_1_23.yaml b/src/app/tests/suites/certification/Test_TC_CADMIN_1_23.yaml deleted file mode 100644 index 9aab51aa3876d2..00000000000000 --- a/src/app/tests/suites/certification/Test_TC_CADMIN_1_23.yaml +++ /dev/null @@ -1,124 +0,0 @@ -# Copyright (c) 2021 Project CHIP Authors -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -name: - 24.1.23. [TC-CADMIN-1.23] Open commissioning window - durations max and - max+1 [BCM] [DUT - Commissionee] - -PICS: - - CADMIN.S - - CADMIN.S.F00 - -config: - nodeId: 0x12344321 - timeout: 200 - endpoint: 0 - payload: - type: char_string - defaultValue: "MT:-24J0AFN00KA0648G00" - -tests: - - label: "Precondition: Reset Devices to factory defaults" - PICS: PICS_SDK_CI_ONLY - cluster: "SystemCommands" - command: "FactoryReset" - - - label: "Precondition: Reset Devices to factory defaults" - verification: | - Reset Devices to factory defaults - cluster: "LogCommands" - command: "UserPrompt" - PICS: PICS_SKIP_SAMPLE_APP - arguments: - values: - - name: "message" - value: "Factory Reset the DUT and enter 'y' after success" - - name: "expectedValue" - value: "y" - - - label: "Step 1: TH_CR1 starts a commissioning process with DUT_CE" - cluster: "CommissionerCommands" - command: "PairWithCode" - PICS: CADMIN.S - arguments: - values: - - name: "nodeId" - value: nodeId - - name: "payload" - value: payload - - - label: "Step 1: TH_CR1 commissioned with DUT_CE" - cluster: "DelayCommands" - command: "WaitForCommissionee" - PICS: CADMIN.S.C01.Rsp - arguments: - values: - - name: "nodeId" - value: nodeId - - - label: - "Step 2: TH_CR1 opens a commissioning window on DUT_CE using BCM with - a value of 180 seconds" - cluster: "Administrator Commissioning" - command: "OpenBasicCommissioningWindow" - PICS: CADMIN.S.C01.Rsp - timedInteractionTimeoutMs: 10000 - arguments: - values: - - name: "CommissioningTimeout" - value: 180 - - - label: - "Step 3: Wait for 181 seconds for commissioning Window to be closed" - PICS: CADMIN.S.C01.Rsp - cluster: "DelayCommands" - command: "WaitForMs" - arguments: - values: - - name: "ms" - value: 181000 - - - label: - "Step 4: TH_CR1 reads the window status to verify the DUT_CE window is - closed" - cluster: "Administrator Commissioning" - command: "readAttribute" - attribute: "WindowStatus" - PICS: CADMIN.S.A0000 - response: - value: 0 - - - label: - "Step 5: TH_CR1 opens a commissioning window on DUT_CE using BCM with - a value of 179 seconds" - cluster: "Administrator Commissioning" - command: "OpenBasicCommissioningWindow" - PICS: CADMIN.S.C01.Rsp - timedInteractionTimeoutMs: 10000 - arguments: - values: - - name: "CommissioningTimeout" - value: 179 - response: - error: INVALID_COMMAND - - - label: - "Step 6: TH_CR1 reads the window status to verify the DUT_CE window is - closed" - cluster: "Administrator Commissioning" - command: "readAttribute" - attribute: "WindowStatus" - PICS: CADMIN.S.A0000 - response: - value: 0 diff --git a/src/app/tests/suites/certification/Test_TC_CADMIN_1_24.yaml b/src/app/tests/suites/certification/Test_TC_CADMIN_1_24.yaml deleted file mode 100644 index 8e201988cc87db..00000000000000 --- a/src/app/tests/suites/certification/Test_TC_CADMIN_1_24.yaml +++ /dev/null @@ -1,199 +0,0 @@ -# Copyright (c) 2021 Project CHIP Authors -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -name: - 24.1.24. [TC-CADMIN-1.24] Open commissioning window - durations max and - max+1 [ECM] [DUT - Commissionee] - -PICS: - - CADMIN.S - -config: - nodeId: 0x12344321 - timeout: 200 - endpoint: 0 - payload: - type: char_string - defaultValue: "MT:-24J0AFN00KA0648G00" - discriminator: - type: int16u - defaultValue: 3840 - PakeVerifier: - type: octet_string - defaultValue: "hex:b96170aae803346884724fe9a3b287c30330c2a660375d17bb205a8cf1aecb350457f8ab79ee253ab6a8e46bb09e543ae422736de501e3db37d441fe344920d09548e4c18240630c4ff4913c53513839b7c07fcc0627a1b8573a149fcd1fa466cf" - -tests: - - label: "Precondition: Reset Devices to factory defaults" - cluster: "SystemCommands" - PICS: PICS_SDK_CI_ONLY - command: "FactoryReset" - - - label: "Precondition: Reset Devices to factory defaults" - verification: | - Reset Devices to factory defaults - cluster: "LogCommands" - command: "UserPrompt" - PICS: PICS_SKIP_SAMPLE_APP - arguments: - values: - - name: "message" - value: "Factory Reset the DUT and enter 'y' after success" - - name: "expectedValue" - value: "y" - - - label: "Step 1: TH_CR1 starts a commissioning process with DUT_CE" - cluster: "CommissionerCommands" - command: "PairWithCode" - PICS: CADMIN.S - arguments: - values: - - name: "nodeId" - value: nodeId - - name: "payload" - value: payload - - - label: "Step 1: TH_CR1 commissioned with DUT_CE" - cluster: "DelayCommands" - command: "WaitForCommissionee" - PICS: CADMIN.S.C00.Rsp - arguments: - values: - - name: "nodeId" - value: nodeId - - - label: - "Step 2: TH_CR1 opens a commissioning window on DUT_CE using ECM with - a value of 180 seconds" - verification: | - On TH_CR1 ( chip tool), open commissioning window - - ./chip-tool pairing open-commissioning-window 1 1 180 1000 3840 - - Verify Manual pairing code on TH_CR1(chip-tool) Log - - [1635925713.966786][9695:9700] CHIP:SC: Success status report received. Session was established - [1635925713.966839][9695:9700] CHIP:IN: New secure session created for device 0x0000000000000001, key 33!! - [1635925713.966938][9695:9700] CHIP:CTL: OpenCommissioningWindow for device ID 1 - [1635925713.972601][9695:9700] CHIP:DMG: ICR moving to [AddingComm] - [1635925713.972705][9695:9700] CHIP:DMG: ICR moving to [AddedComma] - [1635925713.972815][9695:9700] CHIP:IN: Prepared encrypted message 0xaaaad9b57d10 to 0x0000000000000001 of type 0x8 and protocolId (0, 1) on exchange 31056i with MessageCounter:0. - [1635925713.972876][9695:9700] CHIP:IN: Sending encrypted msg 0xaaaad9b57d10 with MessageCounter:0 to 0x0000000000000001 at monotonic time: 13449459 msec - [1635925713.973006][9695:9700] CHIP:DMG: ICR moving to [CommandSen] - [1635925713.973061][9695:9700] CHIP:CTL: Manual pairing code: [35484132896] - [1635925713.973120][9695:9700] CHIP:CTL: SetupQRCode: [MT:00000CQM00A7F87ZT10] - [1635925713.973178][9695:9700] CHIP:EM: Sending Standalone Ack for MessageCounter:1964916542 on exchange 31055i - cluster: "LogCommands" - command: "UserPrompt" - PICS: PICS_SKIP_SAMPLE_APP && CADMIN.S.C00.Rsp - arguments: - values: - - name: "message" - value: "Enter 'y' after success" - - name: "expectedValue" - value: "y" - - - label: - "Step 2a: TH_CR1 opens a commissioning window on DUT_CE using ECM with - a value of 180 seconds" - cluster: "Administrator Commissioning" - command: "OpenCommissioningWindow" - PICS: CADMIN.S.C00.Rsp && PICS_SDK_CI_ONLY - timedInteractionTimeoutMs: 10000 - arguments: - values: - - name: "CommissioningTimeout" - value: 180 - - name: "PAKEPasscodeVerifier" - value: PakeVerifier - - name: "Discriminator" - value: discriminator - - name: "Iterations" - value: 1000 - - name: "Salt" - value: "SPAKE2P Key Salt" - - - label: "Step 3: Wait for commissioning Window to 181 seconds" - PICS: CADMIN.S.C00.Rsp - cluster: "DelayCommands" - command: "WaitForMs" - arguments: - values: - - name: "ms" - value: 181000 - - - label: - "Step 4: TH_CR1 reads the window status to verify the DUT_CE window is - closed" - cluster: "Administrator Commissioning" - command: "readAttribute" - attribute: "WindowStatus" - PICS: CADMIN.S.A0000 - response: - value: 0 - - - label: - "Step 5: TH_CR1 opens a commissioning window on DUT_CE using ECM with - a value of 179 seconds" - verification: | - On TH_CR1 ( chip tool), open commissioning window - - ./chip-tool pairing open-commissioning-window 1 1 179 2000 3841 - - Verify DUT_CE responds General error 0x85 on TH_CR1 (chip-tool) log - - CHIP:DMG: Received Command Response Status for Endpoint=0 Cluster=0x0000_003C Command=0x0000_0001 Status=0x85 - [1652860801.225084][9512:9517] CHIP:TOO: Error: IM Error 0x00000585: General error: 0x85 (INVALID_COMMAND) - [1652860801.225173][9512:9517] CHIP:DMG: ICR moving to [AwaitingDe] - [1652860801.225294][9512:9517] CHIP:EM: Sending Standalone Ack for MessageCounter:4191961 on exchange 37827i - cluster: "LogCommands" - command: "UserPrompt" - PICS: PICS_SKIP_SAMPLE_APP && CADMIN.S.C00.Rsp - arguments: - values: - - name: "message" - value: "Enter 'y' after success" - - name: "expectedValue" - value: "y" - - - label: - "Step 5a: TH_CR1 opens a commissioning window on DUT_CE using ECM with - a value of 179 seconds" - cluster: "Administrator Commissioning" - command: "OpenCommissioningWindow" - PICS: CADMIN.S.C00.Rsp && PICS_SDK_CI_ONLY - timedInteractionTimeoutMs: 10000 - arguments: - values: - - name: "CommissioningTimeout" - value: 179 - - name: "PAKEPasscodeVerifier" - value: PakeVerifier - - name: "Discriminator" - value: discriminator - - name: "Iterations" - value: 1000 - - name: "Salt" - value: "SPAKE2P Key Salt" - response: - error: INVALID_COMMAND - - - label: - "Step 6: TH_CR1 reads the window status to verify the DUT_CE window is - closed" - cluster: "Administrator Commissioning" - command: "readAttribute" - attribute: "WindowStatus" - PICS: CADMIN.S.A0000 - response: - value: 0 diff --git a/src/python_testing/TC_CADMIN_1_22.py b/src/python_testing/TC_CADMIN_1_22.py new file mode 100644 index 00000000000000..4ecd2a780959b4 --- /dev/null +++ b/src/python_testing/TC_CADMIN_1_22.py @@ -0,0 +1,138 @@ +# +# Copyright (c) 2024 Project CHIP Authors +# All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# === BEGIN CI TEST ARGUMENTS === +# test-runner-runs: run1 +# test-runner-run/run1/app: ${ALL_CLUSTERS_APP} +# test-runner-run/run1/factoryreset: True +# test-runner-run/run1/quiet: True +# test-runner-run/run1/app-args: --discriminator 1234 --KVS kvs1 --trace-to json:${TRACE_APP}.json +# test-runner-run/run1/script-args: --storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --trace-to json:${TRACE_TEST_JSON}.json --trace-to perfetto:${TRACE_TEST_PERFETTO}.perfetto --PICS src/app/tests/suites/certification/ci-pics-values +# === END CI TEST ARGUMENTS === + +import logging +import random +from time import sleep + +import chip.clusters as Clusters +from chip import ChipDeviceCtrl +from chip.ChipDeviceCtrl import CommissioningParameters +from chip.exceptions import ChipStackError +from chip.native import PyChipError +from matter_testing_support import MatterBaseTest, TestStep, async_test_body, default_matter_test_main +from mobly import asserts + + +class TC_CADMIN_1_22(MatterBaseTest): + async def OpenCommissioningWindow(self) -> CommissioningParameters: + try: + params = await self.th1.OpenCommissioningWindow( + nodeid=self.dut_node_id, timeout=self.max_window_duration, iteration=10000, discriminator=self.discriminator, option=1) + return params + + except Exception as e: + logging.exception('Error running OpenCommissioningWindow %s', e) + asserts.assert_true(False, 'Failed to open commissioning window') + + def generate_unique_random_value(self, value): + while True: + random_value = random.randint(10000000, 99999999) + if random_value != value: + return random_value + + async def CommissionAttempt( + self, setupPinCode: int, thnum: int, th: str, fail: bool): + + logging.info(f"-----------------Commissioning with TH_CR{str(thnum)}-------------------------") + if fail == True: + ctx = asserts.assert_raises(ChipStackError) + self.print_step(0, ctx) + with ctx: + await th.CommissionOnNetwork( + nodeId=self.dut_node_id, setupPinCode=setup_code, + filterType=ChipDeviceCtrl.DiscoveryFilterType.LONG_DISCRIMINATOR, filter=self.discriminator) + errcode = PyChipError.from_code(ctx.exception.err) + logging.info('Commissioning complete done. Successful? {}, errorcode = {}, cycle={}'.format( + errcode.is_success, errcode, (cycle+1))) + asserts.assert_false(errcode.is_success, 'Commissioning complete did not error as expected') + asserts.assert_true(errcode.sdk_code == 0x0000000B, + 'Unexpected error code returned from CommissioningComplete') + + elif fail == False: + await th.CommissionOnNetwork( + nodeId=self.dut_node_id, setupPinCode=setupPinCode, + filterType=ChipDeviceCtrl.DiscoveryFilterType.LONG_DISCRIMINATOR, filter=self.discriminator) + + async def get_window_status(self) -> int: + AC_cluster = Clusters.AdministratorCommissioning + window_status = await self.read_single_attribute_check_success(dev_ctrl=self.th1, fabric_filtered=False, endpoint=0, cluster=AC_cluster, attribute=AC_cluster.Attributes.WindowStatus) + return window_status + + def steps_TC_CADMIN_1_22(self) -> list[TestStep]: + return [ + TestStep(1, "Commissioning, already done", is_commissioning=True), + TestStep(2, "TH_CR1 opens a commissioning window on DUT_CE using ECM with a value of 900 seconds", + "DUT_CE opens its Commissioning window to allow a second commissioning"), + TestStep(3, "TH_CR1 sends an RevokeCommissioning command to the DUT"), + TestStep(4, "TH_CR1 reads the window status to verify the DUT_CE window is closed", "DUT_CE windows status shows the window is closed"), + TestStep(5, "TH_CR1 opens a commissioning window on DUT_CE using ECM with a value of 901 seconds", + "DUT_CE does not open its Commissioning window to allow a second commissioning. DUT_CE shows 'Failed to open commissioning window. Global status 0x85'"), + TestStep(6, "TH_CR1 reads the window status to verify the DUT_CE window is closed", "DUT_CE windows status shows the window is closed"), + ] + + def pics_TC_CADMIN_1_22(self) -> list[str]: + return ["CADMIN.S"] + + @async_test_body + async def test_TC_CADMIN_1_22(self): + self.step(1) + self.th1 = self.default_controller + self.discriminator = random.randint(0, 4095) + + self.step(2) + params = await self.th1.OpenCommissioningWindow( + nodeid=self.dut_node_id, timeout=900, iteration=10000, discriminator=self.discriminator, option=1) + + self.step(3) + revokeCmd = Clusters.AdministratorCommissioning.Commands.RevokeCommissioning() + await self.th1.SendCommand(nodeid=self.dut_node_id, endpoint=0, payload=revokeCmd, timedRequestTimeoutMs=6000) + # The failsafe cleanup is scheduled after the command completes, so give it a bit of time to do that + sleep(1) + + self.step(4) + window_status = await self.get_window_status() + if window_status != 0: + asserts.fail(f"Commissioning window is expected to be closed, but was found to be open") + + self.step(5) + try: + params = await self.th1.OpenCommissioningWindow( + nodeid=self.dut_node_id, timeout=901, iteration=10000, discriminator=self.discriminator, option=1) + + except ChipStackError as e: + # Since we provided 901 seconds as the timeout duration, + # we should not be able to open comm window as duration is too long. + asserts.assert_equal(e.err, 0x00000585, + "Expected to error as we provided failure value for opening commissioning window") + + self.step(6) + window_status2 = await self.get_window_status() + if window_status2 != 0: + asserts.fail(f"Commissioning window is expected to be closed, but was found to be open") + + +if __name__ == "__main__": + default_matter_test_main() diff --git a/src/python_testing/TC_CADMIN_1_24.py b/src/python_testing/TC_CADMIN_1_24.py new file mode 100644 index 00000000000000..d36e405e2c41d6 --- /dev/null +++ b/src/python_testing/TC_CADMIN_1_24.py @@ -0,0 +1,139 @@ +# +# Copyright (c) 2024 Project CHIP Authors +# All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# === BEGIN CI TEST ARGUMENTS === +# test-runner-runs: run1 +# test-runner-run/run1/app: ${ALL_CLUSTERS_APP} +# test-runner-run/run1/factoryreset: True +# test-runner-run/run1/quiet: True +# test-runner-run/run1/app-args: --discriminator 1234 --KVS kvs1 --trace-to json:${TRACE_APP}.json +# test-runner-run/run1/script-args: --storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --trace-to json:${TRACE_TEST_JSON}.json --trace-to perfetto:${TRACE_TEST_PERFETTO}.perfetto --PICS src/app/tests/suites/certification/ci-pics-values +# === END CI TEST ARGUMENTS === + +import logging +import random +from time import sleep + +import chip.clusters as Clusters +from chip import ChipDeviceCtrl +from chip.ChipDeviceCtrl import CommissioningParameters +from chip.exceptions import ChipStackError +from chip.native import PyChipError +from matter_testing_support import MatterBaseTest, TestStep, async_test_body, default_matter_test_main +from mobly import asserts + + +class TC_CADMIN_1_24(MatterBaseTest): + async def OpenCommissioningWindow(self) -> CommissioningParameters: + try: + params = await self.th1.OpenCommissioningWindow( + nodeid=self.dut_node_id, timeout=self.max_window_duration, iteration=10000, discriminator=self.discriminator, option=1) + return params + + except Exception as e: + logging.exception('Error running OpenCommissioningWindow %s', e) + asserts.assert_true(False, 'Failed to open commissioning window') + + def generate_unique_random_value(self, value): + while True: + random_value = random.randint(10000000, 99999999) + if random_value != value: + return random_value + + async def CommissionAttempt( + self, setupPinCode: int, thnum: int, th: str, fail: bool): + + logging.info(f"-----------------Commissioning with TH_CR{str(thnum)}-------------------------") + if fail == True: + ctx = asserts.assert_raises(ChipStackError) + self.print_step(0, ctx) + with ctx: + await th.CommissionOnNetwork( + nodeId=self.dut_node_id, setupPinCode=setup_code, + filterType=ChipDeviceCtrl.DiscoveryFilterType.LONG_DISCRIMINATOR, filter=self.discriminator) + errcode = PyChipError.from_code(ctx.exception.err) + logging.info('Commissioning complete done. Successful? {}, errorcode = {}, cycle={}'.format( + errcode.is_success, errcode, (cycle+1))) + asserts.assert_false(errcode.is_success, 'Commissioning complete did not error as expected') + asserts.assert_true(errcode.sdk_code == 0x0000000B, + 'Unexpected error code returned from CommissioningComplete') + + elif fail == False: + await th.CommissionOnNetwork( + nodeId=self.dut_node_id, setupPinCode=setupPinCode, + filterType=ChipDeviceCtrl.DiscoveryFilterType.LONG_DISCRIMINATOR, filter=self.discriminator) + + async def get_window_status(self) -> int: + AC_cluster = Clusters.AdministratorCommissioning + window_status = await self.read_single_attribute_check_success(dev_ctrl=self.th1, fabric_filtered=False, endpoint=0, cluster=AC_cluster, attribute=AC_cluster.Attributes.WindowStatus) + return window_status + + def steps_TC_CADMIN_1_24(self) -> list[TestStep]: + return [ + TestStep(1, "Commissioning, already done", is_commissioning=True), + TestStep(2, "TH_CR1 opens a commissioning window on DUT_CE using ECM with a value of 180 seconds", + "DUT_CE opens its Commissioning window to allow a second commissioning"), + TestStep(3, "TH_CR1 sends an RevokeCommissioning command to the DUT"), + TestStep(4, "TH_CR1 reads the window status to verify the DUT_CE window is closed", + "DUT_CE windows status shows the window is closed"), + TestStep(5, "TH_CR1 opens a commissioning window on DUT_CE using ECM with a value of 179 seconds", + "DUT_CE does not open its Commissioning window to allow a second commissioning. DUT_CE shows 'Failed to open commissioning window. Global status 0x85'"), + TestStep(6, "TH_CR1 reads the window status to verify the DUT_CE window is closed", "DUT_CE windows status shows the window is closed"), + ] + + def pics_TC_CADMIN_1_24(self) -> list[str]: + return ["CADMIN.S"] + + @async_test_body + async def test_TC_CADMIN_1_24(self): + self.step(1) + self.th1 = self.default_controller + self.discriminator = random.randint(0, 4095) + + self.step(2) + params = await self.th1.OpenCommissioningWindow( + nodeid=self.dut_node_id, timeout=180, iteration=10000, discriminator=self.discriminator, option=1) + + self.step(3) + revokeCmd = Clusters.AdministratorCommissioning.Commands.RevokeCommissioning() + await self.th1.SendCommand(nodeid=self.dut_node_id, endpoint=0, payload=revokeCmd, timedRequestTimeoutMs=6000) + # The failsafe cleanup is scheduled after the command completes, so give it a bit of time to do that + sleep(1) + + self.step(4) + window_status = await self.get_window_status() + if window_status != 0: + asserts.fail(f"Commissioning window is expected to be closed, but was found to be open") + + self.step(5) + try: + params = await self.th1.OpenCommissioningWindow( + nodeid=self.dut_node_id, timeout=179, iteration=10000, discriminator=self.discriminator, option=1) + + except ChipStackError as e: + # Since we provided 901 seconds as the timeout duration, + # we should not be able to open comm window as duration is too long. + asserts.assert_equal(e.err, 0x00000585, + "Expected to error as we provided failure value for opening commissioning window") + + self.step(6) + window_status2 = await self.get_window_status() + if window_status2 != 0: + asserts.fail(f"Commissioning window is expected to be closed, but was found to be open") + + +if __name__ == "__main__": + default_matter_test_main() From e244d9808c2db5d3f09789c54f948e30a143d0ca Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Tue, 17 Sep 2024 19:42:22 +0000 Subject: [PATCH 02/10] Restyled by autopep8 --- src/python_testing/TC_CADMIN_1_22.py | 20 +++++++++++--------- src/python_testing/TC_CADMIN_1_24.py | 21 +++++++++++---------- 2 files changed, 22 insertions(+), 19 deletions(-) diff --git a/src/python_testing/TC_CADMIN_1_22.py b/src/python_testing/TC_CADMIN_1_22.py index 4ecd2a780959b4..20085b6c30626c 100644 --- a/src/python_testing/TC_CADMIN_1_22.py +++ b/src/python_testing/TC_CADMIN_1_22.py @@ -84,13 +84,15 @@ async def get_window_status(self) -> int: def steps_TC_CADMIN_1_22(self) -> list[TestStep]: return [ TestStep(1, "Commissioning, already done", is_commissioning=True), - TestStep(2, "TH_CR1 opens a commissioning window on DUT_CE using ECM with a value of 900 seconds", - "DUT_CE opens its Commissioning window to allow a second commissioning"), + TestStep(2, "TH_CR1 opens a commissioning window on DUT_CE using ECM with a value of 900 seconds", + "DUT_CE opens its Commissioning window to allow a second commissioning"), TestStep(3, "TH_CR1 sends an RevokeCommissioning command to the DUT"), - TestStep(4, "TH_CR1 reads the window status to verify the DUT_CE window is closed", "DUT_CE windows status shows the window is closed"), - TestStep(5, "TH_CR1 opens a commissioning window on DUT_CE using ECM with a value of 901 seconds", - "DUT_CE does not open its Commissioning window to allow a second commissioning. DUT_CE shows 'Failed to open commissioning window. Global status 0x85'"), - TestStep(6, "TH_CR1 reads the window status to verify the DUT_CE window is closed", "DUT_CE windows status shows the window is closed"), + TestStep(4, "TH_CR1 reads the window status to verify the DUT_CE window is closed", + "DUT_CE windows status shows the window is closed"), + TestStep(5, "TH_CR1 opens a commissioning window on DUT_CE using ECM with a value of 901 seconds", + "DUT_CE does not open its Commissioning window to allow a second commissioning. DUT_CE shows 'Failed to open commissioning window. Global status 0x85'"), + TestStep(6, "TH_CR1 reads the window status to verify the DUT_CE window is closed", + "DUT_CE windows status shows the window is closed"), ] def pics_TC_CADMIN_1_22(self) -> list[str]: @@ -118,15 +120,15 @@ async def test_TC_CADMIN_1_22(self): asserts.fail(f"Commissioning window is expected to be closed, but was found to be open") self.step(5) - try: + try: params = await self.th1.OpenCommissioningWindow( nodeid=self.dut_node_id, timeout=901, iteration=10000, discriminator=self.discriminator, option=1) except ChipStackError as e: - # Since we provided 901 seconds as the timeout duration, + # Since we provided 901 seconds as the timeout duration, # we should not be able to open comm window as duration is too long. asserts.assert_equal(e.err, 0x00000585, - "Expected to error as we provided failure value for opening commissioning window") + "Expected to error as we provided failure value for opening commissioning window") self.step(6) window_status2 = await self.get_window_status() diff --git a/src/python_testing/TC_CADMIN_1_24.py b/src/python_testing/TC_CADMIN_1_24.py index d36e405e2c41d6..1b50bc909c6a33 100644 --- a/src/python_testing/TC_CADMIN_1_24.py +++ b/src/python_testing/TC_CADMIN_1_24.py @@ -84,14 +84,15 @@ async def get_window_status(self) -> int: def steps_TC_CADMIN_1_24(self) -> list[TestStep]: return [ TestStep(1, "Commissioning, already done", is_commissioning=True), - TestStep(2, "TH_CR1 opens a commissioning window on DUT_CE using ECM with a value of 180 seconds", - "DUT_CE opens its Commissioning window to allow a second commissioning"), + TestStep(2, "TH_CR1 opens a commissioning window on DUT_CE using ECM with a value of 180 seconds", + "DUT_CE opens its Commissioning window to allow a second commissioning"), TestStep(3, "TH_CR1 sends an RevokeCommissioning command to the DUT"), - TestStep(4, "TH_CR1 reads the window status to verify the DUT_CE window is closed", - "DUT_CE windows status shows the window is closed"), - TestStep(5, "TH_CR1 opens a commissioning window on DUT_CE using ECM with a value of 179 seconds", - "DUT_CE does not open its Commissioning window to allow a second commissioning. DUT_CE shows 'Failed to open commissioning window. Global status 0x85'"), - TestStep(6, "TH_CR1 reads the window status to verify the DUT_CE window is closed", "DUT_CE windows status shows the window is closed"), + TestStep(4, "TH_CR1 reads the window status to verify the DUT_CE window is closed", + "DUT_CE windows status shows the window is closed"), + TestStep(5, "TH_CR1 opens a commissioning window on DUT_CE using ECM with a value of 179 seconds", + "DUT_CE does not open its Commissioning window to allow a second commissioning. DUT_CE shows 'Failed to open commissioning window. Global status 0x85'"), + TestStep(6, "TH_CR1 reads the window status to verify the DUT_CE window is closed", + "DUT_CE windows status shows the window is closed"), ] def pics_TC_CADMIN_1_24(self) -> list[str]: @@ -119,15 +120,15 @@ async def test_TC_CADMIN_1_24(self): asserts.fail(f"Commissioning window is expected to be closed, but was found to be open") self.step(5) - try: + try: params = await self.th1.OpenCommissioningWindow( nodeid=self.dut_node_id, timeout=179, iteration=10000, discriminator=self.discriminator, option=1) except ChipStackError as e: - # Since we provided 901 seconds as the timeout duration, + # Since we provided 901 seconds as the timeout duration, # we should not be able to open comm window as duration is too long. asserts.assert_equal(e.err, 0x00000585, - "Expected to error as we provided failure value for opening commissioning window") + "Expected to error as we provided failure value for opening commissioning window") self.step(6) window_status2 = await self.get_window_status() From c8a2509ad2cdd348f0dbfcdc5f4e7b50590b49c6 Mon Sep 17 00:00:00 2001 From: Jake Ororke Date: Tue, 17 Sep 2024 13:02:57 -0700 Subject: [PATCH 03/10] Updating TC_CADMIN_1_22 and TC_CADMIN_1_24: - Resolved linting issues --- src/python_testing/TC_CADMIN_1_22.py | 18 +++++++++--------- src/python_testing/TC_CADMIN_1_24.py | 18 +++++++++--------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/python_testing/TC_CADMIN_1_22.py b/src/python_testing/TC_CADMIN_1_22.py index 20085b6c30626c..71cfd01948293d 100644 --- a/src/python_testing/TC_CADMIN_1_22.py +++ b/src/python_testing/TC_CADMIN_1_22.py @@ -57,21 +57,21 @@ async def CommissionAttempt( self, setupPinCode: int, thnum: int, th: str, fail: bool): logging.info(f"-----------------Commissioning with TH_CR{str(thnum)}-------------------------") - if fail == True: + if fail: ctx = asserts.assert_raises(ChipStackError) self.print_step(0, ctx) with ctx: await th.CommissionOnNetwork( - nodeId=self.dut_node_id, setupPinCode=setup_code, + nodeId=self.dut_node_id, setupPinCode=setupPinCode, filterType=ChipDeviceCtrl.DiscoveryFilterType.LONG_DISCRIMINATOR, filter=self.discriminator) errcode = PyChipError.from_code(ctx.exception.err) - logging.info('Commissioning complete done. Successful? {}, errorcode = {}, cycle={}'.format( - errcode.is_success, errcode, (cycle+1))) + logging.info('Commissioning complete done. Successful? {}, errorcode = {}'.format( + errcode.is_success, errcode)) asserts.assert_false(errcode.is_success, 'Commissioning complete did not error as expected') asserts.assert_true(errcode.sdk_code == 0x0000000B, 'Unexpected error code returned from CommissioningComplete') - elif fail == False: + elif not fail: await th.CommissionOnNetwork( nodeId=self.dut_node_id, setupPinCode=setupPinCode, filterType=ChipDeviceCtrl.DiscoveryFilterType.LONG_DISCRIMINATOR, filter=self.discriminator) @@ -105,7 +105,7 @@ async def test_TC_CADMIN_1_22(self): self.discriminator = random.randint(0, 4095) self.step(2) - params = await self.th1.OpenCommissioningWindow( + await self.th1.OpenCommissioningWindow( nodeid=self.dut_node_id, timeout=900, iteration=10000, discriminator=self.discriminator, option=1) self.step(3) @@ -117,11 +117,11 @@ async def test_TC_CADMIN_1_22(self): self.step(4) window_status = await self.get_window_status() if window_status != 0: - asserts.fail(f"Commissioning window is expected to be closed, but was found to be open") + asserts.fail("Commissioning window is expected to be closed, but was found to be open") self.step(5) try: - params = await self.th1.OpenCommissioningWindow( + await self.th1.OpenCommissioningWindow( nodeid=self.dut_node_id, timeout=901, iteration=10000, discriminator=self.discriminator, option=1) except ChipStackError as e: @@ -133,7 +133,7 @@ async def test_TC_CADMIN_1_22(self): self.step(6) window_status2 = await self.get_window_status() if window_status2 != 0: - asserts.fail(f"Commissioning window is expected to be closed, but was found to be open") + asserts.fail("Commissioning window is expected to be closed, but was found to be open") if __name__ == "__main__": diff --git a/src/python_testing/TC_CADMIN_1_24.py b/src/python_testing/TC_CADMIN_1_24.py index 1b50bc909c6a33..7d1c1791ca8770 100644 --- a/src/python_testing/TC_CADMIN_1_24.py +++ b/src/python_testing/TC_CADMIN_1_24.py @@ -57,21 +57,21 @@ async def CommissionAttempt( self, setupPinCode: int, thnum: int, th: str, fail: bool): logging.info(f"-----------------Commissioning with TH_CR{str(thnum)}-------------------------") - if fail == True: + if fail: ctx = asserts.assert_raises(ChipStackError) self.print_step(0, ctx) with ctx: await th.CommissionOnNetwork( - nodeId=self.dut_node_id, setupPinCode=setup_code, + nodeId=self.dut_node_id, setupPinCode=setupPinCode, filterType=ChipDeviceCtrl.DiscoveryFilterType.LONG_DISCRIMINATOR, filter=self.discriminator) errcode = PyChipError.from_code(ctx.exception.err) - logging.info('Commissioning complete done. Successful? {}, errorcode = {}, cycle={}'.format( - errcode.is_success, errcode, (cycle+1))) + logging.info('Commissioning complete done. Successful? {}, errorcode = {}'.format( + errcode.is_success, errcode)) asserts.assert_false(errcode.is_success, 'Commissioning complete did not error as expected') asserts.assert_true(errcode.sdk_code == 0x0000000B, 'Unexpected error code returned from CommissioningComplete') - elif fail == False: + elif not fail: await th.CommissionOnNetwork( nodeId=self.dut_node_id, setupPinCode=setupPinCode, filterType=ChipDeviceCtrl.DiscoveryFilterType.LONG_DISCRIMINATOR, filter=self.discriminator) @@ -105,7 +105,7 @@ async def test_TC_CADMIN_1_24(self): self.discriminator = random.randint(0, 4095) self.step(2) - params = await self.th1.OpenCommissioningWindow( + await self.th1.OpenCommissioningWindow( nodeid=self.dut_node_id, timeout=180, iteration=10000, discriminator=self.discriminator, option=1) self.step(3) @@ -117,11 +117,11 @@ async def test_TC_CADMIN_1_24(self): self.step(4) window_status = await self.get_window_status() if window_status != 0: - asserts.fail(f"Commissioning window is expected to be closed, but was found to be open") + asserts.fail("Commissioning window is expected to be closed, but was found to be open") self.step(5) try: - params = await self.th1.OpenCommissioningWindow( + await self.th1.OpenCommissioningWindow( nodeid=self.dut_node_id, timeout=179, iteration=10000, discriminator=self.discriminator, option=1) except ChipStackError as e: @@ -133,7 +133,7 @@ async def test_TC_CADMIN_1_24(self): self.step(6) window_status2 = await self.get_window_status() if window_status2 != 0: - asserts.fail(f"Commissioning window is expected to be closed, but was found to be open") + asserts.fail("Commissioning window is expected to be closed, but was found to be open") if __name__ == "__main__": From 8866fbe9417a523fde23709b78622fe9dd01eefd Mon Sep 17 00:00:00 2001 From: Jake Ororke Date: Fri, 27 Sep 2024 09:21:01 -0700 Subject: [PATCH 04/10] Created TC_CADMIN_1_22_24 test module: - Merged TC_CADMIN_1_24 and TC_CADMIN_1_22 standalone test modules into a single test module - Found enum for window closed value and replaced it in the tests - Removed generate_unique_value and AttemptCommission functions - Updated CI arguments format to YAML'esque format --- ...TC_CADMIN_1_22.py => TC_CADMIN_1_22_24.py} | 109 +++++++++----- src/python_testing/TC_CADMIN_1_24.py | 140 ------------------ 2 files changed, 70 insertions(+), 179 deletions(-) rename src/python_testing/{TC_CADMIN_1_22.py => TC_CADMIN_1_22_24.py} (56%) delete mode 100644 src/python_testing/TC_CADMIN_1_24.py diff --git a/src/python_testing/TC_CADMIN_1_22.py b/src/python_testing/TC_CADMIN_1_22_24.py similarity index 56% rename from src/python_testing/TC_CADMIN_1_22.py rename to src/python_testing/TC_CADMIN_1_22_24.py index 71cfd01948293d..52695284f250db 100644 --- a/src/python_testing/TC_CADMIN_1_22.py +++ b/src/python_testing/TC_CADMIN_1_22_24.py @@ -14,13 +14,20 @@ # See the License for the specific language governing permissions and # limitations under the License. # -# === BEGIN CI TEST ARGUMENTS === -# test-runner-runs: run1 -# test-runner-run/run1/app: ${ALL_CLUSTERS_APP} -# test-runner-run/run1/factoryreset: True -# test-runner-run/run1/quiet: True -# test-runner-run/run1/app-args: --discriminator 1234 --KVS kvs1 --trace-to json:${TRACE_APP}.json -# test-runner-run/run1/script-args: --storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --trace-to json:${TRACE_TEST_JSON}.json --trace-to perfetto:${TRACE_TEST_PERFETTO}.perfetto --PICS src/app/tests/suites/certification/ci-pics-values +#=== BEGIN CI TEST ARGUMENTS === +# test-runner-runs: +# run1: +# app: ${ALL_CLUSTERS_APP} +# factoryreset: true +# quiet: true +# app-args: --discriminator 1234 --KVS kvs1 --trace-to json:${TRACE_APP}.json +# script-args: > +# --storage-path admin_storage.json +# --commissioning-method on-network +# --discriminator 1234 +# --passcode 20202021 +# --trace-to json:${TRACE_TEST_JSON}.json +# --trace-to perfetto:${TRACE_TEST_PERFETTO}.perfetto # === END CI TEST ARGUMENTS === import logging @@ -47,40 +54,14 @@ async def OpenCommissioningWindow(self) -> CommissioningParameters: logging.exception('Error running OpenCommissioningWindow %s', e) asserts.assert_true(False, 'Failed to open commissioning window') - def generate_unique_random_value(self, value): - while True: - random_value = random.randint(10000000, 99999999) - if random_value != value: - return random_value - - async def CommissionAttempt( - self, setupPinCode: int, thnum: int, th: str, fail: bool): - - logging.info(f"-----------------Commissioning with TH_CR{str(thnum)}-------------------------") - if fail: - ctx = asserts.assert_raises(ChipStackError) - self.print_step(0, ctx) - with ctx: - await th.CommissionOnNetwork( - nodeId=self.dut_node_id, setupPinCode=setupPinCode, - filterType=ChipDeviceCtrl.DiscoveryFilterType.LONG_DISCRIMINATOR, filter=self.discriminator) - errcode = PyChipError.from_code(ctx.exception.err) - logging.info('Commissioning complete done. Successful? {}, errorcode = {}'.format( - errcode.is_success, errcode)) - asserts.assert_false(errcode.is_success, 'Commissioning complete did not error as expected') - asserts.assert_true(errcode.sdk_code == 0x0000000B, - 'Unexpected error code returned from CommissioningComplete') - - elif not fail: - await th.CommissionOnNetwork( - nodeId=self.dut_node_id, setupPinCode=setupPinCode, - filterType=ChipDeviceCtrl.DiscoveryFilterType.LONG_DISCRIMINATOR, filter=self.discriminator) - async def get_window_status(self) -> int: AC_cluster = Clusters.AdministratorCommissioning window_status = await self.read_single_attribute_check_success(dev_ctrl=self.th1, fabric_filtered=False, endpoint=0, cluster=AC_cluster, attribute=AC_cluster.Attributes.WindowStatus) return window_status + def pics_TC_CADMIN_1_22(self) -> list[str]: + return ["CADMIN.S"] + def steps_TC_CADMIN_1_22(self) -> list[TestStep]: return [ TestStep(1, "Commissioning, already done", is_commissioning=True), @@ -95,9 +76,23 @@ def steps_TC_CADMIN_1_22(self) -> list[TestStep]: "DUT_CE windows status shows the window is closed"), ] - def pics_TC_CADMIN_1_22(self) -> list[str]: + def pics_TC_CADMIN_1_24(self) -> list[str]: return ["CADMIN.S"] + def steps_TC_CADMIN_1_24(self) -> list[TestStep]: + return [ + TestStep(1, "Commissioning, already done", is_commissioning=True), + TestStep(2, "TH_CR1 opens a commissioning window on DUT_CE using ECM with a value of 180 seconds", + "DUT_CE opens its Commissioning window to allow a second commissioning"), + TestStep(3, "TH_CR1 sends an RevokeCommissioning command to the DUT"), + TestStep(4, "TH_CR1 reads the window status to verify the DUT_CE window is closed", + "DUT_CE windows status shows the window is closed"), + TestStep(5, "TH_CR1 opens a commissioning window on DUT_CE using ECM with a value of 179 seconds", + "DUT_CE does not open its Commissioning window to allow a second commissioning. DUT_CE shows 'Failed to open commissioning window. Global status 0x85'"), + TestStep(6, "TH_CR1 reads the window status to verify the DUT_CE window is closed", + "DUT_CE windows status shows the window is closed"), + ] + @async_test_body async def test_TC_CADMIN_1_22(self): self.step(1) @@ -116,7 +111,7 @@ async def test_TC_CADMIN_1_22(self): self.step(4) window_status = await self.get_window_status() - if window_status != 0: + if window_status != Clusters.AdministratorCommissioning.Enums.CommissioningWindowStatusEnum.kWindowNotOpen: asserts.fail("Commissioning window is expected to be closed, but was found to be open") self.step(5) @@ -132,9 +127,45 @@ async def test_TC_CADMIN_1_22(self): self.step(6) window_status2 = await self.get_window_status() - if window_status2 != 0: + if window_status2 != Clusters.AdministratorCommissioning.Enums.CommissioningWindowStatusEnum.kWindowNotOpen: asserts.fail("Commissioning window is expected to be closed, but was found to be open") + @async_test_body + async def test_TC_CADMIN_1_24(self): + self.step(1) + self.th1 = self.default_controller + self.discriminator = random.randint(0, 4095) + + self.step(2) + await self.th1.OpenCommissioningWindow( + nodeid=self.dut_node_id, timeout=180, iteration=10000, discriminator=self.discriminator, option=1) + + self.step(3) + revokeCmd = Clusters.AdministratorCommissioning.Commands.RevokeCommissioning() + await self.th1.SendCommand(nodeid=self.dut_node_id, endpoint=0, payload=revokeCmd, timedRequestTimeoutMs=6000) + # The failsafe cleanup is scheduled after the command completes, so give it a bit of time to do that + sleep(1) + + self.step(4) + window_status = await self.get_window_status() + if window_status != Clusters.AdministratorCommissioning.Enums.CommissioningWindowStatusEnum.kWindowNotOpen: + asserts.fail("Commissioning window is expected to be closed, but was found to be open") + + self.step(5) + try: + await self.th1.OpenCommissioningWindow( + nodeid=self.dut_node_id, timeout=179, iteration=10000, discriminator=self.discriminator, option=1) + + except ChipStackError as e: + # Since we provided 901 seconds as the timeout duration, + # we should not be able to open comm window as duration is too long. + asserts.assert_equal(e.err, 0x00000585, + "Expected to error as we provided failure value for opening commissioning window") + + self.step(6) + window_status2 = await self.get_window_status() + if window_status2 != Clusters.AdministratorCommissioning.Enums.CommissioningWindowStatusEnum.kWindowNotOpen: + asserts.fail("Commissioning window is expected to be closed, but was found to be open") if __name__ == "__main__": default_matter_test_main() diff --git a/src/python_testing/TC_CADMIN_1_24.py b/src/python_testing/TC_CADMIN_1_24.py deleted file mode 100644 index 7d1c1791ca8770..00000000000000 --- a/src/python_testing/TC_CADMIN_1_24.py +++ /dev/null @@ -1,140 +0,0 @@ -# -# Copyright (c) 2024 Project CHIP Authors -# All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# === BEGIN CI TEST ARGUMENTS === -# test-runner-runs: run1 -# test-runner-run/run1/app: ${ALL_CLUSTERS_APP} -# test-runner-run/run1/factoryreset: True -# test-runner-run/run1/quiet: True -# test-runner-run/run1/app-args: --discriminator 1234 --KVS kvs1 --trace-to json:${TRACE_APP}.json -# test-runner-run/run1/script-args: --storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --trace-to json:${TRACE_TEST_JSON}.json --trace-to perfetto:${TRACE_TEST_PERFETTO}.perfetto --PICS src/app/tests/suites/certification/ci-pics-values -# === END CI TEST ARGUMENTS === - -import logging -import random -from time import sleep - -import chip.clusters as Clusters -from chip import ChipDeviceCtrl -from chip.ChipDeviceCtrl import CommissioningParameters -from chip.exceptions import ChipStackError -from chip.native import PyChipError -from matter_testing_support import MatterBaseTest, TestStep, async_test_body, default_matter_test_main -from mobly import asserts - - -class TC_CADMIN_1_24(MatterBaseTest): - async def OpenCommissioningWindow(self) -> CommissioningParameters: - try: - params = await self.th1.OpenCommissioningWindow( - nodeid=self.dut_node_id, timeout=self.max_window_duration, iteration=10000, discriminator=self.discriminator, option=1) - return params - - except Exception as e: - logging.exception('Error running OpenCommissioningWindow %s', e) - asserts.assert_true(False, 'Failed to open commissioning window') - - def generate_unique_random_value(self, value): - while True: - random_value = random.randint(10000000, 99999999) - if random_value != value: - return random_value - - async def CommissionAttempt( - self, setupPinCode: int, thnum: int, th: str, fail: bool): - - logging.info(f"-----------------Commissioning with TH_CR{str(thnum)}-------------------------") - if fail: - ctx = asserts.assert_raises(ChipStackError) - self.print_step(0, ctx) - with ctx: - await th.CommissionOnNetwork( - nodeId=self.dut_node_id, setupPinCode=setupPinCode, - filterType=ChipDeviceCtrl.DiscoveryFilterType.LONG_DISCRIMINATOR, filter=self.discriminator) - errcode = PyChipError.from_code(ctx.exception.err) - logging.info('Commissioning complete done. Successful? {}, errorcode = {}'.format( - errcode.is_success, errcode)) - asserts.assert_false(errcode.is_success, 'Commissioning complete did not error as expected') - asserts.assert_true(errcode.sdk_code == 0x0000000B, - 'Unexpected error code returned from CommissioningComplete') - - elif not fail: - await th.CommissionOnNetwork( - nodeId=self.dut_node_id, setupPinCode=setupPinCode, - filterType=ChipDeviceCtrl.DiscoveryFilterType.LONG_DISCRIMINATOR, filter=self.discriminator) - - async def get_window_status(self) -> int: - AC_cluster = Clusters.AdministratorCommissioning - window_status = await self.read_single_attribute_check_success(dev_ctrl=self.th1, fabric_filtered=False, endpoint=0, cluster=AC_cluster, attribute=AC_cluster.Attributes.WindowStatus) - return window_status - - def steps_TC_CADMIN_1_24(self) -> list[TestStep]: - return [ - TestStep(1, "Commissioning, already done", is_commissioning=True), - TestStep(2, "TH_CR1 opens a commissioning window on DUT_CE using ECM with a value of 180 seconds", - "DUT_CE opens its Commissioning window to allow a second commissioning"), - TestStep(3, "TH_CR1 sends an RevokeCommissioning command to the DUT"), - TestStep(4, "TH_CR1 reads the window status to verify the DUT_CE window is closed", - "DUT_CE windows status shows the window is closed"), - TestStep(5, "TH_CR1 opens a commissioning window on DUT_CE using ECM with a value of 179 seconds", - "DUT_CE does not open its Commissioning window to allow a second commissioning. DUT_CE shows 'Failed to open commissioning window. Global status 0x85'"), - TestStep(6, "TH_CR1 reads the window status to verify the DUT_CE window is closed", - "DUT_CE windows status shows the window is closed"), - ] - - def pics_TC_CADMIN_1_24(self) -> list[str]: - return ["CADMIN.S"] - - @async_test_body - async def test_TC_CADMIN_1_24(self): - self.step(1) - self.th1 = self.default_controller - self.discriminator = random.randint(0, 4095) - - self.step(2) - await self.th1.OpenCommissioningWindow( - nodeid=self.dut_node_id, timeout=180, iteration=10000, discriminator=self.discriminator, option=1) - - self.step(3) - revokeCmd = Clusters.AdministratorCommissioning.Commands.RevokeCommissioning() - await self.th1.SendCommand(nodeid=self.dut_node_id, endpoint=0, payload=revokeCmd, timedRequestTimeoutMs=6000) - # The failsafe cleanup is scheduled after the command completes, so give it a bit of time to do that - sleep(1) - - self.step(4) - window_status = await self.get_window_status() - if window_status != 0: - asserts.fail("Commissioning window is expected to be closed, but was found to be open") - - self.step(5) - try: - await self.th1.OpenCommissioningWindow( - nodeid=self.dut_node_id, timeout=179, iteration=10000, discriminator=self.discriminator, option=1) - - except ChipStackError as e: - # Since we provided 901 seconds as the timeout duration, - # we should not be able to open comm window as duration is too long. - asserts.assert_equal(e.err, 0x00000585, - "Expected to error as we provided failure value for opening commissioning window") - - self.step(6) - window_status2 = await self.get_window_status() - if window_status2 != 0: - asserts.fail("Commissioning window is expected to be closed, but was found to be open") - - -if __name__ == "__main__": - default_matter_test_main() From 2ac8bbea52c5bafee9e2bf5807924bbd6d750999 Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Fri, 27 Sep 2024 16:29:08 +0000 Subject: [PATCH 05/10] Restyled by autopep8 --- src/python_testing/TC_CADMIN_1_22_24.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/python_testing/TC_CADMIN_1_22_24.py b/src/python_testing/TC_CADMIN_1_22_24.py index 52695284f250db..1fbc852819475a 100644 --- a/src/python_testing/TC_CADMIN_1_22_24.py +++ b/src/python_testing/TC_CADMIN_1_22_24.py @@ -14,7 +14,7 @@ # See the License for the specific language governing permissions and # limitations under the License. # -#=== BEGIN CI TEST ARGUMENTS === +# === BEGIN CI TEST ARGUMENTS === # test-runner-runs: # run1: # app: ${ALL_CLUSTERS_APP} @@ -167,5 +167,6 @@ async def test_TC_CADMIN_1_24(self): if window_status2 != Clusters.AdministratorCommissioning.Enums.CommissioningWindowStatusEnum.kWindowNotOpen: asserts.fail("Commissioning window is expected to be closed, but was found to be open") + if __name__ == "__main__": default_matter_test_main() From e741b804b93eadedf6480ed10d85f9f7de0bc58a Mon Sep 17 00:00:00 2001 From: Jake Ororke Date: Fri, 27 Sep 2024 10:06:55 -0700 Subject: [PATCH 06/10] Updated TC_CADMIN_1_22_24: - Renamed class to TC_CADMIN_1_22_24 --- src/python_testing/TC_CADMIN_1_22_24.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/python_testing/TC_CADMIN_1_22_24.py b/src/python_testing/TC_CADMIN_1_22_24.py index 1fbc852819475a..0c110b8fb2f50c 100644 --- a/src/python_testing/TC_CADMIN_1_22_24.py +++ b/src/python_testing/TC_CADMIN_1_22_24.py @@ -43,7 +43,7 @@ from mobly import asserts -class TC_CADMIN_1_22(MatterBaseTest): +class TC_CADMIN_1_22_24(MatterBaseTest): async def OpenCommissioningWindow(self) -> CommissioningParameters: try: params = await self.th1.OpenCommissioningWindow( From d80f97a46f5caaac337613f8b8df22eaaec1d3f2 Mon Sep 17 00:00:00 2001 From: Jake Ororke Date: Fri, 27 Sep 2024 10:43:54 -0700 Subject: [PATCH 07/10] Updating TC_CADMIN_1_22_24: - Resolving lint errors --- src/python_testing/TC_CADMIN_1_22_24.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/python_testing/TC_CADMIN_1_22_24.py b/src/python_testing/TC_CADMIN_1_22_24.py index 0c110b8fb2f50c..50c98dbdc26acd 100644 --- a/src/python_testing/TC_CADMIN_1_22_24.py +++ b/src/python_testing/TC_CADMIN_1_22_24.py @@ -35,10 +35,8 @@ from time import sleep import chip.clusters as Clusters -from chip import ChipDeviceCtrl from chip.ChipDeviceCtrl import CommissioningParameters from chip.exceptions import ChipStackError -from chip.native import PyChipError from matter_testing_support import MatterBaseTest, TestStep, async_test_body, default_matter_test_main from mobly import asserts From b1d88ca7dc31a606694d3e4d05274439ca18be8e Mon Sep 17 00:00:00 2001 From: Jake Ororke Date: Fri, 18 Oct 2024 12:08:57 -0700 Subject: [PATCH 08/10] Update TC_CADMIN_1_22_24.py Updated to include dependency location change for matter_testing support module --- src/python_testing/TC_CADMIN_1_22_24.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/python_testing/TC_CADMIN_1_22_24.py b/src/python_testing/TC_CADMIN_1_22_24.py index 50c98dbdc26acd..327b87f35289eb 100644 --- a/src/python_testing/TC_CADMIN_1_22_24.py +++ b/src/python_testing/TC_CADMIN_1_22_24.py @@ -37,7 +37,7 @@ import chip.clusters as Clusters from chip.ChipDeviceCtrl import CommissioningParameters from chip.exceptions import ChipStackError -from matter_testing_support import MatterBaseTest, TestStep, async_test_body, default_matter_test_main +from chip.testing.matter_testing import MatterBaseTest, TestStep, async_test_body, default_matter_test_main from mobly import asserts From fd13214f964959acd79a47c0bd0d0f8a43b53afd Mon Sep 17 00:00:00 2001 From: Jake Ororke Date: Fri, 18 Oct 2024 16:32:39 -0700 Subject: [PATCH 09/10] Updated TC_CADMIN_1_22_24.py: - Resolved issues with CI args in TC_CADMIN_1_22_24 test module - Removed yaml calls for 1_21, 1_22, 1_23, and 1_24, also removed yaml call for 1_9 from manualTests.json --- src/app/tests/suites/manualTests.json | 5 ---- src/python_testing/TC_CADMIN_1_22_24.py | 39 +++++++++++++------------ 2 files changed, 20 insertions(+), 24 deletions(-) diff --git a/src/app/tests/suites/manualTests.json b/src/app/tests/suites/manualTests.json index 01d98213b3e279..ce47e05f3dbef5 100644 --- a/src/app/tests/suites/manualTests.json +++ b/src/app/tests/suites/manualTests.json @@ -179,17 +179,12 @@ "Test_TC_CADMIN_1_18", "Test_TC_CADMIN_1_19", "Test_TC_CADMIN_1_20", - "Test_TC_CADMIN_1_21", - "Test_TC_CADMIN_1_22", "Test_TC_CADMIN_1_3", "Test_TC_CADMIN_1_4", "Test_TC_CADMIN_1_5", "Test_TC_CADMIN_1_6", - "Test_TC_CADMIN_1_9", "Test_TC_CADMIN_1_10", "Test_TC_CADMIN_1_13", - "Test_TC_CADMIN_1_23", - "Test_TC_CADMIN_1_24", "Test_TC_CADMIN_1_25", "Test_TC_CADMIN_1_26" ], diff --git a/src/python_testing/TC_CADMIN_1_22_24.py b/src/python_testing/TC_CADMIN_1_22_24.py index 327b87f35289eb..9af79ac86af7f3 100644 --- a/src/python_testing/TC_CADMIN_1_22_24.py +++ b/src/python_testing/TC_CADMIN_1_22_24.py @@ -18,8 +18,6 @@ # test-runner-runs: # run1: # app: ${ALL_CLUSTERS_APP} -# factoryreset: true -# quiet: true # app-args: --discriminator 1234 --KVS kvs1 --trace-to json:${TRACE_APP}.json # script-args: > # --storage-path admin_storage.json @@ -28,6 +26,9 @@ # --passcode 20202021 # --trace-to json:${TRACE_TEST_JSON}.json # --trace-to perfetto:${TRACE_TEST_PERFETTO}.perfetto +# --PICS src/app/tests/suites/certification/ci-pics-values +# factory-reset: true +# quiet: true # === END CI TEST ARGUMENTS === import logging @@ -74,23 +75,6 @@ def steps_TC_CADMIN_1_22(self) -> list[TestStep]: "DUT_CE windows status shows the window is closed"), ] - def pics_TC_CADMIN_1_24(self) -> list[str]: - return ["CADMIN.S"] - - def steps_TC_CADMIN_1_24(self) -> list[TestStep]: - return [ - TestStep(1, "Commissioning, already done", is_commissioning=True), - TestStep(2, "TH_CR1 opens a commissioning window on DUT_CE using ECM with a value of 180 seconds", - "DUT_CE opens its Commissioning window to allow a second commissioning"), - TestStep(3, "TH_CR1 sends an RevokeCommissioning command to the DUT"), - TestStep(4, "TH_CR1 reads the window status to verify the DUT_CE window is closed", - "DUT_CE windows status shows the window is closed"), - TestStep(5, "TH_CR1 opens a commissioning window on DUT_CE using ECM with a value of 179 seconds", - "DUT_CE does not open its Commissioning window to allow a second commissioning. DUT_CE shows 'Failed to open commissioning window. Global status 0x85'"), - TestStep(6, "TH_CR1 reads the window status to verify the DUT_CE window is closed", - "DUT_CE windows status shows the window is closed"), - ] - @async_test_body async def test_TC_CADMIN_1_22(self): self.step(1) @@ -128,6 +112,23 @@ async def test_TC_CADMIN_1_22(self): if window_status2 != Clusters.AdministratorCommissioning.Enums.CommissioningWindowStatusEnum.kWindowNotOpen: asserts.fail("Commissioning window is expected to be closed, but was found to be open") + def pics_TC_CADMIN_1_24(self) -> list[str]: + return ["CADMIN.S"] + + def steps_TC_CADMIN_1_24(self) -> list[TestStep]: + return [ + TestStep(1, "Commissioning, already done", is_commissioning=True), + TestStep(2, "TH_CR1 opens a commissioning window on DUT_CE using ECM with a value of 180 seconds", + "DUT_CE opens its Commissioning window to allow a second commissioning"), + TestStep(3, "TH_CR1 sends an RevokeCommissioning command to the DUT"), + TestStep(4, "TH_CR1 reads the window status to verify the DUT_CE window is closed", + "DUT_CE windows status shows the window is closed"), + TestStep(5, "TH_CR1 opens a commissioning window on DUT_CE using ECM with a value of 179 seconds", + "DUT_CE does not open its Commissioning window to allow a second commissioning. DUT_CE shows 'Failed to open commissioning window. Global status 0x85'"), + TestStep(6, "TH_CR1 reads the window status to verify the DUT_CE window is closed", + "DUT_CE windows status shows the window is closed"), + ] + @async_test_body async def test_TC_CADMIN_1_24(self): self.step(1) From 08bd80da0ab2bac3b8313f9057db1669d0511d6b Mon Sep 17 00:00:00 2001 From: Jake Ororke Date: Wed, 30 Oct 2024 10:42:48 -0700 Subject: [PATCH 10/10] Updating TC_CADMIN_1_22_24 test module: - Resolving comments from tehampson as these were needed changes to be made -- Substituted to using cleaner code for assert.asserts_equal instead of just assert.failure -- Resolving copy paste error in TC_CADMIN_1_4 test -- Made comments cleaner by rewording to include what the error code was referring too --- src/python_testing/TC_CADMIN_1_22_24.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/python_testing/TC_CADMIN_1_22_24.py b/src/python_testing/TC_CADMIN_1_22_24.py index 9af79ac86af7f3..c1b8199c697c78 100644 --- a/src/python_testing/TC_CADMIN_1_22_24.py +++ b/src/python_testing/TC_CADMIN_1_22_24.py @@ -28,7 +28,7 @@ # --trace-to perfetto:${TRACE_TEST_PERFETTO}.perfetto # --PICS src/app/tests/suites/certification/ci-pics-values # factory-reset: true -# quiet: true +# quiet: false # === END CI TEST ARGUMENTS === import logging @@ -37,7 +37,7 @@ import chip.clusters as Clusters from chip.ChipDeviceCtrl import CommissioningParameters -from chip.exceptions import ChipStackError +from chip.exceptions import ChipStackError from chip.testing.matter_testing import MatterBaseTest, TestStep, async_test_body, default_matter_test_main from mobly import asserts @@ -51,7 +51,7 @@ async def OpenCommissioningWindow(self) -> CommissioningParameters: except Exception as e: logging.exception('Error running OpenCommissioningWindow %s', e) - asserts.assert_true(False, 'Failed to open commissioning window') + asserts.fail('Failed to open commissioning window') async def get_window_status(self) -> int: AC_cluster = Clusters.AdministratorCommissioning @@ -94,7 +94,7 @@ async def test_TC_CADMIN_1_22(self): self.step(4) window_status = await self.get_window_status() if window_status != Clusters.AdministratorCommissioning.Enums.CommissioningWindowStatusEnum.kWindowNotOpen: - asserts.fail("Commissioning window is expected to be closed, but was found to be open") + asserts.assert_equal(await window_status, Clusters.AdministratorCommissioning.Enums.CommissioningWindowStatusEnum.kWindowNotOpen, "Commissioning window is expected to be closed, but was found to be open") self.step(5) try: @@ -104,13 +104,14 @@ async def test_TC_CADMIN_1_22(self): except ChipStackError as e: # Since we provided 901 seconds as the timeout duration, # we should not be able to open comm window as duration is too long. + # we are expected receive Failed to open commissioning window: IM Error 0x00000585: General error: 0x85 (INVALID_COMMAND) asserts.assert_equal(e.err, 0x00000585, "Expected to error as we provided failure value for opening commissioning window") self.step(6) window_status2 = await self.get_window_status() if window_status2 != Clusters.AdministratorCommissioning.Enums.CommissioningWindowStatusEnum.kWindowNotOpen: - asserts.fail("Commissioning window is expected to be closed, but was found to be open") + asserts.assert_equal(await window_status, Clusters.AdministratorCommissioning.Enums.CommissioningWindowStatusEnum.kWindowNotOpen, "Commissioning window is expected to be closed, but was found to be open") def pics_TC_CADMIN_1_24(self) -> list[str]: return ["CADMIN.S"] @@ -148,7 +149,7 @@ async def test_TC_CADMIN_1_24(self): self.step(4) window_status = await self.get_window_status() if window_status != Clusters.AdministratorCommissioning.Enums.CommissioningWindowStatusEnum.kWindowNotOpen: - asserts.fail("Commissioning window is expected to be closed, but was found to be open") + asserts.assert_equal(await window_status, Clusters.AdministratorCommissioning.Enums.CommissioningWindowStatusEnum.kWindowNotOpen, "Commissioning window is expected to be closed, but was found to be open") self.step(5) try: @@ -156,16 +157,16 @@ async def test_TC_CADMIN_1_24(self): nodeid=self.dut_node_id, timeout=179, iteration=10000, discriminator=self.discriminator, option=1) except ChipStackError as e: - # Since we provided 901 seconds as the timeout duration, + # Since we provided 179 seconds as the timeout duration, # we should not be able to open comm window as duration is too long. + # we are expected receive Failed to open commissioning window: IM Error 0x00000585: General error: 0x85 (INVALID_COMMAND) asserts.assert_equal(e.err, 0x00000585, "Expected to error as we provided failure value for opening commissioning window") self.step(6) window_status2 = await self.get_window_status() if window_status2 != Clusters.AdministratorCommissioning.Enums.CommissioningWindowStatusEnum.kWindowNotOpen: - asserts.fail("Commissioning window is expected to be closed, but was found to be open") - + asserts.assert_equal(await window_status, Clusters.AdministratorCommissioning.Enums.CommissioningWindowStatusEnum.kWindowNotOpen, "Commissioning window is expected to be closed, but was found to be open") if __name__ == "__main__": default_matter_test_main()