• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #ifndef AUTH_COMMON_MOCK_H
17 #define AUTH_COMMON_MOCK_H
18 
19 #include <gmock/gmock.h>
20 #include <mutex>
21 #include <securec.h>
22 
23 #include "auth_common.h"
24 #include "auth_connection.h"
25 #include "auth_device_common_key.h"
26 #include "auth_hichain_adapter.h"
27 #include "auth_manager.h"
28 #include "device_auth.h"
29 #include "lnn_distributed_net_ledger.h"
30 #include "lnn_feature_capability.h"
31 #include "lnn_node_info.h"
32 #include "softbus_adapter_bt_common.h"
33 #include "softbus_config_type.h"
34 
35 namespace OHOS {
36 class AuthOtherInterface {
37 public:
AuthOtherInterface()38     AuthOtherInterface() {};
~AuthOtherInterface()39     virtual ~AuthOtherInterface() {};
40 
41     virtual int32_t RegHichainSaStatusListener(void) = 0;
42     virtual int32_t CustomizedSecurityProtocolInit(void) = 0;
43     virtual int32_t LnnGetTrustedDevInfoFromDb(char **udidArray, uint32_t *num) = 0;
44     virtual bool IsSameAccountGroupDevice(void) = 0;
45     virtual bool LnnIsDefaultOhosAccount() = 0;
46     virtual int32_t LnnGetLocalByteInfo(InfoKey key, uint8_t *info, uint32_t len) = 0;
47     virtual bool IsPotentialTrustedDevice(TrustedRelationIdType idType, const char *deviceId,
48         bool isPrecise, bool isPointToPoint) = 0;
49     virtual int32_t AuthFindLatestNormalizeKey(
50         const char *udidHash, AuthDeviceKeyInfo *deviceKey, bool clearOldKey) = 0;
51     virtual bool IsCloudSyncEnabled(void) = 0;
52     virtual bool IsFeatureSupport(uint64_t feature, FeatureCapability capaBit) = 0;
53     virtual int32_t SoftBusGenerateStrHash(const unsigned char *str, uint32_t len, unsigned char *hash) = 0;
54     virtual int32_t LnnGetRemoteNodeInfoByKey(const char *key, NodeInfo *info) = 0;
55     virtual int32_t LnnGetNetworkIdByUdidHash(
56         const uint8_t *udidHash, uint32_t udidHashLen, char *buf, uint32_t len, bool needOnline) = 0;
57     virtual int32_t LnnGetRemoteNodeInfoById(const char *id, IdCategory type, NodeInfo *info) = 0;
58     virtual int32_t ConvertBytesToHexString(
59         char *outBuf, uint32_t outBufLen, const unsigned char *inBuf, uint32_t inLen) = 0;
60     virtual int32_t LnnRetrieveDeviceInfoByNetworkId(const char *networkId, NodeInfo *info) = 0;
61     virtual int32_t SoftbusGetConfig(ConfigType type, unsigned char *val, uint32_t len) = 0;
62     virtual int32_t AuthDeviceInit(const AuthTransCallback *callback) = 0;
63     virtual int32_t AuthMetaInit(const AuthTransCallback *callback) = 0;
64     virtual int32_t AuthFindDeviceKey(const char *udidHash, int32_t keyType, AuthDeviceKeyInfo *deviceKey) = 0;
65     virtual AuthManager *GetAuthManagerByAuthId(int64_t authId) = 0;
66 };
67 class AuthOtherInterfaceMock : public AuthOtherInterface {
68 public:
69     AuthOtherInterfaceMock();
70     ~AuthOtherInterfaceMock() override;
71     MOCK_METHOD0(RegHichainSaStatusListener, int32_t (void));
72     MOCK_METHOD0(CustomizedSecurityProtocolInit, int32_t (void));
73     MOCK_METHOD2(LnnGetTrustedDevInfoFromDb, int32_t (char **, uint32_t *));
74     MOCK_METHOD0(IsSameAccountGroupDevice, bool (void));
75     MOCK_METHOD0(LnnIsDefaultOhosAccount, bool (void));
76     MOCK_METHOD3(LnnGetLocalByteInfo, int32_t (InfoKey, uint8_t *, uint32_t));
77     MOCK_METHOD4(IsPotentialTrustedDevice, bool (TrustedRelationIdType idType, const char *deviceId,
78         bool isPrecise, bool isPointToPoint));
79     MOCK_METHOD3(AuthFindLatestNormalizeKey, int32_t (const char *, AuthDeviceKeyInfo *, bool));
80     MOCK_METHOD0(IsCloudSyncEnabled, bool (void));
81     MOCK_METHOD2(IsFeatureSupport, bool (uint64_t, FeatureCapability));
82     MOCK_METHOD3(SoftBusGenerateStrHash, int32_t (const unsigned char *, uint32_t, unsigned char *));
83     MOCK_METHOD2(LnnGetRemoteNodeInfoByKey, int32_t (const char *, NodeInfo *));
84     MOCK_METHOD5(LnnGetNetworkIdByUdidHash, int32_t (const uint8_t *, uint32_t, char *, uint32_t, bool));
85     MOCK_METHOD3(LnnGetRemoteNodeInfoById, int32_t (const char *id, IdCategory type, NodeInfo *info));
86     MOCK_METHOD4(ConvertBytesToHexString, int32_t (char *, uint32_t, const unsigned char *, uint32_t));
87     MOCK_METHOD2(LnnRetrieveDeviceInfoByNetworkId, int32_t (const char *, NodeInfo *));
88     MOCK_METHOD3(SoftbusGetConfig, int32_t(ConfigType, unsigned char *, uint32_t));
89     MOCK_METHOD1(AuthDeviceInit, int32_t(const AuthTransCallback *));
90     MOCK_METHOD1(AuthMetaInit, int32_t(const AuthTransCallback *));
91     MOCK_METHOD3(AuthFindDeviceKey, int32_t (const char *, int32_t, AuthDeviceKeyInfo *));
92     MOCK_METHOD1(GetAuthManagerByAuthId, AuthManager *(int64_t));
93     static int32_t ActionOfLnnGetRemoteNodeInfoByKey(const char *key, NodeInfo *info);
94     static int32_t ActionOfLnnGetRemoteNodeInfoById(const char *id, IdCategory type, NodeInfo *info);
95 };
96 } // namespace OHOS
97 #endif // AUTH_COMMON_MOCK_H
98