Skip to content

Commit 39b4b11

Browse files
committed
Restyle and unit test for expansion
1 parent aaeafb0 commit 39b4b11

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

src/app/codegen-data-model/tests/TestCodegenModelViaMocks.cpp

+18
Original file line numberDiff line numberDiff line change
@@ -1031,6 +1031,24 @@ TEST(TestCodegenModelViaMocks, EmberAttributeInvalidRead)
10311031
}
10321032
}
10331033

1034+
TEST(TestCodegenModelViaMocks, EmberAttributePathExpansionAccessDeniedRead)
1035+
{
1036+
UseMockNodeConfig config(gTestNodeConfig);
1037+
chip::app::CodegenDataModel model;
1038+
ScopedMockAccessControl accessControl;
1039+
1040+
TestReadRequest testRequest(kDenySubjectDescriptor,
1041+
ConcreteAttributePath(kMockEndpoint1, MockClusterId(1), MockAttributeId(10)));
1042+
std::unique_ptr<AttributeValueEncoder> encoder = testRequest.StartEncoding(&model);
1043+
1044+
testRequest.request.path.mExpanded = true;
1045+
1046+
// For expanded paths, access control failures succeed without encoding anything
1047+
// This is temporary until ACL checks are moved inside the IM/ReportEngine
1048+
ASSERT_EQ(model.ReadAttribute(testRequest.request, *encoder), CHIP_NO_ERROR);
1049+
ASSERT_FALSE(encoder->TriedEncode());
1050+
}
1051+
10341052
TEST(TestCodegenModelViaMocks, EmberAttributeReadInt32S)
10351053
{
10361054
TestEmberScalarTypeRead<int32_t, ZCL_INT32S_ATTRIBUTE_TYPE>(-1234);

src/app/data-model-interface/DataModel.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ class DataModel : public DataModelMetadataTree
6161
/// - Validation of readability/writability
6262
/// - use request.path.mExpanded to skip encoding replies for data according
6363
/// to 8.4.3.2 of the spec:
64-
/// > If the path indicates attribute data that is not readable, then the path SHALL
64+
/// > If the path indicates attribute data that is not readable, then the path SHALL
6565
/// be discarded.
6666
/// > Else if reading from the attribute in the path requires a privilege that is not
6767
/// granted to access the cluster in the path, then the path SHALL be discarded.

0 commit comments

Comments
 (0)