1 /*
2  * Copyright (c) 2023-2024 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #define private public
17 
18 #include <cstdio>
19 #include <gtest/gtest.h>
20 #include <sys/stat.h>
21 #include <unistd.h>
22 
23 #include "app_provision_info.h"
24 #include "base_bundle_installer.h"
25 #include "bundle_install_checker.h"
26 #include "bundle_verify_mgr.h"
27 #include "bundle_util.h"
28 #include "bundle_mgr_service.h"
29 #include "directory_ex.h"
30 
31 using namespace testing::ext;
32 using namespace OHOS::AppExecFwk;
33 namespace OHOS {
34 namespace {
35 const std::string HAP = "hap";
36 const std::string HAP_ONE = "hap1";
37 const std::string HAP_TWO = "hap2";
38 const std::string HAP_THREE = "hap3";
39 const std::string HAP_FOUR = "hap4";
40 const std::string HAP_FIVE = "hap5";
41 const std::string ARM = "arm";
42 const std::string ARM_SO_PATH = "/lib/arm/arm.so";
43 const std::string ARM_AN_PATH = "/an/arm/arm.so";
44 const std::string X86 = "x86";
45 const std::string X86_SO_PATH = "/lib/x86/x86.so";
46 const std::string X86_AN_PATH = "/an/x86/x86.so";
47 const std::string BUNDLE_NAME = "com.example.test";
48 const std::string TEST_PATH = "//com.example.test/";
49 const std::string MODULE_PACKAGE = "com.example.test";
50 const std::string MODULE_PATH = "test_tmp";
51 const std::string ENTRY = "entry";
52 const std::string PROXY_DATAS = "2";
53 const std::string NONISOLATION_ONLY_VALUE = "nonisolationOnly";
54 const std::string ISOLATION_ONLY_VALUE = "isolationOnly";
55 const int32_t PRIORITY_ONE = 1;
56 const int32_t PRIORITY_TWO = 2;
57 const int32_t TEST_UID = 20013999;
58 const int32_t TEST_BUNDLE_ID = 13999;
59 }  // namespace
60 
61 class BmsBundleInstallCheckerTest : public testing::Test {
62 public:
63     BmsBundleInstallCheckerTest();
64     ~BmsBundleInstallCheckerTest();
65     static void SetUpTestCase();
66     static void TearDownTestCase();
67     void SetUp();
68     void TearDown();
69 private:
70     static std::shared_ptr<BundleMgrService> bundleMgrService_;
71 };
72 
73 std::shared_ptr<BundleMgrService> BmsBundleInstallCheckerTest::bundleMgrService_ =
74     DelayedSingleton<BundleMgrService>::GetInstance();
75 
BmsBundleInstallCheckerTest()76 BmsBundleInstallCheckerTest::BmsBundleInstallCheckerTest()
77 {}
78 
~BmsBundleInstallCheckerTest()79 BmsBundleInstallCheckerTest::~BmsBundleInstallCheckerTest()
80 {}
81 
SetUpTestCase()82 void BmsBundleInstallCheckerTest::SetUpTestCase()
83 {
84 }
85 
TearDownTestCase()86 void BmsBundleInstallCheckerTest::TearDownTestCase()
87 {
88     bundleMgrService_->OnStop();
89 }
90 
SetUp()91 void BmsBundleInstallCheckerTest::SetUp()
92 {}
93 
TearDown()94 void BmsBundleInstallCheckerTest::TearDown()
95 {}
96 
97 /**
98  * @tc.number: ExtractModule_0100
99  * @tc.name: test the start function of ExtractModule
100  * @tc.desc: 1. BaseBundleInstaller
101  * @tc.require: issueI5VW01
102 */
103 HWTEST_F(BmsBundleInstallCheckerTest, ExtractModule_0100, Function | SmallTest | Level0)
104 {
105     InnerBundleInfo innerBundleInfo;
106     innerBundleInfo.currentPackage_ = MODULE_PACKAGE;
107     InnerModuleInfo innerModuleInfo;
108     innerModuleInfo.isLibIsolated = true;
109     innerModuleInfo.cpuAbi = X86;
110     innerModuleInfo.nativeLibraryPath = X86;
111     innerModuleInfo.moduleName = MODULE_PACKAGE;
112     innerModuleInfo.modulePackage = MODULE_PACKAGE;
113     innerModuleInfo.name = MODULE_PACKAGE;
114     innerBundleInfo.InsertInnerModuleInfo(MODULE_PACKAGE, innerModuleInfo);
115     BaseBundleInstaller baseBundleInstaller;
116     baseBundleInstaller.modulePackage_ = MODULE_PACKAGE;
117     ErrCode ret = baseBundleInstaller.ExtractModule(innerBundleInfo, MODULE_PATH);
118     EXPECT_NE(ret, ERR_OK);
119 }
120 
121 /**
122  * @tc.number: CheckSysCape_0100
123  * @tc.name: test the start function of CheckSysCap
124  * @tc.desc: 1. BundleInstallChecker
125 */
126 HWTEST_F(BmsBundleInstallCheckerTest, CheckSysCape_0100, Function | SmallTest | Level0)
127 {
128     std::string bundlePath = "/data/test/test.hap";
129     std::vector<std::string> bundlePaths;
130     bundlePaths.push_back(bundlePath);
131     BundleInstallChecker installChecker;
132     auto ret = installChecker.CheckSysCap(bundlePaths);
133     EXPECT_NE(ret, ERR_OK);
134 }
135 
136 /**
137  * @tc.number: CheckSystemSize_0100
138  * @tc.name: test the start function of CheckSystemSize
139  * @tc.desc: 1. BundleInstallChecker
140 */
141 HWTEST_F(BmsBundleInstallCheckerTest, CheckSystemSize_0100, Function | SmallTest | Level0)
142 {
143     std::string bundlePath = "/data/app/el1/bundle";
144     Constants::AppType appType = Constants::AppType::SYSTEM_APP;
145     BundleInstallChecker installChecker;
146     auto ret = installChecker.CheckSystemSize(bundlePath, appType);
147     EXPECT_EQ(ret, ERR_OK);
148 }
149 
150 /**
151  * @tc.number: CheckSystemSize_0200
152  * @tc.name: test the start function of CheckSystemSize
153  * @tc.desc: 1. BundleInstallChecker
154 */
155 HWTEST_F(BmsBundleInstallCheckerTest, CheckSystemSize_0200, Function | SmallTest | Level0)
156 {
157     std::string bundlePath = "/data/app/el1/bundle";
158     Constants::AppType appType = Constants::AppType::THIRD_SYSTEM_APP;
159     BundleInstallChecker installChecker;
160     auto ret = installChecker.CheckSystemSize(bundlePath, appType);
161     EXPECT_EQ(ret, ERR_OK);
162 }
163 
164 /**
165  * @tc.number: CheckSystemSize_0300
166  * @tc.name: test the start function of CheckSystemSize
167  * @tc.desc: 1. BundleInstallChecker
168 */
169 HWTEST_F(BmsBundleInstallCheckerTest, CheckSystemSize_0300, Function | SmallTest | Level0)
170 {
171     std::string bundlePath = "/data/app/el1/bundle";
172     Constants::AppType appType = Constants::AppType::THIRD_PARTY_APP;
173     BundleInstallChecker installChecker;
174     auto ret = installChecker.CheckSystemSize(bundlePath, appType);
175     EXPECT_EQ(ret, ERR_OK);
176 }
177 
178 /**
179  * @tc.number: CheckSystemSize_0400
180  * @tc.name: test the start function of CheckSystemSize
181  * @tc.desc: 1. BundleInstallChecker
182 */
183 HWTEST_F(BmsBundleInstallCheckerTest, CheckSystemSize_0400, Function | SmallTest | Level0)
184 {
185     std::string bundlePath = "";
186     Constants::AppType appType = Constants::AppType::THIRD_PARTY_APP;
187     BundleInstallChecker installChecker;
188     auto ret = installChecker.CheckSystemSize(bundlePath, appType);
189     EXPECT_EQ(ret, ERR_APPEXECFWK_INSTALL_DISK_MEM_INSUFFICIENT);
190 }
191 
192 /**
193  * @tc.number: CheckSystemSize_0500
194  * @tc.name: test the start function of CheckSystemSize
195  * @tc.desc: 1. BundleInstallChecker
196 */
197 HWTEST_F(BmsBundleInstallCheckerTest, CheckSystemSize_0500, Function | SmallTest | Level0)
198 {
199     std::string bundlePath = "/data/app/el1/bundle/public/patch_1000001";
200     bool res = BundleUtil::CreateDir(bundlePath);
201     EXPECT_TRUE(res);
202 
203     Constants::AppType appType = Constants::AppType::SYSTEM_APP;
204     Constants::AppType appType1 = Constants::AppType::THIRD_SYSTEM_APP;
205     Constants::AppType appType2 = Constants::AppType::THIRD_PARTY_APP;
206     BundleInstallChecker installChecker;
207     auto ret = installChecker.CheckSystemSize(bundlePath, appType);
208     EXPECT_EQ(ret, ERR_OK);
209     ret = installChecker.CheckSystemSize(bundlePath, appType1);
210     EXPECT_EQ(ret, ERR_OK);
211     ret = installChecker.CheckSystemSize(bundlePath, appType2);
212     EXPECT_EQ(ret, ERR_OK);
213 
214     res = BundleUtil::DeleteDir(bundlePath);
215     EXPECT_TRUE(res);
216 }
217 
218 /**
219  * @tc.number: CheckSystemSize_0600
220  * @tc.name: test the start function of CheckSystemSize
221  * @tc.desc: 1. BundleInstallChecker
222 */
223 HWTEST_F(BmsBundleInstallCheckerTest, CheckSystemSize_0600, Function | SmallTest | Level0)
224 {
225     std::string bundlePath = "/data/app/el1/bundle/100";
226     Constants::AppType appType = Constants::AppType::SYSTEM_APP;
227     Constants::AppType appType1 = Constants::AppType::THIRD_SYSTEM_APP;
228     Constants::AppType appType2 = Constants::AppType::THIRD_PARTY_APP;
229     BundleInstallChecker installChecker;
230     auto ret = installChecker.CheckSystemSize(bundlePath, appType);
231     EXPECT_EQ(ret, ERR_OK);
232     ret = installChecker.CheckSystemSize(bundlePath, appType1);
233     EXPECT_EQ(ret, ERR_OK);
234     ret = installChecker.CheckSystemSize(bundlePath, appType2);
235     EXPECT_EQ(ret, ERR_OK);
236 }
237 
238 /**
239  * @tc.number: CheckSystemSize_0700
240  * @tc.name: test the start function of CheckSystemSize
241  * @tc.desc: 1. BundleInstallChecker
242 */
243 HWTEST_F(BmsBundleInstallCheckerTest, CheckSystemSize_0700, Function | SmallTest | Level0)
244 {
245     std::string bundlePath = "/data/app/el1/bundle/0";
246     Constants::AppType appType = Constants::AppType::SYSTEM_APP;
247     Constants::AppType appType1 = Constants::AppType::THIRD_SYSTEM_APP;
248     Constants::AppType appType2 = Constants::AppType::THIRD_PARTY_APP;
249     BundleInstallChecker installChecker;
250     auto ret = installChecker.CheckSystemSize(bundlePath, appType);
251     EXPECT_EQ(ret, ERR_OK);
252     ret = installChecker.CheckSystemSize(bundlePath, appType1);
253     EXPECT_EQ(ret, ERR_OK);
254     ret = installChecker.CheckSystemSize(bundlePath, appType2);
255     EXPECT_EQ(ret, ERR_OK);
256 }
257 /**
258  * @tc.number: CheckHapHashParams_0100
259  * @tc.name: test the start function of CheckHapHashParams
260  * @tc.desc: 1. BundleInstallChecker
261 */
262 HWTEST_F(BmsBundleInstallCheckerTest, CheckHapHashParams_0100, Function | SmallTest | Level0)
263 {
264     std::unordered_map<std::string, InnerBundleInfo> infos;
265     std::map<std::string, std::string> hashParams;
266     hashParams.insert(pair<string, string>("1", "2"));
267     BundleInstallChecker installChecker;
268     auto ret = installChecker.CheckHapHashParams(infos, hashParams);
269     EXPECT_EQ(ret, ERR_APPEXECFWK_INSTALL_FAILED_CHECK_HAP_HASH_PARAM);
270 }
271 
272 /**
273  * @tc.number: IsExistedDistroModule_0100
274  * @tc.name: test the start function of IsExistedDistroModule
275  * @tc.desc: 1. BundleInstallChecker
276 */
277 HWTEST_F(BmsBundleInstallCheckerTest, IsExistedDistroModule_0100, Function | SmallTest | Level0)
278 {
279     BundleInstallChecker installChecker;
280     InnerBundleInfo newInfo;
281     InnerBundleInfo info;
282     InnerModuleInfo innerModuleInfo;
283     innerModuleInfo.moduleName = ".entry";
284     newInfo.currentPackage_ = "";
285     newInfo.InsertInnerModuleInfo("", innerModuleInfo);
286     auto ret = installChecker.IsExistedDistroModule(newInfo, info);
287     EXPECT_FALSE(ret);
288 }
289 
290 /**
291  * @tc.number: IsExistedDistroModule_0200
292  * @tc.name: test the start function of IsExistedDistroModule
293  * @tc.desc: 1. BundleInstallChecker
294 */
295 HWTEST_F(BmsBundleInstallCheckerTest, IsExistedDistroModule_0200, Function | SmallTest | Level0)
296 {
297     BundleInstallChecker installChecker;
298     InnerBundleInfo newInfo;
299     InnerBundleInfo info;
300     InnerModuleInfo innerModuleInfo;
301     innerModuleInfo.moduleName = "";
302     newInfo.currentPackage_ = "1";
303     newInfo.InsertInnerModuleInfo("1", innerModuleInfo);
304     auto ret = installChecker.IsExistedDistroModule(newInfo, info);
305     EXPECT_FALSE(ret);
306 }
307 
308 /**
309  * @tc.number: IsExistedDistroModule_0300
310  * @tc.name: test the start function of IsExistedDistroModule
311  * @tc.desc: 1. BundleInstallChecker
312 */
313 HWTEST_F(BmsBundleInstallCheckerTest, IsExistedDistroModule_0300, Function | SmallTest | Level0)
314 {
315     BundleInstallChecker installChecker;
316     InnerBundleInfo newInfo;
317     InnerBundleInfo info;
318     InnerModuleInfo innerModuleInfo;
319     innerModuleInfo.moduleName = "";
320     newInfo.currentPackage_ = "1";
321     newInfo.InsertInnerModuleInfo("", innerModuleInfo);
322     auto ret = installChecker.IsExistedDistroModule(newInfo, info);
323     EXPECT_FALSE(ret);
324 }
325 
326 /**
327  * @tc.number: IsExistedDistroModule_0400
328  * @tc.name: test the start function of IsExistedDistroModule
329  * @tc.desc: 1. BundleInstallChecker
330 */
331 HWTEST_F(BmsBundleInstallCheckerTest, IsExistedDistroModule_0400, Function | SmallTest | Level0)
332 {
333     BundleInstallChecker installChecker;
334     InnerBundleInfo newInfo;
335     InnerBundleInfo info;
336     InnerModuleInfo innerModuleInfo;
337     info.InsertInnerModuleInfo(HAP, innerModuleInfo);
338     innerModuleInfo.moduleName = ENTRY;
339     newInfo.SetCurrentModulePackage(MODULE_PACKAGE);
340     newInfo.SetIsNewVersion(false);
341     newInfo.InsertInnerModuleInfo(HAP, innerModuleInfo);
342     auto ret = installChecker.IsExistedDistroModule(newInfo, info);
343     EXPECT_FALSE(ret);
344 }
345 
346 /**
347  * @tc.number: IsExistedDistroModule_0500
348  * @tc.name: test the start function of IsExistedDistroModule
349  * @tc.desc: 1. BundleInstallChecker
350 */
351 HWTEST_F(BmsBundleInstallCheckerTest, IsExistedDistroModule_0500, Function | SmallTest | Level0)
352 {
353     BundleInstallChecker installChecker;
354     InnerBundleInfo newInfo;
355     InnerBundleInfo info;
356     InnerModuleInfo innerModuleInfo;
357     innerModuleInfo.moduleName = HAP;
358     newInfo.SetCurrentModulePackage(HAP);
359     newInfo.SetIsNewVersion(true);
360     newInfo.InsertInnerModuleInfo(HAP, innerModuleInfo);
361     info.SetIsNewVersion(false);
362     info.InsertInnerModuleInfo(HAP, innerModuleInfo);
363     auto ret = installChecker.IsExistedDistroModule(newInfo, info);
364     EXPECT_TRUE(ret);
365 }
366 
367 /**
368  * @tc.number: CheckMainElement_0100
369  * @tc.name: test the start function of CheckMainElement
370  * @tc.desc: 1. BundleInstallChecker
371 */
372 HWTEST_F(BmsBundleInstallCheckerTest, CheckMainElement_0100, Function | SmallTest | Level0)
373 {
374     BundleInstallChecker installChecker;
375     InnerBundleInfo info;
376     info.innerModuleInfos_.clear();
377     auto ret = installChecker.CheckMainElement(info);
378     EXPECT_EQ(ret, ERR_OK);
379 }
380 
381 /**
382  * @tc.number: CheckMainElement_0200
383  * @tc.name: test the start function of CheckMainElement
384  * @tc.desc: 1. BundleInstallChecker
385 */
386 HWTEST_F(BmsBundleInstallCheckerTest, CheckMainElement_0200, Function | SmallTest | Level0)
387 {
388     BundleInstallChecker installChecker;
389     InnerBundleInfo info;
390     std::map<std::string, InnerModuleInfo> innerModuleInfos;
391     InnerModuleInfo innerModuleInfo;
392     innerModuleInfo.distro.moduleType = Profile::MODULE_TYPE_SHARED;
393     innerModuleInfos.try_emplace(ENTRY, innerModuleInfo);
394     info.AddInnerModuleInfo(innerModuleInfos);
395     auto ret = installChecker.CheckMainElement(info);
396     EXPECT_EQ(ret, ERR_OK);
397 }
398 
399 /**
400  * @tc.number: CheckMainElement_0300
401  * @tc.name: test the start function of CheckMainElement
402  * @tc.desc: 1. BundleInstallChecker
403 */
404 HWTEST_F(BmsBundleInstallCheckerTest, CheckMainElement_0300, Function | SmallTest | Level0)
405 {
406     BundleInstallChecker installChecker;
407     InnerBundleInfo info;
408     std::map<std::string, InnerModuleInfo> innerModuleInfos;
409     InnerModuleInfo innerModuleInfo;
410     innerModuleInfo.distro.moduleType = Profile::MODULE_TYPE_ENTRY;
411     innerModuleInfos.try_emplace(ENTRY, innerModuleInfo);
412     info.AddInnerModuleInfo(innerModuleInfos);
413     auto ret = installChecker.CheckMainElement(info);
414     EXPECT_EQ(ret, ERR_OK);
415     BundleInfo bundleInfo;
416     bundleInfo.entryInstallationFree = true;
417     info.SetBaseBundleInfo(bundleInfo);
418     ret = installChecker.CheckMainElement(info);
419     EXPECT_EQ(ret, ERR_APPEXECFWK_PARSE_PROFILE_PROP_CHECK_ERROR);
420 }
421 
422 /**
423  * @tc.number: GetPrivilegeCapabilityValue_0100
424  * @tc.name: test the start function of GetPrivilegeCapabilityValue
425  * @tc.desc: 1. BundleInstallChecker
426 */
427 HWTEST_F(BmsBundleInstallCheckerTest, GetPrivilegeCapabilityValue_0100, Function | SmallTest | Level0)
428 {
429     BundleInstallChecker installChecker;
430     InnerBundleInfo info;
431     std::vector<std::string> existInJson;
432     existInJson.push_back("1");
433     existInJson.push_back("2");
434     std::string key = "1";
435     bool existInPreJson = true;
436     bool existInProvision = false;
437     auto ret = installChecker.GetPrivilegeCapabilityValue(existInJson, key, existInPreJson, existInProvision);
438     EXPECT_TRUE(ret);
439 }
440 
441 /**
442  * @tc.number: GetPrivilegeCapabilityValue_0200
443  * @tc.name: test the start function of GetPrivilegeCapabilityValue
444  * @tc.desc: 1. BundleInstallChecker
445 */
446 HWTEST_F(BmsBundleInstallCheckerTest, GetPrivilegeCapabilityValue_0200, Function | SmallTest | Level0)
447 {
448     BundleInstallChecker installChecker;
449     InnerBundleInfo info;
450     std::vector<std::string> existInJson;
451     existInJson.push_back("1");
452     existInJson.push_back("2");
453     std::string key = "0";
454     bool existInPreJson = true;
455     bool existInProvision = false;
456     auto ret = installChecker.GetPrivilegeCapabilityValue(existInJson, key, existInPreJson, existInProvision);
457     EXPECT_FALSE(ret);
458 }
459 
460 /**
461  * @tc.number: CheckDeviceType_0100
462  * @tc.name: test the start function of CheckDeviceType
463  * @tc.desc: 1. BundleInstallChecker
464 */
465 HWTEST_F(BmsBundleInstallCheckerTest, CheckDeviceType_0100, Function | SmallTest | Level0)
466 {
467     BundleInstallChecker installChecker;
468     std::unordered_map<std::string, InnerBundleInfo> infos;
469     InnerBundleInfo innerBundleInfo1;
470     InnerBundleInfo innerBundleInfo2;
471     infos.insert(pair<string, InnerBundleInfo>("1", innerBundleInfo1));
472     infos.insert(pair<string, InnerBundleInfo>("2", innerBundleInfo2));
473     auto ret = installChecker.CheckDeviceType(infos);
474     EXPECT_EQ(ret, ERR_OK);
475 }
476 
477 /**
478  * @tc.number: CheckDeviceType_0200
479  * @tc.name: test the start function of CollectProvisionInfo
480  * @tc.desc: 1. BundleInstallChecker
481 */
482 HWTEST_F(BmsBundleInstallCheckerTest, CheckDeviceType_0200, Function | SmallTest | Level0)
483 {
484     BundleInstallChecker installChecker;
485     Security::Verify::ProvisionInfo provisionInfo;
486     AppPrivilegeCapability appPrivilegeCapability;
487     InnerBundleInfo newInfo;
488     provisionInfo.type = Security::Verify::ProvisionType::DEBUG;
489     provisionInfo.distributionType = Security::Verify::AppDistType::NONE_TYPE;
490     installChecker.CollectProvisionInfo(provisionInfo, appPrivilegeCapability, newInfo);
491     EXPECT_EQ(newInfo.GetAppProvisionType(), Constants::APP_PROVISION_TYPE_DEBUG);
492 }
493 
494 /**
495  * @tc.number: CheckDeviceType_0300
496  * @tc.name: test the start function of CheckSysCap
497  * @tc.desc: 1. BundleInstallChecker
498 */
499 HWTEST_F(BmsBundleInstallCheckerTest, CheckDeviceType_0300, Function | SmallTest | Level0)
500 {
501     BundleInstallChecker installChecker;
502     BundlePackInfo bundlePackInfo;
503     InnerBundleInfo innerBundleInfo;
504     installChecker.SetEntryInstallationFree(bundlePackInfo, innerBundleInfo);
505     std::vector<std::string> bundlePaths;
506     ErrCode res = installChecker.CheckSysCap(bundlePaths);
507     EXPECT_EQ(res, ERR_APPEXECFWK_INSTALL_PARAM_ERROR);
508 }
509 
510 /**
511  * @tc.number: CheckDeviceType_0400
512  * @tc.name: test the start function of IsContainModuleName
513  * @tc.desc: 1. BundleInstallChecker
514 */
515 HWTEST_F(BmsBundleInstallCheckerTest, CheckDeviceType_0400, Function | SmallTest | Level0)
516 {
517     BundleInstallChecker installChecker;
518     InnerBundleInfo newInfo;
519     InnerBundleInfo info;
520     bool res = installChecker.IsContainModuleName(newInfo, info);
521     EXPECT_EQ(res, false);
522 }
523 
524 /**
525  * @tc.number: CheckDeviceType_0500
526  * @tc.name: test the start function of CheckModuleNameForMulitHaps
527  * @tc.desc: 1. BundleInstallChecker
528 */
529 HWTEST_F(BmsBundleInstallCheckerTest, CheckDeviceType_0500, Function | SmallTest | Level0)
530 {
531     BundleInstallChecker installChecker;
532     std::unordered_map<std::string, InnerBundleInfo> infos;
533     InnerBundleInfo newInfo;
534     std::map<std::string, InnerModuleInfo> innerModuleInfos;
535     InnerModuleInfo innerModuleInfo;
536     innerModuleInfo.moduleName = "";
537     newInfo.AddInnerModuleInfo(innerModuleInfos);
538     infos.emplace("/data/app/el1/bundle", newInfo);
539     ErrCode res = installChecker.CheckModuleNameForMulitHaps(infos);
540     EXPECT_EQ(res, ERR_APPEXECFWK_INSTALL_INTERNAL_ERROR);
541 }
542 
543 /**
544  * @tc.number: CheckDeviceType_0600
545  * @tc.name: test the start function of MatchSignature
546  * @tc.desc: 1. BundleInstallChecker
547 */
548 HWTEST_F(BmsBundleInstallCheckerTest, CheckDeviceType_0600, Function | SmallTest | Level0)
549 {
550     BundleInstallChecker installChecker;
551     std::vector<std::string> appSignatures;
552     bool res = installChecker.MatchSignature(appSignatures, "");
553     EXPECT_EQ(res, false);
554     appSignatures.push_back("/data/app/el1/bundle");
555     res = installChecker.MatchSignature(appSignatures, "");
556     EXPECT_EQ(res, false);
557 }
558 
559 /**
560  * @tc.number: CheckAppLabel_0001
561  * @tc.name: test the start function of CheckAppLabel
562  * @tc.desc: 1. BundleInstallChecker
563 */
564 HWTEST_F(BmsBundleInstallCheckerTest, CheckAppLabel_0001, Function | SmallTest | Level0)
565 {
566     InnerBundleInfo oldInfo;
567     InnerBundleInfo newInfo;
568     BaseBundleInstaller baseBundleInstaller;
569     auto ret = baseBundleInstaller.CheckAppLabel(oldInfo, newInfo);
570     EXPECT_EQ(ret, ERR_OK);
571     oldInfo.SetAppFeature("hos_normal_app");
572     newInfo.SetAppFeature("hos_system_app");
573     ret = baseBundleInstaller.CheckAppLabel(oldInfo, newInfo);
574     EXPECT_EQ(ret, ERR_APPEXECFWK_INSTALL_APPTYPE_NOT_SAME);
575 }
576 
577 /**
578  * @tc.number: CheckAppLabel_0002
579  * @tc.name: test the start function of CheckAppLabel
580  * @tc.desc: 1. BundleInstallChecker
581 */
582 HWTEST_F(BmsBundleInstallCheckerTest, CheckAppLabel_0002, Function | SmallTest | Level0)
583 {
584     InnerBundleInfo oldInfo;
585     InnerBundleInfo newInfo;
586     oldInfo.baseBundleInfo_->releaseType = "release_type";
587     newInfo.baseBundleInfo_->releaseType = "normal_type";
588     BaseBundleInstaller baseBundleInstaller;
589     auto ret = baseBundleInstaller.CheckAppLabel(oldInfo, newInfo);
590     EXPECT_EQ(ret, ERR_OK);
591 }
592 
593 /**
594  * @tc.number: CheckAppLabel_0003
595  * @tc.name: test the start function of CheckAppLabel
596  * @tc.desc: 1. BundleInstallChecker
597 */
598 HWTEST_F(BmsBundleInstallCheckerTest, CheckAppLabel_0003, Function | SmallTest | Level0)
599 {
600     InnerBundleInfo oldInfo;
601     InnerBundleInfo newInfo;
602     oldInfo.SetAppDistributionType("hos_normal_type");
603     newInfo.SetAppDistributionType("hos_system_type");
604     BaseBundleInstaller baseBundleInstaller;
605     auto ret = baseBundleInstaller.CheckAppLabel(oldInfo, newInfo);
606     EXPECT_EQ(ret, ERR_APPEXECFWK_INSTALL_APP_DISTRIBUTION_TYPE_NOT_SAME);
607 }
608 
609 /**
610  * @tc.number: CheckAppLabel_0004
611  * @tc.name: test the start function of CheckAppLabel
612  * @tc.desc: 1. BundleInstallChecker
613 */
614 HWTEST_F(BmsBundleInstallCheckerTest, CheckAppLabel_0004, Function | SmallTest | Level0)
615 {
616     InnerBundleInfo oldInfo;
617     InnerBundleInfo newInfo;
618     oldInfo.SetAppProvisionType("hos_normal_type");
619     newInfo.SetAppProvisionType("hos_system_type");
620     BaseBundleInstaller baseBundleInstaller;
621     auto ret = baseBundleInstaller.CheckAppLabel(oldInfo, newInfo);
622     EXPECT_EQ(ret, ERR_APPEXECFWK_INSTALL_APP_PROVISION_TYPE_NOT_SAME);
623 }
624 
625 /**
626  * @tc.number: CheckAppLabel_0005
627  * @tc.name: test the start function of CheckAppLabel
628  * @tc.desc: 1. BundleInstallChecker
629 */
630 HWTEST_F(BmsBundleInstallCheckerTest, CheckAppLabel_0005, Function | SmallTest | Level0)
631 {
632     InnerBundleInfo oldInfo;
633     InnerBundleInfo newInfo;
634     oldInfo.SetIsNewVersion(false);
635     newInfo.SetIsNewVersion(true);
636     BaseBundleInstaller baseBundleInstaller;
637     auto ret = baseBundleInstaller.CheckAppLabel(oldInfo, newInfo);
638     EXPECT_EQ(ret, ERR_APPEXECFWK_INSTALL_STATE_ERROR);
639 }
640 
641 /**
642  * @tc.number: CheckAppLabel_0006
643  * @tc.name: test the start function of CheckAppLabel
644  * @tc.desc: 1. BundleInstallChecker
645 */
646 HWTEST_F(BmsBundleInstallCheckerTest, CheckAppLabel_0006, Function | SmallTest | Level0)
647 {
648     InnerBundleInfo oldInfo;
649     InnerBundleInfo newInfo;
650     oldInfo.SetAsanEnabled(false);
651     newInfo.SetAsanEnabled(true);
652     BaseBundleInstaller baseBundleInstaller;
653     auto ret = baseBundleInstaller.CheckAppLabel(oldInfo, newInfo);
654     EXPECT_EQ(ret, ERR_OK);
655 }
656 
657 /**
658  * @tc.number: CheckAppLabel_0007
659  * @tc.name: test the start function of CheckAppLabel
660  * @tc.desc: 1. BundleInstallChecker
661 */
662 HWTEST_F(BmsBundleInstallCheckerTest, CheckAppLabel_0007, Function | SmallTest | Level0)
663 {
664     InnerBundleInfo oldInfo;
665     InnerBundleInfo newInfo;
666     oldInfo.SetApplicationBundleType(BundleType::APP);
667     newInfo.SetApplicationBundleType(BundleType::ATOMIC_SERVICE);
668     BaseBundleInstaller baseBundleInstaller;
669     auto ret = baseBundleInstaller.CheckAppLabel(oldInfo, newInfo);
670     EXPECT_EQ(ret, ERR_APPEXECFWK_BUNDLE_TYPE_NOT_SAME);
671 }
672 
673 /**
674  * @tc.number: GetCallingEventInfo_0001
675  * @tc.name: test the start function of GetCallingEventInfo
676  * @tc.desc: 1. BundleInstallChecker
677 */
678 HWTEST_F(BmsBundleInstallCheckerTest, GetCallingEventInfo_0001, Function | SmallTest | Level0)
679 {
680     EventInfo eventInfo;
681     BaseBundleInstaller baseBundleInstaller;
682     baseBundleInstaller.GetCallingEventInfo(eventInfo);
683     EXPECT_EQ(eventInfo.callingBundleName, Constants::EMPTY_STRING);
684 }
685 
686 /**
687  * @tc.number: GetCallingEventInfo_0002
688  * @tc.name: test the start function of GetCallingEventInfo
689  * @tc.desc: 1. BaseBundleInstaller
690 */
691 HWTEST_F(BmsBundleInstallCheckerTest, GetCallingEventInfo_0002, Function | SmallTest | Level0)
692 {
693     BaseBundleInstaller baseBundleInstaller;
694     baseBundleInstaller.dataMgr_ = std::make_shared<BundleDataMgr>();
695     EventInfo eventInfo;
696     baseBundleInstaller.GetCallingEventInfo(eventInfo);
697     EXPECT_EQ(eventInfo.callingBundleName, Constants::EMPTY_STRING);
698 }
699 
700 /**
701  * @tc.number: GetCallingEventInfo_0003
702  * @tc.name: test the start function of GetCallingEventInfo
703  * @tc.desc: 1. BaseBundleInstaller
704 */
705 HWTEST_F(BmsBundleInstallCheckerTest, GetCallingEventInfo_0003, Function | SmallTest | Level0)
706 {
707     InnerBundleInfo info;
708     BundleInfo bundleInfo;
709     bundleInfo.name = BUNDLE_NAME;
710     bundleInfo.applicationInfo.name = BUNDLE_NAME;
711     ApplicationInfo applicationInfo;
712     applicationInfo.name = BUNDLE_NAME;
713     applicationInfo.bundleName = BUNDLE_NAME;
714     info.SetBaseBundleInfo(bundleInfo);
715     info.SetBaseApplicationInfo(applicationInfo);
716     InnerBundleUserInfo innerBundleUserInfo;
717     innerBundleUserInfo.uid = TEST_UID;
718     innerBundleUserInfo.bundleName = BUNDLE_NAME;
719     innerBundleUserInfo.bundleUserInfo.userId = 100;
720     info.AddInnerBundleUserInfo(innerBundleUserInfo);
721     BaseBundleInstaller baseBundleInstaller;
722     baseBundleInstaller.dataMgr_ = std::make_shared<BundleDataMgr>();
723     EXPECT_NE(baseBundleInstaller.dataMgr_, nullptr);
724     bool ret1 = baseBundleInstaller.dataMgr_ ->UpdateBundleInstallState(BUNDLE_NAME, InstallState::INSTALL_START);
725     bool ret2 =  baseBundleInstaller.dataMgr_ ->AddInnerBundleInfo(BUNDLE_NAME, info);
726     EXPECT_TRUE(ret1);
727     EXPECT_TRUE(ret2);
728 
729     EventInfo eventInfo;
730     eventInfo.callingUid = TEST_UID;
731 
732     baseBundleInstaller.dataMgr_->bundleIdMap_.insert(std::pair<int32_t, std::string>(TEST_BUNDLE_ID, BUNDLE_NAME));
733     baseBundleInstaller.GetCallingEventInfo(eventInfo);
734     EXPECT_EQ(eventInfo.callingBundleName, BUNDLE_NAME);
735 
736     baseBundleInstaller.dataMgr_->bundleIdMap_.erase(TEST_BUNDLE_ID);
737     baseBundleInstaller.dataMgr_->UpdateBundleInstallState(BUNDLE_NAME, InstallState::UNINSTALL_START);
738 }
739 
740 /**
741  * @tc.number: GetInstallEventInfo_0001
742  * @tc.name: test the start function of GetInstallEventInfo
743  * @tc.desc: 1. BaseBundleInstaller
744 */
745 HWTEST_F(BmsBundleInstallCheckerTest, GetInstallEventInfo_0001, Function | SmallTest | Level0)
746 {
747     BaseBundleInstaller baseBundleInstaller;
748     EventInfo eventInfo;
749     baseBundleInstaller.GetInstallEventInfo(eventInfo);
750     EXPECT_EQ(eventInfo.fingerprint, Constants::EMPTY_STRING);
751 }
752 
753 /**
754  * @tc.number: GetInstallEventInfo_0002
755  * @tc.name: test the start function of GetInstallEventInfo
756  * @tc.desc: 1. BaseBundleInstaller
757 */
758 HWTEST_F(BmsBundleInstallCheckerTest, GetInstallEventInfo_0002, Function | SmallTest | Level0)
759 {
760     BaseBundleInstaller baseBundleInstaller;
761     baseBundleInstaller.dataMgr_ = std::make_shared<BundleDataMgr>();;
762     EventInfo eventInfo;
763     baseBundleInstaller.GetInstallEventInfo(eventInfo);
764     EXPECT_EQ(eventInfo.fingerprint, Constants::EMPTY_STRING);
765 }
766 
767 /**
768  * @tc.number: GetInstallEventInfo_0003
769  * @tc.name: test the start function of GetInstallEventInfo
770  * @tc.desc: 1. BaseBundleInstaller
771 */
772 HWTEST_F(BmsBundleInstallCheckerTest, GetInstallEventInfo_0003, Function | SmallTest | Level0)
773 {
774     InnerBundleInfo info;
775     BundleInfo bundleInfo;
776     bundleInfo.name = BUNDLE_NAME;
777     bundleInfo.applicationInfo.name = BUNDLE_NAME;
778     ApplicationInfo applicationInfo;
779     applicationInfo.name = BUNDLE_NAME;
780     applicationInfo.bundleName = BUNDLE_NAME;
781     applicationInfo.appDistributionType = Constants::APP_DISTRIBUTION_TYPE_APP_GALLERY;
782     info.SetBaseBundleInfo(bundleInfo);
783     info.SetBaseApplicationInfo(applicationInfo);
784     BaseBundleInstaller baseBundleInstaller;
785     baseBundleInstaller.dataMgr_ = std::make_shared<BundleDataMgr>();
786     EXPECT_NE(baseBundleInstaller.dataMgr_, nullptr);
787     bool ret1 = baseBundleInstaller.dataMgr_->UpdateBundleInstallState(BUNDLE_NAME, InstallState::INSTALL_START);
788     bool ret2 =  baseBundleInstaller.dataMgr_->AddInnerBundleInfo(BUNDLE_NAME, info);
789     EXPECT_TRUE(ret1);
790     EXPECT_TRUE(ret2);
791 
792     baseBundleInstaller.bundleName_ = BUNDLE_NAME;
793     EventInfo eventInfo;
794     baseBundleInstaller.GetInstallEventInfo(eventInfo);
795     EXPECT_EQ(eventInfo.appDistributionType, Constants::APP_DISTRIBUTION_TYPE_APP_GALLERY);
796 
797     baseBundleInstaller.dataMgr_->UpdateBundleInstallState(BUNDLE_NAME, InstallState::UNINSTALL_START);
798 }
799 
800 /**
801  * @tc.number: GetInstallEventInfo_0004
802  * @tc.name: test the start function of GetInstallEventInfo
803  * @tc.desc: 1. BaseBundleInstaller
804 */
805 HWTEST_F(BmsBundleInstallCheckerTest, GetInstallEventInfo_0004, Function | SmallTest | Level0)
806 {
807     InnerBundleInfo info;
808     BundleInfo bundleInfo;
809     bundleInfo.name = BUNDLE_NAME;
810     bundleInfo.applicationInfo.name = BUNDLE_NAME;
811     ApplicationInfo applicationInfo;
812     applicationInfo.name = BUNDLE_NAME;
813     applicationInfo.bundleName = BUNDLE_NAME;
814     applicationInfo.appDistributionType = Constants::APP_DISTRIBUTION_TYPE_APP_GALLERY;
815     info.SetBaseBundleInfo(bundleInfo);
816     info.SetBaseApplicationInfo(applicationInfo);
817     BaseBundleInstaller baseBundleInstaller;
818     baseBundleInstaller.dataMgr_ = std::make_shared<BundleDataMgr>();
819     EXPECT_NE(baseBundleInstaller.dataMgr_, nullptr);
820     bool ret1 = baseBundleInstaller.dataMgr_->UpdateBundleInstallState(BUNDLE_NAME, InstallState::INSTALL_START);
821     bool ret2 =  baseBundleInstaller.dataMgr_->AddInnerBundleInfo(BUNDLE_NAME, info);
822     EXPECT_TRUE(ret1);
823     EXPECT_TRUE(ret2);
824 
825     baseBundleInstaller.bundleName_ = BUNDLE_NAME;
826     EventInfo eventInfo;
827     InnerModuleInfo moduleInfo;
828     moduleInfo.hapPath = "xxxx.hap";
829     moduleInfo.hashValue = "111";
830     info.InsertInnerModuleInfo(BUNDLE_NAME, moduleInfo);
831     baseBundleInstaller.GetInstallEventInfo(eventInfo);
832     EXPECT_EQ(eventInfo.appDistributionType, Constants::APP_DISTRIBUTION_TYPE_APP_GALLERY);
833     if (!eventInfo.filePath.empty()) {
834         EXPECT_EQ(eventInfo.filePath[0], moduleInfo.hapPath);
835         EXPECT_EQ(eventInfo.hashValue[0], moduleInfo.hashValue);
836     }
837     baseBundleInstaller.dataMgr_->UpdateBundleInstallState(BUNDLE_NAME, InstallState::UNINSTALL_START);
838 }
839 
840 /**
841  * @tc.number: ConvertToAppProvisionInfo_0001
842  * @tc.name: test the start function of ConvertToAppProvisionInfo
843  * @tc.desc: 1. BundleInstallChecker
844 */
845 HWTEST_F(BmsBundleInstallCheckerTest, ConvertToAppProvisionInfo_0001, Function | SmallTest | Level0)
846 {
847     BundleInstallChecker bundleInstallChecker;
848     Security::Verify::ProvisionInfo provisionInfo;
849     provisionInfo.type = Security::Verify::ProvisionType::DEBUG;
850     provisionInfo.distributionType = Security::Verify::AppDistType::NONE_TYPE;
851     AppProvisionInfo appProvisionInfo = bundleInstallChecker.ConvertToAppProvisionInfo(provisionInfo);
852     EXPECT_EQ(appProvisionInfo.type, Constants::APP_PROVISION_TYPE_DEBUG);
853     EXPECT_EQ(appProvisionInfo.appDistributionType, Constants::APP_DISTRIBUTION_TYPE_NONE);
854     EXPECT_EQ(appProvisionInfo.apl, "normal");
855 }
856 
857 /**
858  * @tc.number: ConvertToAppProvisionInfo_0002
859  * @tc.name: test the start function of ConvertToAppProvisionInfo
860  * @tc.desc: 1. BundleInstallChecker
861 */
862 HWTEST_F(BmsBundleInstallCheckerTest, ConvertToAppProvisionInfo_0002, Function | SmallTest | Level0)
863 {
864     BundleInstallChecker bundleInstallChecker;
865     Security::Verify::ProvisionInfo provisionInfo;
866     provisionInfo.type = Security::Verify::ProvisionType::RELEASE;
867     provisionInfo.distributionType = Security::Verify::AppDistType::APP_GALLERY;
868     AppProvisionInfo appProvisionInfo = bundleInstallChecker.ConvertToAppProvisionInfo(provisionInfo);
869     EXPECT_EQ(appProvisionInfo.type, Constants::APP_PROVISION_TYPE_RELEASE);
870     EXPECT_EQ(appProvisionInfo.appDistributionType, Constants::APP_DISTRIBUTION_TYPE_APP_GALLERY);
871     EXPECT_EQ(appProvisionInfo.apl, "normal");
872 }
873 
874 /**
875  * @tc.number: ConvertToAppProvisionInfo_0003
876  * @tc.name: test the start function of ConvertToAppProvisionInfo
877  * @tc.desc: 1. BundleInstallChecker
878 */
879 HWTEST_F(BmsBundleInstallCheckerTest, ConvertToAppProvisionInfo_0003, Function | SmallTest | Level0)
880 {
881     BundleInstallChecker bundleInstallChecker;
882     Security::Verify::ProvisionInfo provisionInfo;
883     provisionInfo.type = Security::Verify::ProvisionType::RELEASE;
884     provisionInfo.distributionType = Security::Verify::AppDistType::ENTERPRISE;
885     provisionInfo.bundleInfo.apl = "system_basic";
886     AppProvisionInfo appProvisionInfo = bundleInstallChecker.ConvertToAppProvisionInfo(provisionInfo);
887     EXPECT_EQ(appProvisionInfo.type, Constants::APP_PROVISION_TYPE_RELEASE);
888     EXPECT_EQ(appProvisionInfo.appDistributionType, Constants::APP_DISTRIBUTION_TYPE_ENTERPRISE);
889     EXPECT_EQ(appProvisionInfo.apl, "system_basic");
890 
891     provisionInfo.distributionType = Security::Verify::AppDistType::OS_INTEGRATION;
892     appProvisionInfo = bundleInstallChecker.ConvertToAppProvisionInfo(provisionInfo);
893     EXPECT_EQ(appProvisionInfo.appDistributionType, Constants::APP_DISTRIBUTION_TYPE_OS_INTEGRATION);
894 
895     provisionInfo.distributionType = Security::Verify::AppDistType::CROWDTESTING;
896     appProvisionInfo = bundleInstallChecker.ConvertToAppProvisionInfo(provisionInfo);
897     EXPECT_EQ(appProvisionInfo.appDistributionType, Constants::APP_DISTRIBUTION_TYPE_CROWDTESTING);
898 }
899 
900 /**
901  * @tc.number: GetPrivilegeCapability_0001
902  * @tc.name: test the start function of GetPrivilegeCapability
903  * @tc.desc: 1. GetPrivilegeCapability
904  * @tc.require: issueI6PKSW
905 */
906 HWTEST_F(BmsBundleInstallCheckerTest, GetPrivilegeCapability_0001, Function | SmallTest | Level0)
907 {
908     BundleInstallChecker installChecker;
909     InstallCheckParam installcheckParam;
910     InnerBundleInfo newInfo;
911     installChecker.GetPrivilegeCapability(installcheckParam, newInfo);
912     EXPECT_EQ(newInfo.GetIsKeepAlive(), false);
913 }
914 
915 /**
916  * @tc.number: SetEntryInstallationFree_0001
917  * @tc.name: test the start function of SetEntryInstallationFree
918  * @tc.desc: 1. SetEntryInstallationFree_0001
919  * @tc.require: issueI6PKSW
920 */
921 HWTEST_F(BmsBundleInstallCheckerTest, SetEntryInstallationFree_0001, Function | SmallTest | Level0)
922 {
923     BundleInstallChecker installChecker;
924     BundlePackInfo bundlePackInfo;
925     InnerBundleInfo innerBundleInfo;
926     innerBundleInfo.SetIsNewVersion(false);
927     PackageModule packageModule;
928     packageModule.distro.moduleType = ENTRY;
929     packageModule.distro.installationFree = true;
930     bundlePackInfo.summary.modules.emplace_back(packageModule);
931     bundlePackInfo.SetValid(true);
932     installChecker.SetEntryInstallationFree(bundlePackInfo, innerBundleInfo);
933     EXPECT_EQ(innerBundleInfo.GetApplicationBundleType(), BundleType::ATOMIC_SERVICE);
934 }
935 
936 /**
937  * @tc.number: CheckAppLabelInfo_0001
938  * @tc.name: test the start function of CheckAppLabelInfo
939  * @tc.desc: 1. CheckAppLabelInfo_0001
940  * @tc.require: issueI6PKSW
941 */
942 HWTEST_F(BmsBundleInstallCheckerTest, CheckAppLabelInfo_0001, Function | SmallTest | Level0)
943 {
944     BundleInstallChecker installChecker;
945     std::unordered_map<std::string, InnerBundleInfo> infos;
946     InnerBundleInfo innerBundleInfo1;
947     InnerBundleInfo innerBundleInfo2;
948     innerBundleInfo1.SetAppType(Constants::AppType::SYSTEM_APP);
949     innerBundleInfo2.SetAppType(Constants::AppType::THIRD_PARTY_APP);
950     infos.emplace(HAP, innerBundleInfo1);
951     infos.emplace(HAP_ONE, innerBundleInfo2);
952     auto ret = installChecker.CheckAppLabelInfo(infos);
953     EXPECT_EQ(ret, ERR_APPEXECFWK_INSTALL_APPTYPE_NOT_SAME);
954 }
955 
956 /**
957  * @tc.number: CheckAppLabelInfo_0002
958  * @tc.name: test the start function of CheckAppLabelInfo
959  * @tc.desc: 1. CheckAppLabelInfo_0002
960  * @tc.require: issueI6PKSW
961 */
962 HWTEST_F(BmsBundleInstallCheckerTest, CheckAppLabelInfo_0002, Function | SmallTest | Level0)
963 {
964     BundleInstallChecker installChecker;
965     std::unordered_map<std::string, InnerBundleInfo> infos;
966     InnerBundleInfo innerBundleInfo1;
967     InnerBundleInfo innerBundleInfo2;
968     innerBundleInfo1.SetIsNewVersion(true);
969     innerBundleInfo2.SetIsNewVersion(false);
970     infos.emplace(HAP, innerBundleInfo1);
971     infos.emplace(HAP_ONE, innerBundleInfo2);
972     auto ret = installChecker.CheckAppLabelInfo(infos);
973     EXPECT_EQ(ret, ERR_APPEXECFWK_INSTALL_STATE_ERROR);
974 }
975 
976 /**
977  * @tc.number: CheckAppLabelInfo_0003
978  * @tc.name: test the start function of CheckAppLabelInfo
979  * @tc.desc: 1. CheckAppLabelInfo_0003
980  * @tc.require: issueI6PKSW
981 */
982 HWTEST_F(BmsBundleInstallCheckerTest, CheckAppLabelInfo_0003, Function | SmallTest | Level0)
983 {
984     BundleInstallChecker installChecker;
985     std::unordered_map<std::string, InnerBundleInfo> infos;
986     InnerBundleInfo innerBundleInfo1;
987     InnerBundleInfo innerBundleInfo2;
988     innerBundleInfo1.SetTargetBundleName(HAP);
989     innerBundleInfo2.SetTargetBundleName(HAP_ONE);
990     infos.emplace(HAP, innerBundleInfo1);
991     infos.emplace(HAP_ONE, innerBundleInfo2);
992     auto ret = installChecker.CheckAppLabelInfo(infos);
993     EXPECT_EQ(ret, ERR_BUNDLEMANAGER_OVERLAY_INSTALLATION_FAILED_TARGET_BUNDLE_NAME_NOT_SAME);
994 }
995 
996 /**
997  * @tc.number: CheckAppLabelInfo_0004
998  * @tc.name: test the start function of CheckAppLabelInfo
999  * @tc.desc: 1. CheckAppLabelInfo_0004
1000  * @tc.require: issueI6PKSW
1001 */
1002 HWTEST_F(BmsBundleInstallCheckerTest, CheckAppLabelInfo_0004, Function | SmallTest | Level0)
1003 {
1004     BundleInstallChecker installChecker;
1005     std::unordered_map<std::string, InnerBundleInfo> infos;
1006     InnerBundleInfo innerBundleInfo1;
1007     InnerBundleInfo innerBundleInfo2;
1008     innerBundleInfo1.SetTargetPriority(PRIORITY_ONE);
1009     innerBundleInfo2.SetTargetPriority(PRIORITY_TWO);
1010     infos.emplace(HAP, innerBundleInfo1);
1011     infos.emplace(HAP_ONE, innerBundleInfo2);
1012     auto ret = installChecker.CheckAppLabelInfo(infos);
1013     EXPECT_EQ(ret, ERR_BUNDLEMANAGER_OVERLAY_INSTALLATION_FAILED_TARGET_PRIORITY_NOT_SAME);
1014 }
1015 
1016 /**
1017  * @tc.number: CheckAppLabelInfo_0005
1018  * @tc.name: test the start function of CheckAppLabelInfo
1019  * @tc.desc: 1. CheckAppLabelInfo_0005
1020  * @tc.require: issueI6PKSW
1021 */
1022 HWTEST_F(BmsBundleInstallCheckerTest, CheckAppLabelInfo_0005, Function | SmallTest | Level0)
1023 {
1024     BundleInstallChecker installChecker;
1025     std::unordered_map<std::string, InnerBundleInfo> infos;
1026     InnerBundleInfo innerBundleInfo1;
1027     InnerBundleInfo innerBundleInfo2;
1028     innerBundleInfo1.SetAsanEnabled(true);
1029     innerBundleInfo2.SetAsanEnabled(false);
1030     infos.emplace(HAP, innerBundleInfo1);
1031     infos.emplace(HAP_ONE, innerBundleInfo2);
1032     auto ret = installChecker.CheckAppLabelInfo(infos);
1033     EXPECT_EQ(ret, ERR_OK);
1034 }
1035 
1036 /**
1037  * @tc.number: CheckAppLabelInfo_0006
1038  * @tc.name: test the start function of CheckAppLabelInfo
1039  * @tc.desc: 1. CheckAppLabelInfo_0006
1040  * @tc.require: issueI6PKSW
1041 */
1042 HWTEST_F(BmsBundleInstallCheckerTest, CheckAppLabelInfo_0006, Function | SmallTest | Level0)
1043 {
1044     BundleInstallChecker installChecker;
1045     std::unordered_map<std::string, InnerBundleInfo> infos;
1046     InnerBundleInfo innerBundleInfo1;
1047     InnerBundleInfo innerBundleInfo2;
1048     innerBundleInfo1.SetApplicationBundleType(BundleType::APP);
1049     innerBundleInfo2.SetApplicationBundleType(BundleType::ATOMIC_SERVICE);
1050     infos.emplace(HAP, innerBundleInfo1);
1051     infos.emplace(HAP_ONE, innerBundleInfo2);
1052     auto ret = installChecker.CheckAppLabelInfo(infos);
1053     EXPECT_EQ(ret, ERR_APPEXECFWK_BUNDLE_TYPE_NOT_SAME);
1054 }
1055 
1056 /**
1057  * @tc.number: CheckAppLabelInfo_0007
1058  * @tc.name: test the start function of CheckAppLabelInfo
1059  * @tc.desc: 1. CheckAppLabelInfo_0007
1060  * @tc.require: issueI6PKSW
1061 */
1062 HWTEST_F(BmsBundleInstallCheckerTest, CheckAppLabelInfo_0007, Function | SmallTest | Level0)
1063 {
1064     BundleInstallChecker installChecker;
1065     std::unordered_map<std::string, InnerBundleInfo> infos;
1066     InnerBundleInfo innerBundleInfo1;
1067     InnerBundleInfo innerBundleInfo2;
1068     innerBundleInfo1.SetEntryInstallationFree(true);
1069     innerBundleInfo2.SetEntryInstallationFree(false);
1070     infos.emplace(HAP, innerBundleInfo1);
1071     infos.emplace(HAP_ONE, innerBundleInfo2);
1072     auto ret = installChecker.CheckAppLabelInfo(infos);
1073     EXPECT_EQ(ret, ERR_APPEXECFWK_INSTALL_TYPE_ERROR);
1074 }
1075 
1076 /**
1077  * @tc.number: CheckAppLabel_0008
1078  * @tc.name: test the start function of CheckAppLabel
1079  * @tc.desc: 1. BundleInstallChecker
1080 */
1081 HWTEST_F(BmsBundleInstallCheckerTest, CheckAppLabel_0008, Function | SmallTest | Level0)
1082 {
1083     InnerBundleInfo oldInfo;
1084     InnerBundleInfo newInfo;
1085     ApplicationInfo applicationInfo;
1086     applicationInfo.debug = false;
1087     oldInfo.SetBaseApplicationInfo(applicationInfo);
1088     applicationInfo.debug = true;
1089     newInfo.SetBaseApplicationInfo(applicationInfo);
1090     BaseBundleInstaller baseBundleInstaller;
1091     auto ret = baseBundleInstaller.CheckAppLabel(oldInfo, newInfo);
1092     EXPECT_EQ(ret, ERR_OK);
1093 }
1094 
1095 /**
1096  * @tc.number: CheckAppLabel_0009
1097  * @tc.name: test the start function of CheckAppLabel
1098  * @tc.desc: 1. BundleInstallChecker
1099 */
1100 HWTEST_F(BmsBundleInstallCheckerTest, CheckAppLabel_0009, Function | SmallTest | Level0)
1101 {
1102     InnerBundleInfo oldInfo;
1103     InnerBundleInfo newInfo;
1104     oldInfo.SetGwpAsanEnabled(false);
1105     newInfo.SetGwpAsanEnabled(true);
1106     BaseBundleInstaller baseBundleInstaller;
1107     auto ret = baseBundleInstaller.CheckAppLabel(oldInfo, newInfo);
1108     EXPECT_EQ(ret, ERR_OK);
1109 }
1110 
1111 /**
1112  * @tc.number: CheckAppLabel_0010
1113  * @tc.name: test the start function of CheckAppLabel
1114  * @tc.desc: 1. BundleInstallChecker
1115 */
1116 HWTEST_F(BmsBundleInstallCheckerTest, CheckAppLabel_0010, Function | SmallTest | Level0)
1117 {
1118     InnerBundleInfo oldInfo;
1119     InnerBundleInfo newInfo;
1120     oldInfo.SetTsanEnabled(false);
1121     newInfo.SetTsanEnabled(true);
1122     BaseBundleInstaller baseBundleInstaller;
1123     auto ret = baseBundleInstaller.CheckAppLabel(oldInfo, newInfo);
1124     EXPECT_EQ(ret, ERR_OK);
1125 }
1126 
1127 /**
1128  * @tc.number: CheckAppLabel_0011
1129  * @tc.name: test the start function of CheckAppLabel
1130  * @tc.desc: 1. BundleInstallChecker
1131 */
1132 HWTEST_F(BmsBundleInstallCheckerTest, CheckAppLabel_0011, Function | SmallTest | Level0)
1133 {
1134     InnerBundleInfo oldInfo;
1135     InnerBundleInfo newInfo;
1136     oldInfo.SetHwasanEnabled(false);
1137     newInfo.SetHwasanEnabled(true);
1138     BaseBundleInstaller baseBundleInstaller;
1139     auto ret = baseBundleInstaller.CheckAppLabel(oldInfo, newInfo);
1140     EXPECT_EQ(ret, ERR_OK);
1141 }
1142 
1143 /**
1144  * @tc.number: CheckAppLabelInfo_0008
1145  * @tc.name: test the start function of CheckAppLabelInfo
1146  * @tc.desc: 1. CheckAppLabelInfo_0008
1147 */
1148 HWTEST_F(BmsBundleInstallCheckerTest, CheckAppLabelInfo_0008, Function | SmallTest | Level0)
1149 {
1150     BundleInstallChecker installChecker;
1151     std::unordered_map<std::string, InnerBundleInfo> infos;
1152     InnerBundleInfo innerBundleInfo1;
1153     BundleInfo bundleInfo;
1154     bundleInfo.compatibleVersion = PRIORITY_ONE;
1155     innerBundleInfo1.SetBaseBundleInfo(bundleInfo);
1156     InnerBundleInfo innerBundleInfo2;
1157     infos.emplace(HAP, innerBundleInfo1);
1158     infos.emplace(HAP_ONE, innerBundleInfo2);
1159     auto ret = installChecker.CheckAppLabelInfo(infos);
1160     EXPECT_EQ(ret, ERR_APPEXECFWK_INSTALL_RELEASETYPE_COMPATIBLE_NOT_SAME);
1161 }
1162 
1163 /**
1164  * @tc.number: CheckAppLabelInfo_0009
1165  * @tc.name: test the start function of CheckAppLabelInfo
1166  * @tc.desc: 1. CheckAppLabelInfo_0009
1167 */
1168 HWTEST_F(BmsBundleInstallCheckerTest, CheckAppLabelInfo_0009, Function | SmallTest | Level0)
1169 {
1170     BundleInstallChecker installChecker;
1171     std::unordered_map<std::string, InnerBundleInfo> infos;
1172     InnerBundleInfo innerBundleInfo1;
1173     InnerBundleInfo innerBundleInfo2;
1174     ApplicationInfo applicationInfo;
1175     applicationInfo.debug = false;
1176     innerBundleInfo1.SetBaseApplicationInfo(applicationInfo);
1177     applicationInfo.debug = true;
1178     innerBundleInfo2.SetBaseApplicationInfo(applicationInfo);
1179     infos.emplace(HAP, innerBundleInfo1);
1180     infos.emplace(HAP_ONE, innerBundleInfo2);
1181     auto ret = installChecker.CheckAppLabelInfo(infos);
1182     EXPECT_EQ(ret, ERR_OK);
1183 }
1184 
1185 /**
1186  * @tc.number: CheckAppLabelInfo_0010
1187  * @tc.name: test the start function of CheckAppLabelInfo
1188  * @tc.desc: 1. CheckAppLabelInfo_0010
1189 */
1190 HWTEST_F(BmsBundleInstallCheckerTest, CheckAppLabelInfo_0010, Function | SmallTest | Level0)
1191 {
1192     BundleInstallChecker installChecker;
1193     std::unordered_map<std::string, InnerBundleInfo> infos;
1194     InnerBundleInfo innerBundleInfo1;
1195     BundleInfo bundleInfo;
1196     bundleInfo.targetVersion = PRIORITY_ONE;
1197     innerBundleInfo1.SetBaseBundleInfo(bundleInfo);
1198     InnerBundleInfo innerBundleInfo2;
1199     infos.emplace(HAP, innerBundleInfo1);
1200     infos.emplace(HAP_ONE, innerBundleInfo2);
1201     auto ret = installChecker.CheckAppLabelInfo(infos);
1202     EXPECT_EQ(ret, ERR_APPEXECFWK_INSTALL_RELEASETYPE_TARGET_NOT_SAME);
1203 }
1204 
1205 /**
1206  * @tc.number: CheckAppLabelInfo_0012
1207  * @tc.name: test the start function of CheckAppLabelInfo
1208  * @tc.desc: 1. CheckAppLabelInfo_0012
1209 */
1210 HWTEST_F(BmsBundleInstallCheckerTest, CheckAppLabelInfo_0012, Function | SmallTest | Level0)
1211 {
1212     BundleInstallChecker installChecker;
1213     std::unordered_map<std::string, InnerBundleInfo> infos;
1214     InnerBundleInfo innerBundleInfo1;
1215     InnerBundleInfo innerBundleInfo2;
1216     innerBundleInfo1.SetGwpAsanEnabled(true);
1217     innerBundleInfo2.SetGwpAsanEnabled(false);
1218     infos.emplace(HAP, innerBundleInfo1);
1219     infos.emplace(HAP_ONE, innerBundleInfo2);
1220     auto ret = installChecker.CheckAppLabelInfo(infos);
1221     EXPECT_EQ(ret, ERR_OK);
1222 }
1223 
1224 /**
1225  * @tc.number: CheckAppLabelInfo_0013
1226  * @tc.name: test the start function of CheckAppLabel
1227  * @tc.desc: 1. Same version
1228  *           2. Both newInfo and oldInfo are not Entry
1229 */
1230 HWTEST_F(BmsBundleInstallCheckerTest, CheckAppLabelInfo_0013, Function | SmallTest | Level0)
1231 {
1232     InnerBundleInfo oldInfo;
1233     InnerBundleInfo newInfo;
1234     BaseBundleInstaller baseBundleInstaller;
1235 
1236     std::map<std::string, InnerModuleInfo> innerModuleInfos;
1237     InnerModuleInfo innerModuleInfo;
1238     innerModuleInfo.isEntry = false;
1239     innerModuleInfos.try_emplace(ENTRY, innerModuleInfo);
1240     oldInfo.innerModuleInfos_ = innerModuleInfos;
1241     newInfo.innerModuleInfos_ = innerModuleInfos;
1242 
1243     auto ret = baseBundleInstaller.CheckAppLabel(oldInfo, newInfo);
1244     EXPECT_EQ(ret, ERR_OK);
1245 }
1246 
1247 /**
1248  * @tc.number: CheckAppLabelInfo_0013
1249  * @tc.name: test the start function of CheckAppLabel
1250  * @tc.desc: 1. Same version
1251  *           2. Both newInfo and oldInfo are Entry
1252  *           3. old is release, new is debug
1253 */
1254 HWTEST_F(BmsBundleInstallCheckerTest, CheckAppLabelInfo_0014, Function | SmallTest | Level0)
1255 {
1256     InnerBundleInfo oldInfo;
1257     InnerBundleInfo newInfo;
1258     ApplicationInfo applicationInfo;
1259     applicationInfo.debug = false;
1260     oldInfo.SetBaseApplicationInfo(applicationInfo);
1261     applicationInfo.debug = true;
1262     newInfo.SetBaseApplicationInfo(applicationInfo);
1263     BaseBundleInstaller baseBundleInstaller;
1264 
1265     std::map<std::string, InnerModuleInfo> innerModuleInfos;
1266     InnerModuleInfo innerModuleInfo;
1267     innerModuleInfo.isEntry = true;
1268     innerModuleInfos.try_emplace(ENTRY, innerModuleInfo);
1269     oldInfo.innerModuleInfos_ = innerModuleInfos;
1270     newInfo.innerModuleInfos_ = innerModuleInfos;
1271 
1272     auto ret = baseBundleInstaller.CheckAppLabel(oldInfo, newInfo);
1273     EXPECT_EQ(ret, ERR_OK);
1274 }
1275 
1276 /**
1277  * @tc.number: CheckAppLabelInfo_0013
1278  * @tc.name: test the start function of CheckAppLabel
1279  * @tc.desc: 1. Same version
1280  *           2. Both newInfo and oldInfo are Entry
1281  *           3. Both old and new is debug
1282 */
1283 HWTEST_F(BmsBundleInstallCheckerTest, CheckAppLabelInfo_0015, Function | SmallTest | Level0)
1284 {
1285     InnerBundleInfo oldInfo;
1286     InnerBundleInfo newInfo;
1287     ApplicationInfo applicationInfo;
1288     applicationInfo.debug = true;
1289     oldInfo.SetBaseApplicationInfo(applicationInfo);
1290     applicationInfo.debug = true;
1291     newInfo.SetBaseApplicationInfo(applicationInfo);
1292     BaseBundleInstaller baseBundleInstaller;
1293 
1294     std::map<std::string, InnerModuleInfo> innerModuleInfos;
1295     InnerModuleInfo innerModuleInfo;
1296     innerModuleInfo.isEntry = true;
1297     innerModuleInfos.try_emplace(ENTRY, innerModuleInfo);
1298     oldInfo.innerModuleInfos_ = innerModuleInfos;
1299     newInfo.innerModuleInfos_ = innerModuleInfos;
1300 
1301     auto ret = baseBundleInstaller.CheckAppLabel(oldInfo, newInfo);
1302     EXPECT_EQ(ret, ERR_OK);
1303 }
1304 
1305 /**
1306  * @tc.number: CheckAppLabelInfo_0016
1307  * @tc.name: test the start function of CheckAppLabel
1308  * @tc.desc: 1. Same version
1309  *           2. oldInfo is entry, newInfo is not entry
1310  *           3. oldInfo is release, newInfo is debug
1311 */
1312 HWTEST_F(BmsBundleInstallCheckerTest, CheckAppLabelInfo_0016, Function | SmallTest | Level0)
1313 {
1314     InnerBundleInfo oldInfo;
1315     InnerBundleInfo newInfo;
1316     ApplicationInfo applicationInfo;
1317     applicationInfo.debug = false;
1318     oldInfo.SetBaseApplicationInfo(applicationInfo);
1319     applicationInfo.debug = true;
1320     newInfo.SetBaseApplicationInfo(applicationInfo);
1321     BaseBundleInstaller baseBundleInstaller;
1322 
1323     std::map<std::string, InnerModuleInfo> innerModuleInfos;
1324     InnerModuleInfo innerModuleInfo;
1325     innerModuleInfo.isEntry = true;
1326     innerModuleInfos.try_emplace(ENTRY, innerModuleInfo);
1327     oldInfo.innerModuleInfos_ = innerModuleInfos;
1328 
1329     std::map<std::string, InnerModuleInfo> innerModuleInfos2;
1330     InnerModuleInfo innerModuleInfo2;
1331     innerModuleInfo2.isEntry = false;
1332     innerModuleInfos2.try_emplace(ENTRY, innerModuleInfo2);
1333     newInfo.innerModuleInfos_ = innerModuleInfos2;
1334 
1335     auto ret = baseBundleInstaller.CheckAppLabel(oldInfo, newInfo);
1336     EXPECT_EQ(ret, ERR_OK);
1337 }
1338 
1339 /**
1340  * @tc.number: CheckAppLabelInfo_0017
1341  * @tc.name: test the start function of CheckAppLabel
1342  * @tc.desc: 1. Same version
1343  *           2. oldInfo is not entry, newInfo is entry
1344  *           3. oldInfo is debug, newInfo is release
1345 */
1346 HWTEST_F(BmsBundleInstallCheckerTest, CheckAppLabelInfo_0017, Function | SmallTest | Level0)
1347 {
1348     InnerBundleInfo oldInfo;
1349     InnerBundleInfo newInfo;
1350     ApplicationInfo applicationInfo;
1351     applicationInfo.debug = true;
1352     oldInfo.SetBaseApplicationInfo(applicationInfo);
1353     applicationInfo.debug = false;
1354     newInfo.SetBaseApplicationInfo(applicationInfo);
1355     BaseBundleInstaller baseBundleInstaller;
1356 
1357     std::map<std::string, InnerModuleInfo> innerModuleInfos;
1358     InnerModuleInfo innerModuleInfo;
1359     innerModuleInfo.isEntry = false;
1360     innerModuleInfos.try_emplace(ENTRY, innerModuleInfo);
1361     oldInfo.innerModuleInfos_ = innerModuleInfos;
1362 
1363     std::map<std::string, InnerModuleInfo> innerModuleInfos2;
1364     InnerModuleInfo innerModuleInfo2;
1365     innerModuleInfo2.isEntry = true;
1366     innerModuleInfos2.try_emplace(ENTRY, innerModuleInfo2);
1367     newInfo.innerModuleInfos_ = innerModuleInfos2;
1368 
1369     auto ret = baseBundleInstaller.CheckAppLabel(oldInfo, newInfo);
1370     EXPECT_EQ(ret, ERR_OK);
1371 }
1372 
1373 /**
1374  * @tc.number: CheckAppLabelInfo_0018
1375  * @tc.name: test the start function of CheckAppLabel
1376  * @tc.desc: 1. Same version
1377  *           2. oldInfo is not entry, newInfo is entry
1378  *           3. oldInfo is debug, newInfo is debug
1379 */
1380 HWTEST_F(BmsBundleInstallCheckerTest, CheckAppLabelInfo_0018, Function | SmallTest | Level0)
1381 {
1382     InnerBundleInfo oldInfo;
1383     InnerBundleInfo newInfo;
1384     ApplicationInfo applicationInfo;
1385     applicationInfo.debug = true;
1386     oldInfo.SetBaseApplicationInfo(applicationInfo);
1387     applicationInfo.debug = true;
1388     newInfo.SetBaseApplicationInfo(applicationInfo);
1389     BaseBundleInstaller baseBundleInstaller;
1390 
1391     std::map<std::string, InnerModuleInfo> innerModuleInfos;
1392     InnerModuleInfo innerModuleInfo;
1393     innerModuleInfo.isEntry = false;
1394     innerModuleInfos.try_emplace(ENTRY, innerModuleInfo);
1395     oldInfo.innerModuleInfos_ = innerModuleInfos;
1396 
1397     std::map<std::string, InnerModuleInfo> innerModuleInfos2;
1398     InnerModuleInfo innerModuleInfo2;
1399     innerModuleInfo2.isEntry = true;
1400     innerModuleInfos2.try_emplace(ENTRY, innerModuleInfo2);
1401     newInfo.innerModuleInfos_ = innerModuleInfos2;
1402 
1403     auto ret = baseBundleInstaller.CheckAppLabel(oldInfo, newInfo);
1404     EXPECT_EQ(ret, ERR_OK);
1405 }
1406 
1407 /**
1408  * @tc.number: CheckAppLabelInfo_0019
1409  * @tc.name: test the start function of CheckAppLabel
1410  * @tc.desc: 1. Same version
1411  *           2. oldInfo is not entry, newInfo is not entry
1412  *           3. oldInfo is release, newInfo is debug
1413 */
1414 HWTEST_F(BmsBundleInstallCheckerTest, CheckAppLabelInfo_0019, Function | SmallTest | Level0)
1415 {
1416     InnerBundleInfo oldInfo;
1417     InnerBundleInfo newInfo;
1418     ApplicationInfo applicationInfo;
1419     applicationInfo.debug = false;
1420     oldInfo.SetBaseApplicationInfo(applicationInfo);
1421     applicationInfo.debug = false;
1422     newInfo.SetBaseApplicationInfo(applicationInfo);
1423     BaseBundleInstaller baseBundleInstaller;
1424 
1425     std::map<std::string, InnerModuleInfo> innerModuleInfos;
1426     InnerModuleInfo innerModuleInfo;
1427     innerModuleInfo.isEntry = false;
1428     innerModuleInfos.try_emplace(ENTRY, innerModuleInfo);
1429     oldInfo.innerModuleInfos_ = innerModuleInfos;
1430 
1431     std::map<std::string, InnerModuleInfo> innerModuleInfos2;
1432     InnerModuleInfo innerModuleInfo2;
1433     innerModuleInfo2.isEntry = true;
1434     innerModuleInfos2.try_emplace(ENTRY, innerModuleInfo2);
1435     newInfo.innerModuleInfos_ = innerModuleInfos2;
1436 
1437     auto ret = baseBundleInstaller.CheckAppLabel(oldInfo, newInfo);
1438     EXPECT_EQ(ret, ERR_OK);
1439 }
1440 
1441 /**
1442  * @tc.number: CheckAppLabelInfo_0020
1443  * @tc.name: test the start function of CheckAppLabel
1444  * @tc.desc: 1. Same version
1445  *           2. oldInfo is entry, newInfo is not entry
1446  *           3. oldInfo is debug, newInfo is debug
1447 */
1448 HWTEST_F(BmsBundleInstallCheckerTest, CheckAppLabelInfo_0020, Function | SmallTest | Level0)
1449 {
1450     InnerBundleInfo oldInfo;
1451     InnerBundleInfo newInfo;
1452     ApplicationInfo applicationInfo;
1453     applicationInfo.debug = true;
1454     oldInfo.SetBaseApplicationInfo(applicationInfo);
1455     applicationInfo.debug = true;
1456     newInfo.SetBaseApplicationInfo(applicationInfo);
1457     BaseBundleInstaller baseBundleInstaller;
1458 
1459     std::map<std::string, InnerModuleInfo> innerModuleInfos;
1460     InnerModuleInfo innerModuleInfo;
1461     innerModuleInfo.isEntry = true;
1462     innerModuleInfos.try_emplace(ENTRY, innerModuleInfo);
1463     oldInfo.innerModuleInfos_ = innerModuleInfos;
1464 
1465     std::map<std::string, InnerModuleInfo> innerModuleInfos2;
1466     InnerModuleInfo innerModuleInfo2;
1467     innerModuleInfo2.isEntry = false;
1468     innerModuleInfos2.try_emplace(ENTRY, innerModuleInfo2);
1469     newInfo.innerModuleInfos_ = innerModuleInfos2;
1470 
1471     auto ret = baseBundleInstaller.CheckAppLabel(oldInfo, newInfo);
1472     EXPECT_EQ(ret, ERR_OK);
1473 }
1474 
1475 /**
1476  * @tc.number: CheckAppLabelInfo_0020
1477  * @tc.name: test the start function of CheckAppLabel
1478  * @tc.desc: 1. Same version
1479  *           2. oldInfo is entry, newInfo is not entry
1480  *           3. oldInfo is release, newInfo is release
1481 */
1482 HWTEST_F(BmsBundleInstallCheckerTest, CheckAppLabelInfo_0021, Function | SmallTest | Level0)
1483 {
1484     InnerBundleInfo oldInfo;
1485     InnerBundleInfo newInfo;
1486     ApplicationInfo applicationInfo;
1487     applicationInfo.debug = false;
1488     oldInfo.SetBaseApplicationInfo(applicationInfo);
1489     applicationInfo.debug = false;
1490     newInfo.SetBaseApplicationInfo(applicationInfo);
1491     BaseBundleInstaller baseBundleInstaller;
1492 
1493     std::map<std::string, InnerModuleInfo> innerModuleInfos;
1494     InnerModuleInfo innerModuleInfo;
1495     innerModuleInfo.isEntry = true;
1496     innerModuleInfos.try_emplace(ENTRY, innerModuleInfo);
1497     oldInfo.innerModuleInfos_ = innerModuleInfos;
1498 
1499     std::map<std::string, InnerModuleInfo> innerModuleInfos2;
1500     InnerModuleInfo innerModuleInfo2;
1501     innerModuleInfo2.isEntry = false;
1502     innerModuleInfos2.try_emplace(ENTRY, innerModuleInfo2);
1503     newInfo.innerModuleInfos_ = innerModuleInfos2;
1504 
1505     auto ret = baseBundleInstaller.CheckAppLabel(oldInfo, newInfo);
1506     EXPECT_EQ(ret, ERR_OK);
1507 }
1508 
1509 /**
1510  * @tc.number: CheckAppLabelInfo_0022
1511  * @tc.name: test the start function of CheckAppLabelInfo
1512  * @tc.desc: 1. Info HasEntry
1513  *           2. entry is release
1514 */
1515 HWTEST_F(BmsBundleInstallCheckerTest, CheckAppLabelInfo_0022, Function | SmallTest | Level0)
1516 {
1517     BundleInstallChecker installChecker;
1518     std::unordered_map<std::string, InnerBundleInfo> infos;
1519     InnerBundleInfo innerBundleInfo;
1520 
1521     std::map<std::string, InnerModuleInfo> innerModuleInfos;
1522     InnerModuleInfo innerModuleInfo;
1523     innerModuleInfo.isEntry = false;
1524     innerModuleInfos.try_emplace(ENTRY, innerModuleInfo);
1525     innerBundleInfo.innerModuleInfos_ = innerModuleInfos;
1526 
1527     ApplicationInfo applicationInfo;
1528     applicationInfo.debug = false;
1529     innerBundleInfo.SetBaseApplicationInfo(applicationInfo);
1530 
1531     infos.emplace(HAP, innerBundleInfo);
1532     auto ret = installChecker.CheckAppLabelInfo(infos);
1533     EXPECT_EQ(ret, ERR_OK);
1534 }
1535 
1536 /**
1537  * @tc.number: CheckAppLabelInfo_0023
1538  * @tc.name: test the start function of CheckAppLabelInfo
1539  * @tc.desc: 1. Info HasEntry
1540  *           2. entry is debug
1541 */
1542 HWTEST_F(BmsBundleInstallCheckerTest, CheckAppLabelInfo_0023, Function | SmallTest | Level0)
1543 {
1544     BundleInstallChecker installChecker;
1545     std::unordered_map<std::string, InnerBundleInfo> infos;
1546     InnerBundleInfo innerBundleInfo;
1547 
1548     std::map<std::string, InnerModuleInfo> innerModuleInfos;
1549     InnerModuleInfo innerModuleInfo;
1550     innerModuleInfo.isEntry = false;
1551     innerModuleInfos.try_emplace(ENTRY, innerModuleInfo);
1552     innerBundleInfo.innerModuleInfos_ = innerModuleInfos;
1553 
1554     ApplicationInfo applicationInfo;
1555     applicationInfo.debug = true;
1556     innerBundleInfo.SetBaseApplicationInfo(applicationInfo);
1557 
1558     infos.emplace(HAP, innerBundleInfo);
1559     auto ret = installChecker.CheckAppLabelInfo(infos);
1560     EXPECT_EQ(ret, ERR_OK);
1561 }
1562 
1563 /**
1564  * @tc.number: CheckAppLabelInfo_0023
1565  * @tc.name: test the start function of CheckAppLabelInfo
1566  * @tc.desc: 1. Info no entry
1567 */
1568 HWTEST_F(BmsBundleInstallCheckerTest, CheckAppLabelInfo_0024, Function | SmallTest | Level0)
1569 {
1570     BundleInstallChecker installChecker;
1571     std::unordered_map<std::string, InnerBundleInfo> infos;
1572     InnerBundleInfo innerBundleInfo;
1573 
1574     infos.emplace(HAP, innerBundleInfo);
1575     auto ret = installChecker.CheckAppLabelInfo(infos);
1576     EXPECT_EQ(ret, ERR_OK);
1577 }
1578 
1579 /**
1580  * @tc.number: CheckAppLabelInfo_0025
1581  * @tc.name: test the start function of CheckAppLabelInfo
1582  * @tc.desc: 1. CheckAppLabelInfo_0025
1583  * @tc.require: issueI6PKSW
1584 */
1585 HWTEST_F(BmsBundleInstallCheckerTest, CheckAppLabelInfo_0025, Function | SmallTest | Level0)
1586 {
1587     BundleInstallChecker installChecker;
1588     std::unordered_map<std::string, InnerBundleInfo> infos;
1589     InnerBundleInfo innerBundleInfo1;
1590     InnerBundleInfo innerBundleInfo2;
1591     innerBundleInfo1.SetTsanEnabled(true);
1592     innerBundleInfo2.SetTsanEnabled(false);
1593     infos.emplace(HAP, innerBundleInfo1);
1594     infos.emplace(HAP_ONE, innerBundleInfo2);
1595     auto ret = installChecker.CheckAppLabelInfo(infos);
1596     EXPECT_EQ(ret, ERR_OK);
1597 }
1598 
1599 /**
1600  * @tc.number: CheckAppLabelInfo_0026
1601  * @tc.name: test the start function of CheckAppLabelInfo
1602  * @tc.desc: 1. CheckAppLabelInfo_0026
1603  * @tc.require: issueI6PKSW
1604 */
1605 HWTEST_F(BmsBundleInstallCheckerTest, CheckAppLabelInfo_0026, Function | SmallTest | Level0)
1606 {
1607     BundleInstallChecker installChecker;
1608     std::unordered_map<std::string, InnerBundleInfo> infos;
1609     InnerBundleInfo innerBundleInfo1;
1610     InnerBundleInfo innerBundleInfo2;
1611     innerBundleInfo1.SetHwasanEnabled(true);
1612     innerBundleInfo2.SetHwasanEnabled(false);
1613     infos.emplace(HAP, innerBundleInfo1);
1614     infos.emplace(HAP_ONE, innerBundleInfo2);
1615     auto ret = installChecker.CheckAppLabelInfo(infos);
1616     EXPECT_EQ(ret, ERR_OK);
1617 }
1618 
1619 /**
1620  * @tc.number: CheckProxyDatas_0001
1621  * @tc.name: test the start function of CheckProxyDatas
1622  * @tc.desc: 1. test CheckProxyDatas
1623 */
1624 HWTEST_F(BmsBundleInstallCheckerTest, CheckProxyDatas_0001, Function | SmallTest | Level0)
1625 {
1626     BundleInstallChecker installChecker;
1627     InnerBundleInfo innerBundleInfo;
1628     ApplicationInfo applicationInfo;
1629     applicationInfo.bundleName = PROXY_DATAS;
1630     innerBundleInfo.SetBaseApplicationInfo(applicationInfo);
1631 
1632     std::map<std::string, InnerModuleInfo> innerModuleInfos;
1633     InnerModuleInfo innerModuleInfo;
1634     innerModuleInfo.moduleName = ENTRY;
1635     ProxyData data;
1636     data.uri = "//";
1637     innerModuleInfo.proxyDatas.push_back(data);
1638     innerModuleInfos.try_emplace(ENTRY, innerModuleInfo);
1639     innerBundleInfo.innerModuleInfos_ = innerModuleInfos;
1640     auto ret = installChecker.CheckProxyDatas(innerBundleInfo);
1641     EXPECT_EQ(ret, ERR_APPEXECFWK_INSTALL_CHECK_PROXY_DATA_URI_FAILED);
1642 }
1643 
1644 /**
1645  * @tc.number: CheckProxyDatas_0001
1646  * @tc.name: test the start function of CheckProxyDatas
1647  * @tc.desc: 1. test CheckProxyDatas
1648 */
1649 HWTEST_F(BmsBundleInstallCheckerTest, CheckProxyDatas_0002, Function | SmallTest | Level0)
1650 {
1651     BundleInstallChecker installChecker;
1652     InnerBundleInfo innerBundleInfo;
1653     std::map<std::string, InnerModuleInfo> innerModuleInfos;
1654     InnerModuleInfo innerModuleInfo;
1655     innerModuleInfo.moduleName = "";
1656     innerModuleInfos.try_emplace("", innerModuleInfo);
1657     innerBundleInfo.innerModuleInfos_ = innerModuleInfos;
1658     auto ret = installChecker.CheckProxyDatas(innerBundleInfo);
1659     EXPECT_EQ(ret, ERR_OK);
1660 }
1661 
1662 /**
1663  * @tc.number: CheckProxyDatas_0001
1664  * @tc.name: test the start function of CheckProxyDatas
1665  * @tc.desc: 1. test CheckProxyDatas
1666 */
1667 HWTEST_F(BmsBundleInstallCheckerTest, CheckProxyDatas_0003, Function | SmallTest | Level0)
1668 {
1669     BundleInstallChecker installChecker;
1670     InnerBundleInfo innerBundleInfo;
1671     ApplicationInfo applicationInfo;
1672     applicationInfo.bundleName = PROXY_DATAS;
1673     innerBundleInfo.SetBaseApplicationInfo(applicationInfo);
1674 
1675     std::map<std::string, InnerModuleInfo> innerModuleInfos;
1676     InnerModuleInfo innerModuleInfo;
1677     innerModuleInfo.moduleName = ENTRY;
1678     ProxyData data;
1679     data.uri = "//2/";
1680     data.requiredReadPermission = "wrong_permission";
1681     innerModuleInfo.proxyDatas.push_back(data);
1682     innerModuleInfos.try_emplace(ENTRY, innerModuleInfo);
1683     innerBundleInfo.innerModuleInfos_ = innerModuleInfos;
1684     auto ret = installChecker.CheckProxyDatas(innerBundleInfo);
1685     EXPECT_EQ(ret, ERR_APPEXECFWK_INSTALL_CHECK_PROXY_DATA_PERMISSION_FAILED);
1686 }
1687 
1688 /**
1689  * @tc.number: CheckProxyDatas_0004
1690  * @tc.name: test the start function of CheckProxyDatas
1691  * @tc.desc: 1. test CheckProxyDatas
1692 */
1693 HWTEST_F(BmsBundleInstallCheckerTest, CheckProxyDatas_0004, Function | SmallTest | Level0)
1694 {
1695     BundleInstallChecker installChecker;
1696     InnerBundleInfo innerBundleInfo;
1697     std::map<std::string, InnerModuleInfo> innerModuleInfos;
1698     InnerModuleInfo innerModuleInfo;
1699     ProxyData data;
1700     data.uri = MODULE_PATH;
1701     innerModuleInfo.proxyDatas.emplace_back(data);
1702     innerModuleInfos.try_emplace(HAP, innerModuleInfo);
1703     innerBundleInfo.innerModuleInfos_ = innerModuleInfos;
1704     ApplicationInfo applicationInfo;
1705     applicationInfo.bundleName = BUNDLE_NAME;
1706     innerBundleInfo.SetBaseApplicationInfo(applicationInfo);
1707     auto ret = installChecker.CheckProxyDatas(innerBundleInfo);
1708     EXPECT_EQ(ret, ERR_APPEXECFWK_INSTALL_CHECK_PROXY_DATA_URI_FAILED);
1709 }
1710 
1711 /**
1712  * @tc.number: CheckProxyDatas_0005
1713  * @tc.name: test the start function of CheckProxyDatas
1714  * @tc.desc: 1. test CheckProxyDatas
1715 */
1716 HWTEST_F(BmsBundleInstallCheckerTest, CheckProxyDatas_0005, Function | SmallTest | Level0)
1717 {
1718     BundleInstallChecker installChecker;
1719     InnerBundleInfo innerBundleInfo;
1720     std::map<std::string, InnerModuleInfo> innerModuleInfos;
1721     InnerModuleInfo innerModuleInfo;
1722     ProxyData data;
1723     data.uri = TEST_PATH;
1724     data.requiredReadPermission = "wrong_permission";
1725     innerModuleInfo.proxyDatas.emplace_back(data);
1726     innerModuleInfos.try_emplace(HAP, innerModuleInfo);
1727     innerBundleInfo.innerModuleInfos_ = innerModuleInfos;
1728     ApplicationInfo applicationInfo;
1729     applicationInfo.isSystemApp = false;
1730     applicationInfo.bundleName = BUNDLE_NAME;
1731     innerBundleInfo.SetBaseApplicationInfo(applicationInfo);
1732     auto ret = installChecker.CheckProxyDatas(innerBundleInfo);
1733     EXPECT_EQ(ret, ERR_APPEXECFWK_INSTALL_CHECK_PROXY_DATA_PERMISSION_FAILED);
1734 }
1735 
1736 /**
1737  * @tc.number: CheckProxyDatas_0006
1738  * @tc.name: test the start function of CheckProxyDatas
1739  * @tc.desc: 1. test CheckProxyDatas
1740 */
1741 HWTEST_F(BmsBundleInstallCheckerTest, CheckProxyDatas_0006, Function | SmallTest | Level0)
1742 {
1743     BundleInstallChecker installChecker;
1744     InnerBundleInfo innerBundleInfo;
1745     auto ret = installChecker.CheckProxyDatas(innerBundleInfo);
1746     EXPECT_EQ(ret, ERR_OK);
1747 }
1748 
1749 /**
1750  * @tc.number: CheckIsolationMode_0001
1751  * @tc.name: test the start function of CheckIsolationMode
1752  * @tc.desc: 1. test CheckIsolationMode
1753 */
1754 HWTEST_F(BmsBundleInstallCheckerTest, CheckIsolationMode_0001, Function | SmallTest | Level0)
1755 {
1756     BundleInstallChecker installChecker;
1757     std::unordered_map<std::string, InnerBundleInfo> infos;
1758     auto ret = installChecker.CheckIsolationMode(infos);
1759     EXPECT_EQ(ret, ERR_OK);
1760 }
1761 
1762 /**
1763  * @tc.number: CheckDuplicateProxyData_0001
1764  * @tc.name: test the start function of CheckDuplicateProxyData
1765  * @tc.desc: 1. test CheckDuplicateProxyData
1766 */
1767 HWTEST_F(BmsBundleInstallCheckerTest, CheckDuplicateProxyData_0001, Function | SmallTest | Level0)
1768 {
1769     InnerBundleInfo newInfo;
1770     InnerBundleInfo oldInfo;
1771     std::map<std::string, InnerModuleInfo> innerModuleInfos;
1772     InnerModuleInfo innerModuleInfo;
1773     innerModuleInfo.moduleName = ENTRY;
1774     ProxyData data;
1775     data.uri = "//2/";
1776     innerModuleInfo.proxyDatas.push_back(data);
1777     innerModuleInfos.try_emplace(ENTRY, innerModuleInfo);
1778     newInfo.innerModuleInfos_ = innerModuleInfos;
1779     oldInfo.innerModuleInfos_ = innerModuleInfos;
1780 
1781     BaseBundleInstaller baseBundleInstaller;
1782     bool ret = baseBundleInstaller.CheckDuplicateProxyData(newInfo, oldInfo);
1783     EXPECT_EQ(ret, false);
1784 }
1785 
1786 /**
1787  * @tc.number: CheckDuplicateProxyData_0002
1788  * @tc.name: test the start function of CheckDuplicateProxyData
1789  * @tc.desc: 1. test CheckDuplicateProxyData
1790 */
1791 HWTEST_F(BmsBundleInstallCheckerTest, CheckDuplicateProxyData_0002, Function | SmallTest | Level0)
1792 {
1793     InnerBundleInfo newInfo;
1794     InnerBundleInfo oldInfo;
1795 
1796     BaseBundleInstaller baseBundleInstaller;
1797     bool ret = baseBundleInstaller.CheckDuplicateProxyData(newInfo, oldInfo);
1798     EXPECT_EQ(ret, true);
1799 }
1800 
1801 /**
1802  * @tc.number: CheckDuplicateProxyData_0002
1803  * @tc.name: test the start function of CheckDuplicateProxyData
1804  * @tc.desc: 1. test CheckDuplicateProxyData
1805 */
1806 HWTEST_F(BmsBundleInstallCheckerTest, CheckDuplicateProxyData_0003, Function | SmallTest | Level0)
1807 {
1808     std::unordered_map<std::string, InnerBundleInfo> newInfos;
1809 
1810     BaseBundleInstaller baseBundleInstaller;
1811     bool ret = baseBundleInstaller.CheckDuplicateProxyData(newInfos);
1812     EXPECT_EQ(ret, true);
1813 }
1814 
1815 /**
1816  * @tc.number: CheckSignatureFileDir_0001
1817  * @tc.name: test the start function of CheckSignatureFileDir
1818  * @tc.desc: 1. test CheckSignatureFileDir
1819 */
1820 HWTEST_F(BmsBundleInstallCheckerTest, CheckSignatureFileDir_0001, Function | SmallTest | Level0)
1821 {
1822     BundleInstallChecker installChecker;
1823     auto ret = installChecker.CheckSignatureFileDir("");
1824     EXPECT_EQ(ret, ERR_BUNDLEMANAGER_INSTALL_CODE_SIGNATURE_FILE_IS_INVALID);
1825 }
1826 
1827 /**
1828  * @tc.number: CheckSignatureFileDir_0002
1829  * @tc.name: test the start function of CheckSignatureFileDir
1830  * @tc.desc: 1. test CheckSignatureFileDir
1831 */
1832 HWTEST_F(BmsBundleInstallCheckerTest, CheckSignatureFileDir_0002, Function | SmallTest | Level0)
1833 {
1834     BundleInstallChecker installChecker;
1835     auto ret = installChecker.CheckSignatureFileDir("data/test");
1836     EXPECT_EQ(ret, ERR_BUNDLEMANAGER_INSTALL_CODE_SIGNATURE_FILE_IS_INVALID);
1837 }
1838 
1839 /**
1840  * @tc.number: CheckSignatureFileDir_0003
1841  * @tc.name: test the start function of CheckSignatureFileDir
1842  * @tc.desc: 1. test CheckSignatureFileDir
1843 */
1844 HWTEST_F(BmsBundleInstallCheckerTest, CheckSignatureFileDir_0003, Function | SmallTest | Level0)
1845 {
1846     BundleInstallChecker installChecker;
1847     auto ret = installChecker.CheckSignatureFileDir("test.sig");
1848     EXPECT_EQ(ret, ERR_OK);
1849 }
1850 
1851 /**
1852  * @tc.number: CheckCheckProxyPermissionLevel_0001
1853  * @tc.name: test the start function of CheckProxyPermissionLevel
1854  * @tc.desc: 1. test CheckProxyPermissionLevel
1855 */
1856 HWTEST_F(BmsBundleInstallCheckerTest, CheckProxyPermissionLevel_0001, Function | SmallTest | Level0)
1857 {
1858     BundleInstallChecker installChecker;
1859     auto ret = installChecker.CheckProxyPermissionLevel("");
1860     EXPECT_EQ(ret, true);
1861 }
1862 
1863 /**
1864  * @tc.number: CheckCheckProxyPermissionLevel_0002
1865  * @tc.name: test the start function of CheckProxyPermissionLevel
1866  * @tc.desc: 1. test CheckProxyPermissionLevel
1867 */
1868 HWTEST_F(BmsBundleInstallCheckerTest, CheckProxyPermissionLevel_0002, Function | SmallTest | Level0)
1869 {
1870     BundleInstallChecker installChecker;
1871     auto ret = installChecker.CheckProxyPermissionLevel("ohos.permission.GET_BUNDLE_INFO");
1872     EXPECT_EQ(ret, false);
1873 }
1874 
1875 /**
1876  * @tc.number: CheckCheckProxyPermissionLevel_0003
1877  * @tc.name: test the start function of CheckProxyPermissionLevel
1878  * @tc.desc: 1. test CheckProxyPermissionLevel
1879 */
1880 HWTEST_F(BmsBundleInstallCheckerTest, CheckProxyPermissionLevel_0003, Function | SmallTest | Level0)
1881 {
1882     BundleInstallChecker installChecker;
1883     auto ret = installChecker.CheckProxyPermissionLevel("wrong_permission_name");
1884     EXPECT_EQ(ret, false);
1885 }
1886 
1887 /**
1888  * @tc.number: CheckMDMUpdateBundleForSelf_0001
1889  * @tc.name: test the start function of CheckMDMUpdateBundleForSelf
1890  * @tc.desc: 1. test CheckMDMUpdateBundleForSelf
1891 */
1892 HWTEST_F(BmsBundleInstallCheckerTest, CheckMDMUpdateBundleForSelf_0001, Function | SmallTest | Level0)
1893 {
1894     BaseBundleInstaller baseBundleInstaller;
1895     InstallParam param;
1896     param.isSelfUpdate = false;
1897     std::unordered_map<std::string, InnerBundleInfo> infos;
1898     InnerBundleInfo innerBundleInfo;
1899     auto ret = baseBundleInstaller.CheckMDMUpdateBundleForSelf(param, innerBundleInfo, infos, true);
1900     EXPECT_EQ(ret, ERR_OK);
1901 }
1902 
1903 /**
1904  * @tc.number: CheckMDMUpdateBundleForSelf_0002
1905  * @tc.name: test the start function of CheckMDMUpdateBundleForSelf
1906  * @tc.desc: 1. test CheckMDMUpdateBundleForSelf
1907 */
1908 HWTEST_F(BmsBundleInstallCheckerTest, CheckMDMUpdateBundleForSelf_0002, Function | SmallTest | Level0)
1909 {
1910     BaseBundleInstaller baseBundleInstaller;
1911     InstallParam param;
1912     param.isSelfUpdate = true;
1913     std::unordered_map<std::string, InnerBundleInfo> infos;
1914     InnerBundleInfo innerBundleInfo;
1915     auto ret = baseBundleInstaller.CheckMDMUpdateBundleForSelf(param, innerBundleInfo, infos, false);
1916     EXPECT_EQ(ret, ERR_APPEXECFWK_INSTALL_SELF_UPDATE_BUNDLENAME_NOT_SAME);
1917 }
1918 
1919 /**
1920  * @tc.number: CheckMDMUpdateBundleForSelf_0003
1921  * @tc.name: test the start function of CheckMDMUpdateBundleForSelf
1922  * @tc.desc: 1. test CheckMDMUpdateBundleForSelf
1923 */
1924 HWTEST_F(BmsBundleInstallCheckerTest, CheckMDMUpdateBundleForSelf_0003, Function | SmallTest | Level0)
1925 {
1926     BaseBundleInstaller baseBundleInstaller;
1927     InstallParam param;
1928     param.isSelfUpdate = true;
1929     std::unordered_map<std::string, InnerBundleInfo> infos;
1930     InnerBundleInfo innerBundleInfo;
1931 
1932     innerBundleInfo.SetAppDistributionType("");
1933     auto ret = baseBundleInstaller.CheckMDMUpdateBundleForSelf(param, innerBundleInfo, infos, true);
1934     EXPECT_EQ(ret, ERR_APPEXECFWK_INSTALL_SELF_UPDATE_NOT_MDM);
1935 }
1936 
1937 /**
1938  * @tc.number: CheckMDMUpdateBundleForSelf_0004
1939  * @tc.name: test the start function of CheckMDMUpdateBundleForSelf
1940  * @tc.desc: 1. test CheckMDMUpdateBundleForSelf
1941 */
1942 HWTEST_F(BmsBundleInstallCheckerTest, CheckMDMUpdateBundleForSelf_0004, Function | SmallTest | Level0)
1943 {
1944     BaseBundleInstaller baseBundleInstaller;
1945     InstallParam param;
1946     param.isSelfUpdate = true;
1947     std::unordered_map<std::string, InnerBundleInfo> infos;
1948     InnerBundleInfo innerBundleInfo;
1949 
1950     innerBundleInfo.SetAppDistributionType(Constants::APP_DISTRIBUTION_TYPE_ENTERPRISE_MDM);
1951     auto ret = baseBundleInstaller.CheckMDMUpdateBundleForSelf(param, innerBundleInfo, infos, true);
1952     EXPECT_EQ(ret, ERR_OK);
1953 }
1954 
1955 /**
1956  * @tc.number: CheckMDMUpdateBundleForSelf_0005
1957  * @tc.name: test the start function of CheckMDMUpdateBundleForSelf
1958  * @tc.desc: 1. test CheckMDMUpdateBundleForSelf
1959 */
1960 HWTEST_F(BmsBundleInstallCheckerTest, CheckMDMUpdateBundleForSelf_0005, Function | SmallTest | Level0)
1961 {
1962     BaseBundleInstaller baseBundleInstaller;
1963     InstallParam param;
1964     param.isSelfUpdate = true;
1965     std::unordered_map<std::string, InnerBundleInfo> infos;
1966     InnerBundleInfo innerBundleInfo;
1967     ApplicationInfo applicationInfo;
1968     applicationInfo.bundleName = BUNDLE_NAME;
1969     innerBundleInfo.SetBaseApplicationInfo(applicationInfo);
1970     innerBundleInfo.SetAppDistributionType(Constants::APP_DISTRIBUTION_TYPE_ENTERPRISE_MDM);
1971     infos.emplace(BUNDLE_NAME, innerBundleInfo);
1972     auto ret = baseBundleInstaller.CheckMDMUpdateBundleForSelf(param, innerBundleInfo, infos, true);
1973     EXPECT_EQ(ret, ERR_OK);
1974 }
1975 
1976 /**
1977  * @tc.number: CheckMDMUpdateBundleForSelf_0006
1978  * @tc.name: test the start function of CheckMDMUpdateBundleForSelf
1979  * @tc.desc: 1. test CheckMDMUpdateBundleForSelf
1980 */
1981 HWTEST_F(BmsBundleInstallCheckerTest, CheckMDMUpdateBundleForSelf_0006, Function | SmallTest | Level0)
1982 {
1983     BaseBundleInstaller baseBundleInstaller;
1984     InstallParam param;
1985     param.isSelfUpdate = true;
1986     std::unordered_map<std::string, InnerBundleInfo> infos;
1987     InnerBundleInfo innerBundleInfo;
1988     ApplicationInfo applicationInfo;
1989     applicationInfo.bundleName = BUNDLE_NAME;
1990     innerBundleInfo.SetBaseApplicationInfo(applicationInfo);
1991     innerBundleInfo.SetAppDistributionType(Constants::APP_DISTRIBUTION_TYPE_ENTERPRISE_MDM);
1992     InnerBundleInfo innerBundleInfo2;
1993     ApplicationInfo applicationInfo2;
1994     applicationInfo.bundleName = "wrong_name";
1995     innerBundleInfo2.SetBaseApplicationInfo(applicationInfo2);
1996     infos.emplace(BUNDLE_NAME, innerBundleInfo2);
1997 
1998     auto ret = baseBundleInstaller.CheckMDMUpdateBundleForSelf(param, innerBundleInfo, infos, true);
1999     EXPECT_EQ(ret, ERR_APPEXECFWK_INSTALL_SELF_UPDATE_BUNDLENAME_NOT_SAME);
2000 }
2001 
2002 /**
2003  * @tc.number: VaildEnterpriseInstallPermission_0001
2004  * @tc.name: test the start function of VaildEnterpriseInstallPermission
2005  * @tc.desc: 1. test VaildEnterpriseInstallPermission
2006 */
2007 HWTEST_F(BmsBundleInstallCheckerTest, VaildEnterpriseInstallPermission_0001, Function | SmallTest | Level0)
2008 {
2009     BundleInstallChecker installChecker;
2010     InstallParam param;
2011     Security::Verify::ProvisionInfo provisionInfo;
2012     param.isSelfUpdate = true;
2013     auto ret = installChecker.VaildEnterpriseInstallPermission(param, provisionInfo);
2014     EXPECT_EQ(ret, false);
2015     provisionInfo.distributionType = Security::Verify::AppDistType::ENTERPRISE_MDM;
2016     ret = installChecker.VaildEnterpriseInstallPermission(param, provisionInfo);
2017     EXPECT_EQ(ret, true);
2018 }
2019 
2020 /**
2021  * @tc.number: VaildEnterpriseInstallPermission_0002
2022  * @tc.name: test the start function of VaildEnterpriseInstallPermission
2023  * @tc.desc: 1. test VaildEnterpriseInstallPermission
2024 */
2025 HWTEST_F(BmsBundleInstallCheckerTest, VaildEnterpriseInstallPermission_0002, Function | SmallTest | Level0)
2026 {
2027     BundleInstallChecker installChecker;
2028     InstallParam param;
2029     Security::Verify::ProvisionInfo provisionInfo;
2030     param.isCallByShell = true;
2031     provisionInfo.type = Security::Verify::ProvisionType::RELEASE;
2032     auto ret = installChecker.VaildEnterpriseInstallPermission(param, provisionInfo);
2033     EXPECT_EQ(ret, false);
2034     provisionInfo.type = Security::Verify::ProvisionType::DEBUG;
2035     ret = installChecker.VaildEnterpriseInstallPermission(param, provisionInfo);
2036     EXPECT_EQ(ret, true);
2037 }
2038 
2039 /**
2040  * @tc.number: VaildEnterpriseInstallPermission_0003
2041  * @tc.name: test the start function of VaildEnterpriseInstallPermission
2042  * @tc.desc: 1. test VaildEnterpriseInstallPermission
2043 */
2044 HWTEST_F(BmsBundleInstallCheckerTest, VaildEnterpriseInstallPermission_0003, Function | SmallTest | Level0)
2045 {
2046     BundleInstallChecker installChecker;
2047     InstallParam param;
2048     Security::Verify::ProvisionInfo provisionInfo;
2049     param.isCallByShell = false;
2050     provisionInfo.distributionType = Security::Verify::AppDistType::ENTERPRISE_NORMAL;
2051     auto ret = installChecker.VaildEnterpriseInstallPermission(param, provisionInfo);
2052     EXPECT_EQ(ret, false);
2053     param.installEtpNormalBundlePermissionStatus = PermissionStatus::HAVE_PERMISSION_STATUS;
2054     ret = installChecker.VaildEnterpriseInstallPermission(param, provisionInfo);
2055     EXPECT_EQ(ret, true);
2056     param.installEtpMdmBundlePermissionStatus = PermissionStatus::HAVE_PERMISSION_STATUS;
2057     ret = installChecker.VaildEnterpriseInstallPermission(param, provisionInfo);
2058     EXPECT_EQ(ret, true);
2059 }
2060 
2061 /**
2062  * @tc.number: VaildEnterpriseInstallPermission_0004
2063  * @tc.name: test the start function of VaildEnterpriseInstallPermission
2064  * @tc.desc: 1. test VaildEnterpriseInstallPermission
2065 */
2066 HWTEST_F(BmsBundleInstallCheckerTest, VaildEnterpriseInstallPermission_0004, Function | SmallTest | Level0)
2067 {
2068     BundleInstallChecker installChecker;
2069     InstallParam param;
2070     Security::Verify::ProvisionInfo provisionInfo;
2071     param.isCallByShell = false;
2072     provisionInfo.distributionType = Security::Verify::AppDistType::ENTERPRISE_MDM;
2073     auto ret = installChecker.VaildEnterpriseInstallPermission(param, provisionInfo);
2074     EXPECT_EQ(ret, false);
2075     param.installEtpMdmBundlePermissionStatus = PermissionStatus::HAVE_PERMISSION_STATUS;
2076     ret = installChecker.VaildEnterpriseInstallPermission(param, provisionInfo);
2077     EXPECT_EQ(ret, true);
2078 }
2079 
2080 /**
2081  * @tc.number: MatchSignature_0101
2082  * @tc.name: test the start function of MatchSignature
2083  * @tc.desc: 1. BundleInstallChecker
2084 */
2085 HWTEST_F(BmsBundleInstallCheckerTest, MatchSignature_0101, Function | SmallTest | Level0)
2086 {
2087     BundleInstallChecker installChecker;
2088     std::vector<std::string> appSignatures;
2089     bool res = installChecker.MatchSignature(appSignatures, "");
2090     EXPECT_FALSE(res);
2091     appSignatures.push_back("exist");
2092     res = installChecker.MatchSignature(appSignatures, "");
2093     EXPECT_FALSE(res);
2094     res = installChecker.MatchSignature(appSignatures, "not_exist");
2095     EXPECT_FALSE(res);
2096     res = installChecker.MatchSignature(appSignatures, "exist");
2097     EXPECT_TRUE(res);
2098 }
2099 
2100 /**
2101  * @tc.number: MatchSignature_0102
2102  * @tc.name: test the start function of MatchOldSignatures
2103  * @tc.desc: 1. BundleInstallChecker
2104 */
2105 HWTEST_F(BmsBundleInstallCheckerTest, MatchSignature_0102, Function | SmallTest | Level0)
2106 {
2107     BundleInstallChecker installChecker;
2108     std::vector<std::string> appSignatures;
2109     DelayedSingleton<BundleMgrService>::GetInstance()->InitBundleDataMgr();
2110     bool res = installChecker.MatchOldSignatures("", appSignatures);
2111     EXPECT_FALSE(res);
2112 }
2113 
2114 /**
2115  * @tc.number: VaildInstallPermissionForShare_0100
2116  * @tc.name: test VaildInstallPermissionForShare
2117  * @tc.desc: 1.test isCallByShell is false
2118  */
2119 HWTEST_F(BmsBundleInstallCheckerTest, VaildInstallPermissionForShare_0100, Function | SmallTest | Level0)
2120 {
2121     BundleInstallChecker installChecker;
2122     InstallCheckParam checkParam;
2123     std::vector<Security::Verify::HapVerifyResult> hapVerifyRes;
2124     Security::Verify::HapVerifyResult result;
2125     hapVerifyRes.emplace_back(result);
2126     checkParam.isCallByShell = false;
2127     checkParam.installBundlePermissionStatus = PermissionStatus::HAVE_PERMISSION_STATUS;
2128     checkParam.installEnterpriseBundlePermissionStatus = PermissionStatus::HAVE_PERMISSION_STATUS;
2129     checkParam.installEtpMdmBundlePermissionStatus = PermissionStatus::HAVE_PERMISSION_STATUS;
2130     bool res1 = installChecker.VaildInstallPermissionForShare(checkParam, hapVerifyRes);
2131     EXPECT_TRUE(res1);
2132 
2133     checkParam.installBundlePermissionStatus = PermissionStatus::NON_HAVE_PERMISSION_STATUS;
2134     bool res2 = installChecker.VaildInstallPermissionForShare(checkParam, hapVerifyRes);
2135     EXPECT_FALSE(res2);
2136 
2137     checkParam.installEnterpriseBundlePermissionStatus = PermissionStatus::NON_HAVE_PERMISSION_STATUS;
2138     bool res3 = installChecker.VaildInstallPermissionForShare(checkParam, hapVerifyRes);
2139     EXPECT_FALSE(res3);
2140 
2141     checkParam.installEtpMdmBundlePermissionStatus = PermissionStatus::NON_HAVE_PERMISSION_STATUS;
2142     bool res4 = installChecker.VaildInstallPermissionForShare(checkParam, hapVerifyRes);
2143     EXPECT_FALSE(res4);
2144 
2145     checkParam.installBundlePermissionStatus = PermissionStatus::HAVE_PERMISSION_STATUS;
2146     bool res5 = installChecker.VaildInstallPermissionForShare(checkParam, hapVerifyRes);
2147     EXPECT_TRUE(res5);
2148 
2149     checkParam.installEnterpriseBundlePermissionStatus = PermissionStatus::HAVE_PERMISSION_STATUS;
2150     bool res6 = installChecker.VaildInstallPermissionForShare(checkParam, hapVerifyRes);
2151     EXPECT_TRUE(res6);
2152 }
2153 
2154 /**
2155  * @tc.number: VaildInstallPermissionForShare_0200
2156  * @tc.name: test VaildInstallPermissionForShare
2157  * @tc.desc: 1.test isCallByShell is true
2158  */
2159 HWTEST_F(BmsBundleInstallCheckerTest, VaildInstallPermissionForShare_0200, Function | SmallTest | Level0)
2160 {
2161     BundleInstallChecker installChecker;
2162     InstallCheckParam checkParam;
2163     std::vector<Security::Verify::HapVerifyResult> hapVerifyRes;
2164     Security::Verify::HapVerifyResult result;
2165     hapVerifyRes.emplace_back(result);
2166     checkParam.isCallByShell = true;
2167     checkParam.installBundlePermissionStatus = PermissionStatus::HAVE_PERMISSION_STATUS;
2168     checkParam.installEnterpriseBundlePermissionStatus = PermissionStatus::HAVE_PERMISSION_STATUS;
2169     checkParam.installEtpMdmBundlePermissionStatus = PermissionStatus::HAVE_PERMISSION_STATUS;
2170     bool res1 = installChecker.VaildInstallPermissionForShare(checkParam, hapVerifyRes);
2171     EXPECT_TRUE(res1);
2172 
2173     checkParam.installBundlePermissionStatus = PermissionStatus::NON_HAVE_PERMISSION_STATUS;
2174     bool res2 = installChecker.VaildInstallPermissionForShare(checkParam, hapVerifyRes);
2175     EXPECT_FALSE(res2);
2176 
2177     checkParam.installEnterpriseBundlePermissionStatus = PermissionStatus::NON_HAVE_PERMISSION_STATUS;
2178     bool res3 = installChecker.VaildInstallPermissionForShare(checkParam, hapVerifyRes);
2179     EXPECT_FALSE(res3);
2180 
2181     checkParam.installEtpMdmBundlePermissionStatus = PermissionStatus::NON_HAVE_PERMISSION_STATUS;
2182     bool res4 = installChecker.VaildInstallPermissionForShare(checkParam, hapVerifyRes);
2183     EXPECT_FALSE(res4);
2184 
2185     checkParam.installBundlePermissionStatus = PermissionStatus::HAVE_PERMISSION_STATUS;
2186     bool res5 = installChecker.VaildInstallPermissionForShare(checkParam, hapVerifyRes);
2187     EXPECT_TRUE(res5);
2188 
2189     checkParam.installEnterpriseBundlePermissionStatus = PermissionStatus::HAVE_PERMISSION_STATUS;
2190     bool res6 = installChecker.VaildInstallPermissionForShare(checkParam, hapVerifyRes);
2191     EXPECT_TRUE(res6);
2192 }
2193 
2194 /**
2195  * @tc.number: VaildEnterpriseInstallPermissionForShare_0100
2196  * @tc.name: test VaildEnterpriseInstallPermissionForShare
2197  * @tc.desc: 1.test VaildEnterpriseInstallPermissionForShare of BundleInstallChecker
2198  */
2199 HWTEST_F(BmsBundleInstallCheckerTest, VaildEnterpriseInstallPermissionForShare_0100, Function | SmallTest | Level0)
2200 {
2201     BundleInstallChecker installChecker;
2202     InstallCheckParam checkParam;
2203     Security::Verify::ProvisionInfo provisionInfo;
2204     checkParam.isCallByShell = true;
2205     provisionInfo.type = Security::Verify::ProvisionType::RELEASE;
2206     bool res1 = installChecker.VaildEnterpriseInstallPermissionForShare(checkParam, provisionInfo);
2207     EXPECT_FALSE(res1);
2208 
2209     checkParam.isCallByShell = false;
2210     provisionInfo.type = Security::Verify::ProvisionType::DEBUG;
2211     bool res2 = installChecker.VaildEnterpriseInstallPermissionForShare(checkParam, provisionInfo);
2212     EXPECT_TRUE(res2);
2213 
2214     provisionInfo.distributionType = Security::Verify::AppDistType::ENTERPRISE_NORMAL;
2215     bool res3 = installChecker.VaildEnterpriseInstallPermissionForShare(checkParam, provisionInfo);
2216     EXPECT_FALSE(res3);
2217 
2218     checkParam.installEtpNormalBundlePermissionStatus = PermissionStatus::HAVE_PERMISSION_STATUS;
2219     bool res4 = installChecker.VaildEnterpriseInstallPermissionForShare(checkParam, provisionInfo);
2220     EXPECT_TRUE(res4);
2221 
2222     checkParam.installEtpMdmBundlePermissionStatus = PermissionStatus::HAVE_PERMISSION_STATUS;
2223     bool res5 = installChecker.VaildEnterpriseInstallPermissionForShare(checkParam, provisionInfo);
2224     EXPECT_TRUE(res5);
2225 
2226     checkParam.installEtpMdmBundlePermissionStatus = PermissionStatus::NON_HAVE_PERMISSION_STATUS;
2227     bool res6 = installChecker.VaildEnterpriseInstallPermissionForShare(checkParam, provisionInfo);
2228     EXPECT_TRUE(res6);
2229 
2230     checkParam.installEtpNormalBundlePermissionStatus = PermissionStatus::NON_HAVE_PERMISSION_STATUS;
2231     bool res7 = installChecker.VaildEnterpriseInstallPermissionForShare(checkParam, provisionInfo);
2232     EXPECT_FALSE(res7);
2233 
2234     checkParam.installEtpMdmBundlePermissionStatus = PermissionStatus::HAVE_PERMISSION_STATUS;
2235     bool res8 = installChecker.VaildEnterpriseInstallPermissionForShare(checkParam, provisionInfo);
2236     EXPECT_TRUE(res8);
2237 
2238     provisionInfo.distributionType = Security::Verify::AppDistType::ENTERPRISE_MDM;
2239     bool res9 = installChecker.VaildEnterpriseInstallPermissionForShare(checkParam, provisionInfo);
2240     EXPECT_TRUE(res9);
2241 
2242     checkParam.installEtpMdmBundlePermissionStatus = PermissionStatus::NON_HAVE_PERMISSION_STATUS;
2243     bool res10 = installChecker.VaildEnterpriseInstallPermissionForShare(checkParam, provisionInfo);
2244     EXPECT_FALSE(res10);
2245 
2246     checkParam.installEtpNormalBundlePermissionStatus = PermissionStatus::NON_HAVE_PERMISSION_STATUS;
2247     bool res11 = installChecker.VaildEnterpriseInstallPermissionForShare(checkParam, provisionInfo);
2248     EXPECT_FALSE(res11);
2249 }
2250 
2251 /**
2252  * @tc.number: ResetAOTCompileStatus_0100
2253  * @tc.name: test ResetAOTCompileStatus
2254  * @tc.desc: 1.test ResetAOTCompileStatus of InnerBundleInfo
2255  */
2256 HWTEST_F(BmsBundleInstallCheckerTest, ResetAOTCompileStatus_0100, Function | SmallTest | Level0)
2257 {
2258     InnerBundleInfo innerBundleInfonfo;
2259     auto res = innerBundleInfonfo.ResetAOTCompileStatus(ENTRY);
2260     EXPECT_EQ(res, ERR_BUNDLE_MANAGER_MODULE_NOT_EXIST);
2261 
2262     InnerModuleInfo innerModuleInfo;
2263     innerBundleInfonfo.InsertInnerModuleInfo(ENTRY, innerModuleInfo);
2264     res = innerBundleInfonfo.ResetAOTCompileStatus(ENTRY);
2265     EXPECT_EQ(res, ERR_OK);
2266 }
2267 
2268 /**
2269  * @tc.number: GetLastInstallationTimeTest
2270  * @tc.name: test GetLastInstallationTime
2271  * @tc.desc: 1.test GetLastInstallationTime of InnerBundleInfo
2272 */
2273 HWTEST_F(BmsBundleInstallCheckerTest, GetLastInstallationTimeTest, Function | SmallTest | Level1)
2274 {
2275     InnerBundleInfo innerBundleInfonfo;
2276     InnerBundleUserInfo innerBundleUserInfo;
2277     innerBundleInfonfo.innerBundleUserInfos_.try_emplace(BUNDLE_NAME, innerBundleUserInfo);
2278     int64_t res = innerBundleInfonfo.GetLastInstallationTime();
2279     EXPECT_GE(res, 0);
2280 }
2281 
2282 /**
2283  * @tc.number: GetEntryModuleNameTest
2284  * @tc.name: test GetEntryModuleName
2285  * @tc.desc: 1.test GetEntryModuleName of InnerBundleInfo
2286 */
2287 HWTEST_F(BmsBundleInstallCheckerTest, GetEntryModuleNameTest, Function | SmallTest | Level1)
2288 {
2289     InnerBundleInfo innerBundleInfonfo;
2290     std::string res = innerBundleInfonfo.GetEntryModuleName();
2291     EXPECT_EQ(res.empty(), true);
2292 
2293     InnerModuleInfo innerModuleInfo;
2294     innerModuleInfo.isEntry = true;
2295     innerModuleInfo.modulePackage = HAP_TWO;
2296     innerBundleInfonfo.InsertInnerModuleInfo(HAP_ONE, innerModuleInfo);
2297     res = innerBundleInfonfo.GetEntryModuleName();
2298     EXPECT_EQ(res.empty(), false);
2299 }
2300 
2301 /**
2302  * @tc.number: VaildInstallPermission_0100
2303  * @tc.name: test VaildInstallPermission
2304  * @tc.desc: 1.test install permission
2305  */
2306 HWTEST_F(BmsBundleInstallCheckerTest, VaildInstallPermission_0100, Function | SmallTest | Level0)
2307 {
2308     BundleInstallChecker installChecker;
2309     InstallParam installParam;
2310     installParam.isSelfUpdate = false;
2311     std::vector<Security::Verify::HapVerifyResult> hapVerifyRes;
2312     bool ret = installChecker.VaildInstallPermission(installParam, hapVerifyRes);
2313     EXPECT_EQ(ret, true);
2314 
2315     Security::Verify::HapVerifyResult result;
2316     hapVerifyRes.emplace_back(result);
2317     ret = installChecker.VaildInstallPermission(installParam, hapVerifyRes);
2318     EXPECT_EQ(ret, false);
2319 }
2320 
2321 /**
2322  * @tc.number: FindModuleInInstalledPackage_0100
2323  * @tc.name: test FindModuleInInstalledPackage
2324  * @tc.desc: 1.test find module in install package
2325  */
2326 HWTEST_F(BmsBundleInstallCheckerTest, FindModuleInInstalledPackage_0100, Function | SmallTest | Level0)
2327 {
2328     BundleInstallChecker installChecker;
2329     std::string moduleName = ENTRY;
2330     std::string bundleName = BUNDLE_NAME;
2331     uint32_t versionCode = 0;
2332     bool ret = installChecker.FindModuleInInstalledPackage(moduleName, bundleName, versionCode);
2333     EXPECT_EQ(ret, false);
2334 }
2335 
2336 /**
2337  * @tc.number: CheckHapHashParams_0200
2338  * @tc.name: test the function of CheckHapHashParams
2339  * @tc.desc: 1.test check hap hash params by CheckHapHashParams
2340 */
2341 HWTEST_F(BmsBundleInstallCheckerTest, CheckHapHashParams_0200, Function | SmallTest | Level0)
2342 {
2343     std::unordered_map<std::string, InnerBundleInfo> infos;
2344     InnerBundleInfo innerBundleInfo;
2345     infos.emplace(HAP, innerBundleInfo);
2346     std::map<std::string, std::string> hashParams;
2347     hashParams.insert(pair<string, string>(ENTRY, BUNDLE_NAME));
2348     BundleInstallChecker installChecker;
2349     auto ret = installChecker.CheckHapHashParams(infos, hashParams);
2350     EXPECT_EQ(ret, ERR_APPEXECFWK_INSTALL_FAILED_MODULE_NAME_EMPTY);
2351 
2352     std::map<std::string, InnerModuleInfo> innerModuleInfos;
2353     InnerModuleInfo innerModuleInfo;
2354     ProxyData data;
2355     data.uri = MODULE_PATH;
2356     innerModuleInfo.moduleName = MODULE_PACKAGE;
2357     innerModuleInfo.proxyDatas.emplace_back(data);
2358     innerModuleInfos.try_emplace(HAP, innerModuleInfo);
2359     innerBundleInfo.innerModuleInfos_ = innerModuleInfos;
2360     infos.clear();
2361     infos.emplace(HAP, innerBundleInfo);
2362     ret = installChecker.CheckHapHashParams(infos, hashParams);
2363     EXPECT_EQ(ret, ERR_APPEXECFWK_INSTALL_FAILED_CHECK_HAP_HASH_PARAM);
2364 }
2365 
2366 /**
2367  * @tc.number: CheckEnterpriseBundle_0100
2368  * @tc.name: test CheckEnterpriseBundle
2369  * @tc.desc: 1.test check enterprise bundle
2370  */
2371 HWTEST_F(BmsBundleInstallCheckerTest, CheckEnterpriseBundle_0100, Function | SmallTest | Level0)
2372 {
2373     BundleInstallChecker installChecker;
2374     Security::Verify::HapVerifyResult result;
2375     Security::Verify::ProvisionInfo provisionInfo;
2376     provisionInfo.type = Security::Verify::ProvisionType::DEBUG;
2377     provisionInfo.distributionType = Security::Verify::AppDistType::ENTERPRISE_NORMAL;
2378     result.SetProvisionInfo(provisionInfo);
2379     bool ret = installChecker.CheckEnterpriseBundle(result);
2380     EXPECT_EQ(ret, true);
2381 
2382     provisionInfo.distributionType = Security::Verify::AppDistType::ENTERPRISE_MDM;
2383     result.SetProvisionInfo(provisionInfo);
2384     ret = installChecker.CheckEnterpriseBundle(result);
2385     EXPECT_EQ(ret, true);
2386 
2387     provisionInfo.distributionType = Security::Verify::AppDistType::ENTERPRISE;
2388     result.SetProvisionInfo(provisionInfo);
2389     ret = installChecker.CheckEnterpriseBundle(result);
2390     EXPECT_EQ(ret, true);
2391 }
2392 
2393 /**
2394  * @tc.number: CheckInternaltestingBundle_0100
2395  * @tc.name: test CheckInternaltestingBundle
2396  * @tc.desc: 1.test check Internaltesting bundle
2397  */
2398 HWTEST_F(BmsBundleInstallCheckerTest, CheckInternaltestingBundle_0100, Function | SmallTest | Level0)
2399 {
2400     BundleInstallChecker installChecker;
2401     Security::Verify::HapVerifyResult result;
2402     Security::Verify::ProvisionInfo provisionInfo;
2403     provisionInfo.type = Security::Verify::ProvisionType::DEBUG;
2404     provisionInfo.distributionType = Security::Verify::AppDistType::INTERNALTESTING;
2405     result.SetProvisionInfo(provisionInfo);
2406     bool ret = installChecker.CheckInternaltestingBundle(result);
2407     EXPECT_EQ(ret, true);
2408 }
2409 
2410 /**
2411  * @tc.number: ParseBundleInfo_0100
2412  * @tc.name: test ParseBundleInfo
2413  * @tc.desc: 1.test parse bundle info
2414  */
2415 HWTEST_F(BmsBundleInstallCheckerTest, ParseBundleInfo_0100, Function | SmallTest | Level0)
2416 {
2417     BundleInstallChecker installChecker;
2418     std::string bundlePath = "";
2419     InnerBundleInfo info;
2420     BundlePackInfo packInfo;
2421     bool ret = installChecker.ParseBundleInfo(bundlePath, info, packInfo);
2422     EXPECT_NE(ret, ERR_OK);
2423 }
2424 
2425 /**
2426  * @tc.number: FindModuleInInstallingPackage_0100
2427  * @tc.name: test FindModuleInInstallingPackage
2428  * @tc.desc: 1.test find module in installing package
2429  */
2430 HWTEST_F(BmsBundleInstallCheckerTest, FindModuleInInstallingPackage_0100, Function | SmallTest | Level0)
2431 {
2432     BundleInstallChecker installChecker;
2433     std::unordered_map<std::string, InnerBundleInfo> infos;
2434     std::string moduleName = MODULE_PACKAGE;
2435     std::string bundleName = BUNDLE_NAME;
2436     bool ret = installChecker.FindModuleInInstallingPackage(moduleName, bundleName, infos);
2437     EXPECT_EQ(ret, false);
2438 
2439     std::map<std::string, InnerModuleInfo> innerModuleInfos;
2440     InnerBundleInfo innerBundleInfo;
2441     InnerModuleInfo innerModuleInfo;
2442     ProxyData data;
2443     data.uri = MODULE_PATH;
2444     innerModuleInfo.moduleName = MODULE_PACKAGE;
2445     innerModuleInfo.proxyDatas.emplace_back(data);
2446     innerModuleInfos.try_emplace(HAP, innerModuleInfo);
2447     innerBundleInfo.innerModuleInfos_ = innerModuleInfos;
2448     infos.emplace(HAP, innerBundleInfo);
2449     ret = installChecker.FindModuleInInstallingPackage(moduleName, bundleName, infos);
2450     EXPECT_EQ(ret, false);
2451 }
2452 } // OHOS
2453