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

Windows compilation: Ensure thrift_proxy tests/mocks do not fail to compile with missing Validate method on google::protobuf::Struct #10780

Merged
merged 4 commits into from
Apr 16, 2020
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
13 changes: 6 additions & 7 deletions test/extensions/filters/network/thrift_proxy/mocks.cc
Original file line number Diff line number Diff line change
Expand Up @@ -92,22 +92,21 @@ MockDecoderFilterCallbacks::MockDecoderFilterCallbacks() {
}
MockDecoderFilterCallbacks::~MockDecoderFilterCallbacks() = default;

MockFilterConfigFactory::MockFilterConfigFactory()
: FactoryBase("envoy.filters.thrift.mock_filter") {
MockFilterConfigFactory::MockFilterConfigFactory() : name_("envoy.filters.thrift.mock_filter") {
mock_filter_ = std::make_shared<NiceMock<MockDecoderFilter>>();
}

MockFilterConfigFactory::~MockFilterConfigFactory() = default;

FilterFactoryCb MockFilterConfigFactory::createFilterFactoryFromProtoTyped(
const ProtobufWkt::Struct& proto_config, const std::string& stat_prefix,
FilterFactoryCb MockFilterConfigFactory::createFilterFactoryFromProto(
const Protobuf::Message& proto_config, const std::string& stats_prefix,
Server::Configuration::FactoryContext& context) {
UNREFERENCED_PARAMETER(context);

config_struct_ = proto_config;
config_stat_prefix_ = stat_prefix;
config_struct_ = dynamic_cast<const ProtobufWkt::Struct&>(proto_config);
config_stat_prefix_ = stats_prefix;

return [this](ThriftFilters::FilterChainFactoryCallbacks& callbacks) -> void {
return [this](FilterChainFactoryCallbacks& callbacks) -> void {
callbacks.addDecoderFilter(mock_filter_);
};
}
Expand Down
21 changes: 15 additions & 6 deletions test/extensions/filters/network/thrift_proxy/mocks.h
Original file line number Diff line number Diff line change
Expand Up @@ -258,19 +258,28 @@ class MockDecoderFilterCallbacks : public DecoderFilterCallbacks {
std::shared_ptr<Router::MockRoute> route_;
};

class MockFilterConfigFactory : public ThriftFilters::FactoryBase<ProtobufWkt::Struct> {
class MockFilterConfigFactory : public NamedThriftFilterConfigFactory {
public:
MockFilterConfigFactory();
~MockFilterConfigFactory() override;

ThriftFilters::FilterFactoryCb
createFilterFactoryFromProtoTyped(const ProtobufWkt::Struct& proto_config,
const std::string& stat_prefix,
Server::Configuration::FactoryContext& context) override;
FilterFactoryCb
createFilterFactoryFromProto(const Protobuf::Message& proto_config,
const std::string& stats_prefix,
Server::Configuration::FactoryContext& context) override;

ProtobufTypes::MessagePtr createEmptyConfigProto() override {
return std::make_unique<ProtobufWkt::Struct>();
}

std::string name() const override { return name_; }

std::shared_ptr<MockDecoderFilter> mock_filter_;
ProtobufWkt::Struct config_struct_;
std::string config_stat_prefix_;

private:
std::shared_ptr<MockDecoderFilter> mock_filter_;
const std::string name_;
};

} // namespace ThriftFilters
Expand Down