diff --git a/src/app/tests/suites/certification/Test_TC_DLOG_2_1.yaml b/src/app/tests/suites/certification/Test_TC_DLOG_2_1.yaml index 45111b016974d2..ebc658f16523b7 100644 --- a/src/app/tests/suites/certification/Test_TC_DLOG_2_1.yaml +++ b/src/app/tests/suites/certification/Test_TC_DLOG_2_1.yaml @@ -34,6 +34,18 @@ tests: Length of TransferFileDesignator is equal to 32 characters Length of TransferFileDesignator is greater than 32 characters To send a message that mismatches the current transfer mode + 1. Execute the below commands in the interactive mode: + ./chip-tool interactive start + 2. Before running the below steps ensure that \tmp folder on the system does not contain the below files. + If they are present please delete these files: + TH_LOG_OK_NORMAL : "Length_1234567.txt" + TH_LOG_OK_FULL_LENGTH : "Length_123456789123456789123.txt" + 3. Use the below command in the all-cluster-app for setting up the diagonistics logs. + ./chip-all-clusters-app --trace_decode 1 --end_user_support_log ~/tmp/end_user_support_log.txt --network_diagnostics_log ~/tmp/nw_log.txt --crash_log ~/tmp/crash_log.txt + The log file content can be set such that the file size can be as follows to obtain different status code from DUT: + 1. end_user_support_log > 1024 bytes + 2. Make sure that nw_log.txt does not exist + 3. crash_log < 1024 bytes disabled: true - label: "Step 1: Commission DUT to TH" @@ -187,7 +199,7 @@ tests: TH_LOG_OK_NORMAL)" PICS: MCORE.BDX.Initiator verification: | - "diagnosticlogs retrieve-logs-request 0 1 1 0 --TransferFileDesignator Length_1234567.txt + diagnosticlogs retrieve-logs-request 0 1 1 0 --TransferFileDesignator Length_1234567.txt On TH(chip-tool), Verify that the DUT sends SendInit message with TransferFileDesignator field set to Length_1234567891234567891 [1707967645.770994][10882:10885] CHIP:ATM: SendInit @@ -219,7 +231,7 @@ tests: by setting Intent field to . NetworkDiag . CrashLogs" PICS: MCORE.BDX.Initiator verification: | - "diagnosticlogs retrieve-logs-request 0 0 1 0 + diagnosticlogs retrieve-logs-request 0 0 1 0 On TH(chip-tool), Verify that the DUT responds with Success(0) status code for the RetrieveLogsResponse command Verify that LogContent field contains at most 1024 bytes @@ -254,7 +266,7 @@ tests: EndUserSupport, RequestedProtocol= BDX)" PICS: MCORE.BDX.Initiator verification: | - "diagnosticlogs retrieve-logs-request 0 1 1 0 + diagnosticlogs retrieve-logs-request 0 1 1 0 On TH(chip-tool), Verify that the DUT responds with INVALID_COMMAND for the RetrieveLogsRequest that was sent without TransferFileDesignator @@ -290,7 +302,7 @@ tests: RequestedProtocol= BDX, TransferFileDesignator = TH_LOG_OK_NORMAL)" PICS: "!MCORE.BDX.Initiator" verification: | - "diagnosticlogs retrieve-logs-request 0 1 1 0 --TransferFileDesignator Length_1234567.txt + diagnosticlogs retrieve-logs-request 0 1 1 0 --TransferFileDesignator Length_1234567.txt On TH(chip-tool), Verify that the DUT responds with Exhausted(1) status code for the RetrieveLogsResponse command with the LogContent field containing at most 1024 bytes @@ -299,14 +311,40 @@ tests: [1707979121.749593][7593:7596] CHIP:TOO: logContent: 31353238303033363031313533353030333730303234303030303234303133653234303230313138333530313331303034373032313533313031316230323330383230323137303630393261383634383836663730643031303730326130383230323038333038323032303430323031303333313064333030623036303936303836343830313635303330343032303133303832303137303036303932613836343838366637306430313037303161303832303136313034383230313564313532343030303132353031663166663336303230353030383030353031383030353032383030353033383030353034383030353035383030353036383030353037383030353038383030353039383030353061383030353062383030353063383030353064383030353065383030353066383030353130383030353131383030353132383030353133383030353134383030353135383030353136383030353137383030353138383030353139383030353161383030353162383030353163383030353164383030353165383030353166383030353230383030353231383030353232383030353233383030353234383030353235383030353236383030353237383030353238383030353239383030353261383030353262383030353263383030353264383030353265383030353266383030353330383030353331383030353332383030353333383030353334383030353335383030353336383030353337383030353338383030353339383030353361383030353362383030353363383030353364383030353365383030353366383030353430383030353431383030353432383030353433383030353434383030353435383030353436383030353437383030353438383030353439383030353461383030353462383030353463383030353464383030353465383030353466383030353530383030353531383030353532383030353533383030353534383030353535383030353536383030353537383030353538383030353539383030353561383030353562383030353563383030353564383030353565383030353566383030353630383030353631383030353632383030353633383031383234303331363263303431333433353334313330333033303330333035333537343333303330333033303330326433303330323430353030323430363030323430373031323430383030313833313763333037613032303130333830313466653334336639353939343737363362363165653435333931333133333834393466653637643865333030623036303936303836343830633733653461363039363038363438303630393630383634383036303936303836343830363039363038363438303630393630383634383036303936303836}" disabled: true + - label: + "Step 11: TH sends RetrieveLogsRequest Command to DUT with Invalid + Intent : RetrieveLogsRequest(Intent = 3, RequestedProtocol= BDX, + TransferFileDesignator = TH_LOG_OK_NORMAL) Repeat this step with + RequestedProtocol as ResponsePayload" + verification: | + diagnosticlogs retrieve-logs-request 3 0 1 0 --TransferFileDesignator Length_1234567.txt + + On TH(chip-tool), Verify that the DUT responds with INVALID_COMMAND for the RetrieveLogsRequest that was sent invalid Intent(3) + + [1707901794.468552][36124:36127] CHIP:DMG: StatusIB = + [1707901794.468560][36124:36127] CHIP:DMG: { + [1707901794.468569][36124:36127] CHIP:DMG: status = 0x85 (INVALID_COMMAND), + [1707901794.468576][36124:36127] CHIP:DMG: }, + [1707901794.468584][36124:36127] CHIP:DMG: + [1707901794.468591][36124:36127] CHIP:DMG: }, + + Repeat this step by setting RequestedProtocol as ResponsePayload : + + diagnosticlogs retrieve-logs-request 3 1 1 0 --TransferFileDesignator Length_1234567.txt + On TH(chip-tool), Verify that the DUT responds with INVALID_COMMAND for the RetrieveLogsRequest that was sent invalid Intent(3) + [1707901794.468552][36124:36127] CHIP:DMG: StatusIB = + [1707901794.468560][36124:36127] CHIP:DMG: { + [1707901794.468569][36124:36127] CHIP:DMG: status = 0x85 (INVALID_COMMAND), + [1707901794.468576][36124:36127] CHIP:DMG: }, + disabled: true + - label: "Step 12: TH sends RetrieveLogsRequest Command to DUT with Invalid RequestedProtocol : RetrieveLogsRequest(Intent = EndUserSupport,RequestedProtocol= 2, TransferFileDesignator = TH_LOG_OK_NORMAL)" - PICS: MCORE.BDX.Initiator verification: | - "diagnosticlogs retrieve-logs-request 0 2 1 0 --TransferFileDesignator Length_1234567.txt + diagnosticlogs retrieve-logs-request 0 2 1 0 --TransferFileDesignator Length_1234567.txt On TH(chip-tool), Verify that the DUT responds with INVALID_COMMAND for the RetrieveLogsRequest that was sent Invalid RequestedProtocol(2) @@ -344,39 +382,14 @@ tests: TransferFileDesignator length : RetrieveLogsRequest(Intent = EndUserSupport,RequestedProtocol= BDX, TransferFileDesignator = TH_LOG_ERROR_EMPTY)" + PICS: MCORE.BDX.Initiator verification: | - "diagnosticlogs retrieve-logs-request 0 1 1 0 --TransferFileDesignator '' - - [1707904517.151453][36678:36681] CHIP:DMG: ICR moving to [ResponseRe] - [1707904517.151489][36678:36681] CHIP:DMG: InvokeResponseMessage = - [1707904517.151501][36678:36681] CHIP:DMG: { - [1707904517.151511][36678:36681] CHIP:DMG: suppressResponse = false, - [1707904517.151522][36678:36681] CHIP:DMG: InvokeResponseIBs = - [1707904517.151541][36678:36681] CHIP:DMG: [ - [1707904517.151548][36678:36681] CHIP:DMG: InvokeResponseIB = - [1707904517.151565][36678:36681] CHIP:DMG: { - [1707904517.151573][36678:36681] CHIP:DMG: CommandStatusIB = - [1707904517.151582][36678:36681] CHIP:DMG: { - [1707904517.151590][36678:36681] CHIP:DMG: CommandPathIB = - [1707904517.151599][36678:36681] CHIP:DMG: { - [1707904517.151613][36678:36681] CHIP:DMG: EndpointId = 0x0, - [1707904517.151627][36678:36681] CHIP:DMG: ClusterId = 0x32, - [1707904517.151640][36678:36681] CHIP:DMG: CommandId = 0x0, - [1707904517.151652][36678:36681] CHIP:DMG: }, - [1707904517.151670][36678:36681] CHIP:DMG: - [1707904517.151681][36678:36681] CHIP:DMG: StatusIB = - [1707904517.151696][36678:36681] CHIP:DMG: { - [1707904517.151708][36678:36681] CHIP:DMG: status = 0x87 (CONSTRAINT_ERROR), - [1707904517.151720][36678:36681] CHIP:DMG: }, - [1707904517.151734][36678:36681] CHIP:DMG: - [1707904517.151745][36678:36681] CHIP:DMG: }, - [1707904517.151763][36678:36681] CHIP:DMG: - [1707904517.151772][36678:36681] CHIP:DMG: }, - [1707904517.151790][36678:36681] CHIP:DMG: - [1707904517.151798][36678:36681] CHIP:DMG: ], - [1707904517.151816][36678:36681] CHIP:DMG: - [1707904517.151824][36678:36681] CHIP:DMG: InteractionModelRevision = 11 - [1707904517.151830][36678:36681] CHIP:DMG: }," + diagnosticlogs retrieve-logs-request 0 1 1 0 --TransferFileDesignator '' + On TH(chip-tool), Verify that DUT sends RetrieveLogsResponse command to TH with Denied(4) status code. + [1719990173.360981][8053:8056] CHIP:TOO: RetrieveLogsResponse: { + [1719990173.361009][8053:8056] CHIP:TOO: status: 4 + [1719990173.361021][8053:8056] CHIP:TOO: logContent: + [1719990173.361030][8053:8056] CHIP:TOO: } disabled: true - label: @@ -385,9 +398,9 @@ tests: EndUserSupport,RequestedProtocol= BDX, TransferFileDesignator = TH_LOG_BAD_LENGTH)" verification: | - "diagnosticlogs retrieve-logs-request 0 1 1 0 --TransferFileDesignator Length_1234567891234567891234567891212345.txt + diagnosticlogs retrieve-logs-request 0 1 1 0 --TransferFileDesignator Length_1234567891234567891234567891212345.txt - On TH(chip-tool), Verify that the DUT responds with CONSTRAINT_ERRORfor the RetrieveLogsRequest that was sent Invalid Invalid TransferFileDesignator length(> 32) + On TH(chip-tool), Verify that the DUT responds with CONSTRAINT_ERROR for the RetrieveLogsRequest that was sent Invalid Invalid TransferFileDesignator length(> 32) [1707904517.151453][36678:36681] CHIP:DMG: ICR moving to [ResponseRe] [1707904517.151489][36678:36681] CHIP:DMG: InvokeResponseMessage = diff --git a/src/app/tests/suites/certification/Test_TC_DRLK_2_4.yaml b/src/app/tests/suites/certification/Test_TC_DRLK_2_4.yaml index bece149e34ed32..a52538964c97f3 100644 --- a/src/app/tests/suites/certification/Test_TC_DRLK_2_4.yaml +++ b/src/app/tests/suites/certification/Test_TC_DRLK_2_4.yaml @@ -33,9 +33,50 @@ tests: - name: "nodeId" value: nodeId - - label: "Create new user" + - label: + "Step 1a: TH writes AutoRelockTime attribute value as 10 seconds on + the DUT" + PICS: DRLK.S.M.AutoRelockTimeAttributeWritable && PICS_SDK_CI_ONLY + command: "writeAttribute" + attribute: "AutoRelockTime" + arguments: + value: 10 + + - label: + "Step 1b: TH writes AutoRelockTime attribute value as 60 seconds on + the DUT" + PICS: DRLK.S.M.AutoRelockTimeAttributeWritable && PICS_SKIP_SAMPLE_APP + command: "writeAttribute" + attribute: "AutoRelockTime" + arguments: + value: 60 + + - label: + "Step 1c: TH writes AutoRelockTime attribute value as 10 seconds on + the DUT" + PICS: PICS_SDK_CI_ONLY && !DRLK.S.M.AutoRelockTimeAttributeWritable + command: "writeAttribute" + attribute: "AutoRelockTime" + arguments: + value: 10 + response: + error: UNSUPPORTED_WRITE + + - label: + "Step 1d: TH writes AutoRelockTime attribute value as 60 seconds on + the DUT" + PICS: PICS_SKIP_SAMPLE_APP && !DRLK.S.M.AutoRelockTimeAttributeWritable + command: "writeAttribute" + attribute: "AutoRelockTime" + arguments: + value: 60 + response: + error: UNSUPPORTED_WRITE + + - label: + "Step 2a: TH sends SetUser Command to DUT with the following values:" command: "SetUser" - PICS: DRLK.S.F08 && DRLK.S.F00 + PICS: DRLK.S.F08 && DRLK.S.C1a.Rsp timedInteractionTimeoutMs: 1000 arguments: values: @@ -54,39 +95,33 @@ tests: - name: "CredentialRule" value: 0 - - label: "Read the user back and verify its fields" - command: "GetUser" - PICS: DRLK.S.F08 && DRLK.S.F00 - arguments: - values: - - name: "UserIndex" - value: 1 + - label: "Step 2b: TH reads MinPINCodeLength attribute from DUT" + PICS: DRLK.S.F00 && DRLK.S.A0018 + command: "readAttribute" + attribute: "MinPINCodeLength" response: - values: - - name: "UserIndex" - value: 1 - - name: "UserName" - value: "xxx" - - name: "UserUniqueID" - value: 6452 - - 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: "Create new PIN credential and lock/unlock user" + saveAs: MinPINCodeLengthValue + constraints: + type: int8u + minValue: 0 + maxValue: 255 + + - label: "Step 2c: TH reads MaxPINCodeLength attribute from DUT" + PICS: DRLK.S.F00 && DRLK.S.A0017 + command: "readAttribute" + attribute: "MaxPINCodeLength" + response: + saveAs: MaxPINCodeLengthValue + constraints: + type: int8u + minValue: 0 + maxValue: 255 + - label: + "Step 2d: TH sends SetCredential Command to DUT with the following + fields and CredentialData Length is in an inclusive range of + MaxPINCodeLengthValue to MaxPINCodeLengthValue" command: "SetCredential" - PICS: DRLK.S.F08 && DRLK.S.F00 + PICS: DRLK.S.F00 && DRLK.S.C22.Rsp && DRLK.S.C23.Tx timedInteractionTimeoutMs: 1000 arguments: values: @@ -111,68 +146,8 @@ tests: - name: "NextCredentialIndex" value: 2 - - label: "Verify created PIN credential" - PICS: DRLK.S.F08 && DRLK.S.F00 - 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: - "Step 1a: TH writes AutoRelockTime attribute value as 10 seconds on - the DUT" - PICS: DRLK.S.M.AutoRelockTimeAttributeWritable && PICS_SDK_CI_ONLY - command: "writeAttribute" - attribute: "AutoRelockTime" - arguments: - value: 10 - - - label: - "Step 1b: TH writes AutoRelockTime attribute value as 60 seconds on - the DUT" - PICS: DRLK.S.M.AutoRelockTimeAttributeWritable && PICS_SKIP_SAMPLE_APP - command: "writeAttribute" - attribute: "AutoRelockTime" - arguments: - value: 60 - - - label: - "Step 1c: TH writes AutoRelockTime attribute value as 10 seconds on - the DUT" - PICS: PICS_SDK_CI_ONLY && !DRLK.S.M.AutoRelockTimeAttributeWritable - command: "writeAttribute" - attribute: "AutoRelockTime" - arguments: - value: 10 - response: - error: UNSUPPORTED_WRITE - - label: - "Step 1d: TH writes AutoRelockTime attribute value as 60 seconds on - the DUT" - PICS: PICS_SKIP_SAMPLE_APP && !DRLK.S.M.AutoRelockTimeAttributeWritable - command: "writeAttribute" - attribute: "AutoRelockTime" - arguments: - value: 60 - response: - error: UNSUPPORTED_WRITE - - - label: - "Step 2a: TH sends the Unlock with Timeout argument value as 10 + "Step 2e: TH sends the Unlock with Timeout argument value as 10 seconds" PICS: DRLK.S.C03.Rsp && PICS_SDK_CI_ONLY command: "UnlockWithTimeout" @@ -185,7 +160,7 @@ tests: value: "123456" - label: - "Step 2b: TH sends the Unlock with Timeout argument value as 60 + "Step 2f: TH sends the Unlock with Timeout argument value as 60 seconds" PICS: " DRLK.S.F08 && DRLK.S.F00 && DRLK.S.C03.Rsp && PICS_SKIP_SAMPLE_APP " @@ -199,7 +174,7 @@ tests: value: "123456" - label: - "Step 2b: TH sends the Unlock with Timeout argument value as 60 + "Step 2g: TH sends the Unlock with Timeout argument value as 60 seconds" PICS: " (!DRLK.S.F08 || !DRLK.S.F00) && DRLK.S.C03.Rsp && @@ -230,27 +205,30 @@ tests: - name: "ms" value: 70000 - - label: "Step 2c: TH reads LockState attribute" + - label: "Step 2h: TH reads LockState attribute" PICS: DRLK.S.A0000 && DRLK.S.C03.Rsp command: "readAttribute" attribute: "LockState" response: value: 1 - - label: "Cleanup the created user" - command: "ClearUser" - PICS: DRLK.S.F08 && DRLK.S.F00 + - label: + "Step 3a: TH sends ClearCredential Command to DUT with the following + fields:" + PICS: DRLK.S.F00 && DRLK.S.C26.Rsp + command: "ClearCredential" timedInteractionTimeoutMs: 1000 arguments: values: - - name: "UserIndex" - value: 1 + - name: "Credential" + value: { CredentialType: 1, CredentialIndex: 1 } - - label: "Clean the created credential" - PICS: DRLK.S.F08 && DRLK.S.F00 && DRLK.S.C26.Rsp - command: "ClearCredential" + - label: + "Step 3b: TH sends ClearUser Command to DUT with the UserIndex as 1" + command: "ClearUser" + PICS: DRLK.S.F08 && DRLK.S.C1d.Rsp timedInteractionTimeoutMs: 1000 arguments: values: - - name: "Credential" - value: { CredentialType: 1, CredentialIndex: 1 } + - name: "UserIndex" + value: 1 diff --git a/src/app/tests/suites/certification/Test_TC_DRLK_2_5.yaml b/src/app/tests/suites/certification/Test_TC_DRLK_2_5.yaml deleted file mode 100644 index c0c8feb91775cd..00000000000000 --- a/src/app/tests/suites/certification/Test_TC_DRLK_2_5.yaml +++ /dev/null @@ -1,320 +0,0 @@ -# Copyright (c) 2021 Project CHIP Authors -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -name: - 111.2.5. [TC-DRLK-2.5] Verification for the following Commands - Set Week - Day Schedule, Get Week Day Schedule , Get Week Day Schedule Response, Clear - Week Day Schedule [DUT-Server] - -PICS: - - DRLK.S - - DRLK.S.F08 - -config: - nodeId: 0x12344321 - cluster: "Door Lock" - endpoint: 1 - -tests: - - label: "Wait for the commissioned device to be retrieved" - cluster: "DelayCommands" - command: "WaitForCommissionee" - arguments: - values: - - name: "nodeId" - value: nodeId - - - label: "Precondition: Create new user" - command: "SetUser" - timedInteractionTimeoutMs: 10000 - arguments: - values: - - name: "OperationType" - value: 0 - - name: "UserIndex" - value: 1 - - name: "UserName" - value: "xxx" - - name: "UserUniqueID" - value: 6452 - - name: "UserStatus" - value: 1 - - name: "UserType" - value: 0 - - name: "CredentialRule" - value: 0 - - - label: "Precondition: 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: "xxx" - - name: "UserUniqueID" - value: 6452 - - 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: - "Step 1: TH reads NumberOfWeekDay SchedulesSupportedPerUser attribute - and saves for future use" - PICS: DRLK.S.F04 && DRLK.S.A0014 - command: "readAttribute" - attribute: "NumberOfWeekDaySchedulesSupportedPerUser" - response: - saveAs: NumberOfWeekDaySchedulesSupportedPerUserValue - constraints: - minValue: 0 - maxValue: 255 - - - label: - "Step 2: TH reads NumberOfTotalUsers Supported attribute and saves for - future use" - PICS: DRLK.S.F08 && DRLK.S.A0011 - command: "readAttribute" - attribute: "NumberOfTotalUsersSupported" - response: - saveAs: NumberOfTotalUsersSupportedValue - constraints: - minValue: 0 - maxValue: 65534 - - - label: - "Step 3: TH send Set Week Day Schedule Command to DUT with the - following values : a)WeekDayIndex as 1 b)UserIndex as 1 c)DaysMaskMap - as 2 d)StartHour as 15 e)StartMinute as 45 f)EndHour as 16 g)EndMinute - as 55 " - PICS: DRLK.S.F04 && DRLK.S.C0b.Rsp - command: "SetWeekDaySchedule" - arguments: - values: - - name: "WeekDayIndex" - value: 1 - - name: "UserIndex" - value: 1 - - name: "DaysMask" - value: 2 - - name: "StartHour" - value: 15 - - name: "StartMinute" - value: 45 - - name: "EndHour" - value: 16 - - name: "EndMinute" - value: 55 - - #issue #18591 - - label: - "Step 4: TH send Get Week Day Schedule Command to DUT with - a)WeekDayIndex as 1 b)UserIndex as 1 " - PICS: DRLK.S.F04 && DRLK.S.C0c.Rsp && DRLK.S.C0c.Tx - command: "GetWeekDaySchedule" - arguments: - values: - - name: "WeekDayIndex" - value: 1 - - name: "UserIndex" - value: 1 - response: - values: - - name: "WeekDayIndex" - value: 1 - - name: "UserIndex" - value: 1 - - name: "Status" - value: 0x0 - - name: "DaysMask" - value: 2 - - name: "StartHour" - value: 15 - - name: "StartMinute" - value: 45 - - name: "EndHour" - constraints: - hasValue: true - minValue: 16 - - name: "EndMinute" - constraints: - hasValue: true - minValue: 55 - - - label: - "Step 5: TH send Set Week Day Schedule Command to DUT with the - following values : a)WeekDayIndex as 0 (invalid value) b)UserIndex as - 1 c)DaysMaskMap as 7 (invalid value) d)StartHour as 15 e)StartMinute - as 45 f)EndHour as 16 g)EndMinute as 55" - PICS: DRLK.S.F04 && DRLK.S.C0b.Rsp - command: "SetWeekDaySchedule" - arguments: - values: - - name: "WeekDayIndex" - value: 0 - - name: "UserIndex" - value: 1 - - name: "DaysMask" - value: 7 - - name: "StartHour" - value: 15 - - name: "StartMinute" - value: 45 - - name: "EndHour" - value: 16 - - name: "EndMinute" - value: 55 - response: - error: INVALID_COMMAND - - - label: - "Step 6: TH send Get Week Day Schedule Command to DUT : a)WeekDayIndex - as 0 b)UserIndex as 1 " - PICS: DRLK.S.F04 && DRLK.S.C0c.Rsp && DRLK.S.C0c.Tx - command: "GetWeekDaySchedule" - arguments: - values: - - name: "WeekDayIndex" - value: 0 - - name: "UserIndex" - value: 1 - response: - values: - - name: "WeekDayIndex" - value: 0 - - name: "UserIndex" - value: 1 - - name: "Status" - value: 0x85 - - name: "DaysMask" - constraints: - hasValue: false - - name: "StartHour" - constraints: - hasValue: false - - name: "StartMinute" - constraints: - hasValue: false - - name: "EndHour" - constraints: - hasValue: false - - name: "EndMinute" - constraints: - hasValue: false - - - label: - "Step 7: TH sends Get Week Day Schedule Command to DUT with following - values: a)WeekDayIndex as 1 (index of existing Schedule entry) - b)UserIndex as 2 (index on non-existent User)" - PICS: DRLK.S.F04 && DRLK.S.C0c.Rsp && DRLK.S.C0c.Tx - command: "GetWeekDaySchedule" - arguments: - values: - - name: "WeekDayIndex" - value: 1 - - name: "UserIndex" - value: 2 - response: - values: - - name: "WeekDayIndex" - value: 1 - - name: "UserIndex" - value: 2 - - name: "Status" - value: 0x8B - - name: "DaysMask" - constraints: - hasValue: false - - name: "StartHour" - constraints: - hasValue: false - - name: "StartMinute" - constraints: - hasValue: false - - name: "EndHour" - constraints: - hasValue: false - - name: "EndMinute" - constraints: - hasValue: false - - - label: - "Step 8: TH sends Clear Week Day Schedule Command to DUT with : - a)WeekDayIndex as 1 b)UserIndex as 1" - PICS: DRLK.S.F04 && DRLK.S.C0d.Rsp - command: "ClearWeekDaySchedule" - arguments: - values: - - name: "WeekDayIndex" - value: 1 - - name: "UserIndex" - value: 1 - - - label: - "Step 9: TH sends Get Week Day Schedule Command to DUT with following - values: a)WeekDayIndex as 1 b)UserIndex as 1" - PICS: DRLK.S.F04 && DRLK.S.C0c.Rsp && DRLK.S.C0c.Tx - command: "GetWeekDaySchedule" - arguments: - values: - - name: "WeekDayIndex" - value: 1 - - name: "UserIndex" - value: 1 - response: - values: - - name: "WeekDayIndex" - value: 1 - - name: "UserIndex" - value: 1 - - name: "Status" - value: 0x8B - - name: "DaysMask" - constraints: - hasValue: false - - name: "StartHour" - constraints: - hasValue: false - - name: "StartMinute" - constraints: - hasValue: false - - name: "EndHour" - constraints: - hasValue: false - - name: "EndMinute" - constraints: - hasValue: false - - - label: "Cleanup the created user" - command: "ClearUser" - timedInteractionTimeoutMs: 10000 - arguments: - values: - - name: "UserIndex" - value: 1 diff --git a/src/app/tests/suites/certification/Test_TC_DRLK_2_9.yaml b/src/app/tests/suites/certification/Test_TC_DRLK_2_9.yaml deleted file mode 100644 index 0c0a372b175d7e..00000000000000 --- a/src/app/tests/suites/certification/Test_TC_DRLK_2_9.yaml +++ /dev/null @@ -1,471 +0,0 @@ -# Copyright (c) 2021 Project CHIP Authors -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -name: - 111.2.9. [TC-DRLK-2.9] Verification for the following Commands - Set - Credential , Set Credential Response, Get Credential Status, Get Credential - Status Response, Clear Credential [DUT-Server] - -PICS: - - DRLK.S - -config: - nodeId: 0x12344321 - cluster: "Door Lock" - endpoint: 1 - -tests: - - label: "Wait for the commissioned device to be retrieved" - cluster: "DelayCommands" - command: "WaitForCommissionee" - arguments: - values: - - name: "nodeId" - value: nodeId - - - label: "Precondition: Create new user with default parameters" - command: "SetUser" - timedInteractionTimeoutMs: 10000 - arguments: - values: - - name: "OperationType" - value: 0 - - name: "UserIndex" - value: 1 - - name: "UserName" - value: "xxx" - - name: "UserUniqueID" - value: 6452 - - name: "UserStatus" - value: 1 - - name: "UserType" - value: 0 - - name: "CredentialRule" - value: 0 - - - label: "Precondition: 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: "xxx" - - name: "UserUniqueID" - value: 6452 - - 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: - "Step 1: TH reads NumberOfTotalUsersSupported attribute and saves for - future use." - PICS: DRLK.S.F08 && DRLK.S.A0011 - command: "readAttribute" - attribute: "NumberOfTotalUsersSupported" - response: - saveAs: NumberOfTotalUsersSupportedValue - constraints: - minValue: 0 - maxValue: 65534 - - - label: - "Step 2: TH sends Set Credential Command to DUT with the following - fields a)OperationType as 0 b)Credential as 1 1 c)CredentialData as - 123456 d)UserIndex as 1 e)UserStatus as null f)UserType as null" - PICS: DRLK.S.F08 && DRLK.S.C22.Rsp && DRLK.S.C23.Tx - command: "SetCredential" - timedInteractionTimeoutMs: 10000 - arguments: - values: - - name: "OperationType" - value: 0 - - 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: 0 - - name: "UserIndex" - value: null - - name: "NextCredentialIndex" - value: 2 - - - label: - "Step 3: TH sends Get Credential Status Command with a)CredentialType - as 1 b)CredentialIndex as 1" - PICS: DRLK.S.F08 && DRLK.S.C24.Rsp && DRLK.S.C25.Tx - command: "GetCredentialStatus" - arguments: - values: - - name: "Credential" - value: { CredentialType: 1, CredentialIndex: 1 } - response: - values: - - name: "CredentialExists" - constraints: - type: boolean - - name: "UserIndex" - value: 1 - - name: "CreatorFabricIndex" - value: 1 - - name: "LastModifiedFabricIndex" - value: 1 - - name: "NextCredentialIndex" - value: null - - - label: - "Step 4: TH sends Set Credential Command to DUT with the following - fields a)OperationType as 0 b)Credential as 1 2 C)CredentialData as - 4321 D)UserIndex as null e)UserStatus as 5(Invalid value) f)UserType - as 10(Invalid value)" - PICS: DRLK.S.F08 && DRLK.S.C22.Rsp && DRLK.S.C23.Tx - command: "SetCredential" - timedInteractionTimeoutMs: 10000 - arguments: - values: - - name: "OperationType" - value: 0 - - name: "Credential" - value: { CredentialType: 1, CredentialIndex: 2 } - - name: "CredentialData" - value: "4321" - - name: "UserIndex" - value: null - - name: "UserStatus" - value: UserStatusEnum.UnknownEnumValue(5) - - name: "UserType" - value: 10 - response: - values: - - name: "Status" - value: 0x85 - - name: "UserIndex" - value: null - - - label: - "Step 5: TH sends Set Credential Command to DUT with the following - fields a)OperationType as 0 b)Credential as 1 2 d)CredentialData as - 123456 (same as step 2) e)UserIndex as null f)UserStatus as null - g)UserType as null" - PICS: DRLK.S.F08 && DRLK.S.C22.Rsp && DRLK.S.C23.Tx - command: "SetCredential" - timedInteractionTimeoutMs: 10000 - arguments: - values: - - name: "OperationType" - value: 0 - - name: "Credential" - value: { CredentialType: 1, CredentialIndex: 2 } - - 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 - - - label: - "Step 6a: TH sends Set Credential Command to DUT with the following - fields a)OperationType as 0 b)Credential as 1 1 (same as step 2) - c)CredentialData as 123456 d)UserIndex as 1 e)UserStatus as null - f)UserType as null" - PICS: DRLK.S.F08 && DRLK.S.C22.Rsp && DRLK.S.C23.Tx - command: "SetCredential" - timedInteractionTimeoutMs: 10000 - arguments: - values: - - name: "OperationType" - value: 0 - - 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" - constraints: - anyOf: [0x2, 0x3] - - - label: - "Step 6b: TH sends Set Credential Command to DUT with the following - fields: a)OperationType as 0 b)Credential as 1 1 (same as step 2) - c)CredentialData as 123457 d)UserIndex as 1 e)UserStatus as null - f)UserType as null" - PICS: DRLK.S.F08 && DRLK.S.C22.Rsp && DRLK.S.C23.Tx - command: "SetCredential" - timedInteractionTimeoutMs: 10000 - arguments: - values: - - name: "OperationType" - value: 0 - - name: "Credential" - value: { CredentialType: 1, CredentialIndex: 1 } - - name: "CredentialData" - value: "123457" - - name: "UserIndex" - value: 1 - - name: "UserStatus" - value: null - - name: "UserType" - value: null - response: - values: - - name: "Status" - constraints: - anyOf: [0x2, 0x3] - - - label: - "Step 7: TH sends Set Credential Command to DUT with the following - fields: a)OperationType as 2 b)Credential as 1 3 c)CredentialData as - 1234567 d)UserIndex as 1 e)UserStatus as null f)UserType as null" - PICS: DRLK.S.F08 && DRLK.S.C22.Rsp && DRLK.S.C23.Tx - command: "SetCredential" - timedInteractionTimeoutMs: 10000 - arguments: - values: - - name: "OperationType" - value: 2 - - name: "Credential" - value: { CredentialType: 1, CredentialIndex: 3 } - - name: "CredentialData" - value: "1234567" - - name: "UserIndex" - value: 1 - - name: "UserStatus" - value: null - - name: "UserType" - value: null - response: - values: - - name: "Status" - value: 0x85 - - - label: - "Step 8: TH sends Clear Credential Command to DUT with the following - fields: a)CredentialType as 1 b)CredentialIndex as 1" - PICS: DRLK.S.F08 && DRLK.S.C26.Rsp - command: "ClearCredential" - timedInteractionTimeoutMs: 10000 - arguments: - values: - - name: "Credential" - value: { CredentialType: 1, CredentialIndex: 1 } - - - label: - "Step 9: TH sends Get Credential command to DUT with the following - fields: a)CredentialType as 1 b)CredentialIndex as 1" - PICS: DRLK.S.F08 && DRLK.S.C24.Rsp && DRLK.S.C25.Tx - 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: - "Step 10: TH sends Set User Command to DUT with the following values: - a)OperationType as 0 b)UserIndex as 2 c)UserName as xxx d)UserUniqueID - as 6452 e)UserStatus as 1 f)UserType as 0 g)CredentialRule as 0" - PICS: DRLK.S.F08 && DRLK.S.C1a.Rsp - command: "SetUser" - timedInteractionTimeoutMs: 10000 - arguments: - values: - - name: "OperationType" - value: 0 - - name: "UserIndex" - value: 2 - - name: "UserName" - value: "xxx" - - name: "UserUniqueID" - value: "6452" - - name: "UserStatus" - value: 1 - - name: "UserType" - value: 0 - - name: "CredentialRule" - value: 0 - - - label: - "Step 11: TH sends Set Credential Command to DUT with the following - fields: a)OperationType as 0 b)Credential as 1 1 c)CredentialData as - 123456 d)UserIndex as 2 e)UserStatus as null f)UserType as null" - PICS: DRLK.S.F08 && DRLK.S.C22.Rsp && DRLK.S.C23.Tx - command: "SetCredential" - timedInteractionTimeoutMs: 10000 - arguments: - values: - - name: "OperationType" - value: 0 - - name: "Credential" - value: { CredentialType: 1, CredentialIndex: 1 } - - name: "CredentialData" - value: "123456" - - name: "UserIndex" - value: 2 - - name: "UserStatus" - value: null - - name: "UserType" - value: null - response: - values: - - name: "Status" - value: 0 - - name: "UserIndex" - value: null - - - label: - "Step 12a: TH sends Clear Credential Command to DUT with the following - fields: a)CredentialType as 1 b)CredentialIndex as 0xFFFE" - PICS: DRLK.S.F08 && DRLK.S.C26.Rsp - command: "ClearCredential" - timedInteractionTimeoutMs: 10000 - arguments: - values: - - name: "Credential" - value: { CredentialType: 1, CredentialIndex: 65534 } - - - label: - "Step 12b: TH sends Get Credential command to DUT with the following - fields: a)CredentialType as 1 b)CredentialIndex as 0xFFFE" - PICS: DRLK.S.F08 && DRLK.S.C24.Rsp && DRLK.S.C25.Tx - command: "GetCredentialStatus" - arguments: - values: - - name: "Credential" - value: { CredentialType: 1, CredentialIndex: 65534 } - response: - values: - - name: "CredentialExists" - value: false - - name: "UserIndex" - value: null - - name: "CreatorFabricIndex" - value: null - - name: "LastModifiedFabricIndex" - value: null - - name: "NextCredentialIndex" - value: null - - - label: - "Step 13: TH sends Get Credential Status Command with a)CredentialType - as 1 b)CredentialIndex as 1" - PICS: DRLK.S.F08 && DRLK.S.C24.Rsp && DRLK.S.C25.Tx - 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: - "Step 14: TH sends Clear Credential Command to DUT with the following - fields: a)CredentialType as 8(Invalid value) b)CredentialIndex as 2" - PICS: DRLK.S.F08 && DRLK.S.C26.Rsp && !DRLK.S.F0d - command: "ClearCredential" - timedInteractionTimeoutMs: 10000 - arguments: - values: - - name: "Credential" - value: { CredentialType: 8, CredentialIndex: 2 } - response: - error: INVALID_COMMAND - - - label: - "Step 14: TH sends Clear Credential Command to DUT with the following - fields: a)CredentialType as 9(Invalid value) b)CredentialIndex as 2" - PICS: DRLK.S.F08 && DRLK.S.C26.Rsp && DRLK.S.F0d - command: "ClearCredential" - timedInteractionTimeoutMs: 10000 - arguments: - values: - - name: "Credential" - value: { CredentialType: 9, CredentialIndex: 2 } - response: - error: INVALID_COMMAND - - - label: "Cleanup the first created user" - command: "ClearUser" - timedInteractionTimeoutMs: 10000 - arguments: - values: - - name: "UserIndex" - value: 1 - - - label: "Cleanup the second created user" - command: "ClearUser" - timedInteractionTimeoutMs: 10000 - arguments: - values: - - name: "UserIndex" - value: 2 diff --git a/src/python_testing/TC_DRLK_2_5.py b/src/python_testing/TC_DRLK_2_5.py new file mode 100644 index 00000000000000..a43067b05bf4af --- /dev/null +++ b/src/python_testing/TC_DRLK_2_5.py @@ -0,0 +1,392 @@ +# +# Copyright (c) 2024 Project CHIP Authors +# All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# See https://github.com/project-chip/connectedhomeip/blob/master/docs/testing/python.md#defining-the-ci-test-arguments +# for details about the block below. +# +# === BEGIN CI TEST ARGUMENTS === +# test-runner-runs: run1 +# test-runner-run/run1/app: ${CHIP_LOCK_APP} +# test-runner-run/run1/factoryreset: True +# test-runner-run/run1/quiet: True +# test-runner-run/run1/app-args: --discriminator 1234 --KVS kvs1 --trace-to json:${TRACE_APP}.json +# test-runner-run/run1/script-args: --storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --PICS src/app/tests/suites/certification/ci-pics-values --trace-to json:${TRACE_TEST_JSON}.json --trace-to perfetto:${TRACE_TEST_PERFETTO}.perfetto +# === END CI TEST ARGUMENTS === + +import logging + +import chip.clusters as Clusters +from chip.interaction_model import InteractionModelError, Status +from matter_testing_support import MatterBaseTest, TestStep, async_test_body, default_matter_test_main, type_matches +from mobly import asserts + +logger = logging.getLogger(__name__) + +drlkcluster = Clusters.DoorLock + + +class TC_DRLK_2_5(MatterBaseTest): + + def steps_TC_DRLK_2_5(self) -> list[TestStep]: + steps = [ + + + TestStep("1", "TH reads NumberOfWeekDaySchedulesSupportedPerUser attribute.", + "Verify that TH is able to read the attribute successfully."), + TestStep("2a", "TH sends SetUser Command to DUT.", "Verify that the DUT sends SUCCESS response."), + TestStep("2b", "TH sends SetWeekDaySchedule Command to DUT.", "Verify that the DUT sends SUCCESS response."), + TestStep("2c", "TH sends SetWeekDaySchedule to DUT with different DaysMaskMap.", + "Verify that the DUT sends SUCCESS response."), + TestStep("3", "TH sends GetWeekDaySchedule Command to DUT.", + "Verify that the DUT sends GetWeekDayScheduleResponse command with expected values."), + TestStep("4", "TH sends SetWeekDaySchedule Command to DUT.", + "Verify that the DUT responds with INVALID_COMMAND."), + TestStep("5", "TH sends SetWeekDaySchedule Command to DUT.", + "Verify that the DUT responds with INVALID_COMMAND."), + TestStep("6", "TH sends SetWeekDaySchedule Command to DUT.", + "Verify that the DUT responds with INVALID_COMMAND."), + TestStep("7", "TH sends SetWeekDaySchedule Command to DUT.", + "Verify that the DUT responds with INVALID_COMMAND."), + TestStep("8", "TH sends GetWeekDaySchedule Command to DUT.", + "Verify that the DUT responds with with INVALID_COMMAND."), + TestStep("9", "TH sends GetWeekDaySchedule Command to DUT.", + "Verify that the DUT responds with GetWeekDayScheduleResponse command with Status NOT_FOUND."), + TestStep("10a", "TH sends ClearWeekDaySchedule Command to DUT.", "Verify that the DUT sends SUCCESS response."), + TestStep("10b", "TH sends ClearWeekDaySchedule Command to DUT.", "Verify that the DUT sends INVALID_COMMAND response."), + TestStep("10c", "TH sends ClearWeekDaySchedule Command to DUT.", "Verify that the DUT sends INVALID_COMMAND response."), + TestStep("11", "TH sends GetWeekDaySchedule Command to DUT.", "Verify that the DUT sends NOT_FOUND response."), + TestStep("12", "TH sends ClearUser Command to DUT.", "Verify that the DUT sends SUCCESS response."), + ] + + return steps + + async def read_attributes_from_dut(self, endpoint, cluster, attribute, expected_status: Status = Status.Success): + try: + attribute_value = await self.read_single_attribute_check_success(endpoint=endpoint, cluster=cluster, + attribute=attribute) + asserts.assert_equal(expected_status, Status.Success) + return attribute_value + except Exception as e: + logging.error(e) + logging.info("Error reading attributes,%s" % (attribute)) + + def pics_TC_DRLK_2_5(self) -> list[str]: + return ["DRLK.S", "DRLK.S.F04"] + + async def clear_user_cmd(self, user_index, expected_status: Status = Status.Success): + try: + await self.send_single_cmd(cmd=Clusters.DoorLock.Commands.ClearUser(userIndex=user_index), + endpoint=self.app_cluster_endpoint, + timedRequestTimeoutMs=1000) + asserts.assert_equal(expected_status, Status.Success) + except InteractionModelError as e: + asserts.assert_equal(e.status, expected_status, f"Unexpected error returned: {e}") + + async def clear_week_day_schedule_cmd(self, week_day_index, user_index, expected_status): + try: + await self.send_single_cmd(cmd=Clusters.DoorLock.Commands.ClearWeekDaySchedule(weekDayIndex=week_day_index, userIndex=user_index), + endpoint=self.app_cluster_endpoint, + timedRequestTimeoutMs=1000) + except InteractionModelError as e: + asserts.assert_equal(e.status, expected_status, f"Unexpected error returned: {e}") + + async def get_weekday_schedule_cmd(self, week_day_index, user_index, days_Mask, start_Hour, start_Minute, end_Hour, end_Minute, expected_status): + + try: + + response = await self.send_single_cmd(cmd=Clusters.DoorLock.Commands.GetWeekDaySchedule( + weekDayIndex=week_day_index, userIndex=user_index), + endpoint=self.app_cluster_endpoint, + timedRequestTimeoutMs=1000) + asserts.assert_true(type_matches(response, Clusters.DoorLock.Commands.GetWeekDayScheduleResponse), + "Unexpected return type for GetWeekDayScheduleResponse") + + if (expected_status == Status.Success): + + asserts.assert_true(response.weekDayIndex == week_day_index, + "Error when executing GetWeekDayScheduleResponse command, weekDayIndex={}".format( + str(response.weekDayIndex))) + asserts.assert_true(response.userIndex == user_index, + "Error when executing GetWeekDayScheduleResponse command, userIndex={}".format( + str(response.userIndex))) + + asserts.assert_true(response.daysMask == days_Mask, + "Error when executing GetWeekDayScheduleResponse command, days_Mask={}".format( + str(response.daysMask))) + asserts.assert_true(response.startHour == start_Hour, + "Error when executing GetWeekDayScheduleResponse command, startHour={}".format( + str(response.startHour))) + asserts.assert_true(response.startMinute == start_Minute, + "Error when executing GetWeekDayScheduleResponse command, startMinute={}".format( + str(response.startMinute))) + asserts.assert_true(response.endHour == end_Hour, + "Error when executing GetWeekDayScheduleResponse command, endHour={}".format( + str(response.endHour))) + asserts.assert_true(response.endMinute == end_Minute, + "Error when executing GetWeekDayScheduleResponse command, endMinute={}".format( + str(response.endMinute))) + + return response + except InteractionModelError as e: + logging.error(e) + asserts.assert_equal(e.status, expected_status, f"Unexpected error returned: {e}") + + async def set_week_days_schedule_cmd(self, week_day_index, user_index, day_mask_map_index, start_Hour, start_Minute, end_Hour, end_Minute, expected_status): + try: + + await self.send_single_cmd(cmd=Clusters.DoorLock.Commands.SetWeekDaySchedule( + weekDayIndex=week_day_index, + userIndex=user_index, + daysMask=day_mask_map_index, + startHour=start_Hour, + startMinute=start_Minute, + endHour=end_Hour, + endMinute=end_Minute), + endpoint=self.app_cluster_endpoint, + timedRequestTimeoutMs=1000) + except InteractionModelError as e: + logging.error(e) + asserts.assert_equal(e.status, expected_status, f"Unexpected error returned: {e}") + + async def clear_credentials_cmd(self, credential, step=None, expected_status: Status = Status.Success): + try: + + await self.send_single_cmd(cmd=Clusters.DoorLock.Commands.ClearCredential(credential=credential), + endpoint=self.app_cluster_endpoint, + timedRequestTimeoutMs=1000) + except InteractionModelError as e: + logging.exception(e) + asserts.assert_equal(e.status, expected_status, f"Unexpected error returned: {e}") + + @async_test_body + async def test_TC_DRLK_2_5(self): + + self.common_cluster_endpoint = 0 + self.app_cluster_endpoint = 1 + user_name = "xxx" + user_index = 1 + user_unique_id = 6452 + week_day_index = 1 + day_mask_map_index = 1 + start_Hour = 15 + start_Minute = 45 + end_Hour = 16 + end_Minute = 55 + + self.step("1") + if self.pics_guard(self.check_pics("DRLK.S.F04") and self.check_pics("DRLK.S.A0014")): + number_week_day_schedules_supported_per_user = await self.read_attributes_from_dut(endpoint=self.app_cluster_endpoint, + cluster=drlkcluster, + attribute=Clusters.DoorLock.Attributes.NumberOfWeekDaySchedulesSupportedPerUser) + logging.info("NumberOfWeekDaySchedulesSupportedPerUser %s" % (number_week_day_schedules_supported_per_user)) + asserts.assert_in(number_week_day_schedules_supported_per_user, range( + 0, 255), "NumberOfWeekDaySchedulesSupportedPerUser value is out of range") + self.step("2a") + if self.pics_guard(self.check_pics("DRLK.S.F08") and self.check_pics("DRLK.S.C1a.Rsp")): + try: + await self.send_single_cmd(cmd=drlkcluster.Commands.SetUser( + operationType=Clusters.DoorLock.Enums.DataOperationTypeEnum.kAdd, + userIndex=user_index, + userName=user_name, + userUniqueID=user_unique_id, + userStatus=Clusters.DoorLock.Enums.UserStatusEnum.kOccupiedEnabled, + userType=Clusters.DoorLock.Enums.UserTypeEnum.kUnrestrictedUser, + credentialRule=Clusters.DoorLock.Enums.CredentialRuleEnum.kSingle), + endpoint=self.app_cluster_endpoint, + timedRequestTimeoutMs=1000) + except InteractionModelError as e: + logging.exception(e) + + self.step("2b") + if self.pics_guard(self.check_pics("DRLK.S.F04") and self.check_pics("DRLK.S.C0b.Rsp")): + try: + await self.set_week_days_schedule_cmd( + week_day_index, + user_index, + day_mask_map_index, + start_Hour, + start_Minute, + end_Hour, + end_Minute, + Status.Success) + + except InteractionModelError as e: + logging.exception(e) + self.step("2c") + if self.pics_guard(self.check_pics("DRLK.S.F04") and self.check_pics("DRLK.S.C0b.Rsp")): + try: + days_masks_map = [2, 4, 8, 16, 32, 64, 24, 42, 51, 107, 123, 127] + for day_mask_map_index in days_masks_map: + await self.set_week_days_schedule_cmd( + week_day_index, + user_index, + day_mask_map_index, + start_Hour, + start_Minute, + end_Hour, + end_Minute, + Status.Success) + except InteractionModelError as e: + logging.exception(e) + + self.step("3") + if self.pics_guard(self.check_pics("DRLK.S.F04") and self.check_pics("DRLK.S.C0c.Rsp") and self.check_pics("DRLK.S.C0c.Tx")): + day_mask_map_index = 127 + await self.get_weekday_schedule_cmd( + week_day_index, + user_index, + day_mask_map_index, + start_Hour, + start_Minute, + end_Hour, + end_Minute, + Status.Success) + self.step("4") + if self.pics_guard(self.check_pics("DRLK.S.F04") and self.check_pics("DRLK.S.C0b.Rsp")): + week_day_index = 0 + day_mask_map_index = 2 + await self.set_week_days_schedule_cmd( + week_day_index, + user_index, + day_mask_map_index, + start_Hour, + start_Minute, + end_Hour, + end_Minute, + Status.InvalidCommand) + self.step("5") + if self.pics_guard(self.check_pics("DRLK.S.F04") and self.check_pics("DRLK.S.C0b.Rsp")): + week_day_index = 1 # Valid value + day_mask_map_index = 0 # invalid value + await self.set_week_days_schedule_cmd( + week_day_index, + user_index, + day_mask_map_index, + start_Hour, + start_Minute, + end_Hour, + end_Minute, + Status.InvalidCommand) + self.step("6") + if self.pics_guard(self.check_pics("DRLK.S.F04") and self.check_pics("DRLK.S.C0b.Rsp")): + week_day_index = 1 # valid value + day_mask_map_index = 128 # invalid value + await self.set_week_days_schedule_cmd( + week_day_index, + user_index, + day_mask_map_index, + start_Hour, + start_Minute, + end_Hour, + end_Minute, + Status.InvalidCommand) + + self.step("7") + if self.pics_guard(self.check_pics("DRLK.S.F04") and self.check_pics("DRLK.S.C0b.Rsp")): + week_day_index = 1 # valid value + day_mask_map_index = 1 # valid value + start_Hour = 18 # inavlid value > end hour + await self.set_week_days_schedule_cmd( + week_day_index, + user_index, + day_mask_map_index, + start_Hour, + start_Minute, + end_Hour, + end_Minute, + Status.InvalidCommand) + + self.step("8") + if self.pics_guard(self.check_pics("DRLK.S.F04") and self.check_pics("DRLK.S.C0c.Rsp") and self.check_pics("DRLK.S.C0c.Tx")): + week_day_index = 0 + user_index = 1 + await self.get_weekday_schedule_cmd( + week_day_index, + user_index, + day_mask_map_index, + start_Hour, + start_Minute, + end_Hour, + end_Minute, + Status.InvalidCommand) + self.step("9") + if self.pics_guard(self.check_pics("DRLK.S.F04") and self.check_pics("DRLK.S.C0c.Rsp") and self.check_pics("DRLK.S.C0c.Tx")): + week_day_index = 1 + user_index = 2 # invalid value as it does not exist + await self.get_weekday_schedule_cmd( + week_day_index, + user_index, + day_mask_map_index, + start_Hour, + start_Minute, + end_Hour, + end_Minute, + Status.NotFound) + self.step("10a") + if self.pics_guard(self.check_pics("DRLK.S.F04") and self.check_pics("DRLK.S.C0d.Rsp")): + week_day_index = 1 + user_index = 1 + await self.clear_week_day_schedule_cmd(week_day_index, + user_index, + Status.Success) + + self.step("10b") + if self.pics_guard(self.check_pics("DRLK.S.F04") and self.check_pics("DRLK.S.C0d.Rsp")): + week_day_index = 0 + user_index = 1 + try: + await self.send_single_cmd(cmd=Clusters.DoorLock.Commands.ClearWeekDaySchedule(week_day_index, user_index), + endpoint=self.app_cluster_endpoint, + timedRequestTimeoutMs=1000) + asserts.fail("Unexpected success in sending ClearWeekDaySchedule Command with invalid week_day_index") + + except InteractionModelError as e: + asserts.assert_equal(e.status, Status.InvalidCommand, + "Unexpected error sending ClearWeekDaySchedule Command with invalid week_day_index") + self.step("10c") + if self.pics_guard(self.check_pics("DRLK.S.F04") and self.check_pics("DRLK.S.C0d.Rsp")): + week_day_index = 1 + user_index = 0 + + try: + await self.send_single_cmd(cmd=Clusters.DoorLock.Commands.ClearWeekDaySchedule(week_day_index, user_index), + endpoint=self.app_cluster_endpoint, + timedRequestTimeoutMs=1000) + asserts.fail("Unexpected success in sending ClearWeekDaySchedule Command with invalid week_day_index") + + except InteractionModelError as e: + asserts.assert_equal(e.status, Status.InvalidCommand, + "Unexpected error sending ClearWeekDaySchedule Command with invalid week_day_index") + + self.step("11") + if self.pics_guard(self.check_pics("DRLK.S.F04") and self.check_pics("DRLK.S.C0c.Rsp") and self.check_pics("DRLK.S.C0c.Tx")): + user_index = 1 # invalid value as it is cleared + await self.get_weekday_schedule_cmd( + week_day_index, + user_index, + day_mask_map_index, + start_Hour, + start_Minute, + end_Hour, + end_Minute, + Status.NotFound) + self.step("12") + if self.pics_guard(self.check_pics("DRLK.S.F08") and self.check_pics("DRLK.S.C1d.Rsp")): + await self.clear_user_cmd(user_index) + + +if __name__ == '__main__': + default_matter_test_main() diff --git a/src/python_testing/TC_DRLK_2_9.py b/src/python_testing/TC_DRLK_2_9.py new file mode 100644 index 00000000000000..954ca7dd7b2f3d --- /dev/null +++ b/src/python_testing/TC_DRLK_2_9.py @@ -0,0 +1,799 @@ +# +# Copyright (c) 2024 Project CHIP Authors +# All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# See https://github.com/project-chip/connectedhomeip/blob/master/docs/testing/python.md#defining-the-ci-test-arguments +# for details about the block below. +# +# === BEGIN CI TEST ARGUMENTS === +# test-runner-runs: run1 +# test-runner-run/run1/app: ${CHIP_LOCK_APP} +# test-runner-run/run1/factoryreset: True +# test-runner-run/run1/quiet: True +# test-runner-run/run1/app-args: --discriminator 1234 --KVS kvs1 --trace-to json:${TRACE_APP}.json +# test-runner-run/run1/script-args: --storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --PICS src/app/tests/suites/certification/ci-pics-values --trace-to json:${TRACE_TEST_JSON}.json --trace-to perfetto:${TRACE_TEST_PERFETTO}.perfetto +# === END CI TEST ARGUMENTS === + +import logging +import random +import string + +import chip.clusters as Clusters +from chip.clusters.Types import NullValue +from chip.interaction_model import InteractionModelError, Status +from drlk_2_x_common import DRLK_COMMON +from matter_testing_support import MatterBaseTest, TestStep, async_test_body, default_matter_test_main, type_matches +from mobly import asserts + +logger = logging.getLogger(__name__) + +drlkcluster = Clusters.DoorLock + + +class TC_DRLK_2_9(MatterBaseTest, DRLK_COMMON): + + def steps_TC_DRLK_2_9(self) -> list[TestStep]: + steps = [ + + TestStep("1", "TH reads NumberOfTotalUsersSupported attribute.", + "Verify that TH is able to read the attribute successfully."), + TestStep("2a", "TH sends SetUser Command to DUT.", "Verify that the DUT sends SUCCESS response"), + TestStep("2b", "TH reads MinPINCodeLength attribute .", + "Verify that TH is able to read the attribute successfully and value is within range."), + TestStep("2c", "TH reads MaxPINCodeLength attribute.", + "Verify that TH is able to read the attribute successfully and value is within range."), + TestStep("2d", "TH reads MinRFIDCodeLength attribute.", + "Verify that TH is able to read the attribute successfully."), + TestStep("2e", "TH reads MaxRFIDCodeLength attribute.", + "Verify that TH is able to read the attribute successfully and value is within range."), + TestStep("2f", "TH sends SetCredential Command to DUT.", + "Verify that the DUT responds with SetCredentialResponse command with Status SUCCESS."), + TestStep("3", "TH sends GetCredentialStatus Command .", + "Verify that the DUT responds with GetCredentialStatusResponse Command ."), + TestStep("4", "TH sends SetCredential Command to DUT.", + "Verify that the DUT responds with SetCredentialResponse command with Status INVALID_COMMAND."), + TestStep("5", "TH sends SetCredential Command to DUT.", + "Verify that the DUT responds with SetCredentialResponse command with Status DUPLICATE."), + TestStep("6a", "TH sends SetCredential Command to DUT.", + "Verify that the DUT responds with SetCredentialResponse command with Status DUPLICATE or OCCUPIED."), + TestStep("6b", "TH sends SetCredential Command to DUT.", + "Verify that the DUT responds with SetCredentialResponse command with Status DUPLICATE or OCCUPIED."), + TestStep("7", "TH sends SetCredential Command to DUT.", + "Verify that the DUT responds with SetCredentialResponse command with Status INVALID_COMMAND."), + TestStep("8", "TH sends ClearCredential Command to DUT.", + "Verify that the DUT sends SUCCESS response."), + TestStep("9a", "TH sends GetCredentialStatus command to DUT ", + "Verify that the DUT responds with GetCredentialStatusResponse Command."), + TestStep("9b", "TH sends ClearUser Command to DUT.", + "Verify that the DUT sends SUCCESS response"), + TestStep("10", "TH sends SetUser Command to DUT.", + "Verify that the DUT sends SUCCESS response."), + TestStep("11", "TH sends SetCredential Command to DUT.", + "Verify that the DUT responds with SetCredentialResponse command with Status SUCCESS."), + TestStep("12a", "TH sends ClearCredential Command to DUT.", + " Verify that the DUT sends SUCCESS response."), + TestStep("13", " TH sends GetCredentialStatus Command.", + "Verify that the DUT responds with GetCredentialStatusResponse Command with credentialExists=FALSE."), + TestStep("14a", "TH sends ClearCredential Command to DUT", + "if {PICS_SF_ALIRO} verify that the DUT sends a SUCCESS response else DUT sends an INVALID_COMMAND response."), + TestStep("14b", "TH sends ClearCredential Command to DUT with Invalid Credential Type.", + "Verify that the DUT sends an INVALID_COMMAND."), + TestStep("14c", "TH sends ClearUser Command to DUT to clear all the users.", + "Verify that the DUT sends SUCCESS response."), + TestStep("14d", "TH reads NumberOfPINUsersSupported attribute.", + "Verify that TH is able to read the attribute successfully and value is within range."), + TestStep("15a", "TH reads NumberOfCredentialsSupportedPerUser attribute from DUT.", + "Verify that TH is able to read the attribute successfully and value is within range."), + TestStep("15b", "TH sends SetUser Command to DUT.", + "Verify that the DUT sends SUCCESS response."), + TestStep("15c", "TH sends SetCredential Command to DUT.", + "Verify that the DUT sends SetCredentialResponse command with Status SUCCESS."), + TestStep("15d", " TH sends SetCredential Command with CredentialIndex as 'max-num-credential-user'.", + "Verify that the DUT sends SetCredentialResponse command with Status RESOURCE_EXHAUSTION."), + TestStep("15e", "TH sends ClearCredential Command to DUT to clear all the credentials of PIN type.", + "Verify that the DUT sends SUCCESS response."), + TestStep("15f", "TH sends ClearUser Command to DUT with UserIndex as 0xFFFE to clear all the users.", + "Verify that the DUT sends SUCCESS response."), + TestStep("16", " TH sends SetUser Command to DUT.", + "Verify that the DUT sends SUCCESS response"), + TestStep("17", "TH sends SetCredential Command to DUT with CredentialType.RFID.", + "Verify that the DUT sends SetCredentialResponse command with Status SUCCESS."), + TestStep("18", "TH sends SetCredential Command to DUT with CredentialType.PIN.", + "Verify that the DUT sends SetCredentialResponse command with Status SUCCESS."), + TestStep("19", "TH sends GetUser Command to DUT.", + "Verify that the DUT responds with GetUserResponse Command."), + TestStep("20", "TH sends SetCredential Command to DUT to modify the CredentialData.", + "Verify that the DUT sends SetCredentialResponse command with Status SUCCESS."), + TestStep("21", "TH sends GetUser Command to DUT.", + "Verify that the DUT responds with GetUserResponse Command."), + TestStep("22", "TH sends ClearCredential Command to DUT to clear all the credentials.", + "Verify that the DUT sends SUCCESS response."), + TestStep("23", "TH sends ClearUser Command to DUT to clear all the users.", + "Verify that the DUT sends SUCCESS response."), + TestStep("24", "TH sends SetUser Command to DUT.", + "Verify that the DUT sends SUCCESS response."), + TestStep("25", "TH sends ClearAliroReaderConfig Command to DUT.", + "Verify that the DUT sends SUCCESS response."), + TestStep("26", ",TH sends SetAliroReaderConfig Command to DUT without GroupResolvingKey.", + "Verify that DUT sends success response."), + TestStep("27", ",TH sends SetAliroReaderConfig Command to DUT with GroupResolvingKey.", + "Verify that DUT sends success response."), + TestStep("28", "TH sends SetCredential Command CredentialType as AliroEvictableEndpointKey.", + "Verify that the DUT responds with SetCredentialResponse commad with status success "), + TestStep("29", "TH sends SetCredential Command to DUT with CredentialType.PIN.", + "Verify that the DUT sends SetCredentialResponse command with Status SUCCESS."), + TestStep("30", "TH sends GetUser Command to DUT.", + "Verify that the DUT sends SUCCESS response."), + TestStep("31", "TH sends SetCredential Command to modify PIN CredentialType", + "Verify that the DUT responds with SetCredentialResponse command with status success "), + TestStep("32", "TH sends GetUser Command to DUT.", + "Verify that the DUT sends SUCCESS response."), + TestStep("33", "TH sends SetCredential Command to modify AliroEvictableEndpointKey CredentialType", + "Verify that the DUT responds with SetCredentialResponse command with status success "), + TestStep("34", "TH sends GetUser Command to DUT.", + "Verify that the DUT sends SUCCESS response."), + TestStep("35", "TH sends ClearUser Command to DUT.", + "Verify that the DUT sends SUCCESS response."), + TestStep("36", "TH sends ClearCredential Command to DUT to clear all the credentials.", + "Verify that the DUT sends SUCCESS response."), + TestStep("37", "TH sends ClearAliroReaderConfig Command to DUT.", + "Verify that the DUT sends SUCCESS response."), ] + + return steps + + async def read_attributes_from_dut(self, endpoint, cluster, attribute, expected_status: Status = Status.Success): + try: + attribute_value = await self.read_single_attribute_check_success(endpoint=endpoint, cluster=cluster, + attribute=attribute) + asserts.assert_equal(expected_status, Status.Success) + return attribute_value + except Exception as e: + logging.error(e) + asserts.assert_equal(expected_status, Status.Success, + f"Error reading attributes, response={attribute_value}") + + def pics_TC_DRLK_2_9(self) -> list[str]: + return ["DRLK.S"] + + async def generate_max_pincode_len(self, maxPincodeLength): + return ''.join(random.choices(string.digits, k=maxPincodeLength)) + + async def generate_code(self): + if (self.maxpincodelength is not None): + validpincodestr = await self.generate_max_pincode_len(self.maxpincodelength) + self.pin_code = bytes(validpincodestr, 'ascii') + validpincodestr = await self.generate_max_pincode_len(self.maxpincodelength) + self.pin_code1 = bytes(validpincodestr, 'ascii') + validpincodestr = await self.generate_max_pincode_len(self.maxpincodelength) + self.pin_code2 = bytes(validpincodestr, 'ascii') + inavlidpincodestr = await self.generate_max_pincode_len(self.maxpincodelength+1) + self.inavlid_pincode = bytes(inavlidpincodestr, 'ascii') + if (self.maxrfidcodelength is not None): + validpincodestr = await self.generate_max_pincode_len(self.maxrfidcodelength) + self.rfid_tag = bytes(validpincodestr, 'ascii') + + async def send_clear_user_cmd(self, user_index, expected_status: Status = Status.Success): + try: + await self.send_single_cmd(cmd=Clusters.DoorLock.Commands.ClearUser(userIndex=user_index), + endpoint=self.app_cluster_endpoint, + timedRequestTimeoutMs=1000) + asserts.assert_equal(expected_status, Status.Success) + except InteractionModelError as e: + asserts.assert_equal(e.status, expected_status, f"Unexpected error returned: {e}") + + async def get_user(self, userindex, username, useruniqueid, credentiallist, expected_status: Status = Status.Success): + try: + response = await self.send_single_cmd(cmd=Clusters.DoorLock.Commands.GetUser(userIndex=userindex), + endpoint=self.app_cluster_endpoint, + timedRequestTimeoutMs=1000) + + asserts.assert_true(type_matches(response, Clusters.DoorLock.Commands.GetUserResponse), + "Unexpected return type for GetUserResponse") + asserts.assert_true(response.userIndex == userindex, + "Error when executing GetUserResponse command, userIndex={}".format( + str(response.userIndex))) + asserts.assert_true(response.userName == username, + "Error when executing GetUserResponse command, userName={}".format( + str(response.userName))) + asserts.assert_true(response.userUniqueID == useruniqueid, + "Error when executing GetUserResponse command, userUniqueID={}".format( + str(response.userUniqueID))) + logging.info("Credentials value is GetUserResponse Command %s" % (str(response.credentials))) + + asserts.assert_equal(len(credentiallist), len(response.credentials), "Error mismatch in expected credential from GetUserResponse command = {}".format( + str(credentiallist))) + # traverse through input credentials and match each value with the resonse credential + for input_credential_index in range(len(credentiallist)): + match_found = False + for response_credential_index in range(len(response.credentials)): + if (response.credentials[response_credential_index] == credentiallist[input_credential_index]): + match_found = True + break + asserts.assert_equal(match_found, True, "Error mismatch in expected credential from GetUserResponse command = {}".format( + str(credentiallist))) + + except InteractionModelError as e: + asserts.assert_equal(e.status, expected_status, f"Unexpected error returned: {e}") + + async def get_credentials_status(self, credentialIndex: int, credentialType: drlkcluster.Enums.CredentialTypeEnum, credential_exists, next_credential_index): + + try: + credentials_struct = drlkcluster.Structs.CredentialStruct(credentialIndex=credentialIndex, + credentialType=credentialType) + response = await self.send_single_cmd(endpoint=self.app_cluster_endpoint, timedRequestTimeoutMs=1000, + cmd=drlkcluster.Commands.GetCredentialStatus( + credential=credentials_struct)) + asserts.assert_true(type_matches(response, Clusters.DoorLock.Commands.GetCredentialStatusResponse), + "Unexpected return type for GetCredentialStatus") + asserts.assert_true(response.credentialExists == credential_exists, + "Error when executing GetCredentialStatus command, credentialExists={}".format( + str(response.credentialExists))) + if (not credential_exists): + asserts.assert_true(response.userIndex == NullValue, + "Error when executing GetCredentialStatus command, userIndex={}".format( + str(response.userIndex))) + asserts.assert_true(response.nextCredentialIndex == next_credential_index, + "Error when executing GetCredentialStatus command, nextCredentialIndex={}".format( + str(response.nextCredentialIndex))) + return response + except InteractionModelError as e: + logging.error(e) + asserts.assert_equal(e.status, Status.Success, f"Unexpected error returned: {e}") + + async def set_credential_cmd(self, credential_enum: drlkcluster.Enums.CredentialTypeEnum, statuscode, credentialIndex, + operationType, userIndex, credentialData, userStatus, userType): + custom_status_code = 149 + + credentials = drlkcluster.Structs.CredentialStruct( + credentialType=credential_enum, + credentialIndex=credentialIndex) + try: + + logging.info("Credential Data is %s" % (credentialData)) + response = await self.send_single_cmd(cmd=drlkcluster.Commands.SetCredential( + operationType=operationType, + credential=credentials, + credentialData=credentialData, + userStatus=userStatus, + userType=userType, + userIndex=userIndex), + endpoint=self.app_cluster_endpoint, + timedRequestTimeoutMs=1000) + asserts.assert_true(type_matches(response, drlkcluster.Commands.SetCredentialResponse), + "Unexpected return type for SetCredential") + asserts.assert_equal(response.userIndex, NullValue) + if (statuscode != custom_status_code): + asserts.assert_true(response.status == statuscode, + "Error sending SetCredential command, status={}".format(str(response.status))) + else: + asserts.assert_true(response.status == 2 or response.status == 3, + "Error sending SetCredential command, status={}".format(str(response.status))) + return response.nextCredentialIndex + except InteractionModelError as e: + logging.exception(e) + asserts.assert_equal(e.status, statuscode, f"Unexpected error returned: {e}") + return -1 + + async def clear_credentials_cmd(self, credential, expected_status: Status = Status.Success): + try: + + await self.send_single_cmd(cmd=Clusters.DoorLock.Commands.ClearCredential(credential=credential), + endpoint=self.app_cluster_endpoint, + timedRequestTimeoutMs=1000) + except InteractionModelError as e: + logging.exception(e) + asserts.assert_equal(e.status, expected_status, f"Unexpected error returned: {e}") + + async def send_clear_aliro_reader_config_cmd(self, expected_status: Status = Status.Success): + try: + await self.send_single_cmd(cmd=Clusters.DoorLock.Commands.ClearAliroReaderConfig(), + endpoint=self.app_cluster_endpoint, + timedRequestTimeoutMs=1000) + asserts.assert_equal(expected_status, Status.Success) + except InteractionModelError as e: + asserts.assert_equal(e.status, expected_status, f"Unexpected error returned: {e}") + + async def send_set_aliro_reader_config_cmd(self, use_group_resolving_key: bool, + expected_status: Status = Status.Success): + try: + + signingKey = bytes.fromhex("89d085fc302ca53e279bfcdecdf3c4adb2f5d9bc9ea6c49e9566d144367df3ff") + verificationKey = bytes.fromhex( + "047a4c992d753924cdf3779a3c84fec2debaa6f0b3084450878acc7ddcce7856ae57b1ebbe2561015103dd7474c2a183675378ec55f1e465ac3436bf3dd5ca54d4") + groupIdentifier = bytes.fromhex("89d085fc302ca53e279bfcdecdf3c4ad") + groupResolvingKey = bytes.fromhex("89d0859bfcdecdf3c4adfc302ca53e27") + + # Checks Pics condition + if use_group_resolving_key is False: + pics_check = self.pics_guard(self.check_pics("DRLK.S.F0d") and not self.check_pics("DRLK.S.F0e") and + self.check_pics("DRLK.S.C28.Rsp")) + else: + pics_check = self.pics_guard(self.check_pics("DRLK.S.F0e") and self.check_pics("DRLK.S.C28.Rsp")) + + if not use_group_resolving_key and pics_check: + await self.send_single_cmd(cmd=Clusters.DoorLock.Commands.SetAliroReaderConfig( + signingKey=signingKey, + verificationKey=verificationKey, + groupIdentifier=groupIdentifier), + endpoint=self.app_cluster_endpoint, + timedRequestTimeoutMs=1000) + asserts.assert_equal(expected_status, Status.Success) + elif use_group_resolving_key and pics_check: + await self.send_single_cmd(cmd=Clusters.DoorLock.Commands.SetAliroReaderConfig( + signingKey=signingKey, + verificationKey=verificationKey, + groupIdentifier=groupIdentifier, + groupResolvingKey=groupResolvingKey), + endpoint=self.app_cluster_endpoint, + timedRequestTimeoutMs=1000) + asserts.assert_equal(expected_status, Status.Success) + except InteractionModelError as e: + logging.exception(f"Got exception when performing SetAliroReaderConfig {e}") + asserts.assert_equal(e.status, expected_status, f"Unexpected error returned: {e}") + + @async_test_body + async def test_TC_DRLK_2_9(self): + + self.Attrib = 0 + numberofcredentialsupportedperuser = None + self.app_cluster_endpoint = 1 + invalid_credential_type = 9 + user_unique_id = 6459 + user_name = "xxx" + credentialIndex_1 = 1 + credentialIndex_2 = 2 + credentialIndex_3 = 3 + userIndex_1 = 1 + userIndex_2 = 2 + invalid_user_status = 5 + invalid_user_type = 10 + + self.pin_code = b"" + self.pin_code1 = b"" + self.pin_code2 = b"" + self.inavlid_pincode = b"" + self.rfid_tag = b"" + + self.minpincodelength = None + self.maxpincodelength = None + self.maxrfidcodelength = None + self.minrfidcodelength = None + + self.endpoint = self.user_params.get("endpoint", 1) + print("endpoint", self.endpoint) + + # Aliro Keys for setting Aliro configuration and credential + + aliroevictableendpointkey1 = bytes.fromhex( + "047a4c772d753924cdf3779a3c84fec2debaa6f0b3084450878acc7ddcce7856ae57b1ebbe2561015103dd7474c2a183675378ec55f1e465ac3436bf3dd5ca54d4") + + aliroevictableendpointkey2 = bytes.fromhex( + "047a4c662d753924cdf3779a3c84fec2debaa6f0b3084450878acc7ddcce7856ae57b1ebbe2561015103dd7474c2a183675378ec55f1e465ac3436bf3dd5ca54d4") + + self.step("1") + if self.pics_guard(self.check_pics("DRLK.S.F08") and self.check_pics("DRLK.S.A0011")): + self.numberoftotaluserssupported = await self.read_attributes_from_dut(endpoint=self.app_cluster_endpoint, + cluster=drlkcluster, + attribute=Clusters.DoorLock.Attributes.NumberOfTotalUsersSupported) + asserts.assert_in(self.numberoftotaluserssupported, range( + 0, 65534), "NumberOfTotalUsersSupported value is out of range") + self.step("2a") + if self.pics_guard(self.check_pics("DRLK.S.F08") and self.check_pics("DRLK.S.C1a.Rsp")): + try: + await self.send_single_cmd(cmd=drlkcluster.Commands.SetUser( + operationType=Clusters.DoorLock.Enums.DataOperationTypeEnum.kAdd, + userIndex=userIndex_1, + userName=user_name, + userUniqueID=user_unique_id, + userStatus=Clusters.DoorLock.Enums.UserStatusEnum.kOccupiedEnabled, + userType=Clusters.DoorLock.Enums.UserTypeEnum.kUnrestrictedUser, + credentialRule=Clusters.DoorLock.Enums.CredentialRuleEnum.kSingle), + endpoint=self.app_cluster_endpoint, + timedRequestTimeoutMs=1000) + except InteractionModelError as e: + logging.exception(e) + + self.step("2b") + if self.pics_guard(self.check_pics("DRLK.S.F08") and self.check_pics("DRLK.S.F00")): + self.minpincodelength = await self.read_attributes_from_dut(endpoint=self.app_cluster_endpoint, + cluster=drlkcluster, + attribute=Clusters.DoorLock.Attributes.MinPINCodeLength) + asserts.assert_in(self.minpincodelength, range( + 0, 255), "MinPINCodeLength value is out of range") + self.step("2c") + if self.pics_guard(self.check_pics("DRLK.S.F08") and self.check_pics("DRLK.S.F00")): + self.maxpincodelength = await self.read_attributes_from_dut(endpoint=self.app_cluster_endpoint, + cluster=drlkcluster, + attribute=Clusters.DoorLock.Attributes.MaxPINCodeLength) + asserts.assert_in(self.maxpincodelength, range( + 0, 255), "MaxPINCodeLength value is out of range") + self.step("2d") + if self.pics_guard(self.check_pics("DRLK.S.F01")): + self.minrfidcodelength = await self.read_attributes_from_dut(endpoint=self.app_cluster_endpoint, + cluster=drlkcluster, + attribute=Clusters.DoorLock.Attributes.MinRFIDCodeLength) + asserts.assert_in(self.minrfidcodelength, range( + 0, 255), "MinRFIDCodeLength value is out of range") + self.step("2e") + if self.pics_guard(self.check_pics("DRLK.S.F01")): + self.maxrfidcodelength = await self.read_attributes_from_dut(endpoint=self.app_cluster_endpoint, + cluster=drlkcluster, + attribute=Clusters.DoorLock.Attributes.MaxRFIDCodeLength) + asserts.assert_in(self.maxrfidcodelength, range( + 0, 255), "MaxRFIDCodeLength value is out of range") + self.step("2f") + await self.generate_code() + if self.pics_guard(self.check_pics("DRLK.S.F00") and self.check_pics("DRLK.S.F08") + and self.check_pics("DRLK.S.C22.Rsp") and self.check_pics("DRLK.S.C23.Tx")): + + await self.set_credential_cmd(credentialData=self.pin_code, + operationType=drlkcluster.Enums.DataOperationTypeEnum.kAdd, + credential_enum=drlkcluster.Enums.CredentialTypeEnum.kPin, + credentialIndex=credentialIndex_1, userIndex=userIndex_1, userStatus=NullValue, userType=NullValue, statuscode=Status.Success) + self.step("3") + if self.pics_guard(self.check_pics("DRLK.S.F00") and self.check_pics("DRLK.S.F08") + and self.check_pics("DRLK.S.C24.Rsp") and self.check_pics("DRLK.S.C25.Tx")): + await self.get_credentials_status(credentialIndex=credentialIndex_1, + credentialType=drlkcluster.Enums.CredentialTypeEnum.kPin, credential_exists=True, next_credential_index=NullValue) + self.step("4") + if self.pics_guard(self.check_pics("DRLK.S.F00") and self.check_pics("DRLK.S.F08") + and self.check_pics("DRLK.S.C22.Rsp") and self.check_pics("DRLK.S.C23.Tx")): + + await self.set_credential_cmd(credentialData=self.inavlid_pincode, + operationType=drlkcluster.Enums.DataOperationTypeEnum.kAdd, + credential_enum=drlkcluster.Enums.CredentialTypeEnum.kPin, + credentialIndex=credentialIndex_2, userIndex=NullValue, userStatus=invalid_user_status, userType=invalid_user_type, statuscode=Status.InvalidCommand) + self.step("5") + if self.pics_guard(self.check_pics("DRLK.S.F00") and self.check_pics("DRLK.S.F08") + and self.check_pics("DRLK.S.C22.Rsp") and self.check_pics("DRLK.S.C23.Tx")): + await self.set_credential_cmd(credentialData=self.pin_code, + operationType=drlkcluster.Enums.DataOperationTypeEnum.kAdd, + credential_enum=drlkcluster.Enums.CredentialTypeEnum.kPin, + credentialIndex=credentialIndex_2, userIndex=NullValue, userStatus=NullValue, userType=NullValue, statuscode=2) + + self.step("6a") + if self.pics_guard(self.check_pics("DRLK.S.F00") and self.check_pics("DRLK.S.F08") + and self.check_pics("DRLK.S.C22.Rsp") and self.check_pics("DRLK.S.C23.Tx")): + await self.set_credential_cmd(credentialData=self.pin_code, + operationType=drlkcluster.Enums.DataOperationTypeEnum.kAdd, + credential_enum=drlkcluster.Enums.CredentialTypeEnum.kPin, + credentialIndex=credentialIndex_1, userIndex=NullValue, userStatus=NullValue, userType=NullValue, statuscode=149) + self.step("6b") + if self.pics_guard(self.check_pics("DRLK.S.F00") and self.check_pics("DRLK.S.F08") + and self.check_pics("DRLK.S.C22.Rsp") and self.check_pics("DRLK.S.C23.Tx")): + await self.set_credential_cmd(credentialData=self.pin_code1, + operationType=drlkcluster.Enums.DataOperationTypeEnum.kAdd, + credential_enum=drlkcluster.Enums.CredentialTypeEnum.kPin, + credentialIndex=credentialIndex_1, userIndex=NullValue, userStatus=NullValue, userType=NullValue, statuscode=149) + self.step("7") + if self.pics_guard(self.check_pics("DRLK.S.F00") and self.check_pics("DRLK.S.F08") + and self.check_pics("DRLK.S.C22.Rsp") and self.check_pics("DRLK.S.C23.Tx")): + await self.set_credential_cmd(credentialData=self.pin_code2, + operationType=drlkcluster.Enums.DataOperationTypeEnum.kModify, + credential_enum=drlkcluster.Enums.CredentialTypeEnum.kPin, + credentialIndex=credentialIndex_3, userIndex=userIndex_1, userStatus=NullValue, userType=NullValue, statuscode=Status.InvalidCommand) + self.step("8") + if self.pics_guard(self.check_pics("DRLK.S.F00") and self.check_pics("DRLK.S.F08") and self.check_pics("DRLK.S.C26.Rsp")): + credentials = drlkcluster.Structs.CredentialStruct(credentialIndex=1, + credentialType=drlkcluster.Enums.CredentialTypeEnum.kPin) + await self.clear_credentials_cmd(credential=credentials) + + self.step("9a") + if self.pics_guard(self.check_pics("DRLK.S.F00") and self.check_pics("DRLK.S.F08") and self.check_pics("DRLK.S.C24.Rsp")): + await self.get_credentials_status(credentialIndex=credentialIndex_1, + credentialType=drlkcluster.Enums.CredentialTypeEnum.kPin, credential_exists=False, next_credential_index=NullValue) + self.step("9b") + if self.pics_guard(self.check_pics("DRLK.S.F08") and self.check_pics("DRLK.S.C1d.Rsp")): + await self.send_clear_user_cmd(user_index=1) + + self.step("10") + if self.pics_guard(self.check_pics("DRLK.S.F08") and self.check_pics("DRLK.S.C1a.Rsp")): + try: + await self.send_single_cmd(cmd=drlkcluster.Commands.SetUser( + operationType=Clusters.DoorLock.Enums.DataOperationTypeEnum.kAdd, + userIndex=userIndex_2, + userName=user_name, + userUniqueID=user_unique_id, + userStatus=Clusters.DoorLock.Enums.UserStatusEnum.kOccupiedEnabled, + userType=Clusters.DoorLock.Enums.UserTypeEnum.kUnrestrictedUser, + credentialRule=Clusters.DoorLock.Enums.CredentialRuleEnum.kSingle), + endpoint=self.app_cluster_endpoint, + timedRequestTimeoutMs=1000) + except InteractionModelError as e: + logging.exception(e) + + self.step("11") + if self.pics_guard(self.check_pics("DRLK.S.F00") and self.check_pics("DRLK.S.F08") + and self.check_pics("DRLK.S.C22.Rsp") and self.check_pics("DRLK.S.C23.Tx")): + await self.set_credential_cmd(credentialData=self.pin_code, + operationType=drlkcluster.Enums.DataOperationTypeEnum.kAdd, + credential_enum=drlkcluster.Enums.CredentialTypeEnum.kPin, + credentialIndex=credentialIndex_1, userIndex=userIndex_2, userStatus=NullValue, userType=NullValue, statuscode=Status.Success) + self.step("12a") + if self.pics_guard(self.check_pics("DRLK.S.F00") and self.check_pics("DRLK.S.F08") and self.check_pics("DRLK.S.C26.Rsp")): + credentials = drlkcluster.Structs.CredentialStruct(credentialIndex=0xFFFE, + credentialType=drlkcluster.Enums.CredentialTypeEnum.kPin) + await self.clear_credentials_cmd(credential=credentials) + + self.step("13") + if self.pics_guard(self.check_pics("DRLK.S.F00") and self.check_pics("DRLK.S.F08") and self.check_pics("DRLK.S.C24.Rsp") and self.check_pics("DRLK.S.C25.Tx")): + await self.get_credentials_status(credentialIndex=credentialIndex_1, + credentialType=drlkcluster.Enums.CredentialTypeEnum.kPin, credential_exists=False, next_credential_index=NullValue) + self.step("14a") + if self.pics_guard(self.check_pics("DRLK.S.F08") and self.check_pics("DRLK.S.C26.Rsp")): + feature_map = await self.read_attributes_from_dut(endpoint=self.app_cluster_endpoint, + cluster=drlkcluster, + attribute=Clusters.DoorLock.Attributes.FeatureMap) + aliro_enabled = feature_map & Clusters.DoorLock.Bitmaps.Feature.kAliroProvisioning + credentials = drlkcluster.Structs.CredentialStruct(credentialIndex=credentialIndex_1, + credentialType=drlkcluster.Enums.CredentialTypeEnum.kAliroNonEvictableEndpointKey) + if (aliro_enabled): + + await self.clear_credentials_cmd(credential=credentials) + else: + try: + await self.send_single_cmd(cmd=Clusters.DoorLock.Commands.ClearCredential(credential=credentials), + endpoint=self.app_cluster_endpoint, + timedRequestTimeoutMs=1000) + asserts.fail("Unexpected success in sending ClearCredential Command with invalid CredentialTpe") + + except InteractionModelError as e: + asserts.assert_equal(e.status, Status.InvalidCommand, + "Unexpected error sending ClearCredential Command with invalid CredentialTpe") + + self.step("14b") + if self.pics_guard(self.check_pics("DRLK.S.F08") and self.check_pics("DRLK.S.C26.Rsp")): + credentials = drlkcluster.Structs.CredentialStruct(credentialIndex=credentialIndex_1, + credentialType=invalid_credential_type) + try: + await self.send_single_cmd(cmd=Clusters.DoorLock.Commands.ClearCredential(credential=credentials), + endpoint=self.app_cluster_endpoint, + timedRequestTimeoutMs=1000) + asserts.fail("Unexpected success in sending ClearCredential Command with invalid CredentialTpe") + except InteractionModelError as e: + asserts.assert_equal(e.status, Status.InvalidCommand, + "Unexpected error sending ClearCredential Command with invalid CredentialTpe") + + self.step("14c") + if self.pics_guard(self.check_pics("DRLK.S.F08") and self.check_pics("DRLK.S.C1d.Rsp")): + await self.send_clear_user_cmd(user_index=int(0xFFFE)) + + self.step("14d") + if self.pics_guard(self.check_pics("DRLK.S.F00") and self.check_pics("DRLK.S.A0012")): + num_pin_users_supported = await self.read_attributes_from_dut(endpoint=self.app_cluster_endpoint, + cluster=drlkcluster, + attribute=Clusters.DoorLock.Attributes.NumberOfPINUsersSupported) + asserts.assert_in(num_pin_users_supported, range( + 0, 65534), "NumberOfPINUsersSupported value is out of range") + self.step("15a") + if self.pics_guard(self.check_pics("DRLK.S.F00") and self.check_pics("DRLK.S.F08") and self.check_pics("DRLK.S.A001c")): + + numberofcredentialsupportedperuser = await self.read_attributes_from_dut(endpoint=self.app_cluster_endpoint, + cluster=drlkcluster, + attribute=Clusters.DoorLock.Attributes.NumberOfCredentialsSupportedPerUser) + asserts.assert_in(numberofcredentialsupportedperuser, range( + 0, 255), "NumberOfCredentialsSupportedPerUser value is out of range") + self.step("15b") + if self.pics_guard(self.check_pics("DRLK.S.F08") and self.check_pics("DRLK.S.C1a.Rsp")): + try: + await self.send_single_cmd(cmd=drlkcluster.Commands.SetUser( + operationType=Clusters.DoorLock.Enums.DataOperationTypeEnum.kAdd, + userIndex=userIndex_1, + userName=user_name, + userUniqueID=user_unique_id, + userStatus=Clusters.DoorLock.Enums.UserStatusEnum.kOccupiedEnabled, + userType=Clusters.DoorLock.Enums.UserTypeEnum.kUnrestrictedUser, + credentialRule=Clusters.DoorLock.Enums.CredentialRuleEnum.kSingle), + endpoint=self.app_cluster_endpoint, + timedRequestTimeoutMs=1000) + except InteractionModelError as e: + logging.exception(e) + + self.step("15c") + if self.pics_guard(self.check_pics("DRLK.S.F00") and self.check_pics("DRLK.S.F08") + and self.check_pics("DRLK.S.C22.Rsp") and self.check_pics("DRLK.S.C23.Tx")): + if (numberofcredentialsupportedperuser < num_pin_users_supported): + logging.info("setting 'start_credential_index' to value 1 ") + start_credential_index = 1 + nextCredentialIndex = 1 + while 1: + uniquePincodeString = await self.generate_max_pincode_len(self.maxpincodelength) + uniquePincode = bytes(uniquePincodeString, 'ascii') + logging.info("Credential Data value is %s" % (uniquePincode)) + if start_credential_index <= (numberofcredentialsupportedperuser): + nextCredentialIndex = await self.set_credential_cmd(credentialData=uniquePincode, + operationType=drlkcluster.Enums.DataOperationTypeEnum.kAdd, + credential_enum=drlkcluster.Enums.CredentialTypeEnum.kPin, + + credentialIndex=start_credential_index, userIndex=userIndex_1, userStatus=NullValue, userType=NullValue, statuscode=Status.Success) + logging.info(f"The updated value of nextCredentialIndex is {nextCredentialIndex}") + start_credential_index += 1 + asserts.assert_true(nextCredentialIndex == start_credential_index, + "Error mismatch in expected nextCredentialIndex={}".format(str(nextCredentialIndex))) + logging.info(f"The updated value of start_credential_index is {start_credential_index}") + else: + break + self.step("15d") + if self.pics_guard(self.check_pics("DRLK.S.F00") and self.check_pics("DRLK.S.F08") + and self.check_pics("DRLK.S.C22.Rsp") and self.check_pics("DRLK.S.C23.Tx")): + if (numberofcredentialsupportedperuser < num_pin_users_supported): + await self.set_credential_cmd(credentialData=self.pin_code, + operationType=drlkcluster.Enums.DataOperationTypeEnum.kAdd, + credential_enum=drlkcluster.Enums.CredentialTypeEnum.kPin, + credentialIndex=start_credential_index, userIndex=userIndex_1, userStatus=NullValue, userType=NullValue, statuscode=Status.ResourceExhausted) + self.step("15e") + if self.pics_guard(self.check_pics("DRLK.S.F08") and self.check_pics("DRLK.S.C26.Rsp")): + credentials = drlkcluster.Structs.CredentialStruct(credentialIndex=0xFFFE, + credentialType=drlkcluster.Enums.CredentialTypeEnum.kPin) + await self.clear_credentials_cmd(credential=credentials) + self.step("15f") + if self.pics_guard(self.check_pics("DRLK.S.F08") and self.check_pics("DRLK.S.C1d.Rsp")): + await self.send_clear_user_cmd(user_index=int(0xFFFE)) + + self.step("16") + if self.pics_guard(self.check_pics("DRLK.S.F08") and self.check_pics("DRLK.S.C1a.Rsp")): + try: + await self.send_single_cmd(cmd=drlkcluster.Commands.SetUser( + operationType=Clusters.DoorLock.Enums.DataOperationTypeEnum.kAdd, + userIndex=userIndex_1, + userName=user_name, + userUniqueID=user_unique_id, + userStatus=Clusters.DoorLock.Enums.UserStatusEnum.kOccupiedEnabled, + userType=Clusters.DoorLock.Enums.UserTypeEnum.kUnrestrictedUser, + credentialRule=Clusters.DoorLock.Enums.CredentialRuleEnum.kSingle), + endpoint=self.app_cluster_endpoint, + timedRequestTimeoutMs=1000) + except InteractionModelError as e: + logging.exception(e) + + self.step("17") + if self.pics_guard(self.check_pics("DRLK.S.F01") and self.check_pics("DRLK.S.C22.Rsp") + and self.check_pics("DRLK.S.C23.Tx")): + await self.set_credential_cmd(credentialData=self.rfid_tag, + operationType=drlkcluster.Enums.DataOperationTypeEnum.kAdd, + credential_enum=drlkcluster.Enums.CredentialTypeEnum.kRfid, + credentialIndex=credentialIndex_1, userIndex=userIndex_1, userStatus=NullValue, userType=NullValue, statuscode=Status.Success) + self.step("18") + if self.pics_guard(self.check_pics("DRLK.S.F00") and self.check_pics("DRLK.S.C22.Rsp") and self.check_pics("DRLK.S.C23.Tx")): + await self.set_credential_cmd(credentialData=self.pin_code, + operationType=drlkcluster.Enums.DataOperationTypeEnum.kAdd, + credential_enum=drlkcluster.Enums.CredentialTypeEnum.kPin, + credentialIndex=credentialIndex_1, userIndex=userIndex_1, userStatus=NullValue, userType=NullValue, statuscode=Status.Success) + + self.step("19") + if self.pics_guard(self.check_pics("DRLK.S.F00") and self.check_pics("DRLK.S.F01") and self.check_pics("DRLK.S.C1b.Rsp")): + + credentiallist: list[drlkcluster.Structs.CredentialStruct] + credentiallist = [drlkcluster.Structs.CredentialStruct(credentialIndex=credentialIndex_1, + credentialType=drlkcluster.Enums.CredentialTypeEnum.kRfid), + drlkcluster.Structs.CredentialStruct(credentialIndex=credentialIndex_1, + credentialType=drlkcluster.Enums.CredentialTypeEnum.kPin)] + await self.get_user(userIndex_1, user_name, user_unique_id, credentiallist, Status.Success) + + self.step("20") + if self.pics_guard(self.check_pics("DRLK.S.F00") and self.check_pics("DRLK.S.C22.Rsp") and self.check_pics("DRLK.S.C23.Tx")): + await self.set_credential_cmd(credentialData=self.pin_code1, + operationType=drlkcluster.Enums.DataOperationTypeEnum.kModify, + credential_enum=drlkcluster.Enums.CredentialTypeEnum.kPin, + credentialIndex=credentialIndex_1, userIndex=userIndex_1, userStatus=NullValue, userType=NullValue, statuscode=Status.Success) + + self.step("21") + if self.pics_guard(self.check_pics("DRLK.S.F00") and self.check_pics("DRLK.S.F01") and self.check_pics("DRLK.S.C1b.Rsp")): + await self.get_user(userIndex_1, user_name, user_unique_id, credentiallist, Status.Success) + + self.step("22") + if self.pics_guard(self.check_pics("DRLK.S.F08") and self.check_pics("DRLK.S.C26.Rsp")): + await self.clear_credentials_cmd(credential=NullValue) + + self.step("23") + if self.pics_guard(self.check_pics("DRLK.S.F08") and self.check_pics("DRLK.S.C1d.Rsp")): + await self.send_clear_user_cmd(userIndex_1) + + self.step("24") + if self.pics_guard(self.check_pics("DRLK.S.F08") and self.check_pics("DRLK.S.C1a.Rsp")): + try: + await self.send_single_cmd(cmd=drlkcluster.Commands.SetUser( + operationType=Clusters.DoorLock.Enums.DataOperationTypeEnum.kAdd, + userIndex=userIndex_1, + userName=user_name, + userUniqueID=user_unique_id, + userStatus=Clusters.DoorLock.Enums.UserStatusEnum.kOccupiedEnabled, + userType=Clusters.DoorLock.Enums.UserTypeEnum.kUnrestrictedUser, + credentialRule=Clusters.DoorLock.Enums.CredentialRuleEnum.kSingle), + endpoint=self.app_cluster_endpoint, + timedRequestTimeoutMs=1000) + except InteractionModelError as e: + logging.exception(e) + + self.step("25") + if self.check_pics("DRLK.S.C29.Rsp"): + await self.send_clear_aliro_reader_config_cmd() + + self.step("26") + await self.send_set_aliro_reader_config_cmd(use_group_resolving_key=False, expected_status=Status.Success) + self.step("27") + await self.send_set_aliro_reader_config_cmd(use_group_resolving_key=True, expected_status=Status.Success) + + self.step("28") + if self.pics_guard(self.check_pics("DRLK.S.F0d") + and self.check_pics("DRLK.S.C22.Rsp") and self.check_pics("DRLK.S.C23.Tx")): + await self.set_credential_cmd(credentialData=aliroevictableendpointkey1, + operationType=drlkcluster.Enums.DataOperationTypeEnum.kAdd, + credential_enum=drlkcluster.Enums.CredentialTypeEnum.kAliroEvictableEndpointKey, + credentialIndex=credentialIndex_1, userIndex=userIndex_1, userStatus=NullValue, userType=NullValue, statuscode=Status.Success) + + self.step("29") + if self.pics_guard(self.check_pics("DRLK.S.F00") + and self.check_pics("DRLK.S.C22.Rsp") and self.check_pics("DRLK.S.C23.Tx")): + await self.set_credential_cmd(credentialData=self.pin_code, + operationType=drlkcluster.Enums.DataOperationTypeEnum.kAdd, + credential_enum=drlkcluster.Enums.CredentialTypeEnum.kPin, + credentialIndex=credentialIndex_1, userIndex=userIndex_1, userStatus=NullValue, userType=NullValue, statuscode=Status.Success) + self.step("30") + if self.pics_guard(self.check_pics("DRLK.S.F00") and self.check_pics("DRLK.S.F0d") and self.check_pics("DRLK.S.C1b.Rsp")): + + credentiallist: list[drlkcluster.Structs.CredentialStruct] + credentiallist = [drlkcluster.Structs.CredentialStruct(credentialIndex=credentialIndex_1, + credentialType=drlkcluster.Enums.CredentialTypeEnum.kAliroEvictableEndpointKey), + drlkcluster.Structs.CredentialStruct(credentialIndex=credentialIndex_1, + credentialType=drlkcluster.Enums.CredentialTypeEnum.kPin)] + await self.get_user(userIndex_1, user_name, user_unique_id, credentiallist, Status.Success) + self.step("31") + if self.pics_guard(self.check_pics("DRLK.S.F00") and self.check_pics("DRLK.S.C22.Rsp") and self.check_pics("DRLK.S.C23.Tx")): + await self.set_credential_cmd(credentialData=self.pin_code2, + operationType=drlkcluster.Enums.DataOperationTypeEnum.kModify, + credential_enum=drlkcluster.Enums.CredentialTypeEnum.kPin, + credentialIndex=credentialIndex_1, userIndex=userIndex_1, userStatus=NullValue, userType=NullValue, statuscode=Status.Success) + + self.step("32") + if self.pics_guard(self.check_pics("DRLK.S.F00") and self.check_pics("DRLK.S.F0d") and self.check_pics("DRLK.S.C1b.Rsp")): + + credentiallist: list[drlkcluster.Structs.CredentialStruct] + credentiallist = [drlkcluster.Structs.CredentialStruct(credentialIndex=credentialIndex_1, + credentialType=drlkcluster.Enums.CredentialTypeEnum.kAliroEvictableEndpointKey), + drlkcluster.Structs.CredentialStruct(credentialIndex=credentialIndex_1, + credentialType=drlkcluster.Enums.CredentialTypeEnum.kPin)] + await self.get_user(userIndex_1, user_name, user_unique_id, credentiallist, Status.Success) + self.step("33") + if self.pics_guard(self.check_pics("DRLK.S.F0d") and self.check_pics("DRLK.S.C22.Rsp") and self.check_pics("DRLK.S.C23.Tx")): + await self.set_credential_cmd(credentialData=aliroevictableendpointkey2, + operationType=drlkcluster.Enums.DataOperationTypeEnum.kModify, + credential_enum=drlkcluster.Enums.CredentialTypeEnum.kAliroEvictableEndpointKey, + credentialIndex=credentialIndex_1, userIndex=userIndex_1, userStatus=NullValue, userType=NullValue, statuscode=Status.Success) + self.step("34") + if self.pics_guard(self.check_pics("DRLK.S.F00") and self.check_pics("DRLK.S.F0d") and self.check_pics("DRLK.S.C1b.Rsp")): + + credentiallist: list[drlkcluster.Structs.CredentialStruct] + credentiallist = [drlkcluster.Structs.CredentialStruct(credentialIndex=credentialIndex_1, + credentialType=drlkcluster.Enums.CredentialTypeEnum.kAliroEvictableEndpointKey), + drlkcluster.Structs.CredentialStruct(credentialIndex=credentialIndex_1, + credentialType=drlkcluster.Enums.CredentialTypeEnum.kPin)] + await self.get_user(userIndex_1, user_name, user_unique_id, credentiallist, Status.Success) + + self.step("35") + if self.pics_guard(self.check_pics("DRLK.S.F08") and self.check_pics("DRLK.S.C1d.Rsp")): + await self.send_clear_user_cmd(userIndex_1) + + self.step("36") + if self.pics_guard(self.check_pics("DRLK.S.C26.Rsp")): + await self.clear_credentials_cmd(credential=NullValue) + + self.step("37") + if self.pics_guard(self.check_pics("DRLK.S.C29.Rsp")): + await self.send_clear_aliro_reader_config_cmd() + + +if __name__ == '__main__': + default_matter_test_main()