blob: fd344bf29ca1b78f3eee23a967534daa8049ce17 [file] [log] [blame]
Manojkiran Edaacd6dd52019-10-15 15:00:51 +05301#pragma once
William A. Kennington III9ecb90e2022-10-14 03:12:43 -07002#include "config_parser.hpp"
Manojkiran Edaacd6dd52019-10-15 15:00:51 +05303#include "mock_ethernet_interface.hpp"
Ratan Gupta35297172018-11-28 18:40:16 +05304#include "network_manager.hpp"
William A. Kennington III2e09d272022-10-14 17:15:00 -07005#include "system_queries.hpp"
Ratan Gupta35297172018-11-28 18:40:16 +05306
7#include <gmock/gmock.h>
8
9namespace phosphor
10{
11namespace network
12{
13
Manojkiran Eda1b5ec9c2020-06-13 15:29:28 +053014void initializeTimers();
15void refreshObjects();
16
William A. Kennington IIIdd9ef812022-10-05 02:08:02 -070017class MockManager : public Manager
Ratan Gupta35297172018-11-28 18:40:16 +053018{
19 public:
Patrick Williamsc38b0712022-07-22 19:26:54 -050020 MockManager(sdbusplus::bus_t& bus, const char* path,
Ratan Gupta35297172018-11-28 18:40:16 +053021 const std::string& dir) :
William A. Kennington IIIdd9ef812022-10-05 02:08:02 -070022 Manager(bus, path, dir)
Ratan Gupta35297172018-11-28 18:40:16 +053023 {
24 }
25
Manojkiran Edaacd6dd52019-10-15 15:00:51 +053026 void createInterfaces() override
27 {
Manojkiran Edaacd6dd52019-10-15 15:00:51 +053028 interfaces.clear();
William A. Kennington IIIfd862be2022-10-09 18:40:55 -070029 for (auto& interface : system::getInterfaces())
Manojkiran Edaacd6dd52019-10-15 15:00:51 +053030 {
William A. Kennington IIIfd862be2022-10-09 18:40:55 -070031 config::Parser config(
32 config::pathForIntfConf(confDir, *interface.name));
William A. Kennington IIIdd9ef812022-10-05 02:08:02 -070033 auto intf = std::make_unique<MockEthernetInterface>(
William A. Kennington IIIfd862be2022-10-09 18:40:55 -070034 bus, *this, interface, objectPath, config);
Manojkiran Edaacd6dd52019-10-15 15:00:51 +053035 intf->createIPAddressObjects();
36 intf->createStaticNeighborObjects();
William A. Kennington IIIa520a392022-08-08 12:17:34 -070037 intf->loadNameServers(config);
Manojkiran Edaacd6dd52019-10-15 15:00:51 +053038 this->interfaces.emplace(
William A. Kennington IIIfd862be2022-10-09 18:40:55 -070039 std::make_pair(std::move(*interface.name), std::move(intf)));
Manojkiran Edaacd6dd52019-10-15 15:00:51 +053040 }
41 }
William A. Kennington III4717d932021-10-08 18:28:23 -070042
William A. Kennington III56ecc782021-10-07 18:44:50 -070043 MOCK_METHOD(void, reloadConfigs, (), (override));
William A. Kennington III85dc57a2022-11-07 16:53:24 -080044 MOCK_METHOD(void, reloadConfigsNoRefresh, (), (override));
Ratan Gupta35297172018-11-28 18:40:16 +053045};
46
47} // namespace network
48} // namespace phosphor