diff --git a/src/app/tests/suites/certification/Test_TC_CADMIN_1_3.yaml b/src/app/tests/suites/certification/Test_TC_CADMIN_1_3.yaml deleted file mode 100644 index fbe4e2b7615d36..00000000000000 --- a/src/app/tests/suites/certification/Test_TC_CADMIN_1_3.yaml +++ /dev/null @@ -1,549 +0,0 @@ -# Copyright (c) 2023 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.3. [TC-CADMIN-1.3] Node Behavior using ECM [DUT - Commissionee] - -PICS: - - CADMIN.S - -config: - nodeId: 0x12344321 - timeout: 300 - nodeId2: - type: node_id - defaultValue: 0xCAFE - endpoint: 0 - discriminator: - type: int16u - defaultValue: 3840 - payload: - type: char_string - defaultValue: "MT:-24J0AFN00KA0648G00" # This value needs to be generated automatically - PakeVerifier: - type: octet_string - defaultValue: "hex:b96170aae803346884724fe9a3b287c30330c2a660375d17bb205a8cf1aecb350457f8ab79ee253ab6a8e46bb09e543ae422736de501e3db37d441fe344920d09548e4c18240630c4ff4913c53513839b7c07fcc0627a1b8573a149fcd1fa466cf" - waitAfterCommissioning: - type: int16u - defaultValue: 5000 - PIXIT.CADMIN.CwDuration: - type: int16u - defaultValue: 180 - -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 1a: 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 1b: TH_CR1 commissioned with DUT_CE" - cluster: "DelayCommands" - command: "WaitForCommissionee" - PICS: CADMIN.S - arguments: - values: - - name: "nodeId" - value: nodeId - - - label: - "Step 1c: TH1 reads CurrentFabricIndex attribute and save it for - future use." - command: "readAttribute" - cluster: "Operational Credentials" - attribute: "CurrentFabricIndex" - response: - saveAs: TH1FabricIndex - - - label: - "Step 2a: TH_CR1 opens a commissioning window on DUT_CE using a - commissioning timeout of PIXIT.CADMIN.CwDuration seconds using ECM" - cluster: "Administrator Commissioning" - command: "OpenCommissioningWindow" - PICS: CADMIN.S.C00.Rsp && PICS_SDK_CI_ONLY - timedInteractionTimeoutMs: 10000 - arguments: - values: - - name: "CommissioningTimeout" - value: PIXIT.CADMIN.CwDuration - - name: "PAKEPasscodeVerifier" - value: PakeVerifier - - name: "Discriminator" - value: discriminator - - name: "Iterations" - value: 1000 - - name: "Salt" - value: "SPAKE2P Key Salt" - - - label: "Waiting after opening commissioning window" - PICS: CADMIN.S.C00.Rsp && PICS_SDK_CI_ONLY - cluster: "DelayCommands" - command: "WaitForMs" - arguments: - values: - - name: "ms" - value: waitAfterCommissioning - - #Issue https://github.com/project-chip/connectedhomeip/issues/26127 - - label: - "Step 2a: TH_CR1 opens a commissioning window on DUT_CE using a - commissioning timeout of PIXIT.CADMIN.CwDuration seconds using ECM" - verification: | - On TH_CR1 send the below command - - ./chip-tool pairing open-commissioning-window 1 1 PIXIT.CADMIN.CwDuration 2000 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 0x10 - 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 2b: DNS-SD records shows DUT_CE advertising.Verify that the - DNS-SD advertisement shows CM=2" - PICS: CADMIN.S.C00.Rsp - cluster: "DiscoveryCommands" - command: "FindCommissionable" - response: - values: - - name: "commissioningMode" - value: 2 - - - label: - "Step 2c: TH_CR1 writes the Basic Information Clusters NodeLabel - mandatory attribute of DUT_CE" - command: "writeAttribute" - PICS: BINFO.S.A0005 - cluster: "Basic Information" - attribute: "NodeLabel" - arguments: - value: "chiptest" - - - label: - "Step 2c: TH_CR1 reads the Basic Information Clusters NodeLabel - mandatory attribute of DUT_CE" - command: "readAttribute" - PICS: BINFO.S.A0005 - cluster: "Basic Information" - attribute: "NodeLabel" - response: - value: "chiptest" - constraints: - type: char_string - maxLength: 32 - - - label: "Step 3a: TH_CR2 starts a commissioning process with DUT_CE" - identity: "beta" - PICS: CADMIN.S && PICS_SDK_CI_ONLY - cluster: "CommissionerCommands" - command: "PairWithCode" - arguments: - values: - - name: "nodeId" - value: nodeId2 - - name: "payload" - value: payload - - - label: "Step 3b: DUT_CE is commissioned by TH_CR2 on Fabric ID2" - PICS: CADMIN.S && PICS_SDK_CI_ONLY - identity: "beta" - cluster: "DelayCommands" - command: "WaitForCommissionee" - arguments: - values: - - name: "nodeId" - value: nodeId2 - - #Issue https://github.com/project-chip/connectedhomeip/issues/26127 - - label: "Step 3: TH_CR2 starts a commissioning process with DUT_CE" - verification: | - On TH_CR2 send the below command - Below is the example when using chip tool as controller (considering 36177160937 as the manual code generated by 1st controller) - - ./chip-tool pairing code 0xCAFE 36177160937 --commissioner-name beta - - Verify the below message in the TH_CR2(chip-tool) Log: - - Device commissioning completed with successoning step 'Cleanup' - [1657186359.584743][3509:3514] CHIP:TOO: Device commissioning completed with success - 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 3c: TH2 reads CurrentFabricIndex attribute and save it for - future use." - identity: "beta" - command: "readAttribute" - cluster: "Operational Credentials" - attribute: "CurrentFabricIndex" - response: - saveAs: TH2FabricIndex - - - label: - "Step 4: Verify DUT_CE is now discoverable over DNS-SD with two SRV - Records" - verification: | - On TH_CR2 send the below command - - Verify if the DUT_CE is broadcasting using - - avahi-browse -rt _matter._tcp - - On TH_CR2(chip-tool) Verify DUT_CE is now discoverable over DNS-SD with two SRV Records - - + eth0 IPv6 9B9C01C971F4119F-0000000000000001 _matter._tcp local - + eth0 IPv6 C8A60CCA27F33379-0000000000000002 _matter._tcp local - = eth0 IPv6 9B9C01C971F4119F-0000000000000001 _matter._tcp local - hostname = [E45F010F27530000.local] - address = [fe80::e65f:1ff:fe0f:2753] - port = [5540] - txt = ["T=1" "SAI=300" "SII=5000"] - = eth0 IPv6 C8A60CCA27F33379-0000000000000002 _matter._tcp local - hostname = [E45F010F27530000.local] - address = [fe80::e65f:1ff:fe0f:2753] - port = [5540] - txt = ["T=1" "SAI=300" "SII=5000"] - ubuntu@ubuntu:~/may16_cntrl/connectedhomeip/examples/chip-tool/out/debug$ - cluster: "LogCommands" - command: "UserPrompt" - PICS: PICS_SKIP_SAMPLE_APP - arguments: - values: - - name: "message" - value: "enter 'y' after success" - - name: "expectedValue" - value: "y" - - - label: "Step 5: TH_CR1 reads the list of Fabrics on DUT_CE" - command: "readAttribute" - cluster: "Operational Credentials" - attribute: "Fabrics" - PICS: OPCREDS.S.A0001 - fabricFiltered: false - response: - constraints: - type: list - contains: - [ - { - Label: "", - FabricIndex: TH1FabricIndex, - NodeID: nodeId, - }, - { - Label: "", - FabricIndex: TH2FabricIndex, - NodeID: nodeId2, - }, - ] - - - label: "Step 6: TH_CR2 reads the list of Fabrics on DUT_CE" - identity: "beta" - command: "readAttribute" - cluster: "Operational Credentials" - attribute: "Fabrics" - PICS: OPCREDS.S.A0001 - fabricFiltered: false - response: - constraints: - type: list - contains: - [ - { - Label: "", - FabricIndex: TH1FabricIndex, - NodeID: nodeId, - }, - { - Label: "", - FabricIndex: TH2FabricIndex, - NodeID: nodeId2, - }, - ] - - - label: - "Step 7a: TH_CR1 writes the Basic Information Clusters NodeLabel - mandatory attribute of DUT_CE" - command: "writeAttribute" - cluster: "Basic Information" - PICS: BINFO.S.A0005 - attribute: "NodeLabel" - arguments: - value: "chiptest1" - - - label: - "Step 7b: TH_CR1 reads the Basic Information Clusters NodeLabel - mandatory attribute of DUT_CE" - command: "readAttribute" - cluster: "Basic Information" - PICS: BINFO.S.A0005 - attribute: "NodeLabel" - response: - value: "chiptest1" - constraints: - type: char_string - maxLength: 32 - - - label: - "Step 8a: TH_CR2 writes the Basic Information Clusters NodeLabel - mandatory attribute of DUT_CE" - identity: "beta" - command: "writeAttribute" - cluster: "Basic Information" - PICS: BINFO.S.A0005 - attribute: "NodeLabel" - arguments: - value: "chiptest2" - - - label: - "Step 8b: TH_CR2 reads the Basic Information Clusters NodeLabel - mandatory attribute of DUT_CE" - identity: "beta" - command: "readAttribute" - cluster: "Basic Information" - PICS: BINFO.S.A0005 - attribute: "NodeLabel" - response: - value: "chiptest2" - constraints: - type: char_string - maxLength: 32 - - - label: "Step 9: TH_CR2 opens a commissioning window on DUT_CE using ECM" - cluster: "Administrator Commissioning" - command: "OpenCommissioningWindow" - PICS: CADMIN.S.C00.Rsp && PICS_SDK_CI_ONLY - identity: "beta" - timedInteractionTimeoutMs: 10000 - arguments: - values: - - name: "CommissioningTimeout" - value: PIXIT.CADMIN.CwDuration - - name: "PAKEPasscodeVerifier" - value: PakeVerifier - - name: "Discriminator" - value: discriminator - - name: "Iterations" - value: 1000 - - name: "Salt" - value: "SPAKE2P Key Salt" - - #Issue https://github.com/project-chip/connectedhomeip/issues/26127 - - label: "Step 9: TH_CR2 opens a commissioning window on DUT_CE using ECM" - verification: | - On TH_CR2 send the below command - - ./chip-tool pairing open-commissioning-window nodeId2 endpoint PIXIT.CADMIN.CwDuration 1000 3840 --commissioner-name beta - - 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] - 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 10: Wait for the commissioning window in step 9 to timeout" - PICS: CADMIN.S.C00.Rsp - cluster: "DelayCommands" - command: "WaitForMs" - arguments: - values: - - name: "ms" - value: PIXIT.CADMIN.CwDuration * 1000 - - - label: - "Step 11: TH_CR2 reads the window status to verify the DUT_CE window - is closed" - cluster: "Administrator Commissioning" - PICS: CADMIN.S.A0000 - command: "readAttribute" - attribute: "WindowStatus" - response: - value: 0 - - - label: "Step 12: TH_CR2 opens a commissioning window on DUT_CE using ECM" - cluster: "Administrator Commissioning" - command: "OpenCommissioningWindow" - PICS: CADMIN.S.C00.Rsp && PICS_SDK_CI_ONLY - identity: "beta" - timedInteractionTimeoutMs: 10000 - arguments: - values: - - name: "CommissioningTimeout" - value: PIXIT.CADMIN.CwDuration - - name: "PAKEPasscodeVerifier" - value: PakeVerifier - - name: "Discriminator" - value: discriminator - - name: "Iterations" - value: 1000 - - name: "Salt" - value: "SPAKE2P Key Salt" - - - label: "Waiting after opening commissioning window" - PICS: CADMIN.S.C00.Rsp && PICS_SDK_CI_ONLY - cluster: "DelayCommands" - command: "WaitForMs" - arguments: - values: - - name: "ms" - value: waitAfterCommissioning - - #Issue https://github.com/project-chip/connectedhomeip/issues/26127 - - label: "Step 12: TH_CR2 opens a commissioning window on DUT_CE using ECM" - verification: | - On TH_CR2 send the below command - - ./chip-tool pairing open-commissioning-window 2 1 PIXIT.CADMIN.CwDuration 1000 3840 --commissioner-name beta - - 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 - 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 13: TH_CR1 starts a commissioning process with DUT_CE before the - timeout from step 12" - cluster: "CommissionerCommands" - command: "PairWithCode" - PICS: CADMIN.S && PICS_SDK_CI_ONLY - arguments: - values: - - name: "nodeId" - value: nodeId - - name: "payload" - value: payload - response: - error: FAILURE - - #Issue https://github.com/project-chip/connectedhomeip/issues/26127 - - label: - "Step 13: TH_CR1 starts a commissioning process with DUT_CE before the - timeout from step 12" - verification: | - Below is the example when using chip tool as controller (considering 36177160937 as the manual code generated by 1st controller) - - ./chip-tool pairing code 0xCAFE 36177160937 - - Verify the OperationalCert error 9 in DUT_CE(all-clusters-app) Log - - [1660902716.613196][3045:3045] CHIP:DMG: Command handler moving to [AddedComma] - [1660902716.613274][3045:3045] CHIP:ZCL: OpCreds: Failed AddNOC request (err=../../examples/all-clusters-app/linux/third_party/connectedhomeip/src/credentials/FabricTable.cpp:1692: CHIP Error 0x0000007E: Trying to add a NOC for a fabric that already exists) with OperationalCert error 9 - [1660902716.613394][3045:3045] CHIP:DMG: Decreasing reference count for CommandHandler, remaining 0 - [1660902716.613497][3045:3045] CHIP:EM: Piggybacking Ack for MessageCounter:176866087 on exchange: 56605r - - Trying to add a NOC for a fabric that already exists On TH_CR1(chip-tool) Log - - [1651786200275] [36301:315544] CHIP: [DMG] Received Command Response Data, Endpoint=0 Cluster=0x0000_003E Command=0x0000_0008 - [1651786200275] [36301:315544] CHIP: [CTL] Device returned status 9 on receiving the NOC - [1651786200275] [36301:315544] CHIP: [CTL] Add NOC failed with error ../../src/controller/CHIPDeviceController.cpp:1187: CHIP Error 0x0000007E: Trying to add a NOC for a fabric that already exists - [1651786200275] [36301:315544] CHIP: [CTL] Error on commissioning step 'SendNOC': '../../src/controller/CHIPDeviceController.cpp:1187: CHIP Error 0x0000007E: Trying to add a NOC for a fabric that already exists' - 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: "Remove TH2 FabricIndex" - PICS: OPCREDS.S.C0a.Rsp && CADMIN.S - identity: "beta" - cluster: "Operational Credentials" - command: "RemoveFabric" - timedInteractionTimeoutMs: 10000 - arguments: - values: - - name: "FabricIndex" - value: TH2FabricIndex diff --git a/src/app/tests/suites/certification/Test_TC_CADMIN_1_4.yaml b/src/app/tests/suites/certification/Test_TC_CADMIN_1_4.yaml deleted file mode 100644 index 7c4eb7420173b3..00000000000000 --- a/src/app/tests/suites/certification/Test_TC_CADMIN_1_4.yaml +++ /dev/null @@ -1,369 +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.4. [TC-CADMIN-1.4] Node Behavior using BCM [DUT - Commissionee] - -PICS: - - CADMIN.S - - CADMIN.S.F00 - -config: - nodeId: 0x12344321 - timeout: 300 - nodeId2: - type: node_id - defaultValue: 0xCAFE - endpoint: 0 - payload: - type: char_string - defaultValue: "MT:-24J0AFN00KA0648G00" - waitAfterCommissioning: - type: int16u - defaultValue: 5000 - PIXIT.CADMIN.CwDuration: - type: int16u - defaultValue: 180 - -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 1a: 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 1a: TH_CR1 commissioned with DUT_CE" - cluster: "DelayCommands" - command: "WaitForCommissionee" - PICS: CADMIN.S - arguments: - values: - - name: "nodeId" - value: nodeId - - - label: - "Step 1b: TH1 reads CurrentFabricIndex attribute and save it for - future use." - command: "readAttribute" - cluster: "Operational Credentials" - attribute: "CurrentFabricIndex" - response: - saveAs: TH1FabricIndex - - - label: "Step 2a: TH_CR1 opens a commissioning window on DUT_CE using BCM" - cluster: "Administrator Commissioning" - command: "OpenBasicCommissioningWindow" - PICS: CADMIN.S.C01.Rsp - timedInteractionTimeoutMs: 10000 - arguments: - values: - - name: "CommissioningTimeout" - value: PIXIT.CADMIN.CwDuration - - - label: "Step 2a: Waiting after opening commissioning window" - PICS: CADMIN.S.C01.Rsp - cluster: "DelayCommands" - command: "WaitForMs" - arguments: - values: - - name: "ms" - value: waitAfterCommissioning - - - label: "Step 2b: Verify that the DNS-SD advertisement shows CM=1" - PICS: CADMIN.S.C01.Rsp - cluster: "DiscoveryCommands" - command: "FindCommissionable" - response: - values: - - name: "commissioningMode" - value: 1 - - - label: - "Step 2c: TH_CR1 writes the Basic Information Clusters NodeLabel - mandatory attribute of DUT_CE" - command: "writeAttribute" - cluster: "Basic Information" - attribute: "NodeLabel" - PICS: BINFO.S.A0005 - arguments: - value: "chiptest" - - - label: - "Step 2d: TH_CR1 reads the Basic Information Clusters NodeLabel - mandatory attribute of DUT_CE" - command: "readAttribute" - cluster: "Basic Information" - attribute: "NodeLabel" - PICS: BINFO.S.A0005 - response: - constraints: - type: char_string - maxLength: 32 - - - label: "Step 3a: TH_CR2 starts a commissioning process with DUT_CE" - identity: "beta" - cluster: "CommissionerCommands" - command: "PairWithCode" - PICS: CADMIN.S - arguments: - values: - - name: "nodeId" - value: nodeId2 - - name: "payload" - value: payload - - - label: "Step 3b: DUT_CE is commissioned by TH_CR2 on Fabric ID2 " - identity: "beta" - cluster: "DelayCommands" - command: "WaitForCommissionee" - PICS: CADMIN.S - arguments: - values: - - name: "nodeId" - value: nodeId2 - - - label: - "Step 3c: TH2 reads CurrentFabricIndex attribute and save it for - future use." - identity: "beta" - command: "readAttribute" - cluster: "Operational Credentials" - attribute: "CurrentFabricIndex" - response: - saveAs: TH2FabricIndex - - #Check for DNS-SD advertisement is not possible in YAML - - label: - "Step 4: Verify DUT_CE is now discoverable over DNS-SD with two SRV - Records" - verification: | - On TH_CR2 send the below command - - Verify if the DUT_CE is broadcasting using - - avahi-browse -rt _matter._tcp - + eth0 IPv6 C8A60CCA27F33379-0000000000000002 _matter._tcp local - + eth0 IPv6 3C26C93CF201458F-0000000000000001 _matter._tcp local - = eth0 IPv6 C8A60CCA27F33379-0000000000000002 _matter._tcp local - hostname = [E45F010F27530000.local] - address = [fe80::e65f:1ff:fe0f:2753] - port = [5540] - txt = ["T=1" "SAI=300" "SII=5000"] - = eth0 IPv6 3C26C93CF201458F-0000000000000001 _matter._tcp local - hostname = [E45F010F27530000.local] - address = [fe80::e65f:1ff:fe0f:2753] - port = [5540] - txt = ["T=1" "SAI=300" "SII=5000"] - cluster: "LogCommands" - command: "UserPrompt" - PICS: PICS_SKIP_SAMPLE_APP - arguments: - values: - - name: "message" - value: "enter 'y' after success" - - name: "expectedValue" - value: "y" - - - label: "Step 5: TH_CR1 reads the list of Fabrics on DUT_CE" - command: "readAttribute" - cluster: "Operational Credentials" - PICS: OPCREDS.S.A0001 - attribute: "Fabrics" - fabricFiltered: false - response: - constraints: - type: list - contains: - [ - { - Label: "", - FabricIndex: TH1FabricIndex, - NodeID: nodeId, - }, - { - Label: "", - FabricIndex: TH2FabricIndex, - NodeID: nodeId2, - }, - ] - - - label: "Step 6: TH_CR2 reads the list of Fabrics on DUT_CE" - identity: "beta" - command: "readAttribute" - cluster: "Operational Credentials" - attribute: "Fabrics" - PICS: OPCREDS.S.A0001 - fabricFiltered: false - response: - constraints: - type: list - contains: - [ - { - Label: "", - FabricIndex: TH1FabricIndex, - NodeID: nodeId, - }, - { - Label: "", - FabricIndex: TH2FabricIndex, - NodeID: nodeId2, - }, - ] - - - label: - "Step 7a: TH_CR1 writes the Basic Information Clusters NodeLabel - mandatory attribute of DUT_CE" - command: "writeAttribute" - cluster: "Basic Information" - attribute: "NodeLabel" - PICS: BINFO.S.A0005 - arguments: - value: "chiptest" - - - label: - "Step 7b: TH_CR1 reads the Basic Information Clusters NodeLabel - mandatory attribute of DUT_CE" - command: "readAttribute" - cluster: "Basic Information" - attribute: "NodeLabel" - PICS: BINFO.S.A0005 - response: - value: "chiptest" - constraints: - type: char_string - maxLength: 32 - - - label: - "Step 8a: TH_CR2 writes the Basic Information Clusters NodeLabel - mandatory attribute of DUT_CE" - identity: "beta" - command: "writeAttribute" - cluster: "Basic Information" - attribute: "NodeLabel" - PICS: BINFO.S.A0005 - arguments: - value: "chiptest" - - - label: - "Step 8b: TH_CR2 reads the Basic Information Clusters NodeLabel - mandatory attribute of DUT_CE" - identity: "beta" - command: "readAttribute" - cluster: "Basic Information" - attribute: "NodeLabel" - PICS: BINFO.S.A0005 - response: - value: "chiptest" - constraints: - type: char_string - maxLength: 32 - - - label: "Step 9: TH_CR2 opens a commissioning window on DUT_CE using BCM" - cluster: "Administrator Commissioning" - command: "OpenBasicCommissioningWindow" - identity: "beta" - PICS: CADMIN.S.C01.Rsp - timedInteractionTimeoutMs: 10000 - arguments: - values: - - name: "CommissioningTimeout" - value: PIXIT.CADMIN.CwDuration - - - label: "Step 10: Wait for the commissioning window in step 13 to timeout" - PICS: CADMIN.S.C01.Rsp - cluster: "DelayCommands" - command: "WaitForMs" - arguments: - values: - - name: "ms" - value: PIXIT.CADMIN.CwDuration * 1000 - - - label: - "Step 11: TH_CR2 reads the window status to verify the DUT_CE window - is closed" - cluster: "Administrator Commissioning" - PICS: CADMIN.S.A0000 - command: "readAttribute" - attribute: "WindowStatus" - response: - value: 0 - - - label: "Step 12a: TH_CR2 opens a commissioning window on DUT_CE using BCM" - cluster: "Administrator Commissioning" - command: "OpenBasicCommissioningWindow" - identity: "beta" - PICS: CADMIN.S.C01.Rsp - timedInteractionTimeoutMs: 10000 - arguments: - values: - - name: "CommissioningTimeout" - value: PIXIT.CADMIN.CwDuration - - - label: "Step 12b: Waiting after opening commissioning window" - PICS: CADMIN.S.C01.Rsp - cluster: "DelayCommands" - command: "WaitForMs" - arguments: - values: - - name: "ms" - value: waitAfterCommissioning - - - label: - "Step 13a: TH_CR1 starts a commissioning process with DUT_CE before - the timeout from step 12" - cluster: "CommissionerCommands" - command: "PairWithCode" - PICS: CADMIN.S - arguments: - values: - - name: "nodeId" - value: nodeId - - name: "payload" - value: payload - response: - error: FAILURE - - - label: "Remove TH2 FabricIndex" - PICS: OPCREDS.S.C0a.Rsp && CADMIN.S - identity: "beta" - cluster: "Operational Credentials" - command: "RemoveFabric" - timedInteractionTimeoutMs: 10000 - arguments: - values: - - name: "FabricIndex" - value: TH2FabricIndex diff --git a/src/app/tests/suites/manualTests.json b/src/app/tests/suites/manualTests.json index 4b7961b29deb01..c7b3ca869c84c7 100644 --- a/src/app/tests/suites/manualTests.json +++ b/src/app/tests/suites/manualTests.json @@ -174,10 +174,6 @@ "Test_TC_CADMIN_1_16", "Test_TC_CADMIN_1_17", "Test_TC_CADMIN_1_18", - "Test_TC_CADMIN_1_19", - "Test_TC_CADMIN_1_20", - "Test_TC_CADMIN_1_3", - "Test_TC_CADMIN_1_4", "Test_TC_CADMIN_1_5", "Test_TC_CADMIN_1_6", "Test_TC_CADMIN_1_10", diff --git a/src/controller/python/OpCredsBinding.cpp b/src/controller/python/OpCredsBinding.cpp index 37b1e9a9d1a267..697edd34d98227 100644 --- a/src/controller/python/OpCredsBinding.cpp +++ b/src/controller/python/OpCredsBinding.cpp @@ -44,6 +44,7 @@ #include #include #include +#include // Added for size_t using namespace chip; @@ -112,6 +113,7 @@ class TestCommissioner : public chip::Controller::AutoCommissioner public: TestCommissioner() { Reset(); } ~TestCommissioner() {} + CHIP_ERROR SetCommissioningParameters(const chip::Controller::CommissioningParameters & params) override { mIsWifi = false; @@ -149,6 +151,31 @@ class TestCommissioner : public chip::Controller::AutoCommissioner return CHIP_NO_ERROR; } + if (report.stageCompleted == chip::Controller::CommissioningStage::kGenerateNOCChain) + { + if (report.Is()) + { + + auto nocChain = report.Get().rcac; + + // Convert RCAC to CHIP cert format to be deciphered by TLV later in python3 + std::vector chipRcac(Credentials::kMaxCHIPCertLength); + MutableByteSpan chipRcacSpan(chipRcac.data(), chipRcac.size()); + chip::Credentials::ConvertX509CertToChipCert(nocChain, chipRcacSpan); + + mCHIPRCACData.assign(chipRcacSpan.data(), chipRcacSpan.data() + chipRcacSpan.size()); + + if (!mCHIPRCACData.empty()) + { + ChipLogProgress(Controller, "RCAC data converted and stored."); + } + else + { + ChipLogError(Controller, "RCAC data is empty. No data to log."); + } + } + } + if (mPrematureCompleteAfter != chip::Controller::CommissioningStage::kError && report.stageCompleted == chip::Controller::CommissioningStage::kSendComplete) { @@ -262,7 +289,9 @@ class TestCommissioner : public chip::Controller::AutoCommissioner mCompletionError = CHIP_NO_ERROR; } bool GetTestCommissionerUsed() { return mTestCommissionerUsed; } + void OnCommissioningSuccess(chip::PeerId peerId) { mReceivedCommissioningSuccess = true; } + void OnCommissioningFailure(chip::PeerId peerId, CHIP_ERROR error, chip::Controller::CommissioningStage stageFailed, chip::Optional additionalErrorInfo) { @@ -294,7 +323,10 @@ class TestCommissioner : public chip::Controller::AutoCommissioner CHIP_ERROR GetCompletionError() { return mCompletionError; } + const std::vector & GetCHIPRCACData() const { return mCHIPRCACData; } + private: + std::vector mCHIPRCACData; static constexpr uint8_t kNumCommissioningStages = chip::to_underlying(chip::Controller::CommissioningStage::kCleanup) + 1; chip::Controller::CommissioningStage mSimulateFailureOnStage = chip::Controller::CommissioningStage::kError; chip::Controller::CommissioningStage mFailOnReportAfterStage = chip::Controller::CommissioningStage::kError; @@ -391,6 +423,7 @@ void pychip_OnCommissioningSuccess(PeerId peerId) { sTestCommissioner.OnCommissioningSuccess(peerId); } + void pychip_OnCommissioningFailure(chip::PeerId peerId, CHIP_ERROR error, chip::Controller::CommissioningStage stageFailed, chip::Optional additionalErrorInfo) { @@ -687,4 +720,25 @@ PyChipError pychip_GetCompletionError() return ToPyChipError(sTestCommissioner.GetCompletionError()); } +extern "C" { +// Function to get the RCAC data from the sTestCommissioner +void pychip_GetCommissioningRCACData(uint8_t * rcacDataPtr, size_t * rcacSize) +{ + // Attempting to get Python RCAC data in C++ + const auto & rcacData = sTestCommissioner.GetCHIPRCACData(); + + if (rcacData.empty()) + { + ChipLogError(Controller, "RCAC data is empty in C++. Nothing to return."); + *rcacSize = 0; + return; + } + + // Ensure the size is passed back to Python + *rcacSize = rcacData.size(); + + // Copy the data from C++ to Python's allocated memory + std::memcpy(rcacDataPtr, rcacData.data(), *rcacSize); +} +} } // extern "C" diff --git a/src/controller/python/chip/ChipDeviceCtrl.py b/src/controller/python/chip/ChipDeviceCtrl.py index 1e8f74fbd28c7d..83986bba9dd26d 100644 --- a/src/controller/python/chip/ChipDeviceCtrl.py +++ b/src/controller/python/chip/ChipDeviceCtrl.py @@ -62,6 +62,8 @@ # Defined in $CHIP_ROOT/src/lib/core/CHIPError.h CHIP_ERROR_TIMEOUT: int = 50 +_RCACCallbackType = CFUNCTYPE(None, POINTER(c_uint8), c_size_t) + LOGGER = logging.getLogger(__name__) _DevicePairingDelegate_OnPairingCompleteFunct = CFUNCTYPE(None, PyChipError) @@ -479,6 +481,7 @@ def HandleCommissioningComplete(nodeId: int, err: PyChipError): if err.is_success: self._commissioning_context.future.set_result(nodeId) + else: self._commissioning_context.future.set_exception(err.to_exception()) @@ -550,6 +553,7 @@ def HandlePASEEstablishmentComplete(err: PyChipError): self.cbHandleCommissioningCompleteFunct = _DevicePairingDelegate_OnCommissioningCompleteFunct( HandleCommissioningComplete) + self._dmLib.pychip_ScriptDevicePairingDelegate_SetCommissioningCompleteCallback( self.pairingDelegate, self.cbHandleCommissioningCompleteFunct) @@ -1959,6 +1963,9 @@ def _InitLib(self): self._dmLib.pychip_GetCompletionError.argtypes = [] self._dmLib.pychip_GetCompletionError.restype = PyChipError + self._dmLib.pychip_GetCommissioningRCACData.argtypes = [ctypes.POINTER(ctypes.c_uint8), ctypes.POINTER(ctypes.c_size_t)] + self._dmLib.pychip_GetCommissioningRCACData.restype = None + self._dmLib.pychip_DeviceController_IssueNOCChain.argtypes = [ c_void_p, py_object, c_char_p, c_size_t, c_uint64] self._dmLib.pychip_DeviceController_IssueNOCChain.restype = PyChipError @@ -2230,6 +2237,30 @@ async def CommissionOnNetwork(self, nodeId: int, setupPinCode: int, return await asyncio.futures.wrap_future(ctx.future) + def get_rcac(self): + # Passes captured RCAC data back to python test modules to be used for validation + try: + rcac_size = 650 + rcac_buffer = (ctypes.c_uint8 * rcac_size)() + + actual_rcac_size = ctypes.c_size_t() + + self._dmLib.pychip_GetCommissioningRCACData(ctypes.cast( + rcac_buffer, ctypes.POINTER(ctypes.c_uint8)), ctypes.byref(actual_rcac_size)) + + # Check if data is available + if actual_rcac_size.value > 0: + # Convert the data to a Python bytes object + rcac_data = bytearray(rcac_buffer[:actual_rcac_size.value]) + rcac_bytes = bytes(rcac_data) + else: + raise Exception("RCAC data is empty") + + except Exception as e: + LOGGER.error(f"Error during RCAC data fetching: {e}") + + return rcac_bytes + async def CommissionWithCode(self, setupPayload: str, nodeid: int, discoveryType: DiscoveryType = DiscoveryType.DISCOVERY_ALL) -> int: ''' Commission with the given nodeid from the setupPayload. setupPayload may be a QR or manual code. diff --git a/src/python_testing/TC_CADMIN_1_3_4.py b/src/python_testing/TC_CADMIN_1_3_4.py new file mode 100644 index 00000000000000..594de789c0964b --- /dev/null +++ b/src/python_testing/TC_CADMIN_1_3_4.py @@ -0,0 +1,377 @@ +# +# 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 +# factory-reset: true +# quiet: true +# run2: +# app: ${ALL_CLUSTERS_APP} +# app-args: --discriminator 1234 --KVS kvs1 --trace-to json:${TRACE_APP}.json +# script-args: > +# --tests test_TC_CADMIN_1_4 +# --storage-path admin_storage.json +# --discriminator 1234 +# --passcode 20202021 +# --trace-to json:${TRACE_TEST_JSON}.json +# --trace-to perfetto:${TRACE_TEST_PERFETTO}.perfetto +# factory-reset: false +# quiet: true +# === END CI TEST ARGUMENTS === + +import asyncio +import base64 +import random +from time import sleep + +import chip.clusters as Clusters +from chip import ChipDeviceCtrl +from chip.exceptions import ChipStackError +from chip.interaction_model import Status +from chip.tlv import TLVReader +from matter_testing_infrastructure.chip.testing.matter_testing import (MatterBaseTest, TestStep, async_test_body, + default_matter_test_main) +from mdns_discovery import mdns_discovery +from mobly import asserts + +opcreds = Clusters.OperationalCredentials +nonce = random.randbytes(32) + + +class TC_CADMIN(MatterBaseTest): + async def get_fabrics(self, th: ChipDeviceCtrl) -> int: + OC_cluster = Clusters.OperationalCredentials + fabric_info = await self.read_single_attribute_check_success(dev_ctrl=th, fabric_filtered=True, cluster=OC_cluster, attribute=OC_cluster.Attributes.Fabrics) + return fabric_info + + async def get_txt_record(self): + discovery = mdns_discovery.MdnsDiscovery(verbose_logging=True) + comm_service = await discovery.get_commissionable_service( + discovery_timeout_sec=240, + log_output=False, + ) + return comm_service + + async def write_nl_attr(self, th: ChipDeviceCtrl, attr_val: object): + result = await th.WriteAttribute(nodeid=self.dut_node_id, attributes=[(0, attr_val)]) + asserts.assert_equal(result[0].Status, Status.Success, f"{th} node label write failed") + + async def read_nl_attr(self, th: ChipDeviceCtrl, attr_val: object): + try: + await th.ReadAttribute(nodeid=self.dut_node_id, attributes=[(0, attr_val)]) + except Exception as e: + asserts.assert_equal(e.err, "Received error message from read attribute attempt") + self.print_step(0, e) + + 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 pics_TC_CADMIN_1_3(self) -> list[str]: + return ["CADMIN.S"] + + def steps_TC_CADMIN_1_3(self) -> list[TestStep]: + return [ + TestStep(1, "TH_CR1 starts a commissioning process with DUT_CE", is_commissioning=True), + TestStep(2, "TH_CR1 reads the BasicCommissioningInfo attribute from the General Commissioning cluster and saves the MaxCumulativeFailsafeSeconds field as max_window_duration."), + TestStep("3a", "TH_CR1 opens a commissioning window on DUT_CE using a commissioning timeout of max_window_duration using ECM", + "DUT_CE opens its Commissioning window to allow a second commissioning."), + TestStep("3b", "DNS-SD records shows DUT_CE advertising", "Verify that the DNS-SD advertisement shows CM=2"), + TestStep("3c", "TH_CR1 writes and reads the Basic Information Cluster’s NodeLabel mandatory attribute of DUT_CE", + "Verify DUT_CE responds to both write/read with a success"), + TestStep(4, "TH creates a controller (TH_CR2) on a new fabric and commissions DUT_CE using that controller. TH_CR2 should commission the device using a different NodeID than TH_CR1.", + "Commissioning is successful"), + TestStep(5, "TH_CR1 reads the Fabrics attribute from the Node Operational Credentials cluster using a fabric-filtered read", + "Verify that the RootPublicKey matches the root public key for TH_CR1 and the NodeID matches the node ID used when TH_CR1 commissioned the device."), + TestStep(6, "TH_CR2 reads the Fabrics attribute from the Node Operational Credentials cluster using a fabric-filtered read", + "Verify that the RootPublicKey matches the root public key for TH_CR2 and the NodeID matches the node ID used when TH_CR2 commissioned the device."), + TestStep(7, "TH_CR1 writes and reads the Basic Information Cluster’s NodeLabel mandatory attribute of DUT_CE", + "Verify DUT_CE responds to both write/read with a success"), + TestStep(8, "TH_CR2 reads, writes and then reads the Basic Information Cluster’s NodeLabel mandatory attribute of DUT_CE", + "Verify the initial read reflect the value written in the above step. Verify DUT_CE responds to both write/read with a success"), + TestStep(9, "TH_CR2 opens a commissioning window on DUT_CE for 180 seconds using ECM"), + TestStep(10, "Wait for the commissioning window in step 9 to timeout"), + TestStep(11, "TH_CR2 reads the window status to verify the DUT_CE window is closed", + "DUT_CE windows status shows the window is closed"), + TestStep(12, "TH_CR2 opens a commissioning window on DUT_CE using ECM", + "DUT_CE opens its Commissioning window to allow a new commissioning"), + TestStep(13, "TH_CR1 starts a commissioning process with DUT_CE before the timeout from step 12", + "Since DUT_CE was already commissioned by TH_CR1 in step 1, AddNOC fails with NOCResponse with StatusCode field set to FabricConflict (9)"), + TestStep(14, "TH_CR2 reads the CurrentFabricIndex attribute from the Operational Credentials cluster and saves as th2_idx, 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_test_body + async def test_TC_CADMIN_1_3(self): + self.step(1) + + # Establishing TH1 + self.th1 = self.default_controller + + 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.max_window_duration = duration.maxCumulativeFailsafeSeconds + + self.step("3a") + # params = await self.openCommissioningWindow(dev_ctrl=self.th1, node_id=self.dut_node_id) + params = await self.th1.OpenCommissioningWindow(nodeid=self.dut_node_id, timeout=self.max_window_duration, iteration=1000, discriminator=1234, option=1) + self.print_step("TH1 params", params) + + self.step("3b") + services = await self.get_txt_record() + if services.txt_record['CM'] != "2": + asserts.fail(f"Expected cm record value not found, instead value found was {str(services.txt_record['CM'])}") + + self.step("3c") + BI_cluster = Clusters.BasicInformation + nl_attribute = BI_cluster.Attributes.NodeLabel + await self.write_nl_attr(th=self.th1, attr_val=nl_attribute) + await self.read_nl_attr(th=self.th1, attr_val=nl_attribute) + + self.step(4) + # Establishing TH2 + 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, useTestCommissioner=True) + await self.th2.CommissionOnNetwork( + nodeId=self.dut_node_id, setupPinCode=params.setupPinCode, + filterType=ChipDeviceCtrl.DiscoveryFilterType.LONG_DISCRIMINATOR, filter=1234) + rcac = self.th2.get_rcac() + + th2_rcac_decoded = TLVReader(rcac).get()["Any"][9] + + self.step(5) + # TH_CR1 reads the Fabrics attribute from the Node Operational Credentials cluster using a fabric-filtered read + th1_fabric_info = await self.get_fabrics(th=self.th1) + + # Verify that the RootPublicKey matches the root public key for TH_CR1 and the NodeID matches the node ID used when TH_CR1 commissioned the device. + # await self.send_single_cmd(dev_ctrl=self.th1, node_id=self.dut_node_id, cmd=Clusters.GeneralCommissioning.Commands.ArmFailSafe(10)) + th1_cam_rcac = TLVReader(base64.b64decode( + self.certificate_authority_manager.activeCaList[0]._persistentStorage._jsonData["sdk-config"]["f/1/r"])).get()["Any"][9] + + if th1_fabric_info[0].rootPublicKey != th1_cam_rcac: + asserts.fail("public keys from fabric and certs for TH1 are not the same") + if th1_fabric_info[0].nodeID != self.dut_node_id: + asserts.fail("DUT node ID from fabric does not equal DUT node ID for TH1 during commissioning") + + # Expiring the failsafe timer in an attempt to clean up before TH2 attempt. + # await self.th1.SendCommand(self.dut_node_id, 0, Clusters.GeneralCommissioning.Commands.ArmFailSafe(0)) + + self.step(6) + # TH_CR2 reads the Fabrics attribute from the Node Operational Credentials cluster using a fabric-filtered read + th2_fabric_info = await self.get_fabrics(th=self.th2) + + # Verify that the RootPublicKey matches the root public key for TH_CR2 and the NodeID matches the node ID used when TH_CR2 commissioned the device. + # await self.send_single_cmd(dev_ctrl=self.th2, node_id=self.dut_node_id, cmd=Clusters.GeneralCommissioning.Commands.ArmFailSafe(10)) + + if th2_fabric_info[0].rootPublicKey != th2_rcac_decoded: + asserts.fail("public keys from fabric and certs for TH1 are not the same") + if th2_fabric_info[0].nodeID != self.dut_node_id: + asserts.fail("DUT node ID from fabric does not equal DUT node ID for TH1 during commissioning") + + # await self.th2.SendCommand(self.dut_node_id, 0, Clusters.GeneralCommissioning.Commands.ArmFailSafe(0)) + # await self.th1.SendCommand(self.dut_node_id, 0, Clusters.GeneralCommissioning.Commands.ArmFailSafe(0)) + + self.step(7) + # TH_CR1 writes and reads the Basic Information Cluster’s NodeLabel mandatory attribute of DUT_CE + await self.write_nl_attr(th=self.th1, attr_val=nl_attribute) + await self.read_nl_attr(th=self.th1, attr_val=nl_attribute) + + self.step(8) + # TH_CR2 writes and reads the Basic Information Cluster’s NodeLabel mandatory attribute of DUT_CE + await self.write_nl_attr(th=self.th2, attr_val=nl_attribute) + await self.read_nl_attr(th=self.th2, attr_val=nl_attribute) + sleep(1) + + self.step(9) + # TH_CR2 opens a commissioning window on DUT_CE for 180 seconds using ECM + await self.th2.OpenCommissioningWindow(nodeid=self.dut_node_id, timeout=180, iteration=1000, discriminator=0, option=1) + + self.step(10) + sleep(181) + + self.step(11) + # TH_CR2 reads the window status to verify the DUT_CE window is closed + # TODO: Issue noticed when initially attempting to check window status, issue is detailed here: https://github.com/project-chip/connectedhomeip/issues/35983 + # Workaround in place until above issue resolved + try: + window_status = await self.th2.ReadAttribute(nodeid=self.dut_node_id, attributes=[(0, Clusters.AdministratorCommissioning.Attributes.WindowStatus)]) + except asyncio.CancelledError: + window_status = await self.th2.ReadAttribute(nodeid=self.dut_node_id, attributes=[(0, Clusters.AdministratorCommissioning.Attributes.WindowStatus)]) + + window_status = window_status[0] + outer_key = list(window_status.keys())[0] + inner_key = list(window_status[outer_key].keys())[1] + if window_status[outer_key][inner_key] != Clusters.AdministratorCommissioning.Enums.CommissioningWindowStatusEnum.kWindowNotOpen: + asserts.fail("Commissioning window is expected to be closed, but was found to be open") + + self.step(12) + # TH_CR2 opens a commissioning window on DUT_CE using ECM + self.discriminator = random.randint(0, 4095) + # params2 = await self.openCommissioningWindow(dev_ctrl=self.th2, node_id=self.dut_node_id) + params2 = await self.th2.OpenCommissioningWindow(nodeid=self.dut_node_id, timeout=self.max_window_duration, iteration=1000, discriminator=1234, option=1) + + self.step(13) + # TH_CR1 starts a commissioning process with DUT_CE before the timeout from step 12 + try: + await self.th1.CommissionOnNetwork( + nodeId=self.dut_node_id, setupPinCode=params2.setupPinCode, + filterType=ChipDeviceCtrl.DiscoveryFilterType.LONG_DISCRIMINATOR, filter=1234) + except ChipStackError as e: + asserts.assert_equal(e.err, 0x0000007E, + "Expected to return Trying to add NOC for fabric that already exists") + """ + expected error: + [2024-10-08 11:57:43.144125][TEST][STDOUT][MatterTest] 10-08 11:57:42.777 INFO Device returned status 9 on receiving the NOC + [2024-10-08 11:57:43.144365][TEST][STDOUT][MatterTest] 10-08 11:57:42.777 INFO Add NOC failed with error src/controller/CHIPDeviceController.cpp:1712: CHIP Error 0x0000007E: Trying to add a NOC for a fabric that already exists + """ + + 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(14) + # TH_CR2 reads the CurrentFabricIndex attribute from the Operational Credentials cluster and saves as th2_idx, TH_CR1 sends the RemoveFabric command to the DUT with the FabricIndex set to th2_idx + th2_idx = await self.th2.ReadAttribute(nodeid=self.dut_node_id, attributes=[(0, Clusters.OperationalCredentials.Attributes.CurrentFabricIndex)]) + outer_key = list(th2_idx.keys())[0] + inner_key = list(th2_idx[outer_key].keys())[0] + attribute_key = list(th2_idx[outer_key][inner_key].keys())[1] + removeFabricCmd = Clusters.OperationalCredentials.Commands.RemoveFabric(th2_idx[outer_key][inner_key][attribute_key]) + await self.th1.SendCommand(nodeid=self.dut_node_id, endpoint=0, payload=removeFabricCmd) + + def pics_TC_CADMIN_1_4(self) -> list[str]: + return ["CADMIN.S"] + + def steps_TC_CADMIN_1_4(self) -> list[TestStep]: + return [ + TestStep(1, "TH_CR1 starts a commissioning process with DUT_CE", is_commissioning=True), + TestStep(2, "TH_CR1 reads the BasicCommissioningInfo attribute from the General Commissioning cluster and saves the MaxCumulativeFailsafeSeconds field as max_window_duration."), + TestStep("3a", "TH_CR1 opens a commissioning window on DUT_CE using a commissioning timeout of max_window_duration using BCM", + "DUT_CE opens its Commissioning window to allow a second commissioning."), + TestStep("3b", "DNS-SD records shows DUT_CE advertising", "Verify that the DNS-SD advertisement shows CM=1"), + TestStep("3c", "TH_CR1 writes and reads the Basic Information Cluster’s NodeLabel mandatory attribute of DUT_CE", + "Verify DUT_CE responds to both write/read with a success"), + TestStep(4, "TH creates a controller (TH_CR2) on a new fabric and commissions DUT_CE using that controller. TH_CR2 should commission the device using a different NodeID than TH_CR1.", + "Commissioning is successful"), + TestStep(5, "TH_CR1 reads the Fabrics attribute from the Node Operational Credentials cluster using a fabric-filtered read", + "Verify that the RootPublicKey matches the root public key for TH_CR1 and the NodeID matches the node ID used when TH_CR1 commissioned the device."), + TestStep(6, "TH_CR2 reads the Fabrics attribute from the Node Operational Credentials cluster using a fabric-filtered read", + "Verify that the RootPublicKey matches the root public key for TH_CR2 and the NodeID matches the node ID used when TH_CR2 commissioned the device."), + TestStep(7, "TH_CR2 reads the CurrentFabricIndex attribute from the Operational Credentials cluster and saves as th2_idx, 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_test_body + async def test_TC_CADMIN_1_4(self): + self.step(1) + setupPayloadInfo = self.get_setup_payload_info() + if not setupPayloadInfo: + asserts.assert_true( + False, 'passcode and discriminator must be provided values in order for this test to work due to using BCM, please rerun test with providing --passcode and --discriminator ') + + # Establishing TH1 + self.th1 = self.default_controller + + 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.max_window_duration = duration.maxCumulativeFailsafeSeconds + + self.step("3a") + obcCmd = Clusters.AdministratorCommissioning.Commands.OpenBasicCommissioningWindow(180) + await self.th1.SendCommand(nodeid=self.dut_node_id, endpoint=0, payload=obcCmd, timedRequestTimeoutMs=6000) + + self.step("3b") + services = await self.get_txt_record() + if services.txt_record['CM'] != "1": + asserts.fail(f"Expected cm record value not found, instead value found was {str(services.txt_record['CM'])}") + + self.step("3c") + BI_cluster = Clusters.BasicInformation + nl_attribute = BI_cluster.Attributes.NodeLabel + await self.write_nl_attr(th=self.th1, attr_val=nl_attribute) + await self.read_nl_attr(th=self.th1, attr_val=nl_attribute) + + self.step(4) + # Establishing TH2 + 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, useTestCommissioner=True) + await self.th2.CommissionOnNetwork( + nodeId=self.dut_node_id, setupPinCode=setupPayloadInfo[0].passcode, + filterType=ChipDeviceCtrl.DiscoveryFilterType.LONG_DISCRIMINATOR, filter=setupPayloadInfo[0].filter_value) + rcac = self.th2.get_rcac() + + th2_rcac_decoded = TLVReader(rcac).get()["Any"][9] + + self.step(5) + # TH_CR1 reads the Fabrics attribute from the Node Operational Credentials cluster using a fabric-filtered read + th1_fabric_info = await self.get_fabrics(th=self.th1) + + # Verify that the RootPublicKey matches the root public key for TH_CR1 and the NodeID matches the node ID used when TH_CR1 commissioned the device. + # await self.send_single_cmd(dev_ctrl=self.th1, node_id=self.dut_node_id, cmd=Clusters.GeneralCommissioning.Commands.ArmFailSafe(10)) + th1_cam_rcac = TLVReader(base64.b64decode( + self.certificate_authority_manager.activeCaList[0]._persistentStorage._jsonData["sdk-config"]["f/1/r"])).get()["Any"][9] + if th1_fabric_info[0].rootPublicKey != th1_cam_rcac: + asserts.fail("public keys from fabric and certs for TH1 are not the same") + if th1_fabric_info[0].nodeID != self.dut_node_id: + asserts.fail("DUT node ID from fabric does not equal DUT node ID for TH1 during commissioning") + + # Expiring the failsafe timer in an attempt to clean up before TH2 attempt. + # await self.th1.SendCommand(self.dut_node_id, 0, Clusters.GeneralCommissioning.Commands.ArmFailSafe(0)) + + self.step(6) + # TH_CR2 reads the Fabrics attribute from the Node Operational Credentials cluster using a fabric-filtered read + th2_fabric_info = await self.get_fabrics(th=self.th2) + + # Verify that the RootPublicKey matches the root public key for TH_CR2 and the NodeID matches the node ID used when TH_CR2 commissioned the device. + # await self.send_single_cmd(dev_ctrl=self.th2, node_id=self.dut_node_id, cmd=Clusters.GeneralCommissioning.Commands.ArmFailSafe(10)) + + if th2_fabric_info[0].rootPublicKey != th2_rcac_decoded: + asserts.fail("public keys from fabric and certs for TH1 are not the same") + if th2_fabric_info[0].nodeID != self.dut_node_id: + asserts.fail("DUT node ID from fabric does not equal DUT node ID for TH1 during commissioning") + + # await self.th2.SendCommand(self.dut_node_id, 0, Clusters.GeneralCommissioning.Commands.ArmFailSafe(0)) + + self.step(7) + # TH_CR2 reads the CurrentFabricIndex attribute from the Operational Credentials cluster and saves as th2_idx, TH_CR1 sends the RemoveFabric command to the DUT with the FabricIndex set to th2_idx + th2_idx = await self.th2.ReadAttribute(nodeid=self.dut_node_id, attributes=[(0, Clusters.OperationalCredentials.Attributes.CurrentFabricIndex)]) + outer_key = list(th2_idx.keys())[0] + inner_key = list(th2_idx[outer_key].keys())[0] + attribute_key = list(th2_idx[outer_key][inner_key].keys())[1] + removeFabricCmd = Clusters.OperationalCredentials.Commands.RemoveFabric(th2_idx[outer_key][inner_key][attribute_key]) + await self.th1.SendCommand(nodeid=self.dut_node_id, endpoint=0, payload=removeFabricCmd) + + +if __name__ == "__main__": + default_matter_test_main()