Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

filters: Add test/server:filter_config_test #14746

Merged
merged 8 commits into from
Jan 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions test/server/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,16 @@ envoy_cc_test(
],
)

envoy_cc_test(
name = "filter_config_test",
srcs = ["filter_config_test.cc"],
deps = [
"//include/envoy/server:filter_config_interface",
"//source/extensions/filters/http/common:pass_through_filter_lib",
"//test/mocks/server:server_mocks",
],
)

envoy_cc_test(
name = "hot_restart_impl_test",
srcs = envoy_select_hot_restart(["hot_restart_impl_test.cc"]),
Expand Down
42 changes: 42 additions & 0 deletions test/server/filter_config_test.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#include "envoy/server/filter_config.h"

#include "extensions/filters/http/common/pass_through_filter.h"

#include "test/mocks/server/factory_context.h"

#include "gmock/gmock.h"
#include "gtest/gtest.h"

namespace Envoy {
namespace {

class TestHttpFilterConfigFactory : public Server::Configuration::NamedHttpFilterConfigFactory {
public:
TestHttpFilterConfigFactory() = default;

Http::FilterFactoryCb
createFilterFactoryFromProto(const Protobuf::Message&, const std::string&,
Server::Configuration::FactoryContext&) override {
return [](Http::FilterChainFactoryCallbacks& callbacks) -> void {
callbacks.addStreamDecoderFilter(std::make_shared<Http::PassThroughDecoderFilter>());
};
}

ProtobufTypes::MessagePtr createEmptyConfigProto() override { return nullptr; }
ProtobufTypes::MessagePtr createEmptyProtocolOptionsProto() override { return nullptr; }

std::string name() const override { return "envoy.test.http_filter"; }
std::string configType() override { return ""; };
};

TEST(NamedHttpFilterConfigFactoryTest, CreateFilterFactory) {
TestHttpFilterConfigFactory factory;
const std::string stats_prefix = "foo";
Server::Configuration::MockFactoryContext context;
ProtobufTypes::MessagePtr message{new Envoy::ProtobufWkt::Struct()};

factory.createFilterFactoryFromProto(*message, stats_prefix, context);
}

} // namespace
} // namespace Envoy