From 20caa91fea35cc5629aa0a6b9aa864eddceed15e Mon Sep 17 00:00:00 2001
From: mkardous-silabs <84793247+mkardous-silabs@users.noreply.github.com>
Date: Mon, 19 Aug 2024 16:23:01 -0400
Subject: [PATCH] [ICD] Add ICDM 3.2 Python Certification Script (#34782)

* Add ICDM 3.2 Python Certification Script

* fix restyle

* Restyled by prettier-json

* Restyled by isort

* restyle and linter fix

* Add CI test arguments

---------

Co-authored-by: Restyled.io <commits@restyled.io>
---
 .../certification/Test_TC_ICDM_3_2.yaml       | 346 ---------------
 src/app/tests/suites/manualTests.json         |   2 +-
 src/python_testing/TC_ICDM_3_2.py             | 419 ++++++++++++++++++
 3 files changed, 420 insertions(+), 347 deletions(-)
 delete mode 100644 src/app/tests/suites/certification/Test_TC_ICDM_3_2.yaml
 create mode 100644 src/python_testing/TC_ICDM_3_2.py

diff --git a/src/app/tests/suites/certification/Test_TC_ICDM_3_2.yaml b/src/app/tests/suites/certification/Test_TC_ICDM_3_2.yaml
deleted file mode 100644
index f6104a53d411d1..00000000000000
--- a/src/app/tests/suites/certification/Test_TC_ICDM_3_2.yaml
+++ /dev/null
@@ -1,346 +0,0 @@
-# Copyright (c) 2024 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: 217.2.3. [TC-ICDM-3.2] Verify RegisterClient command with DUT as Server
-
-PICS:
-    - ICDM.S
-    - ICDM.S.C00.Rsp
-    - ICDM.S.C02.Rsp
-
-config:
-    nodeId: 0x12344321
-    cluster: "Basic Information"
-    endpoint: 0
-
-tests:
-    - label: "Preconditions"
-      verification: |
-          1.Commission DUT to TH (can be skipped if done in a preceding test).
-          2a.TH reads from the DUT the RegisteredClients attribute.
-          2b.If list of registered clients is not empty, unregister existing client(s)
-          2c.TH reads from the DUT the RegisteredClients attribute. Verify that the DUT response contains empty list of registered clients.
-      disabled: true
-
-    - label:
-          "Step 1a: TH sends RegisterClient command. - CheckInNodeID:
-          registering clients node ID (CheckInNodeID1) - MonitoredSubject:
-          monitored subject ID (MonitorSubID1) - Key: shared secret between the
-          client and the ICD (Key1)"
-      PICS: ICDM.S.C00.Rsp
-      verification: |
-          ./chip-tool icdmanagement register-client 1 1 hex:1234567890abcdef1234567890abcdef 1 0
-
-          [1702418857.289325][1350:1352] CHIP:DMG: Received Command Response Data, Endpoint=0 Cluster=0x0000_0046 Command=0x0000_0001
-          [1702418857.289426][1350:1352] CHIP:TOO: Endpoint: 0 Cluster: 0x0000_0046 Command 0x0000_0001
-          [1702418857.289635][1350:1352] CHIP:TOO:   RegisterClientResponse: {
-          [1702418857.289725][1350:1352] CHIP:TOO:     ICDCounter: 1321491095
-          [1702418857.289781][1350:1352] CHIP:TOO:    }
-      disabled: true
-
-    - label: "Step 1b: TH reads from the DUT the RegisteredClients attribute."
-      PICS: ICDM.S.A0003
-      verification: |
-          ./chip-tool icdmanagement read registered-clients 1 0
-
-          [1702418868.283920][1353:1355] CHIP:TOO: Endpoint: 0 Cluster: 0x0000_0046 Attribute 0x0000_0003 DataVersion: 4124981277
-          [1702418868.284152][1353:1355] CHIP:TOO:   RegisteredClients: 2 entries
-          [1702418868.284338][1353:1355] CHIP:TOO:     [1]: {
-          [1702418868.284396][1353:1355] CHIP:TOO:       CheckInNodeID: 112233
-          [1702418868.284449][1353:1355] CHIP:TOO:       MonitoredSubject: 112233
-          [1702418868.284525][1353:1355] CHIP:TOO:       FabricIndex: 1
-          [1702418868.284577][1353:1355] CHIP:TOO:      }
-          [1702418868.284647][1353:1355] CHIP:TOO:     [2]: {
-          [1702418868.284700][1353:1355] CHIP:TOO:       CheckInNodeID: 1
-          [1702418868.284751][1353:1355] CHIP:TOO:       MonitoredSubject: 1
-          [1702418868.284801][1353:1355] CHIP:TOO:       FabricIndex: 1
-          [1702418868.284849][1353:1355] CHIP:TOO:      }
-      disabled: true
-
-    - label: "Step 1c: Power cycle DUT"
-      verification: |
-          Power cycle DUT
-      disabled: true
-
-    - label: "Step 1d: TH reads from the DUT the RegisteredClients attribute."
-      PICS: ICDM.S.A0003(RegisteredClients)
-      verification: |
-          ./chip-tool icdmanagement read registered-clients 1 0
-
-          [1702418876.828984][1356:1358] CHIP:TOO: Endpoint: 0 Cluster: 0x0000_0046 Attribute 0x0000_0003 DataVersion: 4124981277
-          [1702418876.829201][1356:1358] CHIP:TOO:   RegisteredClients: 2 entries
-          [1702418876.829372][1356:1358] CHIP:TOO:     [1]: {
-          [1702418876.829426][1356:1358] CHIP:TOO:       CheckInNodeID: 112233
-          [1702418876.829535][1356:1358] CHIP:TOO:       MonitoredSubject: 112233
-          [1702418876.829609][1356:1358] CHIP:TOO:       FabricIndex: 1
-          [1702418876.829655][1356:1358] CHIP:TOO:      }
-          [1702418876.829719][1356:1358] CHIP:TOO:     [2]: {
-          [1702418876.829766][1356:1358] CHIP:TOO:       CheckInNodeID: 1
-          [1702418876.829867][1356:1358] CHIP:TOO:       MonitoredSubject: 1
-          [1702418876.829912][1356:1358] CHIP:TOO:       FabricIndex: 1
-          [1702418876.829955][1356:1358] CHIP:TOO:      }
-      disabled: true
-
-    - label:
-          "Step 2a: Setup the TH such that is has administrator privileges for
-          the ICDM cluster."
-      verification: |
-          chip-tool default with admin privilege.
-      disabled: true
-
-    - label:
-          "Step 2b: TH sends RegisterClient command with same CheckInNodeID as
-          in Step 1a and different MonitoredSubject and Key. - CheckInNodeID:
-          registering clients node ID (CheckInNodeID1) - MonitoredSubject:
-          monitored subject ID (MonitorSubID2) - Key: shared secret between the
-          client and the ICD (Key2)"
-      PICS: ICDM.S.C00.Rsp
-      verification: |
-          ./chip-tool icdmanagement register-client 1 2 hex:abcdef1234567890abcdef1234567890 1 0
-
-          [1702418883.807797][1359:1361] CHIP:DMG: Received Command Response Data, Endpoint=0 Cluster=0x0000_0046 Command=0x0000_0001
-          [1702418883.807919][1359:1361] CHIP:TOO: Endpoint: 0 Cluster: 0x0000_0046 Command 0x0000_0001
-          [1702418883.808188][1359:1361] CHIP:TOO:   RegisterClientResponse: {
-          [1702418883.808260][1359:1361] CHIP:TOO:     ICDCounter: 1321491095
-          [1702418883.808316][1359:1361] CHIP:TOO:    }
-      disabled: true
-
-    - label: "Step 2c: TH reads from the DUT the ICDCounter attribute."
-      PICS: ICDM.S.A0004
-      verification: |
-          ./chip-tool icdmanagement read icdcounter 1 0
-
-          [1702418902.706877][1365:1367] CHIP:TOO: Endpoint: 0 Cluster: 0x0000_0046 Attribute 0x0000_0004 DataVersion: 4124981277
-          [1702418902.706989][1365:1367] CHIP:TOO:   ICDCounter: 1321491095
-      disabled: true
-
-    - label: "Step 2d: TH reads from the DUT the RegisteredClients attribute."
-      PICS: ICDM.S.A0003
-      verification: |
-          ./chip-tool icdmanagement read registered-clients 1 0
-
-          [1702418891.793516][1362:1364] CHIP:TOO: Endpoint: 0 Cluster: 0x0000_0046 Attribute 0x0000_0003 DataVersion: 4124981277
-          [1702418891.793737][1362:1364] CHIP:TOO:   RegisteredClients: 2 entries
-          [1702418891.793959][1362:1364] CHIP:TOO:     [1]: {
-          [1702418891.794016][1362:1364] CHIP:TOO:       CheckInNodeID: 112233
-          [1702418891.794065][1362:1364] CHIP:TOO:       MonitoredSubject: 112233
-          [1702418891.794133][1362:1364] CHIP:TOO:       FabricIndex: 1
-          [1702418891.794179][1362:1364] CHIP:TOO:      }
-          [1702418891.794290][1362:1364] CHIP:TOO:     [2]: {
-          [1702418891.794344][1362:1364] CHIP:TOO:       CheckInNodeID: 1
-          [1702418891.794390][1362:1364] CHIP:TOO:       MonitoredSubject: 2
-          [1702418891.794483][1362:1364] CHIP:TOO:       FabricIndex: 1
-          [1702418891.794531][1362:1364] CHIP:TOO:      }
-      disabled: true
-
-    - label:
-          "Step 2e: TH sends UnregisterClient command with the CheckInNodeID
-          (CheckInNodeID1)."
-      PICS: ICDM.S.C02.Rsp
-      verification: |
-          ./chip-tool icdmanagement unregister-client 1 1 0
-
-          [1702419153.281757][1380:1382] CHIP:DMG: InvokeResponseMessage =
-          [1702419153.281885][1380:1382] CHIP:DMG: {
-          [1702419153.282005][1380:1382] CHIP:DMG:         suppressResponse = false,
-          [1702419153.282061][1380:1382] CHIP:DMG:         InvokeResponseIBs =
-          [1702419153.282126][1380:1382] CHIP:DMG:         [
-          [1702419153.282177][1380:1382] CHIP:DMG:                 InvokeResponseIB =
-          [1702419153.282243][1380:1382] CHIP:DMG:                 {
-          [1702419153.282296][1380:1382] CHIP:DMG:                         CommandStatusIB =
-          [1702419153.282357][1380:1382] CHIP:DMG:                         {
-          [1702419153.282576][1380:1382] CHIP:DMG:                                 CommandPathIB =
-          [1702419153.282650][1380:1382] CHIP:DMG:                                 {
-          [1702419153.282725][1380:1382] CHIP:DMG:                                         EndpointId = 0x0,
-          [1702419153.282812][1380:1382] CHIP:DMG:                                         ClusterId = 0x46,
-          [1702419153.282895][1380:1382] CHIP:DMG:                                         CommandId = 0x2,
-          [1702419153.282973][1380:1382] CHIP:DMG:                                 },
-          [1702419153.283183][1380:1382] CHIP:DMG:
-          [1702419153.283246][1380:1382] CHIP:DMG:                                 StatusIB =
-          [1702419153.283327][1380:1382] CHIP:DMG:                                 {
-          [1702419153.283409][1380:1382] CHIP:DMG:                                         status = 0x00 (SUCCESS),
-          [1702419153.283490][1380:1382] CHIP:DMG:                                 },
-          [1702419153.283562][1380:1382] CHIP:DMG:
-          [1702419153.283626][1380:1382] CHIP:DMG:                         },
-          [1702419153.283699][1380:1382] CHIP:DMG:
-          [1702419153.283751][1380:1382] CHIP:DMG:                 },
-          [1702419153.283811][1380:1382] CHIP:DMG:
-          [1702419153.283859][1380:1382] CHIP:DMG:         ],
-          [1702419153.283919][1380:1382] CHIP:DMG:
-          [1702419153.283966][1380:1382] CHIP:DMG:         InteractionModelRevision = 11
-          [1702419153.284013][1380:1382] CHIP:DMG: },
-          [1702419153.284182][1380:1382] CHIP:DMG: Received Command Response Status for Endpoint=0 Cluster=0x0000_0046 Command=0x0000_0002 Status=0x0
-      disabled: true
-
-    - label: "Step 2f: TH reads from the DUT the RegisteredClients attribute."
-      PICS: ICDM.S.A0003
-      verification: |
-          ./chip-tool icdmanagement read registered-clients 1 0
-
-          [1702419210.157158][1385:1387] CHIP:TOO: Endpoint: 0 Cluster: 0x0000_0046 Attribute 0x0000_0003 DataVersion: 4124981277
-          [1702419210.157311][1385:1387] CHIP:TOO:   RegisteredClients: 1 entries
-          [1702419210.157489][1385:1387] CHIP:TOO:     [1]: {
-          [1702419210.157543][1385:1387] CHIP:TOO:       CheckInNodeID: 112233
-          [1702419210.157591][1385:1387] CHIP:TOO:       MonitoredSubject: 112233
-          [1702419210.157662][1385:1387] CHIP:TOO:       FabricIndex: 1
-          [1702419210.157730][1385:1387] CHIP:TOO:      }
-      disabled: true
-
-    - label:
-          "Step 2g: Clear the THs administrator privileges for the ICDM cluster."
-      verification: |
-          ./chip-tool accesscontrol write acl '[{"fabricIndex": 1, "privilege": 4, "authMode": 2, "subjects": [112233], "targets": null } ]' 1 0
-      disabled: true
-
-    - label:
-          "Step 3a: TH sends RegisterClient command. - CheckInNodeID:
-          registering clients node ID (CheckInNodeID3) - MonitoredSubject:
-          monitored subject ID (MonitorSubID3) - Key: shared secret between the
-          client and the ICD (Key3) - VerificationKey: verification key
-          (VerificationKey3)"
-      PICS: ICDM.S.C00.Rsp
-      verification: |
-          ./chip-tool icdmanagement register-client 3 3 hex:3334567890abcdef3334567890abcdef 1 0  --VerificationKey hex:abcdef1234567890abcdef1234567890
-
-          [1702433488.601132][2043:2045] CHIP:DMG: Received Command Response Data, Endpoint=0 Cluster=0x0000_0046 Command=0x0000_0001
-          [1702433488.601231][2043:2045] CHIP:TOO: Endpoint: 0 Cluster: 0x0000_0046 Command 0x0000_0001
-          [1702433488.601414][2043:2045] CHIP:TOO:   RegisterClientResponse: {
-          [1702433488.601478][2043:2045] CHIP:TOO:     ICDCounter: 228745926
-          [1702433488.601531][2043:2045] CHIP:TOO:    }
-      disabled: true
-
-    - label: "Step 3b: TH reads from the DUT the RegisteredClients attribute."
-      PICS: ICDM.S.A0003
-      verification: |
-          ./chip-tool icdmanagement read registered-clients 1 0
-
-          [1702433698.808800][2095:2097] CHIP:TOO: Endpoint: 0 Cluster: 0x0000_0046 Attribute 0x0000_0003 DataVersion: 2083795792
-          [1702433698.808939][2095:2097] CHIP:TOO:   RegisteredClients: 2 entries
-          [1702433698.809081][2095:2097] CHIP:TOO:     [1]: {
-          [1702433698.809126][2095:2097] CHIP:TOO:       CheckInNodeID: 112233
-          [1702433698.809167][2095:2097] CHIP:TOO:       MonitoredSubject: 112233
-          [1702433698.809226][2095:2097] CHIP:TOO:       FabricIndex: 1
-          [1702433698.809266][2095:2097] CHIP:TOO:      }
-          [1702433698.809319][2095:2097] CHIP:TOO:     [2]: {
-          [1702433698.809359][2095:2097] CHIP:TOO:       CheckInNodeID: 3
-          [1702433698.809399][2095:2097] CHIP:TOO:       MonitoredSubject: 3
-          [1702433698.809514][2095:2097] CHIP:TOO:       FabricIndex: 1
-          [1702433698.809559][2095:2097] CHIP:TOO:      }
-      disabled: true
-
-    - label:
-          "Step 4: TH sends RegisterClient command with same CheckInNodeID as in
-          Step 3a and different MonitoredSubject and Key, and an invalid
-          VerificationKey - CheckInNodeID: registering clients node ID
-          (CheckInNodeID3) - MonitoredSubject: monitored subject ID
-          (MonitorSubID4) - Key: shared secret between the client and the ICD
-          (Key4) - VerificationKey: invalid verification key (VerificationKey4)"
-      PICS: ICDM.S.C00.Rsp
-      verification: |
-          ./chip-tool icdmanagement register-client 3 4 hex:3334567890abcdef3334567890abcdef 1 0  --VerificationKey hex:abcdef1234567890
-
-          [1703266655.434604][2378:2381] CHIP:DMG: Received Command Response Status for Endpoint=0 Cluster=0x0000_0046 Command=0x0000_0000 Status=0x1
-          [1703266655.434688][2378:2381] CHIP:TOO: Error: IM Error 0x00000501: General error: 0x01 (FAILURE)
-      disabled: true
-
-    - label:
-          "Step 5: TH sends RegisterClient command with same CheckInNodeID as in
-          Step 3a and different MonitoredSubject, Key, and VerificationKey -
-          CheckInNodeID: registering clients node ID (CheckInNodeID3) -
-          MonitoredSubject: monitored subject ID (MonitorSubID5) - Key: shared
-          secret between the client and the ICD (Key5) - VerificationKey: valid
-          verification key (VerificationKey5)"
-      PICS: ICDM.S.C00.Rsp
-      verification: |
-          ./chip-tool icdmanagement register-client 3 5 hex:3334567890abcdef3334567890abcdef 1 0  --VerificationKey hex:abcdef1234567890abcdef1234500000
-
-          [1703266705.829853][2551:2553] CHIP:DMG: Received Command Response Status for Endpoint=0 Cluster=0x0000_0046 Command=0x0000_0000 Status=0x1
-          [1703266705.829994][2551:2553] CHIP:TOO: Error: IM Error 0x00000501: General error: 0x01 (FAILURE)
-      disabled: true
-
-    - label:
-          "Step 6a: TH sends RegisterClient command with same CheckInNodeID and
-          VerificationKey as in Step 3a and different MonitoredSubject and Key -
-          CheckInNodeID: registering clients node ID (CheckInNodeID3) -
-          MonitoredSubject: monitored subject ID (MonitorSubID6) - Key: shared
-          secret between the client and the ICD (Key6) - VerificationKey:
-          verification key (VerificationKey3)"
-      PICS: ICDM.S.C00.Rsp
-      verification: |
-          ./chip-tool icdmanagement register-client 3 6 hex:3334567890abcdef3334567890abcdef 1 0  --VerificationKey hex:abcdef1234567890abcdef1234567890
-
-          [1703267703.849366][2694:2696] CHIP:TOO: Endpoint: 0 Cluster: 0x0000_0046 Command 0x0000_0001
-          [1703267703.849532][2694:2696] CHIP:TOO:   RegisterClientResponse: {
-          [1703267703.849587][2694:2696] CHIP:TOO:     ICDCounter: 228745930
-          [1703267703.849633][2694:2696] CHIP:TOO:    }
-      disabled: true
-
-    - label: "Step 6b: TH reads from the DUT the RegisteredClients attribute."
-      PICS: ICDM.S.A0003
-      verification: |
-          ./chip-tool icdmanagement read registered-clients 1 0
-
-          [1702433698.808800][2095:2097] CHIP:TOO: Endpoint: 0 Cluster: 0x0000_0046 Attribute 0x0000_0003 DataVersion: 2083795792
-          [1702433698.808939][2095:2097] CHIP:TOO:   RegisteredClients: 2 entries
-          [1702433698.809081][2095:2097] CHIP:TOO:     [1]: {
-          [1702433698.809126][2095:2097] CHIP:TOO:       CheckInNodeID: 112233
-          [1702433698.809167][2095:2097] CHIP:TOO:       MonitoredSubject: 112233
-          [1702433698.809226][2095:2097] CHIP:TOO:       FabricIndex: 1
-          [1702433698.809266][2095:2097] CHIP:TOO:      }
-          [1702433698.809319][2095:2097] CHIP:TOO:     [2]: {
-          [1702433698.809359][2095:2097] CHIP:TOO:       CheckInNodeID: 3
-          [1702433698.809399][2095:2097] CHIP:TOO:       MonitoredSubject: 6
-          [1702433698.809514][2095:2097] CHIP:TOO:       FabricIndex: 1
-          [1702433698.809559][2095:2097] CHIP:TOO:      }
-      disabled: true
-
-    - label:
-          "Step 6c: TH sends UnregisterClient command with the CheckInNodeID
-          (CheckInNodeID3) and VerificationKey (VerificationKey3)."
-      PICS: ICDM.S.C02.Rsp
-      verification: |
-          ./chip-tool icdmanagement unregister-client 3 3 0
-
-          [1702419153.281757][1380:1382] CHIP:DMG: InvokeResponseMessage =
-          [1702419153.281885][1380:1382] CHIP:DMG: {
-          [1702419153.282005][1380:1382] CHIP:DMG:         suppressResponse = false,
-          [1702419153.282061][1380:1382] CHIP:DMG:         InvokeResponseIBs =
-          [1702419153.282126][1380:1382] CHIP:DMG:         [
-          [1702419153.282177][1380:1382] CHIP:DMG:                 InvokeResponseIB =
-          [1702419153.282243][1380:1382] CHIP:DMG:                 {
-          [1702419153.282296][1380:1382] CHIP:DMG:                         CommandStatusIB =
-          [1702419153.282357][1380:1382] CHIP:DMG:                         {
-          [1702419153.282576][1380:1382] CHIP:DMG:                                 CommandPathIB =
-          [1702419153.282650][1380:1382] CHIP:DMG:                                 {
-          [1702419153.282725][1380:1382] CHIP:DMG:                                         EndpointId = 0x0,
-          [1702419153.282812][1380:1382] CHIP:DMG:                                         ClusterId = 0x46,
-          [1702419153.282895][1380:1382] CHIP:DMG:                                         CommandId = 0x2,
-          [1702419153.282973][1380:1382] CHIP:DMG:                                 },
-          [1702419153.283183][1380:1382] CHIP:DMG:
-          [1702419153.283246][1380:1382] CHIP:DMG:                                 StatusIB =
-          [1702419153.283327][1380:1382] CHIP:DMG:                                 {
-          [1702419153.283409][1380:1382] CHIP:DMG:                                         status = 0x00 (SUCCESS),
-          [1702419153.283490][1380:1382] CHIP:DMG:                                 },
-          [1702419153.283562][1380:1382] CHIP:DMG:
-          [1702419153.283626][1380:1382] CHIP:DMG:                         },
-          [1702419153.283699][1380:1382] CHIP:DMG:
-          [1702419153.283751][1380:1382] CHIP:DMG:                 },
-          [1702419153.283811][1380:1382] CHIP:DMG:
-          [1702419153.283859][1380:1382] CHIP:DMG:         ],
-          [1702419153.283919][1380:1382] CHIP:DMG:
-          [1702419153.283966][1380:1382] CHIP:DMG:         InteractionModelRevision = 11
-          [1702419153.284013][1380:1382] CHIP:DMG: },
-          [1702419153.284182][1380:1382] CHIP:DMG: Received Command Response Status for Endpoint=0 Cluster=0x0000_0046 Command=0x0000_0002 Status=0x0
-      disabled: true
diff --git a/src/app/tests/suites/manualTests.json b/src/app/tests/suites/manualTests.json
index 5edf1cbe71a264..8048c7b3be6e22 100644
--- a/src/app/tests/suites/manualTests.json
+++ b/src/app/tests/suites/manualTests.json
@@ -117,7 +117,7 @@
     "GeneralCommissioning": ["Test_TC_CGEN_2_2"],
     "GeneralDiagnostics": ["Test_TC_DGGEN_2_2"],
     "Identify": ["Test_TC_I_3_2"],
-    "IcdManagement": ["Test_TC_ICDM_3_2", "Test_TC_ICDM_5_1"],
+    "IcdManagement": ["Test_TC_ICDM_4_1", "Test_TC_ICDM_5_1"],
     "IlluminanceMeasurement": [],
     "InteractionDataModel": [
         "Test_TC_IDM_1_1",
diff --git a/src/python_testing/TC_ICDM_3_2.py b/src/python_testing/TC_ICDM_3_2.py
new file mode 100644
index 00000000000000..5a194420c3619e
--- /dev/null
+++ b/src/python_testing/TC_ICDM_3_2.py
@@ -0,0 +1,419 @@
+
+#
+#    Copyright (c) 2023 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.
+#
+
+# See https://github.com/project-chip/connectedhomeip/blob/master/docs/testing/python.md#defining-the-ci-test-arguments
+# for details about the block below.
+#
+# === BEGIN CI TEST ARGUMENTS ===
+# test-runner-runs: run1
+# test-runner-run/run1/app: ${LIT_ICD_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 --PICS src/app/tests/suites/certification/ci-pics-values --trace-to json:${TRACE_TEST_JSON}.json --trace-to perfetto:${TRACE_TEST_PERFETTO}.perfetto
+# === END CI TEST ARGUMENTS ===
+
+import logging
+import time
+from dataclasses import dataclass
+
+import chip.clusters as Clusters
+from chip.interaction_model import InteractionModelError, Status
+from matter_testing_support import MatterBaseTest, TestStep, async_test_body, default_matter_test_main
+from mobly import asserts
+
+logger = logging.getLogger(__name__)
+
+# ==========================
+# Constants
+# ==========================
+
+kRootEndpointId = 0
+
+cluster = Clusters.Objects.IcdManagement
+commands = cluster.Commands
+ClientTypeEnum = cluster.Enums.ClientTypeEnum
+attributes = cluster.Attributes
+
+
+@dataclass
+class Client:
+    checkInNodeID: int
+    subjectId: int
+    key: bytes
+    clientType: ClientTypeEnum
+
+
+#
+# Test Input Data
+#
+kIncorrectKey = b"\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1a"
+kInvalidKey = b"\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e1g"
+
+client1 = Client(
+    checkInNodeID=1,
+    subjectId=1,
+    key=b"\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f",
+    clientType=ClientTypeEnum.kEphemeral
+)
+
+client2 = Client(
+    checkInNodeID=1,
+    subjectId=2,
+    key=b"\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1e",
+    clientType=ClientTypeEnum.kEphemeral
+)
+
+client3 = Client(
+    checkInNodeID=1,
+    subjectId=3,
+    key=b"\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1d",
+    clientType=ClientTypeEnum.kEphemeral
+)
+
+client4 = Client(
+    checkInNodeID=1,
+    subjectId=4,
+    key=b"\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1c",
+    clientType=ClientTypeEnum.kEphemeral
+)
+
+client5 = Client(
+    checkInNodeID=5,
+    subjectId=5,
+    key=b"\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1b",
+    clientType=ClientTypeEnum.kEphemeral
+)
+
+client6 = Client(
+    checkInNodeID=5,
+    subjectId=6,
+    key=b"\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1a",
+    clientType=ClientTypeEnum.kEphemeral
+)
+
+client7 = Client(
+    checkInNodeID=5,
+    subjectId=7,
+    key=b"\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x0f",
+    clientType=ClientTypeEnum.kEphemeral
+)
+
+client8 = Client(
+    checkInNodeID=5,
+    subjectId=8,
+    key=b"\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x0e",
+    clientType=ClientTypeEnum.kEphemeral
+)
+
+
+class TC_ICDM_3_2(MatterBaseTest):
+
+    #
+    # Class Helper functions
+    #
+    async def _read_icdm_attribute_expect_success(self, attribute):
+        return await self.read_single_attribute_check_success(endpoint=kRootEndpointId, cluster=cluster, attribute=attribute)
+
+    async def _send_single_icdm_command(self, command):
+        return await self.send_single_cmd(command, endpoint=kRootEndpointId)
+    #
+    # Test Harness Helpers
+    #
+
+    def desc_TC_ICDM_3_2(self) -> str:
+        """Returns a description of this test"""
+        return "[TC-ICDM-3.2] Verify RegisterClient Command with DUT as Server"
+
+    def steps_TC_ICDM_3_2(self) -> list[TestStep]:
+        steps = [
+            TestStep(0, "Commissioning, already done", is_commissioning=True),
+            TestStep(1, "TH reads from the DUT the RegisteredClients attribute. RegisteredClients is empty."),
+            TestStep("2a", "TH sends RegisterClient command."),
+            TestStep("2b", "TH reads from the DUT the RegisteredClients attribute."),
+            TestStep("2c", "Power cycle DUT."),
+            TestStep("2d", "TH waits for {PIXIT.WAITTIME.REBOOT}"),
+            TestStep("2e", "TH reads from the DUT the RegisteredClients attribute."),
+            TestStep("3a", "TH sends RegisterClient command with same CheckInNodeID1 as in Step 1a and different MonitorSubID2 and Key2."),
+            TestStep("3b", "TH reads from the DUT the RegisteredClients attribute."),
+            TestStep("4a", "TH sends RegisterClient command with same CheckInNodeID1 as in Step 1a and different MonitorSubID3 and Key3, and an invalid VerificationKey3."),
+            TestStep("4b", "TH reads from the DUT the RegisteredClients attribute."),
+            TestStep("5a", "TH sends RegisterClient command with same CheckInNodeID1 as in Step 1a and different MonitorSubID4 and Key4, and a valid wrong VerificationKey4."),
+            TestStep("5b", "TH reads from the DUT the RegisteredClients attribute."),
+            TestStep("6a", "TH sends UnregisterClient command with CheckInNodeID1."),
+            TestStep("6b", "TH reads from the DUT the RegisteredClients attribute."),
+            TestStep(7, "Set the TH to Manage privilege for ICDM cluster."),
+            TestStep("8a", "TH sends RegisterClient command."),
+            TestStep("8b", "TH sends RegisterClient command with same CheckInNodeID5 as in Step 6a and different MonitorSubID6 and Key6, and an invalid VerificationKey6."),
+            TestStep("8c", "TH sends RegisterClient command with same CheckInNodeID5 as in Step 6a and different MonitorSubID7 and Key7, and an valid wrong VerificationKey7."),
+            TestStep("8d", "TH sends RegisterClient command with same CheckInNodeID5 and VerificationKey5 as in Step 6a and different MonitorSubID9 and Key9."),
+            TestStep(9, "TH sends UnregisterClient command with the CheckInNodeID5 and VerificationKey5."),
+        ]
+        return steps
+
+    def pics_TC_ICDM_3_2(self) -> list[str]:
+        """ This function returns a list of PICS for this test case that must be True for the test to be run"""
+        pics = [
+            "ICDM.S",
+            "ICDM.S.F00"
+        ]
+        return pics
+
+    #
+    # ICDM 3.2 Test Body
+    #
+
+    @ async_test_body
+    async def test_TC_ICDM_3_2(self):
+        is_ci = self.check_pics("PICS_SDK_CI_ONLY")
+
+        if not is_ci:
+            asserts.assert_true('PIXIT.WAITTIME.REBOOT' in self.matter_test_config.global_test_params,
+                                "PIXIT.WAITTIME.REBOOT must be included on the command line in "
+                                "the --int-arg flag as PIXIT.WAITTIME.REBOOT:<wait time>")
+
+            wait_time_reboot = self.matter_test_config.global_test_params['PIXIT.WAITTIME.REBOOT']
+            if wait_time_reboot == 0:
+                asserts.fail("PIXIT.WAITTIME.REBOOT shall be higher than 0.")
+
+        # Pre-Condition: Commissioning
+        self.step(0)
+
+        # Empty RegisteredClients attribute for all registrations
+        self.step(1)
+        registeredClients = await self._read_icdm_attribute_expect_success(
+            attributes.RegisteredClients)
+
+        for client in registeredClients:
+            try:
+                await self._send_single_icdm_command(commands.UnregisterClient(checkInNodeID=client.checkInNodeID))
+            except InteractionModelError as e:
+                asserts.assert_equal(
+                    e.status, Status.Success, "Unexpected error returned")
+
+        try:
+            self.step("2a")
+            try:
+                await self._send_single_icdm_command(commands.RegisterClient(checkInNodeID=client1.checkInNodeID, monitoredSubject=client1.subjectId, key=client1.key, clientType=client1.clientType))
+            except InteractionModelError as e:
+                asserts.assert_equal(
+                    e.status, Status.Success, "Unexpected error returned")
+
+            self.step("2b")
+            registeredClients = await self._read_icdm_attribute_expect_success(
+                attributes.RegisteredClients)
+            # Validate list size
+            asserts.assert_equal(len(registeredClients), 1,
+                                 "The expected length of RegisteredClients is 1. List has the wrong size.")
+
+            # Validate entry values
+            asserts.assert_equal(
+                registeredClients[0].checkInNodeID, client1.checkInNodeID, "The read attribute does not match the registered value.")
+            asserts.assert_equal(
+                registeredClients[0].monitoredSubject, client1.subjectId, "The read attribute does not match the registered value.")
+            asserts.assert_equal(
+                registeredClients[0].clientType, client1.clientType, "The read attribute does not match the registered value.")
+
+            # Reboot
+            self.step("2c")
+            if not is_ci:
+                self.wait_for_user_input(prompt_msg="Restart DUT. Press Enter when restart has been initiated.")
+
+            self.step("2d")
+            if not is_ci:
+                time.sleep(wait_time_reboot)
+
+            self.step("2e")
+            registeredClients = await self._read_icdm_attribute_expect_success(
+                attributes.RegisteredClients)
+            # Validate list size
+            asserts.assert_equal(len(registeredClients), 1,
+                                 "The expected length of RegisteredClients is 1. List has the wrong size.")
+
+            # Validate entry values
+            asserts.assert_equal(
+                registeredClients[0].checkInNodeID, client1.checkInNodeID, "The read attribute does not match the registered value.")
+            asserts.assert_equal(
+                registeredClients[0].monitoredSubject, client1.subjectId, "The read attribute does not match the registered value.")
+            asserts.assert_equal(
+                registeredClients[0].clientType, client1.clientType, "The read attribute does not match the registered value.")
+
+            self.step("3a")
+            try:
+                await self._send_single_icdm_command(commands.RegisterClient(checkInNodeID=client2.checkInNodeID, monitoredSubject=client2.subjectId, key=client2.key, clientType=client2.clientType))
+            except InteractionModelError as e:
+                asserts.assert_equal(
+                    e.status, Status.Success, "Unexpected error returned")
+
+            self.step("3b")
+            registeredClients = await self._read_icdm_attribute_expect_success(
+                attributes.RegisteredClients)
+            # Validate list size
+            asserts.assert_equal(len(registeredClients), 1,
+                                 "The expected length of RegisteredClients is 1. List has the wrong size.")
+
+            # Validate entry values
+            asserts.assert_equal(
+                registeredClients[0].checkInNodeID, client2.checkInNodeID, "The read attribute does not match the registered value.")
+            asserts.assert_equal(
+                registeredClients[0].monitoredSubject, client2.subjectId, "The read attribute does not match the registered value.")
+            asserts.assert_equal(
+                registeredClients[0].clientType, client2.clientType, "The read attribute does not match the registered value.")
+
+            self.step("4a")
+            try:
+                await self._send_single_icdm_command(commands.RegisterClient(checkInNodeID=client3.checkInNodeID, monitoredSubject=client3.subjectId, key=client3.key, clientType=client3.clientType, verificationKey=kInvalidKey))
+            except InteractionModelError as e:
+                asserts.assert_equal(
+                    e.status, Status.Success, "Unexpected error returned")
+
+            self.step("4b")
+            registeredClients = await self._read_icdm_attribute_expect_success(
+                attributes.RegisteredClients)
+            # Validate list size
+            asserts.assert_equal(len(registeredClients), 1,
+                                 "The expected length of RegisteredClients is 1. List has the wrong size.")
+
+            # Validate entry values
+            asserts.assert_equal(
+                registeredClients[0].checkInNodeID, client3.checkInNodeID, "The read attribute does not match the registered value.")
+            asserts.assert_equal(
+                registeredClients[0].monitoredSubject, client3.subjectId, "The read attribute does not match the registered value.")
+            asserts.assert_equal(
+                registeredClients[0].clientType, client3.clientType, "The read attribute does not match the registered value.")
+
+            self.step("5a")
+            try:
+                await self._send_single_icdm_command(commands.RegisterClient(checkInNodeID=client4.checkInNodeID, monitoredSubject=client4.subjectId, key=client4.key, clientType=client4.clientType, verificationKey=kIncorrectKey))
+            except InteractionModelError as e:
+                asserts.assert_equal(
+                    e.status, Status.Success, "Unexpected error returned")
+
+            self.step("5b")
+            registeredClients = await self._read_icdm_attribute_expect_success(
+                attributes.RegisteredClients)
+            # Validate list size
+            asserts.assert_equal(len(registeredClients), 1,
+                                 "The expected length of RegisteredClients is 1. List has the wrong size.")
+
+            # Validate entry values
+            asserts.assert_equal(
+                registeredClients[0].checkInNodeID, client4.checkInNodeID, "The read attribute does not match the registered value.")
+            asserts.assert_equal(
+                registeredClients[0].monitoredSubject, client4.subjectId, "The read attribute does not match the registered value.")
+            asserts.assert_equal(
+                registeredClients[0].clientType, client4.clientType, "The read attribute does not match the registered value.")
+
+            self.step("6a")
+            try:
+                await self._send_single_icdm_command(commands.UnregisterClient(checkInNodeID=client4.checkInNodeID))
+            except InteractionModelError as e:
+                asserts.assert_equal(
+                    e.status, Status.Success, "Unexpected error returned")
+
+            self.step("6b")
+            registeredClients = await self._read_icdm_attribute_expect_success(
+                attributes.RegisteredClients)
+            asserts.assert_equal(len(registeredClients), 0,
+                                 "The RegisteredClients list must be empty. List has the wrong size.")
+
+            self.step(7)
+            ac = Clusters.AccessControl
+            previousAcl = await self.read_single_attribute_check_success(cluster=ac, attribute=ac.Attributes.Acl)
+            newAcls = []
+
+            # Set Admin permissions on Access Control cluster
+            newAclEntry = ac.Structs.AccessControlEntryStruct(privilege=ac.Enums.AccessControlEntryPrivilegeEnum.kAdminister,
+                                                              authMode=ac.Enums.AccessControlEntryAuthModeEnum.kCase,
+                                                              subjects=previousAcl[0].subjects, targets=[ac.Structs.AccessControlTargetStruct(
+                                                                  cluster=Clusters.AccessControl.id)], fabricIndex=previousAcl[0].fabricIndex
+                                                              )
+            newAcls.append(newAclEntry)
+
+            # Set Manage permissions on ICD Management cluster
+            newAclEntry = ac.Structs.AccessControlEntryStruct(privilege=ac.Enums.AccessControlEntryPrivilegeEnum.kManage,
+                                                              authMode=ac.Enums.AccessControlEntryAuthModeEnum.kCase,
+                                                              subjects=previousAcl[0].subjects, targets=[ac.Structs.AccessControlTargetStruct(
+                                                                  cluster=Clusters.IcdManagement.id)], fabricIndex=previousAcl[0].fabricIndex
+                                                              )
+            newAcls.append(newAclEntry)
+
+            try:
+                await self.default_controller.WriteAttribute(nodeid=self.dut_node_id, attributes=[(0, ac.Attributes.Acl(newAcls))])
+            except InteractionModelError as e:
+                asserts.assert_equal(
+                    e.status, Status.Success, "Unexpected error returned")
+
+            self.step("8a")
+            try:
+                await self._send_single_icdm_command(commands.RegisterClient(checkInNodeID=client5.checkInNodeID, monitoredSubject=client5.subjectId, key=client5.key, clientType=client5.clientType))
+            except InteractionModelError as e:
+                asserts.assert_equal(
+                    e.status, Status.Success, "Unexpected error returned")
+
+            self.step("8b")
+            try:
+                await self._send_single_icdm_command(commands.RegisterClient(checkInNodeID=client6.checkInNodeID, monitoredSubject=client6.subjectId, key=client6.key, clientType=client6.clientType, verificationKey=kInvalidKey))
+            except InteractionModelError as e:
+                asserts.assert_equal(
+                    e.status, Status.Failure, "Unexpected error returned")
+
+            self.step("8c")
+            try:
+                await self._send_single_icdm_command(commands.RegisterClient(checkInNodeID=client7.checkInNodeID, monitoredSubject=client7.subjectId, key=client7.key, clientType=client7.clientType, verificationKey=kIncorrectKey))
+            except InteractionModelError as e:
+                asserts.assert_equal(
+                    e.status, Status.Failure, "Unexpected error returned")
+
+            self.step("8d")
+            try:
+                await self._send_single_icdm_command(commands.RegisterClient(checkInNodeID=client8.checkInNodeID, monitoredSubject=client8.subjectId, key=client8.key, clientType=client8.clientType, verificationKey=client5.key))
+            except InteractionModelError as e:
+                asserts.assert_equal(
+                    e.status, Status.Success, "Unexpected error returned")
+
+            self.step(9)
+            try:
+                await self._send_single_icdm_command(commands.UnregisterClient(checkInNodeID=client8.checkInNodeID, verificationKey=client8.key))
+            except InteractionModelError as e:
+                asserts.assert_equal(
+                    e.status, Status.Success, "Unexpected error returned")
+
+        # Post-Condition steps
+        finally:
+            # Reset ACLs
+            try:
+                await self.default_controller.WriteAttribute(nodeid=self.dut_node_id, attributes=[(0, ac.Attributes.Acl(previousAcl))])
+            except InteractionModelError as e:
+                asserts.assert_equal(
+                    e.status, Status.Success, "Unexpected error returned")
+
+            # Clear all RegisteredClients
+            registeredClients = await self._read_icdm_attribute_expect_success(
+                attributes.RegisteredClients)
+
+            for client in registeredClients:
+                try:
+                    await self._send_single_icdm_command(commands.UnregisterClient(checkInNodeID=client.checkInNodeID))
+                except InteractionModelError as e:
+                    asserts.assert_equal(
+                        e.status, Status.Success, "Unexpected error returned")
+
+
+if __name__ == "__main__":
+    default_matter_test_main()