blob: c15662feef828c61497eea10d3e9dd987274fdc1 [file] [log] [blame] [edit]
#include <cassert>
#include <memory>
#include <string>
#include "absl/status/status.h"
#include "absl/status/statusor.h"
#include "absl/strings/string_view.h"
#include "proxy_builder.h"
#include "proxy_config.pb.h"
#include "redfish_plugin.h"
#include "request_response.h"
namespace milotic {
// This is a plugin for tests that overrides all request URIs with the path to
// a fixed Redfish ID.
class TestPlugin : public RedfishPlugin {
public:
explicit TestPlugin(const milotic_grpc_proxy::Plugin::Test& config)
: id_(config.fixed_redfish_id()) {}
RequestAction PreprocessRequest(RedfishPlugin::RequestVerb verb,
ProxyRequest& request) override {
request.SetPath(id_);
return RequestAction::kNext;
}
absl::StatusOr<ProxyResponse> HandleRequest(
RedfishPlugin::RequestVerb verb,
std::unique_ptr<ProxyRequest> request) override {
return absl::UnknownError("Should not be called");
}
absl::Status Subscribe(std::unique_ptr<ProxyRequest> request,
EventHandler* /*handler*/) override {
return absl::UnknownError("Should not be called");
}
absl::Status Initialize(Proxy* proxy) override { return absl::OkStatus(); };
private:
std::string id_;
};
REGISTER_REDFISH_PLUGIN(test, TestPlugin);
// This is a plugin for tests that does nothing.
class TestDummyPlugin : public RedfishPlugin {
public:
explicit TestDummyPlugin(
const milotic_grpc_proxy::Plugin::TestDummy& /*config*/) {}
RequestAction PreprocessRequest(RedfishPlugin::RequestVerb verb,
ProxyRequest& request) override {
assert(false);
return RequestAction{};
}
absl::StatusOr<ProxyResponse> HandleRequest(
RedfishPlugin::RequestVerb verb,
std::unique_ptr<ProxyRequest> request) override {
assert(false);
return absl::UnknownError("Should not be called");
}
absl::Status Subscribe(std::unique_ptr<ProxyRequest> request,
EventHandler* /*handler*/) override {
assert(false);
return absl::UnknownError("Should not be called");
}
absl::Status Initialize(Proxy* /*proxy*/) override {
assert(false);
return absl::UnknownError("Should not be called");
}
};
REGISTER_REDFISH_PLUGIN(test_do_not_use, TestDummyPlugin);
} // namespace milotic