Skip to content

Commit adbb76b

Browse files
committed
Add unit test for invalid global attribute read
1 parent 51a20bb commit adbb76b

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

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

+21
Original file line numberDiff line numberDiff line change
@@ -976,6 +976,27 @@ TEST(TestCodegenModelViaMocks, EmberAttributeReadAclDeny)
976976
ASSERT_EQ(model.ReadAttribute(testRequest.request, *encoder), CHIP_ERROR_ACCESS_DENIED);
977977
}
978978

979+
TEST(TestCodegenModelViaMocks, ReadForInvalidGlobalAttributePath)
980+
{
981+
UseMockNodeConfig config(gTestNodeConfig);
982+
chip::app::CodegenDataModel model;
983+
ScopedMockAccessControl accessControl;
984+
985+
{
986+
TestReadRequest testRequest(kAdminSubjectDescriptor,
987+
ConcreteAttributePath(kEndpointIdThatIsMissing, MockClusterId(1), AttributeList::Id));
988+
std::unique_ptr<AttributeValueEncoder> encoder = testRequest.StartEncoding(&model);
989+
ASSERT_EQ(model.ReadAttribute(testRequest.request, *encoder), CHIP_IM_GLOBAL_STATUS(UnsupportedEndpoint));
990+
}
991+
992+
{
993+
TestReadRequest testRequest(kAdminSubjectDescriptor,
994+
ConcreteAttributePath(kMockEndpoint1, kInvalidClusterId, AttributeList::Id));
995+
std::unique_ptr<AttributeValueEncoder> encoder = testRequest.StartEncoding(&model);
996+
ASSERT_EQ(model.ReadAttribute(testRequest.request, *encoder), CHIP_IM_GLOBAL_STATUS(UnsupportedCluster));
997+
}
998+
}
999+
9791000
TEST(TestCodegenModelViaMocks, EmberAttributeInvalidRead)
9801001
{
9811002
UseMockNodeConfig config(gTestNodeConfig);

0 commit comments

Comments
 (0)