Skip to content

Commit 9bb7762

Browse files
LyudmilaKostanyanrestyled-commitsandy31415
authored
Test Access Control Cluster (project-chip#42216)
* Enhance unit tests for Access Control Cluster by adding initialization and attribute reading tests. Introduced a TestDeviceTypeResolver for better test isolation and ensured mandatory and optional attributes can be read successfully. Improved setup and teardown procedures for the test suite. * Enhance ReadAttributesTest in Access Control Cluster by adding assertions for minimum attribute values. Updated tests to verify that SubjectsPerAccessControlEntry, TargetsPerAccessControlEntry, and AccessControlEntriesPerFabric meet the Matter specification requirements. * Add `WriteAttribute` tests for `AccessControl` cluster - Add WriteAttributesTest to verify writable attributes can be written - Update WriteTesting.h to support fabric-scoped types in write operations - Test writing Acl and Extension attributes, and verify read-only attributes reject writes * Add unit tests for `ReviewFabricRestrictions` command in `TestAccessControlCluster` This commit introduces a mock AccessRestrictionProvider and several unit tests to validate the behavior of the ReviewFabricRestrictions command. The tests cover various scenarios, including successful requests, handling of empty ARL lists, multiple entries, wildcard restrictions, and error propagation from the provider. This enhances the test coverage for access control functionality and ensures correct processing of access restrictions. * Restyled by clang-format * Revert changes in specific files * Fix `WriteAttributesTest` segmentation fault Remove ACL/Extension write attempts that require SubjectDescriptor setup. ClusterTester doesn't support fabric configuration needed for these writes. Keep only read-only attribute protection tests. ACL/Extension writes are tested in integration tests. * Add error checks in test teardown and list iteration helper - Check Finish() return value in TearDownTestSuite - Verify iterator status in CountListElements to catch decoding errors * Refactor test assertions in `TestAccessControlCluster` and `WriteTesting` - Remove assertion checks in `TearDownTestSuite` for `Finish()` method. - Replace `ASSERT_EQ` with `PW_ASSERT` in `CountListElements` for iterator status verification. - Clean up unused specialization for list types in `WriteTesting.h`. * Restyled by clang-format * Refactor formatting in `TestAccessControlCluster` tests - Adjust indentation for better readability in attribute assertions. - Simplify the call to `Testing::EqualAttributeSets` by removing the namespace prefix for consistency. * Restyled by clang-format * Refactor `TestAccessControlCluster` for improved readability - Adjust indentation in attribute assertions for consistency. - Update the call to Testing::EqualAttributeSets to include the chip:: namespace for clarity. * Restyled by clang-format * Remove `WriteAttributesTest` from `TestAccessControlCluster` as it is redundant. * Refactor `TestAccessControlCluster` tests for improved clarity and error handling - Adjusted indentation in attribute assertions for consistency. - Updated `CountListElements` to return `CHIP_ERROR` for better error reporting. - Modified assertions in `ReadAttributesTest` to utilize the updated `CountListElements` function. * Restyled by clang-format * Update comments in `TestAccessControlCluster` * Refactor `TestAccessControlCluster` to use `chip::Testing` namespace * Restyled by clang-format * Remove unnecessary `chip::` prefix in `AccessControlCluster` test file * Restore access restriction provider after test to prevent use-after-free issue * Extract `TestAccessControlClusterWithMockProvider` test fixture to reduce code duplication * Replace magic numbers with cluster IDs in `AccessControlCluster` test * Restyled by clang-format * Add constructor to initialize `ClusterTester` in test fixture Initialize mTester with mCluster in the constructor since ClusterTester doesn't have a default constructor. * Remove unused `ScopedBuffer` include * Restyled by clang-format * Ensure cluster shutdown in `AccessControlCluster` tests * Restyled by clang-format * Refine test assertions: remove redundant checks and improve error validation Remove redundant response.has_value() checks after IsSuccess() and replace generic failure assertion with specific error code validation in ProviderError test. * Restyled by clang-format * Simplify ProviderError test setup Use empty ARL list instead of creating entry struct, as ARL contents are not relevant for testing error propagation. * Restyled by clang-format * Refactor access restriction test to use type mappings and loops * Restyled by clang-format * Refactor `TestAccessControlCluster` to use correct includes * Restyled by clang-format --------- Co-authored-by: Restyled.io <[email protected]> Co-authored-by: Andrei Litvin <[email protected]>
1 parent 48e30b8 commit 9bb7762

File tree

2 files changed

+444
-5
lines changed

2 files changed

+444
-5
lines changed

0 commit comments

Comments
 (0)