From 219e1980c751c1b5fba2ef33a47cd3b6ffb480b5 Mon Sep 17 00:00:00 2001 From: mkardous-silabs <84793247+mkardous-silabs@users.noreply.github.com> Date: Wed, 15 May 2024 23:01:00 -0400 Subject: [PATCH] [ICD] Add python script for ICDM 3.1 cert test (#33451) * Add python script for ICDM 3.1 cert test * Delete manual steps * Add script to CI * restyle * remove 3.1 from the manual tests --- .github/workflows/tests.yaml | 1 + .../certification/Test_TC_ICDM_3_1.yaml | 319 ------------------ src/app/tests/suites/manualTests.json | 1 - src/python_testing/TC_ICDM_3_1.py | 264 +++++++++++++++ 4 files changed, 265 insertions(+), 320 deletions(-) delete mode 100644 src/app/tests/suites/certification/Test_TC_ICDM_3_1.yaml create mode 100644 src/python_testing/TC_ICDM_3_1.py diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 58bdd2314c823a..57bc3971d44ea3 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -508,6 +508,7 @@ jobs: scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --app out/linux-x64-all-clusters-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-all-clusters-app --factoryreset --app-args "--discriminator 1234 --KVS kvs1 --trace-to json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script "src/python_testing/TC_FAN_3_4.py" --script-args "--storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"' scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --app out/linux-x64-all-clusters-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-all-clusters-app --factoryreset --app-args "--discriminator 1234 --KVS kvs1 --trace-to json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script "src/python_testing/TC_FAN_3_5.py" --script-args "--storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"' scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --app out/linux-x64-lit-icd-ipv6only-no-ble-no-wifi-tsan-clang-test/lit-icd-app --factoryreset --app-args "--discriminator 1234 --KVS kvs1 --trace-to json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script "src/python_testing/TC_ICDM_2_1.py" --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:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"' + scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --app out/linux-x64-lit-icd-ipv6only-no-ble-no-wifi-tsan-clang-test/lit-icd-app --factoryreset --app-args "--discriminator 1234 --KVS kvs1 --trace-to json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script "src/python_testing/TC_ICDM_3_1.py" --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:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"' scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --app out/linux-x64-lit-icd-ipv6only-no-ble-no-wifi-tsan-clang-test/lit-icd-app --factoryreset --app-args "--discriminator 1234 --KVS kvs1 --trace-to json:out/trace_data/app-{SCRIPT_BASE_NAME}.json --enable-key 000102030405060708090a0b0c0d0e0f" --script "src/python_testing/TC_ICDManagementCluster.py" --script-args "--storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --hex-arg enableKey:000102030405060708090a0b0c0d0e0f --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"' scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --app out/linux-x64-all-clusters-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-all-clusters-app --factoryreset --app-args "--discriminator 1234 --KVS kvs1 --trace-to json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script "src/python_testing/TC_IDM_1_2.py" --script-args "--storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"' scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --app out/linux-x64-all-clusters-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-all-clusters-app --factoryreset --app-args "--discriminator 1234 --KVS kvs1 --trace-to json:out/trace_data/app-{SCRIPT_BASE_NAME}.json --enable-key 000102030405060708090a0b0c0d0e0f" --script "src/python_testing/TC_IDM_1_4.py" --script-args "--hex-arg PIXIT.DGGEN.TEST_EVENT_TRIGGER_KEY:000102030405060708090a0b0c0d0e0f --storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"' diff --git a/src/app/tests/suites/certification/Test_TC_ICDM_3_1.yaml b/src/app/tests/suites/certification/Test_TC_ICDM_3_1.yaml deleted file mode 100644 index 365d820bccf00f..00000000000000 --- a/src/app/tests/suites/certification/Test_TC_ICDM_3_1.yaml +++ /dev/null @@ -1,319 +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.2. [TC-ICDM-3.1] Register/Unregister Clients with DUT as Server - -PICS: - - ICDM.S - - ICDM.S.F00 - - 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 0a: Preconfition 1: Read 'register-clients' by sending the - command below and note the check-in nodeID for the entries" - verification: | - ./chip-tool icdmanagement read registered-clients 1 0 - - [1704888897.027204][71644:71646] CHIP:DMG: } - [1704888897.027313][71644:71646] CHIP:TOO: Endpoint: 0 Cluster: 0x0000_0046 Attribute 0x0000_0003 DataVersion: 852105378 - [1704888897.027351][71644:71646] CHIP:TOO: RegisteredClients: 1 entries - [1704888897.027394][71644:71646] CHIP:TOO: [1]: { - [1704888897.027412][71644:71646] CHIP:TOO: CheckInNodeID: 112233 - [1704888897.027421][71644:71646] CHIP:TOO: MonitoredSubject: 112233 - [1704888897.027431][71644:71646] CHIP:TOO: FabricIndex: 1 - [1704888897.027440][71644:71646] CHIP:TOO: } - [1704888897.027521][71644:71646] CHIP:EM: <<< [E:49337i S:30873 M:176023643 (Ack:200282364)] (S) Msg TX to 1:0000000000000001 [5BF5] [UDP:[fe80::a70c:61dc:df51:6945%enxd03745ce8f62]:5540] --- Type 0000:10 (SecureChannel:StandaloneAck) - disabled: true - - - label: - "Step 0b: Preconfition 2: Please send the 'unregister client' command - using the check-in nodeID received from the previous read" - verification: | - ./chip-tool icdmanagement unregister-client 112233 1 0 - - [1704888949.629057][71657:71659] CHIP:DMG: - [1704888949.629066][71657:71659] CHIP:DMG: InteractionModelRevision = 11 - [1704888949.629074][71657:71659] CHIP:DMG: }, - [1704888949.629125][71657:71659] CHIP:DMG: Received Command Response Status for Endpoint=0 Cluster=0x0000_0046 Command=0x0000_0002 Status=0x0 - [1704888949.629153][71657:71659] CHIP:DMG: ICR moving to [AwaitingDe] - disabled: true - - - label: - "Step 0c: Preconfition 3: Verify that all entries have been - successfully unregistered by reading 'register-clients'" - verification: | - ./chip-tool icdmanagement read registered-clients 1 0 - [1704889092.945869][71700:71702] CHIP:DMG: } - [1704889092.945955][71700:71702] CHIP:TOO: Endpoint: 0 Cluster: 0x0000_0046 Attribute 0x0000_0003 DataVersion: 852105378 - [1704889092.945989][71700:71702] CHIP:TOO: RegisteredClients: 0 entries - [1704889092.946079][71700:71702] CHIP:EM: <<< [E:63454i S:39669 M:600516 (Ack:156383188)] (S) - disabled: true - - - label: - "Step 1: TH sends RegisterClient command. - CheckInNodeID: registering - clients node ID - MonitoredSubject: monitored subject ID - Key: shared - secret between the client and the ICD" - PICS: ICDM.S.C00.Rsp - verification: | - ./chip-tool icdmanagement register-client 1 1 hex:1234567890abcdef1234567890abcdef 1 0 - On TH(chip-tool) verify that DUT responds with status code as success - - [1687534883748] [49948:406768] [DMG] Received Command Response Data, Endpoint=0 Cluster=0x0000_0046 Command=0x0000_0001 - [1687534883748] [49948:406768] [TOO] Endpoint: 0 Cluster: 0x0000_0046 Command 0x0000_0001 - [1687534883748] [49948:406768] [TOO] RegisterClientResponse: { - [1687534883748] [49948:406768] [TOO] ICDCounter: 0 - [1687534883748] [49948:406768] [TOO] } - disabled: true - - - label: "Step 2: TH reads from the DUT the RegisteredClients attribute." - PICS: ICDM.S.A0003 - verification: | - ./chip-tool icdmanagement read registered-clients 1 0 - - On TH(Chip-tool), Verify that the DUT response contains a list of 1 registered client of given CheckInNodeID, MonitoredSubject, and Key - - [1689676816.943056][18202:18204] CHIP:DMG: } - [1689676816.943185][18202:18204] CHIP:TOO: Endpoint: 0 Cluster: 0x0000_0046 Attribute 0x0000_0003 DataVersion: 1824957093 - [1689676816.943237][18202:18204] CHIP:TOO: RegisteredClients: 2 entries - [1689676816.943266][18202:18204] CHIP:TOO: [1]: { - [1689676816.943273][18202:18204] CHIP:TOO: CheckInNodeID: 1 - [1689676816.943279][18202:18204] CHIP:TOO: MonitoredSubject: 1 - [1689676816.943288][18202:18204] CHIP:TOO: Key: 31323334353637383930616263646566 - [1689676816.943302][18202:18204] CHIP:TOO: FabricIndex: 1 - [1689676816.943309][18202:18204] CHIP:TOO: } - [1689676816.943411][18202:18204] CHIP:EM: <<< [E:57729i S:18360 M:263136445 (Ack:51562449)] (S) Msg TX to 1:0000000000000001 [BFDE] --- Type 0000:10 (SecureChannel:StandaloneAck) - [1689676816.943425][18202:18204] CHIP:IN: (S) Sending msg 263136445 on secure session with LSID: 18360 - disabled: true - - - label: - "Step 3a: TH reads from the DUT the - ICDM.S.A0005(ClientsSupportedPerFabric) attribute." - PICS: ICDM.S.A0005 - verification: | - ./chip-tool icdmanagement read clients-supported-per-fabric 1 0 - - [1689676851.025335][18210:18212] CHIP:DMG: } - [1689676851.025406][18210:18212] CHIP:TOO: Endpoint: 0 Cluster: 0x0000_0046 Attribute 0x0000_0005 DataVersion: 1824957093 - [1689676851.025433][18210:18212] CHIP:TOO: ClientsSupportedPerFabric: 2 - [1689676851.025500][18210:18212] CHIP:EM: <<< [E:302i S:21595 M:237990169 (Ack:268232015)] (S) Msg TX to 1:0000000000000001 [BFDE] --- Type 0000:10 (SecureChannel:StandaloneAck) - [1689676851.025513][18210:18212] CHIP:IN: (S) Sending msg 237990169 on secure session with LSID: 21595 - [1689676851.025540][18210:18212] CHIP:EM: Flushed pending ack for MessageCounter:268232015 on exchange 302i - disabled: true - - - label: - "Step 3b: If len(RegisteredClients) is less than - ClientsSupportedPerFabric, TH repeats RegisterClient command with a - different CheckInNodeID until the number of entries in - RegisteredClients equals ClientsSupportedPerFabric." - PICS: ICDM.S.C00.Rsp - verification: | - ./chip-tool icdmanagement register-client 2 2 hex:2234567890abcdef2234567890abcdef 1 0 - - On TH(chip-tool) verify that DUT responds with status code as success - - [1687535275413] [50580:413095] [DMG] Received Command Response Data, Endpoint=0 Cluster=0x0000_0046 Command=0x0000_0001 - [1687535275413] [50580:413095] [TOO] Endpoint: 0 Cluster: 0x0000_0046 Command 0x0000_0001 - [1687535275413] [50580:413095] [TOO] RegisterClientResponse: { - [1687535275413] [50580:413095] [TOO] ICDCounter: 0 - [1687535275413] [50580:413095] [TOO] } - disabled: true - - - label: - "Step 3c: TH sends RegisterClient command with a different - CheckInNodeID." - PICS: ICDM.S.C00.Rsp - verification: | - ./chip-tool icdmanagement register-client 10 20 hex:abcdef1234567890abcdef1234567890 1 0 - - On TH(chip-tool) verify that DUT responds with status as RESOURCE_EXHAUSTED(0x89) - - [1687535364276] [50673:414417] [DMG] Received Command Response Status for Endpoint=0 Cluster=0x0000_0046 Command=0x0000_0000 Status=0x89 - [1687535364276] [50673:414417] [TOO] Error: IM Error 0x00000589: General error: 0x89 (RESOURCE_EXHAUSTED) - disabled: true - - - label: "Step 4: TH reads from the DUT the RegisteredClients attribute." - PICS: ICDM.S.A0003 - verification: | - ./chip-tool icdmanagement read registered-clients 1 0 - On TH(chip-tool), Verify that the DUT response contains a list of registered clients from Step 1 and 3b; each entry contains CheckInNodeID, MonitoredSubject, and Key. - - [1689676880.681118][18221:18223] CHIP:DMG: } - [1689676880.681246][18221:18223] CHIP:TOO: Endpoint: 0 Cluster: 0x0000_0046 Attribute 0x0000_0003 DataVersion: 1824957093 - [1689676880.681292][18221:18223] CHIP:TOO: RegisteredClients: 2 entries - [1689676880.681320][18221:18223] CHIP:TOO: [1]: { - [1689676880.681334][18221:18223] CHIP:TOO: CheckInNodeID: 1 - [1689676880.681341][18221:18223] CHIP:TOO: MonitoredSubject: 1 - [1689676880.681349][18221:18223] CHIP:TOO: Key: 31323334353637383930616263646566 - [1689676880.681357][18221:18223] CHIP:TOO: FabricIndex: 1 - [1689676880.681363][18221:18223] CHIP:TOO: } - [1689676880.681373][18221:18223] CHIP:TOO: [2]: { - [1689676880.681378][18221:18223] CHIP:TOO: CheckInNodeID: 2 - [1689676880.681384][18221:18223] CHIP:TOO: MonitoredSubject: 2 - [1689676880.681390][18221:18223] CHIP:TOO: Key: 32323334353637383930616263646566 - [1689676880.681396][18221:18223] CHIP:TOO: FabricIndex: 1 - [1689676880.681401][18221:18223] CHIP:TOO: } - [1689676880.681461][18221:18223] CHIP:EM: <<< [E:58454i S:61329 M:203963160 (Ack:146764558)] (S) Msg TX to 1:0000000000000001 [BFDE] --- Type 0000:10 (SecureChannel:StandaloneAck) - [1689676880.681475][18221:18223] CHIP:IN: (S) Sending msg 203963160 on secure session with LSID: 61329 - [1689676880.681506][18221:18223] CHIP:EM: Flushed pending ack for MessageCounter:146764558 on exchange 58454i - [1689676880.681697][18221:18221] CHIP:CTL: Shutting down the commissioner - disabled: true - - - label: - "Step 5a: TH sends UnregisterClient command with a CheckInNodeID which - is not in the list of RegisteredClients from Step 4." - PICS: ICDM.S.C02.Rsp - verification: | - ./chip-tool icdmanagement unregister-client 10 1 0 - On TH(chip-tool) verify that DUT responds with status as NOT_FOUND(0x8b). - [1687535473821] [50706:415574] [DMG] Received Command Response Status for Endpoint=0 Cluster=0x0000_0046 Command=0x0000_0002 Status=0x8b - [1687535473821] [50706:415574] [TOO] Error: IM Error 0x0000058B: General error: 0x8b (NOT_FOUND) - disabled: true - - - label: - "Step 5b: TH sends UnregisterClient command with the CheckInNodeID - from Step 1." - PICS: ICDM.S.C02.Rsp - verification: | - ./chip-tool icdmanagement unregister-client 1 1 0 - On TH(chip-tool) verify that DUT responds with status as SUCCESS(0x00). - [1689764286.310839][26236:26241] CHIP:DMG: InvokeResponseMessage = - [1689764286.310843][26236:26241] CHIP:DMG: { - [1689764286.310848][26236:26241] CHIP:DMG: suppressResponse = false, - [1689764286.310852][26236:26241] CHIP:DMG: InvokeResponseIBs = - [1689764286.310859][26236:26241] CHIP:DMG: [ - [1689764286.310863][26236:26241] CHIP:DMG: InvokeResponseIB = - [1689764286.310871][26236:26241] CHIP:DMG: { - [1689764286.310875][26236:26241] CHIP:DMG: CommandStatusIB = - [1689764286.310880][26236:26241] CHIP:DMG: { - [1689764286.310885][26236:26241] CHIP:DMG: CommandPathIB = - [1689764286.310891][26236:26241] CHIP:DMG: { - [1689764286.310896][26236:26241] CHIP:DMG: EndpointId = 0x0, - [1689764286.310901][26236:26241] CHIP:DMG: ClusterId = 0x46, - [1689764286.310906][26236:26241] CHIP:DMG: CommandId = 0x2, - [1689764286.310911][26236:26241] CHIP:DMG: }, - [1689764286.310919][26236:26241] CHIP:DMG: - [1689764286.310922][26236:26241] CHIP:DMG: StatusIB = - [1689764286.310928][26236:26241] CHIP:DMG: { - [1689764286.310932][26236:26241] CHIP:DMG: status = 0x00 (SUCCESS), - [1689764286.310936][26236:26241] CHIP:DMG: }, - [1689764286.310941][26236:26241] CHIP:DMG: - [1689764286.310945][26236:26241] CHIP:DMG: }, - [1689764286.310951][26236:26241] CHIP:DMG: - [1689764286.310955][26236:26241] CHIP:DMG: }, - [1689764286.310962][26236:26241] CHIP:DMG: - [1689764286.310966][26236:26241] CHIP:DMG: ], - [1689764286.310972][26236:26241] CHIP:DMG: - [1689764286.310976][26236:26241] CHIP:DMG: InteractionModelRevision = 1 - [1689764286.310980][26236:26241] CHIP:DMG: }, - [1689764286.311002][26236:26241] CHIP:DMG: Received Command Response Status for Endpoint=0 Cluster=0x0000_0046 Command=0x0000_0002 Status=0x0 - [1689764286.311020][26236:26241] CHIP:DMG: ICR moving to [AwaitingDe] - [1689764286.311060][26236:26241] CHIP:EM: <<< [E:63413i S:31018 M:161228496 (Ack:98843769)] (S) Msg TX to 1:0000000000000001 [D397] --- Type 0000:10 (SecureChannel:StandaloneAck) - [1689764286.311069][26236:26241] CHIP:IN: (S) Sending msg 161228496 on secure session with LSID: 31018 - [1689764286.311093][26236:26241] CHIP:EM: Flushed pending ack for MessageCounter:98843769 on exchange 63413i - disabled: true - - - label: - "Step 5c: Repeat Step 5b with the rest of CheckInNodeIDs from the list - of RegisteredClients from Step 4, if any." - PICS: ICDM.S.C02.Rsp - verification: | - ./chip-tool icdmanagement unregister-client 2 1 0 - On TH(chip-tool) verify that DUT responds with status as SUCCESS(0x00). - - [1689764308.632783][26647:26650] CHIP:DMG: ICR moving to [ResponseRe] - [1689764308.632806][26647:26650] CHIP:DMG: InvokeResponseMessage = - [1689764308.632816][26647:26650] CHIP:DMG: { - [1689764308.632826][26647:26650] CHIP:DMG: suppressResponse = false, - [1689764308.632842][26647:26650] CHIP:DMG: InvokeResponseIBs = - [1689764308.632864][26647:26650] CHIP:DMG: [ - [1689764308.632878][26647:26650] CHIP:DMG: InvokeResponseIB = - [1689764308.632899][26647:26650] CHIP:DMG: { - [1689764308.632918][26647:26650] CHIP:DMG: CommandStatusIB = - [1689764308.632941][26647:26650] CHIP:DMG: { - [1689764308.632982][26647:26650] CHIP:DMG: CommandPathIB = - [1689764308.633008][26647:26650] CHIP:DMG: { - [1689764308.633028][26647:26650] CHIP:DMG: EndpointId = 0x0, - [1689764308.633056][26647:26650] CHIP:DMG: ClusterId = 0x46, - [1689764308.633080][26647:26650] CHIP:DMG: CommandId = 0x2, - [1689764308.633103][26647:26650] CHIP:DMG: }, - [1689764308.633129][26647:26650] CHIP:DMG: - [1689764308.633151][26647:26650] CHIP:DMG: StatusIB = - [1689764308.633176][26647:26650] CHIP:DMG: { - [1689764308.633201][26647:26650] CHIP:DMG: status = 0x00 (SUCCESS), - [1689764308.633228][26647:26650] CHIP:DMG: }, - [1689764308.633252][26647:26650] CHIP:DMG: - [1689764308.633273][26647:26650] CHIP:DMG: }, - [1689764308.633295][26647:26650] CHIP:DMG: - [1689764308.633311][26647:26650] CHIP:DMG: }, - [1689764308.633331][26647:26650] CHIP:DMG: - [1689764308.633345][26647:26650] CHIP:DMG: ], - [1689764308.633363][26647:26650] CHIP:DMG: - [1689764308.633383][26647:26650] CHIP:DMG: InteractionModelRevision = 1 - [1689764308.633413][26647:26650] CHIP:DMG: }, - [1689764308.633514][26647:26650] CHIP:DMG: Received Command Response Status for Endpoint=0 Cluster=0x0000_0046 Command=0x0000_0002 Status=0x0 - [1689764308.633536][26647:26650] CHIP:DMG: ICR moving to [AwaitingDe] - disabled: true - - - label: "Step 6: TH reads from the DUT the RegisteredClients attribute." - PICS: ICDM.S.A0003 - verification: | - ./chip-tool icdmanagement read registered-clients 1 0 - On TH(chip-tool) Verify that the DUT response contains empty list of registered clients. - - [1689764322.761414][26808:26810] CHIP:DMG: } - [1689764322.761506][26808:26810] CHIP:TOO: Endpoint: 0 Cluster: 0x0000_0046 Attribute 0x0000_0003 DataVersion: 1750818309 - [1689764322.761629][26808:26810] CHIP:TOO: RegisteredClients: 0 entries - [1689764322.761723][26808:26810] CHIP:EM: <<< [E:36669i S:5946 M:161762028 (Ack:88110606)] (S) Msg TX to 1:0000000000000001 [D397] --- Type 0000:10 (SecureChannel:StandaloneAck) - [1689764322.761742][26808:26810] CHIP:IN: (S) Sending msg 161762028 on secure session with LSID: 5946 - [1689764322.761775][26808:26810] CHIP:EM: Flushed pending ack for MessageCounter:88110606 on exchange 36669i - disabled: true - - - label: - "Step 7: TH sends UnregisterClient command with the CheckInNodeID from - Step 1." - PICS: ICDM.S.C02.Rsp - verification: | - ./chip-tool icdmanagement unregister-client 1 1 0 - On TH(chip-tool) verify that DUT responds with status as NOT_FOUND(0x8b) - - [1689764335.957449][27077:27079] CHIP:DMG: }, - [1689764335.957456][27077:27079] CHIP:DMG: - [1689764335.957460][27077:27079] CHIP:DMG: ], - [1689764335.957468][27077:27079] CHIP:DMG: - [1689764335.957472][27077:27079] CHIP:DMG: InteractionModelRevision = 1 - [1689764335.957476][27077:27079] CHIP:DMG: }, - [1689764335.957497][27077:27079] CHIP:DMG: Received Command Response Status for Endpoint=0 Cluster=0x0000_0046 Command=0x0000_0002 Status=0x8b - [1689764335.957513][27077:27079] CHIP:TOO: Error: IM Error 0x0000058B: General error: 0x8b (NOT_FOUND) - [1689764335.957525][27077:27079] CHIP:DMG: ICR moving to [AwaitingDe] - [1689764335.957567][27077:27079] CHIP:EM: <<< [E:17566i S:36201 M:3097260 (Ack:169314533)] (S) Msg TX to 1:0000000000000001 [D397] --- Type 0000:10 (SecureChannel:StandaloneAck) - [1689764335.957578][27077:27079] CHIP:IN: (S) Sending msg 3097260 on secure session with LSID: 36201 - [1689764335.957604][27077:27079] CHIP:EM: Flushed pending ack for MessageCounter:169314533 on exchange 17566i - [1689764335.957677][27077:27077] CHIP:CTL: Shutting down the commissioner - disabled: true diff --git a/src/app/tests/suites/manualTests.json b/src/app/tests/suites/manualTests.json index 7472f56588b61d..0331f9eba773df 100644 --- a/src/app/tests/suites/manualTests.json +++ b/src/app/tests/suites/manualTests.json @@ -120,7 +120,6 @@ "GeneralDiagnostics": ["Test_TC_DGGEN_2_2"], "Identify": ["Test_TC_I_3_2"], "IcdManagement": [ - "Test_TC_ICDM_3_1", "Test_TC_ICDM_3_2", "Test_TC_ICDM_3_3", "Test_TC_ICDM_4_1", diff --git a/src/python_testing/TC_ICDM_3_1.py b/src/python_testing/TC_ICDM_3_1.py new file mode 100644 index 00000000000000..87bd7a740ba786 --- /dev/null +++ b/src/python_testing/TC_ICDM_3_1.py @@ -0,0 +1,264 @@ + +# +# 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. +# +import logging +import os + +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__) + +kRootEndpointId = 0 + +cluster = Clusters.Objects.IcdManagement +commands = cluster.Commands +monitoredRegistration = cluster.Structs.MonitoringRegistrationStruct + + +# Step 2 Registration entry +kStep2CheckInNodeId = 101 +kStep2MonitoredSubjectStep2 = 1001 +kStep2Key = b"\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f" + + +class TC_ICDM_3_1(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_1(self) -> str: + """Returns a description of this test""" + return "[TC-ICDM-3.1] Register/Unregister Clients with DUT as Server" + + def steps_TC_ICDM_3_1(self) -> list[TestStep]: + steps = [ + TestStep("0a", "Commissioning, already done", + is_commissioning=True), + TestStep( + "0b", "TH reads from the DUT the RegisteredClients attribute. RegisteredClients is empty."), + TestStep( + "1a", "TH reads from the DUT the ClientsSupportedPerFabric attribute."), + TestStep( + "1b", "TH reads from the DUT the ICDCounter attribute."), + TestStep(2, "TH sends RegisterClient command."), + TestStep(3, "TH reads from the DUT the RegisteredClients attribute."), + TestStep( + 4, "If len(RegisteredClients) is less than ClientsSupportedPerFabric, TH repeats RegisterClient command with different CheckInNodeID(s) until the number of entries in RegisteredClients equals ClientsSupportedPerFabric."), + TestStep(5, "TH reads from the DUT the RegisteredClients attribute."), + TestStep( + 6, "TH sends RegisterClient command with a different CheckInNodeID."), + TestStep( + 7, "TTH sends UnregisterClient command with the CheckInNodeID from Step 6."), + TestStep( + 8, "TH sends UnregisterClient command with the CheckInNodeID from Step 2."), + TestStep( + 9, "TH reads from the DUT the RegisteredClients attribute."), + TestStep( + 10, "Repeat Step 9 with the rest of CheckInNodeIDs from the list of RegisteredClients from Step 4, if any."), + TestStep(11, "TH reads from the DUT the RegisteredClients attribute."), + TestStep( + 12, "TH sends UnregisterClient command with the CheckInNodeID from Step 2."), + ] + return steps + + def pics_TC_ICDM_3_1(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.1 Test Body + # + + @async_test_body + async def test_TC_ICDM_3_1(self): + + cluster = Clusters.Objects.IcdManagement + attributes = cluster.Attributes + + # Pre-Condition: Commissioning + self.step("0a") + + # Pre-Condition: Empty RegisteredClients attribute for all registrations + self.step("0b") + 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") + pass + + self.step("1a") + if self.pics_guard(self.check_pics("ICDM.S.A0005")): + clientsSupportedPerFabric = await self._read_icdm_attribute_expect_success( + attributes.ClientsSupportedPerFabric) + + self.step("1b") + if self.pics_guard(self.check_pics("ICDM.S.A0005")): + icdCounter = await self._read_icdm_attribute_expect_success(attributes.ICDCounter) + + self.step(2) + if self.pics_guard(self.check_pics("ICDM.S.C00.Rsp")): + try: + response = await self._send_single_icdm_command(commands.RegisterClient(checkInNodeID=kStep2CheckInNodeId, monitoredSubject=kStep2MonitoredSubjectStep2, key=kStep2Key)) + except InteractionModelError as e: + asserts.assert_equal( + e.status, Status.Success, "Unexpected error returned") + pass + + # Validate response contains the ICDCounter + asserts.assert_greater_equal(response.ICDCounter, icdCounter, + "The ICDCounter in the response does not match the read ICDCounter.") + + self.step(3) + if self.pics_guard(self.check_pics("ICDM.S.A0003")): + 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, kStep2CheckInNodeId, "The read attribute does not match the registered value.") + asserts.assert_equal( + registeredClients[0].monitoredSubject, kStep2MonitoredSubjectStep2, "The read attribute does not match the registered value.") + + self.step(4) + if self.pics_guard(self.check_pics("ICDM.S.C00.Rsp")): + if (len(registeredClients) < clientsSupportedPerFabric): + newClients = [] + # Generate new clients data + for i in range(clientsSupportedPerFabric - len(registeredClients)): + newClients.append({ + "checkInNodeID": i + 1, + "monitoredSubject": i + 1, + "key": os.urandom(16) + }) + + for client in newClients: + try: + response = await self._send_single_icdm_command(commands.RegisterClient(checkInNodeID=client["checkInNodeID"], monitoredSubject=client["monitoredSubject"], key=client["key"])) + except InteractionModelError as e: + asserts.assert_equal( + e.status, Status.Success, "Unexpected error returned") + pass + + # Validate response contains the ICDCounter + asserts.assert_greater_equal(response.ICDCounter, icdCounter, + "The ICDCounter in the response does not match the read ICDCounter.") + + self.step(5) + if self.pics_guard(self.check_pics("ICDM.S.A0003")): + registeredClients = await self._read_icdm_attribute_expect_success( + attributes.RegisteredClients) + + # Validate list size + asserts.assert_equal(len(registeredClients[1:]), len(newClients), + "The expected length of RegisteredClients is clientsSupportedPerFabric. List has the wrong size.") + + for client, expectedClient in zip(registeredClients[1:], newClients): + asserts.assert_equal( + client.checkInNodeID, expectedClient["checkInNodeID"], "The read attribute does not match the registered value.") + asserts.assert_equal( + client.monitoredSubject, expectedClient["monitoredSubject"], "The read attribute does not match the registered value.") + + self.step(6) + if self.pics_guard(self.check_pics("ICDM.S.C00.Rsp")): + try: + response = await self._send_single_icdm_command(commands.RegisterClient(checkInNodeID=0xFFFF, monitoredSubject=0xFFFF, key=os.urandom(16))) + except InteractionModelError as e: + asserts.assert_equal( + e.status, Status.ResourceExhausted, "Unexpected error returned") + pass + + self.step(7) + if self.pics_guard(self.check_pics("ICDM.S.C02.Rsp")): + try: + await self._send_single_icdm_command(commands.UnregisterClient(checkInNodeID=0xFFFF)) + except InteractionModelError as e: + asserts.assert_equal( + e.status, Status.NotFound, "Unexpected error returned") + pass + + self.step(8) + if self.pics_guard(self.check_pics("ICDM.S.C02.Rsp")): + try: + await self._send_single_icdm_command(commands.UnregisterClient(checkInNodeID=kStep2CheckInNodeId)) + except InteractionModelError as e: + asserts.assert_equal( + e.status, Status.Success, "Unexpected error returned") + pass + + self.step(9) + if self.pics_guard(self.check_pics("ICDM.S.A0003")): + registeredClients = await self._read_icdm_attribute_expect_success( + attributes.RegisteredClients) + + for client in registeredClients: + asserts.assert_not_equal(client.checkInNodeID, kStep2CheckInNodeId, + "CheckInNodeID was unregistered. It should not be present in the attribute list.") + + self.step(10) + if self.pics_guard(self.check_pics("ICDM.S.C02.Rsp")): + for client in newClients: + 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") + pass + + self.step(11) + if self.pics_guard(self.check_pics("ICDM.S.A0003")): + registeredClients = await self._read_icdm_attribute_expect_success( + attributes.RegisteredClients) + + asserts.assert_true( + not registeredClients, "This list should empty. An element did not get deleted.") + + self.step(12) + if self.pics_guard(self.check_pics("ICDM.S.C02.Rsp")): + try: + await self._send_single_icdm_command(commands.UnregisterClient(checkInNodeID=kStep2CheckInNodeId)) + except InteractionModelError as e: + asserts.assert_equal( + e.status, Status.NotFound, "Unexpected error returned") + pass + + +if __name__ == "__main__": + default_matter_test_main()