# Copyright (c) 2021 Project CHIP Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Auto-generated scripts for harness use only, please review before automation. The endpoints and cluster names are currently set to default

name:
    32.6.4. [TC-IDM-6.4] Events Subscribe Interaction from DUT to TH. [DUT as
    Client]

PICS:
    - MCORE.IDM.C.SubscribeRequest

config:
    nodeId: 0x12344321
    cluster: "Basic Information"
    endpoint: 0

tests:
    - label: "Note"
      verification: |
          1. The Cluster and Commands should be based on the cluster implementation on the DUT.
          2. The cluster used in the below test steps is an example, User can use any supported chip cluster/attribute/command.
      disabled: true

    - label: "Note"
      verification: |
          Chip-tool command used below are an example to verify the  DUT as client test cases. For certification test, we expect DUT should have a capability or way to run the equivalent command.
      disabled: true

    - label: "Precondition"
      verification: |
          1. Please use Interactive mode to Verify subscription test cases
          2. Here the command to enter interactive mode:--   ./chip-tool interactive start
      disabled: true

    - label:
          "Step 1: DUT sends Subscribe Request Message to the TH for a supported
          event."
      verification: |
          basicinformation subscribe-event start-up 10 100 1 0

          On TH (On the reference app), On reference app verify that  the subscription message received has the all fields which mentioned below
           KeepSubscriptions which is of type bool.
           MinIntervalFloor which is of type uint16.
           MaxIntervalCeiling which is of type uint16.
           EventRequests - list of request paths to cluster events. Should be a valid EventPathIB from the Valid Event Paths table and not target a group.
           EventFilters - list of minimum event numbers per specific node. (Optional)
           FabricFiltered which is of type bool.

          [1657455555.193832][11525:11525] CHIP:EM: Handling via exchange: 33689r, Delegate: 0xaaaae00c1430
          [1657455555.193912][11525:11525] CHIP:IM: Received Subscribe request
          [1657455555.194063][11525:11525] CHIP:IM: Deleting previous subscription from NodeId: 000000000001B669, FabricIndex: 1
          [1657455555.194186][11525:11525] CHIP:DMG: SubscribeRequestMessage =
          [1657455555.194252][11525:11525] CHIP:DMG: {
          [1657455555.194312][11525:11525] CHIP:DMG:      KeepSubscriptions = false,
          [1657455555.194395][11525:11525] CHIP:DMG:      MinIntervalFloorSeconds = 0xa,
          [1657455555.194461][11525:11525] CHIP:DMG:      MaxIntervalCeilingSeconds = 0x64,
          [1657455555.194522][11525:11525] CHIP:DMG:      EventPathIBs =
          [1657455555.194586][11525:11525] CHIP:DMG:      [
          [1657455555.194646][11525:11525] CHIP:DMG:              EventPath =
          [1657455555.194708][11525:11525] CHIP:DMG:              {
          [1657455555.194776][11525:11525] CHIP:DMG:                      Endpoint = 0x0,
          [1657455555.194853][11525:11525] CHIP:DMG:                      Cluster = 0x28,
          [1657455555.194931][11525:11525] CHIP:DMG:                      Event = 0x0,
          [1657455555.195002][11525:11525] CHIP:DMG:              },
          [1657455555.195075][11525:11525] CHIP:DMG:
          [1657455555.195135][11525:11525] CHIP:DMG:      ],
          [1657455555.195202][11525:11525] CHIP:DMG:
          [1657455555.195263][11525:11525] CHIP:DMG:      isFabricFiltered = true,
          [1657455555.195325][11525:11525] CHIP:DMG:      InteractionModelRevision = 1
          [1657455555.195382][11525:11525] CHIP:DMG: },
          [1657455555.195593][11525:11525] CHIP:DMG: Final negotiated min/max parameters: Min = 10s, Max = 100s
          [1657455555.195766][11525:11525] CHIP:DMG: IM RH moving to [GeneratingReports]
          [1657455555.195955][11525:11525] CHIP:DMG: Building Reports for ReadHandler with LastReportGeneration = 0 DirtyGeneration = 0
      disabled: true

    - label:
          "Step 2: DUT sends Subscribe Request Message to the TH. TH sends
          Report Data message to DUT."
      verification: |
          Product maker needs to provide instructions for how to trigger the command on the DUT. For comparison, the DUT behavior for this test step can be simulated using chip-tool (when DUT is a commissioner/Client)

          basicinformation subscribe-event-by-id 0x000 20 400 1 0
          On TH (On the reference app), Verify DUT is responds with  status response  for the data sent in the above command
          6 from Retrans Table on exchange 33690r
          [1657455691.695355][11525:11525] CHIP:EM: Removed CHIP MessageCounter:11056066 from RetransTable on exchange 33690r
          [1657455691.695430][11525:11525] CHIP:DMG: StatusResponseMessage =
          [1657455691.695483][11525:11525] CHIP:DMG: {
          [1657455691.695510][11525:11525] CHIP:DMG:      Status = 0x00 (SUCCESS),
          [1657455691.695549][11525:11525] CHIP:DMG:      InteractionModelRevision = 1
          [1657455691.695574][11525:11525] CHIP:DMG: }
          [1657455691.695600][11525:11525] CHIP:IM: Received status response, status is 0x00 (SUCCESS)
          [1657455691.695643][11525:11525] CHIP:DMG: Refresh Subscribe Sync Timer with max 400 seconds
      disabled: true

    - label:
          "Step 3: DUT sends Subscribe Request Message to the TH and TH does not
          respond with Report Data message to DUT."
      verification: |
          Mark this as not testable /NA. Out of Scope for V1.0
      disabled: true

    - label:
          "Step 4: DUT sends Subscribe Request Message to the TH. TH sends
          Report Data message to DUT. DUT sends Status Response Message to the
          TH. TH does not respond with Subscribe Response message to DUT."
      verification: |
          Mark this as not testable /NA. Out of Scope for V1.0
      disabled: true

    - label:
          "Step 5: With an active Event subscription from DUT to TH, TH sends
          Report Data message to DUT with an invalid SubscriptionId."
      verification: |
          Mark this as not testable /NA. Out of Scope for V1.0
      disabled: true

    - label:
          "Step 6: With an active Event subscription from DUT to TH, TH sends
          Report Data message to DUT after the maximum interval from the last
          Report Data."
      verification: |
          Mark this as not testable /NA. Out of Scope for V1.0
      disabled: true
