If there are no local credentials for a locked profile, show sign in button
[chromium-blink-merge.git] / net / quic / crypto / null_decrypter_test.cc
blob4c8bae4ff5f6373047acd08e97c37d8dbc4c90da
1 // Copyright (c) 2012 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.
5 #include "net/quic/crypto/null_decrypter.h"
6 #include "net/quic/test_tools/quic_test_utils.h"
8 using base::StringPiece;
10 namespace net {
11 namespace test {
13 class NullDecrypterTest : public ::testing::TestWithParam<bool> {
16 TEST_F(NullDecrypterTest, Decrypt) {
17 unsigned char expected[] = {
18 // fnv hash
19 0xa0, 0x6f, 0x44, 0x8a,
20 0x44, 0xf8, 0x18, 0x3b,
21 0x47, 0x91, 0xb2, 0x13,
22 // payload
23 'g', 'o', 'o', 'd',
24 'b', 'y', 'e', '!',
26 const char* data = reinterpret_cast<const char*>(expected);
27 size_t len = arraysize(expected);
28 NullDecrypter decrypter;
29 char buffer[256];
30 size_t length = 0;
31 ASSERT_TRUE(decrypter.DecryptPacket(0, "hello world!", StringPiece(data, len),
32 buffer, &length, 256));
33 EXPECT_LT(0u, length);
34 EXPECT_EQ("goodbye!", StringPiece(buffer, length));
37 TEST_F(NullDecrypterTest, BadHash) {
38 unsigned char expected[] = {
39 // fnv hash
40 0x46, 0x11, 0xea, 0x5f,
41 0xcf, 0x1d, 0x66, 0x5b,
42 0xba, 0xf0, 0xbc, 0xfd,
43 // payload
44 'g', 'o', 'o', 'd',
45 'b', 'y', 'e', '!',
47 const char* data = reinterpret_cast<const char*>(expected);
48 size_t len = arraysize(expected);
49 NullDecrypter decrypter;
50 char buffer[256];
51 size_t length = 0;
52 ASSERT_FALSE(decrypter.DecryptPacket(
53 0, "hello world!", StringPiece(data, len), buffer, &length, 256));
56 TEST_F(NullDecrypterTest, ShortInput) {
57 unsigned char expected[] = {
58 // fnv hash (truncated)
59 0x46, 0x11, 0xea, 0x5f,
60 0xcf, 0x1d, 0x66, 0x5b,
61 0xba, 0xf0, 0xbc,
63 const char* data = reinterpret_cast<const char*>(expected);
64 size_t len = arraysize(expected);
65 NullDecrypter decrypter;
66 char buffer[256];
67 size_t length = 0;
68 ASSERT_FALSE(decrypter.DecryptPacket(
69 0, "hello world!", StringPiece(data, len), buffer, &length, 256));
72 } // namespace test
73 } // namespace net