• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 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 <gmock/gmock.h>
17 #include "accesstoken_kit.h"
18 #include "account_iam_client.h"
19 #include "account_iam_client_test_callback.h"
20 #include "account_log_wrapper.h"
21 #include "account_iam_callback_stub.h"
22 #include "account_iam_callback_service.h"
23 #include "token_setproc.h"
24 #include "iam_common_defines.h"
25 
26 namespace OHOS {
27 namespace AccountTest {
28 namespace {
29     const int32_t TEST_USER_ID = 200;
30     const uint32_t INVALID_IPC_CODE = 1000;
31     const uint64_t TEST_CONTEXT_ID = 122;
32     const std::vector<uint8_t> TEST_CHALLENGE = {1, 2, 3, 4};
33 }
34 
35 using namespace testing;
36 using namespace testing::ext;
37 using namespace OHOS::AccountSA;
38 using namespace OHOS::Security::AccessToken;
39 using namespace OHOS::UserIam::UserAuth;
40 
41 class MockIInputer : public OHOS::AccountSA::IInputer {
42 public:
~MockIInputer()43     virtual ~MockIInputer() {}
OnGetData(int32_t authSubType,std::shared_ptr<IInputerData> inputerData)44     void OnGetData(int32_t authSubType, std::shared_ptr<IInputerData> inputerData) override
45     {
46         return;
47     }
48 };
49 
50 class AccountIAMClientTest : public testing::Test {
51 public:
52     static void SetUpTestCase(void);
53     static void TearDownTestCase(void);
54     void SetUp(void) override;
55     void TearDown(void) override;
56 };
57 
SetUpTestCase(void)58 void AccountIAMClientTest::SetUpTestCase(void)
59 {
60     AccessTokenID tokenId = AccessTokenKit::GetNativeTokenId("accountmgr");
61     SetSelfTokenID(tokenId);
62 }
63 
TearDownTestCase(void)64 void AccountIAMClientTest::TearDownTestCase(void)
65 {}
66 
SetUp(void)67 void AccountIAMClientTest::SetUp(void)
68 {}
69 
TearDown(void)70 void AccountIAMClientTest::TearDown(void)
71 {}
72 
73 /**
74  * @tc.name: AccountIAMClient_OpenSession_0100
75  * @tc.desc: Open Session.
76  * @tc.type: FUNC
77  * @tc.require: issueI5N90O
78  */
79 HWTEST_F(AccountIAMClientTest, AccountIAMClient_OpenSession_0100, TestSize.Level0)
80 {
81     std::vector<uint8_t> challenge;
82     AccountIAMClient::GetInstance().OpenSession(0, challenge);
83     EXPECT_TRUE(challenge.size() != 0);
84     AccountIAMClient::GetInstance().CloseSession(0);
85 }
86 
87 /**
88  * @tc.name: AccountIAMClient_AddCredential_0100
89  * @tc.desc: Add credential.
90  * @tc.type: FUNC
91  * @tc.require: issueI5N90O
92  */
93 HWTEST_F(AccountIAMClientTest, AccountIAMClient_AddCredential_0100, TestSize.Level0)
94 {
95     CredentialParameters testPara = {};
96     auto testCallback = std::make_shared<MockIDMCallback>();
97     EXPECT_NE(testCallback, nullptr);
98     EXPECT_CALL(*testCallback, OnResult(_, _)).Times(Exactly(1));
99     AccountIAMClient::GetInstance().AddCredential(TEST_USER_ID, testPara, testCallback);
100 }
101 
102 /**
103  * @tc.name: AccountIAMClient_AddCredential_0200
104  * @tc.desc: Add credential.
105  * @tc.type: FUNC
106  * @tc.require: issueI5N90O
107  */
108 HWTEST_F(AccountIAMClientTest, AccountIAMClient_AddCredential_0200, TestSize.Level0)
109 {
110     CredentialParameters testPara = {};
111     testPara.authType = AuthType::PIN;
112     auto testCallback = std::make_shared<MockIDMCallback>();
113     EXPECT_NE(testCallback, nullptr);
114     EXPECT_CALL(*testCallback, OnResult(_, _)).Times(Exactly(2));
115     AccountIAMClient::GetInstance().AddCredential(0, testPara, testCallback);
116     AccountIAMClient::GetInstance().AddCredential(TEST_USER_ID, testPara, nullptr);
117     AccountIAMClient::GetInstance().AddCredential(TEST_USER_ID, testPara, testCallback);
118 }
119 
120 /**
121  * @tc.name: AccountIAMClient_UpdateCredential_0100
122  * @tc.desc: Update credential.
123  * @tc.type: FUNC
124  * @tc.require: issueI5N90O
125  */
126 HWTEST_F(AccountIAMClientTest, AccountIAMClient_UpdateCredential_0100, TestSize.Level0)
127 {
128     CredentialParameters testPara = {};
129     auto testCallback = std::make_shared<MockIDMCallback>();
130     EXPECT_NE(testCallback, nullptr);
131     EXPECT_CALL(*testCallback, OnResult(_, _)).Times(Exactly(1));
132     AccountIAMClient::GetInstance().UpdateCredential(TEST_USER_ID, testPara, testCallback);
133 }
134 
135 /**
136  * @tc.name: AccountIAMClient_UpdateCredential_200
137  * @tc.desc: Update credential.
138  * @tc.type: FUNC
139  * @tc.require: issueI5N90O
140  */
141 HWTEST_F(AccountIAMClientTest, AccountIAMClient_UpdateCredential_200, TestSize.Level0)
142 {
143     CredentialParameters testPara = {};
144     testPara.authType = AuthType::PIN;
145     auto testCallback = std::make_shared<MockIDMCallback>();
146     EXPECT_NE(testCallback, nullptr);
147     EXPECT_CALL(*testCallback, OnResult(_, _)).Times(Exactly(2));
148     AccountIAMClient::GetInstance().UpdateCredential(TEST_USER_ID, testPara, nullptr);
149     AccountIAMClient::GetInstance().UpdateCredential(0, testPara, testCallback);
150     AccountIAMClient::GetInstance().UpdateCredential(TEST_USER_ID, testPara, testCallback);
151 }
152 
153 /**
154  * @tc.name: AccountIAMClient_Cancel_0100
155  * @tc.desc: Cancel.
156  * @tc.type: FUNC
157  * @tc.require: issueI5N90O
158  */
159 HWTEST_F(AccountIAMClientTest, AccountIAMClient_Cancel_0100, TestSize.Level0)
160 {
161     int32_t ret = AccountIAMClient::GetInstance().Cancel(TEST_USER_ID);
162     EXPECT_NE(ret, 0);
163 }
164 
165 /**
166  * @tc.name: AccountIAMClient_DelCred_0100
167  * @tc.desc: Delete credential.
168  * @tc.type: FUNC
169  * @tc.require: issueI5N90O
170  */
171 HWTEST_F(AccountIAMClientTest, AccountIAMClient_DelCred_0100, TestSize.Level0)
172 {
173     uint64_t testCredentialId = 111;
174     std::vector<uint8_t> testAuthToken = {1, 2, 3, 4};
175     auto testCallback = std::make_shared<MockIDMCallback>();
176     EXPECT_NE(testCallback, nullptr);
177     EXPECT_CALL(*testCallback, OnResult(_, _)).Times(Exactly(2));
178     AccountIAMClient::GetInstance().DelCred(TEST_USER_ID, testCredentialId, testAuthToken, nullptr);
179     AccountIAMClient::GetInstance().DelCred(0, testCredentialId, testAuthToken, testCallback);
180     AccountIAMClient::GetInstance().DelCred(TEST_USER_ID, testCredentialId, testAuthToken, testCallback);
181 }
182 
183 /**
184  * @tc.name: AccountIAMClient_DelUser_0100
185  * @tc.desc: Delete user.
186  * @tc.type: FUNC
187  * @tc.require: issueI5N90O
188  */
189 HWTEST_F(AccountIAMClientTest, AccountIAMClient_DelUser_0100, TestSize.Level0)
190 {
191     std::vector<uint8_t> testAuthToken = {1, 2, 3, 4};
192     auto testCallback = std::make_shared<MockIDMCallback>();
193     EXPECT_NE(testCallback, nullptr);
194     EXPECT_CALL(*testCallback, OnResult(_, _)).Times(Exactly(2));
195     AccountIAMClient::GetInstance().DelUser(TEST_USER_ID, testAuthToken, nullptr);
196     AccountIAMClient::GetInstance().DelUser(0, testAuthToken, testCallback);
197     AccountIAMClient::GetInstance().DelUser(TEST_USER_ID, testAuthToken, testCallback);
198 }
199 
200 /**
201  * @tc.name: AccountIAMClient_GetCredentialInfo_0100
202  * @tc.desc: Get credential info.
203  * @tc.type: FUNC
204  * @tc.require: issueI5N90O
205  */
206 HWTEST_F(AccountIAMClientTest, AccountIAMClient_GetCredentialInfo_0100, TestSize.Level0)
207 {
208     auto testCallback = std::make_shared<MockGetCredInfoCallback>();
209     EXPECT_NE(testCallback, nullptr);
210     EXPECT_CALL(*testCallback, OnCredentialInfo(_, _)).Times(Exactly(1));
211     AccountIAMClient::GetInstance().GetCredentialInfo(TEST_USER_ID, AuthType::PIN, testCallback);
212 }
213 
214 /**
215  * @tc.name: AccountIAMClient_GetAvailableStatus_0100
216  * @tc.desc: Get available status.
217  * @tc.type: FUNC
218  * @tc.require: issueI5N90O
219  */
220 HWTEST_F(AccountIAMClientTest, AccountIAMClient_GetAvailableStatus_0100, TestSize.Level0)
221 {
222     int32_t status;
223     AccountIAMClient::GetInstance().GetAvailableStatus(AuthType::FACE, AuthTrustLevel::ATL1, status);
224     EXPECT_NE(status, 0);
225 }
226 
227 /**
228  * @tc.name: AccountIAMClient_GetAvailableStatus_0200
229  * @tc.desc: Get available status.
230  * @tc.type: FUNC
231  * @tc.require: issueI5N90O
232  */
233 HWTEST_F(AccountIAMClientTest, AccountIAMClient_GetAvailableStatus_0200, TestSize.Level0)
234 {
235     int32_t status;
236     AuthTrustLevel level = static_cast<AuthTrustLevel>(0);
237     int32_t ret = AccountIAMClient::GetInstance().GetAvailableStatus(AuthType::FACE, level, status);
238     EXPECT_EQ(ERR_ACCOUNT_IAM_KIT_PARAM_INVALID_ERROR, ret);
239 }
240 
241 /**
242  * @tc.name: AccountIAMClient_GetProperty_0100
243  * @tc.desc: Get property.
244  * @tc.type: FUNC
245  * @tc.require: issueI5N90O
246  */
247 HWTEST_F(AccountIAMClientTest, AccountIAMClient_GetProperty_0100, TestSize.Level0)
248 {
249     GetPropertyRequest testRequest = {};
250     auto testCallback = std::make_shared<MockGetSetPropCallback>();
251     EXPECT_NE(testCallback, nullptr);
252     EXPECT_CALL(*testCallback, OnResult(_, _)).Times(1);
253     AccountIAMClient::GetInstance().GetProperty(TEST_USER_ID, testRequest, nullptr);
254     AccountIAMClient::GetInstance().GetProperty(TEST_USER_ID, testRequest, testCallback);
255 }
256 
257 /**
258  * @tc.name: AccountIAMClient_SetProperty_0100
259  * @tc.desc: Set property.
260  * @tc.type: FUNC
261  * @tc.require: issueI5N90O
262  */
263 HWTEST_F(AccountIAMClientTest, AccountIAMClient_SetProperty_0100, TestSize.Level0)
264 {
265     SetPropertyRequest testRequest = {};
266     auto testCallback = std::make_shared<MockGetSetPropCallback>();
267     EXPECT_NE(testCallback, nullptr);
268     EXPECT_CALL(*testCallback, OnResult(_, _)).Times(1);
269     AccountIAMClient::GetInstance().SetProperty(TEST_USER_ID, testRequest, nullptr);
270     AccountIAMClient::GetInstance().SetProperty(TEST_USER_ID, testRequest, testCallback);
271 }
272 
273 /**
274  * @tc.name: AccountIAMClient_AuthUser_0100
275  * @tc.desc: Auth user.
276  * @tc.type: FUNC
277  * @tc.require: issueI5N90O
278  */
279 HWTEST_F(AccountIAMClientTest, AccountIAMClient_AuthUser_0100, TestSize.Level0)
280 {
281     SetPropertyRequest testRequest = {};
282     auto testCallback = std::make_shared<MockIDMCallback>();
283     EXPECT_NE(testCallback, nullptr);
284     EXPECT_CALL(*testCallback, OnResult(_, _)).Times(2);
285     AccountIAMClient::GetInstance().AuthUser(0, TEST_CHALLENGE, AuthType::PIN, AuthTrustLevel::ATL1, testCallback);
286     AccountIAMClient::GetInstance().AuthUser(
287         TEST_USER_ID, TEST_CHALLENGE, AuthType::PIN, AuthTrustLevel::ATL1, testCallback);
288 }
289 
290 /**
291  * @tc.name: AccountIAMClient_Auth_0100
292  * @tc.desc: Auth current user.
293  * @tc.type: FUNC
294  * @tc.require: issueI5N90O
295  */
296 HWTEST_F(AccountIAMClientTest, AccountIAMClient_Auth_0100, TestSize.Level0)
297 {
298     SetPropertyRequest testRequest = {};
299     auto testCallback = std::make_shared<MockIDMCallback>();
300     EXPECT_NE(testCallback, nullptr);
301     EXPECT_CALL(*testCallback, OnResult(_, _)).Times(1);
302     AccountIAMClient::GetInstance().Auth(TEST_CHALLENGE, AuthType::PIN, AuthTrustLevel::ATL1, testCallback);
303 }
304 
305 /**
306  * @tc.name: AccountIAMClient_CancelAuth_0100
307  * @tc.desc: Cancel authentication.
308  * @tc.type: FUNC
309  * @tc.require: issueI5N90O
310  */
311 HWTEST_F(AccountIAMClientTest, AccountIAMClient_CancelAuth_0100, TestSize.Level0)
312 {
313     EXPECT_NE(ERR_OK, AccountIAMClient::GetInstance().CancelAuth(TEST_CONTEXT_ID));
314 }
315 
316 class TestIInputer : public OHOS::AccountSA::IInputer {
317 public:
OnGetData(int32_t authSubType,std::shared_ptr<IInputerData> inputerData)318     void OnGetData(int32_t authSubType, std::shared_ptr<IInputerData> inputerData)override {}
319     virtual ~TestIInputer() = default;
320 };
321 
322 /**
323  * @tc.name: AccountIAMClient_RegisterPINInputer_0100
324  * @tc.desc: Register inputer.
325  * @tc.type: FUNC
326  * @tc.require: issueI5N90O
327  */
328 HWTEST_F(AccountIAMClientTest, AccountIAMClient_RegisterPINInputer_0100, TestSize.Level0)
329 {
330     std::shared_ptr<IInputer> inputer = std::make_shared<TestIInputer>();
331     EXPECT_NE(nullptr, inputer);
332     EXPECT_EQ(ERR_OK, AccountIAMClient::GetInstance().RegisterPINInputer(inputer));
333     EXPECT_EQ(ERR_ACCOUNT_IAM_KIT_INPUTER_ALREADY_REGISTERED,
334         AccountIAMClient::GetInstance().RegisterPINInputer(inputer));
335 
336     AccountIAMClient::GetInstance().UnregisterPINInputer();
337 }
338 
339 /**
340  * @tc.name: AccountIAMClient_RegisterInputer_0100
341  * @tc.desc: Unregister/Register inputer failed for unsupported auth type.
342  * @tc.type: FUNC
343  * @tc.require: issueI5N90O
344  */
345 HWTEST_F(AccountIAMClientTest, AccountIAMClient_RegisterInputer_0100, TestSize.Level0)
346 {
347     std::shared_ptr<IInputer> inputer = std::make_shared<TestIInputer>();
348     EXPECT_NE(nullptr, inputer);
349     EXPECT_EQ(ERR_ACCOUNT_IAM_UNSUPPORTED_AUTH_TYPE,
350         AccountIAMClient::GetInstance().RegisterInputer(AuthType::PIN, inputer));
351     EXPECT_EQ(ERR_ACCOUNT_IAM_UNSUPPORTED_AUTH_TYPE, AccountIAMClient::GetInstance().UnregisterInputer(AuthType::PIN));
352 }
353 
354 /**
355  * @tc.name: AccountIAMClient_GetAccountState_0100
356  * @tc.desc: Get account state.
357  * @tc.type: FUNC
358  * @tc.require: issueI5N90O
359  */
360 HWTEST_F(AccountIAMClientTest, AccountIAMClient_GetAccountState_0100, TestSize.Level0)
361 {
362     int32_t userId = 1111; // 1111: invalid userId
363     EXPECT_EQ(IDLE, AccountIAMClient::GetInstance().GetAccountState(userId));
364 
365     userId = 100; // 100: userId
366     EXPECT_NE(IDLE, AccountIAMClient::GetInstance().GetAccountState(userId));
367 }
368 
369 /**
370  * @tc.name: AccountIAMClient_SetCredential_0100
371  * @tc.desc: SetCredential.
372  * @tc.type: FUNC
373  * @tc.require: issueI5N90O
374  */
375 HWTEST_F(AccountIAMClientTest, AccountIAMClient_SetCredential_0100, TestSize.Level0)
376 {
377     int32_t userId = 1111; // 1111: userId
378     std::vector<uint8_t> cred1(10, 'a');
379     CredentialItem credItem;
380     AccountIAMClient::GetInstance().SetCredential(userId, cred1);
381     AccountIAMClient::GetInstance().GetCredential(userId, credItem);
382     EXPECT_TRUE(credItem.oldCredential.empty());
383     EXPECT_FALSE(credItem.credential.empty());
384 
385     std::vector<uint8_t> cred2(10, 'b');
386     AccountIAMClient::GetInstance().SetCredential(userId, cred2);
387     AccountIAMClient::GetInstance().GetCredential(userId, credItem);
388     EXPECT_FALSE(credItem.oldCredential.empty());
389     EXPECT_FALSE(credItem.credential.empty());
390 
391     AccountIAMClient::GetInstance().ClearCredential(userId);
392 }
393 
394 /**
395  * @tc.name: AccountIAMClient_SetAuthSubType_0100
396  * @tc.desc: SetAuthSubType.
397  * @tc.type: FUNC
398  * @tc.require: issueI5N90O
399  */
400 HWTEST_F(AccountIAMClientTest, AccountIAMClient_SetAuthSubType_0100, TestSize.Level0)
401 {
402     int32_t userId = 1111; // 1111: userId
403     int32_t type = 11;
404     EXPECT_EQ(0, AccountIAMClient::GetInstance().GetAuthSubType(userId));
405     AccountIAMClient::GetInstance().SetAuthSubType(userId, type);
406     EXPECT_EQ(type, AccountIAMClient::GetInstance().GetAuthSubType(userId));
407 
408     AccountIAMClient::GetInstance().SetAuthSubType(userId, type + 1);
409     EXPECT_EQ(type, AccountIAMClient::GetInstance().GetAuthSubType(userId));
410 
411     AccountIAMClient::GetInstance().ClearCredential(userId);
412 }
413 
414 /**
415  * @tc.name: IDMCallbackStub_OnRemoteRequest_0100
416  * @tc.desc: OnRemoteRequest with wrong message code.
417  * @tc.type: FUNC
418  * @tc.require:
419  */
420 HWTEST_F(AccountIAMClientTest, IDMCallbackStub_OnRemoteRequest_0100, TestSize.Level0)
421 {
422     MessageParcel data;
423     MessageParcel reply;
424     MessageOption option = {MessageOption::TF_SYNC};
425     data.WriteInterfaceToken(IDMCallbackStub::GetDescriptor());
426 
427     sptr<IDMCallbackStub> stub = new (std::nothrow) IDMCallbackService(TEST_USER_ID, nullptr);
428     ASSERT_NE(nullptr, stub);
429     int32_t ret = stub->OnRemoteRequest(INVALID_IPC_CODE, data, reply, option);
430     EXPECT_EQ(IPC_STUB_UNKNOW_TRANS_ERR, ret);
431 }
432 
433 /**
434  * @tc.name: IDMCallbackStub_ProcOnAcquireInfo_0100
435  * @tc.desc: ProcOnAcquireInfo.
436  * @tc.type: FUNC
437  * @tc.require:
438  */
439 HWTEST_F(AccountIAMClientTest, IDMCallbackStub_ProcOnAcquireInfo_0100, TestSize.Level0)
440 {
441     MessageParcel data;
442     MessageParcel reply;
443     MessageOption option = {MessageOption::TF_SYNC};
444 
445     int32_t module = 0;
446     int32_t acquireInfo = 0;
447     std::vector<uint8_t> buffer;
448     data.WriteInterfaceToken(IDMCallbackStub::GetDescriptor());
449     data.WriteInt32(module);
450     data.WriteInt32(acquireInfo);
451     data.WriteUInt8Vector(buffer);
452 
453     sptr<IDMCallbackStub> stub = new (std::nothrow) IDMCallbackService(TEST_USER_ID, nullptr);
454     ASSERT_NE(nullptr, stub);
455     int32_t ret = stub->OnRemoteRequest(static_cast<uint32_t>(IIDMCallback::Message::ON_ACQUIRE_INFO), data, reply,
456         option);
457     EXPECT_EQ(ERR_OK, ret);
458 }
459 
460 /**
461  * @tc.name: GetCredInfoCallbackStub_OnRemoteRequest_0100
462  * @tc.desc: OnRemoteRequest with wrong message code.
463  * @tc.type: FUNC
464  * @tc.require:
465  */
466 HWTEST_F(AccountIAMClientTest, GetCredInfoCallbackStub_OnRemoteRequest_0100, TestSize.Level0)
467 {
468     MessageParcel data;
469     MessageParcel reply;
470     MessageOption option = {MessageOption::TF_SYNC};
471     data.WriteInterfaceToken(GetCredInfoCallbackStub::GetDescriptor());
472 
473     sptr<GetCredInfoCallbackStub> stub = new (std::nothrow) GetCredInfoCallbackService(nullptr);
474     ASSERT_NE(nullptr, stub);
475     int32_t ret = stub->OnRemoteRequest(INVALID_IPC_CODE, data, reply, option);
476     EXPECT_EQ(IPC_STUB_UNKNOW_TRANS_ERR, ret);
477 }
478 
479 /**
480  * @tc.name: GetCredInfoCallbackStub_ProcOnCredentialInfo_0100
481  * @tc.desc: ProcOnCredentialInfo.
482  * @tc.type: FUNC
483  * @tc.require:
484  */
485 HWTEST_F(AccountIAMClientTest, GetCredInfoCallbackStub_ProcOnCredentialInfo_0100, TestSize.Level0)
486 {
487     MessageParcel data;
488     MessageParcel reply;
489     MessageOption option = {MessageOption::TF_SYNC};
490 
491     uint32_t vectorSize = 1;
492     CredentialInfo info;
493     std::vector<CredentialInfo> infoList = {info};
494     data.WriteInterfaceToken(GetCredInfoCallbackStub::GetDescriptor());
495     data.WriteUint32(vectorSize);
496     for (const auto &info : infoList) {
497         data.WriteUint64(info.credentialId);
498         data.WriteInt32(info.authType);
499         PinSubType pinType = info.pinType.value_or(PinSubType::PIN_MAX);
500         data.WriteInt32(pinType);
501         data.WriteUint64(info.templateId);
502     }
503 
504     sptr<GetCredInfoCallbackStub> stub = new (std::nothrow) GetCredInfoCallbackService(nullptr);
505     ASSERT_NE(nullptr, stub);
506     int32_t ret = stub->OnRemoteRequest(static_cast<uint32_t>(IGetCredInfoCallback::Message::ON_CREDENTIAL_INFO), data,
507         reply, option);
508     EXPECT_EQ(ERR_OK, ret);
509 }
510 
511 /**
512  * @tc.name: GetSetPropCallbackStub_OnRemoteRequest_0100
513  * @tc.desc: OnRemoteRequest with wrong message code.
514  * @tc.type: FUNC
515  * @tc.require:
516  */
517 HWTEST_F(AccountIAMClientTest, GetSetPropCallbackStub_OnRemoteRequest_0100, TestSize.Level0)
518 {
519     MessageParcel data;
520     MessageParcel reply;
521     MessageOption option = {MessageOption::TF_SYNC};
522     data.WriteInterfaceToken(GetSetPropCallbackStub::GetDescriptor());
523 
524     sptr<GetSetPropCallbackStub> stub = new (std::nothrow) GetSetPropCallbackService(nullptr);
525     ASSERT_NE(nullptr, stub);
526     int32_t ret = stub->OnRemoteRequest(INVALID_IPC_CODE, data, reply, option);
527     EXPECT_EQ(IPC_STUB_UNKNOW_TRANS_ERR, ret);
528 }
529 }  // namespace AccountTest
530 }  // namespace OHOS