summaryrefslogtreecommitdiffstats
path: root/net/quic/crypto/crypto_handshake_message_test.cc
blob: a4fae52946bc363772ef610b699863680a732183 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
// Copyright (c) 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "net/quic/crypto/crypto_handshake_message.h"

#include "net/quic/crypto/crypto_handshake.h"
#include "net/quic/crypto/crypto_protocol.h"
#include "net/test/gtest_util.h"

namespace net {
namespace test {
namespace {

TEST(CryptoHandshakeMessageTest, DebugString) {
  CryptoHandshakeMessage message;
  message.set_tag(kSHLO);
  EXPECT_EQ("SHLO<\n>", message.DebugString());
}

TEST(CryptoHandshakeMessageTest, DebugStringWithUintVector) {
  CryptoHandshakeMessage message;
  message.set_tag(kREJ);
  std::vector<uint32_t> reasons = {
      SOURCE_ADDRESS_TOKEN_DIFFERENT_IP_ADDRESS_FAILURE,
      CLIENT_NONCE_NOT_UNIQUE_FAILURE};
  message.SetVector(kRREJ, reasons);
  EXPECT_EQ(
      "REJ <\n  RREJ: "
      "SOURCE_ADDRESS_TOKEN_DIFFERENT_IP_ADDRESS_FAILURE,"
      "CLIENT_NONCE_NOT_UNIQUE_FAILURE\n>",
      message.DebugString());
}

TEST(CryptoHandshakeMessageTest, DebugStringWithTagVector) {
  CryptoHandshakeMessage message;
  message.set_tag(kCHLO);
  message.SetTaglist(kCOPT, kTBBR, kPAD, kBYTE, 0);
  EXPECT_EQ("CHLO<\n  COPT: 'TBBR','PAD ','BYTE'\n>", message.DebugString());
}

TEST(CryptoHandshakeMessageTest, ServerDesignatedConnectionId) {
  CryptoHandshakeMessage message;
  message.set_tag(kSREJ);
  message.SetValue(kRCID, UINT64_C(18364758544493064720));
  EXPECT_EQ("SREJ<\n  RCID: 18364758544493064720\n>", message.DebugString());
}

}  // namespace
}  // namespace test
}  // namespace net