Skip to content

Commit

Permalink
Fix ext_proc fuzzer test issues. (#27619)
Browse files Browse the repository at this point in the history
* Fix ext_proc fuzzer test issues.

Signed-off-by: Yanjun Xiang <[email protected]>
  • Loading branch information
yanjunxiang-google authored May 26, 2023
1 parent 92be7e1 commit 0e82260
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 4 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,18 @@ namespace UnitTestFuzz {

class FuzzerMocks {
public:
FuzzerMocks() : addr_(std::make_shared<Network::Address::PipeInstance>("/test/test.sock")) {
FuzzerMocks()
: addr_(std::make_shared<Network::Address::PipeInstance>("/test/test.sock")), buffer_("foo") {
ON_CALL(decoder_callbacks_, connection())
.WillByDefault(Return(OptRef<const Network::Connection>{connection_}));
connection_.stream_info_.downstream_connection_info_provider_->setRemoteAddress(addr_);
connection_.stream_info_.downstream_connection_info_provider_->setLocalAddress(addr_);
ON_CALL(decoder_callbacks_, addDecodedTrailers()).WillByDefault(ReturnRef(request_trailers_));
ON_CALL(encoder_callbacks_, addEncodedTrailers()).WillByDefault(ReturnRef(response_trailers_));
ON_CALL(decoder_callbacks_, decodingBuffer()).WillByDefault(Return(&buffer_));
ON_CALL(encoder_callbacks_, encodingBuffer()).WillByDefault(Return(&buffer_));
ON_CALL(decoder_callbacks_, decoderBufferLimit()).WillByDefault(Return(1024));
ON_CALL(encoder_callbacks_, encoderBufferLimit()).WillByDefault(Return(1024));
}

NiceMock<Http::MockStreamDecoderFilterCallbacks> decoder_callbacks_;
Expand All @@ -33,6 +38,7 @@ class FuzzerMocks {
NiceMock<Envoy::Network::MockConnection> connection_;
NiceMock<Http::TestRequestTrailerMapImpl> request_trailers_;
NiceMock<Http::TestResponseTrailerMapImpl> response_trailers_;
NiceMock<Buffer::OwnedImpl> buffer_;
testing::NiceMock<StreamInfo::MockStreamInfo> async_client_stream_info_;
};

Expand Down Expand Up @@ -72,8 +78,8 @@ DEFINE_PROTO_FUZZER(
filter->setDecoderFilterCallbacks(mocks.decoder_callbacks_);
filter->setEncoderFilterCallbacks(mocks.encoder_callbacks_);

ON_CALL(*client, start(_, _, _))
.WillByDefault(Invoke(
EXPECT_CALL(*client, start(_, _, _))
.WillRepeatedly(Invoke(
[&](ExternalProcessing::ExternalProcessorCallbacks&,
const envoy::config::core::v3::GrpcService&,
const StreamInfo::StreamInfo&) -> ExternalProcessing::ExternalProcessorStreamPtr {
Expand All @@ -88,7 +94,7 @@ DEFINE_PROTO_FUZZER(
}));
EXPECT_CALL(*stream, streamInfo())
.WillRepeatedly(ReturnRef(mocks.async_client_stream_info_));
ON_CALL(*stream, close()).WillByDefault(Return(false));
EXPECT_CALL(*stream, close()).WillRepeatedly(Return(false));
return stream;
}));

Expand Down

0 comments on commit 0e82260

Please sign in to comment.