Home | History | Annotate | Download | only in quic
      1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
      2 // Use of this source code is governed by a BSD-style license that can be
      3 // found in the LICENSE file.
      4 
      5 #include "net/tools/quic/quic_spdy_server_stream.h"
      6 
      7 #include "base/strings/string_piece.h"
      8 #include "net/quic/quic_connection.h"
      9 #include "net/quic/quic_protocol.h"
     10 #include "net/quic/test_tools/quic_test_utils.h"
     11 #include "net/tools/quic/test_tools/quic_test_utils.h"
     12 #include "testing/gtest/include/gtest/gtest.h"
     13 
     14 using base::StringPiece;
     15 using net::tools::test::MockConnection;
     16 using net::test::MockSession;
     17 
     18 namespace net {
     19 namespace tools {
     20 namespace test {
     21 namespace {
     22 
     23 class QuicSpdyServerStreamTest : public ::testing::Test {
     24  public:
     25   QuicSpdyServerStreamTest()
     26       : connection_(new MockConnection(1, IPEndPoint(), false)),
     27         session_(connection_, true),
     28         stream_(1, &session_) {
     29   }
     30 
     31   MockConnection* connection_;
     32   MockSession session_;
     33   QuicSpdyServerStream stream_;
     34 };
     35 
     36 TEST_F(QuicSpdyServerStreamTest, InvalidHeadersWithFin) {
     37   char arr[] = {
     38     0x00, 0x00, 0x00, 0x05,  // ....
     39     0x00, 0x00, 0x00, 0x05,  // ....
     40     0x3a, 0x68, 0x6f, 0x73,  // :hos
     41     0x74, 0x00, 0x00, 0x00,  // t...
     42     0x00, 0x00, 0x00, 0x00,  // ....
     43     0x07, 0x3a, 0x6d, 0x65,  // .:me
     44     0x74, 0x68, 0x6f, 0x64,  // thod
     45     0x00, 0x00, 0x00, 0x03,  // ....
     46     0x47, 0x45, 0x54, 0x00,  // GET.
     47     0x00, 0x00, 0x05, 0x3a,  // ...:
     48     0x70, 0x61, 0x74, 0x68,  // path
     49     0x00, 0x00, 0x00, 0x04,  // ....
     50     0x2f, 0x66, 0x6f, 0x6f,  // /foo
     51     0x00, 0x00, 0x00, 0x07,  // ....
     52     0x3a, 0x73, 0x63, 0x68,  // :sch
     53     0x65, 0x6d, 0x65, 0x00,  // eme.
     54     0x00, 0x00, 0x00, 0x00,  // ....
     55     0x00, 0x00, 0x08, 0x3a,  // ...:
     56     0x76, 0x65, 0x72, 0x73,  // vers
     57     '\x96', 0x6f, 0x6e, 0x00,  // <i(69)>on.
     58     0x00, 0x00, 0x08, 0x48,  // ...H
     59     0x54, 0x54, 0x50, 0x2f,  // TTP/
     60     0x31, 0x2e, 0x31,        // 1.1
     61   };
     62   QuicStreamFrame frame(1, true, 0, StringPiece(arr, arraysize(arr)));
     63   // Verify that we don't crash when we get a invalid headers in stream frame.
     64   stream_.OnStreamFrame(frame);
     65 }
     66 
     67 }  // namespace
     68 }  // namespace test
     69 }  // namespace tools
     70 }  // namespace net
     71