|
7 | 7 | #include "test/test_common/logging.h"
|
8 | 8 | #include "test/test_common/test_runtime.h"
|
9 | 9 |
|
10 |
| -#include "conn_manager_impl_test_base.h" |
11 |
| - |
12 | 10 | using testing::_;
|
13 | 11 | using testing::An;
|
14 | 12 | using testing::AnyNumber;
|
@@ -2715,87 +2713,6 @@ TEST_F(HttpConnectionManagerImplTest, TestPeriodicAccessLogging) {
|
2715 | 2713 | filter->callbacks_->encodeHeaders(std::move(response_headers), true, "details");
|
2716 | 2714 | }
|
2717 | 2715 |
|
2718 |
| -class StreamErrorOnInvalidHttpMessageTest : public HttpConnectionManagerImplTest { |
2719 |
| -public: |
2720 |
| - void sendInvalidRequestAndVerifyConnectionState(bool stream_error_on_invalid_http_message, |
2721 |
| - bool send_complete_request = true) { |
2722 |
| - setup(); |
2723 |
| - |
2724 |
| - EXPECT_CALL(*codec_, dispatch(_)) |
2725 |
| - .WillRepeatedly(Invoke([&](Buffer::Instance& data) -> Http::Status { |
2726 |
| - decoder_ = &conn_manager_->newStream(response_encoder_); |
2727 |
| - |
2728 |
| - // These request headers are missing the necessary ":host" |
2729 |
| - RequestHeaderMapPtr headers{ |
2730 |
| - new TestRequestHeaderMapImpl{{":method", "GET"}, {":path", "/"}}}; |
2731 |
| - decoder_->decodeHeaders(std::move(headers), send_complete_request); |
2732 |
| - data.drain(0); |
2733 |
| - return Http::okStatus(); |
2734 |
| - })); |
2735 |
| - |
2736 |
| - auto* filter = new MockStreamFilter(); |
2737 |
| - EXPECT_CALL(filter_factory_, createFilterChain(_)) |
2738 |
| - .WillOnce(Invoke([&](FilterChainManager& manager) -> bool { |
2739 |
| - auto factory = createStreamFilterFactoryCb(StreamFilterSharedPtr{filter}); |
2740 |
| - manager.applyFilterFactoryCb({}, factory); |
2741 |
| - return true; |
2742 |
| - })); |
2743 |
| - EXPECT_CALL(*filter, setDecoderFilterCallbacks(_)); |
2744 |
| - EXPECT_CALL(*filter, setEncoderFilterCallbacks(_)); |
2745 |
| - |
2746 |
| - // codec stream error |
2747 |
| - EXPECT_CALL(response_encoder_, streamErrorOnInvalidHttpMessage()) |
2748 |
| - .WillOnce(Return(stream_error_on_invalid_http_message)); |
2749 |
| - EXPECT_CALL(*filter, encodeComplete()); |
2750 |
| - EXPECT_CALL(*filter, encodeHeaders(_, true)); |
2751 |
| - if (!stream_error_on_invalid_http_message) { |
2752 |
| - EXPECT_CALL(filter_callbacks_.connection_, close(_)).Times(AnyNumber()); |
2753 |
| - if (send_complete_request) { |
2754 |
| - // The request is complete, so we should not flush close. |
2755 |
| - EXPECT_CALL(filter_callbacks_.connection_, close(Network::ConnectionCloseType::FlushWrite)) |
2756 |
| - .Times(AnyNumber()); |
2757 |
| - } else { |
2758 |
| - // If the request isn't complete, avoid a FIN/RST race with delay close. |
2759 |
| - EXPECT_CALL(filter_callbacks_.connection_, |
2760 |
| - close(Network::ConnectionCloseType::FlushWriteAndDelay)) |
2761 |
| - .Times(AnyNumber()); |
2762 |
| - } |
2763 |
| - } |
2764 |
| - EXPECT_CALL(response_encoder_, encodeHeaders(_, true)) |
2765 |
| - .WillOnce(Invoke([&](const ResponseHeaderMap& headers, bool) -> void { |
2766 |
| - EXPECT_EQ("400", headers.getStatusValue()); |
2767 |
| - EXPECT_EQ("missing_host_header", |
2768 |
| - filter->decoder_callbacks_->streamInfo().responseCodeDetails().value()); |
2769 |
| - if (!stream_error_on_invalid_http_message) { |
2770 |
| - EXPECT_NE(nullptr, headers.Connection()); |
2771 |
| - EXPECT_EQ("close", headers.getConnectionValue()); |
2772 |
| - } else { |
2773 |
| - EXPECT_EQ(nullptr, headers.Connection()); |
2774 |
| - } |
2775 |
| - })); |
2776 |
| - |
2777 |
| - EXPECT_CALL(*filter, onStreamComplete()); |
2778 |
| - EXPECT_CALL(*filter, onDestroy()); |
2779 |
| - |
2780 |
| - Buffer::OwnedImpl fake_input; |
2781 |
| - conn_manager_->onData(fake_input, false); |
2782 |
| - } |
2783 |
| -}; |
2784 |
| - |
2785 |
| -TEST_F(StreamErrorOnInvalidHttpMessageTest, ConnectionTerminatedIfCodecStreamErrorIsFalse) { |
2786 |
| - sendInvalidRequestAndVerifyConnectionState(false); |
2787 |
| -} |
2788 |
| - |
2789 |
| -TEST_F(StreamErrorOnInvalidHttpMessageTest, |
2790 |
| - ConnectionTerminatedWithDelayIfCodecStreamErrorIsFalse) { |
2791 |
| - // Same as above, only with an incomplete request. |
2792 |
| - sendInvalidRequestAndVerifyConnectionState(false, false); |
2793 |
| -} |
2794 |
| - |
2795 |
| -TEST_F(StreamErrorOnInvalidHttpMessageTest, ConnectionOpenIfCodecStreamErrorIsTrue) { |
2796 |
| - sendInvalidRequestAndVerifyConnectionState(true); |
2797 |
| -} |
2798 |
| - |
2799 | 2716 | TEST_F(HttpConnectionManagerImplTest, TestAccessLogSsl) {
|
2800 | 2717 | setup(SetupOpts().setSsl(true));
|
2801 | 2718 |
|
|
0 commit comments