| OLD | NEW |
| 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 "net/dns/dns_config_service_win.h" | 5 #include "net/dns/dns_config_service_win.h" |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/win/windows_version.h" | 9 #include "base/win/windows_version.h" |
| 10 #include "net/dns/dns_protocol.h" | 10 #include "net/dns/dns_protocol.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 // Empty suffixes terminate the list | 24 // Empty suffixes terminate the list |
| 25 { L"crbug.com,com,,org", { "crbug.com", "com", NULL } }, | 25 { L"crbug.com,com,,org", { "crbug.com", "com", NULL } }, |
| 26 // IDN are converted to punycode | 26 // IDN are converted to punycode |
| 27 { L"\u017c\xf3\u0142ta.pi\u0119\u015b\u0107.pl,pl", | 27 { L"\u017c\xf3\u0142ta.pi\u0119\u015b\u0107.pl,pl", |
| 28 { "xn--ta-4ja03asj.xn--pi-wla5e0q.pl", "pl", NULL } }, | 28 { "xn--ta-4ja03asj.xn--pi-wla5e0q.pl", "pl", NULL } }, |
| 29 // Empty search list is invalid | 29 // Empty search list is invalid |
| 30 { L"", { NULL } }, | 30 { L"", { NULL } }, |
| 31 { L",,", { NULL } }, | 31 { L",,", { NULL } }, |
| 32 }; | 32 }; |
| 33 | 33 |
| 34 std::vector<std::string> actual_output, expected_output; | 34 for (const auto& t : cases) { |
| 35 for (unsigned i = 0; i < arraysize(cases); ++i) { | 35 std::vector<std::string> actual_output, expected_output; |
| 36 const TestCase& t = cases[i]; | |
| 37 actual_output.clear(); | |
| 38 actual_output.push_back("UNSET"); | 36 actual_output.push_back("UNSET"); |
| 39 expected_output.clear(); | |
| 40 for (const char* const* output = t.output; *output; ++output) { | 37 for (const char* const* output = t.output; *output; ++output) { |
| 41 expected_output.push_back(*output); | 38 expected_output.push_back(*output); |
| 42 } | 39 } |
| 43 bool result = internal::ParseSearchList(t.input, &actual_output); | 40 bool result = internal::ParseSearchList(t.input, &actual_output); |
| 44 if (!expected_output.empty()) { | 41 if (!expected_output.empty()) { |
| 45 EXPECT_TRUE(result); | 42 EXPECT_TRUE(result); |
| 46 EXPECT_EQ(expected_output, actual_output); | 43 EXPECT_EQ(expected_output, actual_output); |
| 47 } else { | 44 } else { |
| 48 EXPECT_FALSE(result) << "Unexpected parse success on " << t.input; | 45 EXPECT_FALSE(result) << "Unexpected parse success on " << t.input; |
| 49 } | 46 } |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 { IF_TYPE_SOFTWARE_LOOPBACK, IfOperStatusUp, L"localhost", | 161 { IF_TYPE_SOFTWARE_LOOPBACK, IfOperStatusUp, L"localhost", |
| 165 { "2.0.0.2" } }, | 162 { "2.0.0.2" } }, |
| 166 { IF_TYPE_FASTETHER, IfOperStatusDormant, L"example.com", | 163 { IF_TYPE_FASTETHER, IfOperStatusDormant, L"example.com", |
| 167 { "1.0.0.1" } }, | 164 { "1.0.0.1" } }, |
| 168 { IF_TYPE_USB, IfOperStatusUp, L"chromium.org" }, | 165 { IF_TYPE_USB, IfOperStatusUp, L"chromium.org" }, |
| 169 { 0 }, | 166 { 0 }, |
| 170 }, | 167 }, |
| 171 }, | 168 }, |
| 172 }; | 169 }; |
| 173 | 170 |
| 174 for (size_t i = 0; i < arraysize(cases); ++i) { | 171 for (const auto& t : cases) { |
| 175 const TestCase& t = cases[i]; | 172 internal::DnsSystemSettings settings; |
| 176 internal::DnsSystemSettings settings = { | 173 settings.addresses = CreateAdapterAddresses(t.input_adapters); |
| 177 CreateAdapterAddresses(t.input_adapters), | 174 // Default settings for the rest. |
| 178 // Default settings for the rest. | |
| 179 }; | |
| 180 std::vector<IPEndPoint> expected_nameservers; | 175 std::vector<IPEndPoint> expected_nameservers; |
| 181 for (size_t j = 0; !t.expected_nameservers[j].empty(); ++j) { | 176 for (size_t j = 0; !t.expected_nameservers[j].empty(); ++j) { |
| 182 IPAddressNumber ip; | 177 IPAddressNumber ip; |
| 183 ASSERT_TRUE(ParseIPLiteralToNumber(t.expected_nameservers[j], &ip)); | 178 ASSERT_TRUE(ParseIPLiteralToNumber(t.expected_nameservers[j], &ip)); |
| 184 uint16 port = t.expected_ports[j]; | 179 uint16 port = t.expected_ports[j]; |
| 185 if (!port) | 180 if (!port) |
| 186 port = dns_protocol::kDefaultPort; | 181 port = dns_protocol::kDefaultPort; |
| 187 expected_nameservers.push_back(IPEndPoint(ip, port)); | 182 expected_nameservers.push_back(IPEndPoint(ip, port)); |
| 188 } | 183 } |
| 189 | 184 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 202 } | 197 } |
| 203 } | 198 } |
| 204 | 199 |
| 205 TEST(DnsConfigServiceWinTest, ConvertSuffixSearch) { | 200 TEST(DnsConfigServiceWinTest, ConvertSuffixSearch) { |
| 206 AdapterInfo infos[2] = { | 201 AdapterInfo infos[2] = { |
| 207 { IF_TYPE_USB, IfOperStatusUp, L"connection.suffix", { "1.0.0.1" } }, | 202 { IF_TYPE_USB, IfOperStatusUp, L"connection.suffix", { "1.0.0.1" } }, |
| 208 { 0 }, | 203 { 0 }, |
| 209 }; | 204 }; |
| 210 | 205 |
| 211 const struct TestCase { | 206 const struct TestCase { |
| 212 internal::DnsSystemSettings input_settings; | 207 struct { |
| 208 internal::DnsSystemSettings::RegString policy_search_list; |
| 209 internal::DnsSystemSettings::RegString tcpip_search_list; |
| 210 internal::DnsSystemSettings::RegString tcpip_domain; |
| 211 internal::DnsSystemSettings::RegString primary_dns_suffix; |
| 212 internal::DnsSystemSettings::DevolutionSetting policy_devolution; |
| 213 internal::DnsSystemSettings::DevolutionSetting dnscache_devolution; |
| 214 internal::DnsSystemSettings::DevolutionSetting tcpip_devolution; |
| 215 } input_settings; |
| 213 std::string expected_search[5]; | 216 std::string expected_search[5]; |
| 214 } cases[] = { | 217 } cases[] = { |
| 215 { // Policy SearchList override. | 218 { // Policy SearchList override. |
| 216 { | 219 { |
| 217 CreateAdapterAddresses(infos), | |
| 218 { true, L"policy.searchlist.a,policy.searchlist.b" }, | 220 { true, L"policy.searchlist.a,policy.searchlist.b" }, |
| 219 { true, L"tcpip.searchlist.a,tcpip.searchlist.b" }, | 221 { true, L"tcpip.searchlist.a,tcpip.searchlist.b" }, |
| 220 { true, L"tcpip.domain" }, | 222 { true, L"tcpip.domain" }, |
| 221 { true, L"primary.dns.suffix" }, | 223 { true, L"primary.dns.suffix" }, |
| 222 }, | 224 }, |
| 223 { "policy.searchlist.a", "policy.searchlist.b" }, | 225 { "policy.searchlist.a", "policy.searchlist.b" }, |
| 224 }, | 226 }, |
| 225 { // User-specified SearchList override. | 227 { // User-specified SearchList override. |
| 226 { | 228 { |
| 227 CreateAdapterAddresses(infos), | |
| 228 { false }, | 229 { false }, |
| 229 { true, L"tcpip.searchlist.a,tcpip.searchlist.b" }, | 230 { true, L"tcpip.searchlist.a,tcpip.searchlist.b" }, |
| 230 { true, L"tcpip.domain" }, | 231 { true, L"tcpip.domain" }, |
| 231 { true, L"primary.dns.suffix" }, | 232 { true, L"primary.dns.suffix" }, |
| 232 }, | 233 }, |
| 233 { "tcpip.searchlist.a", "tcpip.searchlist.b" }, | 234 { "tcpip.searchlist.a", "tcpip.searchlist.b" }, |
| 234 }, | 235 }, |
| 235 { // Void SearchList. Using tcpip.domain | 236 { // Void SearchList. Using tcpip.domain |
| 236 { | 237 { |
| 237 CreateAdapterAddresses(infos), | |
| 238 { true, L",bad.searchlist,parsed.as.empty" }, | 238 { true, L",bad.searchlist,parsed.as.empty" }, |
| 239 { true, L"tcpip.searchlist,good.but.overridden" }, | 239 { true, L"tcpip.searchlist,good.but.overridden" }, |
| 240 { true, L"tcpip.domain" }, | 240 { true, L"tcpip.domain" }, |
| 241 { false }, | 241 { false }, |
| 242 }, | 242 }, |
| 243 { "tcpip.domain", "connection.suffix" }, | 243 { "tcpip.domain", "connection.suffix" }, |
| 244 }, | 244 }, |
| 245 { // Void SearchList. Using primary.dns.suffix | 245 { // Void SearchList. Using primary.dns.suffix |
| 246 { | 246 { |
| 247 CreateAdapterAddresses(infos), | |
| 248 { true, L",bad.searchlist,parsed.as.empty" }, | 247 { true, L",bad.searchlist,parsed.as.empty" }, |
| 249 { true, L"tcpip.searchlist,good.but.overridden" }, | 248 { true, L"tcpip.searchlist,good.but.overridden" }, |
| 250 { true, L"tcpip.domain" }, | 249 { true, L"tcpip.domain" }, |
| 251 { true, L"primary.dns.suffix" }, | 250 { true, L"primary.dns.suffix" }, |
| 252 }, | 251 }, |
| 253 { "primary.dns.suffix", "connection.suffix" }, | 252 { "primary.dns.suffix", "connection.suffix" }, |
| 254 }, | 253 }, |
| 255 { // Void SearchList. Using tcpip.domain when primary.dns.suffix is empty | 254 { // Void SearchList. Using tcpip.domain when primary.dns.suffix is empty |
| 256 { | 255 { |
| 257 CreateAdapterAddresses(infos), | |
| 258 { true, L",bad.searchlist,parsed.as.empty" }, | 256 { true, L",bad.searchlist,parsed.as.empty" }, |
| 259 { true, L"tcpip.searchlist,good.but.overridden" }, | 257 { true, L"tcpip.searchlist,good.but.overridden" }, |
| 260 { true, L"tcpip.domain" }, | 258 { true, L"tcpip.domain" }, |
| 261 { true, L"" }, | 259 { true, L"" }, |
| 262 }, | 260 }, |
| 263 { "tcpip.domain", "connection.suffix" }, | 261 { "tcpip.domain", "connection.suffix" }, |
| 264 }, | 262 }, |
| 265 { // Void SearchList. Using tcpip.domain when primary.dns.suffix is NULL | 263 { // Void SearchList. Using tcpip.domain when primary.dns.suffix is NULL |
| 266 { | 264 { |
| 267 CreateAdapterAddresses(infos), | |
| 268 { true, L",bad.searchlist,parsed.as.empty" }, | 265 { true, L",bad.searchlist,parsed.as.empty" }, |
| 269 { true, L"tcpip.searchlist,good.but.overridden" }, | 266 { true, L"tcpip.searchlist,good.but.overridden" }, |
| 270 { true, L"tcpip.domain" }, | 267 { true, L"tcpip.domain" }, |
| 271 { true }, | 268 { true }, |
| 272 }, | 269 }, |
| 273 { "tcpip.domain", "connection.suffix" }, | 270 { "tcpip.domain", "connection.suffix" }, |
| 274 }, | 271 }, |
| 275 { // No primary suffix. Devolution does not matter. | 272 { // No primary suffix. Devolution does not matter. |
| 276 { | 273 { |
| 277 CreateAdapterAddresses(infos), | |
| 278 { false }, | 274 { false }, |
| 279 { false }, | 275 { false }, |
| 280 { true }, | 276 { true }, |
| 281 { true }, | 277 { true }, |
| 282 { { true, 1 }, { true, 2 } }, | 278 { { true, 1 }, { true, 2 } }, |
| 283 }, | 279 }, |
| 284 { "connection.suffix" }, | 280 { "connection.suffix" }, |
| 285 }, | 281 }, |
| 286 { // Devolution enabled by policy, level by dnscache. | 282 { // Devolution enabled by policy, level by dnscache. |
| 287 { | 283 { |
| 288 CreateAdapterAddresses(infos), | |
| 289 { false }, | 284 { false }, |
| 290 { false }, | 285 { false }, |
| 291 { true, L"a.b.c.d.e" }, | 286 { true, L"a.b.c.d.e" }, |
| 292 { false }, | 287 { false }, |
| 293 { { true, 1 }, { false } }, // policy_devolution: enabled, level | 288 { { true, 1 }, { false } }, // policy_devolution: enabled, level |
| 294 { { true, 0 }, { true, 3 } }, // dnscache_devolution | 289 { { true, 0 }, { true, 3 } }, // dnscache_devolution |
| 295 { { true, 0 }, { true, 1 } }, // tcpip_devolution | 290 { { true, 0 }, { true, 1 } }, // tcpip_devolution |
| 296 }, | 291 }, |
| 297 { "a.b.c.d.e", "connection.suffix", "b.c.d.e", "c.d.e" }, | 292 { "a.b.c.d.e", "connection.suffix", "b.c.d.e", "c.d.e" }, |
| 298 }, | 293 }, |
| 299 { // Devolution enabled by dnscache, level by policy. | 294 { // Devolution enabled by dnscache, level by policy. |
| 300 { | 295 { |
| 301 CreateAdapterAddresses(infos), | |
| 302 { false }, | 296 { false }, |
| 303 { false }, | 297 { false }, |
| 304 { true, L"a.b.c.d.e" }, | 298 { true, L"a.b.c.d.e" }, |
| 305 { true, L"f.g.i.l.j" }, | 299 { true, L"f.g.i.l.j" }, |
| 306 { { false }, { true, 4 } }, | 300 { { false }, { true, 4 } }, |
| 307 { { true, 1 }, { false } }, | 301 { { true, 1 }, { false } }, |
| 308 { { true, 0 }, { true, 3 } }, | 302 { { true, 0 }, { true, 3 } }, |
| 309 }, | 303 }, |
| 310 { "f.g.i.l.j", "connection.suffix", "g.i.l.j" }, | 304 { "f.g.i.l.j", "connection.suffix", "g.i.l.j" }, |
| 311 }, | 305 }, |
| 312 { // Devolution enabled by default. | 306 { // Devolution enabled by default. |
| 313 { | 307 { |
| 314 CreateAdapterAddresses(infos), | |
| 315 { false }, | 308 { false }, |
| 316 { false }, | 309 { false }, |
| 317 { true, L"a.b.c.d.e" }, | 310 { true, L"a.b.c.d.e" }, |
| 318 { false }, | 311 { false }, |
| 319 { { false }, { false } }, | 312 { { false }, { false } }, |
| 320 { { false }, { true, 3 } }, | 313 { { false }, { true, 3 } }, |
| 321 { { false }, { true, 1 } }, | 314 { { false }, { true, 1 } }, |
| 322 }, | 315 }, |
| 323 { "a.b.c.d.e", "connection.suffix", "b.c.d.e", "c.d.e" }, | 316 { "a.b.c.d.e", "connection.suffix", "b.c.d.e", "c.d.e" }, |
| 324 }, | 317 }, |
| 325 { // Devolution enabled at level = 2, but nothing to devolve. | 318 { // Devolution enabled at level = 2, but nothing to devolve. |
| 326 { | 319 { |
| 327 CreateAdapterAddresses(infos), | |
| 328 { false }, | 320 { false }, |
| 329 { false }, | 321 { false }, |
| 330 { true, L"a.b" }, | 322 { true, L"a.b" }, |
| 331 { false }, | 323 { false }, |
| 332 { { false }, { false } }, | 324 { { false }, { false } }, |
| 333 { { false }, { true, 2 } }, | 325 { { false }, { true, 2 } }, |
| 334 { { false }, { true, 2 } }, | 326 { { false }, { true, 2 } }, |
| 335 }, | 327 }, |
| 336 { "a.b", "connection.suffix" }, | 328 { "a.b", "connection.suffix" }, |
| 337 }, | 329 }, |
| 338 { // Devolution disabled when no explicit level. | 330 { // Devolution disabled when no explicit level. |
| 339 // Windows XP and Vista use a default level = 2, but we don't. | 331 // Windows XP and Vista use a default level = 2, but we don't. |
| 340 { | 332 { |
| 341 CreateAdapterAddresses(infos), | |
| 342 { false }, | 333 { false }, |
| 343 { false }, | 334 { false }, |
| 344 { true, L"a.b.c.d.e" }, | 335 { true, L"a.b.c.d.e" }, |
| 345 { false }, | 336 { false }, |
| 346 { { true, 1 }, { false } }, | 337 { { true, 1 }, { false } }, |
| 347 { { true, 1 }, { false } }, | 338 { { true, 1 }, { false } }, |
| 348 { { true, 1 }, { false } }, | 339 { { true, 1 }, { false } }, |
| 349 }, | 340 }, |
| 350 { "a.b.c.d.e", "connection.suffix" }, | 341 { "a.b.c.d.e", "connection.suffix" }, |
| 351 }, | 342 }, |
| 352 { // Devolution disabled by policy level. | 343 { // Devolution disabled by policy level. |
| 353 { | 344 { |
| 354 CreateAdapterAddresses(infos), | |
| 355 { false }, | 345 { false }, |
| 356 { false }, | 346 { false }, |
| 357 { true, L"a.b.c.d.e" }, | 347 { true, L"a.b.c.d.e" }, |
| 358 { false }, | 348 { false }, |
| 359 { { false }, { true, 1 } }, | 349 { { false }, { true, 1 } }, |
| 360 { { true, 1 }, { true, 3 } }, | 350 { { true, 1 }, { true, 3 } }, |
| 361 { { true, 1 }, { true, 4 } }, | 351 { { true, 1 }, { true, 4 } }, |
| 362 }, | 352 }, |
| 363 { "a.b.c.d.e", "connection.suffix" }, | 353 { "a.b.c.d.e", "connection.suffix" }, |
| 364 }, | 354 }, |
| 365 { // Devolution disabled by user setting. | 355 { // Devolution disabled by user setting. |
| 366 { | 356 { |
| 367 CreateAdapterAddresses(infos), | |
| 368 { false }, | 357 { false }, |
| 369 { false }, | 358 { false }, |
| 370 { true, L"a.b.c.d.e" }, | 359 { true, L"a.b.c.d.e" }, |
| 371 { false }, | 360 { false }, |
| 372 { { false }, { true, 3 } }, | 361 { { false }, { true, 3 } }, |
| 373 { { false }, { true, 3 } }, | 362 { { false }, { true, 3 } }, |
| 374 { { true, 0 }, { true, 3 } }, | 363 { { true, 0 }, { true, 3 } }, |
| 375 }, | 364 }, |
| 376 { "a.b.c.d.e", "connection.suffix" }, | 365 { "a.b.c.d.e", "connection.suffix" }, |
| 377 }, | 366 }, |
| 378 }; | 367 }; |
| 379 | 368 |
| 380 for (size_t i = 0; i < arraysize(cases); ++i) { | 369 for (auto& t : cases) { |
| 381 const TestCase& t = cases[i]; | 370 internal::DnsSystemSettings settings; |
| 371 settings.addresses = CreateAdapterAddresses(infos); |
| 372 settings.policy_search_list = t.input_settings.policy_search_list; |
| 373 settings.tcpip_search_list = t.input_settings.tcpip_search_list; |
| 374 settings.tcpip_domain = t.input_settings.tcpip_domain; |
| 375 settings.primary_dns_suffix = t.input_settings.primary_dns_suffix; |
| 376 settings.policy_devolution = t.input_settings.policy_devolution; |
| 377 settings.dnscache_devolution = t.input_settings.dnscache_devolution; |
| 378 settings.tcpip_devolution = t.input_settings.tcpip_devolution; |
| 379 |
| 382 DnsConfig config; | 380 DnsConfig config; |
| 383 EXPECT_EQ(internal::CONFIG_PARSE_WIN_OK, | 381 EXPECT_EQ(internal::CONFIG_PARSE_WIN_OK, |
| 384 internal::ConvertSettingsToDnsConfig(t.input_settings, &config)); | 382 internal::ConvertSettingsToDnsConfig(settings, &config)); |
| 385 std::vector<std::string> expected_search; | 383 std::vector<std::string> expected_search; |
| 386 for (size_t j = 0; !t.expected_search[j].empty(); ++j) { | 384 for (size_t j = 0; !t.expected_search[j].empty(); ++j) { |
| 387 expected_search.push_back(t.expected_search[j]); | 385 expected_search.push_back(t.expected_search[j]); |
| 388 } | 386 } |
| 389 EXPECT_EQ(expected_search, config.search); | 387 EXPECT_EQ(expected_search, config.search); |
| 390 } | 388 } |
| 391 } | 389 } |
| 392 | 390 |
| 393 TEST(DnsConfigServiceWinTest, AppendToMultiLabelName) { | 391 TEST(DnsConfigServiceWinTest, AppendToMultiLabelName) { |
| 394 AdapterInfo infos[2] = { | 392 AdapterInfo infos[2] = { |
| 395 { IF_TYPE_USB, IfOperStatusUp, L"connection.suffix", { "1.0.0.1" } }, | 393 { IF_TYPE_USB, IfOperStatusUp, L"connection.suffix", { "1.0.0.1" } }, |
| 396 { 0 }, | 394 { 0 }, |
| 397 }; | 395 }; |
| 398 | 396 |
| 399 // The default setting was true pre-Vista. | 397 // The default setting was true pre-Vista. |
| 400 bool default_value = (base::win::GetVersion() < base::win::VERSION_VISTA); | 398 bool default_value = (base::win::GetVersion() < base::win::VERSION_VISTA); |
| 401 | 399 |
| 402 const struct TestCase { | 400 const struct TestCase { |
| 403 internal::DnsSystemSettings::RegDword input; | 401 internal::DnsSystemSettings::RegDword input; |
| 404 bool expected_output; | 402 bool expected_output; |
| 405 } cases[] = { | 403 } cases[] = { |
| 406 { { true, 0 }, false }, | 404 { { true, 0 }, false }, |
| 407 { { true, 1 }, true }, | 405 { { true, 1 }, true }, |
| 408 { { false, 0 }, default_value }, | 406 { { false, 0 }, default_value }, |
| 409 }; | 407 }; |
| 410 | 408 |
| 411 for (size_t i = 0; i < arraysize(cases); ++i) { | 409 for (const auto& t : cases) { |
| 412 const TestCase& t = cases[i]; | 410 internal::DnsSystemSettings settings; |
| 413 internal::DnsSystemSettings settings = { | 411 settings.addresses = CreateAdapterAddresses(infos); |
| 414 CreateAdapterAddresses(infos), | 412 settings.append_to_multi_label_name = t.input; |
| 415 { false }, { false }, { false }, { false }, | |
| 416 { { false }, { false } }, | |
| 417 { { false }, { false } }, | |
| 418 { { false }, { false } }, | |
| 419 t.input, | |
| 420 }; | |
| 421 DnsConfig config; | 413 DnsConfig config; |
| 422 EXPECT_EQ(internal::CONFIG_PARSE_WIN_OK, | 414 EXPECT_EQ(internal::CONFIG_PARSE_WIN_OK, |
| 423 internal::ConvertSettingsToDnsConfig(settings, &config)); | 415 internal::ConvertSettingsToDnsConfig(settings, &config)); |
| 424 EXPECT_EQ(t.expected_output, config.append_to_multi_label_name); | 416 EXPECT_EQ(t.expected_output, config.append_to_multi_label_name); |
| 425 } | 417 } |
| 426 } | 418 } |
| 427 | 419 |
| 428 // Setting have_name_resolution_policy_table should set unhandled_options. | 420 // Setting have_name_resolution_policy_table should set unhandled_options. |
| 429 TEST(DnsConfigServiceWinTest, HaveNRPT) { | 421 TEST(DnsConfigServiceWinTest, HaveNRPT) { |
| 430 AdapterInfo infos[2] = { | 422 AdapterInfo infos[2] = { |
| 431 { IF_TYPE_USB, IfOperStatusUp, L"connection.suffix", { "1.0.0.1" } }, | 423 { IF_TYPE_USB, IfOperStatusUp, L"connection.suffix", { "1.0.0.1" } }, |
| 432 { 0 }, | 424 { 0 }, |
| 433 }; | 425 }; |
| 434 | 426 |
| 435 const struct TestCase { | 427 const struct TestCase { |
| 436 bool have_nrpt; | 428 bool have_nrpt; |
| 437 bool unhandled_options; | 429 bool unhandled_options; |
| 438 internal::ConfigParseWinResult result; | 430 internal::ConfigParseWinResult result; |
| 439 } cases[] = { | 431 } cases[] = { |
| 440 { false, false, internal::CONFIG_PARSE_WIN_OK }, | 432 { false, false, internal::CONFIG_PARSE_WIN_OK }, |
| 441 { true, true, internal::CONFIG_PARSE_WIN_UNHANDLED_OPTIONS }, | 433 { true, true, internal::CONFIG_PARSE_WIN_UNHANDLED_OPTIONS }, |
| 442 }; | 434 }; |
| 443 | 435 |
| 444 for (size_t i = 0; i < arraysize(cases); ++i) { | 436 for (const auto& t : cases) { |
| 445 const TestCase& t = cases[i]; | 437 internal::DnsSystemSettings settings; |
| 446 internal::DnsSystemSettings settings = { | 438 settings.addresses = CreateAdapterAddresses(infos); |
| 447 CreateAdapterAddresses(infos), | 439 settings.have_name_resolution_policy = t.have_nrpt; |
| 448 { false }, { false }, { false }, { false }, | |
| 449 { { false }, { false } }, | |
| 450 { { false }, { false } }, | |
| 451 { { false }, { false } }, | |
| 452 { false }, | |
| 453 t.have_nrpt, | |
| 454 }; | |
| 455 DnsConfig config; | 440 DnsConfig config; |
| 456 EXPECT_EQ(t.result, | 441 EXPECT_EQ(t.result, |
| 457 internal::ConvertSettingsToDnsConfig(settings, &config)); | 442 internal::ConvertSettingsToDnsConfig(settings, &config)); |
| 458 EXPECT_EQ(t.unhandled_options, config.unhandled_options); | 443 EXPECT_EQ(t.unhandled_options, config.unhandled_options); |
| 459 EXPECT_EQ(t.have_nrpt, config.use_local_ipv6); | 444 EXPECT_EQ(t.have_nrpt, config.use_local_ipv6); |
| 460 } | 445 } |
| 461 } | 446 } |
| 462 | 447 |
| 463 | 448 |
| 464 } // namespace | 449 } // namespace |
| 465 | 450 |
| 466 } // namespace net | 451 } // namespace net |
| 467 | 452 |
| OLD | NEW |