1 /*
2 * Copyright (c) 2025 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 "auth_apply_key_process_mock.h"
17
18 using namespace testing;
19 using namespace testing::ext;
20
21 namespace OHOS {
22
23 void *g_applyKeyProcMockInterface;
AuthApplyKeyProcessInterfaceMock()24 AuthApplyKeyProcessInterfaceMock::AuthApplyKeyProcessInterfaceMock()
25 {
26 g_applyKeyProcMockInterface = reinterpret_cast<void *>(this);
27 }
28
~AuthApplyKeyProcessInterfaceMock()29 AuthApplyKeyProcessInterfaceMock::~AuthApplyKeyProcessInterfaceMock()
30 {
31 g_applyKeyProcMockInterface = nullptr;
32 }
33
AuthApplyKeyProcessInterfaceMock()34 static AuthApplyKeyProcessInterface *AuthApplyKeyProcessInterfaceMock()
35 {
36 return reinterpret_cast<AuthApplyKeyProcessInterface *>(g_applyKeyProcMockInterface);
37 }
38
39 extern "C" {
LnnAsyncCallbackDelayHelper(SoftBusLooper * looper,LnnAsyncCallbackFunc callback,void * para,uint64_t delayMillis)40 int32_t LnnAsyncCallbackDelayHelper(
41 SoftBusLooper *looper, LnnAsyncCallbackFunc callback, void *para, uint64_t delayMillis)
42 {
43 return AuthApplyKeyProcessInterfaceMock()->LnnAsyncCallbackDelayHelper(looper, callback, para, delayMillis);
44 }
45
LnnGetLocalStrInfo(InfoKey key,char * info,uint32_t len)46 int32_t LnnGetLocalStrInfo(InfoKey key, char *info, uint32_t len)
47 {
48 return AuthApplyKeyProcessInterfaceMock()->LnnGetLocalStrInfo(key, info, len);
49 }
50
SoftBusGenerateStrHash(const unsigned char * str,uint32_t len,unsigned char * hash)51 int32_t SoftBusGenerateStrHash(const unsigned char *str, uint32_t len, unsigned char *hash)
52 {
53 return AuthApplyKeyProcessInterfaceMock()->SoftBusGenerateStrHash(str, len, hash);
54 }
55
56
LnnGetLocalByteInfo(InfoKey key,uint8_t * info,uint32_t len)57 int32_t LnnGetLocalByteInfo(InfoKey key, uint8_t *info, uint32_t len)
58 {
59 return AuthApplyKeyProcessInterfaceMock()->LnnGetLocalByteInfo(key, info, len);
60 }
61
AddStringToJsonObject(cJSON * json,const char * const string,const char * value)62 bool AddStringToJsonObject(cJSON *json, const char *const string, const char *value)
63 {
64 return AuthApplyKeyProcessInterfaceMock()->AddStringToJsonObject(json, string, value);
65 }
66
AddNumberToJsonObject(cJSON * json,const char * const string,int num)67 bool AddNumberToJsonObject(cJSON *json, const char * const string, int num)
68 {
69 return AuthApplyKeyProcessInterfaceMock()->AddNumberToJsonObject(json, string, num);
70 }
71
ConnGetHeadSize(void)72 uint32_t ConnGetHeadSize(void)
73 {
74 return AuthApplyKeyProcessInterfaceMock()->ConnGetHeadSize();
75 }
76
GetAuthDataSize(uint32_t len)77 uint32_t GetAuthDataSize(uint32_t len)
78 {
79 return AuthApplyKeyProcessInterfaceMock()->GetAuthDataSize(len);
80 }
81
PackAuthData(const AuthDataHead * head,const uint8_t * data,uint8_t * buf,uint32_t size)82 int32_t PackAuthData(const AuthDataHead *head, const uint8_t *data,
83 uint8_t *buf, uint32_t size)
84 {
85 return AuthApplyKeyProcessInterfaceMock()->PackAuthData(head, data, buf, size);
86 }
87
GenSeq(bool isServer)88 int64_t GenSeq(bool isServer)
89 {
90 return 0;
91 }
92
GetApplyKeyByBusinessInfo(const RequestBusinessInfo * info,uint8_t * uk,uint32_t ukLen,char * accountHash,uint32_t accountHashLen)93 int32_t GetApplyKeyByBusinessInfo(
94 const RequestBusinessInfo *info, uint8_t *uk, uint32_t ukLen, char *accountHash, uint32_t accountHashLen)
95 {
96 return AuthApplyKeyProcessInterfaceMock()->GetApplyKeyByBusinessInfo(info, uk, ukLen, accountHash, accountHashLen);
97 }
98
UnpackAuthData(const uint8_t * data,uint32_t len,AuthDataHead * head)99 const uint8_t *UnpackAuthData(const uint8_t *data, uint32_t len, AuthDataHead *head)
100 {
101 return AuthApplyKeyProcessInterfaceMock()->UnpackAuthData(data, len, head);
102 }
103
cJSON_Delete(cJSON * item)104 void cJSON_Delete(cJSON* item)
105 {
106 (void)item;
107 return;
108 }
109
GetJsonObjectStringItem(const cJSON * json,const char * const string,char * target,uint32_t targetLen)110 bool GetJsonObjectStringItem(const cJSON *json, const char * const string, char *target, uint32_t targetLen)
111 {
112 return AuthApplyKeyProcessInterfaceMock()->GetJsonObjectStringItem(json, string, target, targetLen);
113 }
114
GetJsonObjectNumberItem(const cJSON * json,const char * const string,int32_t * target)115 bool GetJsonObjectNumberItem(const cJSON *json, const char * const string, int32_t *target)
116 {
117 return AuthApplyKeyProcessInterfaceMock()->GetJsonObjectNumberItem(json, string, target);
118 }
119
InitDeviceAuthService()120 int32_t InitDeviceAuthService()
121 {
122 return AuthApplyKeyProcessInterfaceMock()->InitDeviceAuthService();
123 }
124
GetLightAccountVerifierInstance(void)125 const LightAccountVerifier *GetLightAccountVerifierInstance(void)
126 {
127 return AuthApplyKeyProcessInterfaceMock()->GetLightAccountVerifierInstance();
128 }
129
GetActiveOsAccountIds(void)130 int32_t GetActiveOsAccountIds(void)
131 {
132 return 0;
133 }
134
GetSoftbusHichainAuthErrorCode(uint32_t hichainErrCode,uint32_t * softbusErrCode)135 void GetSoftbusHichainAuthErrorCode(uint32_t hichainErrCode, uint32_t *softbusErrCode)
136 {
137 *softbusErrCode = hichainErrCode;
138 return;
139 }
140
ConnSetConnectCallback(ConnModule moduleId,const ConnectCallback * callback)141 int32_t ConnSetConnectCallback(ConnModule moduleId, const ConnectCallback *callback)
142 {
143 return AuthApplyKeyProcessInterfaceMock()->ConnSetConnectCallback(moduleId, callback);
144 }
145
AuthInsertApplyKey(const RequestBusinessInfo * info,const uint8_t * uk,uint32_t ukLen,uint64_t time,char * accountHash)146 int32_t AuthInsertApplyKey(const RequestBusinessInfo *info, const uint8_t *uk, uint32_t ukLen,
147 uint64_t time, char *accountHash)
148 {
149 return AuthApplyKeyProcessInterfaceMock()->AuthInsertApplyKey(info, uk, ukLen, time, accountHash);
150 }
151
GetAuthSideStr(bool isServer)152 const char *GetAuthSideStr(bool isServer)
153 {
154 return AuthApplyKeyProcessInterfaceMock()->GetAuthSideStr(isServer);
155 }
156
ConnPostBytes(uint32_t connectionId,ConnPostData * data)157 int32_t ConnPostBytes(uint32_t connectionId, ConnPostData *data)
158 {
159 return AuthApplyKeyProcessInterfaceMock()->ConnPostBytes(connectionId, data);
160 }
161
162 } // extern "C"
163 } // namespace OHOS