# 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: Door Lock Cluster Users and Credentials tests

config:
    nodeId: 0x12344321
    cluster: "Door Lock"
    endpoint: 1
    payload:
        type: char_string
        defaultValue: "MT:-24J0AFN00KA0648G00"
    discriminator:
        type: int16u
        defaultValue: 3840
    waitAfterCommissioning:
        type: int16u
        defaultValue: 1000
    PakeVerifier:
        type: octet_string
        defaultValue: "hex:b96170aae803346884724fe9a3b287c30330c2a660375d17bb205a8cf1aecb350457f8ab79ee253ab6a8e46bb09e543ae422736de501e3db37d441fe344920d09548e4c18240630c4ff4913c53513839b7c07fcc0627a1b8573a149fcd1fa466cf"

tests:
    - label: "Wait for the commissioned device to be retrieved"
      cluster: "DelayCommands"
      command: "WaitForCommissionee"
      arguments:
          values:
              - name: "nodeId"
                value: nodeId

    - label: "Read available user slot and verify response fields"
      command: "GetUser"
      arguments:
          values:
              - name: "UserIndex"
                value: 1
      response:
          values:
              - name: "UserIndex"
                value: 1
              - name: "UserName"
                value: null
              - name: "UserUniqueID"
                value: null
              - name: "UserStatus"
                value: null
              - name: "UserType"
                value: null
              - name: "CredentialRule"
                value: null
              - name: "Credentials"
                value: null
              - name: "CreatorFabricIndex"
                value: null
              - name: "LastModifiedFabricIndex"
                value: null
              - name: "NextUserIndex"
                value: null

    - label: "Get number of supported users and verify default value"
      command: "readAttribute"
      attribute: "NumberOfTotalUsersSupported"
      response:
          saveAs: NumberOfTotalUsersSupportedValue
          value: 10

    #
    # Commission to second fabric to facilitate testing SetCredential/SetUser fabric restrictions
    #
    - label: "Open Commissioning Window from alpha"
      endpoint: 0
      cluster: "Administrator Commissioning"
      command: "OpenCommissioningWindow"
      timedInteractionTimeoutMs: 10000
      arguments:
          values:
              - name: "CommissioningTimeout"
                value: 180
              - name: "PAKEPasscodeVerifier"
                value: PakeVerifier
              - name: "Discriminator"
                value: discriminator
              - name: "Iterations"
                value: 1000
              - name: "Salt"
                value: "SPAKE2P Key Salt"

    - label: "Waiting after opening commissioning window"
      cluster: "DelayCommands"
      command: "WaitForMs"
      arguments:
          values:
              - name: "ms"
                value: waitAfterCommissioning

    - label: "Commission from TH2"
      identity: "beta"
      endpoint: 0
      cluster: "CommissionerCommands"
      command: "PairWithCode"
      arguments:
          values:
              - name: "nodeId"
                value: nodeId
              - name: "payload"
                value: payload

    - label: "Wait for the commissioned device to be retrieved for TH2"
      endpoint: 0
      identity: beta
      cluster: "DelayCommands"
      command: "WaitForCommissionee"
      arguments:
          values:
              - name: "nodeId"
                value: nodeId

    - label: "Read fails for user with index 0"
      command: "GetUser"
      arguments:
          values:
              - name: "UserIndex"
                value: 0
      response:
          error: INVALID_COMMAND

    - label:
          "Read fails for user with index greater than Number Of Users Supported"
      command: "GetUser"
      arguments:
          values:
              - name: "UserIndex"
                value: NumberOfTotalUsersSupportedValue + 1
      response:
          error: INVALID_COMMAND

    - label: "Create new user with default parameters"
      command: "SetUser"
      timedInteractionTimeoutMs: 10000
      arguments:
          values:
              - name: "OperationType"
                value: 0
              - name: "UserIndex"
                value: 1
              - name: "UserName"
                value: null
              - name: "UserUniqueID"
                value: null
              - name: "UserStatus"
                value: null
              - name: "UserType"
                value: null
              - name: "CredentialRule"
                value: null

    - label: "Read the user back and verify its fields"
      command: "GetUser"
      arguments:
          values:
              - name: "UserIndex"
                value: 1
      response:
          values:
              - name: "UserIndex"
                value: 1
              - name: "UserName"
                value: ""
              - name: "UserUniqueID"
                value: null
              - name: "UserStatus"
                value: 1
              - name: "UserType"
                value: 0
              - name: "CredentialRule"
                value: 0
              - name: "Credentials"
                value: []
              - name: "CreatorFabricIndex"
                value: 1
              - name: "LastModifiedFabricIndex"
                value: 1
              - name: "NextUserIndex"
                value: null

    - label: "Set user at the occupied index fails with appropriate response"
      command: "SetUser"
      timedInteractionTimeoutMs: 10000
      arguments:
          values:
              - name: "OperationType"
                value: 0
              - name: "UserIndex"
                value: 1
              - name: "UserName"
                value: null
              - name: "UserUniqueID"
                value: null
              - name: "UserStatus"
                value: null
              - name: "UserType"
                value: null
              - name: "CredentialRule"
                value: null
      response:
          error: FAILURE

    - label: "Modify userName for existing user"
      command: "SetUser"
      timedInteractionTimeoutMs: 10000
      arguments:
          values:
              - name: "OperationType"
                value: 2
              - name: "UserIndex"
                value: 1
              - name: "UserName"
                value: "new_user"
              - name: "UserUniqueID"
                value: null
              - name: "UserStatus"
                value: null
              - name: "UserType"
                value: null
              - name: "CredentialRule"
                value: null

    - label: "Read the modified user back and verify its fields"
      command: "GetUser"
      arguments:
          values:
              - name: "UserIndex"
                value: 1
      response:
          values:
              - name: "UserIndex"
                value: 1
              - name: "UserName"
                value: "new_user"
              - name: "UserUniqueID"
                value: null
              - name: "UserStatus"
                value: 1
              - name: "UserType"
                value: 0
              - name: "CredentialRule"
                value: 0
              - name: "Credentials"
                value: []
              - name: "CreatorFabricIndex"
                value: 1
              - name: "LastModifiedFabricIndex"
                value: 1
              - name: "NextUserIndex"
                value: null

    - label: "Modify userUniqueId for existing user"
      command: "SetUser"
      timedInteractionTimeoutMs: 10000
      arguments:
          values:
              - name: "OperationType"
                value: 2
              - name: "UserIndex"
                value: 1
              - name: "UserName"
                value: null
              - name: "UserUniqueID"
                value: 0x1234ABCD
              - name: "UserStatus"
                value: null
              - name: "UserType"
                value: null
              - name: "CredentialRule"
                value: null

    - label: "Read the modified user back and verify its fields"
      command: "GetUser"
      arguments:
          values:
              - name: "UserIndex"
                value: 1
      response:
          values:
              - name: "UserIndex"
                value: 1
              - name: "UserName"
                value: "new_user"
              - name: "UserUniqueID"
                value: 0x1234ABCD
              - name: "UserStatus"
                value: 1
              - name: "UserType"
                value: 0
              - name: "CredentialRule"
                value: 0
              - name: "Credentials"
                value: []
              - name: "CreatorFabricIndex"
                value: 1
              - name: "LastModifiedFabricIndex"
                value: 1
              - name: "NextUserIndex"
                value: null

    - label: "Modify userStatus for existing user"
      command: "SetUser"
      timedInteractionTimeoutMs: 10000
      arguments:
          values:
              - name: "OperationType"
                value: 2
              - name: "UserIndex"
                value: 1
              - name: "UserName"
                value: null
              - name: "UserUniqueID"
                value: null
              - name: "UserStatus"
                value: 0x03 # Occupied, Disabled
              - name: "UserType"
                value: null
              - name: "CredentialRule"
                value: null

    - label: "Read the modified user back and verify its fields"
      command: "GetUser"
      arguments:
          values:
              - name: "UserIndex"
                value: 1
      response:
          values:
              - name: "UserIndex"
                value: 1
              - name: "UserName"
                value: "new_user"
              - name: "UserUniqueID"
                value: 0x1234ABCD
              - name: "UserStatus"
                value: 3
              - name: "UserType"
                value: 0
              - name: "CredentialRule"
                value: 0
              - name: "Credentials"
                value: []
              - name: "CreatorFabricIndex"
                value: 1
              - name: "LastModifiedFabricIndex"
                value: 1
              - name: "NextUserIndex"
                value: null

    - label: "Modify userType for existing user"
      command: "SetUser"
      timedInteractionTimeoutMs: 10000
      arguments:
          values:
              - name: "OperationType"
                value: 2
              - name: "UserIndex"
                value: 1
              - name: "UserName"
                value: null
              - name: "UserUniqueID"
                value: null
              - name: "UserStatus"
                value: null
              - name: "UserType"
                value: 0x06 # Disposable user
              - name: "CredentialRule"
                value: null

    - label: "Read the modified user back and verify its fields"
      command: "GetUser"
      arguments:
          values:
              - name: "UserIndex"
                value: 1
      response:
          values:
              - name: "UserIndex"
                value: 1
              - name: "UserName"
                value: "new_user"
              - name: "UserUniqueID"
                value: 0x1234ABCD
              - name: "UserStatus"
                value: 3
              - name: "UserType"
                value: 6
              - name: "CredentialRule"
                value: 0
              - name: "Credentials"
                value: []
              - name: "CreatorFabricIndex"
                value: 1
              - name: "LastModifiedFabricIndex"
                value: 1
              - name: "NextUserIndex"
                value: null

    - label: "Modify credentialRule for existing user"
      command: "SetUser"
      timedInteractionTimeoutMs: 10000
      arguments:
          values:
              - name: "OperationType"
                value: 2
              - name: "UserIndex"
                value: 1
              - name: "UserName"
                value: null
              - name: "UserUniqueID"
                value: null
              - name: "UserStatus"
                value: null
              - name: "UserType"
                value: null
              - name: "CredentialRule"
                value: 2

    - label: "Read the modified user back and verify its fields"
      command: "GetUser"
      arguments:
          values:
              - name: "UserIndex"
                value: 1
      response:
          values:
              - name: "UserIndex"
                value: 1
              - name: "UserName"
                value: "new_user"
              - name: "UserUniqueID"
                value: 0x1234ABCD
              - name: "UserStatus"
                value: 3
              - name: "UserType"
                value: 6
              - name: "CredentialRule"
                value: 2
              - name: "Credentials"
                value: []
              - name: "CreatorFabricIndex"
                value: 1
              - name: "LastModifiedFabricIndex"
                value: 1
              - name: "NextUserIndex"
                value: null

    - label: "Modify all fields for existing user"
      command: "SetUser"
      timedInteractionTimeoutMs: 10000
      arguments:
          values:
              - name: "OperationType"
                value: 2
              - name: "UserIndex"
                value: 1
              - name: "UserName"
                value: "test_user"
              - name: "UserUniqueID"
                value: 0x1BCDA0A0
              - name: "UserStatus"
                value: 1
              - name: "UserType"
                value: 0
              - name: "CredentialRule"
                value: 1

    - label: "Read the modified user back and verify its fields"
      command: "GetUser"
      arguments:
          values:
              - name: "UserIndex"
                value: 1
      response:
          values:
              - name: "UserIndex"
                value: 1
              - name: "UserName"
                value: "test_user"
              - name: "UserUniqueID"
                value: 0x1BCDA0A0
              - name: "UserStatus"
                value: 1
              - name: "UserType"
                value: 0
              - name: "CredentialRule"
                value: 1
              - name: "Credentials"
                value: []
              - name: "CreatorFabricIndex"
                value: 1
              - name: "LastModifiedFabricIndex"
                value: 1
              - name: "NextUserIndex"
                value: null

    - label:
          "Modify UserStatus, UserType, CredentialRule for existing user from
          different fabric"
      command: "SetUser"
      identity: "beta"
      timedInteractionTimeoutMs: 10000
      arguments:
          values:
              - name: "OperationType"
                value: 2
              - name: "UserIndex"
                value: 1
              - name: "UserName"
                value: null
              - name: "UserUniqueID"
                value: null
              - name: "UserStatus"
                value: 3
              - name: "UserType"
                value: 6
              - name: "CredentialRule"
                value: 2

    - label: "Read the modified user back and verify its fields"
      command: "GetUser"
      arguments:
          values:
              - name: "UserIndex"
                value: 1
      response:
          values:
              - name: "UserIndex"
                value: 1
              - name: "UserName"
                value: "test_user"
              - name: "UserUniqueID"
                value: 0x1BCDA0A0
              - name: "UserStatus"
                value: 3
              - name: "UserType"
                value: 6
              - name: "CredentialRule"
                value: 2
              - name: "Credentials"
                value: []
              - name: "CreatorFabricIndex"
                value: 1
              - name: "LastModifiedFabricIndex"
                value: 2
              - name: "NextUserIndex"
                value: null

    - label:
          "Attempt to modify UserName for existing user from different fabric"
      command: "SetUser"
      identity: "beta"
      timedInteractionTimeoutMs: 10000
      arguments:
          values:
              - name: "OperationType"
                value: 2
              - name: "UserIndex"
                value: 1
              - name: "UserName"
                value: "test_fab2"
              - name: "UserUniqueID"
                value: null
              - name: "UserStatus"
                value: null
              - name: "UserType"
                value: null
              - name: "CredentialRule"
                value: null
      response:
          error: INVALID_COMMAND

    - label:
          "Attempt to modify userUniqueId for existing user from different
          fabric"
      command: "SetUser"
      identity: "beta"
      timedInteractionTimeoutMs: 10000
      arguments:
          values:
              - name: "OperationType"
                value: 2
              - name: "UserIndex"
                value: 1
              - name: "UserName"
                value: null
              - name: "UserUniqueID"
                value: 0x1234ABCD
              - name: "UserStatus"
                value: null
              - name: "UserType"
                value: null
              - name: "CredentialRule"
                value: null
      response:
          error: INVALID_COMMAND

    - label: "Read the modified user back and verify its fields"
      command: "GetUser"
      arguments:
          values:
              - name: "UserIndex"
                value: 1
      response:
          values:
              - name: "UserIndex"
                value: 1
              - name: "UserName"
                value: "test_user"
              - name: "UserUniqueID"
                value: 0x1BCDA0A0
              - name: "UserStatus"
                value: 3
              - name: "UserType"
                value: 6
              - name: "CredentialRule"
                value: 2
              - name: "Credentials"
                value: []
              - name: "CreatorFabricIndex"
                value: 1
              - name: "LastModifiedFabricIndex"
                value: 2
              - name: "NextUserIndex"
                value: null

    - label: "Add another user with non-default fields"
      command: "SetUser"
      timedInteractionTimeoutMs: 10000
      arguments:
          values:
              - name: "OperationType"
                value: 0
              - name: "UserIndex"
                value: 2
              - name: "UserName"
                value: "test_user2"
              - name: "UserUniqueID"
                value: 0xC0FFEE
              - name: "UserStatus"
                value: 1
              - name: "UserType"
                value: 1
              - name: "CredentialRule"
                value: 2

    - label: "Read the new user back and verify its fields"
      command: "GetUser"
      arguments:
          values:
              - name: "UserIndex"
                value: 2
      response:
          values:
              - name: "UserIndex"
                value: 2
              - name: "UserName"
                value: "test_user2"
              - name: "UserUniqueID"
                value: 0xC0FFEE
              - name: "UserStatus"
                value: 1
              - name: "UserType"
                value: 1
              - name: "CredentialRule"
                value: 2
              - name: "Credentials"
                value: []
              - name: "CreatorFabricIndex"
                value: 1
              - name: "LastModifiedFabricIndex"
                value: 1
              - name: "NextUserIndex"
                value: null

    - label: "Try to add a user with userStatus 0"
      command: "SetUser"
      timedInteractionTimeoutMs: 10000
      arguments:
          values:
              - name: "OperationType"
                value: 0
              - name: "UserIndex"
                value: 3
              - name: "UserName"
                value: "test_user3"
              - name: "UserUniqueID"
                value: 0xBABA
              - name: "UserStatus"
                value: 0
              - name: "UserType"
                value: null
              - name: "CredentialRule"
                value: null
      response:
          error: INVALID_COMMAND

    - label: "Make sure the user did not get created"
      command: "GetUser"
      arguments:
          values:
              - name: "UserIndex"
                value: 3
      response:
          values:
              - name: "UserIndex"
                value: 3
              - name: "UserName"
                value: null
              - name: "UserUniqueID"
                value: null
              - name: "UserStatus"
                value: null
              - name: "UserType"
                value: null
              - name: "CredentialRule"
                value: null
              - name: "Credentials"
                value: null
              - name: "CreatorFabricIndex"
                value: null
              - name: "LastModifiedFabricIndex"
                value: null
              - name: "NextUserIndex"
                value: null

    - label: "Try to add a user with userStatus 2"
      command: "SetUser"
      timedInteractionTimeoutMs: 10000
      arguments:
          values:
              - name: "OperationType"
                value: 0
              - name: "UserIndex"
                value: 3
              - name: "UserName"
                value: "test_user3"
              - name: "UserUniqueID"
                value: 0xBABA
              - name: "UserStatus"
                value: UserStatusEnum.UnknownEnumValue(2)
              - name: "UserType"
                value: null
              - name: "CredentialRule"
                value: null
      response:
          error: INVALID_COMMAND

    - label: "Make sure the user did not get created"
      command: "GetUser"
      arguments:
          values:
              - name: "UserIndex"
                value: 3
      response:
          values:
              - name: "UserIndex"
                value: 3
              - name: "UserName"
                value: null
              - name: "UserUniqueID"
                value: null
              - name: "UserStatus"
                value: null
              - name: "UserType"
                value: null
              - name: "CredentialRule"
                value: null
              - name: "Credentials"
                value: null
              - name: "CreatorFabricIndex"
                value: null
              - name: "LastModifiedFabricIndex"
                value: null
              - name: "NextUserIndex"
                value: null

    - label: "Try to add a user with userStatus 3"
      command: "SetUser"
      timedInteractionTimeoutMs: 10000
      arguments:
          values:
              - name: "OperationType"
                value: 0
              - name: "UserIndex"
                value: 3
              - name: "UserName"
                value: "test_user3"
              - name: "UserUniqueID"
                value: 0xBABA
              - name: "UserStatus"
                value: 3
              - name: "UserType"
                value: null
              - name: "CredentialRule"
                value: null

    - label: "Read the new third user back and verify its fields"
      command: "GetUser"
      arguments:
          values:
              - name: "UserIndex"
                value: 3
      response:
          values:
              - name: "UserIndex"
                value: 3
              - name: "UserName"
                value: "test_user3"
              - name: "UserUniqueID"
                value: 0xBABA
              - name: "UserStatus"
                value: 3
              - name: "UserType"
                value: 0
              - name: "CredentialRule"
                value: 0
              - name: "Credentials"
                value: []
              - name: "CreatorFabricIndex"
                value: 1
              - name: "LastModifiedFabricIndex"
                value: 1
              - name: "NextUserIndex"
                value: null

    - label: "Create user in the last slot"
      command: "SetUser"
      timedInteractionTimeoutMs: 10000
      arguments:
          values:
              - name: "OperationType"
                value: 0
              - name: "UserIndex"
                value: NumberOfTotalUsersSupportedValue
              - name: "UserName"
                value: "last_user"
              - name: "UserUniqueID"
                value: null
              - name: "UserStatus"
                value: null
              - name: "UserType"
                value: null
              - name: "CredentialRule"
                value: null

    - label: "Read the last user back and verify its fields"
      command: "GetUser"
      arguments:
          values:
              - name: "UserIndex"
                value: NumberOfTotalUsersSupportedValue
      response:
          values:
              - name: "UserIndex"
                value: NumberOfTotalUsersSupportedValue
              - name: "UserName"
                value: "last_user"
              - name: "UserUniqueID"
                value: null
              - name: "UserStatus"
                value: 1
              - name: "UserType"
                value: 0
              - name: "CredentialRule"
                value: 0
              - name: "Credentials"
                value: []
              - name: "CreatorFabricIndex"
                value: 1
              - name: "LastModifiedFabricIndex"
                value: 1
              - name: "NextUserIndex"
                value: null

    - label: "User creation in the 0 slot fails"
      command: "SetUser"
      timedInteractionTimeoutMs: 10000
      arguments:
          values:
              - name: "OperationType"
                value: 0
              - name: "UserIndex"
                value: 0
              - name: "UserName"
                value: null
              - name: "UserUniqueID"
                value: null
              - name: "UserStatus"
                value: null
              - name: "UserType"
                value: null
              - name: "CredentialRule"
                value: null
      response:
          error: INVALID_COMMAND

    - label: "User creation in the out-of-bounds slot fails"
      command: "SetUser"
      timedInteractionTimeoutMs: 10000
      arguments:
          values:
              - name: "OperationType"
                value: 0
              - name: "UserIndex"
                value: NumberOfTotalUsersSupportedValue + 1
              - name: "UserName"
                value: null
              - name: "UserUniqueID"
                value: null
              - name: "UserStatus"
                value: null
              - name: "UserType"
                value: null
              - name: "CredentialRule"
                value: null
      response:
          error: INVALID_COMMAND

    - label: "Clear first user"
      command: "ClearUser"
      timedInteractionTimeoutMs: 10000
      arguments:
          values:
              - name: "UserIndex"
                value: 1

    - label: "Read cleared user and verify it is available"
      command: "GetUser"
      arguments:
          values:
              - name: "UserIndex"
                value: 1
      response:
          values:
              - name: "UserIndex"
                value: 1
              - name: "UserName"
                value: null
              - name: "UserUniqueID"
                value: null
              - name: "UserStatus"
                value: null
              - name: "UserType"
                value: null
              - name: "CredentialRule"
                value: null
              - name: "Credentials"
                value: null
              - name: "CreatorFabricIndex"
                value: null
              - name: "LastModifiedFabricIndex"
                value: null
              - name: "NextUserIndex"
                value: 2 # Slot 2 is still occupied

    - label: "Create new user in the cleared slot"
      command: "SetUser"
      timedInteractionTimeoutMs: 10000
      arguments:
          values:
              - name: "OperationType"
                value: 0
              - name: "UserIndex"
                value: 1
              - name: "UserName"
                value: null
              - name: "UserUniqueID"
                value: null
              - name: "UserStatus"
                value: null
              - name: "UserType"
                value: null
              - name: "CredentialRule"
                value: null

    - label:
          "Read the user in the previously cleared slot and verify its fields"
      command: "GetUser"
      arguments:
          values:
              - name: "UserIndex"
                value: 1
      response:
          values:
              - name: "UserIndex"
                value: 1
              - name: "UserName"
                value: ""
              - name: "UserUniqueID"
                value: null
              - name: "UserStatus"
                value: 1
              - name: "UserType"
                value: 0
              - name: "CredentialRule"
                value: 0
              - name: "Credentials"
                value: []
              - name: "CreatorFabricIndex"
                value: 1
              - name: "LastModifiedFabricIndex"
                value: 1
              - name: "NextUserIndex"
                value: 2 # Slot 2 is still occupied

    - label: "Clear user with index 0 fails"
      command: "ClearUser"
      timedInteractionTimeoutMs: 10000
      arguments:
          values:
              - name: "UserIndex"
                value: 0
      response:
          error: INVALID_COMMAND

    - label: "Clear user with out-of-bounds index fails"
      command: "ClearUser"
      timedInteractionTimeoutMs: 10000
      arguments:
          values:
              - name: "UserIndex"
                value: NumberOfTotalUsersSupportedValue + 1
      response:
          error: INVALID_COMMAND

    - label: "Clear all users"
      command: "ClearUser"
      timedInteractionTimeoutMs: 10000
      arguments:
          values:
              - name: "UserIndex"
                value: 0xFFFE

    - label: "Read first cleared user and verify it is available"
      command: "GetUser"
      arguments:
          values:
              - name: "UserIndex"
                value: 2
      response:
          values:
              - name: "UserIndex"
                value: 2
              - name: "UserName"
                value: null
              - name: "UserUniqueID"
                value: null
              - name: "UserStatus"
                value: null
              - name: "UserType"
                value: null
              - name: "CredentialRule"
                value: null
              - name: "Credentials"
                value: null
              - name: "CreatorFabricIndex"
                value: null
              - name: "LastModifiedFabricIndex"
                value: null
              - name: "NextUserIndex"
                value: null

    - label: "Read last cleared user and verify it is available"
      command: "GetUser"
      arguments:
          values:
              - name: "UserIndex"
                value: NumberOfTotalUsersSupportedValue
      response:
          values:
              - name: "UserIndex"
                value: NumberOfTotalUsersSupportedValue
              - name: "UserName"
                value: null
              - name: "UserUniqueID"
                value: null
              - name: "UserStatus"
                value: null
              - name: "UserType"
                value: null
              - name: "CredentialRule"
                value: null
              - name: "Credentials"
                value: null
              - name: "CreatorFabricIndex"
                value: null
              - name: "LastModifiedFabricIndex"
                value: null
              - name: "NextUserIndex"
                value: null

    #
    # Credentials tests
    #

    - label: "Get number of supported PIN credentials and verify default value"
      command: "readAttribute"
      attribute: "NumberOfPINUsersSupported"
      response:
          saveAs: NumberOfPINUsersSupportedValue
          value: 10

    - label: "Check that PIN credential does not exist"
      command: "GetCredentialStatus"
      arguments:
          values:
              - name: "Credential"
                value: { CredentialType: 1, CredentialIndex: 1 }
      response:
          values:
              - name: "CredentialExists"
                value: false
              - name: "UserIndex"
                value: null
              - name: "CreatorFabricIndex"
                value: null
              - name: "LastModifiedFabricIndex"
                value: null
              - name: "NextCredentialIndex"
                value: null

    - label: "Reading PIN credential with index 0 returns no credential"
      command: "GetCredentialStatus"
      arguments:
          values:
              - name: "Credential"
                value: { CredentialType: 1, CredentialIndex: 0 }
      response:
          values:
              - name: "CredentialExists"
                value: false
              - name: "UserIndex"
                value: null
              - name: "CreatorFabricIndex"
                value: null
              - name: "LastModifiedFabricIndex"
                value: null
              - name: "NextCredentialIndex"
                value: null

    - label:
          "Reading PIN credential with out-of-bounds index returns no credential"
      command: "GetCredentialStatus"
      arguments:
          values:
              - name: "Credential"
                value:
                    {
                        CredentialType: 1,
                        CredentialIndex: NumberOfPINUsersSupportedValue + 1,
                    }
      response:
          values:
              - name: "CredentialExists"
                value: false
              - name: "UserIndex"
                value: null
              - name: "CreatorFabricIndex"
                value: null
              - name: "LastModifiedFabricIndex"
                value: null
              - name: "NextCredentialIndex"
                value: null

    - label:
          "Verify that a user with UserStatus = 0 cannot be added via
          SetCredential"
      command: "SetCredential"
      timedInteractionTimeoutMs: 10000
      arguments:
          values:
              - name: "OperationType"
                value: 0
              - name: "Credential"
                value: { CredentialType: 1, CredentialIndex: 1 }
              - name: "CredentialData"
                value: "000000"
              - name: "UserIndex"
                value: null
              - name: "UserStatus"
                value: 0
              - name: "UserType"
                value: null
      response:
          values:
              - name: "Status"
                value: 0x85 # INVALID_COMMAND
              - name: "UserIndex"
                value: null
              - name: "NextCredentialIndex"
                value: 2

    - label:
          "Verify that a user with UserStatus = 2 cannot be added via
          SetCredential"
      command: "SetCredential"
      timedInteractionTimeoutMs: 10000
      arguments:
          values:
              - name: "OperationType"
                value: 0
              - name: "Credential"
                value: { CredentialType: 1, CredentialIndex: 1 }
              - name: "CredentialData"
                value: "000000"
              - name: "UserIndex"
                value: null
              - name: "UserStatus"
                value: UserStatusEnum.UnknownEnumValue(2)
              - name: "UserType"
                value: null
      response:
          values:
              - name: "Status"
                value: 0x85 # INVALID_COMMAND
              - name: "UserIndex"
                value: null
              - name: "NextCredentialIndex"
                value: 2

    - label: "Create new PIN credential and user"
      command: "SetCredential"
      timedInteractionTimeoutMs: 10000
      arguments:
          values:
              - name: "OperationType"
                value: 0
              - name: "Credential"
                value: { CredentialType: 1, CredentialIndex: 1 }
              - name: "CredentialData"
                value: "000000"
              - name: "UserIndex"
                value: null
              - name: "UserStatus"
                value: null
              - name: "UserType"
                value: null
      response:
          values:
              - name: "Status"
                value: 0x00
              - name: "UserIndex"
                value: 1
              - name: "NextCredentialIndex"
                value: 2

    - label: "Verify created user"
      command: "GetUser"
      arguments:
          values:
              - name: "UserIndex"
                value: 1
      response:
          values:
              - name: "UserIndex"
                value: 1
              - name: "UserName"
                value: ""
              - name: "UserUniqueID"
                value: null
              - name: "UserStatus"
                value: 1
              - name: "UserType"
                value: 0
              - name: "CredentialRule"
                value: 0
              - name: "Credentials"
                value: [{ CredentialType: 1, CredentialIndex: 1 }]
              - name: "CreatorFabricIndex"
                value: 1
              - name: "LastModifiedFabricIndex"
                value: 1
              - name: "NextUserIndex"
                value: null

    - label: "Verify created PIN credential"
      command: "GetCredentialStatus"
      arguments:
          values:
              - name: "Credential"
                value: { CredentialType: 1, CredentialIndex: 1 }
      response:
          values:
              - name: "CredentialExists"
                value: true
              - name: "UserIndex"
                value: 1
              - name: "CreatorFabricIndex"
                value: 1
              - name: "LastModifiedFabricIndex"
                value: 1
              - name: "NextCredentialIndex"
                value: null

    - label: "Create new PIN credential and user with index 0 fails"
      command: "SetCredential"
      timedInteractionTimeoutMs: 10000
      arguments:
          values:
              - name: "OperationType"
                value: 0
              - name: "Credential"
                value: { CredentialType: 1, CredentialIndex: 0 }
              - name: "CredentialData"
                value: "123456"
              - name: "UserIndex"
                value: null
              - name: "UserStatus"
                value: null
              - name: "UserType"
                value: null
      response:
          values:
              - name: "Status"
                value: 0x85
              - name: "UserIndex"
                value: null
              - name: "NextCredentialIndex"
                value: 2

    - label: "Create new PIN credential and user with out-of-bounds index fails"
      command: "SetCredential"
      timedInteractionTimeoutMs: 10000
      arguments:
          values:
              - name: "OperationType"
                value: 0
              - name: "Credential"
                value:
                    {
                        CredentialType: 1,
                        CredentialIndex: NumberOfPINUsersSupportedValue + 1,
                    }
              - name: "CredentialData"
                value: "123456"
              - name: "UserIndex"
                value: null
              - name: "UserStatus"
                value: null
              - name: "UserType"
                value: null
      response:
          values:
              - name: "Status"
                value: 0x85
              - name: "UserIndex"
                value: null
              - name: "NextCredentialIndex"
                value: null

    - label: "Get number of supported RFID credentials and verify default value"
      command: "readAttribute"
      attribute: "NumberOfRFIDUsersSupported"
      response:
          saveAs: NumberOfRFIDUsersSupportedValue
          value: 10

    - label: "Reading RFID credential with index 0 returns no credential"
      command: "GetCredentialStatus"
      arguments:
          values:
              - name: "Credential"
                value: { CredentialType: 2, CredentialIndex: 0 }
      response:
          values:
              - name: "CredentialExists"
                value: false
              - name: "UserIndex"
                value: null
              - name: "CreatorFabricIndex"
                value: null
              - name: "LastModifiedFabricIndex"
                value: null
              - name: "NextCredentialIndex"
                value: null

    - label:
          "Reading RFID credential with out-of-bounds index returns no
          credential"
      command: "GetCredentialStatus"
      arguments:
          values:
              - name: "Credential"
                value:
                    {
                        CredentialType: 2,
                        CredentialIndex: NumberOfRFIDUsersSupportedValue + 1,
                    }
      response:
          values:
              - name: "CredentialExists"
                value: false
              - name: "UserIndex"
                value: null
              - name: "CreatorFabricIndex"
                value: null
              - name: "LastModifiedFabricIndex"
                value: null
              - name: "NextCredentialIndex"
                value: null

    - label: "Check that RFID credential does not exist"
      command: "GetCredentialStatus"
      arguments:
          values:
              - name: "Credential"
                value: { CredentialType: 2, CredentialIndex: 2 }
      response:
          values:
              - name: "CredentialExists"
                value: false
              - name: "UserIndex"
                value: null
              - name: "CreatorFabricIndex"
                value: null
              - name: "LastModifiedFabricIndex"
                value: null
              - name: "NextCredentialIndex"
                value: null

    - label:
          "Create new RFID credential and add it to existing user with non-null
          UserStatus should fail"
      command: "SetCredential"
      timedInteractionTimeoutMs: 10000
      arguments:
          values:
              - name: "OperationType"
                value: 0
              - name: "Credential"
                value: { CredentialType: 2, CredentialIndex: 1 }
              - name: "CredentialData"
                value: "rfid_data_123456"
              - name: "UserIndex"
                value: 1
              - name: "UserStatus"
                value: 1
              - name: "UserType"
                value: null
      response:
          values:
              - name: "Status"
                value: 0x85 # INVALID_COMMAND
              - name: "UserIndex"
                value: null
              - name: "NextCredentialIndex"
                value: 2

    - label:
          "Create new RFID credential and add it to existing user with non-null
          UserType should fail"
      command: "SetCredential"
      timedInteractionTimeoutMs: 10000
      arguments:
          values:
              - name: "OperationType"
                value: 0
              - name: "Credential"
                value: { CredentialType: 2, CredentialIndex: 1 }
              - name: "CredentialData"
                value: "rfid_data_123456"
              - name: "UserIndex"
                value: 1
              - name: "UserStatus"
                value: null
              - name: "UserType"
                value: 0
      response:
          values:
              - name: "Status"
                value: 0x85 # INVALID_COMMAND
              - name: "UserIndex"
                value: null
              - name: "NextCredentialIndex"
                value: 2

    - label:
          "Create new RFID credential and add it to existing user with non-null
          UserType and UserStatus should fail"
      command: "SetCredential"
      timedInteractionTimeoutMs: 10000
      arguments:
          values:
              - name: "OperationType"
                value: 0
              - name: "Credential"
                value: { CredentialType: 2, CredentialIndex: 1 }
              - name: "CredentialData"
                value: "rfid_data_123456"
              - name: "UserIndex"
                value: 1
              - name: "UserStatus"
                value: 1
              - name: "UserType"
                value: 0
      response:
          values:
              - name: "Status"
                value: 0x85 # INVALID_COMMAND
              - name: "UserIndex"
                value: null
              - name: "NextCredentialIndex"
                value: 2

    - label:
          "Attempt to create new RFID credential from different fabric and add
          it to existing user"
      command: "SetCredential"
      identity: "beta"
      timedInteractionTimeoutMs: 10000
      arguments:
          values:
              - name: "OperationType"
                value: 0
              - name: "Credential"
                value: { CredentialType: 2, CredentialIndex: 1 }
              - name: "CredentialData"
                value: "rfid_data_123456"
              - name: "UserIndex"
                value: 1
              - name: "UserStatus"
                value: null
              - name: "UserType"
                value: null
      response:
          values:
              - name: "Status"
                value: 0x85
              - name: "UserIndex"
                value: null
              - name: "NextCredentialIndex"
                value: 2

    - label: "Verify user has not been modified"
      command: "GetUser"
      arguments:
          values:
              - name: "UserIndex"
                value: 1
      response:
          values:
              - name: "UserIndex"
                value: 1
              - name: "UserName"
                value: ""
              - name: "UserUniqueID"
                value: null
              - name: "UserStatus"
                value: 1
              - name: "UserType"
                value: 0
              - name: "CredentialRule"
                value: 0
              - name: "Credentials"
                value: [{ CredentialType: 1, CredentialIndex: 1 }]
              - name: "CreatorFabricIndex"
                value: 1
              - name: "LastModifiedFabricIndex"
                value: 1
              - name: "NextUserIndex"
                value: null

    - label: "Verify no credential has been created"
      command: "GetCredentialStatus"
      arguments:
          values:
              - name: "Credential"
                value: { CredentialType: 2, CredentialIndex: 1 }
      response:
          values:
              - name: "CredentialExists"
                value: false
              - name: "UserIndex"
                value: null
              - name: "CreatorFabricIndex"
                value: null
              - name: "LastModifiedFabricIndex"
                value: null
              - name: "NextCredentialIndex"
                value: null

    - label: "Create new RFID credential and add it to existing user"
      command: "SetCredential"
      timedInteractionTimeoutMs: 10000
      arguments:
          values:
              - name: "OperationType"
                value: 0
              - name: "Credential"
                value: { CredentialType: 2, CredentialIndex: 1 }
              - name: "CredentialData"
                value: "rfid_data_123456"
              - name: "UserIndex"
                value: 1
              - name: "UserStatus"
                value: null
              - name: "UserType"
                value: null
      response:
          values:
              - name: "Status"
                value: 0x00
              - name: "UserIndex"
                value: null
              - name: "NextCredentialIndex"
                value: 2

    - label: "Verify modified user"
      command: "GetUser"
      arguments:
          values:
              - name: "UserIndex"
                value: 1
      response:
          values:
              - name: "UserIndex"
                value: 1
              - name: "UserName"
                value: ""
              - name: "UserUniqueID"
                value: null
              - name: "UserStatus"
                value: 1
              - name: "UserType"
                value: 0
              - name: "CredentialRule"
                value: 0
              - name: "Credentials"
                value:
                    [
                        { CredentialType: 1, CredentialIndex: 1 },
                        { CredentialType: 2, CredentialIndex: 1 },
                    ]
              - name: "CreatorFabricIndex"
                value: 1
              - name: "LastModifiedFabricIndex"
                value: 1
              - name: "NextUserIndex"
                value: null

    - label: "Verify created credential"
      command: "GetCredentialStatus"
      arguments:
          values:
              - name: "Credential"
                value: { CredentialType: 2, CredentialIndex: 1 }
      response:
          values:
              - name: "CredentialExists"
                value: true
              - name: "UserIndex"
                value: 1
              - name: "CreatorFabricIndex"
                value: 1
              - name: "LastModifiedFabricIndex"
                value: 1
              - name: "NextCredentialIndex"
                value: null

    - label:
          "Attempt to modify credentialData of existing RFID credential from
          different fabric"
      command: "SetCredential"
      identity: "beta"
      timedInteractionTimeoutMs: 10000
      arguments:
          values:
              - name: "OperationType"
                value: 2
              - name: "Credential"
                value: { CredentialType: 2, CredentialIndex: 1 }
              - name: "CredentialData"
                value: "rfid_data_654321"
              - name: "UserIndex"
                value: 1
              - name: "UserStatus"
                value: null
              - name: "UserType"
                value: null
      response:
          values:
              - name: "Status"
                value: 0x85
              - name: "UserIndex"
                value: null
              - name: "NextCredentialIndex"
                value: 2

    - label:
          "Verify that credential was not changed by attempting to create new
          credential with unmodified data"
      command: "SetCredential"
      timedInteractionTimeoutMs: 10000
      arguments:
          values:
              - name: "OperationType"
                value: 0
              - name: "Credential"
                value: { CredentialType: 2, CredentialIndex: 2 }
              - name: "CredentialData"
                value: "rfid_data_123456"
              - name: "UserIndex"
                value: null
              - name: "UserStatus"
                value: null
              - name: "UserType"
                value: null
      response:
          values:
              - name: "Status"
                value: 0x02
              - name: "UserIndex"
                value: null
              - name: "NextCredentialIndex"
                value: 3

    - label: "Create new RFID credential and user with index 0 fails"
      command: "SetCredential"
      timedInteractionTimeoutMs: 10000
      arguments:
          values:
              - name: "OperationType"
                value: 0
              - name: "Credential"
                value: { CredentialType: 2, CredentialIndex: 0 }
              - name: "CredentialData"
                value: "new_rfid_data_field"
              - name: "UserIndex"
                value: null
              - name: "UserStatus"
                value: null
              - name: "UserType"
                value: null
      response:
          values:
              - name: "Status"
                value: 0x85
              - name: "UserIndex"
                value: null
              - name: "NextCredentialIndex"
                value: 2

    - label:
          "Create new RFID credential and user with out-of-bounds index fails"
      command: "SetCredential"
      timedInteractionTimeoutMs: 10000
      arguments:
          values:
              - name: "OperationType"
                value: 0
              - name: "Credential"
                value:
                    {
                        CredentialType: 2,
                        CredentialIndex: NumberOfRFIDUsersSupportedValue + 1,
                    }
              - name: "CredentialData"
                value: "new_rfid_data_field"
              - name: "UserIndex"
                value: null
              - name: "UserStatus"
                value: null
              - name: "UserType"
                value: null
      response:
          values:
              - name: "Status"
                value: 0x85
              - name: "UserIndex"
                value: null
              - name: "NextCredentialIndex"
                value: null

    - label: "Create new credential and try to add it to 0 user"
      command: "SetCredential"
      timedInteractionTimeoutMs: 10000
      arguments:
          values:
              - name: "OperationType"
                value: 0
              - name: "Credential"
                value: { CredentialType: 1, CredentialIndex: 2 }
              - name: "CredentialData"
                value: "123465"
              - name: "UserIndex"
                value: 0
              - name: "UserStatus"
                value: null
              - name: "UserType"
                value: null
      response:
          values:
              - name: "Status"
                value: 0x85
              - name: "UserIndex"
                value: null
              - name: "NextCredentialIndex"
                value: 3

    - label: "Create new credential and try to add it to out-of-bounds user"
      command: "SetCredential"
      timedInteractionTimeoutMs: 10000
      arguments:
          values:
              - name: "OperationType"
                value: 0
              - name: "Credential"
                value: { CredentialType: 1, CredentialIndex: 2 }
              - name: "CredentialData"
                value: "123465"
              - name: "UserIndex"
                value: NumberOfTotalUsersSupportedValue + 1
              - name: "UserStatus"
                value: null
              - name: "UserType"
                value: null
      response:
          values:
              - name: "Status"
                value: 0x85
              - name: "UserIndex"
                value: null
              - name: "NextCredentialIndex"
                value: 3

    - label: "Create new PIN with too short data"
      command: "SetCredential"
      timedInteractionTimeoutMs: 10000
      arguments:
          values:
              - name: "OperationType"
                value: 0
              - name: "Credential"
                value: { CredentialType: 1, CredentialIndex: 2 }
              - name: "CredentialData"
                value: "12345"
              - name: "UserIndex"
                value: 0
              - name: "UserStatus"
                value: null
              - name: "UserType"
                value: null
      response:
          values:
              - name: "Status"
                value: 0x85
              - name: "UserIndex"
                value: null
              - name: "NextCredentialIndex"
                value: 3

    - label: "Create new PIN with too long data"
      command: "SetCredential"
      timedInteractionTimeoutMs: 10000
      arguments:
          values:
              - name: "OperationType"
                value: 0
              - name: "Credential"
                value: { CredentialType: 1, CredentialIndex: 2 }
              - name: "CredentialData"
                value: "123456789"
              - name: "UserIndex"
                value: 0
              - name: "UserStatus"
                value: null
              - name: "UserType"
                value: null
      response:
          values:
              - name: "Status"
                value: 0x85
              - name: "UserIndex"
                value: null
              - name: "NextCredentialIndex"
                value: 3

    - label: "Create new RFID with too short data"
      command: "SetCredential"
      timedInteractionTimeoutMs: 10000
      arguments:
          values:
              - name: "OperationType"
                value: 0
              - name: "Credential"
                value: { CredentialType: 2, CredentialIndex: 2 }
              - name: "CredentialData"
                value: "rfid_data"
              - name: "UserIndex"
                value: 0
              - name: "UserStatus"
                value: null
              - name: "UserType"
                value: null
      response:
          values:
              - name: "Status"
                value: 0x85
              - name: "UserIndex"
                value: null
              - name: "NextCredentialIndex"
                value: 3

    - label: "Create new PIN with Programming user type fails"
      command: "SetCredential"
      timedInteractionTimeoutMs: 10000
      arguments:
          values:
              - name: "OperationType"
                value: 0
              - name: "Credential"
                value: { CredentialType: 1, CredentialIndex: 2 }
              - name: "CredentialData"
                value: "123456"
              - name: "UserIndex"
                value: 0
              - name: "UserStatus"
                value: null
              - name: "UserType"
                value: 3
      response:
          values:
              - name: "Status"
                value: 0x85
              - name: "UserIndex"
                value: null
              - name: "NextCredentialIndex"
                value: 3

    - label: "Create new RFID with too short data"
      command: "SetCredential"
      timedInteractionTimeoutMs: 10000
      arguments:
          values:
              - name: "OperationType"
                value: 0
              - name: "Credential"
                value: { CredentialType: 2, CredentialIndex: 2 }
              - name: "CredentialData"
                value: "very_long_rfid_data_to_test_boundaries"
              - name: "UserIndex"
                value: 0
              - name: "UserStatus"
                value: null
              - name: "UserType"
                value: null
      response:
          values:
              - name: "Status"
                value: 0x85
              - name: "UserIndex"
                value: null
              - name: "NextCredentialIndex"
                value: 3

    - label: "Create new PIN credential with data the would cause duplicate"
      command: "SetCredential"
      timedInteractionTimeoutMs: 10000
      arguments:
          values:
              - name: "OperationType"
                value: 0
              - name: "Credential"
                value: { CredentialType: 1, CredentialIndex: 3 }
              - name: "CredentialData"
                value: "000000"
              - name: "UserIndex"
                value: null
              - name: "UserStatus"
                value: null
              - name: "UserType"
                value: null
      response:
          values:
              - name: "Status"
                value: 0x02
              - name: "UserIndex"
                value: null
              - name: "NextCredentialIndex"
                value: 4

    - label: "Create new RFID credential with data the would cause duplicate"
      command: "SetCredential"
      timedInteractionTimeoutMs: 10000
      arguments:
          values:
              - name: "OperationType"
                value: 0
              - name: "Credential"
                value: { CredentialType: 2, CredentialIndex: 2 }
              - name: "CredentialData"
                value: "rfid_data_123456"
              - name: "UserIndex"
                value: null
              - name: "UserStatus"
                value: null
              - name: "UserType"
                value: null
      response:
          values:
              - name: "Status"
                value: 0x02
              - name: "UserIndex"
                value: null
              - name: "NextCredentialIndex"
                value: 3

    - label:
          "Modify credentialData of existing PIN credential with non-null
          UserStatus should fail"
      command: "SetCredential"
      timedInteractionTimeoutMs: 10000
      arguments:
          values:
              - name: "OperationType"
                value: 2
              - name: "Credential"
                value: { CredentialType: 1, CredentialIndex: 1 }
              - name: "CredentialData"
                value: "123456"
              - name: "UserIndex"
                value: 1
              - name: "UserStatus"
                value: 1
              - name: "UserType"
                value: null
      response:
          values:
              - name: "Status"
                value: 0x85 # INVALID_COMMAND
              - name: "UserIndex"
                value: null
              - name: "NextCredentialIndex"
                value: 2

    - label:
          "Modify credentialData of existing PIN credential with non-null
          UserType should fail"
      command: "SetCredential"
      timedInteractionTimeoutMs: 10000
      arguments:
          values:
              - name: "OperationType"
                value: 2
              - name: "Credential"
                value: { CredentialType: 1, CredentialIndex: 1 }
              - name: "CredentialData"
                value: "123456"
              - name: "UserIndex"
                value: 1
              - name: "UserStatus"
                value: null
              - name: "UserType"
                value: 0
      response:
          values:
              - name: "Status"
                value: 0x85 # INVALID_COMMAND
              - name: "UserIndex"
                value: null
              - name: "NextCredentialIndex"
                value: 2

    - label:
          "Modify credentialData of existing PIN credential with non-null
          UserStatus and UserType should fail"
      command: "SetCredential"
      timedInteractionTimeoutMs: 10000
      arguments:
          values:
              - name: "OperationType"
                value: 2
              - name: "Credential"
                value: { CredentialType: 1, CredentialIndex: 1 }
              - name: "CredentialData"
                value: "123456"
              - name: "UserIndex"
                value: 1
              - name: "UserStatus"
                value: 1
              - name: "UserType"
                value: 0
      response:
          values:
              - name: "Status"
                value: 0x85 # INVALID_COMMAND
              - name: "UserIndex"
                value: null
              - name: "NextCredentialIndex"
                value: 2

    - label: "Modify credentialData of existing PIN credential"
      command: "SetCredential"
      timedInteractionTimeoutMs: 10000
      arguments:
          values:
              - name: "OperationType"
                value: 2
              - name: "Credential"
                value: { CredentialType: 1, CredentialIndex: 1 }
              - name: "CredentialData"
                value: "123456"
              - name: "UserIndex"
                value: 1
              - name: "UserStatus"
                value: null
              - name: "UserType"
                value: null
      response:
          values:
              - name: "Status"
                value: 0x00
              - name: "UserIndex"
                value: null
              - name: "NextCredentialIndex"
                value: 2

    - label:
          "Verify that credential was changed by creating new credential with
          old data"
      command: "SetCredential"
      timedInteractionTimeoutMs: 10000
      arguments:
          values:
              - name: "OperationType"
                value: 0
              - name: "Credential"
                value: { CredentialType: 1, CredentialIndex: 2 }
              - name: "CredentialData"
                value: "000000"
              - name: "UserIndex"
                value: null
              - name: "UserStatus"
                value: null
              - name: "UserType"
                value: null
      response:
          values:
              - name: "Status"
                value: 0x00
              - name: "UserIndex"
                value: 2
              - name: "NextCredentialIndex"
                value: 3

    - label:
          "Verify that credential was changed by creating new credential with
          new data"
      command: "SetCredential"
      timedInteractionTimeoutMs: 10000
      arguments:
          values:
              - name: "OperationType"
                value: 0
              - name: "Credential"
                value: { CredentialType: 1, CredentialIndex: 3 }
              - name: "CredentialData"
                value: "123456"
              - name: "UserIndex"
                value: null
              - name: "UserStatus"
                value: null
              - name: "UserType"
                value: null
      response:
          values:
              - name: "Status"
                value: 0x02
              - name: "UserIndex"
                value: null
              - name: "NextCredentialIndex"
                value: 4

    # At that state we have the following users:
    # Index = 1, Credentials = {(1, PIN), (2, RFID)}
    # Index = 2, Credentials = {(3, PIN)}

    # Add additional RFID and PIN credentials to the user to make sure that we can have distinct credentials
    # of the same type

    - label: "Create new RFID credential and add it to existing user"
      command: "SetCredential"
      timedInteractionTimeoutMs: 10000
      arguments:
          values:
              - name: "OperationType"
                value: 0
              - name: "Credential"
                value: { CredentialType: 2, CredentialIndex: 2 }
              - name: "CredentialData"
                value: "rfid_data_7890"
              - name: "UserIndex"
                value: 1
              - name: "UserStatus"
                value: null
              - name: "UserType"
                value: null
      response:
          values:
              - name: "Status"
                value: 0x00
              - name: "UserIndex"
                value: null
              - name: "NextCredentialIndex"
                value: 3

    - label: "Verify modified user"
      command: "GetUser"
      arguments:
          values:
              - name: "UserIndex"
                value: 1
      response:
          values:
              - name: "UserIndex"
                value: 1
              - name: "UserName"
                value: ""
              - name: "UserUniqueID"
                value: null
              - name: "UserStatus"
                value: 1
              - name: "UserType"
                value: 0
              - name: "CredentialRule"
                value: 0
              - name: "Credentials"
                value:
                    [
                        { CredentialType: 1, CredentialIndex: 1 },
                        { CredentialType: 2, CredentialIndex: 1 },
                        { CredentialType: 2, CredentialIndex: 2 },
                    ]
              - name: "CreatorFabricIndex"
                value: 1
              - name: "LastModifiedFabricIndex"
                value: 1
              - name: "NextUserIndex"
                value: 2

    - label: "Create new RFID credential and add it to existing user"
      command: "SetCredential"
      timedInteractionTimeoutMs: 10000
      arguments:
          values:
              - name: "OperationType"
                value: 0
              - name: "Credential"
                value: { CredentialType: 1, CredentialIndex: 3 }
              - name: "CredentialData"
                value: "789012"
              - name: "UserIndex"
                value: 1
              - name: "UserStatus"
                value: null
              - name: "UserType"
                value: null
      response:
          values:
              - name: "Status"
                value: 0x00
              - name: "UserIndex"
                value: null
              - name: "NextCredentialIndex"
                value: 4

    - label: "Verify modified user"
      command: "GetUser"
      arguments:
          values:
              - name: "UserIndex"
                value: 1
      response:
          values:
              - name: "UserIndex"
                value: 1
              - name: "UserName"
                value: ""
              - name: "UserUniqueID"
                value: null
              - name: "UserStatus"
                value: 1
              - name: "UserType"
                value: 0
              - name: "CredentialRule"
                value: 0
              - name: "Credentials"
                value:
                    [
                        { CredentialType: 1, CredentialIndex: 1 },
                        { CredentialType: 2, CredentialIndex: 1 },
                        { CredentialType: 2, CredentialIndex: 2 },
                        { CredentialType: 1, CredentialIndex: 3 },
                    ]
              - name: "CreatorFabricIndex"
                value: 1
              - name: "LastModifiedFabricIndex"
                value: 1
              - name: "NextUserIndex"
                value: 2

    - label: "Clear first PIN credential"
      command: "ClearCredential"
      timedInteractionTimeoutMs: 10000
      arguments:
          values:
              - name: "Credential"
                value: { CredentialType: 1, CredentialIndex: 1 }

    - label: "Read back the credential and make sure it is deleted"
      command: "GetCredentialStatus"
      arguments:
          values:
              - name: "Credential"
                value: { CredentialType: 1, CredentialIndex: 1 }
      response:
          values:
              - name: "CredentialExists"
                value: false
              - name: "UserIndex"
                value: null
              - name: "CreatorFabricIndex"
                value: null
              - name: "LastModifiedFabricIndex"
                value: null
              - name: "NextCredentialIndex"
                value: 2

    - label: "Read the user back and make sure PIN credential is deleted"
      command: "GetUser"
      arguments:
          values:
              - name: "UserIndex"
                value: 1
      response:
          values:
              - name: "UserIndex"
                value: 1
              - name: "UserName"
                value: ""
              - name: "UserUniqueID"
                value: null
              - name: "UserStatus"
                value: 1
              - name: "UserType"
                value: 0
              - name: "CredentialRule"
                value: 0
              - name: "Credentials"
                value:
                    [
                        { CredentialType: 2, CredentialIndex: 1 },
                        { CredentialType: 2, CredentialIndex: 2 },
                        { CredentialType: 1, CredentialIndex: 3 },
                    ]
              - name: "CreatorFabricIndex"
                value: 1
              - name: "LastModifiedFabricIndex"
                value: 1
              - name: "NextUserIndex"
                value: 2

    - label: "Make sure a LockUserChange event was generated"
      command: "readEvent"
      event: "LockUserChange"
      # I wish there were a way to not hardcode this 27, but it's experimentally
      # determined: doing a read without an eventNumber filter here shows 26
      # LockUserChange events before this removal.
      eventNumber: 27
      response:
          value:
              {
                  LockDataType: LockDataTypeEnum.PIN,
                  DataOperationType: DataOperationTypeEnum.Clear,
                  OperationSource: OperationSourceEnum.Remote,
                  UserIndex: 1,
                  DataIndex: 1,
              }

    - label: "Clear the second PIN credential"
      command: "ClearCredential"
      timedInteractionTimeoutMs: 10000
      arguments:
          values:
              - name: "Credential"
                value: { CredentialType: 1, CredentialIndex: 2 }

    - label: "Read back the credential and make sure it is deleted"
      command: "GetCredentialStatus"
      arguments:
          values:
              - name: "Credential"
                value: { CredentialType: 1, CredentialIndex: 2 }
      response:
          values:
              - name: "CredentialExists"
                value: false
              - name: "UserIndex"
                value: null
              - name: "CreatorFabricIndex"
                value: null
              - name: "LastModifiedFabricIndex"
                value: null
              - name: "NextCredentialIndex"
                value: 3

    - label: "Read the user back and make sure related user is deleted"
      command: "GetUser"
      arguments:
          values:
              - name: "UserIndex"
                value: 2
      response:
          values:
              - name: "UserIndex"
                value: 2
              - name: "UserName"
                value: null
              - name: "UserUniqueID"
                value: null
              - name: "UserStatus"
                value: null
              - name: "UserType"
                value: null
              - name: "CredentialRule"
                value: null
              - name: "Credentials"
                value: null
              - name: "CreatorFabricIndex"
                value: null
              - name: "LastModifiedFabricIndex"
                value: null
              - name: "NextUserIndex"
                value: null

    - label: "Create new RFID credential with user"
      command: "SetCredential"
      timedInteractionTimeoutMs: 10000
      arguments:
          values:
              - name: "OperationType"
                value: 0
              - name: "Credential"
                value: { CredentialType: 2, CredentialIndex: 3 }
              - name: "CredentialData"
                value: "rfid_data_12345"
              - name: "UserIndex"
                value: null
              - name: "UserStatus"
                value: null
              - name: "UserType"
                value: null
      response:
          values:
              - name: "Status"
                value: 0x00
              - name: "UserIndex"
                value: 2
              - name: "NextCredentialIndex"
                value: 4

    - label: "Clear all the RFID credentials"
      command: "ClearCredential"
      timedInteractionTimeoutMs: 10000
      arguments:
          values:
              - name: "Credential"
                value: { CredentialType: 2, CredentialIndex: 0xFFFE }

    - label: "Read back the fist RFID credential and make sure it is deleted"
      command: "GetCredentialStatus"
      arguments:
          values:
              - name: "Credential"
                value: { CredentialType: 2, CredentialIndex: 1 }
      response:
          values:
              - name: "CredentialExists"
                value: false
              - name: "UserIndex"
                value: null
              - name: "CreatorFabricIndex"
                value: null
              - name: "LastModifiedFabricIndex"
                value: null
              - name: "NextCredentialIndex"
                value: null

    - label: "Read back the second RFID credential and make sure it is deleted"
      command: "GetCredentialStatus"
      arguments:
          values:
              - name: "Credential"
                value: { CredentialType: 2, CredentialIndex: 2 }
      response:
          values:
              - name: "CredentialExists"
                value: false
              - name: "UserIndex"
                value: null
              - name: "CreatorFabricIndex"
                value: null
              - name: "LastModifiedFabricIndex"
                value: null
              - name: "NextCredentialIndex"
                value: null

    - label: "Read back the third RFID credential and make sure it is deleted"
      command: "GetCredentialStatus"
      arguments:
          values:
              - name: "Credential"
                value: { CredentialType: 2, CredentialIndex: 3 }
      response:
          values:
              - name: "CredentialExists"
                value: false
              - name: "UserIndex"
                value: null
              - name: "CreatorFabricIndex"
                value: null
              - name: "LastModifiedFabricIndex"
                value: null
              - name: "NextCredentialIndex"
                value: null

    - label:
          "Read the user related with first RFID back and make sure it has only
          PIN credential"
      command: "GetUser"
      arguments:
          values:
              - name: "UserIndex"
                value: 1
      response:
          values:
              - name: "UserIndex"
                value: 1
              - name: "UserName"
                value: ""
              - name: "UserUniqueID"
                value: null
              - name: "UserStatus"
                value: 1
              - name: "UserType"
                value: 0
              - name: "CredentialRule"
                value: 0
              - name: "Credentials"
                value: [{ CredentialType: 1, CredentialIndex: 3 }]
              - name: "CreatorFabricIndex"
                value: 1
              - name: "LastModifiedFabricIndex"
                value: 1
              - name: "NextUserIndex"
                value: null

    - label:
          "Read the user related with second RFID back and make sure it is
          deleted"
      command: "GetUser"
      arguments:
          values:
              - name: "UserIndex"
                value: 2
      response:
          values:
              - name: "UserIndex"
                value: 2
              - name: "UserName"
                value: null
              - name: "UserUniqueID"
                value: null
              - name: "UserStatus"
                value: null
              - name: "UserType"
                value: null
              - name: "CredentialRule"
                value: null
              - name: "Credentials"
                value: null
              - name: "CreatorFabricIndex"
                value: null
              - name: "LastModifiedFabricIndex"
                value: null
              - name: "NextUserIndex"
                value: null

    - label: "Create new PIN credential with user"
      command: "SetCredential"
      timedInteractionTimeoutMs: 10000
      arguments:
          values:
              - name: "OperationType"
                value: 0
              - name: "Credential"
                value: { CredentialType: 1, CredentialIndex: 1 }
              - name: "CredentialData"
                value: "123456"
              - name: "UserIndex"
                value: null
              - name: "UserStatus"
                value: null
              - name: "UserType"
                value: null
      response:
          values:
              - name: "Status"
                value: 0x00
              - name: "UserIndex"
                value: 2
              - name: "NextCredentialIndex"
                value: 2

    - label: "Create new RFID credential with user"
      command: "SetCredential"
      timedInteractionTimeoutMs: 10000
      arguments:
          values:
              - name: "OperationType"
                value: 0
              - name: "Credential"
                value: { CredentialType: 2, CredentialIndex: 2 }
              - name: "CredentialData"
                value: "rfid_data_1234"
              - name: "UserIndex"
                value: null
              - name: "UserStatus"
                value: null
              - name: "UserType"
                value: null
      response:
          values:
              - name: "Status"
                value: 0x00
              - name: "UserIndex"
                value: 3
              - name: "NextCredentialIndex"
                value: 3

    - label: "Create another RFID credential with user"
      command: "SetCredential"
      timedInteractionTimeoutMs: 10000
      arguments:
          values:
              - name: "OperationType"
                value: 0
              - name: "Credential"
                value: { CredentialType: 2, CredentialIndex: 6 }
              - name: "CredentialData"
                value: "rfid_data_9876"
              - name: "UserIndex"
                value: null
              - name: "UserStatus"
                value: null
              - name: "UserType"
                value: null
      response:
          values:
              - name: "Status"
                value: 0x00
              - name: "UserIndex"
                value: 4
              - name: "NextCredentialIndex"
                value: 7

    # This test is disabled for now because ZAP generators are not generating working code when
    # command has nullable as a parameter.
    - label: "Clear all the credentials"
      command: "ClearCredential"
      timedInteractionTimeoutMs: 10000
      arguments:
          values:
              - name: "Credential"
                value: null

    - label: "Read back the first PIN credential and make sure it is deleted"
      command: "GetCredentialStatus"
      arguments:
          values:
              - name: "Credential"
                value: { CredentialType: 1, CredentialIndex: 1 }
      response:
          values:
              - name: "CredentialExists"
                value: false
              - name: "UserIndex"
                value: null
              - name: "CreatorFabricIndex"
                value: null
              - name: "LastModifiedFabricIndex"
                value: null
              - name: "NextCredentialIndex"
                value: null

    - label: "Read back the first RFID credential and make sure it is deleted"
      command: "GetCredentialStatus"
      arguments:
          values:
              - name: "Credential"
                value: { CredentialType: 2, CredentialIndex: 2 }
      response:
          values:
              - name: "CredentialExists"
                value: false
              - name: "UserIndex"
                value: null
              - name: "CreatorFabricIndex"
                value: null
              - name: "LastModifiedFabricIndex"
                value: null
              - name: "NextCredentialIndex"
                value: null

    - label: "Read back the second PIN credential and make sure it is deleted"
      command: "GetCredentialStatus"
      arguments:
          values:
              - name: "Credential"
                value: { CredentialType: 1, CredentialIndex: 6 }
      response:
          values:
              - name: "CredentialExists"
                value: false
              - name: "UserIndex"
                value: null
              - name: "CreatorFabricIndex"
                value: null
              - name: "LastModifiedFabricIndex"
                value: null
              - name: "NextCredentialIndex"
                value: null

    - label:
          "Read the user related with first PIN back and make sure it is deleted"
      command: "GetUser"
      arguments:
          values:
              - name: "UserIndex"
                value: 1
      response:
          values:
              - name: "UserIndex"
                value: 1
              - name: "UserName"
                value: null
              - name: "UserUniqueID"
                value: null
              - name: "UserStatus"
                value: null
              - name: "UserType"
                value: null
              - name: "CredentialRule"
                value: null
              - name: "Credentials"
                value: null
              - name: "CreatorFabricIndex"
                value: null
              - name: "LastModifiedFabricIndex"
                value: null
              - name: "NextUserIndex"
                value: null

    - label:
          "Read the user related with first RFID back and make sure it is
          deleted"
      command: "GetUser"
      arguments:
          values:
              - name: "UserIndex"
                value: 2
      response:
          values:
              - name: "UserIndex"
                value: 2
              - name: "UserName"
                value: null
              - name: "UserUniqueID"
                value: null
              - name: "UserStatus"
                value: null
              - name: "UserType"
                value: null
              - name: "CredentialRule"
                value: null
              - name: "Credentials"
                value: null
              - name: "CreatorFabricIndex"
                value: null
              - name: "LastModifiedFabricIndex"
                value: null
              - name: "NextUserIndex"
                value: null

    - label:
          "Read the user related with second PIN back and make sure it is
          deleted"
      command: "GetUser"
      arguments:
          values:
              - name: "UserIndex"
                value: 3
      response:
          values:
              - name: "UserIndex"
                value: 3
              - name: "UserName"
                value: null
              - name: "UserUniqueID"
                value: null
              - name: "UserStatus"
                value: null
              - name: "UserType"
                value: null
              - name: "CredentialRule"
                value: null
              - name: "Credentials"
                value: null
              - name: "CreatorFabricIndex"
                value: null
              - name: "LastModifiedFabricIndex"
                value: null
              - name: "NextUserIndex"
                value: null

    - label:
          "Read the user related with last RFID back and make sure it is deleted"
      command: "GetUser"
      arguments:
          values:
              - name: "UserIndex"
                value: 4
      response:
          values:
              - name: "UserIndex"
                value: 4
              - name: "UserName"
                value: null
              - name: "UserUniqueID"
                value: null
              - name: "UserStatus"
                value: null
              - name: "UserType"
                value: null
              - name: "CredentialRule"
                value: null
              - name: "Credentials"
                value: null
              - name: "CreatorFabricIndex"
                value: null
              - name: "LastModifiedFabricIndex"
                value: null
              - name: "NextUserIndex"
                value: null

    - label: "Create new Programming PIN credential with invalid index"
      command: "SetCredential"
      timedInteractionTimeoutMs: 10000
      arguments:
          values:
              - name: "OperationType"
                value: 0
              - name: "Credential"
                value: { CredentialType: 0, CredentialIndex: 1 }
              - name: "CredentialData"
                value: "123456"
              - name: "UserIndex"
                value: null
              - name: "UserStatus"
                value: null
              - name: "UserType"
                value: null
      response:
          values:
              - name: "Status"
                value: 0x85
              - name: "UserIndex"
                value: null
              - name: "NextCredentialIndex"
                value: null

    - label: "Create new Programming PIN credential with valid index"
      command: "SetCredential"
      timedInteractionTimeoutMs: 10000
      arguments:
          values:
              - name: "OperationType"
                value: 0
              - name: "Credential"
                value: { CredentialType: 0, CredentialIndex: 0 }
              - name: "CredentialData"
                value: "123456"
              - name: "UserIndex"
                value: null
              - name: "UserStatus"
                value: null
              - name: "UserType"
                value: null
      response:
          values:
              - name: "Status"
                value: 0x00
              - name: "UserIndex"
                value: 1
              - name: "NextCredentialIndex"
                value: null

    - label: "Verify created user"
      command: "GetUser"
      arguments:
          values:
              - name: "UserIndex"
                value: 1
      response:
          values:
              - name: "UserIndex"
                value: 1
              - name: "UserName"
                value: ""
              - name: "UserUniqueID"
                value: null
              - name: "UserStatus"
                value: 1
              - name: "UserType"
                value: 0
              - name: "CredentialRule"
                value: 0
              - name: "Credentials"
                value: [{ CredentialType: 0, CredentialIndex: 0 }]
              - name: "CreatorFabricIndex"
                value: 1
              - name: "LastModifiedFabricIndex"
                value: 1
              - name: "NextUserIndex"
                value: null

    - label: "Verify created programming PIN credential"
      command: "GetCredentialStatus"
      arguments:
          values:
              - name: "Credential"
                value: { CredentialType: 0, CredentialIndex: 0 }
      response:
          values:
              - name: "CredentialExists"
                value: true
              - name: "UserIndex"
                value: 1
              - name: "CreatorFabricIndex"
                value: 1
              - name: "LastModifiedFabricIndex"
                value: 1
              - name: "NextCredentialIndex"
                value: null

    - label: "Modify the Programming PIN credential"
      command: "SetCredential"
      timedInteractionTimeoutMs: 10000
      arguments:
          values:
              - name: "OperationType"
                value: 2
              - name: "Credential"
                value: { CredentialType: 0, CredentialIndex: 0 }
              - name: "CredentialData"
                value: "654321"
              - name: "UserIndex"
                value: null
              - name: "UserStatus"
                value: null
              - name: "UserType"
                value: null
      response:
          values:
              - name: "Status"
                value: 0x00
              - name: "UserIndex"
                value: null
              - name: "NextCredentialIndex"
                value: null

    - label: "Clearing Programming PIN fails"
      command: "ClearCredential"
      timedInteractionTimeoutMs: 10000
      arguments:
          values:
              - name: "Credential"
                value: { CredentialType: 0, CredentialIndex: 0 }
      response:
          error: INVALID_COMMAND

    - label: "Clearing Programming PIN with invalid index fails"
      command: "ClearCredential"
      timedInteractionTimeoutMs: 10000
      arguments:
          values:
              - name: "Credential"
                value: { CredentialType: 0, CredentialIndex: 1 }
      response:
          error: INVALID_COMMAND

    - label: "Clearing PIN credential with zero index fails"
      command: "ClearCredential"
      timedInteractionTimeoutMs: 10000
      arguments:
          values:
              - name: "Credential"
                value: { CredentialType: 1, CredentialIndex: 0 }
      response:
          error: INVALID_COMMAND

    - label: "Clearing PIN credential with out-of-bound index fails"
      command: "ClearCredential"
      timedInteractionTimeoutMs: 10000
      arguments:
          values:
              - name: "Credential"
                value:
                    {
                        CredentialType: 1,
                        CredentialIndex: NumberOfPINUsersSupportedValue + 1,
                    }
      response:
          error: INVALID_COMMAND

    - label: "Clearing RFID credential with zero index fails"
      command: "ClearCredential"
      timedInteractionTimeoutMs: 10000
      arguments:
          values:
              - name: "Credential"
                value: { CredentialType: 2, CredentialIndex: 0 }
      response:
          error: INVALID_COMMAND

    - label: "Clearing RFID credential with out-of-bound index fails"
      command: "ClearCredential"
      timedInteractionTimeoutMs: 10000
      arguments:
          values:
              - name: "Credential"
                value:
                    {
                        CredentialType: 2,
                        CredentialIndex: NumberOfRFIDUsersSupportedValue + 1,
                    }
      response:
          error: INVALID_COMMAND

    # Cleanup so the test could be run again. Also checks that clearUser removes associated credentials
    - label: "Clear the Programming PIN user"
      command: "ClearUser"
      timedInteractionTimeoutMs: 10000
      arguments:
          values:
              - name: "UserIndex"
                value: 1

    - label: "Make sure Programming PIN user is deleted"
      command: "GetUser"
      arguments:
          values:
              - name: "UserIndex"
                value: 1
      response:
          values:
              - name: "UserIndex"
                value: 1
              - name: "UserName"
                value: null
              - name: "UserUniqueID"
                value: null
              - name: "UserStatus"
                value: null
              - name: "UserType"
                value: null
              - name: "CredentialRule"
                value: null
              - name: "Credentials"
                value: null
              - name: "CreatorFabricIndex"
                value: null
              - name: "LastModifiedFabricIndex"
                value: null
              - name: "NextUserIndex"
                value: null

    - label: "Make sure programming PIN credential is deleted"
      command: "GetCredentialStatus"
      arguments:
          values:
              - name: "Credential"
                value: { CredentialType: 0, CredentialIndex: 0 }
      response:
          values:
              - name: "CredentialExists"
                value: false
              - name: "UserIndex"
                value: null
              - name: "CreatorFabricIndex"
                value: null
              - name: "LastModifiedFabricIndex"
                value: null
              - name: "NextCredentialIndex"
                value: null

    # Test to make sure it's impossible to add more than NumberOfCredentialsSupportedPerUser credentials to a single user
    - label: "Create new PIN credential and user"
      command: "SetCredential"
      timedInteractionTimeoutMs: 10000
      arguments:
          values:
              - name: "OperationType"
                value: 0
              - name: "Credential"
                value: { CredentialType: 1, CredentialIndex: 1 }
              - name: "CredentialData"
                value: "000000"
              - name: "UserIndex"
                value: null
              - name: "UserStatus"
                value: null
              - name: "UserType"
                value: null
      response:
          values:
              - name: "Status"
                value: 0x00
              - name: "UserIndex"
                value: 1
              - name: "NextCredentialIndex"
                value: 2

    - label: "Create second PIN credential and add it to existing user"
      command: "SetCredential"
      timedInteractionTimeoutMs: 10000
      arguments:
          values:
              - name: "OperationType"
                value: 0
              - name: "Credential"
                value: { CredentialType: 1, CredentialIndex: 2 }
              - name: "CredentialData"
                value: "000001"
              - name: "UserIndex"
                value: 1
              - name: "UserStatus"
                value: null
              - name: "UserType"
                value: null
      response:
          values:
              - name: "Status"
                value: 0x00
              - name: "UserIndex"
                value: null
              - name: "NextCredentialIndex"
                value: 3

    - label: "Create third PIN credential and add it to existing user"
      command: "SetCredential"
      timedInteractionTimeoutMs: 10000
      arguments:
          values:
              - name: "OperationType"
                value: 0
              - name: "Credential"
                value: { CredentialType: 1, CredentialIndex: 3 }
              - name: "CredentialData"
                value: "000002"
              - name: "UserIndex"
                value: 1
              - name: "UserStatus"
                value: null
              - name: "UserType"
                value: null
      response:
          values:
              - name: "Status"
                value: 0x00
              - name: "UserIndex"
                value: null
              - name: "NextCredentialIndex"
                value: 4

    - label: "Create fourth PIN credential and add it to existing user"
      command: "SetCredential"
      timedInteractionTimeoutMs: 10000
      arguments:
          values:
              - name: "OperationType"
                value: 0
              - name: "Credential"
                value: { CredentialType: 1, CredentialIndex: 4 }
              - name: "CredentialData"
                value: "000003"
              - name: "UserIndex"
                value: 1
              - name: "UserStatus"
                value: null
              - name: "UserType"
                value: null
      response:
          values:
              - name: "Status"
                value: 0x00
              - name: "UserIndex"
                value: null
              - name: "NextCredentialIndex"
                value: 5

    - label: "Create fifth PIN credential and add it to existing user"
      command: "SetCredential"
      timedInteractionTimeoutMs: 10000
      arguments:
          values:
              - name: "OperationType"
                value: 0
              - name: "Credential"
                value: { CredentialType: 1, CredentialIndex: 5 }
              - name: "CredentialData"
                value: "000004"
              - name: "UserIndex"
                value: 1
              - name: "UserStatus"
                value: null
              - name: "UserType"
                value: null
      response:
          values:
              - name: "Status"
                value: 0x00
              - name: "UserIndex"
                value: null
              - name: "NextCredentialIndex"
                value: 6

    - label: "Try to create sixth PIN credential and make sure it fails"
      command: "SetCredential"
      timedInteractionTimeoutMs: 10000
      arguments:
          values:
              - name: "OperationType"
                value: 0
              - name: "Credential"
                value: { CredentialType: 1, CredentialIndex: 6 }
              - name: "CredentialData"
                value: "000005"
              - name: "UserIndex"
                value: 1
              - name: "UserStatus"
                value: null
              - name: "UserType"
                value: null
      response:
          values:
              - name: "Status"
                value: 0x89
              - name: "UserIndex"
                value: null
              - name: "NextCredentialIndex"
                value: 7

    - label: "Final clean-up"
      command: "ClearUser"
      timedInteractionTimeoutMs: 10000
      arguments:
          values:
              - name: "UserIndex"
                value: 1
