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 "identify_context.h"
17 
18 #include "mock_context.h"
19 #include "mock_identification.h"
20 #include "mock_schedule_node.h"
21 
22 using namespace testing;
23 using namespace testing::ext;
24 namespace OHOS {
25 namespace UserIam {
26 namespace UserAuth {
27 class IdentifyContextTest : public testing::Test {
28 public:
29     static void SetUpTestCase();
30 
31     static void TearDownTestCase();
32 
33     void SetUp() override;
34 
35     void TearDown() override;
36 };
37 
SetUpTestCase()38 void IdentifyContextTest::SetUpTestCase()
39 {
40 }
41 
TearDownTestCase()42 void IdentifyContextTest::TearDownTestCase()
43 {
44 }
45 
SetUp()46 void IdentifyContextTest::SetUp()
47 {
48 }
49 
TearDown()50 void IdentifyContextTest::TearDown()
51 {
52 }
53 
54 HWTEST_F(IdentifyContextTest, IdentifyContextTest_NullHdi, TestSize.Level0)
55 {
56     const uint64_t testContestId = 2;
57     const int32_t testResultCode = 7;
58     const auto finalResult = Common::MakeShared<Attributes>();
59     ASSERT_NE(finalResult, nullptr);
60     std::shared_ptr<MockContextCallback> contextCallback = Common::MakeShared<MockContextCallback>();
61     ASSERT_NE(contextCallback, nullptr);
62     EXPECT_CALL(*contextCallback, OnResult(_, _)).Times(Exactly(1));
63     // Error: identify is null
64     std::shared_ptr<Identification> identify = nullptr;
65 
66     auto oriContext = Common::MakeShared<IdentifyContext>(testContestId, identify, contextCallback);
67     ASSERT_NE(oriContext, nullptr);
68     std::shared_ptr<Context> context = oriContext;
69     std::shared_ptr<ScheduleNodeCallback> nodeCallback = oriContext;
70 
71     ASSERT_EQ(context->Start(), false);
72     ASSERT_EQ(context->Stop(), false);
73     nodeCallback->OnScheduleStoped(testResultCode, finalResult);
74 }
75 
76 HWTEST_F(IdentifyContextTest, IdentifyContextTest_NullCallback, TestSize.Level0)
77 {
78     const uint64_t testContestId = 2;
79     const ExecutorRole testRole = static_cast<ExecutorRole>(3);
80     const int32_t testModuleType = 4;
81     const std::vector<uint8_t> testAcquireMsg = {4, 5, 6};
82     const int32_t testResultCode = 7;
83     const auto finalResult = Common::MakeShared<Attributes>();
84     ASSERT_NE(finalResult, nullptr);
85 
86     std::shared_ptr<MockIdentification> mockIdentify = Common::MakeShared<MockIdentification>();
87     ASSERT_NE(mockIdentify, nullptr);
88     // Error: contextCallback is null
89     std::shared_ptr<ContextCallback> contextCallback = nullptr;
90 
91     auto oriContext = Common::MakeShared<IdentifyContext>(testContestId, mockIdentify, contextCallback);
92     ASSERT_NE(oriContext, nullptr);
93     std::shared_ptr<ScheduleNodeCallback> nodeCallback = oriContext;
94 
95     nodeCallback->OnScheduleStarted();
96     nodeCallback->OnScheduleProcessed(testRole, testModuleType, testAcquireMsg);
97     nodeCallback->OnScheduleStoped(testResultCode, finalResult);
98 }
99 
100 HWTEST_F(IdentifyContextTest, IdentifyContextTest_BasicInfo, TestSize.Level0)
101 {
102     const uint64_t testContestId = 2;
103 
104     std::shared_ptr<MockIdentification> mockIdentify = Common::MakeShared<MockIdentification>();
105     ASSERT_NE(mockIdentify, nullptr);
106     std::shared_ptr<ContextCallback> contextCallback = Common::MakeShared<MockContextCallback>();
107     ASSERT_NE(contextCallback, nullptr);
108 
109     auto oriContext = Common::MakeShared<IdentifyContext>(testContestId, mockIdentify, contextCallback);
110     ASSERT_NE(oriContext, nullptr);
111     std::shared_ptr<Context> context = oriContext;
112 
113     ASSERT_EQ(context->GetContextId(), testContestId);
114     ASSERT_EQ(context->GetContextType(), CONTEXT_IDENTIFY);
115 }
116 
117 HWTEST_F(IdentifyContextTest, IdentifyContextTest_Start_001, TestSize.Level0)
118 {
119     static const uint64_t testContestId = 2;
120 
121     std::shared_ptr<MockIdentification> mockIdentify = Common::MakeShared<MockIdentification>();
122     ASSERT_NE(mockIdentify, nullptr);
123     EXPECT_CALL(*mockIdentify, GetLatestError()).Times(1);
124     EXPECT_CALL(*mockIdentify, Start(_, _))
125         .Times(Exactly(1))
126         .WillOnce([](std::vector<std::shared_ptr<ScheduleNode>> &scheduleList,
__anon978235340102(std::vector<std::shared_ptr<ScheduleNode>> &scheduleList, std::shared_ptr<ScheduleNodeCallback> callback) 127                       std::shared_ptr<ScheduleNodeCallback> callback) {
128             // Error: process identification start fail
129             return false;
130         });
131     std::shared_ptr<ContextCallback> contextCallback = Common::MakeShared<MockContextCallback>();
132     ASSERT_NE(contextCallback, nullptr);
133     std::shared_ptr<Context> context = Common::MakeShared<IdentifyContext>(testContestId,
134         mockIdentify, contextCallback);
135     ASSERT_NE(context, nullptr);
136     ASSERT_EQ(context->Start(), false);
137 }
138 
139 HWTEST_F(IdentifyContextTest, IdentifyContextTest_Start_002, TestSize.Level0)
140 {
141     static const uint64_t testContestId = 2;
142 
143     std::shared_ptr<MockIdentification> mockIdentify = Common::MakeShared<MockIdentification>();
144     ASSERT_NE(mockIdentify, nullptr);
145     EXPECT_CALL(*mockIdentify, Start(_, _))
146         .Times(Exactly(1))
147         .WillOnce([](std::vector<std::shared_ptr<ScheduleNode>> &scheduleList,
__anon978235340202(std::vector<std::shared_ptr<ScheduleNode>> &scheduleList, std::shared_ptr<ScheduleNodeCallback> callback) 148                       std::shared_ptr<ScheduleNodeCallback> callback) {
149             // Error: scheduleNodeList size = 0
150             return true;
151         });
152     std::shared_ptr<ContextCallback> contextCallback = Common::MakeShared<MockContextCallback>();
153     ASSERT_NE(contextCallback, nullptr);
154     std::shared_ptr<Context> context = Common::MakeShared<IdentifyContext>(testContestId,
155         mockIdentify, contextCallback);
156     ASSERT_NE(context, nullptr);
157     ASSERT_EQ(context->Start(), false);
158 }
159 
160 HWTEST_F(IdentifyContextTest, IdentifyContextTest_Start_003, TestSize.Level0)
161 {
162     static const uint64_t testContestId = 2;
163 
164     std::shared_ptr<MockIdentification> mockIdentify = Common::MakeShared<MockIdentification>();
165     ASSERT_NE(mockIdentify, nullptr);
166     EXPECT_CALL(*mockIdentify, Start(_, _))
167         .Times(Exactly(1))
168         .WillOnce([](std::vector<std::shared_ptr<ScheduleNode>> &scheduleList,
__anon978235340302(std::vector<std::shared_ptr<ScheduleNode>> &scheduleList, std::shared_ptr<ScheduleNodeCallback> callback) 169                       std::shared_ptr<ScheduleNodeCallback> callback) {
170             // Error: scheduleNodeList size = 2
171             scheduleList.push_back(Common::MakeShared<MockScheduleNode>());
172             scheduleList.push_back(Common::MakeShared<MockScheduleNode>());
173             return true;
174         });
175     std::shared_ptr<ContextCallback> contextCallback = Common::MakeShared<MockContextCallback>();
176     ASSERT_NE(contextCallback, nullptr);
177     std::shared_ptr<Context> context = Common::MakeShared<IdentifyContext>(testContestId,
178         mockIdentify, contextCallback);
179     ASSERT_NE(context, nullptr);
180     ASSERT_EQ(context->Start(), false);
181 }
182 
183 HWTEST_F(IdentifyContextTest, IdentifyContextTest_Start_004, TestSize.Level0)
184 {
185     static const uint64_t testContestId = 2;
186 
187     std::shared_ptr<MockIdentification> mockIdentify = Common::MakeShared<MockIdentification>();
188     ASSERT_NE(mockIdentify, nullptr);
189     EXPECT_CALL(*mockIdentify, Start(_, _))
190         .Times(Exactly(1))
191         .WillOnce([](std::vector<std::shared_ptr<ScheduleNode>> &scheduleList,
__anon978235340402(std::vector<std::shared_ptr<ScheduleNode>> &scheduleList, std::shared_ptr<ScheduleNodeCallback> callback) 192                       std::shared_ptr<ScheduleNodeCallback> callback) {
193             // Error: schedule node start fail
194             auto scheduleNode = Common::MakeShared<MockScheduleNode>();
195             EXPECT_CALL(*scheduleNode, StartSchedule()).Times(Exactly(1)).WillOnce(Return(false));
196             scheduleList.push_back(scheduleNode);
197             return true;
198         });
199     std::shared_ptr<ContextCallback> contextCallback = Common::MakeShared<MockContextCallback>();
200     ASSERT_NE(contextCallback, nullptr);
201     std::shared_ptr<Context> context = Common::MakeShared<IdentifyContext>(testContestId,
202         mockIdentify, contextCallback);
203     ASSERT_NE(context, nullptr);
204     ASSERT_EQ(context->Start(), false);
205 }
206 
207 HWTEST_F(IdentifyContextTest, IdentifyContextTest_Start_005, TestSize.Level0)
208 {
209     static const uint64_t testContestId = 2;
210     static const uint64_t testScheduleId = 3;
211 
212     std::shared_ptr<MockIdentification> mockIdentify = Common::MakeShared<MockIdentification>();
213     ASSERT_NE(mockIdentify, nullptr);
214     EXPECT_CALL(*mockIdentify, Start(_, _))
215         .Times(Exactly(1))
216         .WillOnce([](std::vector<std::shared_ptr<ScheduleNode>> &scheduleList,
__anon978235340502(std::vector<std::shared_ptr<ScheduleNode>> &scheduleList, std::shared_ptr<ScheduleNodeCallback> callback) 217                       std::shared_ptr<ScheduleNodeCallback> callback) {
218             // Success
219             EXPECT_EQ(scheduleList.size(), 0U);
220             auto scheduleNode = Common::MakeShared<MockScheduleNode>();
221             EXPECT_CALL(*scheduleNode, StartSchedule()).Times(Exactly(1)).WillOnce(Return(true));
222             EXPECT_CALL(*scheduleNode, GetScheduleId()).Times(Exactly(2)).WillRepeatedly(Return(testScheduleId));
223             scheduleList.push_back(scheduleNode);
224             return true;
225         });
226     std::shared_ptr<ContextCallback> contextCallback = Common::MakeShared<MockContextCallback>();
227     ASSERT_NE(contextCallback, nullptr);
228     std::shared_ptr<Context> context = Common::MakeShared<IdentifyContext>(testContestId,
229         mockIdentify, contextCallback);
230     ASSERT_NE(context, nullptr);
231     ASSERT_EQ(context->Start(), true);
232     ASSERT_EQ(context->Start(), false);
233     auto node = context->GetScheduleNode(testScheduleId);
234     ASSERT_NE(node, nullptr);
235     node = context->GetScheduleNode(testScheduleId + 1);
236     ASSERT_EQ(node, nullptr);
237 }
238 
239 HWTEST_F(IdentifyContextTest, IdentifyContextTest_Stop_001, TestSize.Level0)
240 {
241     static const uint64_t testContestId = 2;
242 
243     std::shared_ptr<MockIdentification> mockIdentify = Common::MakeShared<MockIdentification>();
244     ASSERT_NE(mockIdentify, nullptr);
245     EXPECT_CALL(*mockIdentify, GetLatestError()).Times(1);
__anon978235340602() 246     EXPECT_CALL(*mockIdentify, Cancel()).Times(Exactly(1)).WillOnce([]() {
247         // Error: identification cancel fail
248         return false;
249     });
250     std::shared_ptr<ContextCallback> contextCallback = Common::MakeShared<MockContextCallback>();
251     ASSERT_NE(contextCallback, nullptr);
252     std::shared_ptr<Context> context = Common::MakeShared<IdentifyContext>(testContestId,
253         mockIdentify, contextCallback);
254     ASSERT_NE(context, nullptr);
255     ASSERT_EQ(context->Stop(), false);
256 }
257 
258 HWTEST_F(IdentifyContextTest, IdentifyContextTest_Stop_002, TestSize.Level0)
259 {
260     static const uint64_t testContestId = 2;
261 
262     std::shared_ptr<MockIdentification> mockIdentify = Common::MakeShared<MockIdentification>();
263     ASSERT_NE(mockIdentify, nullptr);
__anon978235340702() 264     EXPECT_CALL(*mockIdentify, Cancel()).Times(Exactly(1)).WillOnce([]() { return true; });
265     std::shared_ptr<ContextCallback> contextCallback = Common::MakeShared<MockContextCallback>();
266     ASSERT_NE(contextCallback, nullptr);
267     std::shared_ptr<Context> context = Common::MakeShared<IdentifyContext>(testContestId,
268         mockIdentify, contextCallback);
269     ASSERT_NE(context, nullptr);
270     ASSERT_EQ(context->Stop(), true);
271 }
272 
273 HWTEST_F(IdentifyContextTest, IdentifyContextTest_OnScheduleStarted, TestSize.Level0)
274 {
275     static const uint64_t testContestId = 2;
276 
277     std::shared_ptr<MockIdentification> mockIdentify = Common::MakeShared<MockIdentification>();
278     ASSERT_NE(mockIdentify, nullptr);
279     std::shared_ptr<ContextCallback> contextCallback = Common::MakeShared<MockContextCallback>();
280     ASSERT_NE(contextCallback, nullptr);
281 
282     std::shared_ptr<ScheduleNodeCallback> nodeCallback =
283         Common::MakeShared<IdentifyContext>(testContestId, mockIdentify, contextCallback);
284     ASSERT_NE(nodeCallback, nullptr);
285     nodeCallback->OnScheduleStarted();
286 }
287 
288 HWTEST_F(IdentifyContextTest, IdentifyContextTest_OnScheduleProcessed, TestSize.Level0)
289 {
290     static const uint64_t testContestId = 2;
291     const ExecutorRole testRole = static_cast<ExecutorRole>(3);
292     const int32_t testModuleType = 4;
293     const std::vector<uint8_t> testAcquireMsg = {4, 5, 6};
294 
295     std::shared_ptr<MockIdentification> mockIdentify = Common::MakeShared<MockIdentification>();
296     ASSERT_NE(mockIdentify, nullptr);
297     auto contextCallback = Common::MakeShared<MockContextCallback>();
298     ASSERT_NE(contextCallback, nullptr);
299     EXPECT_CALL(*contextCallback, OnAcquireInfo(_, _, _))
300         .WillOnce(
__anon978235340802(ExecutorRole src, int32_t moduleType, const std::vector<uint8_t> &acquireMsg) 301             [](ExecutorRole src, int32_t moduleType, const std::vector<uint8_t> &acquireMsg) {
302                 EXPECT_EQ(moduleType, 4);
303             }
304         );
305 
306     std::shared_ptr<ScheduleNodeCallback> nodeCallback =
307         Common::MakeShared<IdentifyContext>(testContestId, mockIdentify, contextCallback);
308     ASSERT_NE(nodeCallback, nullptr);
309 
310     nodeCallback->OnScheduleProcessed(testRole, testModuleType, testAcquireMsg);
311 }
312 
313 HWTEST_F(IdentifyContextTest, IdentifyContextTest_OnScheduleStoped_001, TestSize.Level0)
314 {
315     static const uint64_t testContestId = 2;
316     static const int32_t testResultCode = 7;
317 
318     std::shared_ptr<MockIdentification> mockIdentify = Common::MakeShared<MockIdentification>();
319     ASSERT_NE(mockIdentify, nullptr);
320     std::shared_ptr<MockContextCallback> contextCallback = Common::MakeShared<MockContextCallback>();
321     ASSERT_NE(contextCallback, nullptr);
322     EXPECT_CALL(*contextCallback, OnResult(_, _))
323         .Times(Exactly(1))
__anon978235340902(int32_t resultCode, const Attributes &finalResult) 324         .WillOnce([](int32_t resultCode, const Attributes &finalResult) {
325             EXPECT_EQ(resultCode, testResultCode);
326         });
327 
328     std::shared_ptr<ScheduleNodeCallback> nodeCallback =
329         Common::MakeShared<IdentifyContext>(testContestId, mockIdentify, contextCallback);
330     ASSERT_NE(nodeCallback, nullptr);
331     // Error: result is null when testResultCode is not success
332     std::shared_ptr<Attributes> result = nullptr;
333     nodeCallback->OnScheduleStoped(testResultCode, result);
334 }
335 
336 HWTEST_F(IdentifyContextTest, IdentifyContextTest_OnScheduleStoped_002, TestSize.Level0)
337 {
338     static const uint64_t testContestId = 2;
339     static const int32_t testResultCode = ResultCode::SUCCESS;
340 
341     std::shared_ptr<MockIdentification> mockIdentify = Common::MakeShared<MockIdentification>();
342     ASSERT_NE(mockIdentify, nullptr);
343     std::shared_ptr<MockContextCallback> contextCallback = Common::MakeShared<MockContextCallback>();
344     ASSERT_NE(contextCallback, nullptr);
345     EXPECT_CALL(*contextCallback, OnResult(_, _))
346         .Times(Exactly(1))
__anon978235340a02(int32_t resultCode, const Attributes &finalResult) 347         .WillOnce([](int32_t resultCode, const Attributes &finalResult) {
348             EXPECT_EQ(resultCode, ResultCode::GENERAL_ERROR);
349         });
350 
351     std::shared_ptr<ScheduleNodeCallback> nodeCallback =
352         Common::MakeShared<IdentifyContext>(testContestId, mockIdentify, contextCallback);
353     ASSERT_NE(nodeCallback, nullptr);
354     // Error: result is null when testResultCode is success
355     std::shared_ptr<Attributes> result = nullptr;
356     nodeCallback->OnScheduleStoped(testResultCode, result);
357 }
358 
359 HWTEST_F(IdentifyContextTest, IdentifyContextTest_OnScheduleStoped_003, TestSize.Level0)
360 {
361     static const uint64_t testContestId = 2;
362     static const int32_t testResultCode = ResultCode::SUCCESS;
363 
364     std::shared_ptr<MockIdentification> mockIdentify = Common::MakeShared<MockIdentification>();
365     ASSERT_NE(mockIdentify, nullptr);
366     std::shared_ptr<MockContextCallback> contextCallback = Common::MakeShared<MockContextCallback>();
367     ASSERT_NE(contextCallback, nullptr);
368     EXPECT_CALL(*contextCallback, OnResult(_, _))
369         .Times(Exactly(1))
__anon978235340b02(int32_t resultCode, const Attributes &finalResult) 370         .WillOnce([](int32_t resultCode, const Attributes &finalResult) {
371             EXPECT_EQ(resultCode, ResultCode::GENERAL_ERROR);
372         });
373 
374     std::shared_ptr<ScheduleNodeCallback> nodeCallback =
375         Common::MakeShared<IdentifyContext>(testContestId, mockIdentify, contextCallback);
376     ASSERT_NE(nodeCallback, nullptr);
377     // Error: ATTR_RESULT_CODE is not set
378     std::shared_ptr<Attributes> result = Common::MakeShared<Attributes>();
379     ASSERT_NE(result, nullptr);
380     nodeCallback->OnScheduleStoped(testResultCode, result);
381 }
382 
383 HWTEST_F(IdentifyContextTest, IdentifyContextTest_OnScheduleStoped_004, TestSize.Level0)
384 {
385     static const uint64_t testContestId = 2;
386     static const int32_t testResultCode = ResultCode::SUCCESS;
387     static const std::vector<uint8_t> testScheduleResult = {3, 4, 5, 6};
388 
389     std::shared_ptr<MockIdentification> mockIdentify = Common::MakeShared<MockIdentification>();
390     ASSERT_NE(mockIdentify, nullptr);
391     EXPECT_CALL(*mockIdentify, GetLatestError()).Times(1);
392     EXPECT_CALL(*mockIdentify, Update(_, _))
393         .Times(Exactly(1))
__anon978235340c02(const std::vector<uint8_t> &scheduleResult, Identification::IdentifyResultInfo &resultInfo) 394         .WillOnce([](const std::vector<uint8_t> &scheduleResult, Identification::IdentifyResultInfo &resultInfo) {
395             EXPECT_EQ(scheduleResult, testScheduleResult);
396             return false;
397         });
398     std::shared_ptr<MockContextCallback> contextCallback = Common::MakeShared<MockContextCallback>();
399     ASSERT_NE(contextCallback, nullptr);
400     EXPECT_CALL(*contextCallback, OnResult(_, _))
401         .Times(Exactly(1))
__anon978235340d02(int32_t resultCode, const Attributes &finalResult) 402         .WillOnce([](int32_t resultCode, const Attributes &finalResult) {
403             EXPECT_EQ(resultCode, ResultCode::GENERAL_ERROR);
404         });
405 
406     std::shared_ptr<ScheduleNodeCallback> nodeCallback =
407         Common::MakeShared<IdentifyContext>(testContestId, mockIdentify, contextCallback);
408     ASSERT_NE(nodeCallback, nullptr);
409     // Error: identify_->Update return false
410     std::shared_ptr<Attributes> result = Common::MakeShared<Attributes>();
411     ASSERT_NE(result, nullptr);
412     bool ret = result->SetUint8ArrayValue(Attributes::ATTR_RESULT, testScheduleResult);
413     ASSERT_EQ(ret, true);
414     nodeCallback->OnScheduleStoped(testResultCode, result);
415 }
416 
417 HWTEST_F(IdentifyContextTest, IdentifyContextTest_OnScheduleStoped_005, TestSize.Level0)
418 {
419     static const uint64_t testContestId = 2;
420     static const std::vector<uint8_t> testScheduleResult = {3, 4, 5, 6};
421     static const int32_t testResultCode = 7;
422     static const int32_t testUserId = 8;
423     static const std::vector<uint8_t> testToken = {10, 11, 12, 13};
424 
425     std::shared_ptr<MockIdentification> mockIdentify = Common::MakeShared<MockIdentification>();
426     ASSERT_NE(mockIdentify, nullptr);
427     EXPECT_CALL(*mockIdentify, Update(_, _))
428         .Times(Exactly(1))
__anon978235340e02(const std::vector<uint8_t> &scheduleResult, Identification::IdentifyResultInfo &resultInfo) 429         .WillOnce([](const std::vector<uint8_t> &scheduleResult, Identification::IdentifyResultInfo &resultInfo) {
430             EXPECT_EQ(scheduleResult, testScheduleResult);
431             resultInfo.result = testResultCode;
432             resultInfo.userId = testUserId;
433             resultInfo.token = testToken;
434             return true;
435         });
436     std::shared_ptr<MockContextCallback> contextCallback = Common::MakeShared<MockContextCallback>();
437     ASSERT_NE(contextCallback, nullptr);
438     EXPECT_CALL(*contextCallback, OnResult(_, _))
439         .Times(Exactly(1))
__anon978235340f02(int32_t resultCode, const Attributes &finalResult) 440         .WillOnce([](int32_t resultCode, const Attributes &finalResult) {
441             EXPECT_EQ(resultCode, testResultCode);
442             uint32_t attrResultCode;
443             int32_t userId;
444             vector<uint8_t> signature;
445             bool ret = finalResult.GetUint32Value(Attributes::ATTR_RESULT_CODE, attrResultCode);
446             EXPECT_EQ(ret, true);
447             ret = finalResult.GetInt32Value(Attributes::ATTR_USER_ID, userId);
448             EXPECT_EQ(ret, true);
449             ret = finalResult.GetUint8ArrayValue(Attributes::ATTR_SIGNATURE, signature);
450             EXPECT_EQ(ret, true);
451 
452             EXPECT_EQ(resultCode, testResultCode);
453             EXPECT_EQ(userId, testUserId);
454             EXPECT_EQ(signature, testToken);
455         });
456 
457     std::shared_ptr<ScheduleNodeCallback> nodeCallback =
458         Common::MakeShared<IdentifyContext>(testContestId, mockIdentify, contextCallback);
459     ASSERT_NE(nodeCallback, nullptr);
460     // Success
461     std::shared_ptr<Attributes> result = Common::MakeShared<Attributes>();
462     ASSERT_NE(result, nullptr);
463     bool ret = result->SetUint8ArrayValue(Attributes::ATTR_RESULT, testScheduleResult);
464     ASSERT_EQ(ret, true);
465     nodeCallback->OnScheduleStoped(testResultCode, result);
466 }
467 } // namespace UserAuth
468 } // namespace UserIam
469 } // namespace OHOS
470