• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022-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 #ifndef OHOS_DM_AUTH_MANAGER_FIRST_TEST_H
17 #define OHOS_DM_AUTH_MANAGER_FIRST_TEST_H
18 
19 #include <gmock/gmock.h>
20 #include <gtest/gtest.h>
21 #include <map>
22 #include <string>
23 
24 #include "authentication.h"
25 #include "softbus_session.h"
26 #include "device_manager_service_listener.h"
27 #include "dm_adapter_manager.h"
28 #include "dm_constants.h"
29 #include "softbus_connector.h"
30 #include "hichain_connector.h"
31 #include "auth_request_state.h"
32 #include "auth_response_state.h"
33 #include "auth_message_processor.h"
34 #include "dm_timer.h"
35 #include "dm_auth_manager.h"
36 #include "softbus_session_mock.h"
37 #include "app_manager_mock.h"
38 #include "dm_crypto_mock.h"
39 #include "deviceprofile_connector_mock.h"
40 #include "hichain_auth_connector_mock.h"
41 #include "multiple_user_connector_mock.h"
42 #include "crypto_mgr_mock.h"
43 
44 namespace OHOS {
45 namespace DistributedHardware {
46 class DmAuthManagerTest : public testing::Test {
47 public:
48     static void SetUpTestCase();
49     static void TearDownTestCase();
50     void SetUp();
51     void TearDown();
52 
53     std::shared_ptr<SoftbusConnector> softbusConnector = std::make_shared<SoftbusConnector>();
54     std::shared_ptr<DeviceManagerServiceListener> listener = std::make_shared<DeviceManagerServiceListener>();
55     std::shared_ptr<HiChainConnector> hiChainConnector = std::make_shared<HiChainConnector>();
56     std::shared_ptr<HiChainAuthConnector> hiChainAuthConnector = std::make_shared<HiChainAuthConnector>();
57 
58     std::shared_ptr<DmAuthManager> authManager_ =
59         std::make_shared<DmAuthManager>(softbusConnector, hiChainConnector, listener, hiChainAuthConnector);
60     static inline std::shared_ptr<SoftbusSessionMock> softbusSessionMock_ = nullptr;
61     static inline std::shared_ptr<AppManagerMock> appManagerMock_ = nullptr;
62     static inline std::shared_ptr<CryptoMock> cryptoMock_ = nullptr;
63     static inline std::shared_ptr<DeviceProfileConnectorMock> deviceProfileConnectorMock_ = nullptr;
64     static inline std::shared_ptr<HiChainAuthConnectorMock> hiChainAuthConnectorMock_ = nullptr;
65     static inline std::shared_ptr<MultipleUserConnectorMock> multipleUserConnectorMock_ = nullptr;
66     static inline std::shared_ptr<CryptoMgrMock> cryptoMgrMock_ = nullptr;
67 };
68 
69 class AuthRequestFinishStateMock : public AuthRequestFinishState {
70 public:
71     MOCK_METHOD(int32_t, GetStateType, (), (override));
72 };
73 
74 class AuthRequestInitStateMock : public AuthRequestInitState {
75 public:
76     MOCK_METHOD(int32_t, GetStateType, (), (override));
77 };
78 
79 class AuthResponseInitStateMock : public AuthResponseInitState {
80 public:
81     MOCK_METHOD(int32_t, GetStateType, (), (override));
82 };
83 } // namespace DistributedHardware
84 } // namespace OHOS
85 #endif
86