| Index: net/dns/dns_transaction_unittest.cc
|
| diff --git a/net/dns/dns_transaction_unittest.cc b/net/dns/dns_transaction_unittest.cc
|
| index 5e61f273ecffa64e35bc1d73c062ea4794465edf..e52ea4e71a59d16064f26367042e239f9180eb53 100644
|
| --- a/net/dns/dns_transaction_unittest.cc
|
| +++ b/net/dns/dns_transaction_unittest.cc
|
| @@ -258,6 +258,14 @@ class DnsTransactionTest : public testing::Test {
|
| AddResponse(dotted_name, qtype, id, data, data_length, ASYNC);
|
| }
|
|
|
| + void AddSyncResponse(const std::string& dotted_name,
|
| + uint16 qtype,
|
| + uint16 id,
|
| + const char* data,
|
| + size_t data_length) {
|
| + AddResponse(dotted_name, qtype, id, data, data_length, SYNCHRONOUS);
|
| + }
|
| +
|
| // Add expected query of |dotted_name| and |qtype| and no response.
|
| void AddTimeout(const char* dotted_name, uint16 qtype) {
|
| CHECK(socket_factory_.get());
|
| @@ -303,6 +311,10 @@ class DnsTransactionTest : public testing::Test {
|
| AddRcode(dotted_name, qtype, rcode, ASYNC);
|
| }
|
|
|
| + void AddSyncRcode(const char* dotted_name, uint16 qtype, int rcode) {
|
| + AddRcode(dotted_name, qtype, rcode, SYNCHRONOUS);
|
| + }
|
| +
|
| // Call after all Add* calls to prepare data for |socket_factory_|.
|
| // This separation is necessary because the |reads_| and |writes_| vectors
|
| // could reallocate their data during those calls.
|
| @@ -487,6 +499,29 @@ TEST_F(DnsTransactionTest, CancelFromCallback) {
|
| EXPECT_TRUE(helper0.Run(transaction_factory_.get()));
|
| }
|
|
|
| +TEST_F(DnsTransactionTest, MalformedResponse) {
|
| + config_.attempts = 3;
|
| + ConfigureFactory();
|
| + AddAsyncResponse(kT0HostName, kT0Qtype,
|
| + 1 /* mismatched id */,
|
| + reinterpret_cast<const char*>(kT0ResponseDatagram),
|
| + arraysize(kT0ResponseDatagram));
|
| + AddSyncResponse(kT0HostName, kT0Qtype,
|
| + 2 /* mismatched id */,
|
| + reinterpret_cast<const char*>(kT0ResponseDatagram),
|
| + arraysize(kT0ResponseDatagram));
|
| + AddAsyncResponse(kT0HostName, kT0Qtype,
|
| + 0 /* matching id */,
|
| + reinterpret_cast<const char*>(kT0ResponseDatagram),
|
| + arraysize(kT0ResponseDatagram));
|
| + PrepareSockets();
|
| +
|
| + TransactionHelper helper0(kT0HostName,
|
| + kT0Qtype,
|
| + kT0RecordCount);
|
| + EXPECT_TRUE(helper0.Run(transaction_factory_.get()));
|
| +}
|
| +
|
| TEST_F(DnsTransactionTest, ServerFail) {
|
| AddAsyncRcode(kT0HostName, kT0Qtype, dns_protocol::kRcodeSERVFAIL);
|
| PrepareSockets();
|
| @@ -725,12 +760,11 @@ TEST_F(DnsTransactionTest, SyncFirstQuery) {
|
| config_.search.push_back("ccs.neu.edu");
|
| ConfigureFactory();
|
|
|
| - AddResponse(kT0HostName,
|
| - kT0Qtype,
|
| - 0 /* id */,
|
| - reinterpret_cast<const char*>(kT0ResponseDatagram),
|
| - arraysize(kT0ResponseDatagram),
|
| - SYNCHRONOUS);
|
| + AddSyncResponse(kT0HostName,
|
| + kT0Qtype,
|
| + 0 /* id */,
|
| + reinterpret_cast<const char*>(kT0ResponseDatagram),
|
| + arraysize(kT0ResponseDatagram));
|
| PrepareSockets();
|
|
|
| TransactionHelper helper0(kT0HostName,
|
| @@ -744,16 +778,14 @@ TEST_F(DnsTransactionTest, SyncFirstQueryWithSearch) {
|
| config_.search.push_back("ccs.neu.edu");
|
| ConfigureFactory();
|
|
|
| - AddRcode("www.lab.ccs.neu.edu",
|
| - kT2Qtype,
|
| - dns_protocol::kRcodeNXDOMAIN,
|
| - SYNCHRONOUS);
|
| - AddResponse(kT2HostName, // "www.ccs.neu.edu"
|
| - kT2Qtype,
|
| - 2 /* id */,
|
| - reinterpret_cast<const char*>(kT2ResponseDatagram),
|
| - arraysize(kT2ResponseDatagram),
|
| - ASYNC);
|
| + AddSyncRcode("www.lab.ccs.neu.edu",
|
| + kT2Qtype,
|
| + dns_protocol::kRcodeNXDOMAIN);
|
| + AddAsyncResponse(kT2HostName, // "www.ccs.neu.edu"
|
| + kT2Qtype,
|
| + 2 /* id */,
|
| + reinterpret_cast<const char*>(kT2ResponseDatagram),
|
| + arraysize(kT2ResponseDatagram));
|
| PrepareSockets();
|
|
|
| TransactionHelper helper0("www",
|
| @@ -767,16 +799,14 @@ TEST_F(DnsTransactionTest, SyncSearchQuery) {
|
| config_.search.push_back("ccs.neu.edu");
|
| ConfigureFactory();
|
|
|
| - AddRcode("www.lab.ccs.neu.edu",
|
| - dns_protocol::kTypeA,
|
| - dns_protocol::kRcodeNXDOMAIN,
|
| - ASYNC);
|
| - AddResponse(kT2HostName,
|
| - kT2Qtype,
|
| - 2 /* id */,
|
| - reinterpret_cast<const char*>(kT2ResponseDatagram),
|
| - arraysize(kT2ResponseDatagram),
|
| - SYNCHRONOUS);
|
| + AddAsyncRcode("www.lab.ccs.neu.edu",
|
| + dns_protocol::kTypeA,
|
| + dns_protocol::kRcodeNXDOMAIN);
|
| + AddSyncResponse(kT2HostName,
|
| + kT2Qtype,
|
| + 2 /* id */,
|
| + reinterpret_cast<const char*>(kT2ResponseDatagram),
|
| + arraysize(kT2ResponseDatagram));
|
| PrepareSockets();
|
|
|
| TransactionHelper helper0("www",
|
|
|