From 359202e377dd08b10d807a3030c5764e0586bb5b Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Thu, 6 Jun 2024 22:39:53 -0400 Subject: [PATCH] Generate LockUserChange events when clearing a credential. We were passing false for sendUserChangeEvent at all callsites of clearCredential(), which is not correct for the "clear a single credential" case. The other cases generate their own LockUserChange events. --- scripts/tests/chiptest/__init__.py | 1 + .../door-lock-server/door-lock-server.cpp | 2 +- src/app/tests/suites/DL_UsersAndCredentials.yaml | 16 ++++++++++++++++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/scripts/tests/chiptest/__init__.py b/scripts/tests/chiptest/__init__.py index 9ae18675cadf78..0bd954a6241c72 100644 --- a/scripts/tests/chiptest/__init__.py +++ b/scripts/tests/chiptest/__init__.py @@ -171,6 +171,7 @@ def _GetDarwinFrameworkToolUnsupportedTests() -> Set[str]: """Tests that fail in darwin-framework-tool for some reason""" return { "DL_LockUnlock", # darwin-framework-tool does not currently support reading or subscribing to Events + "DL_UsersAndCredentials", # darwin-framework-tool does not currently support reading or subscribing to Events "Test_AddNewFabricFromExistingFabric", # darwin-framework-tool does not support the GetCommissionerRootCertificate command. # The name of the arguments once converted differs for chip-tool and darwin-framework-tool (attribute-ids vs attribute-id. See #31934) "TestAttributesById", diff --git a/src/app/clusters/door-lock-server/door-lock-server.cpp b/src/app/clusters/door-lock-server/door-lock-server.cpp index 742afee28480f3..d62acc9304b5f3 100644 --- a/src/app/clusters/door-lock-server/door-lock-server.cpp +++ b/src/app/clusters/door-lock-server/door-lock-server.cpp @@ -951,7 +951,7 @@ void DoorLockServer::clearCredentialCommandHandler( } commandObj->AddStatus(commandPath, - clearCredential(commandPath.mEndpointId, modifier, sourceNodeId, credentialType, credentialIndex, false)); + clearCredential(commandPath.mEndpointId, modifier, sourceNodeId, credentialType, credentialIndex, true)); } void DoorLockServer::setWeekDayScheduleCommandHandler(chip::app::CommandHandler * commandObj, diff --git a/src/app/tests/suites/DL_UsersAndCredentials.yaml b/src/app/tests/suites/DL_UsersAndCredentials.yaml index e86fbbe56dc053..35964fae067f41 100644 --- a/src/app/tests/suites/DL_UsersAndCredentials.yaml +++ b/src/app/tests/suites/DL_UsersAndCredentials.yaml @@ -2051,6 +2051,22 @@ tests: - name: "NextUserIndex" value: 2 + - label: "Make sure a LockUserChange event was generated" + command: "readEvent" + event: "LockUserChange" + # I wish there were a way to not hardcode this 25, but it's experimentally + # determined: doing a read without an eventNumber filter here shows 24 + # LockUserChange events before this removal. + eventNumber: 25 + response: + value: { + LockDataType: LockDataTypeEnum.PIN, + DataOperationType: DataOperationTypeEnum.Clear, + OperationSource: OperationSourceEnum.Remote, + UserIndex: 1, + DataIndex: 1, + } + - label: "Clear the second PIN credential" command: "ClearCredential" timedInteractionTimeoutMs: 10000