@@ -373,6 +373,28 @@ CHIP_ERROR DecodeList(TLV::TLVReader & reader, std::vector<T> & out)
373
373
}
374
374
}
375
375
376
+ class UnsupportedReadAccessInterface : public AttributeAccessInterface
377
+ {
378
+ public:
379
+ UnsupportedReadAccessInterface (ConcreteAttributePath path) :
380
+ AttributeAccessInterface (MakeOptional(path.mEndpointId ), path.mClusterId ), mPath (path)
381
+ {}
382
+ ~UnsupportedReadAccessInterface () = default ;
383
+
384
+ CHIP_ERROR Read (const ConcreteReadAttributePath & path, AttributeValueEncoder & encoder) override
385
+ {
386
+ if (static_cast <const ConcreteAttributePath &>(path) != mPath )
387
+ {
388
+ // returning without trying to handle means "I do not handle this"
389
+ return CHIP_NO_ERROR;
390
+ }
391
+
392
+ return CHIP_IM_GLOBAL_STATUS (UnsupportedRead);
393
+ }
394
+ private:
395
+ ConcreteAttributePath mPath ;
396
+ };
397
+
376
398
class StructAttributeAccessInterface : public AttributeAccessInterface
377
399
{
378
400
public:
@@ -1049,6 +1071,27 @@ TEST(TestCodegenModelViaMocks, EmberAttributePathExpansionAccessDeniedRead)
1049
1071
ASSERT_FALSE (encoder->TriedEncode ());
1050
1072
}
1051
1073
1074
+ TEST (TestCodegenModelViaMocks, AccessInterfaceUnsupportedRead) {
1075
+ UseMockNodeConfig config (gTestNodeConfig );
1076
+ chip::app::CodegenDataModel model;
1077
+ ScopedMockAccessControl accessControl;
1078
+
1079
+ const ConcreteAttributePath kTestPath (kMockEndpoint3 , MockClusterId (4 ),
1080
+ MOCK_ATTRIBUTE_ID_FOR_NON_NULLABLE_TYPE (ZCL_STRUCT_ATTRIBUTE_TYPE));
1081
+
1082
+ TestReadRequest testRequest (kAdminSubjectDescriptor , kTestPath );
1083
+ RegisteredAttributeAccessInterface<UnsupportedReadAccessInterface> aai (kTestPath );
1084
+
1085
+ testRequest.request .path .mExpanded = true ;
1086
+
1087
+ // For expanded paths, unsupported read from AAI (i.e. reading write-only data)
1088
+ // succeed without attempting to encode.
1089
+ // This is temporary until ACL checks are moved inside the IM/ReportEngine
1090
+ std::unique_ptr<AttributeValueEncoder> encoder = testRequest.StartEncoding (&model);
1091
+ ASSERT_EQ (model.ReadAttribute (testRequest.request , *encoder), CHIP_NO_ERROR);
1092
+ ASSERT_FALSE (encoder->TriedEncode ());
1093
+ }
1094
+
1052
1095
TEST (TestCodegenModelViaMocks, EmberAttributeReadInt32S)
1053
1096
{
1054
1097
TestEmberScalarTypeRead<int32_t , ZCL_INT32S_ATTRIBUTE_TYPE>(-1234 );
0 commit comments