Chromium Code Reviews| OLD | NEW |
|---|---|
| 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/quic_crypto_client_config.h" | 5 #include "net/quic/crypto/quic_crypto_client_config.h" |
| 6 | 6 |
| 7 #include "net/quic/crypto/proof_verifier.h" | 7 #include "net/quic/crypto/proof_verifier.h" |
| 8 #include "net/quic/quic_server_id.h" | 8 #include "net/quic/quic_server_id.h" |
| 9 #include "net/quic/test_tools/mock_random.h" | 9 #include "net/quic/test_tools/mock_random.h" |
| 10 #include "net/quic/test_tools/quic_test_utils.h" | 10 #include "net/quic/test_tools/quic_test_utils.h" |
| 11 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
| 12 | 12 |
| 13 using std::string; | 13 using std::string; |
| 14 using std::vector; | 14 using std::vector; |
| 15 | 15 |
| 16 namespace net { | 16 namespace net { |
| 17 namespace test { | 17 namespace test { |
| 18 | 18 |
| 19 class TestProofVerifyDetails : public ProofVerifyDetails { | |
|
wtc
2014/07/29 01:48:24
Nit: we probably should nest this inside an unname
Ryan Hamilton
2014/07/29 17:04:50
Done.
| |
| 20 virtual ~TestProofVerifyDetails() {} | |
| 21 | |
| 22 virtual ProofVerifyDetails* Clone() const OVERRIDE { | |
|
wtc
2014/07/29 01:48:24
Nit: should we add a "ProofVerifyDetails interface
Ryan Hamilton
2014/07/29 17:04:50
Done.
| |
| 23 return NULL; | |
|
wtc
2014/07/29 01:48:24
BUG: this should return new TestProofVerifyDetails
Ryan Hamilton
2014/07/29 17:04:50
Done.
| |
| 24 } | |
| 25 }; | |
| 26 | |
| 19 TEST(QuicCryptoClientConfigTest, CachedState_IsEmpty) { | 27 TEST(QuicCryptoClientConfigTest, CachedState_IsEmpty) { |
| 20 QuicCryptoClientConfig::CachedState state; | 28 QuicCryptoClientConfig::CachedState state; |
| 21 EXPECT_TRUE(state.IsEmpty()); | 29 EXPECT_TRUE(state.IsEmpty()); |
| 22 } | 30 } |
| 23 | 31 |
| 24 TEST(QuicCryptoClientConfigTest, CachedState_IsComplete) { | 32 TEST(QuicCryptoClientConfigTest, CachedState_IsComplete) { |
| 25 QuicCryptoClientConfig::CachedState state; | 33 QuicCryptoClientConfig::CachedState state; |
| 26 EXPECT_FALSE(state.IsComplete(QuicWallTime::FromUNIXSeconds(0))); | 34 EXPECT_FALSE(state.IsComplete(QuicWallTime::FromUNIXSeconds(0))); |
| 27 } | 35 } |
| 28 | 36 |
| 29 TEST(QuicCryptoClientConfigTest, CachedState_GenerationCounter) { | 37 TEST(QuicCryptoClientConfigTest, CachedState_GenerationCounter) { |
| 30 QuicCryptoClientConfig::CachedState state; | 38 QuicCryptoClientConfig::CachedState state; |
| 31 EXPECT_EQ(0u, state.generation_counter()); | 39 EXPECT_EQ(0u, state.generation_counter()); |
| 32 state.SetProofInvalid(); | 40 state.SetProofInvalid(); |
| 33 EXPECT_EQ(1u, state.generation_counter()); | 41 EXPECT_EQ(1u, state.generation_counter()); |
| 34 } | 42 } |
| 35 | 43 |
| 36 TEST(QuicCryptoClientConfigTest, CachedState_SetProofVerifyDetails) { | 44 TEST(QuicCryptoClientConfigTest, CachedState_SetProofVerifyDetails) { |
| 37 QuicCryptoClientConfig::CachedState state; | 45 QuicCryptoClientConfig::CachedState state; |
| 38 EXPECT_TRUE(state.proof_verify_details() == NULL); | 46 EXPECT_TRUE(state.proof_verify_details() == NULL); |
| 39 ProofVerifyDetails* details = new ProofVerifyDetails; | 47 ProofVerifyDetails* details = new TestProofVerifyDetails; |
| 40 state.SetProofVerifyDetails(details); | 48 state.SetProofVerifyDetails(details); |
| 41 EXPECT_EQ(details, state.proof_verify_details()); | 49 EXPECT_EQ(details, state.proof_verify_details()); |
| 42 } | 50 } |
| 43 | 51 |
| 44 TEST(QuicCryptoClientConfigTest, CachedState_InitializeFrom) { | 52 TEST(QuicCryptoClientConfigTest, CachedState_InitializeFrom) { |
| 45 QuicCryptoClientConfig::CachedState state; | 53 QuicCryptoClientConfig::CachedState state; |
| 46 QuicCryptoClientConfig::CachedState other; | 54 QuicCryptoClientConfig::CachedState other; |
| 47 state.set_source_address_token("TOKEN"); | 55 state.set_source_address_token("TOKEN"); |
| 48 // TODO(rch): Populate other fields of |state|. | 56 // TODO(rch): Populate other fields of |state|. |
| 49 other.InitializeFrom(state); | 57 other.InitializeFrom(state); |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 250 EXPECT_EQ(state, cleared_cache); | 258 EXPECT_EQ(state, cleared_cache); |
| 251 EXPECT_FALSE(cleared_cache->proof_valid()); | 259 EXPECT_FALSE(cleared_cache->proof_valid()); |
| 252 EXPECT_TRUE(cleared_cache->server_config().empty()); | 260 EXPECT_TRUE(cleared_cache->server_config().empty()); |
| 253 EXPECT_TRUE(cleared_cache->certs().empty()); | 261 EXPECT_TRUE(cleared_cache->certs().empty()); |
| 254 EXPECT_TRUE(cleared_cache->signature().empty()); | 262 EXPECT_TRUE(cleared_cache->signature().empty()); |
| 255 EXPECT_EQ(2u, cleared_cache->generation_counter()); | 263 EXPECT_EQ(2u, cleared_cache->generation_counter()); |
| 256 } | 264 } |
| 257 | 265 |
| 258 } // namespace test | 266 } // namespace test |
| 259 } // namespace net | 267 } // namespace net |
| OLD | NEW |