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_DEVICE_PROFILE_MOCK_H 17 #define AUTH_DEVICE_PROFILE_MOCK_H 18 19 #include <gmock/gmock.h> 20 21 #include "auth_device_profile_listener.h" 22 #include "auth_identity_service_adapter.h" 23 #include "auth_log.h" 24 #include "auth_uk_manager.h" 25 #include "auth_user_common_key.h" 26 #include "bus_center_info_key.h" 27 #include "device_profile_listener.h" 28 #include "softbus_adapter_file.h" 29 30 namespace OHOS { 31 class AuthDeviceProfileInterface { 32 public: AuthDeviceProfileInterface()33 AuthDeviceProfileInterface() {}; ~AuthDeviceProfileInterface()34 virtual ~AuthDeviceProfileInterface() {}; 35 36 virtual int32_t GetActiveOsAccountIds(void) = 0; 37 virtual int32_t LnnGetLocalNum64Info(InfoKey key, int64_t *info) = 0; 38 virtual bool LnnIsDefaultOhosAccount(void) = 0; 39 virtual int32_t LnnGetLocalStrInfo(InfoKey key, char *info, uint32_t len) = 0; 40 virtual bool AuthIsUkExpired(uint64_t time) = 0; 41 virtual int32_t AuthInsertUserKey(const AuthACLInfo *aclInfo, const AuthUserKeyInfo *userKeyInfo, 42 bool isUserBindLevel) = 0; 43 virtual uint64_t SoftBusGetSysTimeMs(void) = 0; 44 virtual int32_t SoftBusGenerateStrHash(const unsigned char *str, uint32_t len, unsigned char *hash) = 0; 45 virtual int32_t ConvertBytesToHexString(char *outBuf, uint32_t outBufLen, const unsigned char *inBuf, 46 uint32_t inLen) = 0; 47 virtual int32_t LnnGetLocalByteInfo(InfoKey key, uint8_t *info, uint32_t len) = 0; 48 virtual int32_t IdServiceGetCredInfoByUdid(const char *udid, SoftBusCredInfo *credInfo); 49 virtual int32_t RegisterToDp(DeviceProfileChangeListener *deviceProfilePara) = 0; 50 virtual int32_t GetUserKeyByUkId(int32_t sessionKeyId, uint8_t *uk, uint32_t ukLen) = 0; 51 virtual int32_t CheckAclInfoIsAccesser(const AuthACLInfo *acl, bool *isAccesser) = 0; 52 }; 53 54 class AuthDeviceProfileInterfaceMock : public AuthDeviceProfileInterface { 55 public: 56 AuthDeviceProfileInterfaceMock(); 57 ~AuthDeviceProfileInterfaceMock() override; 58 59 MOCK_METHOD0(GetActiveOsAccountIds, int32_t (void)); 60 MOCK_METHOD2(LnnGetLocalNum64Info, int32_t (InfoKey, int64_t *)); 61 MOCK_METHOD0(LnnIsDefaultOhosAccount, bool (void)); 62 MOCK_METHOD3(LnnGetLocalStrInfo, int32_t (InfoKey, char *, uint32_t)); 63 MOCK_METHOD1(AuthIsUkExpired, bool (uint64_t)); 64 MOCK_METHOD3(AuthInsertUserKey, int32_t (const AuthACLInfo *, const AuthUserKeyInfo *, bool)); 65 MOCK_METHOD0(SoftBusGetSysTimeMs, uint64_t (void)); 66 MOCK_METHOD3(SoftBusGenerateStrHash, int32_t (const unsigned char *, uint32_t, unsigned char *)); 67 MOCK_METHOD4(ConvertBytesToHexString, int32_t (char *, uint32_t, const unsigned char *, uint32_t inLen)); 68 MOCK_METHOD3(LnnGetLocalByteInfo, int32_t (InfoKey, uint8_t *, uint32_t)); 69 MOCK_METHOD2(IdServiceGetCredInfoByUdid, int32_t(const char *, SoftBusCredInfo *)); 70 MOCK_METHOD1(RegisterToDp, int32_t (DeviceProfileChangeListener *)); 71 MOCK_METHOD3(GetUserKeyByUkId, int32_t (int32_t, uint8_t *, uint32_t)); 72 MOCK_METHOD2(CheckAclInfoIsAccesser, int32_t(const AuthACLInfo *, bool *)); 73 }; 74 } // namespace OHOS 75 #endif