From 7252dcaf1fe7b752ada5db923f5f2f4e7a1a4671 Mon Sep 17 00:00:00 2001 From: zqq Date: Wed, 24 Sep 2025 15:38:05 +0800 Subject: [PATCH] check subuser when enable autolaunch Signed-off-by: zqq --- .../common/src/param_check_utils.cpp | 2 +- ...tributeddb_interfaces_auto_launch_test.cpp | 23 +++++++++++++++++-- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/frameworks/libs/distributeddb/common/src/param_check_utils.cpp b/frameworks/libs/distributeddb/common/src/param_check_utils.cpp index 868448d1852..5b80769bb8d 100644 --- a/frameworks/libs/distributeddb/common/src/param_check_utils.cpp +++ b/frameworks/libs/distributeddb/common/src/param_check_utils.cpp @@ -169,7 +169,7 @@ int ParamCheckUtils::CheckAndTransferAutoLaunchParam(const AutoLaunchParam ¶ LOGE("[AutoLaunch] CheckConflictNotifierType is invalid."); return -E_INVALID_ARGS; } - if (!ParamCheckUtils::CheckStoreParameter(param.storeId, param.appId, param.userId)) { + if (!ParamCheckUtils::CheckStoreParameter(param.storeId, param.appId, param.userId, false, param.subUser)) { LOGE("[AutoLaunch] CheckStoreParameter is invalid."); return -E_INVALID_ARGS; } diff --git a/frameworks/libs/distributeddb/test/unittest/common/interfaces/distributeddb_interfaces_auto_launch_test.cpp b/frameworks/libs/distributeddb/test/unittest/common/interfaces/distributeddb_interfaces_auto_launch_test.cpp index c6ac19b0b4c..e513922b26c 100644 --- a/frameworks/libs/distributeddb/test/unittest/common/interfaces/distributeddb_interfaces_auto_launch_test.cpp +++ b/frameworks/libs/distributeddb/test/unittest/common/interfaces/distributeddb_interfaces_auto_launch_test.cpp @@ -473,7 +473,7 @@ HWTEST_F(DistributedDBInterfacesAutoLaunchTest, EnableKvStoreAutoLaunch005, Test } /** - * @tc.name: EnableKvStoreAutoLaunch005 + * @tc.name: EnableKvStoreAutoLaunch006 * @tc.desc: test the over limits for the enable list. * @tc.type: FUNC * @tc.require: @@ -530,6 +530,25 @@ HWTEST_F(DistributedDBInterfacesAutoLaunchTest, EnableKvStoreAutoLaunch006, Test EXPECT_EQ(KvStoreDelegateManager::DisableKvStoreAutoLaunch(USER_ID1, APP_ID1, "store_1"), NOT_FOUND); } +/** + * @tc.name: EnableKvStoreAutoLaunch007 + * @tc.desc: test invalid enable auto launch. + * @tc.type: FUNC + * @tc.author: zqq + */ +HWTEST_F(DistributedDBInterfacesAutoLaunchTest, EnableKvStoreAutoLaunch007, TestSize.Level0) +{ + CipherPassword passwd; + AutoLaunchOption launchOption = {true, false, CipherType::DEFAULT, passwd, "", false, g_testDir, nullptr}; + AutoLaunchParam param; + param.storeId = "store_id"; + param.userId = USER_ID1; + param.appId = APP_ID1; + param.option = launchOption; + param.subUser.resize(129, 'u'); // 129 is invalid length + EXPECT_EQ(KvStoreDelegateManager::EnableKvStoreAutoLaunch(param), INVALID_ARGS); +} + namespace { void SetAutoLaunchLifeCycleTime(const std::string &storeId, uint32_t time) { @@ -546,7 +565,7 @@ void SetAutoLaunchLifeCycleTime(const std::string &storeId, uint32_t time) } } /** - * @tc.name: EnableKvStoreAutoLaunch007 + * @tc.name: DisableKvStoreAutoLaunch001 * @tc.desc: test the over limits for the enable list. * @tc.type: FUNC * @tc.require: -- Gitee