• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022-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 "UTTest_auth_message_processor.h"
17 
18 #include "dm_log.h"
19 #include "dm_constants.h"
20 #include "auth_message_processor.h"
21 #include "softbus_connector.h"
22 #include "softbus_session.h"
23 #include "dm_auth_manager.h"
24 #include "device_manager_service_listener.h"
25 
26 namespace OHOS {
27 namespace DistributedHardware {
28 constexpr const char* TAG_APP_THUMBNAIL = "APPTHUM";
29 
SetUp()30 void AuthMessageProcessorTest::SetUp()
31 {
32 }
TearDown()33 void AuthMessageProcessorTest::TearDown()
34 {
35 }
SetUpTestCase()36 void AuthMessageProcessorTest::SetUpTestCase()
37 {
38 }
TearDownTestCase()39 void AuthMessageProcessorTest::TearDownTestCase()
40 {
41 }
42 
43 namespace {
44 std::shared_ptr<SoftbusConnector> softbusConnector = std::make_shared<SoftbusConnector>();
45 std::shared_ptr<DeviceManagerServiceListener> listener = std::make_shared<DeviceManagerServiceListener>();
46 std::shared_ptr<HiChainConnector> hiChainConnector_ = std::make_shared<HiChainConnector>();
47 /**
48  * @tc.name: AuthMessageProcessor::AuthMessageProcessor_001
49  * @tc.desc: 1 set cryptoAdapter_ to null
50  *           2 call AuthMessageProcessor::AuthMessageProcessor_001 with cryptoAdapter_ = nullptr
51  *           3 check ret is authMessageProcessor->CreateNegotiateMessage(jsonObj);
52  * @tc.type: FUNC
53  * @tc.require: AR000GHSJK
54  */
55 HWTEST_F(AuthMessageProcessorTest, AuthMessageProcessor_001, testing::ext::TestSize.Level0)
56 {
57     std::shared_ptr<DmAuthManager> Test =
58         std::make_shared<DmAuthManager>(softbusConnector, listener, hiChainConnector_);
59     ASSERT_NE(Test, nullptr);
60 }
61 
62 /**
63  * @tc.name: AuthMessageProcessor::AuthMessageProcessor_001
64  * @tc.desc: 1 set cryptoAdapter_ to null
65  *           2 call AuthMessageProcessor::AuthMessageProcessor_001 with cryptoAdapter_ = nullptr
66  *           3 check ret is authMessageProcessor->CreateNegotiateMessage(jsonObj);
67  * @tc.type: FUNC
68  * @tc.require: AR000GHSJK
69  */
70 HWTEST_F(AuthMessageProcessorTest, AuthMessageProcessor_002, testing::ext::TestSize.Level0)
71 {
72     std::shared_ptr<DmAuthManager> Test =
73         std::make_shared<DmAuthManager>(softbusConnector, listener, hiChainConnector_);
74     Test.reset();
75     EXPECT_EQ(Test, nullptr);
76 }
77 
78 /**
79  * @tc.name: AuthMessageProcessor::CreateNegotiateMessage_001
80  * @tc.desc: 1 set cryptoAdapter_ to null
81  *           2 call AuthMessageProcessor::CreateNegotiateMessage_001 with cryptoAdapter_ = nullptr
82  *           3 check ret is authMessageProcessor->CreateNegotiateMessage(jsonObj);
83  * @tc.type: FUNC
84  * @tc.require: AR000GHSJK
85  */
86 HWTEST_F(AuthMessageProcessorTest, CreateNegotiateMessage_001, testing::ext::TestSize.Level0)
87 {
88     std::shared_ptr<DmAuthManager> data =
89         std::make_shared<DmAuthManager>(softbusConnector, listener, hiChainConnector_);
90     std::shared_ptr<AuthMessageProcessor> authMessageProcessor = std::make_shared<AuthMessageProcessor>(data);
91     std::shared_ptr<DmAuthResponseContext> authResponseContext = std::make_shared<DmAuthResponseContext>();
92     authMessageProcessor->authResponseContext_ = std::make_shared<DmAuthResponseContext>();
93     int32_t msgType = MSG_TYPE_NEGOTIATE;
94     nlohmann::json jsonObj;
95     jsonObj[TAG_VER] = DM_ITF_VER;
96     jsonObj[TAG_MSG_TYPE] = msgType;
97     jsonObj[TAG_AUTH_TYPE] = authMessageProcessor->authResponseContext_->authType;
98     authMessageProcessor->SetResponseContext(authResponseContext);
99     authMessageProcessor->cryptoAdapter_ = nullptr;
100     authMessageProcessor->CreateNegotiateMessage(jsonObj);
101     std::string str1 = jsonObj.dump();
102 
103     nlohmann::json jsonObject;
104     jsonObject[TAG_VER] = DM_ITF_VER;
105     jsonObject[TAG_MSG_TYPE] = msgType;
106     jsonObject[TAG_CRYPTO_SUPPORT] = false;
107     jsonObject[TAG_AUTH_TYPE] = authMessageProcessor->authResponseContext_->authType;
108     jsonObject[TAG_REPLY] = authMessageProcessor->authResponseContext_->reply;
109     jsonObject[TAG_LOCAL_DEVICE_ID] = authMessageProcessor->authResponseContext_->localDeviceId;
110     std::string str2 = jsonObject.dump();
111     ASSERT_EQ(str1, str2);
112 }
113 
114 /**
115  * @tc.name: AuthMessageProcessor::CreateSyncGroupMessage_001
116  * @tc.desc: Compare JSON before and after assignment
117  * @tc.type: FUNC
118  * @tc.require: AR000GHSJK
119  */
120 HWTEST_F(AuthMessageProcessorTest, CreateSyncGroupMessage_001, testing::ext::TestSize.Level0)
121 {
122     std::shared_ptr<HiChainConnector> hiChainConnector_ = std::make_shared<HiChainConnector>();
123     std::shared_ptr<DmAuthManager> data =
124         std::make_shared<DmAuthManager>(softbusConnector, listener, hiChainConnector_);
125     std::shared_ptr<AuthMessageProcessor> authMessageProcessor = std::make_shared<AuthMessageProcessor>(data);
126     authMessageProcessor->authRequestContext_ = std::make_shared<DmAuthRequestContext>();
127     nlohmann::json jsona;
128     nlohmann::json jsonObj;
129     authMessageProcessor->authRequestContext_->deviceId = "132416546";
130     std::vector<std::string> syncGroupList;
131     syncGroupList.push_back("1111");
132     authMessageProcessor->authRequestContext_->syncGroupList = syncGroupList;
133     jsona[TAG_DEVICE_ID] = authMessageProcessor->authRequestContext_->deviceId;
134     jsona[TAG_GROUPIDS] = authMessageProcessor->authRequestContext_->syncGroupList;
135     authMessageProcessor->CreateSyncGroupMessage(jsonObj);
136     std::string str1 = jsona.dump();
137     std::string str2 = jsonObj.dump();
138     ASSERT_EQ(str1, str2);
139 }
140 
141 /**
142  * @tc.name: AuthMessageProcessor::CreateResponseAuthMessage_001
143  * @tc.desc: Compare JSON before and after assignment
144  * @tc.type: FUNC
145  * @tc.require: AR000GHSJK
146  */
147 HWTEST_F(AuthMessageProcessorTest, CreateResponseAuthMessage_001, testing::ext::TestSize.Level0)
148 {
149     std::shared_ptr<HiChainConnector> hiChainConnector_ = std::make_shared<HiChainConnector>();
150     std::shared_ptr<DmAuthManager> data =
151         std::make_shared<DmAuthManager>(softbusConnector, listener, hiChainConnector_);
152     std::shared_ptr<AuthMessageProcessor> authMessageProcessor = std::make_shared<AuthMessageProcessor>(data);
153     authMessageProcessor->authResponseContext_ = std::make_shared<DmAuthResponseContext>();
154     nlohmann::json jsona;
155     nlohmann::json jsonObj;
156     authMessageProcessor->authResponseContext_->reply = 0;
157     authMessageProcessor->authResponseContext_->deviceId = "132416546";
158     authMessageProcessor->authResponseContext_->token = "11";
159     nlohmann::json jsonb;
160     jsonb[TAG_GROUP_ID] = "123456";
161     authMessageProcessor->authResponseContext_->groupId = jsonb.dump();
162     authMessageProcessor->authResponseContext_->authToken = "123456";
163     authMessageProcessor->authResponseContext_->networkId = "11112222";
164     authMessageProcessor->authResponseContext_->requestId = 222222;
165     authMessageProcessor->authResponseContext_->groupName = "333333";
166     jsona[TAG_TOKEN] = authMessageProcessor->authResponseContext_->token;
167     jsona[TAG_REPLY] = authMessageProcessor->authResponseContext_->reply;
168     jsona[TAG_DEVICE_ID] = authMessageProcessor->authResponseContext_->deviceId;
169     jsona[TAG_AUTH_TOKEN] = authMessageProcessor->authResponseContext_->authToken;
170     jsona[TAG_NET_ID] = authMessageProcessor->authResponseContext_->networkId;
171     jsona[TAG_REQUEST_ID] = authMessageProcessor->authResponseContext_->requestId;
172     jsona[TAG_GROUP_ID] = "123456";
173     jsona[TAG_GROUP_NAME] = authMessageProcessor->authResponseContext_->groupName;
174     authMessageProcessor->CreateResponseAuthMessage(jsonObj);
175     std::string str1 = jsona.dump();
176     std::string str2 = jsonObj.dump();
177     ASSERT_EQ(str1, str2);
178 }
179 
180 /**
181  * @tc.name: AuthMessageProcessor::CreateResponseFinishMessage_001
182  * @tc.desc: Compare JSON before and after assignment
183  * @tc.type: FUNC
184  * @tc.require: AR000GHSJK
185  */
186 HWTEST_F(AuthMessageProcessorTest, CreateResponseFinishMessage_001, testing::ext::TestSize.Level0)
187 {
188     std::shared_ptr<HiChainConnector> hiChainConnector_ = std::make_shared<HiChainConnector>();
189     std::shared_ptr<DmAuthManager> data =
190         std::make_shared<DmAuthManager>(softbusConnector, listener, hiChainConnector_);
191     std::shared_ptr<AuthMessageProcessor> authMessageProcessor = std::make_shared<AuthMessageProcessor>(data);
192     authMessageProcessor->authResponseContext_ = std::make_shared<DmAuthResponseContext>();
193     nlohmann::json jsona;
194     nlohmann::json jsonObj;
195     authMessageProcessor->authResponseContext_->reply = 1;
196     jsona[TAG_REPLY] = authMessageProcessor->authResponseContext_->reply;
197     authMessageProcessor->CreateResponseFinishMessage(jsonObj);
198     std::string str1 = jsona.dump();
199     std::string str2 = jsonObj.dump();
200     ASSERT_EQ(str1, str2);
201 }
202 
203 /**
204  * @tc.name: AuthMessageProcessor::ParseResponseFinishMessage_001
205  * @tc.desc: Compare JSON before and after assignment
206  * @tc.type: FUNC
207  * @tc.require: AR000GHSJK
208  */
209 HWTEST_F(AuthMessageProcessorTest, ParseResponseFinishMessage_001, testing::ext::TestSize.Level0)
210 {
211     std::shared_ptr<HiChainConnector> hiChainConnector_ = std::make_shared<HiChainConnector>();
212     std::shared_ptr<DmAuthManager> data =
213         std::make_shared<DmAuthManager>(softbusConnector, listener, hiChainConnector_);
214     std::shared_ptr<AuthMessageProcessor> authMessageProcessor = std::make_shared<AuthMessageProcessor>(data);
215     std::shared_ptr<DmAuthResponseContext> authResponseContext = std::make_shared<DmAuthResponseContext>();
216     authMessageProcessor->authResponseContext_ = std::make_shared<DmAuthResponseContext>();
217     nlohmann::json jsonObj;
218     authMessageProcessor->authResponseContext_->reply = 1;
219     jsonObj[TAG_REPLY] = authMessageProcessor->authResponseContext_->reply;
220     authMessageProcessor->SetResponseContext(authResponseContext);
221     authMessageProcessor->ParseResponseFinishMessage(jsonObj);
222     ASSERT_EQ(authMessageProcessor->authResponseContext_, authResponseContext);
223 }
224 
225 /**
226  * @tc.name: AuthMessageProcessor::ParseResponseFinishMessage_002
227  * @tc.desc: Compare JSON before and after assignment
228  * @tc.type: FUNC
229  * @tc.require: AR000GHSJK
230  */
231 HWTEST_F(AuthMessageProcessorTest, ParseResponseFinishMessage_002, testing::ext::TestSize.Level0)
232 {
233     std::shared_ptr<HiChainConnector> hiChainConnector_ = std::make_shared<HiChainConnector>();
234     std::shared_ptr<DmAuthManager> data =
235         std::make_shared<DmAuthManager>(softbusConnector, listener, hiChainConnector_);
236     std::shared_ptr<AuthMessageProcessor> authMessageProcessor = std::make_shared<AuthMessageProcessor>(data);
237     authMessageProcessor->authResponseContext_ = std::make_shared<DmAuthResponseContext>();
238     nlohmann::json jsonObj;
239     jsonObj[TAG_REPLY] = 22;
240     authMessageProcessor->ParseResponseFinishMessage(jsonObj);
241     ASSERT_EQ(authMessageProcessor->authResponseContext_->reply, jsonObj[TAG_REPLY]);
242 }
243 
244 /**
245  * @tc.name: AuthMessageProcessor::ParseResponseFinishMessage_003
246  * @tc.desc: Compare JSON before and after assignment
247  * @tc.type: FUNC
248  * @tc.require: AR000GHSJK
249  */
250 HWTEST_F(AuthMessageProcessorTest, ParseResponseFinishMessage_003, testing::ext::TestSize.Level0)
251 {
252     std::shared_ptr<HiChainConnector> hiChainConnector_ = std::make_shared<HiChainConnector>();
253     std::shared_ptr<DmAuthManager> data =
254         std::make_shared<DmAuthManager>(softbusConnector, listener, hiChainConnector_);
255     std::shared_ptr<AuthMessageProcessor> authMessageProcessor = std::make_shared<AuthMessageProcessor>(data);
256     authMessageProcessor->authResponseContext_ = std::make_shared<DmAuthResponseContext>();
257     std::string str = R"(
258     {
259         "REPLY" : "30000000000"
260     }
261     )";
262     nlohmann::json jsonObj = nlohmann::json::parse(str, nullptr, false);
263     authMessageProcessor->ParseResponseFinishMessage(jsonObj);
264     ASSERT_NE(authMessageProcessor->authResponseContext_->reply, jsonObj[TAG_REPLY]);
265 }
266 
267 /**
268  * @tc.name: AuthMessageProcessor::ParseAuthResponseMessage_001
269  * @tc.desc: Compare JSON before and after assi gnment
270  * @tc.type: FUNC
271  * @tc.require: AR000GHSJK
272  */
273 HWTEST_F(AuthMessageProcessorTest, ParseAuthResponseMessage_001, testing::ext::TestSize.Level0)
274 {
275     std::shared_ptr<HiChainConnector> hiChainConnector_ = std::make_shared<HiChainConnector>();
276     std::shared_ptr<DmAuthManager> data =
277         std::make_shared<DmAuthManager>(softbusConnector, listener, hiChainConnector_);
278     std::shared_ptr<AuthMessageProcessor> authMessageProcessor = std::make_shared<AuthMessageProcessor>(data);
279     std::shared_ptr<DmAuthResponseContext> authResponseContext = std::make_shared<DmAuthResponseContext>();
280     nlohmann::json jsona;
281     authResponseContext->reply = 0;
282     authResponseContext->deviceId = "11111";
283     authResponseContext->authToken = "123456";
284     authResponseContext->networkId = "12345";
285     authResponseContext->requestId = 2;
286     authResponseContext->groupId = "23456";
287     authResponseContext->groupName = "34567";
288     authResponseContext->token = "11123";
289     jsona[TAG_TOKEN] = authResponseContext->token;
290     jsona[TAG_REPLY] = authResponseContext->reply;
291     jsona[TAG_DEVICE_ID] = authResponseContext->deviceId;
292     jsona[TAG_AUTH_TOKEN] = authResponseContext->authToken;
293     jsona[TAG_NET_ID] = authResponseContext->networkId;
294     jsona[TAG_REQUEST_ID] = authResponseContext->requestId;
295     jsona[TAG_GROUP_ID] = authResponseContext->groupId;
296     jsona[TAG_GROUP_NAME] = authResponseContext->groupName;
297     authMessageProcessor->SetResponseContext(authResponseContext);
298     authMessageProcessor->ParseAuthResponseMessage(jsona);
299     ASSERT_EQ(authMessageProcessor->authResponseContext_, authResponseContext);
300 }
301 
302 /**
303  * @tc.name: AuthMessageProcessor::ParseAuthRequestMessage_001
304  * @tc.desc: Compare JSON before and after assignment
305  * @tc.type: FUNC
306  * @tc.require: AR000GHSJK
307  */
308 HWTEST_F(AuthMessageProcessorTest, ParseAuthRequestMessage_001, testing::ext::TestSize.Level0)
309 {
310     std::shared_ptr<HiChainConnector> hiChainConnector_ = std::make_shared<HiChainConnector>();
311     std::shared_ptr<DmAuthManager> data =
312         std::make_shared<DmAuthManager>(softbusConnector, listener, hiChainConnector_);
313     std::shared_ptr<AuthMessageProcessor> authMessageProcessor = std::make_shared<AuthMessageProcessor>(data);
314     std::shared_ptr<DmAuthResponseContext> authResponseContext = std::make_shared<DmAuthResponseContext>();
315     authMessageProcessor->SetResponseContext(authResponseContext);
316     nlohmann::json jsonThumbnail;
317     authResponseContext->deviceId = "123";
318     authResponseContext->reply = 0;
319     authResponseContext->authType = 222;
320     authResponseContext->networkId = "234";
321     authResponseContext->groupId = "345";
322     authResponseContext->groupName = "456";
323     authResponseContext->requestId = 2333;
324     jsonThumbnail[TAG_DEVICE_ID] = authResponseContext->deviceId;
325     jsonThumbnail[TAG_REPLY] = authResponseContext->reply;
326     jsonThumbnail[TAG_AUTH_TYPE] = authResponseContext->authType;
327     jsonThumbnail[TAG_NET_ID] = authResponseContext->networkId;
328     jsonThumbnail[TAG_GROUP_ID] = authResponseContext->groupId;
329     jsonThumbnail[TAG_GROUP_NAME] = authResponseContext->groupName;
330     jsonThumbnail[TAG_REQUEST_ID] = authResponseContext->requestId;
331     int32_t ret = authMessageProcessor->ParseAuthRequestMessage(jsonThumbnail);
332     ASSERT_EQ(ret, ERR_DM_FAILED);
333 }
334 
335 /**
336  * @tc.name: AuthMessageProcessor::ParseAuthRequestMessage_002
337  * @tc.desc: Compare JSON before and after assignment
338  * @tc.type: FUNC
339  * @tc.require: AR000GHSJK
340  */
341 HWTEST_F(AuthMessageProcessorTest, ParseAuthRequestMessage_002, testing::ext::TestSize.Level0)
342 {
343     std::shared_ptr<HiChainConnector> hiChainConnector_ = std::make_shared<HiChainConnector>();
344     std::shared_ptr<DmAuthManager> data =
345         std::make_shared<DmAuthManager>(softbusConnector, listener, hiChainConnector_);
346     std::shared_ptr<AuthMessageProcessor> authMessageProcessor = std::make_shared<AuthMessageProcessor>(data);
347     std::shared_ptr<DmAuthResponseContext> authResponseContext = std::make_shared<DmAuthResponseContext>();
348     authMessageProcessor->SetResponseContext(authResponseContext);
349     nlohmann::json jsonThumbnail;
350     jsonThumbnail[TAG_SLICE_NUM] = 1;
351     jsonThumbnail[TAG_INDEX] = 0;
352     jsonThumbnail[TAG_DEVICE_ID] = "123";
353     jsonThumbnail[TAG_AUTH_TYPE] = 1;
354     jsonThumbnail[TAG_CUSTOM_DESCRIPTION] = "123";
355     jsonThumbnail[TAG_TOKEN] = "1234";
356     jsonThumbnail[TAG_TARGET] = "12345";
357     jsonThumbnail[TAG_APP_OPERATION] = "123456";
358     jsonThumbnail[TAG_LOCAL_DEVICE_ID] = "localdeviceTest";
359     jsonThumbnail[TAG_REQUESTER] = "AJ125S25S3E65F1A24T";
360     jsonThumbnail[TAG_DEVICE_TYPE] = 1;
361     int32_t ret = authMessageProcessor->ParseAuthRequestMessage(jsonThumbnail);
362     ASSERT_EQ(ret, DM_OK);
363 }
364 
365 /**
366  * @tc.name: AuthMessageProcessor::ParseAuthRequestMessage_003
367  * @tc.desc: Compare JSON before and after assignment
368  * @tc.type: FUNC
369  * @tc.require: AR000GHSJK
370  */
371 HWTEST_F(AuthMessageProcessorTest, ParseAuthRequestMessage_003, testing::ext::TestSize.Level0)
372 {
373     std::shared_ptr<HiChainConnector> hiChainConnector_ = std::make_shared<HiChainConnector>();
374     std::shared_ptr<DmAuthManager> data =
375         std::make_shared<DmAuthManager>(softbusConnector, listener, hiChainConnector_);
376     std::shared_ptr<AuthMessageProcessor> authMessageProcessor = std::make_shared<AuthMessageProcessor>(data);
377     std::shared_ptr<DmAuthResponseContext> authResponseContext = std::make_shared<DmAuthResponseContext>();
378     authMessageProcessor->SetResponseContext(authResponseContext);
379     nlohmann::json jsonThumbnail;
380     jsonThumbnail[TAG_SLICE_NUM] = 1;
381     jsonThumbnail[TAG_INDEX] = 0;
382     jsonThumbnail[TAG_DEVICE_ID] = 123;
383     jsonThumbnail[TAG_AUTH_TYPE] = 1;
384     jsonThumbnail[TAG_CUSTOM_DESCRIPTION] = "123";
385     jsonThumbnail[TAG_TOKEN] = "1234";
386     jsonThumbnail[TAG_TARGET] = "12345";
387     jsonThumbnail[TAG_APP_OPERATION] = "123456";
388     int32_t ret = authMessageProcessor->ParseAuthRequestMessage(jsonThumbnail);
389     ASSERT_EQ(ret, DM_OK);
390 }
391 
392 /**
393  * @tc.name: AuthMessageProcessor::ParseAuthRequestMessage_004
394  * @tc.desc: Compare JSON before and after assignment
395  * @tc.type: FUNC
396  * @tc.require: AR000GHSJK
397  */
398 HWTEST_F(AuthMessageProcessorTest, ParseAuthRequestMessage_004, testing::ext::TestSize.Level0)
399 {
400     std::shared_ptr<HiChainConnector> hiChainConnector_ = std::make_shared<HiChainConnector>();
401     std::shared_ptr<DmAuthManager> data =
402         std::make_shared<DmAuthManager>(softbusConnector, listener, hiChainConnector_);
403     std::shared_ptr<AuthMessageProcessor> authMessageProcessor = std::make_shared<AuthMessageProcessor>(data);
404     std::shared_ptr<DmAuthResponseContext> authResponseContext = std::make_shared<DmAuthResponseContext>();
405     authMessageProcessor->SetResponseContext(authResponseContext);
406     nlohmann::json jsonThumbnail;
407     jsonThumbnail[TAG_SLICE_NUM] = 1;
408     jsonThumbnail[TAG_INDEX] = 0;
409     jsonThumbnail[TAG_DEVICE_ID] = "123";
410     jsonThumbnail[TAG_AUTH_TYPE] = 1;
411     jsonThumbnail[TAG_CUSTOM_DESCRIPTION] = "123";
412     jsonThumbnail[TAG_TOKEN] = "1234";
413     jsonThumbnail[TAG_TARGET] = "12345";
414     jsonThumbnail[TAG_APP_OPERATION] = "123456";
415     jsonThumbnail[TAG_APP_THUMBNAIL] = "jsontest";
416     jsonThumbnail[TAG_LOCAL_DEVICE_ID] = "localdeviceTest";
417     jsonThumbnail[TAG_REQUESTER] = "iknbghkkj266SSjsjjdan21526";
418     jsonThumbnail[TAG_DEVICE_TYPE] = 1;
419     int32_t ret = authMessageProcessor->ParseAuthRequestMessage(jsonThumbnail);
420     ASSERT_EQ(ret, ERR_DM_AUTH_MESSAGE_INCOMPLETE);
421 }
422 
423 /**
424  * @tc.name: AuthMessageProcessor::ParseNegotiateMessage_001
425  * @tc.desc: Compare authResponseContext before and after assignment
426  * @tc.type: FUNC
427  * @tc.require: AR000GHSJK
428  */
429 HWTEST_F(AuthMessageProcessorTest, ParseNegotiateMessage_001, testing::ext::TestSize.Level0)
430 {
431     std::shared_ptr<HiChainConnector> hiChainConnector_ = std::make_shared<HiChainConnector>();
432     std::shared_ptr<DmAuthManager> data =
433         std::make_shared<DmAuthManager>(softbusConnector, listener, hiChainConnector_);
434     std::shared_ptr<AuthMessageProcessor> authMessageProcessor = std::make_shared<AuthMessageProcessor>(data);
435     std::shared_ptr<DmAuthResponseContext> authResponseContext = std::make_shared<DmAuthResponseContext>();
436     authMessageProcessor->authResponseContext_ = std::make_shared<DmAuthResponseContext>();
437     nlohmann::json jsonObj;
438     jsonObj[TAG_CRYPTO_SUPPORT] = "CRYPTOSUPPORT";
439     jsonObj[TAG_CRYPTO_SUPPORT] = authMessageProcessor->authResponseContext_->cryptoSupport;
440     authResponseContext->localDeviceId = "22";
441     authResponseContext->authType = 1;
442     authResponseContext->reply = 33;
443     jsonObj[TAG_AUTH_TYPE] = authResponseContext->authType;
444     jsonObj[TAG_LOCAL_DEVICE_ID] = authResponseContext->localDeviceId;
445     jsonObj[TAG_REPLY] = authResponseContext->reply;
446     authMessageProcessor->SetResponseContext(authResponseContext);
447     authMessageProcessor->ParseNegotiateMessage(jsonObj);
448     ASSERT_EQ(authMessageProcessor->authResponseContext_, authResponseContext);
449 }
450 
451 /**
452  * @tc.name: AuthMessageProcessor::ParseNegotiateMessage_002
453  * @tc.desc: Compare authResponseContext before and after assignment
454  * @tc.type: FUNC
455  * @tc.require: AR000GHSJK
456  */
457 HWTEST_F(AuthMessageProcessorTest, ParseNegotiateMessage_002, testing::ext::TestSize.Level0)
458 {
459     std::shared_ptr<HiChainConnector> hiChainConnector_ = std::make_shared<HiChainConnector>();
460     std::shared_ptr<DmAuthManager> data =
461         std::make_shared<DmAuthManager>(softbusConnector, listener, hiChainConnector_);
462     std::shared_ptr<AuthMessageProcessor> authMessageProcessor = std::make_shared<AuthMessageProcessor>(data);
463     std::shared_ptr<DmAuthResponseContext> authResponseContext = std::make_shared<DmAuthResponseContext>();
464     authMessageProcessor->authResponseContext_ = std::make_shared<DmAuthResponseContext>();
465     nlohmann::json jsonObj;
466     authResponseContext->localDeviceId = "22";
467     authResponseContext->authType = 1;
468     authResponseContext->reply = 33;
469     jsonObj[TAG_CRYPTO_NAME] = "CRYPTONAME";
470     jsonObj[TAG_CRYPTO_NAME] = authResponseContext->cryptoSupport;
471     jsonObj[TAG_AUTH_TYPE] = authResponseContext->authType;
472     jsonObj[TAG_LOCAL_DEVICE_ID] = authResponseContext->localDeviceId;
473     jsonObj[TAG_REPLY] = authResponseContext->reply;
474     authMessageProcessor->SetResponseContext(authResponseContext);
475     authMessageProcessor->ParseNegotiateMessage(jsonObj);
476     ASSERT_EQ(authMessageProcessor->authResponseContext_, authResponseContext);
477 }
478 
479 /**
480  * @tc.name: AuthMessageProcessor::ParseNegotiateMessage_003
481  * @tc.desc: Compare authResponseContext before and after assignment
482  * @tc.type: FUNC
483  * @tc.require: AR000GHSJK
484  */
485 HWTEST_F(AuthMessageProcessorTest, ParseNegotiateMessage_003, testing::ext::TestSize.Level0)
486 {
487     std::shared_ptr<HiChainConnector> hiChainConnector_ = std::make_shared<HiChainConnector>();
488     std::shared_ptr<DmAuthManager> data =
489         std::make_shared<DmAuthManager>(softbusConnector, listener, hiChainConnector_);
490     std::shared_ptr<AuthMessageProcessor> authMessageProcessor = std::make_shared<AuthMessageProcessor>(data);
491     std::shared_ptr<DmAuthResponseContext> authResponseContext = std::make_shared<DmAuthResponseContext>();
492     authMessageProcessor->authResponseContext_ = std::make_shared<DmAuthResponseContext>();
493     nlohmann::json jsonObj;
494     authResponseContext->localDeviceId = "22";
495     authResponseContext->authType = 1;
496     authResponseContext->reply = 33;
497     jsonObj[TAG_CRYPTO_VERSION] = "CRYPTOVERSION";
498     jsonObj[TAG_CRYPTO_VERSION] = authResponseContext->cryptoSupport;
499     jsonObj[TAG_AUTH_TYPE] = authResponseContext->authType;
500     jsonObj[TAG_LOCAL_DEVICE_ID] = authResponseContext->localDeviceId;
501     jsonObj[TAG_REPLY] = authResponseContext->reply;
502     authMessageProcessor->SetResponseContext(authResponseContext);
503     authMessageProcessor->ParseNegotiateMessage(jsonObj);
504     ASSERT_EQ(authMessageProcessor->authResponseContext_, authResponseContext);
505 }
506 
507 /**
508  * @tc.name: AuthMessageProcessor::ParseNegotiateMessage_004
509  * @tc.desc: Compare authResponseContext before and after assignment
510  * @tc.type: FUNC
511  * @tc.require: AR000GHSJK
512  */
513 HWTEST_F(AuthMessageProcessorTest, ParseNegotiateMessage_004, testing::ext::TestSize.Level0)
514 {
515     std::shared_ptr<HiChainConnector> hiChainConnector_ = std::make_shared<HiChainConnector>();
516     std::shared_ptr<DmAuthManager> data =
517         std::make_shared<DmAuthManager>(softbusConnector, listener, hiChainConnector_);
518     std::shared_ptr<AuthMessageProcessor> authMessageProcessor = std::make_shared<AuthMessageProcessor>(data);
519     std::shared_ptr<DmAuthResponseContext> authResponseContext = std::make_shared<DmAuthResponseContext>();
520     authMessageProcessor->authResponseContext_ = std::make_shared<DmAuthResponseContext>();
521     nlohmann::json jsonObj;
522     authResponseContext->localDeviceId = "22";
523     authResponseContext->authType = 1;
524     authResponseContext->reply = 33;
525     jsonObj[TAG_DEVICE_ID] = "DEVICEID";
526     jsonObj[TAG_DEVICE_ID] = authResponseContext->deviceId;
527     jsonObj[TAG_AUTH_TYPE] = authResponseContext->authType;
528     jsonObj[TAG_LOCAL_DEVICE_ID] = authResponseContext->localDeviceId;
529     jsonObj[TAG_REPLY] = authResponseContext->reply;
530     authMessageProcessor->SetResponseContext(authResponseContext);
531     authMessageProcessor->ParseNegotiateMessage(jsonObj);
532     ASSERT_EQ(authMessageProcessor->authResponseContext_, authResponseContext);
533 }
534 
535 /**
536  * @tc.name: AuthMessageProcessor::ParseNegotiateMessage_005
537  * @tc.desc: Compare authResponseContext before and after assignment
538  * @tc.type: FUNC
539  * @tc.require: AR000GHSJK
540  */
541 HWTEST_F(AuthMessageProcessorTest, ParseNegotiateMessage_005, testing::ext::TestSize.Level0)
542 {
543     std::shared_ptr<HiChainConnector> hiChainConnector_ = std::make_shared<HiChainConnector>();
544     std::shared_ptr<DmAuthManager> data =
545         std::make_shared<DmAuthManager>(softbusConnector, listener, hiChainConnector_);
546     std::shared_ptr<AuthMessageProcessor> authMessageProcessor = std::make_shared<AuthMessageProcessor>(data);
547     std::shared_ptr<DmAuthResponseContext> authResponseContext = std::make_shared<DmAuthResponseContext>();
548     authMessageProcessor->authResponseContext_ = std::make_shared<DmAuthResponseContext>();
549     nlohmann::json jsonObj;
550     authResponseContext->localDeviceId = "22";
551     authResponseContext->authType = 1;
552     authResponseContext->reply = 33;
553     jsonObj[TAG_LOCAL_DEVICE_ID] = "LOCALDEVICEID";
554     jsonObj[TAG_LOCAL_DEVICE_ID] = authResponseContext->localDeviceId;
555     jsonObj[TAG_AUTH_TYPE] = authResponseContext->authType;
556     jsonObj[TAG_LOCAL_DEVICE_ID] = authResponseContext->localDeviceId;
557     jsonObj[TAG_REPLY] = authResponseContext->reply;
558     authMessageProcessor->SetResponseContext(authResponseContext);
559     authMessageProcessor->ParseNegotiateMessage(jsonObj);
560     ASSERT_EQ(authMessageProcessor->authResponseContext_, authResponseContext);
561 }
562 
563 /**
564  * @tc.name: AuthMessageProcessor::ParseRespNegotiateMessage_001
565  * @tc.desc: return true
566  * @tc.type: FUNC
567  * @tc.require: AR000GHSJK
568  */
569 HWTEST_F(AuthMessageProcessorTest, ParseRespNegotiateMessage_001, testing::ext::TestSize.Level0)
570 {
571     std::shared_ptr<HiChainConnector> hiChainConnector_ = std::make_shared<HiChainConnector>();
572     std::shared_ptr<DmAuthManager> data =
573         std::make_shared<DmAuthManager>(softbusConnector, listener, hiChainConnector_);
574     std::shared_ptr<AuthMessageProcessor> authMessageProcessor = std::make_shared<AuthMessageProcessor>(data);
575     std::shared_ptr<DmAuthResponseContext> authResponseContext = std::make_shared<DmAuthResponseContext>();
576     authMessageProcessor->SetResponseContext(authResponseContext);
577     nlohmann::json jsonObj;
578     jsonObj[TAG_IDENTICAL_ACCOUNT] = false;
579     authMessageProcessor->ParseRespNegotiateMessage(jsonObj);
580     ASSERT_EQ(authMessageProcessor->authResponseContext_->isIdenticalAccount, jsonObj[TAG_IDENTICAL_ACCOUNT]);
581 }
582 
583 /**
584  * @tc.name: AuthMessageProcessor::ParseRespNegotiateMessage_002
585  * @tc.desc: return true
586  * @tc.type: FUNC
587  * @tc.require: AR000GHSJK
588  */
589 HWTEST_F(AuthMessageProcessorTest, ParseRespNegotiateMessage_002, testing::ext::TestSize.Level0)
590 {
591     std::shared_ptr<HiChainConnector> hiChainConnector_ = std::make_shared<HiChainConnector>();
592     std::shared_ptr<DmAuthManager> data =
593         std::make_shared<DmAuthManager>(softbusConnector, listener, hiChainConnector_);
594     std::shared_ptr<AuthMessageProcessor> authMessageProcessor = std::make_shared<AuthMessageProcessor>(data);
595     std::shared_ptr<DmAuthResponseContext> authResponseContext = std::make_shared<DmAuthResponseContext>();
596     authMessageProcessor->SetResponseContext(authResponseContext);
597     nlohmann::json jsonObj;
598     jsonObj[TAG_IDENTICAL_ACCOUNT] = "test";
599     authMessageProcessor->ParseRespNegotiateMessage(jsonObj);
600     ASSERT_NE(authMessageProcessor->authResponseContext_->isIdenticalAccount, jsonObj[TAG_IDENTICAL_ACCOUNT]);
601 }
602 
603 /**
604  * @tc.name: AuthMessageProcessor::SetRequestContext_001
605  * @tc.desc: Compare authResponseContext before and after assignment
606  * @tc.type: FUNC
607  * @tc.require: AR000GHSJK
608  */
609 HWTEST_F(AuthMessageProcessorTest, SetRequestContext_001, testing::ext::TestSize.Level0)
610 {
611     std::shared_ptr<HiChainConnector> hiChainConnector_ = std::make_shared<HiChainConnector>();
612     std::shared_ptr<DmAuthManager> data =
613         std::make_shared<DmAuthManager>(softbusConnector, listener, hiChainConnector_);
614     std::shared_ptr<AuthMessageProcessor> authMessageProcessor = std::make_shared<AuthMessageProcessor>(data);
615     std::shared_ptr<DmAuthRequestContext> authRequestContext = std::make_shared<DmAuthRequestContext>();
616     authMessageProcessor->SetRequestContext(authRequestContext);
617     ASSERT_EQ(authMessageProcessor->authRequestContext_, authRequestContext);
618 }
619 
620 /**
621  * @tc.name: AuthMessageProcessor::SetRequestContext_002
622  * @tc.desc: Judge whether authrequestcontext is empty
623  * @tc.type: FUNC
624  * @tc.require: AR000GHSJK
625  */
626 HWTEST_F(AuthMessageProcessorTest, SetRequestContext_002, testing::ext::TestSize.Level0)
627 {
628     std::shared_ptr<HiChainConnector> hiChainConnector_ = std::make_shared<HiChainConnector>();
629     std::shared_ptr<DmAuthManager> data =
630         std::make_shared<DmAuthManager>(softbusConnector, listener, hiChainConnector_);
631     std::shared_ptr<AuthMessageProcessor> authMessageProcessor = std::make_shared<AuthMessageProcessor>(data);
632     std::shared_ptr<DmAuthRequestContext> authRequestContext = std::make_shared<DmAuthRequestContext>();
633     authMessageProcessor->SetRequestContext(nullptr);
634     ASSERT_EQ(authMessageProcessor->authRequestContext_, nullptr);
635 }
636 
637 /**
638  * @tc.name: AuthMessageProcessor::SetResponseContext_001
639  * @tc.desc: Compare authResponseContext before and after assignment
640  * @tc.type: FUNC
641  * @tc.require: AR000GHSJK
642  */
643 HWTEST_F(AuthMessageProcessorTest, SetResponseContext_001, testing::ext::TestSize.Level0)
644 {
645     std::shared_ptr<HiChainConnector> hiChainConnector_ = std::make_shared<HiChainConnector>();
646     std::shared_ptr<DmAuthManager> data =
647         std::make_shared<DmAuthManager>(softbusConnector, listener, hiChainConnector_);
648     std::shared_ptr<AuthMessageProcessor> authMessageProcessor = std::make_shared<AuthMessageProcessor>(data);
649     std::shared_ptr<DmAuthResponseContext> authResponseContext = std::make_shared<DmAuthResponseContext>();
650     authMessageProcessor->SetResponseContext(authResponseContext);
651     ASSERT_EQ(authMessageProcessor->authResponseContext_, authResponseContext);
652 }
653 
654 /**
655  * @tc.name: AuthMessageProcessor::SetResponseContext_002
656  * @tc.desc: Judge whether authrequestcontext is empty
657  * @tc.type: FUNC
658  * @tc.require: AR000GHSJK
659  */
660 HWTEST_F(AuthMessageProcessorTest, SetResponseContext_002, testing::ext::TestSize.Level0)
661 {
662     std::shared_ptr<HiChainConnector> hiChainConnector_ = std::make_shared<HiChainConnector>();
663     std::shared_ptr<DmAuthManager> data =
664         std::make_shared<DmAuthManager>(softbusConnector, listener, hiChainConnector_);
665     std::shared_ptr<AuthMessageProcessor> authMessageProcessor = std::make_shared<AuthMessageProcessor>(data);
666     std::shared_ptr<DmAuthResponseContext> authResponseContext = std::make_shared<DmAuthResponseContext>();
667     authMessageProcessor->SetResponseContext(nullptr);
668     ASSERT_EQ(authMessageProcessor->authResponseContext_, nullptr);
669 }
670 
671 /**
672  * @tc.name: AuthMessageProcessor::GetResponseContext_001
673  * @tc.desc: Compare authResponseContext before and after assignment
674  * @tc.type: FUNC
675  * @tc.require: AR000GHSJK
676  */
677 HWTEST_F(AuthMessageProcessorTest, GetResponseContext_001, testing::ext::TestSize.Level0)
678 {
679     std::shared_ptr<HiChainConnector> hiChainConnector_ = std::make_shared<HiChainConnector>();
680     std::shared_ptr<DmAuthManager> data =
681         std::make_shared<DmAuthManager>(softbusConnector, listener, hiChainConnector_);
682     std::shared_ptr<AuthMessageProcessor> authMessageProcessor = std::make_shared<AuthMessageProcessor>(data);
683     authMessageProcessor->authResponseContext_ = std::make_shared<DmAuthResponseContext>();
684     std::shared_ptr<DmAuthResponseContext> authResponseContext = authMessageProcessor->GetResponseContext();
685     ASSERT_EQ(authResponseContext, authMessageProcessor->authResponseContext_);
686 }
687 
688 /**
689  * @tc.name: AuthMessageProcessor::GetResponseContext_002
690  * @tc.desc: Judge whether authrequestcontext is empty
691  * @tc.type: FUNC
692  * @tc.require: AR000GHSJK
693  */
694 HWTEST_F(AuthMessageProcessorTest, GetResponseContext_002, testing::ext::TestSize.Level0)
695 {
696     std::shared_ptr<HiChainConnector> hiChainConnector_ = std::make_shared<HiChainConnector>();
697     std::shared_ptr<DmAuthManager> data =
698         std::make_shared<DmAuthManager>(softbusConnector, listener, hiChainConnector_);
699     std::shared_ptr<AuthMessageProcessor> authMessageProcessor = std::make_shared<AuthMessageProcessor>(data);
700     authMessageProcessor->authResponseContext_ = std::make_shared<DmAuthResponseContext>();
701     std::shared_ptr<DmAuthResponseContext> authResponseContext = authMessageProcessor->GetResponseContext();
702     ASSERT_NE(authResponseContext, nullptr);
703 }
704 
705 /**
706  * @tc.name: AuthMessageProcessor::CreateSimpleMessage_001
707  * @tc.desc: return the length of string is empty
708  * @tc.type: FUNC
709  * @tc.require: AR000GHSJK
710  */
711 HWTEST_F(AuthMessageProcessorTest, CreateSimpleMessage_001, testing::ext::TestSize.Level0)
712 {
713     std::shared_ptr<HiChainConnector> hiChainConnector_ = std::make_shared<HiChainConnector>();
714     std::shared_ptr<DmAuthManager> data =
715         std::make_shared<DmAuthManager>(softbusConnector, listener, hiChainConnector_);
716     std::shared_ptr<AuthMessageProcessor> authMessageProcessor = std::make_shared<AuthMessageProcessor>(data);
717     authMessageProcessor->authRequestContext_ = std::make_shared<DmAuthRequestContext>();
718     authMessageProcessor->authResponseContext_ = std::make_shared<DmAuthResponseContext>();
719     int32_t msgType = MSG_TYPE_SYNC_GROUP;
720     std::string ret = authMessageProcessor->CreateSimpleMessage(msgType);
721     ASSERT_NE(ret.size(), 0);
722     msgType = MSG_TYPE_RESP_AUTH;
723     ret = authMessageProcessor->CreateSimpleMessage(msgType);
724     ASSERT_NE(ret.size(), 0);
725     msgType = MSG_TYPE_REQ_AUTH_TERMINATE;
726     ret = authMessageProcessor->CreateSimpleMessage(msgType);
727     ASSERT_NE(ret.size(), 0);
728 }
729 
730 /**
731  * @tc.name: AuthMessageProcessor::GetRequestContext_001
732  * @tc.desc: Compare authRequestContext before and after assignment
733  * @tc.type: FUNC
734  * @tc.require: AR000GHSJK
735  */
736 HWTEST_F(AuthMessageProcessorTest, GetRequestContext_001, testing::ext::TestSize.Level0)
737 {
738     std::shared_ptr<HiChainConnector> hiChainConnector_ = std::make_shared<HiChainConnector>();
739     std::shared_ptr<DmAuthManager> data =
740         std::make_shared<DmAuthManager>(softbusConnector, listener, hiChainConnector_);
741     std::shared_ptr<AuthMessageProcessor> authMessageProcessor = std::make_shared<AuthMessageProcessor>(data);
742     std::shared_ptr<DmAuthRequestContext> authRequestContext = std::make_shared<DmAuthRequestContext>();
743     authMessageProcessor->SetRequestContext(authRequestContext);
744     auto ret = authMessageProcessor->GetRequestContext();
745     ASSERT_EQ(authMessageProcessor->authRequestContext_, ret);
746 }
747 
748 /**
749  * @tc.name: AuthMessageProcessor::ParseMessage_001
750  * @tc.desc: Return DM_OK
751  * @tc.type: FUNC
752  * @tc.require: AR000GHSJK
753  */
754 HWTEST_F(AuthMessageProcessorTest, ParseMessage_001, testing::ext::TestSize.Level0)
755 {
756     std::shared_ptr<HiChainConnector> hiChainConnector_ = std::make_shared<HiChainConnector>();
757     std::shared_ptr<DmAuthManager> data =
758         std::make_shared<DmAuthManager>(softbusConnector, listener, hiChainConnector_);
759     std::shared_ptr<AuthMessageProcessor> authMessageProcessor = std::make_shared<AuthMessageProcessor>(data);
760     std::shared_ptr<DmAuthResponseContext> authResponseContext = std::make_shared<DmAuthResponseContext>();
761     authMessageProcessor->SetResponseContext(authResponseContext);
762     std::string message = R"(
763     {
764         "AUTHTYPE": 1,
765         "CRYPTOSUPPORT": false,
766         "ITF_VER": "1.1",
767         "LOCALDEVICEID": "e68f0b9186386e87487564b02e91421f904eb9517f262721c9ada090477e35f5",
768         "MSG_TYPE": 80,
769         "REPLY": 2016
770     }
771     )";
772     int32_t ret = authMessageProcessor->ParseMessage(message);
773     ASSERT_EQ(ret, DM_OK);
774 }
775 
776 /**
777  * @tc.name: AuthMessageProcessor::ParseMessage_002
778  * @tc.desc: Return DM_OK
779  * @tc.type: FUNC
780  * @tc.require: AR000GHSJK
781  */
782 HWTEST_F(AuthMessageProcessorTest, ParseMessage_002, testing::ext::TestSize.Level0)
783 {
784     std::shared_ptr<HiChainConnector> hiChainConnector_ = std::make_shared<HiChainConnector>();
785     std::shared_ptr<DmAuthManager> data =
786         std::make_shared<DmAuthManager>(softbusConnector, listener, hiChainConnector_);
787     std::shared_ptr<AuthMessageProcessor> authMessageProcessor = std::make_shared<AuthMessageProcessor>(data);
788     std::shared_ptr<DmAuthResponseContext> authResponseContext = std::make_shared<DmAuthResponseContext>();
789     authMessageProcessor->SetResponseContext(authResponseContext);
790     std::string message = R"(
791     {
792         "AUTHTYPE": 1,
793         "CRYPTOSUPPORT": false,
794         "ITF_VER": "1.1",
795         "LOCALDEVICEID": "e68f0b9186386e87487564b02e91421f904eb9517f262721c9ada090477e35f5",
796         "MSG_TYPE": 90,
797         "REPLY": 2016
798     }
799     )";
800     int32_t ret = authMessageProcessor->ParseMessage(message);
801     ASSERT_EQ(ret, DM_OK);
802 }
803 
804 /**
805  * @tc.name: AuthMessageProcessor::ParseMessage_003
806  * @tc.desc: Return DM_OK
807  * @tc.type: FUNC
808  * @tc.require: AR000GHSJK
809  */
810 HWTEST_F(AuthMessageProcessorTest, ParseMessage_003, testing::ext::TestSize.Level0)
811 {
812     std::shared_ptr<HiChainConnector> hiChainConnector_ = std::make_shared<HiChainConnector>();
813     std::shared_ptr<DmAuthManager> data =
814         std::make_shared<DmAuthManager>(softbusConnector, listener, hiChainConnector_);
815     std::shared_ptr<AuthMessageProcessor> authMessageProcessor = std::make_shared<AuthMessageProcessor>(data);
816     std::shared_ptr<DmAuthResponseContext> authResponseContext = std::make_shared<DmAuthResponseContext>();
817     authMessageProcessor->SetResponseContext(authResponseContext);
818     std::string message = R"(
819     {
820         "APPDESC": "Distributed Calc",
821         "CUSTOMDESC": "customDescription",
822         "APPICON": "",
823         "APPNAME": "Distributed Calc",
824         "APPOPERATION": "appoperrationTest",
825         "AUTHTYPE":1,
826         "DEVICEID": "e68f0b9186386e87487564b02e91421f904eb9517f262721c9ada090477e35f5",
827         "LOCALDEVICEID": "test0b9186386e87487564b02etest1f904eb9517f262721c9ada090477etest",
828         "DEVICETYPE": 1,
829         "HOST": "com.example.distributedcalc",
830         "INDEX": 0,
831         "ITF_VER": "1.1",
832         "MSG_TYPE": 100,
833         "REQUESTER": "test0b9186386e87487564b02etest1f904eb9517f262721c9ada090477etest",
834         "SLICE": 1,
835         "TARGET": "com.example.distributedcalc",
836         "THUMSIZE": 0,
837         "TOKEN": "73141022",
838         "VISIBILITY": 0
839     }
840     )";
841     int32_t ret = authMessageProcessor->ParseMessage(message);
842     ASSERT_EQ(ret, DM_OK);
843 }
844 
845 /**
846  * @tc.name: AuthMessageProcessor::ParseMessage_004
847  * @tc.desc: Return DM_OK
848  * @tc.type: FUNC
849  * @tc.require: AR000GHSJK
850  */
851 HWTEST_F(AuthMessageProcessorTest, ParseMessage_004, testing::ext::TestSize.Level0)
852 {
853     std::shared_ptr<HiChainConnector> hiChainConnector_ = std::make_shared<HiChainConnector>();
854     std::shared_ptr<DmAuthManager> data =
855         std::make_shared<DmAuthManager>(softbusConnector, listener, hiChainConnector_);
856     std::shared_ptr<AuthMessageProcessor> authMessageProcessor = std::make_shared<AuthMessageProcessor>(data);
857     std::shared_ptr<DmAuthResponseContext> authResponseContext = std::make_shared<DmAuthResponseContext>();
858     authMessageProcessor->SetResponseContext(authResponseContext);
859     std::string message = R"(
860     {
861         "REPLY": 0,
862         "DEVICEID": "e68f0b9186386e87487564b02e91421f904eb9517f262721c9ada090477e35f5",
863         "TOKEN": "7314",
864         "GROUPNAME": "com.example.test",
865         "ITF_VER": "1.1",
866         "MSG_TYPE": 200,
867         "NETID": "147258963",
868         "REQUESTID": 8448,
869         "authToken": "com.example.distributedcalc62063A65EC8540074FF01413BDC3B6D7",
870         "groupId" : "e68f0b9186386e87487564b02e91421f904eb9517f262721c9ada090477e35f5"
871     }
872     )";
873     int32_t ret = authMessageProcessor->ParseMessage(message);
874     ASSERT_EQ(ret, DM_OK);
875 }
876 
877 /**
878  * @tc.name: AuthMessageProcessor::ParseMessage_005
879  * @tc.desc: Return DM_OK
880  * @tc.type: FUNC
881  * @tc.require: AR000GHSJK
882  */
883 HWTEST_F(AuthMessageProcessorTest, ParseMessage_005, testing::ext::TestSize.Level0)
884 {
885     std::shared_ptr<HiChainConnector> hiChainConnector_ = std::make_shared<HiChainConnector>();
886     std::shared_ptr<DmAuthManager> data =
887         std::make_shared<DmAuthManager>(softbusConnector, listener, hiChainConnector_);
888     std::shared_ptr<AuthMessageProcessor> authMessageProcessor = std::make_shared<AuthMessageProcessor>(data);
889     std::shared_ptr<DmAuthResponseContext> authResponseContext = std::make_shared<DmAuthResponseContext>();
890     authMessageProcessor->SetResponseContext(authResponseContext);
891     std::string message = R"(
892     {
893         "REPLY": 0,
894         "ITF_VER": "1.1",
895         "MSG_TYPE": 104
896     }
897     )";
898     int32_t ret = authMessageProcessor->ParseMessage(message);
899     ASSERT_EQ(ret, DM_OK);
900 }
901 
902 /**
903  * @tc.name: AuthMessageProcessor::ParseMessage_006
904  * @tc.desc: Return ERR_DM_FAILED
905  * @tc.type: FUNC
906  * @tc.require: AR000GHSJK
907  */
908 HWTEST_F(AuthMessageProcessorTest, ParseMessage_006, testing::ext::TestSize.Level0)
909 {
910     std::shared_ptr<HiChainConnector> hiChainConnector_ = std::make_shared<HiChainConnector>();
911     std::shared_ptr<DmAuthManager> data =
912         std::make_shared<DmAuthManager>(softbusConnector, listener, hiChainConnector_);
913     std::shared_ptr<AuthMessageProcessor> authMessageProcessor = std::make_shared<AuthMessageProcessor>(data);
914     std::shared_ptr<DmAuthResponseContext> authResponseContext = std::make_shared<DmAuthResponseContext>();
915     authMessageProcessor->SetResponseContext(authResponseContext);
916     std::string message = R"(
917     {
918         "REPLY": 1,
919         "ITF_VER": "1.1.2",
920         "MSG_TYPE": "104"
921     }
922     )";
923     int32_t ret = authMessageProcessor->ParseMessage(message);
924     ASSERT_EQ(ret, ERR_DM_FAILED);
925 }
926 } // namespace
927 } // namespace DistributedHardware
928 } // namespace OHOS
929