#include "net/quic/crypto/quic_crypto_server_config.h"
#include "net/quic/crypto/quic_random.h"
#include "net/quic/quic_connection.h"
+#include "net/quic/quic_utils.h"
#include "net/quic/test_tools/quic_connection_peer.h"
#include "net/quic/test_tools/quic_data_stream_peer.h"
#include "net/quic/test_tools/quic_test_utils.h"
QuicDataStreamPeer::SetHeadersDecompressed(stream, true);
}
+ QuicVersion version() const { return connection_->version(); }
+
StrictMock<MockQuicServerSessionVisitor> owner_;
StrictMock<MockConnection>* connection_;
QuicConfig config_;
::testing::ValuesIn(QuicSupportedVersions()));
TEST_P(QuicServerSessionTest, CloseStreamDueToReset) {
- QuicStreamId stream_id = GetParam() == QUIC_VERSION_12 ? 3 : 5;
+ QuicStreamId stream_id = (version() == QUIC_VERSION_12 ? 3 : 5);
// Open a stream, then reset it.
// Send two bytes of payload to open it.
QuicStreamFrame data1(stream_id, false, 0, MakeIOVector("HT"));
// compression context' state.
MarkHeadersReadForStream(stream_id);
- // Send a reset.
- QuicRstStreamFrame rst1(stream_id, QUIC_STREAM_NO_ERROR);
+ // Send a reset (and expect the peer to send a RST in response).
+ QuicRstStreamFrame rst1(stream_id, QUIC_STREAM_NO_ERROR, 0);
+ if (version() > QUIC_VERSION_13) {
+ EXPECT_CALL(*connection_,
+ SendRstStream(stream_id, QUIC_STREAM_NO_ERROR, 0));
+ }
visitor_->OnRstStream(rst1);
EXPECT_EQ(0u, session_->GetNumOpenStreams());
}
TEST_P(QuicServerSessionTest, NeverOpenStreamDueToReset) {
- QuicStreamId stream_id = GetParam() == QUIC_VERSION_12 ? 3 : 5;
- // Send a reset.
- QuicRstStreamFrame rst1(stream_id, QUIC_STREAM_NO_ERROR);
+ QuicStreamId stream_id = (version() == QUIC_VERSION_12 ? 3 : 5);
+
+ // Send a reset (and expect the peer to send a RST in response).
+ QuicRstStreamFrame rst1(stream_id, QUIC_STREAM_NO_ERROR, 0);
+ if (version() > QUIC_VERSION_13) {
+ EXPECT_CALL(*connection_,
+ SendRstStream(stream_id, QUIC_STREAM_NO_ERROR, 0));
+ }
visitor_->OnRstStream(rst1);
EXPECT_EQ(0u, session_->GetNumOpenStreams());
vector<QuicStreamFrame> frames;
frames.push_back(data1);
- if (connection_->version() > QUIC_VERSION_12) {
+ if (version() > QUIC_VERSION_12) {
EXPECT_TRUE(visitor_->OnStreamFrames(frames));
} else {
// When we get data for the closed stream, it implies the far side has
}
TEST_P(QuicServerSessionTest, GoOverPrematureClosedStreamLimit) {
- QuicStreamId stream_id = GetParam() == QUIC_VERSION_12 ? 3 : 5;
- if (connection_->version() > QUIC_VERSION_12) {
+ QuicStreamId stream_id = (version() == QUIC_VERSION_12 ? 3 : 5);
+ if (version() > QUIC_VERSION_12) {
// The prematurely closed stream limit is v12 specific.
return;
}
}
TEST_P(QuicServerSessionTest, AcceptClosedStream) {
- QuicStreamId stream_id = GetParam() == QUIC_VERSION_12 ? 3 : 5;
+ QuicStreamId stream_id = (version() == QUIC_VERSION_12 ? 3 : 5);
vector<QuicStreamFrame> frames;
// Send (empty) compressed headers followed by two bytes of data.
frames.push_back(QuicStreamFrame(stream_id, false, 0,
// compression context' state.
MarkHeadersReadForStream(stream_id);
- // Send a reset.
- QuicRstStreamFrame rst(stream_id, QUIC_STREAM_NO_ERROR);
+ // Send a reset (and expect the peer to send a RST in response).
+ QuicRstStreamFrame rst(stream_id, QUIC_STREAM_NO_ERROR, 0);
+ if (version() > QUIC_VERSION_13) {
+ EXPECT_CALL(*connection_,
+ SendRstStream(stream_id, QUIC_STREAM_NO_ERROR, 0));
+ }
visitor_->OnRstStream(rst);
// If we were tracking, we'd probably want to reject this because it's data
}
TEST_P(QuicServerSessionTest, MaxNumConnections) {
- QuicStreamId stream_id = GetParam() == QUIC_VERSION_12 ? 3 : 5;
+ QuicStreamId stream_id = (version() == QUIC_VERSION_12 ? 3 : 5);
EXPECT_EQ(0u, session_->GetNumOpenStreams());
EXPECT_TRUE(QuicServerSessionPeer::GetIncomingDataStream(session_.get(),
stream_id));
}
TEST_P(QuicServerSessionTest, MaxNumConnectionsImplicit) {
- QuicStreamId stream_id = GetParam() == QUIC_VERSION_12 ? 3 : 5;
+ QuicStreamId stream_id = (version() == QUIC_VERSION_12 ? 3 : 5);
EXPECT_EQ(0u, session_->GetNumOpenStreams());
EXPECT_TRUE(QuicServerSessionPeer::GetIncomingDataStream(session_.get(),
stream_id));