Skip to content

Commit

Permalink
Generate LockUserChange events when clearing a credential. (#33797)
Browse files Browse the repository at this point in the history
* 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.

* Update src/app/clusters/door-lock-server/door-lock-server.cpp

Co-authored-by: Andrei Litvin <[email protected]>

* Restyled by clang-format

---------

Co-authored-by: Justin Wood <[email protected]>
Co-authored-by: Andrei Litvin <[email protected]>
Co-authored-by: Restyled.io <[email protected]>
  • Loading branch information
4 people authored and pull[bot] committed Nov 18, 2024
1 parent 11992a1 commit 3c19c4a
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
1 change: 1 addition & 0 deletions scripts/tests/chiptest/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
3 changes: 2 additions & 1 deletion src/app/clusters/door-lock-server/door-lock-server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -951,7 +951,8 @@ void DoorLockServer::clearCredentialCommandHandler(
}

commandObj->AddStatus(commandPath,
clearCredential(commandPath.mEndpointId, modifier, sourceNodeId, credentialType, credentialIndex, false));
clearCredential(commandPath.mEndpointId, modifier, sourceNodeId, credentialType, credentialIndex,
/* sendUserChangeEvent = */ true));
}

void DoorLockServer::setWeekDayScheduleCommandHandler(chip::app::CommandHandler * commandObj,
Expand Down
17 changes: 17 additions & 0 deletions src/app/tests/suites/DL_UsersAndCredentials.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2051,6 +2051,23 @@ 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
Expand Down

0 comments on commit 3c19c4a

Please sign in to comment.