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

Side by Side Diff: components/certificate_transparency/log_dns_client_unittest.cc

Issue 2351513002: net: rename BoundNetLog to NetLogWithSource (Closed)
Patch Set: one more fix, content bound_net_log_ Created 4 years, 3 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
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "components/certificate_transparency/log_dns_client.h" 5 #include "components/certificate_transparency/log_dns_client.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 protected: 116 protected:
117 LogDnsClientTest() 117 LogDnsClientTest()
118 : network_change_notifier_(net::NetworkChangeNotifier::CreateMock()) { 118 : network_change_notifier_(net::NetworkChangeNotifier::CreateMock()) {
119 mock_dns_.SetSocketReadMode(GetParam()); 119 mock_dns_.SetSocketReadMode(GetParam());
120 mock_dns_.InitializeDnsConfig(); 120 mock_dns_.InitializeDnsConfig();
121 } 121 }
122 122
123 void QueryLeafIndex(base::StringPiece log_domain, 123 void QueryLeafIndex(base::StringPiece log_domain,
124 base::StringPiece leaf_hash, 124 base::StringPiece leaf_hash,
125 MockLeafIndexCallback* callback) { 125 MockLeafIndexCallback* callback) {
126 LogDnsClient log_client(mock_dns_.CreateDnsClient(), net::BoundNetLog()); 126 LogDnsClient log_client(mock_dns_.CreateDnsClient(),
127 net::NetLogWithSource());
127 log_client.QueryLeafIndex(log_domain, leaf_hash, callback->AsCallback()); 128 log_client.QueryLeafIndex(log_domain, leaf_hash, callback->AsCallback());
128 callback->WaitUntilRun(); 129 callback->WaitUntilRun();
129 } 130 }
130 131
131 void QueryAuditProof(base::StringPiece log_domain, 132 void QueryAuditProof(base::StringPiece log_domain,
132 uint64_t leaf_index, 133 uint64_t leaf_index,
133 uint64_t tree_size, 134 uint64_t tree_size,
134 MockAuditProofCallback* callback) { 135 MockAuditProofCallback* callback) {
135 LogDnsClient log_client(mock_dns_.CreateDnsClient(), net::BoundNetLog()); 136 LogDnsClient log_client(mock_dns_.CreateDnsClient(),
137 net::NetLogWithSource());
136 log_client.QueryAuditProof(log_domain, leaf_index, tree_size, 138 log_client.QueryAuditProof(log_domain, leaf_index, tree_size,
137 callback->AsCallback()); 139 callback->AsCallback());
138 callback->WaitUntilRun(); 140 callback->WaitUntilRun();
139 } 141 }
140 142
141 // This will be the NetworkChangeNotifier singleton for the duration of the 143 // This will be the NetworkChangeNotifier singleton for the duration of the
142 // test. It is accessed statically by LogDnsClient. 144 // test. It is accessed statically by LogDnsClient.
143 std::unique_ptr<net::NetworkChangeNotifier> network_change_notifier_; 145 std::unique_ptr<net::NetworkChangeNotifier> network_change_notifier_;
144 // Queues and handles asynchronous DNS tasks. Indirectly used by LogDnsClient, 146 // Queues and handles asynchronous DNS tasks. Indirectly used by LogDnsClient,
145 // the underlying net::DnsClient, and NetworkChangeNotifier. 147 // the underlying net::DnsClient, and NetworkChangeNotifier.
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after
507 MockAuditProofCallback callback; 509 MockAuditProofCallback callback;
508 QueryAuditProof("ct.test", 123456, 999999, &callback); 510 QueryAuditProof("ct.test", 123456, 999999, &callback);
509 ASSERT_TRUE(callback.called()); 511 ASSERT_TRUE(callback.called());
510 EXPECT_THAT(callback.net_error(), IsError(net::ERR_DNS_TIMED_OUT)); 512 EXPECT_THAT(callback.net_error(), IsError(net::ERR_DNS_TIMED_OUT));
511 EXPECT_THAT(callback.proof(), IsNull()); 513 EXPECT_THAT(callback.proof(), IsNull());
512 } 514 }
513 515
514 TEST_P(LogDnsClientTest, AdoptsLatestDnsConfigIfValid) { 516 TEST_P(LogDnsClientTest, AdoptsLatestDnsConfigIfValid) {
515 std::unique_ptr<net::DnsClient> tmp = mock_dns_.CreateDnsClient(); 517 std::unique_ptr<net::DnsClient> tmp = mock_dns_.CreateDnsClient();
516 net::DnsClient* dns_client = tmp.get(); 518 net::DnsClient* dns_client = tmp.get();
517 LogDnsClient log_client(std::move(tmp), net::BoundNetLog()); 519 LogDnsClient log_client(std::move(tmp), net::NetLogWithSource());
518 520
519 // Get the current DNS config, modify it and broadcast the update. 521 // Get the current DNS config, modify it and broadcast the update.
520 net::DnsConfig config(*dns_client->GetConfig()); 522 net::DnsConfig config(*dns_client->GetConfig());
521 ASSERT_NE(123, config.attempts); 523 ASSERT_NE(123, config.attempts);
522 config.attempts = 123; 524 config.attempts = 123;
523 mock_dns_.SetDnsConfig(config); 525 mock_dns_.SetDnsConfig(config);
524 526
525 // Let the DNS config change propogate. 527 // Let the DNS config change propogate.
526 base::RunLoop().RunUntilIdle(); 528 base::RunLoop().RunUntilIdle();
527 EXPECT_EQ(123, dns_client->GetConfig()->attempts); 529 EXPECT_EQ(123, dns_client->GetConfig()->attempts);
528 } 530 }
529 531
530 TEST_P(LogDnsClientTest, IgnoresLatestDnsConfigIfInvalid) { 532 TEST_P(LogDnsClientTest, IgnoresLatestDnsConfigIfInvalid) {
531 std::unique_ptr<net::DnsClient> tmp = mock_dns_.CreateDnsClient(); 533 std::unique_ptr<net::DnsClient> tmp = mock_dns_.CreateDnsClient();
532 net::DnsClient* dns_client = tmp.get(); 534 net::DnsClient* dns_client = tmp.get();
533 LogDnsClient log_client(std::move(tmp), net::BoundNetLog()); 535 LogDnsClient log_client(std::move(tmp), net::NetLogWithSource());
534 536
535 // Get the current DNS config, modify it and broadcast the update. 537 // Get the current DNS config, modify it and broadcast the update.
536 net::DnsConfig config(*dns_client->GetConfig()); 538 net::DnsConfig config(*dns_client->GetConfig());
537 ASSERT_THAT(config.nameservers, Not(IsEmpty())); 539 ASSERT_THAT(config.nameservers, Not(IsEmpty()));
538 config.nameservers.clear(); // Makes config invalid 540 config.nameservers.clear(); // Makes config invalid
539 mock_dns_.SetDnsConfig(config); 541 mock_dns_.SetDnsConfig(config);
540 542
541 // Let the DNS config change propogate. 543 // Let the DNS config change propogate.
542 base::RunLoop().RunUntilIdle(); 544 base::RunLoop().RunUntilIdle();
543 EXPECT_THAT(dns_client->GetConfig()->nameservers, Not(IsEmpty())); 545 EXPECT_THAT(dns_client->GetConfig()->nameservers, Not(IsEmpty()));
544 } 546 }
545 547
546 INSTANTIATE_TEST_CASE_P(ReadMode, 548 INSTANTIATE_TEST_CASE_P(ReadMode,
547 LogDnsClientTest, 549 LogDnsClientTest,
548 ::testing::Values(net::IoMode::ASYNC, 550 ::testing::Values(net::IoMode::ASYNC,
549 net::IoMode::SYNCHRONOUS)); 551 net::IoMode::SYNCHRONOUS));
550 552
551 } // namespace 553 } // namespace
552 } // namespace certificate_transparency 554 } // namespace certificate_transparency
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698