forked from envoyproxy/envoy
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
filters: Add test/server:filter_config_test (envoyproxy#14746)
As part of envoyproxy#14470, I'll be modifying the base filter interface to include an overridable dependencies() function. This is prep work. Risk Level: Low (test only) Doc Change: n/a Release Notes: n/a Signed-off-by: Auni Ahsan <[email protected]>
- Loading branch information
Showing
2 changed files
with
52 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |