• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2024 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_hichain_deps_mock.h"
17 
18 using namespace testing;
19 using namespace testing::ext;
20 
21 namespace OHOS {
22 void *g_hichainMockInterface;
AuthHichainInterfaceMock()23 AuthHichainInterfaceMock::AuthHichainInterfaceMock()
24 {
25     g_hichainMockInterface = reinterpret_cast<void *>(this);
26 }
27 
~AuthHichainInterfaceMock()28 AuthHichainInterfaceMock::~AuthHichainInterfaceMock()
29 {
30     g_hichainMockInterface = nullptr;
31 }
32 
GetAuthHichainMockInterface()33 static AuthHichainInterface *GetAuthHichainMockInterface()
34 {
35     return reinterpret_cast<AuthHichainInterfaceMock *>(g_hichainMockInterface);
36 }
37 
38 extern "C" {
cJSON_CreateObject()39 cJSON *cJSON_CreateObject()
40 {
41     return GetAuthHichainMockInterface()->cJSON_CreateObject();
42 }
43 
AddStringToJsonObject(cJSON * json,const char * const string,const char * value)44 bool AddStringToJsonObject(cJSON *json, const char * const string, const char *value)
45 {
46     return GetAuthHichainMockInterface()->AddStringToJsonObject(json, string, value);
47 }
48 
AddBoolToJsonObject(cJSON * json,const char * const string,bool value)49 bool AddBoolToJsonObject(cJSON *json, const char * const string, bool value)
50 {
51     return GetAuthHichainMockInterface()->AddBoolToJsonObject(json, string, value);
52 }
53 
AddNumberToJsonObject(cJSON * json,const char * const string,int32_t num)54 bool AddNumberToJsonObject(cJSON *json, const char * const string, int32_t num)
55 {
56     return GetAuthHichainMockInterface()->AddNumberToJsonObject(json, string, num);
57 }
58 
cJSON_PrintUnformatted(const cJSON * json)59 char *cJSON_PrintUnformatted(const cJSON *json)
60 {
61     return GetAuthHichainMockInterface()->cJSON_PrintUnformatted(json);
62 }
63 
AuthSessionPostAuthData(int64_t authSeq,const uint8_t * data,uint32_t len)64 int32_t AuthSessionPostAuthData(int64_t authSeq, const uint8_t *data, uint32_t len)
65 {
66     return GetAuthHichainMockInterface()->AuthSessionPostAuthData(authSeq, data, len);
67 }
68 
LnnEventExtraInit(LnnEventExtra * extra)69 void LnnEventExtraInit(LnnEventExtra *extra)
70 {
71     return GetAuthHichainMockInterface()->LnnEventExtraInit(extra);
72 }
73 
GetLnnTriggerInfo(LnnTriggerInfo * triggerInfo)74 void GetLnnTriggerInfo(LnnTriggerInfo *triggerInfo)
75 {
76     return GetAuthHichainMockInterface()->GetLnnTriggerInfo(triggerInfo);
77 }
78 
SoftBusGetSysTimeMs(void)79 uint64_t SoftBusGetSysTimeMs(void)
80 {
81     return GetAuthHichainMockInterface()->SoftBusGetSysTimeMs();
82 }
83 
GetAuthFsmByAuthSeq(int64_t authSeq)84 AuthFsm *GetAuthFsmByAuthSeq(int64_t authSeq)
85 {
86     return GetAuthHichainMockInterface()->GetAuthFsmByAuthSeq(authSeq);
87 }
88 
ReleaseAuthLock(void)89 void ReleaseAuthLock(void)
90 {
91     return GetAuthHichainMockInterface()->ReleaseAuthLock();
92 }
93 
AuthSessionSaveSessionKey(int64_t authSeq,const uint8_t * key,uint32_t len)94 int32_t AuthSessionSaveSessionKey(int64_t authSeq, const uint8_t *key, uint32_t len)
95 {
96     return GetAuthHichainMockInterface()->AuthSessionSaveSessionKey(authSeq, key, len);
97 }
98 
AuthSessionHandleAuthFinish(int64_t authSeq)99 int32_t AuthSessionHandleAuthFinish(int64_t authSeq)
100 {
101     return GetAuthHichainMockInterface()->AuthSessionHandleAuthFinish(authSeq);
102 }
103 
GetAuthSideStr(bool isServer)104 const char *GetAuthSideStr(bool isServer)
105 {
106     return GetAuthHichainMockInterface()->GetAuthSideStr(isServer);
107 }
108 
AuthFailNotifyProofInfo(int32_t errCode,const char * errorReturn,uint32_t errorReturnLen)109 int32_t AuthFailNotifyProofInfo(int32_t errCode, const char *errorReturn, uint32_t errorReturnLen)
110 {
111     return GetAuthHichainMockInterface()->AuthFailNotifyProofInfo(errCode, errorReturn, errorReturnLen);
112 }
113 
LnnAsyncCallbackDelayHelper(SoftBusLooper * looper,LnnAsyncCallbackFunc callback,void * para,uint64_t delayMillis)114 int32_t LnnAsyncCallbackDelayHelper(SoftBusLooper *looper, LnnAsyncCallbackFunc callback,
115     void *para, uint64_t delayMillis)
116 {
117     return GetAuthHichainMockInterface()->LnnAsyncCallbackDelayHelper(looper, callback, para, delayMillis);
118 }
119 
AuthSessionHandleAuthError(int64_t authSeq,int32_t reason)120 int32_t AuthSessionHandleAuthError(int64_t authSeq, int32_t reason)
121 {
122     return GetAuthHichainMockInterface()->AuthSessionHandleAuthError(authSeq, reason);
123 }
124 
AuthSessionGetUdid(int64_t authSeq,char * udid,uint32_t size)125 int32_t AuthSessionGetUdid(int64_t authSeq, char *udid, uint32_t size)
126 {
127     return GetAuthHichainMockInterface()->AuthSessionGetUdid(authSeq, udid, size);
128 }
129 
LnnGetLocalStrInfo(InfoKey key,char * info,uint32_t len)130 int32_t LnnGetLocalStrInfo(InfoKey key, char *info, uint32_t len)
131 {
132     return GetAuthHichainMockInterface()->LnnGetLocalStrInfo(key, info, len);
133 }
134 
SoftBusGenerateStrHash(const unsigned char * str,uint32_t len,unsigned char * hash)135 int32_t SoftBusGenerateStrHash(const unsigned char *str, uint32_t len, unsigned char *hash)
136 {
137     return GetAuthHichainMockInterface()->SoftBusGenerateStrHash(str, len, hash);
138 }
139 
ConvertBytesToHexString(char * outBuf,uint32_t outBufLen,const unsigned char * inBuf,uint32_t inLen)140 int32_t ConvertBytesToHexString(char *outBuf, uint32_t outBufLen,
141     const unsigned char *inBuf, uint32_t inLen)
142 {
143     return GetAuthHichainMockInterface()->ConvertBytesToHexString(outBuf, outBufLen, inBuf, inLen);
144 }
145 
GetNodeFromPcRestrictMap(const char * udidHash,uint32_t * count)146 int32_t GetNodeFromPcRestrictMap(const char *udidHash, uint32_t *count)
147 {
148     return GetAuthHichainMockInterface()->GetNodeFromPcRestrictMap(udidHash, count);
149 }
150 
DeleteNodeFromPcRestrictMap(const char * udidHash)151 void DeleteNodeFromPcRestrictMap(const char *udidHash)
152 {
153     return GetAuthHichainMockInterface()->DeleteNodeFromPcRestrictMap(udidHash);
154 }
155 
GetJsonObjectStringItem(const cJSON * json,const char * const string,char * target,uint32_t targetLen)156 bool GetJsonObjectStringItem(const cJSON *json, const char * const string, char *target, uint32_t targetLen)
157 {
158     return GetAuthHichainMockInterface()->GetJsonObjectStringItem(json, string, target, targetLen);
159 }
160 
GetJsonObjectNumberItem(const cJSON * json,const char * const string,int32_t * target)161 bool GetJsonObjectNumberItem(const cJSON *json, const char * const string, int32_t *target)
162 {
163     return GetAuthHichainMockInterface()->GetJsonObjectNumberItem(json, string, target);
164 }
165 
UnregChangeListener(const char * appId)166 int32_t UnregChangeListener(const char *appId)
167 {
168     return GetAuthHichainMockInterface()->UnregChangeListener(appId);
169 }
170 
AuthDevice(int64_t authReqId,const char * authParams,const DeviceAuthCallback * cb)171 int32_t AuthDevice(int64_t authReqId, const char *authParams, const DeviceAuthCallback *cb)
172 {
173     return GetAuthHichainMockInterface()->AuthDevice(authReqId, authParams, cb);
174 }
175 
ProcessAuthData(int64_t authSeq,const uint8_t * data,uint32_t len,DeviceAuthCallback * cb)176 int32_t ProcessAuthData(int64_t authSeq, const uint8_t *data, uint32_t len, DeviceAuthCallback *cb)
177 {
178     return GetAuthHichainMockInterface()->ProcessAuthData(authSeq, data, len, cb);
179 }
180 
DestroyDeviceAuth(void)181 void DestroyDeviceAuth(void)
182 {
183     return GetAuthHichainMockInterface()->DestroyDeviceAuth();
184 }
185 
RequireAuthLock(void)186 bool RequireAuthLock(void)
187 {
188     return GetAuthHichainMockInterface()->RequireAuthLock();
189 }
190 } // extern "C"
191 } // namespace OHOS
192