| Index: net/dns/dns_transaction_unittest.cc
|
| diff --git a/net/dns/dns_transaction_unittest.cc b/net/dns/dns_transaction_unittest.cc
|
| index 67a045719b054f08a865799fe6e4bcf44bcfe38a..94c9b3b490b19c09892f65146533ca1470bc2a55 100644
|
| --- a/net/dns/dns_transaction_unittest.cc
|
| +++ b/net/dns/dns_transaction_unittest.cc
|
| @@ -44,34 +44,31 @@ class DnsSocketData {
|
| if (use_tcp_) {
|
| scoped_ptr<uint16> length(new uint16);
|
| *length = base::HostToNet16(query_->io_buffer()->size());
|
| - writes_.push_back(MockWrite(mode,
|
| - reinterpret_cast<const char*>(length.get()),
|
| - sizeof(uint16)));
|
| + writes_.push_back(MockWrite(
|
| + mode, reinterpret_cast<const char*>(length.get()), sizeof(uint16)));
|
| lengths_.push_back(length.release());
|
| }
|
| - writes_.push_back(MockWrite(mode,
|
| - query_->io_buffer()->data(),
|
| - query_->io_buffer()->size()));
|
| + writes_.push_back(MockWrite(
|
| + mode, query_->io_buffer()->data(), query_->io_buffer()->size()));
|
| }
|
| ~DnsSocketData() {}
|
|
|
| // All responses must be added before GetProvider.
|
|
|
| // Adds pre-built DnsResponse. |tcp_length| will be used in TCP mode only.
|
| - void AddResponseWithLength(scoped_ptr<DnsResponse> response, IoMode mode,
|
| + void AddResponseWithLength(scoped_ptr<DnsResponse> response,
|
| + IoMode mode,
|
| uint16 tcp_length) {
|
| CHECK(!provider_.get());
|
| if (use_tcp_) {
|
| scoped_ptr<uint16> length(new uint16);
|
| *length = base::HostToNet16(tcp_length);
|
| - reads_.push_back(MockRead(mode,
|
| - reinterpret_cast<const char*>(length.get()),
|
| - sizeof(uint16)));
|
| + reads_.push_back(MockRead(
|
| + mode, reinterpret_cast<const char*>(length.get()), sizeof(uint16)));
|
| lengths_.push_back(length.release());
|
| }
|
| - reads_.push_back(MockRead(mode,
|
| - response->io_buffer()->data(),
|
| - response->io_buffer()->size()));
|
| + reads_.push_back(MockRead(
|
| + mode, response->io_buffer()->data(), response->io_buffer()->size()));
|
| responses_.push_back(response.release());
|
| }
|
|
|
| @@ -84,16 +81,15 @@ class DnsSocketData {
|
| // Adds pre-built response from |data| buffer.
|
| void AddResponseData(const uint8* data, size_t length, IoMode mode) {
|
| CHECK(!provider_.get());
|
| - AddResponse(make_scoped_ptr(
|
| - new DnsResponse(reinterpret_cast<const char*>(data), length, 0)), mode);
|
| + AddResponse(make_scoped_ptr(new DnsResponse(
|
| + reinterpret_cast<const char*>(data), length, 0)),
|
| + mode);
|
| }
|
|
|
| // Add no-answer (RCODE only) response matching the query.
|
| void AddRcode(int rcode, IoMode mode) {
|
| - scoped_ptr<DnsResponse> response(
|
| - new DnsResponse(query_->io_buffer()->data(),
|
| - query_->io_buffer()->size(),
|
| - 0));
|
| + scoped_ptr<DnsResponse> response(new DnsResponse(
|
| + query_->io_buffer()->data(), query_->io_buffer()->size(), 0));
|
| dns_protocol::Header* header =
|
| reinterpret_cast<dns_protocol::Header*>(response->io_buffer()->data());
|
| header->flags |= base::HostToNet16(dns_protocol::kFlagResponse | rcode);
|
| @@ -108,17 +104,15 @@ class DnsSocketData {
|
| // Terminate the reads with ERR_IO_PENDING to prevent overrun and default to
|
| // timeout.
|
| reads_.push_back(MockRead(ASYNC, ERR_IO_PENDING));
|
| - provider_.reset(new DelayedSocketData(1, &reads_[0], reads_.size(),
|
| - &writes_[0], writes_.size()));
|
| + provider_.reset(new DelayedSocketData(
|
| + 1, &reads_[0], reads_.size(), &writes_[0], writes_.size()));
|
| if (use_tcp_) {
|
| provider_->set_connect_data(MockConnect(reads_[0].mode, OK));
|
| }
|
| return provider_.get();
|
| }
|
|
|
| - uint16 query_id() const {
|
| - return query_->id();
|
| - }
|
| + uint16 query_id() const { return query_->id(); }
|
|
|
| // Returns true if the expected query was written to the socket.
|
| bool was_written() const {
|
| @@ -143,10 +137,8 @@ class TestSocketFactory;
|
| // A variant of MockUDPClientSocket which always fails to Connect.
|
| class FailingUDPClientSocket : public MockUDPClientSocket {
|
| public:
|
| - FailingUDPClientSocket(SocketDataProvider* data,
|
| - net::NetLog* net_log)
|
| - : MockUDPClientSocket(data, net_log) {
|
| - }
|
| + FailingUDPClientSocket(SocketDataProvider* data, net::NetLog* net_log)
|
| + : MockUDPClientSocket(data, net_log) {}
|
| virtual ~FailingUDPClientSocket() {}
|
| virtual int Connect(const IPEndPoint& endpoint) OVERRIDE {
|
| return ERR_CONNECTION_REFUSED;
|
| @@ -162,8 +154,7 @@ class TestUDPClientSocket : public MockUDPClientSocket {
|
| TestUDPClientSocket(TestSocketFactory* factory,
|
| SocketDataProvider* data,
|
| net::NetLog* net_log)
|
| - : MockUDPClientSocket(data, net_log), factory_(factory) {
|
| - }
|
| + : MockUDPClientSocket(data, net_log), factory_(factory) {}
|
| virtual ~TestUDPClientSocket() {}
|
| virtual int Connect(const IPEndPoint& endpoint) OVERRIDE;
|
|
|
| @@ -226,18 +217,13 @@ class TransactionHelper {
|
| expected_answer_count_(expected_answer_count),
|
| cancel_in_callback_(false),
|
| quit_in_callback_(false),
|
| - completed_(false) {
|
| - }
|
| + completed_(false) {}
|
|
|
| // Mark that the transaction shall be destroyed immediately upon callback.
|
| - void set_cancel_in_callback() {
|
| - cancel_in_callback_ = true;
|
| - }
|
| + void set_cancel_in_callback() { cancel_in_callback_ = true; }
|
|
|
| // Mark to call MessageLoop::Quit() upon callback.
|
| - void set_quit_in_callback() {
|
| - quit_in_callback_ = true;
|
| - }
|
| + void set_quit_in_callback() { quit_in_callback_ = true; }
|
|
|
| void StartTransaction(DnsTransactionFactory* factory) {
|
| EXPECT_EQ(NULL, transaction_.get());
|
| @@ -291,9 +277,7 @@ class TransactionHelper {
|
| }
|
| }
|
|
|
| - bool has_completed() const {
|
| - return completed_;
|
| - }
|
| + bool has_completed() const { return completed_; }
|
|
|
| // Shorthands for commonly used commands.
|
|
|
| @@ -337,8 +321,8 @@ class DnsTransactionTest : public testing::Test {
|
| }
|
| for (unsigned i = 0; i < num_servers; ++i) {
|
| dns_ip[3] = i;
|
| - config_.nameservers.push_back(IPEndPoint(dns_ip,
|
| - dns_protocol::kDefaultPort));
|
| + config_.nameservers.push_back(
|
| + IPEndPoint(dns_ip, dns_protocol::kDefaultPort));
|
| }
|
| }
|
|
|
| @@ -382,8 +366,8 @@ class DnsTransactionTest : public testing::Test {
|
| uint16 qtype,
|
| const uint8* data,
|
| size_t data_length) {
|
| - AddQueryAndResponse(id, dotted_name, qtype, data, data_length, ASYNC,
|
| - false);
|
| + AddQueryAndResponse(
|
| + id, dotted_name, qtype, data, data_length, ASYNC, false);
|
| }
|
|
|
| void AddSyncQueryAndResponse(uint16 id,
|
| @@ -391,8 +375,8 @@ class DnsTransactionTest : public testing::Test {
|
| uint16 qtype,
|
| const uint8* data,
|
| size_t data_length) {
|
| - AddQueryAndResponse(id, dotted_name, qtype, data, data_length, SYNCHRONOUS,
|
| - false);
|
| + AddQueryAndResponse(
|
| + id, dotted_name, qtype, data, data_length, SYNCHRONOUS, false);
|
| }
|
|
|
| // Add expected query of |dotted_name| and |qtype| and no response.
|
| @@ -474,8 +458,11 @@ class DnsTransactionTest : public testing::Test {
|
| };
|
|
|
| TEST_F(DnsTransactionTest, Lookup) {
|
| - AddAsyncQueryAndResponse(0 /* id */, kT0HostName, kT0Qtype,
|
| - kT0ResponseDatagram, arraysize(kT0ResponseDatagram));
|
| + AddAsyncQueryAndResponse(0 /* id */,
|
| + kT0HostName,
|
| + kT0Qtype,
|
| + kT0ResponseDatagram,
|
| + arraysize(kT0ResponseDatagram));
|
|
|
| TransactionHelper helper0(kT0HostName, kT0Qtype, kT0RecordCount);
|
| EXPECT_TRUE(helper0.Run(transaction_factory_.get()));
|
| @@ -484,10 +471,16 @@ TEST_F(DnsTransactionTest, Lookup) {
|
| // Concurrent lookup tests assume that DnsTransaction::Start immediately
|
| // consumes a socket from ClientSocketFactory.
|
| TEST_F(DnsTransactionTest, ConcurrentLookup) {
|
| - AddAsyncQueryAndResponse(0 /* id */, kT0HostName, kT0Qtype,
|
| - kT0ResponseDatagram, arraysize(kT0ResponseDatagram));
|
| - AddAsyncQueryAndResponse(1 /* id */, kT1HostName, kT1Qtype,
|
| - kT1ResponseDatagram, arraysize(kT1ResponseDatagram));
|
| + AddAsyncQueryAndResponse(0 /* id */,
|
| + kT0HostName,
|
| + kT0Qtype,
|
| + kT0ResponseDatagram,
|
| + arraysize(kT0ResponseDatagram));
|
| + AddAsyncQueryAndResponse(1 /* id */,
|
| + kT1HostName,
|
| + kT1Qtype,
|
| + kT1ResponseDatagram,
|
| + arraysize(kT1ResponseDatagram));
|
|
|
| TransactionHelper helper0(kT0HostName, kT0Qtype, kT0RecordCount);
|
| helper0.StartTransaction(transaction_factory_.get());
|
| @@ -501,10 +494,16 @@ TEST_F(DnsTransactionTest, ConcurrentLookup) {
|
| }
|
|
|
| TEST_F(DnsTransactionTest, CancelLookup) {
|
| - AddAsyncQueryAndResponse(0 /* id */, kT0HostName, kT0Qtype,
|
| - kT0ResponseDatagram, arraysize(kT0ResponseDatagram));
|
| - AddAsyncQueryAndResponse(1 /* id */, kT1HostName, kT1Qtype,
|
| - kT1ResponseDatagram, arraysize(kT1ResponseDatagram));
|
| + AddAsyncQueryAndResponse(0 /* id */,
|
| + kT0HostName,
|
| + kT0Qtype,
|
| + kT0ResponseDatagram,
|
| + arraysize(kT0ResponseDatagram));
|
| + AddAsyncQueryAndResponse(1 /* id */,
|
| + kT1HostName,
|
| + kT1Qtype,
|
| + kT1ResponseDatagram,
|
| + arraysize(kT1ResponseDatagram));
|
|
|
| TransactionHelper helper0(kT0HostName, kT0Qtype, kT0RecordCount);
|
| helper0.StartTransaction(transaction_factory_.get());
|
| @@ -520,8 +519,11 @@ TEST_F(DnsTransactionTest, CancelLookup) {
|
| }
|
|
|
| TEST_F(DnsTransactionTest, DestroyFactory) {
|
| - AddAsyncQueryAndResponse(0 /* id */, kT0HostName, kT0Qtype,
|
| - kT0ResponseDatagram, arraysize(kT0ResponseDatagram));
|
| + AddAsyncQueryAndResponse(0 /* id */,
|
| + kT0HostName,
|
| + kT0Qtype,
|
| + kT0ResponseDatagram,
|
| + arraysize(kT0ResponseDatagram));
|
|
|
| TransactionHelper helper0(kT0HostName, kT0Qtype, kT0RecordCount);
|
| helper0.StartTransaction(transaction_factory_.get());
|
| @@ -535,8 +537,11 @@ TEST_F(DnsTransactionTest, DestroyFactory) {
|
| }
|
|
|
| TEST_F(DnsTransactionTest, CancelFromCallback) {
|
| - AddAsyncQueryAndResponse(0 /* id */, kT0HostName, kT0Qtype,
|
| - kT0ResponseDatagram, arraysize(kT0ResponseDatagram));
|
| + AddAsyncQueryAndResponse(0 /* id */,
|
| + kT0HostName,
|
| + kT0Qtype,
|
| + kT0ResponseDatagram,
|
| + arraysize(kT0ResponseDatagram));
|
|
|
| TransactionHelper helper0(kT0HostName, kT0Qtype, kT0RecordCount);
|
| helper0.set_cancel_in_callback();
|
| @@ -551,10 +556,10 @@ TEST_F(DnsTransactionTest, MismatchedResponseSync) {
|
| // Attempt receives mismatched response followed by valid response.
|
| scoped_ptr<DnsSocketData> data(
|
| new DnsSocketData(0 /* id */, kT0HostName, kT0Qtype, SYNCHRONOUS, false));
|
| - data->AddResponseData(kT1ResponseDatagram,
|
| - arraysize(kT1ResponseDatagram), SYNCHRONOUS);
|
| - data->AddResponseData(kT0ResponseDatagram,
|
| - arraysize(kT0ResponseDatagram), SYNCHRONOUS);
|
| + data->AddResponseData(
|
| + kT1ResponseDatagram, arraysize(kT1ResponseDatagram), SYNCHRONOUS);
|
| + data->AddResponseData(
|
| + kT0ResponseDatagram, arraysize(kT0ResponseDatagram), SYNCHRONOUS);
|
| AddSocketData(data.Pass());
|
|
|
| TransactionHelper helper0(kT0HostName, kT0Qtype, kT0RecordCount);
|
| @@ -570,10 +575,10 @@ TEST_F(DnsTransactionTest, MismatchedResponseAsync) {
|
| // Second attempt times out.
|
| scoped_ptr<DnsSocketData> data(
|
| new DnsSocketData(0 /* id */, kT0HostName, kT0Qtype, ASYNC, false));
|
| - data->AddResponseData(kT1ResponseDatagram,
|
| - arraysize(kT1ResponseDatagram), ASYNC);
|
| - data->AddResponseData(kT0ResponseDatagram,
|
| - arraysize(kT0ResponseDatagram), ASYNC);
|
| + data->AddResponseData(
|
| + kT1ResponseDatagram, arraysize(kT1ResponseDatagram), ASYNC);
|
| + data->AddResponseData(
|
| + kT0ResponseDatagram, arraysize(kT0ResponseDatagram), ASYNC);
|
| AddSocketData(data.Pass());
|
| AddQueryAndTimeout(kT0HostName, kT0Qtype);
|
|
|
| @@ -587,8 +592,11 @@ TEST_F(DnsTransactionTest, MismatchedResponseFail) {
|
|
|
| // Attempt receives mismatched response but times out because only one attempt
|
| // is allowed.
|
| - AddAsyncQueryAndResponse(1 /* id */, kT0HostName, kT0Qtype,
|
| - kT0ResponseDatagram, arraysize(kT0ResponseDatagram));
|
| + AddAsyncQueryAndResponse(1 /* id */,
|
| + kT0HostName,
|
| + kT0Qtype,
|
| + kT0ResponseDatagram,
|
| + arraysize(kT0ResponseDatagram));
|
|
|
| TransactionHelper helper0(kT0HostName, kT0Qtype, ERR_DNS_TIMED_OUT);
|
| EXPECT_TRUE(helper0.RunUntilDone(transaction_factory_.get()));
|
| @@ -651,8 +659,8 @@ TEST_F(DnsTransactionTest, ServerFallbackAndRotate) {
|
| EXPECT_TRUE(helper1.Run(transaction_factory_.get()));
|
|
|
| unsigned kOrder[] = {
|
| - 0, 1, 2, 0, 1, // The first transaction.
|
| - 1, 2, 0, // The second transaction starts from the next server.
|
| + 0, 1, 2, 0, 1, // The first transaction.
|
| + 1, 2, 0, // The second transaction starts from the next server.
|
| };
|
| CheckServerOrder(kOrder, arraysize(kOrder));
|
| }
|
| @@ -666,22 +674,22 @@ TEST_F(DnsTransactionTest, SuffixSearchAboveNdots) {
|
| ConfigureNumServers(2);
|
| ConfigureFactory();
|
|
|
| - AddAsyncQueryAndRcode("x.y.z", dns_protocol::kTypeA,
|
| - dns_protocol::kRcodeNXDOMAIN);
|
| - AddAsyncQueryAndRcode("x.y.z.a", dns_protocol::kTypeA,
|
| - dns_protocol::kRcodeNXDOMAIN);
|
| - AddAsyncQueryAndRcode("x.y.z.b", dns_protocol::kTypeA,
|
| - dns_protocol::kRcodeNXDOMAIN);
|
| - AddAsyncQueryAndRcode("x.y.z.c", dns_protocol::kTypeA,
|
| - dns_protocol::kRcodeNXDOMAIN);
|
| + AddAsyncQueryAndRcode(
|
| + "x.y.z", dns_protocol::kTypeA, dns_protocol::kRcodeNXDOMAIN);
|
| + AddAsyncQueryAndRcode(
|
| + "x.y.z.a", dns_protocol::kTypeA, dns_protocol::kRcodeNXDOMAIN);
|
| + AddAsyncQueryAndRcode(
|
| + "x.y.z.b", dns_protocol::kTypeA, dns_protocol::kRcodeNXDOMAIN);
|
| + AddAsyncQueryAndRcode(
|
| + "x.y.z.c", dns_protocol::kTypeA, dns_protocol::kRcodeNXDOMAIN);
|
|
|
| - TransactionHelper helper0("x.y.z", dns_protocol::kTypeA,
|
| - ERR_NAME_NOT_RESOLVED);
|
| + TransactionHelper helper0(
|
| + "x.y.z", dns_protocol::kTypeA, ERR_NAME_NOT_RESOLVED);
|
|
|
| EXPECT_TRUE(helper0.Run(transaction_factory_.get()));
|
|
|
| // Also check if suffix search causes server rotation.
|
| - unsigned kOrder0[] = { 0, 1, 0, 1 };
|
| + unsigned kOrder0[] = {0, 1, 0, 1};
|
| CheckServerOrder(kOrder0, arraysize(kOrder0));
|
| }
|
|
|
| @@ -693,24 +701,24 @@ TEST_F(DnsTransactionTest, SuffixSearchBelowNdots) {
|
| ConfigureFactory();
|
|
|
| // Responses for first transaction.
|
| - AddAsyncQueryAndRcode("x.y.a", dns_protocol::kTypeA,
|
| - dns_protocol::kRcodeNXDOMAIN);
|
| - AddAsyncQueryAndRcode("x.y.b", dns_protocol::kTypeA,
|
| - dns_protocol::kRcodeNXDOMAIN);
|
| - AddAsyncQueryAndRcode("x.y.c", dns_protocol::kTypeA,
|
| - dns_protocol::kRcodeNXDOMAIN);
|
| - AddAsyncQueryAndRcode("x.y", dns_protocol::kTypeA,
|
| - dns_protocol::kRcodeNXDOMAIN);
|
| + AddAsyncQueryAndRcode(
|
| + "x.y.a", dns_protocol::kTypeA, dns_protocol::kRcodeNXDOMAIN);
|
| + AddAsyncQueryAndRcode(
|
| + "x.y.b", dns_protocol::kTypeA, dns_protocol::kRcodeNXDOMAIN);
|
| + AddAsyncQueryAndRcode(
|
| + "x.y.c", dns_protocol::kTypeA, dns_protocol::kRcodeNXDOMAIN);
|
| + AddAsyncQueryAndRcode(
|
| + "x.y", dns_protocol::kTypeA, dns_protocol::kRcodeNXDOMAIN);
|
| // Responses for second transaction.
|
| - AddAsyncQueryAndRcode("x.a", dns_protocol::kTypeA,
|
| - dns_protocol::kRcodeNXDOMAIN);
|
| - AddAsyncQueryAndRcode("x.b", dns_protocol::kTypeA,
|
| - dns_protocol::kRcodeNXDOMAIN);
|
| - AddAsyncQueryAndRcode("x.c", dns_protocol::kTypeA,
|
| - dns_protocol::kRcodeNXDOMAIN);
|
| + AddAsyncQueryAndRcode(
|
| + "x.a", dns_protocol::kTypeA, dns_protocol::kRcodeNXDOMAIN);
|
| + AddAsyncQueryAndRcode(
|
| + "x.b", dns_protocol::kTypeA, dns_protocol::kRcodeNXDOMAIN);
|
| + AddAsyncQueryAndRcode(
|
| + "x.c", dns_protocol::kTypeA, dns_protocol::kRcodeNXDOMAIN);
|
| // Responses for third transaction.
|
| - AddAsyncQueryAndRcode("x", dns_protocol::kTypeAAAA,
|
| - dns_protocol::kRcodeNXDOMAIN);
|
| + AddAsyncQueryAndRcode(
|
| + "x", dns_protocol::kTypeAAAA, dns_protocol::kRcodeNXDOMAIN);
|
|
|
| TransactionHelper helper0("x.y", dns_protocol::kTypeA, ERR_NAME_NOT_RESOLVED);
|
|
|
| @@ -722,16 +730,16 @@ TEST_F(DnsTransactionTest, SuffixSearchBelowNdots) {
|
| EXPECT_TRUE(helper1.Run(transaction_factory_.get()));
|
|
|
| // A fully-qualified name.
|
| - TransactionHelper helper2("x.", dns_protocol::kTypeAAAA,
|
| - ERR_NAME_NOT_RESOLVED);
|
| + TransactionHelper helper2(
|
| + "x.", dns_protocol::kTypeAAAA, ERR_NAME_NOT_RESOLVED);
|
|
|
| EXPECT_TRUE(helper2.Run(transaction_factory_.get()));
|
| }
|
|
|
| TEST_F(DnsTransactionTest, EmptySuffixSearch) {
|
| // Responses for first transaction.
|
| - AddAsyncQueryAndRcode("x", dns_protocol::kTypeA,
|
| - dns_protocol::kRcodeNXDOMAIN);
|
| + AddAsyncQueryAndRcode(
|
| + "x", dns_protocol::kTypeA, dns_protocol::kRcodeNXDOMAIN);
|
|
|
| // A fully-qualified name.
|
| TransactionHelper helper0("x.", dns_protocol::kTypeA, ERR_NAME_NOT_RESOLVED);
|
| @@ -739,8 +747,8 @@ TEST_F(DnsTransactionTest, EmptySuffixSearch) {
|
| EXPECT_TRUE(helper0.Run(transaction_factory_.get()));
|
|
|
| // A single label name is not even attempted.
|
| - TransactionHelper helper1("singlelabel", dns_protocol::kTypeA,
|
| - ERR_DNS_SEARCH_EMPTY);
|
| + TransactionHelper helper1(
|
| + "singlelabel", dns_protocol::kTypeA, ERR_DNS_SEARCH_EMPTY);
|
|
|
| helper1.Run(transaction_factory_.get());
|
| EXPECT_TRUE(helper1.has_completed());
|
| @@ -754,21 +762,21 @@ TEST_F(DnsTransactionTest, DontAppendToMultiLabelName) {
|
| ConfigureFactory();
|
|
|
| // Responses for first transaction.
|
| - AddAsyncQueryAndRcode("x.y.z", dns_protocol::kTypeA,
|
| - dns_protocol::kRcodeNXDOMAIN);
|
| + AddAsyncQueryAndRcode(
|
| + "x.y.z", dns_protocol::kTypeA, dns_protocol::kRcodeNXDOMAIN);
|
| // Responses for second transaction.
|
| - AddAsyncQueryAndRcode("x.y", dns_protocol::kTypeA,
|
| - dns_protocol::kRcodeNXDOMAIN);
|
| + AddAsyncQueryAndRcode(
|
| + "x.y", dns_protocol::kTypeA, dns_protocol::kRcodeNXDOMAIN);
|
| // Responses for third transaction.
|
| - AddAsyncQueryAndRcode("x.a", dns_protocol::kTypeA,
|
| - dns_protocol::kRcodeNXDOMAIN);
|
| - AddAsyncQueryAndRcode("x.b", dns_protocol::kTypeA,
|
| - dns_protocol::kRcodeNXDOMAIN);
|
| - AddAsyncQueryAndRcode("x.c", dns_protocol::kTypeA,
|
| - dns_protocol::kRcodeNXDOMAIN);
|
| -
|
| - TransactionHelper helper0("x.y.z", dns_protocol::kTypeA,
|
| - ERR_NAME_NOT_RESOLVED);
|
| + AddAsyncQueryAndRcode(
|
| + "x.a", dns_protocol::kTypeA, dns_protocol::kRcodeNXDOMAIN);
|
| + AddAsyncQueryAndRcode(
|
| + "x.b", dns_protocol::kTypeA, dns_protocol::kRcodeNXDOMAIN);
|
| + AddAsyncQueryAndRcode(
|
| + "x.c", dns_protocol::kTypeA, dns_protocol::kRcodeNXDOMAIN);
|
| +
|
| + TransactionHelper helper0(
|
| + "x.y.z", dns_protocol::kTypeA, ERR_NAME_NOT_RESOLVED);
|
| EXPECT_TRUE(helper0.Run(transaction_factory_.get()));
|
|
|
| TransactionHelper helper1("x.y", dns_protocol::kTypeA, ERR_NAME_NOT_RESOLVED);
|
| @@ -779,18 +787,15 @@ TEST_F(DnsTransactionTest, DontAppendToMultiLabelName) {
|
| }
|
|
|
| const uint8 kResponseNoData[] = {
|
| - 0x00, 0x00, 0x81, 0x80, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00,
|
| - // Question
|
| - 0x01, 'x', 0x01, 'y', 0x01, 'z', 0x01, 'b', 0x00, 0x00, 0x01, 0x00, 0x01,
|
| - // Authority section, SOA record, TTL 0x3E6
|
| - 0x01, 'z', 0x00, 0x00, 0x06, 0x00, 0x01, 0x00, 0x00, 0x03, 0xE6,
|
| - // Minimal RDATA, 18 bytes
|
| - 0x00, 0x12,
|
| - 0x00, 0x00,
|
| - 0x00, 0x00, 0x00, 0x00,
|
| - 0x00, 0x00, 0x00, 0x00,
|
| - 0x00, 0x00, 0x00, 0x00,
|
| - 0x00, 0x00, 0x00, 0x00,
|
| + 0x00, 0x00, 0x81, 0x80, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00,
|
| + // Question
|
| + 0x01, 'x', 0x01, 'y', 0x01, 'z', 0x01, 'b', 0x00, 0x00, 0x01, 0x00,
|
| + 0x01,
|
| + // Authority section, SOA record, TTL 0x3E6
|
| + 0x01, 'z', 0x00, 0x00, 0x06, 0x00, 0x01, 0x00, 0x00, 0x03, 0xE6,
|
| + // Minimal RDATA, 18 bytes
|
| + 0x00, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
| + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
| };
|
|
|
| TEST_F(DnsTransactionTest, SuffixSearchStop) {
|
| @@ -800,12 +805,15 @@ TEST_F(DnsTransactionTest, SuffixSearchStop) {
|
| config_.search.push_back("c");
|
| ConfigureFactory();
|
|
|
| - AddAsyncQueryAndRcode("x.y.z", dns_protocol::kTypeA,
|
| - dns_protocol::kRcodeNXDOMAIN);
|
| - AddAsyncQueryAndRcode("x.y.z.a", dns_protocol::kTypeA,
|
| - dns_protocol::kRcodeNXDOMAIN);
|
| - AddAsyncQueryAndResponse(0 /* id */, "x.y.z.b", dns_protocol::kTypeA,
|
| - kResponseNoData, arraysize(kResponseNoData));
|
| + AddAsyncQueryAndRcode(
|
| + "x.y.z", dns_protocol::kTypeA, dns_protocol::kRcodeNXDOMAIN);
|
| + AddAsyncQueryAndRcode(
|
| + "x.y.z.a", dns_protocol::kTypeA, dns_protocol::kRcodeNXDOMAIN);
|
| + AddAsyncQueryAndResponse(0 /* id */,
|
| + "x.y.z.b",
|
| + dns_protocol::kTypeA,
|
| + kResponseNoData,
|
| + arraysize(kResponseNoData));
|
|
|
| TransactionHelper helper0("x.y.z", dns_protocol::kTypeA, 0 /* answers */);
|
|
|
| @@ -817,8 +825,11 @@ TEST_F(DnsTransactionTest, SyncFirstQuery) {
|
| config_.search.push_back("ccs.neu.edu");
|
| ConfigureFactory();
|
|
|
| - AddSyncQueryAndResponse(0 /* id */, kT0HostName, kT0Qtype,
|
| - kT0ResponseDatagram, arraysize(kT0ResponseDatagram));
|
| + AddSyncQueryAndResponse(0 /* id */,
|
| + kT0HostName,
|
| + kT0Qtype,
|
| + kT0ResponseDatagram,
|
| + arraysize(kT0ResponseDatagram));
|
|
|
| TransactionHelper helper0(kT0HostName, kT0Qtype, kT0RecordCount);
|
| EXPECT_TRUE(helper0.Run(transaction_factory_.get()));
|
| @@ -829,11 +840,14 @@ TEST_F(DnsTransactionTest, SyncFirstQueryWithSearch) {
|
| config_.search.push_back("ccs.neu.edu");
|
| ConfigureFactory();
|
|
|
| - AddSyncQueryAndRcode("www.lab.ccs.neu.edu", kT2Qtype,
|
| - dns_protocol::kRcodeNXDOMAIN);
|
| + AddSyncQueryAndRcode(
|
| + "www.lab.ccs.neu.edu", kT2Qtype, dns_protocol::kRcodeNXDOMAIN);
|
| // "www.ccs.neu.edu"
|
| - AddAsyncQueryAndResponse(2 /* id */, kT2HostName, kT2Qtype,
|
| - kT2ResponseDatagram, arraysize(kT2ResponseDatagram));
|
| + AddAsyncQueryAndResponse(2 /* id */,
|
| + kT2HostName,
|
| + kT2Qtype,
|
| + kT2ResponseDatagram,
|
| + arraysize(kT2ResponseDatagram));
|
|
|
| TransactionHelper helper0("www", kT2Qtype, kT2RecordCount);
|
| EXPECT_TRUE(helper0.Run(transaction_factory_.get()));
|
| @@ -844,10 +858,14 @@ TEST_F(DnsTransactionTest, SyncSearchQuery) {
|
| config_.search.push_back("ccs.neu.edu");
|
| ConfigureFactory();
|
|
|
| - AddAsyncQueryAndRcode("www.lab.ccs.neu.edu", dns_protocol::kTypeA,
|
| + AddAsyncQueryAndRcode("www.lab.ccs.neu.edu",
|
| + dns_protocol::kTypeA,
|
| dns_protocol::kRcodeNXDOMAIN);
|
| - AddSyncQueryAndResponse(2 /* id */, kT2HostName, kT2Qtype,
|
| - kT2ResponseDatagram, arraysize(kT2ResponseDatagram));
|
| + AddSyncQueryAndResponse(2 /* id */,
|
| + kT2HostName,
|
| + kT2Qtype,
|
| + kT2ResponseDatagram,
|
| + arraysize(kT2ResponseDatagram));
|
|
|
| TransactionHelper helper0("www", kT2Qtype, kT2RecordCount);
|
| EXPECT_TRUE(helper0.Run(transaction_factory_.get()));
|
| @@ -856,8 +874,8 @@ TEST_F(DnsTransactionTest, SyncSearchQuery) {
|
| TEST_F(DnsTransactionTest, ConnectFailure) {
|
| socket_factory_->fail_next_socket_ = true;
|
| transaction_ids_.push_back(0); // Needed to make a DnsUDPAttempt.
|
| - TransactionHelper helper0("www.chromium.org", dns_protocol::kTypeA,
|
| - ERR_CONNECTION_REFUSED);
|
| + TransactionHelper helper0(
|
| + "www.chromium.org", dns_protocol::kTypeA, ERR_CONNECTION_REFUSED);
|
| EXPECT_TRUE(helper0.Run(transaction_factory_.get()));
|
| }
|
|
|
| @@ -869,35 +887,48 @@ TEST_F(DnsTransactionTest, ConnectFailureFollowedBySuccess) {
|
| transaction_ids_.push_back(0); // Needed to make a DnsUDPAttempt.
|
| socket_factory_->fail_next_socket_ = true;
|
| // Second DNS query succeeds.
|
| - AddAsyncQueryAndResponse(0 /* id */, kT0HostName, kT0Qtype,
|
| - kT0ResponseDatagram, arraysize(kT0ResponseDatagram));
|
| + AddAsyncQueryAndResponse(0 /* id */,
|
| + kT0HostName,
|
| + kT0Qtype,
|
| + kT0ResponseDatagram,
|
| + arraysize(kT0ResponseDatagram));
|
| TransactionHelper helper0(kT0HostName, kT0Qtype, kT0RecordCount);
|
| EXPECT_TRUE(helper0.Run(transaction_factory_.get()));
|
| }
|
|
|
| TEST_F(DnsTransactionTest, TCPLookup) {
|
| - AddAsyncQueryAndRcode(kT0HostName, kT0Qtype,
|
| + AddAsyncQueryAndRcode(kT0HostName,
|
| + kT0Qtype,
|
| dns_protocol::kRcodeNOERROR | dns_protocol::kFlagTC);
|
| - AddQueryAndResponse(0 /* id */, kT0HostName, kT0Qtype,
|
| - kT0ResponseDatagram, arraysize(kT0ResponseDatagram),
|
| - ASYNC, true /* use_tcp */);
|
| + AddQueryAndResponse(0 /* id */,
|
| + kT0HostName,
|
| + kT0Qtype,
|
| + kT0ResponseDatagram,
|
| + arraysize(kT0ResponseDatagram),
|
| + ASYNC,
|
| + true /* use_tcp */);
|
|
|
| TransactionHelper helper0(kT0HostName, kT0Qtype, kT0RecordCount);
|
| EXPECT_TRUE(helper0.Run(transaction_factory_.get()));
|
| }
|
|
|
| TEST_F(DnsTransactionTest, TCPFailure) {
|
| - AddAsyncQueryAndRcode(kT0HostName, kT0Qtype,
|
| + AddAsyncQueryAndRcode(kT0HostName,
|
| + kT0Qtype,
|
| dns_protocol::kRcodeNOERROR | dns_protocol::kFlagTC);
|
| - AddQueryAndRcode(kT0HostName, kT0Qtype, dns_protocol::kRcodeSERVFAIL,
|
| - ASYNC, true /* use_tcp */);
|
| + AddQueryAndRcode(kT0HostName,
|
| + kT0Qtype,
|
| + dns_protocol::kRcodeSERVFAIL,
|
| + ASYNC,
|
| + true /* use_tcp */);
|
|
|
| TransactionHelper helper0(kT0HostName, kT0Qtype, ERR_DNS_SERVER_FAILED);
|
| EXPECT_TRUE(helper0.Run(transaction_factory_.get()));
|
| }
|
|
|
| TEST_F(DnsTransactionTest, TCPMalformed) {
|
| - AddAsyncQueryAndRcode(kT0HostName, kT0Qtype,
|
| + AddAsyncQueryAndRcode(kT0HostName,
|
| + kT0Qtype,
|
| dns_protocol::kRcodeNOERROR | dns_protocol::kFlagTC);
|
| scoped_ptr<DnsSocketData> data(
|
| new DnsSocketData(0 /* id */, kT0HostName, kT0Qtype, ASYNC, true));
|
| @@ -905,7 +936,8 @@ TEST_F(DnsTransactionTest, TCPMalformed) {
|
| data->AddResponseWithLength(
|
| make_scoped_ptr(
|
| new DnsResponse(reinterpret_cast<const char*>(kT0ResponseDatagram),
|
| - arraysize(kT0ResponseDatagram), 0)),
|
| + arraysize(kT0ResponseDatagram),
|
| + 0)),
|
| ASYNC,
|
| static_cast<uint16>(kT0QuerySize - 1));
|
| AddSocketData(data.Pass());
|
| @@ -917,7 +949,8 @@ TEST_F(DnsTransactionTest, TCPMalformed) {
|
| TEST_F(DnsTransactionTest, TCPTimeout) {
|
| config_.timeout = TestTimeouts::tiny_timeout();
|
| ConfigureFactory();
|
| - AddAsyncQueryAndRcode(kT0HostName, kT0Qtype,
|
| + AddAsyncQueryAndRcode(kT0HostName,
|
| + kT0Qtype,
|
| dns_protocol::kRcodeNOERROR | dns_protocol::kFlagTC);
|
| AddSocketData(make_scoped_ptr(
|
| new DnsSocketData(1 /* id */, kT0HostName, kT0Qtype, ASYNC, true)));
|
|
|