From d9c6de56df8ea92b5bda3eff12f1e8d4589222f3 Mon Sep 17 00:00:00 2001 From: Jake Ororke Date: Thu, 17 Oct 2024 11:32:05 -0700 Subject: [PATCH] [ Test ] Creating test module TC_CADMIN_1_11 (#34760) * Creating test module TC_CADMIN_1_11: - Test module created following matter-test-scripts task (https://github.com/project-chip/matter-test-scripts/issues/286): -- Open commissioning window on DUT twice using ECM then BCM [DUT - Commissionee] -- Commission DUT to TH_CR1 (can be skipped if done in a preceding test) -- TH_CR1 reads the BasicCommissioningInfo attribute from the General Commissioning cluster on EP0 and saves the MaxCumulativeFailsafeSeconds as timeout -- TH_CR1 sends an OpenCommissioningWindow command to the DUT with the CommissioningTimeout set to timeout -- TH_CR2 fully commissions the DUT -- TH_CR1 sends an OpenCommissioningWindow command to the DUT with the CommissioningTimeout set to timeout -- TH_CR1 sends an OpenCommissioningWindow command to the DUT with the CommissioningTimeout set to timeout -- TH_CR2 sends an OpenCommissioningWindow command to the DUT with the CommissioningTimeout set to timeout -- TH_CR1 sends an RevokeCommissioning command to the DUT -- TH_CR1 reads the FeatureMap from the Administrator Commissioning Cluster. If the feature map includes the BC feature bit, repeat steps 5-8 using the OpenBasicCommissioningWindow command -- TH_CR2 reads the CurrentFabricIndex attribute from the Node Operational Credentials cluster and saves as th2_idx -- TH_CR1 sends the RemoveFabric command to the DUT with the FabricIndex set to th2_idx * Restyled by autopep8 * Update tests.yaml * Update TC_CADMIN_1_11.py Updated OpenbasicCommissioningWindow to update to using correct variables. * Updated TC_CADMIN_1_11 test module: - Removed unneccessary count variable due to no longer being needed - Added expectations to TestSteps - Replaced elif with else statements in OpenCommissioningWindow and OpenBasicCommissioningWindow functions - Set busy_enum var using Clusters.AdministratorCommissioning.Enums.StatusCode.kBusy enum value - Changed method to check features for administrator commissioning cluster to check if BC bit value is contained in features * Restyled by autopep8 * Updated TC_CADMIN_1_11: - Removed unneeded prints from the code output * Restyled by autopep8 * Apply suggestions from code review Co-authored-by: C Freeman * Update TC_CADMIN_1_11.py -Added Optional function from typing library to resolve issue with latest code change * Update TC_CADMIN_1_11.py - Due to recent changes, had to update to using PyChipError for ctx.exception.err in order to handle error raised during commissioning properly * Updating TC_CADMIN_1_11: - Updated method for OpenBasicCommissiongWindow with BC feature enabled * Restyled by autopep8 * Update src/python_testing/TC_CADMIN_1_11.py Co-authored-by: C Freeman * Updated TC_CADMIN_1_11 test module: - Removed useTestCommissioner when creating self.th2 - Changed to using None instead of 0 as variable value for OpenCommissioningWindow() - Removed generate_unique_randow_value() as not needed in this test module * Updating TC_CADMIN_1_11 test module: - Resolved linting error * Updated TC_CADMIN_1_11: - Updated due to latest changes to matter_testing support module * Restyled by autopep8 * Removed TC_CADMIN_1_11.yaml and updated TC_CADMIN_1_11: - Removed Test_TC_CADMIN_1_11.yaml - Updated TC_CADMIN_1_11 python test module to enable verbose output in CI/CD pipeline. * Updated TC_CADMIN_1_11 test module: - Updated CI/CD nominclature for this test to match latest version * Updated src/app/tests/suites/manualTests.json: - Removed Test_TC_CADMIN_1_11 from MultipleFabrics section --------- Co-authored-by: Restyled.io Co-authored-by: C Freeman --- .../certification/Test_TC_CADMIN_1_11.yaml | 377 ------------------ src/app/tests/suites/manualTests.json | 1 - src/python_testing/TC_CADMIN_1_11.py | 222 +++++++++++ 3 files changed, 222 insertions(+), 378 deletions(-) delete mode 100644 src/app/tests/suites/certification/Test_TC_CADMIN_1_11.yaml create mode 100644 src/python_testing/TC_CADMIN_1_11.py diff --git a/src/app/tests/suites/certification/Test_TC_CADMIN_1_11.yaml b/src/app/tests/suites/certification/Test_TC_CADMIN_1_11.yaml deleted file mode 100644 index 26503486dd059a..00000000000000 --- a/src/app/tests/suites/certification/Test_TC_CADMIN_1_11.yaml +++ /dev/null @@ -1,377 +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. -# Auto-generated scripts for harness use only, please review before automation. The endpoints and cluster names are currently set to default - -name: - 4.1.11. [TC-CADMIN-1.11] Open commissioning window on DUT twice using ECM - then BCM [DUT - Commissionee] - -PICS: - - CADMIN.S - - CADMIN.S.F00 - -config: - nodeId: 0x12344321 - cluster: "Basic Information" - endpoint: 0 - -tests: - - label: "Precondition" - verification: | - Reset Devices to factory defaults - disabled: true - - - label: "Step 1: TH_CR1 starts a commissioning process with DUT_CE" - PICS: CADMIN.S - verification: | - "1. Provision the DUT_CE (all-cluster-app) device using TH_CR1 (chip-tool ) on the raspi" - disabled: true - - - label: - "Step 2: TH_CR1 opens a commissioning window on DUT_CE using a - commissioning timeout of PIXIT.CADMIN.CwDuration seconds using ECM" - PICS: CADMIN.S.C00.Rsp - verification: | - On TH_CR1 send the below command - - ./chip-tool pairing open-commissioning-window 1 1 180 1000 3840 - - Verify the Open commisioning window on the DUT_CE(all-cluster-app) Log: - - [1660904553.796857][3537:3537] CHIP:DMG: Received command for Endpoint=0 Cluster=0x0000_003C Command=0x0000_0000 - [1660904553.796951][3537:3537] CHIP:ZCL: Received command to open commissioning window - [1660904553.797255][3537:3537] CHIP:IN: SecureSession[0xaaab142ef7f0]: Allocated Type:1 LSID:34523 - - Verify the Manual pairing code on the TH_CR1(chip-tool) Log: - - [1635864513.699433][3850:3855] CHIP:DMG: ICR moving to [CommandSen] - [1635864513.699489][3850:3855] CHIP:CTL: Manual pairing code: [36177160937] - [1635864513.699566][3850:3855] CHIP:CTL: SetupQRCode: [MT:00000CQM00YZN476420] - [1635864513.699636][3850:3855] CHIP:EM: Sending Standalone Ack for MessageCounter:2599714227 on exchange 60688i - [1635864513.699685][3850:3855] CHIP:IN: Prepared plaintext message 0xffff8a7cd960 to 0x0000000000000000 of type - disabled: true - - - label: "Step 3: DNS-SD records shows DUT_CE advertising" - verification: | - On TH_CR1 send the below command - - avahi-browse -rt _matterc._udp - + wlp5s0 IPv6 C326228BDB082BF4 _matterc._udp local - + wlp5s0 IPv6 7B6545A75C5330BE _matterc._udp local - = wlp5s0 IPv6 7B6545A75C5330BE _matterc._udp local - hostname = [E45F010F27530000.local] - address = [fe80::e65f:1ff:fe0f:2755] - port = [5540] - txt = ["PI=" "PH=33" "CM=1" "D=3841" "T=1" "CRA=300" "CRI=5000" "VP=65521+32769"] - = wlp5s0 IPv6 C326228BDB082BF4 _matterc._udp local - hostname = [E45F010F27530000.local] - address = [fe80::e65f:1ff:fe0f:2755] - port = [5540] - txt = ["PI=" "PH=36" "CM=2" "D=3840" "T=1" "CRA=300" "CRI=5000" "VP=65521+32769"] - grl@grl-ThinkPad-L480:~/2nd_cntrl/connectedhomeip/examples/chip-tool/out/debug$ On TH_CR1 send the below command - disabled: true - - - label: "Step 4: TH_CR3 Commissions with DUT_CE" - PICS: CADMIN.S - verification: | - On TH_CR3 send the below command - - ./chip-tool pairing code 3 35484132896 --commissioner-name gamma - - Verify you got below message TH_CR3(chip-tool) log - Device commissioning completed with success - disabled: true - - - label: - "Step 5: TH_CR1 opens a commissioning window on DUT_CE using a - commissioning timeout of PIXIT.CADMIN.CwDuration seconds using ECM and - TH_CR2 Commissions with DUT_CE" - PICS: CADMIN.S.C00.Rsp - verification: | - On TH_CR1 send the below command - - ./chip-tool pairing open-commissioning-window 1 1 180 1000 3840 - - Verify Manual pairing code on TH1(chip-tool) Log - - 0x0000000000000001 at monotonic time: 16129075 msec - [1635874557.417449][4549:4554] CHIP:DMG: ICR moving to [CommandSen] - [1635874557.417505][4549:4554] CHIP:CTL: Manual pairing code: [35484132896] - [1635874557.417577][4549:4554] CHIP:CTL: SetupQRCode: [MT:00000CQM00AT-F5A510] - - On TH_CR2 send the below command - - ./chip-tool pairing code 2 35484132896 --commissioner-name beta - - Verify you got below message on TH_CR2(chip-tool) log - Device commissioning completed with success - disabled: true - - - label: - "Step 6: TH_CR1 opens a commissioning window on DUT_CE using a - commissioning timeout of PIXIT.CADMIN.CwDuration seconds using ECM" - PICS: CADMIN.S.C00.Rsp - verification: | - On TH_CR1 send the below command - - ./chip-tool pairing open-commissioning-window 1 1 180 1000 3840 - - Verify the Open commisioning window on the DUT_CE(all-cluster-app) Log: - - [1660904553.796857][3537:3537] CHIP:DMG: Received command for Endpoint=0 Cluster=0x0000_003C Command=0x0000_0000 - [1660904553.796951][3537:3537] CHIP:ZCL: Received command to open commissioning window - [1660904553.797255][3537:3537] CHIP:IN: SecureSession[0xaaab142ef7f0]: Allocated Type:1 LSID:34523 - - Verify the Manual pairing code on the TH_CR1(chip-tool) Log: - - [1635874557.417271][4549:4554] CHIP:IN: Sending encrypted msg 0xaaaac5947d10 with MessageCounter:0 to 0x0000000000000001 at monotonic time: 16129075 msec - [1635874557.417449][4549:4554] CHIP:DMG: ICR moving to [CommandSen] - [1635874557.417505][4549:4554] CHIP:CTL: Manual pairing code: [35484132896] - [1635874557.417577][4549:4554] CHIP:CTL: SetupQRCode: [MT:00000CQM00AT-F5A510] - disabled: true - - - label: - "Step 7: Before the expiration of PIXIT.CADMIN.CwDuration seconds - which was set in step 5, TH_CR1 opens a 2nd commissioning window on - DUT_CE using a commissioning timeout of PIXIT.CADMIN.CwDuration - seconds using ECM" - PICS: CADMIN.S.C00.Rsp - verification: | - On TH_CR1 send the below command - - Verify that the DUT_CE is rejecting the opening of second commissioning session with the response status 0x01 failure - - - ./chip-tool pairing open-commissioning-window 1 1 180 1000 3840 - - Verify cluster status 1 on TH_CR1(chip-tool) Log - - - [1650527291.952431][8566:8571] CHIP:DMG: - [1650527291.952458][8566:8571] CHIP:DMG: StatusIB = - [1650527291.952488][8566:8571] CHIP:DMG: { - [1650527291.952519][8566:8571] CHIP:DMG: status = 0x01 (FAILURE), - [1650527291.952555][8566:8571] CHIP:DMG: cluster-status = 0x2, - [1650527291.952578][8566:8571] CHIP:DMG: }, - [1650527291.952612][8566:8571] CHIP:DMG: - [1650527291.952634][8566:8571] CHIP:DMG: }, - disabled: true - - - label: "Step 8: TH_CR1 reads the list of Fabrics on DUT_CE" - PICS: OPCREDS.S.A0001 - verification: | - On TH_CR1 send the below command - - ./chip-tool operationalcredentials read fabrics 1 0 --fabric-filtered 0 - - Verify the list of Fabrics consists of FabricIndex 1, FabricIndex 2, FabricIndex 3 on TH_CR1(chip-tool) log - - CHIP:TOO: Endpoint: 0 Cluster: 0x0000_003E Attribute 0x0000_0001 DataVersion: 268962768 - [1650527361.425870][15792:15797] CHIP:TOO: Fabrics: 3 entries - [1650527361.426777][15792:15797] CHIP:TOO: [1]: { - [1650527361.426859][15792:15797] CHIP:TOO: RootPublicKey: 0429A71383F336D80918C9EC655112513E428C073AF7FB44820EC793535302C6E3825C56EE6DD1A683EAA7B59E3F261B46FFA24A6D911E8D88839F4C1B3C84BA01 - [1650527361.426923][15792:15797] CHIP:TOO: VendorId: 65521 - [1650527361.426979][15792:15797] CHIP:TOO: FabricId: 1 - [1650527361.427033][15792:15797] CHIP:TOO: NodeId: 1 - [1650527361.427088][15792:15797] CHIP:TOO: Label: - [1650527361.427166][15792:15797] CHIP:TOO: FabricIndex: 1 - [1650527361.427376][15792:15797] CHIP:TOO: } - [1650527361.427464][15792:15797] CHIP:TOO: [2]: { - [1650527361.427532][15792:15797] CHIP:TOO: RootPublicKey: 04781BCEE70118049ED61DD5B4E401CF1A09D2F78AE7F5770BE5506AD24238E5E0777277DABAFD062659651C95CC2CA7DEAACE40DB579A946CC07CADB141BE05D7 - [1650527361.427595][15792:15797] CHIP:TOO: VendorId: 65521 - [1650527361.427649][15792:15797] CHIP:TOO: FabricId: 1 - [1650527361.427703][15792:15797] CHIP:TOO: NodeId: 3 - [1650527361.427756][15792:15797] CHIP:TOO: Label: - [1650527361.427811][15792:15797] CHIP:TOO: FabricIndex: 2 - [1650527361.427868][15792:15797] CHIP:TOO: } - [1650527361.427943][15792:15797] CHIP:TOO: [3]: { - [1650527361.428008][15792:15797] CHIP:TOO: RootPublicKey: 0403EDB5B461030A34EF7EA2F9DB0D46A36185E4755C365AF9344C4959F049EF21D55EAB903A2C7FBFC305EEFA42989250D7517A73E6156062390A60C0D4C41EBD - [1650527361.428067][15792:15797] CHIP:TOO: VendorId: 65521 - [1650527361.428122][15792:15797] CHIP:TOO: FabricId: 1 - [1650527361.428176][15792:15797] CHIP:TOO: NodeId: 2 - [1650527361.428229][15792:15797] CHIP:TOO: Label: - [1650527361.428282][15792:15797] CHIP:TOO: FabricIndex: 3 - [1650527361.428335][15792:15797] CHIP:TOO: } - disabled: true - - - label: - "Step 9: Wait for the expiration of PIXIT.CADMIN.CwDuration seconds - that was set in step 6" - verification: | - Wait for the expiration of PIXIT.CADMIN.CwDuration seconds that was set in step 6 - disabled: true - - - label: - "Step 10: TH_CR1 re-opens a commissioning window on DUT_CE using a - commissioning timeout of PIXIT.CADMIN.CwDuration seconds using BCM" - PICS: CADMIN.S.C01.Rsp - verification: | - On TH_CR1 send the below command - - ./chip-tool administratorcommissioning open-basic-commissioning-window 500 1 0 --timedInteractionTimeoutMs 1000 - - Verify the Open commisioning window on the DUT_CE(all-cluster-app) Log: - - [1660904553.796857][3537:3537] CHIP:DMG: Received command for Endpoint=0 Cluster=0x0000_003C Command=0x0000_0000 - [1660904553.796951][3537:3537] CHIP:ZCL: Received command to open commissioning window - [1660904553.797255][3537:3537] CHIP:IN: SecureSession[0xaaab142ef7f0]: Allocated Type:1 LSID:34523 - - Verify the Manual pairing code on the TH_CR1(chip-tool) Log: - - [1650278416.249347][11064:11069] CHIP:DMG: }, - [1650278416.249430][11064:11069] CHIP:DMG: - [1650278416.249501][11064:11069] CHIP:DMG: StatusIB = - [1650278416.249581][11064:11069] CHIP:DMG: { - [1650278416.249664][11064:11069] CHIP:DMG: status = 0x00 (SUCCESS), - [1650278416.249738][11064:11069] CHIP:DMG: }, - [1650278416.249823][11064:11069] CHIP:DMG: - disabled: true - - - label: "Step 11: DNS-SD records shows DUT_CE advertising" - verification: | - On TH_CR1 send the below command - avahi-browse -rt _matterc._udp - + eth0 IPv6 2664ED6939FC373C _matterc._udp local - = eth0 IPv6 2664ED6939FC373C _matterc._udp local - hostname = [E45F010F27530000.local] - address = [fe80::e65f:1ff:fe0f:2753] - port = [5540] - txt = ["PI=" "PH=36" "CM=1" "D=3840" "T=1" "SAI=300" "SII=5000" "VP=65521+32769"] - ubuntu@ubuntu:~/may16_cntrl/connectedhomeip/examples/chip-tool/out/debug$ - disabled: true - - - label: - "Step 12: Before the expiration of PIXIT.CADMIN.CwDuration seconds - that was set in step 10, TH_CR3 opens a 2nd commissioning window on - DUT_CE using a commissioning timeout of PIXIT.CADMIN.CwDuration - seconds using BCM" - PICS: CADMIN.S.C01.Rsp - verification: | - On TH_CR3 send the below command - - ./chip-tool administratorcommissioning open-basic-commissioning-window 500 3 0 --timedInteractionTimeoutMs 1000 --commissioner-name gamma - - Verify that the DUT_CE is rejecting the opening of second commissioning session with the response status 0x01 failure - - - - [1650527565.991042][24618:24623] CHIP:DMG: { - [1650527565.991112][24618:24623] CHIP:DMG: EndpointId = 0x0, - [1650527565.991186][24618:24623] CHIP:DMG: ClusterId = 0x3c, - [1650527565.991257][24618:24623] CHIP:DMG: CommandId = 0x1, - [1650527565.991332][24618:24623] CHIP:DMG: }, - [1650527565.991441][24618:24623] CHIP:DMG: - [1650527565.991505][24618:24623] CHIP:DMG: StatusIB = - [1650527565.991574][24618:24623] CHIP:DMG: { - [1650527565.991645][24618:24623] CHIP:DMG: status = 0x01 (FAILURE), - [1650527565.991743][24618:24623] CHIP:DMG: cluster-status = 0x2, - [1650527565.991830][24618:24623] CHIP:DMG: }, - [1650527565.991918][24618:24623] CHIP:DMG: - [1650527565.991976][24618:24623] CHIP:DMG: }, - [1650527565.992061][24618:24623] CHIP:DMG: - [1650527565.992116][24618:24623] CHIP:DMG: }, - disabled: true - - - label: - "Step 13: Wait for the expiration of PIXIT.CADMIN.CwDuration seconds - that was set in step 11" - verification: | - Wait for the expiration of PIXIT.CADMIN.CwDuration seconds that was set in step 10 - disabled: true - - - label: "Step 14: TH_CR1 reads the list of Fabrics on DUT_CE" - PICS: OPCREDS.S.A0001 - verification: | - On TH_CR1 send the below command - - ./chip-tool operationalcredentials read fabrics 1 0 --fabric-filtered 0 - - Verify the list of Fabrics consists of FabricIndex 1, FabricIndex 2, FabricIndex 3 on TH_CR1(chip-tool) log - - CHIP:TOO: Endpoint: 0 Cluster: 0x0000_003E Attribute 0x0000_0001 DataVersion: 268962768 - [1678866402.096093][704851:704853] CHIP:TOO: Fabrics: 3 entries - [1678866402.096119][704851:704853] CHIP:TOO: [1]: { - [1678866402.096131][704851:704853] CHIP:TOO: RootPublicKey: 045F808373B5CED7FC2AFF99D98C2DEE6CA3889A9B078E87DAD9E263C9DEDB47AD7D31703024B72F4CB68A3017963128748FC7E97C6CBB419AF8AA914CE67D7457 - [1678866402.096141][704851:704853] CHIP:TOO: VendorID: 65521 - [1678866402.096147][704851:704853] CHIP:TOO: FabricID: 1 - [1678866402.096154][704851:704853] CHIP:TOO: NodeID: 1 - [1678866402.096160][704851:704853] CHIP:TOO: Label: - [1678866402.096167][704851:704853] CHIP:TOO: FabricIndex: 1 - [1678866402.096173][704851:704853] CHIP:TOO: } - [1678866402.096185][704851:704853] CHIP:TOO: [2]: { - [1678866402.096194][704851:704853] CHIP:TOO: RootPublicKey: 0458F2B4AD99F579EC01AA271EFDDF14526CE5222BADE218C703902544430F32FA9B951963C6C03713AC63E2D95785CFCD997946098957C4F5844BD2B3916B7148 - [1678866402.096201][704851:704853] CHIP:TOO: VendorID: 65521 - [1678866402.096207][704851:704853] CHIP:TOO: FabricID: 3 - [1678866402.096213][704851:704853] CHIP:TOO: NodeID: 3 - [1678866402.096219][704851:704853] CHIP:TOO: Label: - [1678866402.096224][704851:704853] CHIP:TOO: FabricIndex: 2 - [1678866402.096230][704851:704853] CHIP:TOO: } - [1678866402.096241][704851:704853] CHIP:TOO: [3]: { - [1678866402.096250][704851:704853] CHIP:TOO: RootPublicKey: 04CE10BA136D610089C4810BF963C354CE93BA61D267E8B9594977E3CC5FF30741941CE3D2A0A9E62A66AEF02CAA9F25A614F033D304D9F2ACF4204FAB68E8F773 - [1678866402.096257][704851:704853] CHIP:TOO: VendorID: 65521 - [1678866402.096263][704851:704853] CHIP:TOO: FabricID: 2 - [1678866402.096269][704851:704853] CHIP:TOO: NodeID: 2 - [1678866402.096274][704851:704853] CHIP:TOO: Label: - [1678866402.096280][704851:704853] CHIP:TOO: FabricIndex: 3 - [1678866402.096286][704851:704853] CHIP:TOO: } - disabled: true - - - label: - "Step 15: TH_CR1 opens a commissioning window on DUT_CE using a - commissioning timeout of PIXIT.CADMIN.CwDuration seconds using BCM" - PICS: CADMIN.S.C01.Rsp - verification: | - On TH_CR1 send the below command - - ./chip-tool administratorcommissioning open-basic-commissioning-window 500 1 0 --timedInteractionTimeoutMs 1000 - - Verify success response On TH_CR1(chip-tool) Log - - [1650278416.249268][11064:11069] CHIP:DMG: CommandId = 0x1, - [1650278416.249347][11064:11069] CHIP:DMG: }, - [1650278416.249430][11064:11069] CHIP:DMG: - [1650278416.249501][11064:11069] CHIP:DMG: StatusIB = - [1650278416.249581][11064:11069] CHIP:DMG: { - [1650278416.249664][11064:11069] CHIP:DMG: status = 0x00 (SUCCESS), - [1650278416.249738][11064:11069] CHIP:DMG: }, - [1650278416.249823][11064:11069] CHIP:DMG: - disabled: true - - - label: - "Step 16: Before the expiration of PIXIT.CADMIN.CwDuration seconds - that was set in step 14, TH_CR2 opens a second commissioning window on - DUT_CE using a commissioning timeout of PIXIT.CADMIN.CwDuration - seconds using BCM" - PICS: CADMIN.S.C01.Rsp - verification: | - On TH_CR2 send the below command - - ./chip-tool administratorcommissioning open-basic-commissioning-window 500 2 0 --timedInteractionTimeoutMs 1000 --commissioner-name beta - - - Verify that the DUT_CE is rejecting the opening of second commissioning session with the response status 0x01 failure - - - - [1650527622.374682][15824:15829] CHIP:DMG: }, - [1650527622.374799][15824:15829] CHIP:DMG: - [1650527622.374896][15824:15829] CHIP:DMG: StatusIB = - [1650527622.374979][15824:15829] CHIP:DMG: { - [1650527622.375086][15824:15829] CHIP:DMG: status = 0x01 (FAILURE), - [1650527622.375236][15824:15829] CHIP:DMG: cluster-status = 0x2, - [1650527622.375320][15824:15829] CHIP:DMG: }, - [1650527622.375426][15824:15829] CHIP:DMG: - [1650527622.375527][15824:15829] CHIP:DMG: }, - [1650527622.375616][15824:15829] CHIP:DMG: - disabled: true diff --git a/src/app/tests/suites/manualTests.json b/src/app/tests/suites/manualTests.json index 3b0b354840e1c6..01d98213b3e279 100644 --- a/src/app/tests/suites/manualTests.json +++ b/src/app/tests/suites/manualTests.json @@ -171,7 +171,6 @@ "Test_TC_CADMIN_1_2", "Test_TC_CADMIN_1_7", "Test_TC_CADMIN_1_8", - "Test_TC_CADMIN_1_11", "Test_TC_CADMIN_1_12", "Test_TC_CADMIN_1_14", "Test_TC_CADMIN_1_15", diff --git a/src/python_testing/TC_CADMIN_1_11.py b/src/python_testing/TC_CADMIN_1_11.py new file mode 100644 index 00000000000000..cefd8b44a785f4 --- /dev/null +++ b/src/python_testing/TC_CADMIN_1_11.py @@ -0,0 +1,222 @@ +# +# 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: +# app: ${ALL_CLUSTERS_APP} +# 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 +# --PICS src/app/tests/suites/certification/ci-pics-values +# factory-reset: true +# quiet: false +# === END CI TEST ARGUMENTS === + + +import logging +import random +from time import sleep +from typing import Optional + +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_infrastructure.chip.testing.matter_testing import (MatterBaseTest, TestStep, async_test_body, + default_matter_test_main) +from mobly import asserts + + +class TC_CADMIN_1_11(MatterBaseTest): + async def OpenCommissioningWindow(self, th, expectedErrCode) -> CommissioningParameters: + if expectedErrCode is None: + params = await th.OpenCommissioningWindow( + nodeid=self.dut_node_id, timeout=self.timeout, iteration=10000, discriminator=self.discriminator, option=1) + return params + + else: + ctx = asserts.assert_raises(ChipStackError) + with ctx: + await th.OpenCommissioningWindow( + nodeid=self.dut_node_id, timeout=self.timeout, iteration=10000, discriminator=self.discriminator, option=1) + 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 == expectedErrCode, + 'Unexpected error code returned from CommissioningComplete') + + async def OpenBasicCommissioningWindow(self, th: ChipDeviceCtrl, expectedErrCode: Optional[Clusters.AdministratorCommissioning.Enums.StatusCode] = None) -> CommissioningParameters: + if not expectedErrCode: + params = await th.OpenBasicCommissioningWindow( + nodeid=self.dut_node_id, timeout=self.timeout) + return params + + else: + ctx = asserts.assert_raises(ChipStackError) + with ctx: + await th.OpenBasicCommissioningWindow( + nodeid=self.dut_node_id, timeout=self.timeout) + errcode = ctx.exception.chip_error + 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 == expectedErrCode, + 'Unexpected error code returned from CommissioningComplete') + + async def read_currentfabricindex(self, th: ChipDeviceCtrl) -> int: + cluster = Clusters.OperationalCredentials + attribute = Clusters.OperationalCredentials.Attributes.CurrentFabricIndex + current_fabric_index = await self.read_single_attribute_check_success(dev_ctrl=th, endpoint=0, cluster=cluster, attribute=attribute) + return current_fabric_index + + def steps_TC_CADMIN_1_11(self) -> list[TestStep]: + return [ + TestStep(1, "Commissioning, already done", is_commissioning=True), + TestStep( + 2, "TH_CR1 gets the MaxCumulativeFailsafeSeconds value from BasicCommissioningInfo attribute in GeneralCommissioning Cluster", "Should set the MaxCumulativeFailsafeSeconds value from BasicCommissioningInfo attribute to timeout"), + TestStep( + 3, "TH_CR1 opens commissioning window on DUT with duration set to value for MaxCumulativeFailsafeSeconds", "Commissioning window should open with timeout set to MaxCumulativeFailsafeSeconds"), + TestStep(4, "TH_CR2 fully commissions the DUT", "DUT should fully commission"), + TestStep( + 5, "TH_CR1 opens commissioning window on DUT with duration set to value from BasicCommissioningInfo", "New commissioning window should open and be set to timeout"), + TestStep(6, "TH_CR1 sends an OpenCommissioningWindow command to the DUT and attempts to open another commissioning window", + "Commissioning window should fail to be opened due to being busy"), + TestStep(7, "TH_CR2 sends an OpenCommissioningWindow command to the DUT and attempts to open another commissioning window", + "Commissioning window should fail to be opened due to being busy"), + TestStep(8, "TH_CR1 sends an RevokeCommissioning command to the DUT", "Commissioning window should be closed"), + TestStep(9, "TH_CR1 reads the FeatureMap from the Administrator Commissioning Cluster to check to see if BC is supported on DUT", + "FeatureMap should be checked to see if BC enum is available feature, if not then test steps 9a-9d will be skipped"), + TestStep("9a", "TH_CR1 opens commissioning window on DUT with duration set to value from BasicCommissioningInfo", + "Opens basic commissioning window on the DUT for timeout set to value of MaxCumulativeFailsafeSeconds"), + TestStep("9b", "TH_CR1 sends an OpenBasicCommissioningWindow command to the DUT and attempts to open another commissioning window", + "Commissioning window should fail to be opened due to being busy"), + TestStep("9c", "TH_CR2 sends an OpenBasicCommissioningWindow command to the DUT and attempts to open another commissioning window", + "Commissioning window should fail to be opened due to being busy"), + TestStep("9d", "TH_CR1 sends a RevokeCommissioning command to the DUT", "Commissioning window should be closed"), + TestStep(10, "TH_CR2 reads the CurrentFabricIndex attribute from the Operational Credentials cluster and saves as th2_idx", + "th2_idx set to value for CurrentFabricIndex attribute from TH_CR2"), + TestStep(11, "TH_CR1 sends the RemoveFabric command to the DUT with the FabricIndex set to th2_idx", + "TH_CR1 removes TH_CR2 fabric using th2_idx"), + ] + + async def CommissionAttempt( + self, setupPinCode: int): + + logging.info("-----------------Commissioning with TH_CR2-------------------------") + await self.th2.CommissionOnNetwork( + nodeId=self.dut_node_id, setupPinCode=setupPinCode, + filterType=ChipDeviceCtrl.DiscoveryFilterType.LONG_DISCRIMINATOR, filter=self.discriminator) + + def pics_TC_CADMIN_1_11(self) -> list[str]: + return ["CADMIN.S"] + + @async_test_body + async def test_TC_CADMIN_1_11(self): + self.step(1) + + # Establishing TH1 and TH2 controllers + self.th1 = self.default_controller + self.discriminator = random.randint(0, 4095) + th2_certificate_authority = self.certificate_authority_manager.NewCertificateAuthority() + th2_fabric_admin = th2_certificate_authority.NewFabricAdmin(vendorId=0xFFF1, fabricId=self.th1.fabricId + 1) + self.th2 = th2_fabric_admin.NewController(nodeId=2) + + self.step(2) + GC_cluster = Clusters.GeneralCommissioning + attribute = GC_cluster.Attributes.BasicCommissioningInfo + duration = await self.read_single_attribute_check_success(endpoint=0, cluster=GC_cluster, attribute=attribute) + self.timeout = duration.maxCumulativeFailsafeSeconds + + self.step(3) + params = await self.OpenCommissioningWindow(self.th1, None) + setupPinCode = params.setupPinCode + busy_enum = Clusters.AdministratorCommissioning.Enums.StatusCode.kBusy + + self.step(4) + await self.CommissionAttempt(setupPinCode) + + self.step(5) + await self.OpenCommissioningWindow(self.th1, None) + + self.step(6) + await self.OpenCommissioningWindow(self.th1, busy_enum) + + self.step(7) + await self.OpenCommissioningWindow(self.th2, busy_enum) + + self.step(8) + 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(9) + + AC_cluster = Clusters.AdministratorCommissioning + fm_attribute = Clusters.AdministratorCommissioning.Attributes + features = await self.read_single_attribute_check_success(cluster=AC_cluster, attribute=fm_attribute.FeatureMap) + + self.supports_bc = bool(features & AC_cluster.Bitmaps.Feature.kBasic) != 0 + + if self.supports_bc: + self.count = 0 + self.step("9a") + obcCmd = Clusters.AdministratorCommissioning.Commands.OpenBasicCommissioningWindow(180) + await self.th1.SendCommand(nodeid=self.dut_node_id, endpoint=0, payload=obcCmd, timedRequestTimeoutMs=6000) + + self.step("9b") + try: + await self.th1.SendCommand(nodeid=self.dut_node_id, endpoint=0, payload=obcCmd, timedRequestTimeoutMs=6000) + except Exception as e: + asserts.assert_true(e.clusterStatus == busy_enum, + 'Unexpected error code returned from CommissioningComplete') + + self.step("9c") + try: + await self.th2.SendCommand(nodeid=self.dut_node_id, endpoint=0, payload=obcCmd, timedRequestTimeoutMs=6000) + except Exception as e: + asserts.assert_true(e.clusterStatus == busy_enum, + 'Unexpected error code returned from CommissioningComplete') + + self.step("9d") + 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) + + else: + self.skip_step("9a") + self.skip_step("9b") + self.skip_step("9c") + self.skip_step("9d") + + # Read CurrentFabricIndex attribute from the Operational Credentials cluster + self.step(10) + th2_idx = await self.read_currentfabricindex(self.th2) + + self.step(11) + removeFabricCmd = Clusters.OperationalCredentials.Commands.RemoveFabric(th2_idx) + await self.th1.SendCommand(nodeid=self.dut_node_id, endpoint=0, payload=removeFabricCmd) + + +if __name__ == "__main__": + default_matter_test_main()