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

Side by Side Diff: net/dns/dns_config_service_posix_unittest.cc

Issue 10546081: [net/dns] If the only name server is 0.0.0.0:53 assume DnsConfig is invalid. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Initialize sockaddr_in. Created 8 years, 6 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <resolv.h> 5 #include <resolv.h>
6 6
7 #include "base/sys_byteorder.h" 7 #include "base/sys_byteorder.h"
8 #include "net/dns/dns_config_service_posix.h" 8 #include "net/dns/dns_config_service_posix.h"
9 9
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 ASSERT_TRUE(internal::ConvertResStateToDnsConfig(res, &config)); 115 ASSERT_TRUE(internal::ConvertResStateToDnsConfig(res, &config));
116 CloseResState(&res); 116 CloseResState(&res);
117 EXPECT_TRUE(config.IsValid()); 117 EXPECT_TRUE(config.IsValid());
118 118
119 DnsConfig expected_config; 119 DnsConfig expected_config;
120 EXPECT_FALSE(expected_config.EqualsIgnoreHosts(config)); 120 EXPECT_FALSE(expected_config.EqualsIgnoreHosts(config));
121 InitializeExpectedConfig(&expected_config); 121 InitializeExpectedConfig(&expected_config);
122 EXPECT_TRUE(expected_config.EqualsIgnoreHosts(config)); 122 EXPECT_TRUE(expected_config.EqualsIgnoreHosts(config));
123 } 123 }
124 124
125 TEST(DnsConfigServicePosixTest, RejectDefaultNameserver) {
126 struct __res_state res = {};
127 res.options = RES_INIT;
128 const char kDnsrch[] = "chromium.org";
129 memcpy(res.defdname, kDnsrch, sizeof(kDnsrch));
130 res.dnsrch[0] = res.defdname;
131
132 struct sockaddr_in sa = {};
133 sa.sin_family = AF_INET;
134 sa.sin_port = base::HostToNet16(NS_DEFAULTPORT);
135 sa.sin_addr.s_addr = INADDR_ANY;
136 res.nsaddr_list[0] = sa;
137 res.nscount = 1;
138
139 DnsConfig config;
140 EXPECT_FALSE(internal::ConvertResStateToDnsConfig(res, &config));
141
142 sa.sin_addr.s_addr = 0xDEADBEEF;
143 res.nsaddr_list[0] = sa;
144 EXPECT_TRUE(internal::ConvertResStateToDnsConfig(res, &config));
145 }
146
125 } // namespace 147 } // namespace
126 } // namespace net 148 } // namespace net
OLDNEW
« net/dns/dns_config_service_posix.cc ('K') | « net/dns/dns_config_service_posix.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698