1 /*
2  * Copyright (C) 2023 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 #include "app_domain_verify_rdb_data_manager.h"
17 #include "gtest/gtest.h"
18 #include <memory>
19 #include <string>
20 #define private public
21 #define protected public
22 #include "app_domain_verify_data_mgr.h"
23 #include "app_domain_verify_mgr_service.h"
24 #include "app_domain_verify_agent_client.h"
25 #undef private
26 #undef protected
27 #include "mock_verify_agent.h"
28 #include "mock_constant.h"
29 #include "mock_verify_mgr.h"
30 #include "mock_access_token.h"
31 #include "app_domain_verify_mgr_interface_code.h"
32 #include "rdb_helper.h"
33 #include "app_domain_verify_mgr_service_proxy.h"
34 #include "app_domain_verify_mgr_interface_code.h"
35 #include "system_ability_definition.h"
36 #include "app_domain_verify_parcel_util.h"
37 #include "mock_convert_callback.h"
38 
39 namespace OHOS::AppDomainVerify {
40 using namespace testing;
41 using namespace testing::ext;
42 std::shared_ptr<AppDomainVerifyMgrService> appDomainVerifyMgrService = std::make_shared<AppDomainVerifyMgrService>();
43 auto appDomainVerifyAgentStubMock_ = std::make_shared<AppDomainVerifyAgentRemoteStubMock>();
44 class MgrServiceTest : public testing::Test {
45 public:
46     static void SetUpTestCase(void);
47     static void TearDownTestCase(void);
48     void SetUp();
49     void TearDown();
50 };
51 
InvokeSingleVerifyOK(uint32_t code,MessageParcel & data,MessageParcel & reply,MessageOption & option)52 int InvokeSingleVerifyOK(uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption& option)
53 {
54     APP_DOMAIN_VERIFY_HILOGD(APP_DOMAIN_VERIFY_MODULE_BUTT, "call end");
55     std::string bundleName = BUNDLE_NAME;
56     VerifyResultInfo verifyResultInfo;
57     verifyResultInfo.hostVerifyStatusMap.insert_or_assign(
58         "https://" + HOST, std::make_tuple(InnerVerifyStatus::STATE_SUCCESS, std::string(), 0));
59     appDomainVerifyMgrService->SaveDomainVerifyStatus(bundleName, verifyResultInfo);
60     return 0;
61 }
62 
InvokeSingleVerifyFail(uint32_t code,MessageParcel & data,MessageParcel & reply,MessageOption & option)63 int InvokeSingleVerifyFail(uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption& option)
64 {
65     APP_DOMAIN_VERIFY_HILOGD(APP_DOMAIN_VERIFY_MODULE_BUTT, "call end");
66     std::string bundleName = BUNDLE_NAME;
67     VerifyResultInfo verifyResultInfo;
68     verifyResultInfo.hostVerifyStatusMap.insert_or_assign(
69         "https://" + HOST, std::make_tuple(InnerVerifyStatus::STATE_FAIL, std::string(), 0));
70     appDomainVerifyMgrService->SaveDomainVerifyStatus(bundleName, verifyResultInfo);
71     return UNKNOWN_ERROR;
72 }
SetUpTestCase(void)73 void MgrServiceTest::SetUpTestCase(void)
74 {
75     printf("SetUpTestCase \n");
76 }
77 
TearDownTestCase(void)78 void MgrServiceTest::TearDownTestCase(void)
79 {
80     printf("TearDownTestCase  1\n");
81     AppDomainVerifyAgentClient::agentServiceProxy_.ForceSetRefPtr(nullptr);
82     printf("TearDownTestCase 2\n");
83     AppDomainVerifyAgentClient::DestroyInstance();
84     printf("TearDownTestCase 3\n");
85     appDomainVerifyMgrService->Stop();
86     appDomainVerifyAgentStubMock_.reset();
87     printf("TearDownTestCase \n");
88 }
89 
SetUp(void)90 void MgrServiceTest::SetUp(void)
91 {
92     MockAccessToken::mockSA();
93     AppDomainVerifyAgentClient::staticDestoryMonitor_.destoryed_ = true;
94     printf("SetUp \n");
95 }
96 
TearDown(void)97 void MgrServiceTest::TearDown(void)
98 {
99     printf("TearDown \n");
100 }
101 
102 /**
103  * @tc.name: MgrServiceVerifyDomainTest001
104  * @tc.desc: verify domain ok
105  * @tc.type: FUNC
106  */
107 HWTEST_F(MgrServiceTest, MgrServiceVerifyDomainTest001, TestSize.Level0)
108 {
109     EXPECT_CALL(*appDomainVerifyAgentStubMock_, SendRequest(_, _, _, _))
110         .Times(AtLeast(1))
111         .WillRepeatedly(::testing::Invoke(InvokeSingleVerifyOK));
112     AppDomainVerifyAgentClient::agentServiceProxy_ = sptr<AppDomainVerifyAgentServiceProxy>::MakeSptr(
113         appDomainVerifyAgentStubMock_.get());
114 
115     std::string appIdentifier = "appIdentifier";
116     std::string bundleName = "bundleName";
117     std::string fingerprint = "fingerprint";
118 
119     std::vector<SkillUri> skillUris;
120     SkillUri skillUri;
121     skillUris.push_back(skillUri);
122     MessageParcel data;
123     MessageParcel reply;
124     MessageOption option;
125     WRITE_PARCEL_AND_RETURN_IF_FAIL(InterfaceToken, data, AppDomainVerifyMgrServiceProxy::GetDescriptor());
126     WRITE_PARCEL_AND_RETURN_IF_FAIL(String, data, appIdentifier);
127     WRITE_PARCEL_AND_RETURN_IF_FAIL(String, data, bundleName);
128     WRITE_PARCEL_AND_RETURN_IF_FAIL(String, data, fingerprint);
129 
130     uint32_t size = static_cast<uint32_t>(skillUris.size());
131     WRITE_PARCEL_AND_RETURN_IF_FAIL(Uint32, data, size);
132 
133     for (uint32_t i = 0; i < skillUris.size(); ++i) {
134         WRITE_PARCEL_AND_RETURN_IF_FAIL(Parcelable, data, &skillUris[i]);
135     }
136     int32_t error = appDomainVerifyMgrService->OnRemoteRequest(
137         AppDomainVerifyMgrInterfaceCode::VERIFY_DOMAIN, data, reply, option);
138     ASSERT_TRUE(error == ERR_OK);
139 }
140 
141 /**
142  * @tc.name: MgrServiceVerifyDomainTest002
143  * @tc.desc: verify domain wrong with interface token
144  * @tc.type: FUNC
145  */
146 HWTEST_F(MgrServiceTest, MgrServiceVerifyDomainTest002, TestSize.Level0)
147 {
148     std::string appIdentifier = "appIdentifier";
149     std::string bundleName = "bundleName";
150     std::string fingerprint = "fingerprint";
151 
152     std::vector<SkillUri> skillUris;
153     SkillUri skillUri;
154     skillUris.push_back(skillUri);
155     MessageParcel data;
156     MessageParcel reply;
157     MessageOption option;
158     WRITE_PARCEL_AND_RETURN_IF_FAIL(InterfaceToken, data, std::u16string(u"abc"));
159     WRITE_PARCEL_AND_RETURN_IF_FAIL(String, data, appIdentifier);
160     WRITE_PARCEL_AND_RETURN_IF_FAIL(String, data, bundleName);
161     WRITE_PARCEL_AND_RETURN_IF_FAIL(String, data, fingerprint);
162 
163     uint32_t size = static_cast<uint32_t>(skillUris.size());
164     WRITE_PARCEL_AND_RETURN_IF_FAIL(Uint32, data, size);
165 
166     int32_t error = appDomainVerifyMgrService->OnRemoteRequest(
167         AppDomainVerifyMgrInterfaceCode::VERIFY_DOMAIN, data, reply, option);
168     ASSERT_TRUE(error != ERR_OK);
169 }
170 
171 /**
172  * @tc.name: MgrServiceVerifyDomainTest003
173  * @tc.desc: OnRemoteRequest with wrong opconde
174  * @tc.type: FUNC
175  */
176 HWTEST_F(MgrServiceTest, MgrServiceVerifyDomainTest003, TestSize.Level0)
177 {
178     auto appDomainVerifyMgrStubMock = std::make_shared<AppDomainVerifyMgrStubMock>();
179     std::string appIdentifier = "appIdentifier";
180     std::string bundleName = "bundleName";
181     std::string fingerprint = "fingerprint";
182 
183     std::vector<SkillUri> skillUris;
184     SkillUri skillUri;
185     skillUris.push_back(skillUri);
186     MessageParcel data;
187     MessageParcel reply;
188     MessageOption option;
189     WRITE_PARCEL_AND_RETURN_IF_FAIL(InterfaceToken, data, AppDomainVerifyMgrServiceProxy::GetDescriptor());
190     WRITE_PARCEL_AND_RETURN_IF_FAIL(String, data, appIdentifier);
191     WRITE_PARCEL_AND_RETURN_IF_FAIL(String, data, bundleName);
192     WRITE_PARCEL_AND_RETURN_IF_FAIL(String, data, fingerprint);
193 
194     uint32_t size = static_cast<uint32_t>(skillUris.size());
195     WRITE_PARCEL_AND_RETURN_IF_FAIL(Uint32, data, size);
196 
197     int32_t error = appDomainVerifyMgrService->OnRemoteRequest(100, data, reply, option);
198     ASSERT_TRUE(error != ERR_OK);
199 }
200 /**
201  * @tc.name: MgrServiceClearDomainTest001
202  * @tc.desc: clear domain verify result ok
203  * @tc.type: FUNC
204  */
205 HWTEST_F(MgrServiceTest, MgrServiceClearDomainTest001, TestSize.Level0)
206 {
207     auto appDomainVerifyMgrStubMock = std::make_shared<AppDomainVerifyMgrStubMock>();
208     std::string appIdentifier = "appIdentifier";
209     std::string bundleName = "bundleName";
210     std::string fingerprint = "fingerprint";
211     MessageParcel data;
212     MessageParcel reply;
213     MessageOption option;
214     WRITE_PARCEL_AND_RETURN_IF_FAIL(InterfaceToken, data, AppDomainVerifyMgrServiceProxy::GetDescriptor());
215     WRITE_PARCEL_AND_RETURN_IF_FAIL(String, data, appIdentifier);
216     WRITE_PARCEL_AND_RETURN_IF_FAIL(String, data, bundleName);
217     int32_t error = appDomainVerifyMgrService->OnRemoteRequest(
218         AppDomainVerifyMgrInterfaceCode::CLEAR_DOMAIN_VERIFY_RESULT, data, reply, option);
219     ASSERT_TRUE(error == ERR_OK);
220 }
221 
222 /**
223  * @tc.name: MgrServiceFilterDomainTest001
224  * @tc.desc: filter abilities ok
225  * @tc.type: FUNC
226  */
227 HWTEST_F(MgrServiceTest, MgrServiceFilterDomainTest001, TestSize.Level0)
228 {
229     auto appDomainVerifyMgrStubMock = std::make_shared<AppDomainVerifyMgrStubMock>();
230     OHOS::AAFwk::Want want;
231     std::vector<OHOS::AppExecFwk::AbilityInfo> originAbilityInfos;
232     OHOS::AppExecFwk::AbilityInfo abilityInfo;
233     originAbilityInfos.push_back(abilityInfo);
234     std::vector<OHOS::AppExecFwk::AbilityInfo> filtedAbilityInfos;
235     MessageParcel data;
236     MessageParcel reply;
237     MessageOption option;
238     WRITE_PARCEL_AND_RETURN_IF_FAIL(InterfaceToken, data, AppDomainVerifyMgrServiceProxy::GetDescriptor());
239     WRITE_PARCEL_AND_RETURN_IF_FAIL(Parcelable, data, &want);
240     uint32_t originAbilityInfoSize = static_cast<uint32_t>(originAbilityInfos.size());
241     WRITE_PARCEL_AND_RETURN_IF_FAIL(Uint32, data, originAbilityInfoSize);
242 
243     for (uint32_t i = 0; i < originAbilityInfos.size(); ++i) {
244         WRITE_PARCEL_AND_RETURN_IF_FAIL(Parcelable, data, &originAbilityInfos[i]);
245     }
246     int32_t error = appDomainVerifyMgrService->OnRemoteRequest(
247         AppDomainVerifyMgrInterfaceCode::FILTER_ABILITIES, data, reply, option);
248     ASSERT_TRUE(error == ERR_OK);
249 }
250 
251 /**
252  * @tc.name: MgrServiceFilterDomainTest002
253  * @tc.desc: filter abilities with wrong originAbility array
254  * @tc.type: FUNC
255  */
256 HWTEST_F(MgrServiceTest, MgrServiceFilterDomainTest002, TestSize.Level0)
257 {
258     auto appDomainVerifyMgrStubMock = std::make_shared<AppDomainVerifyMgrStubMock>();
259     OHOS::AAFwk::Want want;
260     OHOS::AppExecFwk::ElementName element;
261     element.SetBundleName(BUNDLE_NAME);
262     element.SetAbilityName("a");
263     want.SetElement(element);
264     std::vector<OHOS::AppExecFwk::AbilityInfo> originAbilityInfos;
265     OHOS::AppExecFwk::AbilityInfo abilityInfo;
266     originAbilityInfos.push_back(abilityInfo);
267     std::vector<OHOS::AppExecFwk::AbilityInfo> filtedAbilityInfos;
268     MessageParcel data;
269     MessageParcel reply;
270     MessageOption option;
271     WRITE_PARCEL_AND_RETURN_IF_FAIL(InterfaceToken, data, AppDomainVerifyMgrServiceProxy::GetDescriptor());
272     WRITE_PARCEL_AND_RETURN_IF_FAIL(Parcelable, data, &want);
273     uint32_t originAbilityInfoSize = static_cast<uint32_t>(originAbilityInfos.size());
274     WRITE_PARCEL_AND_RETURN_IF_FAIL(Uint32, data, originAbilityInfoSize);
275     int32_t error = appDomainVerifyMgrService->OnRemoteRequest(
276         AppDomainVerifyMgrInterfaceCode::FILTER_ABILITIES, data, reply, option);
277     ASSERT_TRUE(error != ERR_OK);
278 }
279 
280 /**
281  * @tc.name: MgrServiceFilterDomainTest003
282  * @tc.desc: filter abilities with wrong originAbility size
283  * @tc.type: FUNC
284  */
285 HWTEST_F(MgrServiceTest, MgrServiceFilterDomainTest003, TestSize.Level0)
286 {
287     auto appDomainVerifyMgrStubMock = std::make_shared<AppDomainVerifyMgrStubMock>();
288     OHOS::AAFwk::Want want;
289     want.SetUri("https://www.baidu.com");
290 
291     std::vector<OHOS::AppExecFwk::AbilityInfo> originAbilityInfos;
292     OHOS::AppExecFwk::AbilityInfo abilityInfo;
293     originAbilityInfos.push_back(abilityInfo);
294     std::vector<OHOS::AppExecFwk::AbilityInfo> filtedAbilityInfos;
295     MessageParcel data;
296     MessageParcel reply;
297     MessageOption option;
298     WRITE_PARCEL_AND_RETURN_IF_FAIL(InterfaceToken, data, AppDomainVerifyMgrServiceProxy::GetDescriptor());
299     WRITE_PARCEL_AND_RETURN_IF_FAIL(Parcelable, data, &want);
300     uint32_t originAbilityInfoSize = static_cast<uint32_t>(originAbilityInfos.size());
301     WRITE_PARCEL_AND_RETURN_IF_FAIL(Uint32, data, originAbilityInfoSize);
302 
303     for (uint32_t i = 0; i < originAbilityInfos.size(); ++i) {
304         WRITE_PARCEL_AND_RETURN_IF_FAIL(Parcelable, data, &originAbilityInfos[i]);
305     }
306     int32_t error = appDomainVerifyMgrService->OnRemoteRequest(
307         AppDomainVerifyMgrInterfaceCode::FILTER_ABILITIES, data, reply, option);
308     ASSERT_TRUE(error == ERR_OK);
309 }
310 /**
311  * @tc.name: MgrServiceQueryDomainTest001
312  * @tc.desc: query verify status
313  * @tc.type: FUNC
314  */
315 HWTEST_F(MgrServiceTest, MgrServiceQueryDomainTest001, TestSize.Level0)
316 {
317     std::string bundleName = "bundleName";
318     MessageParcel data;
319     MessageParcel reply;
320     MessageOption option;
321     WRITE_PARCEL_AND_RETURN_IF_FAIL(InterfaceToken, data, AppDomainVerifyMgrServiceProxy::GetDescriptor());
322     WRITE_PARCEL_AND_RETURN_IF_FAIL(String, data, bundleName);
323 
324     int32_t error = appDomainVerifyMgrService->OnRemoteRequest(
325         AppDomainVerifyMgrInterfaceCode::QUERY_VERIFY_STATUS, data, reply, option);
326     ASSERT_TRUE(error == ERR_OK);
327 }
328 /**
329  * @tc.name: MgrServiceQueryAllDomainTest001
330  * @tc.desc: query verify status without bundle name
331  * @tc.type: FUNC
332  */
333 HWTEST_F(MgrServiceTest, MgrServiceQueryAllDomainTest001, TestSize.Level0)
334 {
335     MessageParcel data;
336     MessageParcel reply;
337     MessageOption option;
338     WRITE_PARCEL_AND_RETURN_IF_FAIL(InterfaceToken, data, AppDomainVerifyMgrServiceProxy::GetDescriptor());
339 
340     int32_t error = appDomainVerifyMgrService->OnRemoteRequest(
341         AppDomainVerifyMgrInterfaceCode::QUERY_ALL_VERIFY_STATUS, data, reply, option);
342     ASSERT_TRUE(error == ERR_OK);
343 }
344 /**
345  * @tc.name: MgrServiceSaveAllDomainTest001
346  * @tc.desc: save all domain
347  * @tc.type: FUNC
348  */
349 HWTEST_F(MgrServiceTest, MgrServiceSaveAllDomainTest001, TestSize.Level0)
350 {
351     VerifyResultInfo verifyResultInfo;
352     std::string bundleName = "bundleName";
353     MessageParcel data;
354     MessageParcel reply;
355     MessageOption option;
356     WRITE_PARCEL_AND_RETURN_IF_FAIL(InterfaceToken, data, AppDomainVerifyMgrServiceProxy::GetDescriptor());
357     WRITE_PARCEL_AND_RETURN_IF_FAIL(String, data, bundleName);
358     WRITE_PARCEL_AND_RETURN_IF_FAIL(Parcelable, data, &verifyResultInfo);
359 
360     int32_t error = appDomainVerifyMgrService->OnRemoteRequest(
361         AppDomainVerifyMgrInterfaceCode::SAVE_VERIFY_STATUS, data, reply, option);
362     ASSERT_TRUE(error == ERR_OK);
363 }
364 /**
365  * @tc.name: MgrServiceIsAtomicUrlTest001
366  * @tc.desc: is aotmic service url
367  * @tc.type: FUNC
368  */
369 HWTEST_F(MgrServiceTest, MgrServiceIsAtomicUrlTest001, TestSize.Level0)
370 {
371     std::string url = "https://www.openharmony.com";
372     MessageParcel data;
373     MessageParcel reply;
374     MessageOption option;
375     WRITE_PARCEL_AND_RETURN_IF_FAIL(InterfaceToken, data, IAppDomainVerifyMgrService::GetDescriptor());
376     WRITE_PARCEL_AND_RETURN_IF_FAIL(String, data, url);
377 
378     int32_t error = appDomainVerifyMgrService->OnRemoteRequest(
379         AppDomainVerifyMgrInterfaceCode::IS_ATOMIC_SERVICE_URL, data, reply, option);
380     ASSERT_TRUE(error == ERR_OK);
381 }
382 /**
383  * @tc.name: MgrServiceConvertToExplicitWantTest001
384  * @tc.desc: convert to explicit want
385  * @tc.type: FUNC
386  */
387 HWTEST_F(MgrServiceTest, MgrServiceConvertToExplicitWantTest001, TestSize.Level0)
388 {
389     OHOS::AAFwk::Want implicitWant;
390     sptr<MocConvertCallback> callback = new MocConvertCallback;
391     MessageParcel data;
392     MessageParcel reply;
393     MessageOption option;
394     WRITE_PARCEL_AND_RETURN_IF_FAIL(InterfaceToken, data, IAppDomainVerifyMgrService::GetDescriptor());
395     WRITE_PARCEL_AND_RETURN_IF_FAIL(Parcelable, data, &implicitWant);
396     WRITE_PARCEL_AND_RETURN_IF_FAIL(RemoteObject, data, callback->AsObject());
397 
398     int32_t error = appDomainVerifyMgrService->OnRemoteRequest(
399         AppDomainVerifyMgrInterfaceCode::CONVERT_TO_EXPLICIT_WANT, data, reply, option);
400     ASSERT_TRUE(error == ERR_OK);
401 }
402 
403 /**
404  * @tc.name: MgrServiceConvertToExplicitWantTest002
405  * @tc.desc: convert to explicit want with out want
406  * @tc.type: FUNC
407  */
408 HWTEST_F(MgrServiceTest, MgrServiceConvertToExplicitWantTest002, TestSize.Level0)
409 {
410     OHOS::AAFwk::Want implicitWant;
411     sptr<MocConvertCallback> callback = new MocConvertCallback;
412     MessageParcel data;
413     MessageParcel reply;
414     MessageOption option;
415     WRITE_PARCEL_AND_RETURN_IF_FAIL(InterfaceToken, data, IAppDomainVerifyMgrService::GetDescriptor());
416     WRITE_PARCEL_AND_RETURN_IF_FAIL(RemoteObject, data, callback->AsObject());
417 
418     int32_t error = appDomainVerifyMgrService->OnRemoteRequest(
419         AppDomainVerifyMgrInterfaceCode::CONVERT_TO_EXPLICIT_WANT, data, reply, option);
420     ASSERT_TRUE(error != ERR_OK);
421 }
422 /**
423  * @tc.name: MgrServiceConvertToExplicitWantTest003
424  * @tc.desc: convert to explicit want without cb
425  * @tc.type: FUNC
426  */
427 HWTEST_F(MgrServiceTest, MgrServiceConvertToExplicitWantTest003, TestSize.Level0)
428 {
429     OHOS::AAFwk::Want implicitWant;
430     sptr<MocConvertCallback> callback = new MocConvertCallback;
431     MessageParcel data;
432     MessageParcel reply;
433     MessageOption option;
434     WRITE_PARCEL_AND_RETURN_IF_FAIL(InterfaceToken, data, IAppDomainVerifyMgrService::GetDescriptor());
435     WRITE_PARCEL_AND_RETURN_IF_FAIL(Parcelable, data, &implicitWant);
436 
437     int32_t error = appDomainVerifyMgrService->OnRemoteRequest(
438         AppDomainVerifyMgrInterfaceCode::CONVERT_TO_EXPLICIT_WANT, data, reply, option);
439     ASSERT_TRUE(error != ERR_OK);
440 }
441 
442 /**
443  * @tc.name: MgrServiceTest022
444  * @tc.desc: dump null
445  * @tc.type: FUNC
446  */
447 HWTEST_F(MgrServiceTest, MgrServiceTest022, TestSize.Level0)
448 {
449     appDomainVerifyMgrService->OnDump();
450     int fd = 0;
451     std::vector<std::u16string> args;
452     int ret = appDomainVerifyMgrService->Dump(fd, args);
453     ASSERT_TRUE(ret == ERR_OK);
454 }
455 /**
456  * @tc.name: MgrServiceTest023
457  * @tc.desc: dump normal
458  * @tc.type: FUNC
459  */
460 HWTEST_F(MgrServiceTest, MgrServiceTest023, TestSize.Level0)
461 {
462     appDomainVerifyMgrService->OnDump();
463     int fd = 0;
464     std::vector<std::u16string> args;
465     std::unordered_map<std::string, VerifyResultInfo> verifyMap;
466     VerifyResultInfo verifyResultInfo;
467     verifyMap.emplace("com.example", verifyResultInfo);
468     appDomainVerifyMgrService->dataManager_->verifyMap_->swap(verifyMap);
469     int ret = appDomainVerifyMgrService->Dump(fd, args);
470     ASSERT_TRUE(ret == ERR_OK);
471 }
472 /**
473  * @tc.name: MgrServiceTest024
474  * @tc.desc: UpdateWhiteListUrls
475  * @tc.type: FUNC
476  */
477 HWTEST_F(MgrServiceTest, MgrServiceTest024, TestSize.Level0)
478 {
479     ASSERT_TRUE(appDomainVerifyMgrService);
480     std::string url = "https://www.openharmonytest1.com";
481     EXPECT_FALSE(appDomainVerifyMgrService->IsAtomicServiceUrl(url));
482 
483     std::vector<std::string> urls{ url };
484     appDomainVerifyMgrService->UpdateWhiteListUrls(urls);
485     EXPECT_TRUE(appDomainVerifyMgrService->IsAtomicServiceUrl(url));
486 }
487 
488 /**
489  * @tc.name: MgrServiceTest025
490  * @tc.desc: UpdateWhiteListUrls
491  * @tc.type: FUNC
492  */
493 HWTEST_F(MgrServiceTest, MgrServiceTest025, TestSize.Level0)
494 {
495     ASSERT_TRUE(appDomainVerifyMgrService);
496     std::string url2 = "https://www.openharmonytest2.com";
497     std::string url3 = "https://www.openharmonytest2.com";
498     EXPECT_FALSE(appDomainVerifyMgrService->IsAtomicServiceUrl(url2));
499     EXPECT_FALSE(appDomainVerifyMgrService->IsAtomicServiceUrl(url3));
500 
501     std::vector<std::string> urls{ url2, url3};
502     appDomainVerifyMgrService->UpdateWhiteListUrls(urls);
503     EXPECT_TRUE(appDomainVerifyMgrService->IsAtomicServiceUrl(url3));
504 }
505 
506 /**
507  * @tc.name: MgrServiceTest026
508  * @tc.desc: UpdateWhiteListUrls
509  * @tc.type: FUNC
510  */
511 HWTEST_F(MgrServiceTest, MgrServiceTest026, TestSize.Level0)
512 {
513     ASSERT_TRUE(appDomainVerifyMgrService);
514     std::string getDumpString{ " " };
515     appDomainVerifyMgrService->DumpAllVerifyInfos(getDumpString);
516     EXPECT_FALSE(getDumpString.empty());
517 }
518 
519 /**
520  * @tc.name: MgrServiceTest027
521  * @tc.desc: IsWantImplicit
522  * @tc.type: FUNC
523  */
524 HWTEST_F(MgrServiceTest, MgrServiceTest027, TestSize.Level0)
525 {
526     ASSERT_TRUE(appDomainVerifyMgrService);
527     AAFwk::Want want;
528     EXPECT_TRUE(appDomainVerifyMgrService->IsWantImplicit(want));
529 }
530 
531 /**
532  * @tc.name: MgrServiceTest028
533  * @tc.desc: IsWantImplicit
534  * @tc.type: FUNC
535  */
536 HWTEST_F(MgrServiceTest, MgrServiceTest028, TestSize.Level0)
537 {
538     ASSERT_TRUE(appDomainVerifyMgrService);
539     AAFwk::Want want;
540     AppExecFwk::ElementName element("10", "bundleName", "abilityName", "moduleName");
541     want.SetElement(element);
542     EXPECT_FALSE(appDomainVerifyMgrService->IsWantImplicit(want));
543 }
544 
545 /**
546  * @tc.name: MgrServiceTest029
547  * @tc.desc: QueryDomainVerifyStatus
548  * @tc.type: FUNC
549  */
550 HWTEST_F(MgrServiceTest, MgrServiceTest029, TestSize.Level0)
551 {
552     ASSERT_TRUE(appDomainVerifyMgrService);
553     ASSERT_TRUE(appDomainVerifyMgrService->dataManager_);
554     std::string bundleName{ "MgrServiceTest029" };
555     VerifyResultInfo verifyResultInfo;
556     verifyResultInfo.hostVerifyStatusMap.emplace(
557         bundleName, std::make_tuple(InnerVerifyStatus::STATE_SUCCESS, std::string(), 0));
558     verifyResultInfo.hostVerifyStatusMap.emplace(
559         "test", std::make_tuple(InnerVerifyStatus::STATE_SUCCESS, std::string(), 0));
560     appDomainVerifyMgrService->dataManager_->SaveVerifyStatus(bundleName, verifyResultInfo);
561 
562     DomainVerifyStatus domainVerificationState = DomainVerifyStatus::STATE_NONE;
563     EXPECT_TRUE(appDomainVerifyMgrService->QueryDomainVerifyStatus(bundleName, domainVerificationState));
564     EXPECT_TRUE(domainVerificationState == DomainVerifyStatus::STATE_VERIFIED);
565 }
566 
567 /**
568  * @tc.name: MgrServiceTest030
569  * @tc.desc: QueryDomainVerifyStatus
570  * @tc.type: FUNC
571  */
572 HWTEST_F(MgrServiceTest, MgrServiceTest030, TestSize.Level0)
573 {
574     ASSERT_TRUE(appDomainVerifyMgrService);
575     ASSERT_TRUE(appDomainVerifyMgrService->dataManager_);
576     std::string bundleName{ "MgrServiceTest030" };
577     VerifyResultInfo verifyResultInfo;
578     verifyResultInfo.hostVerifyStatusMap.emplace(
579         bundleName, std::make_tuple(InnerVerifyStatus::UNKNOWN, std::string(), 0));
580     appDomainVerifyMgrService->dataManager_->SaveVerifyStatus(bundleName, verifyResultInfo);
581     DomainVerifyStatus domainVerificationState = DomainVerifyStatus::STATE_NONE;
582     EXPECT_TRUE(appDomainVerifyMgrService->QueryDomainVerifyStatus(bundleName, domainVerificationState));
583     EXPECT_TRUE(domainVerificationState != DomainVerifyStatus::STATE_VERIFIED);
584 }
585 
586 /**
587  * @tc.name: MgrServiceTest031
588  * @tc.desc: QueryDomainVerifyStatus
589  * @tc.type: FUNC
590  */
591 HWTEST_F(MgrServiceTest, MgrServiceTest031, TestSize.Level0)
592 {
593     ASSERT_TRUE(appDomainVerifyMgrService);
594     ASSERT_TRUE(appDomainVerifyMgrService->dataManager_);
595     std::string bundleName{ "MgrServiceTest031" };
596     VerifyResultInfo verifyResultInfo;
597     appDomainVerifyMgrService->dataManager_->SaveVerifyStatus(bundleName, verifyResultInfo);
598 
599     DomainVerifyStatus domainVerificationState = DomainVerifyStatus::STATE_NONE;
600     EXPECT_TRUE(appDomainVerifyMgrService->QueryDomainVerifyStatus(bundleName, domainVerificationState));
601     EXPECT_TRUE(domainVerificationState == DomainVerifyStatus::STATE_NONE);
602 }
603 
604 /**
605  * @tc.name: MgrServiceTest032
606  * @tc.desc: QueryAllDomainVerifyStatus
607  * @tc.type: FUNC
608  */
609 HWTEST_F(MgrServiceTest, MgrServiceTest032, TestSize.Level0)
610 {
611     ASSERT_TRUE(appDomainVerifyMgrService);
612     ASSERT_TRUE(appDomainVerifyMgrService->dataManager_);
613     std::string bundleName{ "MgrServiceTest031" };
614     VerifyResultInfo verifyResultInfo;
615     verifyResultInfo.hostVerifyStatusMap.emplace(
616         bundleName, std::make_tuple(InnerVerifyStatus::STATE_FAIL, std::string(), 0));
617     appDomainVerifyMgrService->dataManager_->SaveVerifyStatus(bundleName, verifyResultInfo);
618 
619     BundleVerifyStatusInfo bundleVerificationState;
620     EXPECT_TRUE(appDomainVerifyMgrService->QueryAllDomainVerifyStatus(bundleVerificationState));
621     EXPECT_TRUE(bundleVerificationState.bundleVerifyStatusInfoMap_.size() != 0);
622 }
623 
624 /**
625  * @tc.name: MgrServiceTest033
626  * @tc.desc: SaveDomainVerifyStatus
627  * @tc.type: FUNC
628  */
629 HWTEST_F(MgrServiceTest, MgrServiceTest033, TestSize.Level0)
630 {
631     ASSERT_TRUE(appDomainVerifyMgrService);
632     ASSERT_TRUE(appDomainVerifyMgrService->dataManager_);
633     std::string bundleName{ "MgrServiceTest033" };
634     VerifyResultInfo verifyResultInfo;
635     verifyResultInfo.hostVerifyStatusMap.emplace(
636         bundleName, std::make_tuple(InnerVerifyStatus::STATE_FAIL, std::string(), 0));
637     EXPECT_TRUE(appDomainVerifyMgrService->SaveDomainVerifyStatus(bundleName, verifyResultInfo));
638     VerifyResultInfo getVerifyResultInfo;
639     auto dataMgr = appDomainVerifyMgrService->dataManager_;
640     EXPECT_TRUE(dataMgr->GetVerifyStatus(bundleName, getVerifyResultInfo));
641 }
642 
643 /**
644  * @tc.name: MgrServiceTest034
645  * @tc.desc: SaveDomainVerifyStatus
646  * @tc.type: FUNC
647  */
648 HWTEST_F(MgrServiceTest, MgrServiceTest034, TestSize.Level0)
649 {
650     ASSERT_TRUE(appDomainVerifyMgrService);
651     ASSERT_TRUE(appDomainVerifyMgrService->dataManager_);
652     std::string bundleName{ "" };
653     VerifyResultInfo verifyResultInfo;
654     verifyResultInfo.hostVerifyStatusMap.emplace(
655         bundleName, std::make_tuple(InnerVerifyStatus::STATE_FAIL, std::string(), 0));
656     EXPECT_FALSE(appDomainVerifyMgrService->SaveDomainVerifyStatus(bundleName, verifyResultInfo));
657 }
658 }