Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(164)

Side by Side Diff: net/quic/crypto/local_strike_register_client_test.cc

Issue 113883003: - Add a priority field to QuicCryptoServerConfig configs and used it as (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "net/quic/crypto/local_strike_register_client.h" 5 #include "net/quic/crypto/local_strike_register_client.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/strings/string_piece.h" 10 #include "base/strings/string_piece.h"
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 virtual void SetUp() { 56 virtual void SetUp() {
57 strike_register_.reset(new LocalStrikeRegisterClient( 57 strike_register_.reset(new LocalStrikeRegisterClient(
58 kMaxEntries, kCurrentTimeExternalSecs, kWindowSecs, kOrbit, 58 kMaxEntries, kCurrentTimeExternalSecs, kWindowSecs, kOrbit,
59 net::StrikeRegister::NO_STARTUP_PERIOD_NEEDED)); 59 net::StrikeRegister::NO_STARTUP_PERIOD_NEEDED));
60 } 60 }
61 61
62 scoped_ptr<LocalStrikeRegisterClient> strike_register_; 62 scoped_ptr<LocalStrikeRegisterClient> strike_register_;
63 }; 63 };
64 64
65 TEST_F(LocalStrikeRegisterClientTest, CheckOrbit) { 65 TEST_F(LocalStrikeRegisterClientTest, CheckOrbit) {
66 EXPECT_EQ(StringPiece(reinterpret_cast<const char*>(kOrbit), kOrbitSize), 66 EXPECT_TRUE(strike_register_->IsKnownOrbit(
67 strike_register_->orbit()); 67 StringPiece(reinterpret_cast<const char*>(kOrbit), kOrbitSize)));
68 EXPECT_FALSE(strike_register_->IsKnownOrbit(
69 StringPiece(reinterpret_cast<const char*>(kOrbit), kOrbitSize - 1)));
70 EXPECT_FALSE(strike_register_->IsKnownOrbit(
71 StringPiece(reinterpret_cast<const char*>(kOrbit), kOrbitSize + 1)));
72 EXPECT_FALSE(strike_register_->IsKnownOrbit(
73 StringPiece(reinterpret_cast<const char*>(kOrbit) + 1, kOrbitSize)));
68 } 74 }
69 75
70 TEST_F(LocalStrikeRegisterClientTest, IncorrectNonceLength) { 76 TEST_F(LocalStrikeRegisterClientTest, IncorrectNonceLength) {
71 string valid_nonce; 77 string valid_nonce;
72 uint32 norder = htonl(kCurrentTimeExternalSecs); 78 uint32 norder = htonl(kCurrentTimeExternalSecs);
73 valid_nonce.assign(reinterpret_cast<const char*>(&norder), sizeof(norder)); 79 valid_nonce.assign(reinterpret_cast<const char*>(&norder), sizeof(norder));
74 valid_nonce.append(strike_register_->orbit()); 80 valid_nonce.append(string(reinterpret_cast<const char*>(kOrbit), kOrbitSize));
75 valid_nonce.append(string(20, '\x17')); // 20 'random' bytes. 81 valid_nonce.append(string(20, '\x17')); // 20 'random' bytes.
76 82
77 { 83 {
78 // Validation fails if you remove a byte from the nonce. 84 // Validation fails if you remove a byte from the nonce.
79 bool called; 85 bool called;
80 bool is_valid; 86 bool is_valid;
81 string short_nonce = valid_nonce.substr(0, valid_nonce.length() - 1); 87 string short_nonce = valid_nonce.substr(0, valid_nonce.length() - 1);
82 strike_register_->VerifyNonceIsValidAndUnique( 88 strike_register_->VerifyNonceIsValidAndUnique(
83 short_nonce, 89 short_nonce,
84 QuicWallTime::FromUNIXSeconds(kCurrentTimeExternalSecs), 90 QuicWallTime::FromUNIXSeconds(kCurrentTimeExternalSecs),
(...skipping 25 matching lines...) Expand all
110 QuicWallTime::FromUNIXSeconds(kCurrentTimeExternalSecs), 116 QuicWallTime::FromUNIXSeconds(kCurrentTimeExternalSecs),
111 new RecordResultCallback(&called, &is_valid)); 117 new RecordResultCallback(&called, &is_valid));
112 EXPECT_TRUE(called); 118 EXPECT_TRUE(called);
113 EXPECT_TRUE(is_valid); 119 EXPECT_TRUE(is_valid);
114 } 120 }
115 } 121 }
116 122
117 } // namespace 123 } // namespace
118 } // namespace test 124 } // namespace test
119 } // namespace net 125 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/crypto/local_strike_register_client.cc ('k') | net/quic/crypto/quic_crypto_server_config.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698