| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/properties_based_quic_server_info.h" | 5 #include "net/quic/crypto/properties_based_quic_server_info.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "net/base/net_errors.h" | 9 #include "net/base/net_errors.h" |
| 10 #include "net/http/http_server_properties_impl.h" | 10 #include "net/http/http_server_properties_impl.h" |
| 11 #include "net/quic/quic_server_id.h" | 11 #include "net/quic/quic_server_id.h" |
| 12 #include "net/test/gtest_util.h" |
| 13 #include "testing/gmock/include/gmock/gmock.h" |
| 12 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
| 13 | 15 |
| 14 namespace net { | 16 namespace net { |
| 15 namespace test { | 17 namespace test { |
| 16 | 18 |
| 17 namespace { | 19 namespace { |
| 18 const char kServerConfigA[] = "server_config_a"; | 20 const char kServerConfigA[] = "server_config_a"; |
| 19 const char kSourceAddressTokenA[] = "source_address_token_a"; | 21 const char kSourceAddressTokenA[] = "source_address_token_a"; |
| 20 const char kCertSCTA[] = "cert_sct_a"; | 22 const char kCertSCTA[] = "cert_sct_a"; |
| 21 const char kChloHashA[] = "chlo_hash_a"; | 23 const char kChloHashA[] = "chlo_hash_a"; |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 }; | 69 }; |
| 68 | 70 |
| 69 // Test persisting, reading and verifying and then updating and verifing. | 71 // Test persisting, reading and verifying and then updating and verifing. |
| 70 TEST_F(PropertiesBasedQuicServerInfoTest, Update) { | 72 TEST_F(PropertiesBasedQuicServerInfoTest, Update) { |
| 71 InitializeAndPersist(); | 73 InitializeAndPersist(); |
| 72 | 74 |
| 73 // Read the persisted data and verify we have read the data correctly. | 75 // Read the persisted data and verify we have read the data correctly. |
| 74 PropertiesBasedQuicServerInfo server_info1(server_id_, | 76 PropertiesBasedQuicServerInfo server_info1(server_id_, |
| 75 &http_server_properties_); | 77 &http_server_properties_); |
| 76 server_info1.Start(); | 78 server_info1.Start(); |
| 77 EXPECT_EQ(OK, server_info1.WaitForDataReady(callback_)); // Read the data. | 79 EXPECT_THAT(server_info1.WaitForDataReady(callback_), |
| 80 IsOk()); // Read the data. |
| 78 EXPECT_TRUE(server_info1.IsDataReady()); | 81 EXPECT_TRUE(server_info1.IsDataReady()); |
| 79 | 82 |
| 80 // Verify the data. | 83 // Verify the data. |
| 81 const QuicServerInfo::State& state1 = server_info1.state(); | 84 const QuicServerInfo::State& state1 = server_info1.state(); |
| 82 EXPECT_EQ(1U, state1.certs.size()); | 85 EXPECT_EQ(1U, state1.certs.size()); |
| 83 VerifyInitialData(state1); | 86 VerifyInitialData(state1); |
| 84 | 87 |
| 85 // Update the data, by adding another cert. | 88 // Update the data, by adding another cert. |
| 86 QuicServerInfo::State* state2 = server_info1.mutable_state(); | 89 QuicServerInfo::State* state2 = server_info1.mutable_state(); |
| 87 state2->certs.push_back(kCertB); | 90 state2->certs.push_back(kCertB); |
| 88 EXPECT_TRUE(server_info_.IsReadyToPersist()); | 91 EXPECT_TRUE(server_info_.IsReadyToPersist()); |
| 89 server_info1.Persist(); | 92 server_info1.Persist(); |
| 90 | 93 |
| 91 // Read the persisted data and verify we have read the data correctly. | 94 // Read the persisted data and verify we have read the data correctly. |
| 92 PropertiesBasedQuicServerInfo server_info2(server_id_, | 95 PropertiesBasedQuicServerInfo server_info2(server_id_, |
| 93 &http_server_properties_); | 96 &http_server_properties_); |
| 94 server_info2.Start(); | 97 server_info2.Start(); |
| 95 EXPECT_EQ(OK, server_info2.WaitForDataReady(callback_)); // Read the data. | 98 EXPECT_THAT(server_info2.WaitForDataReady(callback_), |
| 99 IsOk()); // Read the data. |
| 96 EXPECT_TRUE(server_info1.IsDataReady()); | 100 EXPECT_TRUE(server_info1.IsDataReady()); |
| 97 | 101 |
| 98 // Verify updated data. | 102 // Verify updated data. |
| 99 const QuicServerInfo::State& state3 = server_info2.state(); | 103 const QuicServerInfo::State& state3 = server_info2.state(); |
| 100 VerifyInitialData(state3); | 104 VerifyInitialData(state3); |
| 101 EXPECT_EQ(2U, state3.certs.size()); | 105 EXPECT_EQ(2U, state3.certs.size()); |
| 102 EXPECT_EQ(kCertB, state3.certs[1]); | 106 EXPECT_EQ(kCertB, state3.certs[1]); |
| 103 } | 107 } |
| 104 | 108 |
| 105 } // namespace test | 109 } // namespace test |
| 106 } // namespace net | 110 } // namespace net |
| OLD | NEW |