1 /* 2 * Copyright (C) 2018, The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.server.connectivity; 18 19 import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_OFF; 20 import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_PROVIDER_HOSTNAME; 21 import static android.net.NetworkCapabilities.MAX_TRANSPORT; 22 import static android.net.NetworkCapabilities.MIN_TRANSPORT; 23 import static android.net.NetworkCapabilities.TRANSPORT_VPN; 24 import static android.net.NetworkCapabilities.TRANSPORT_WIFI; 25 import static android.provider.Settings.Global.PRIVATE_DNS_DEFAULT_MODE; 26 import static android.provider.Settings.Global.PRIVATE_DNS_MODE; 27 import static android.provider.Settings.Global.PRIVATE_DNS_SPECIFIER; 28 29 import static com.android.testutils.MiscAssertsKt.assertContainsExactly; 30 import static com.android.testutils.MiscAssertsKt.assertContainsStringsExactly; 31 import static com.android.testutils.MiscAssertsKt.assertFieldCountEquals; 32 33 import static org.junit.Assert.assertEquals; 34 import static org.junit.Assert.assertFalse; 35 import static org.junit.Assert.assertNotNull; 36 import static org.junit.Assert.assertNull; 37 import static org.junit.Assert.assertTrue; 38 import static org.mockito.Mockito.reset; 39 import static org.mockito.Mockito.times; 40 import static org.mockito.Mockito.verify; 41 import static org.mockito.Mockito.when; 42 43 import android.annotation.NonNull; 44 import android.content.Context; 45 import android.net.IDnsResolver; 46 import android.net.IpPrefix; 47 import android.net.LinkAddress; 48 import android.net.LinkProperties; 49 import android.net.Network; 50 import android.net.NetworkCapabilities; 51 import android.net.ResolverOptionsParcel; 52 import android.net.ResolverParamsParcel; 53 import android.net.RouteInfo; 54 import android.net.shared.PrivateDnsConfig; 55 import android.provider.Settings; 56 import android.test.mock.MockContentResolver; 57 import android.util.SparseArray; 58 59 import androidx.test.filters.SmallTest; 60 import androidx.test.runner.AndroidJUnit4; 61 62 import com.android.internal.util.MessageUtils; 63 import com.android.internal.util.test.FakeSettingsProvider; 64 65 import libcore.net.InetAddressUtils; 66 67 import org.junit.Before; 68 import org.junit.Test; 69 import org.junit.runner.RunWith; 70 import org.mockito.ArgumentCaptor; 71 import org.mockito.Mock; 72 import org.mockito.MockitoAnnotations; 73 74 import java.net.InetAddress; 75 import java.util.Arrays; 76 77 /** 78 * Tests for {@link DnsManager}. 79 * 80 * Build, install and run with: 81 * runtest frameworks-net -c com.android.server.connectivity.DnsManagerTest 82 */ 83 @RunWith(AndroidJUnit4.class) 84 @SmallTest 85 public class DnsManagerTest { 86 static final String TEST_IFACENAME = "test_wlan0"; 87 static final int TEST_NETID = 100; 88 static final int TEST_NETID_ALTERNATE = 101; 89 static final int TEST_NETID_UNTRACKED = 102; 90 static final int TEST_DEFAULT_SAMPLE_VALIDITY_SECONDS = 1800; 91 static final int TEST_DEFAULT_SUCCESS_THRESHOLD_PERCENT = 25; 92 static final int TEST_DEFAULT_MIN_SAMPLES = 8; 93 static final int TEST_DEFAULT_MAX_SAMPLES = 64; 94 static final int[] TEST_TRANSPORT_TYPES = {TRANSPORT_WIFI, TRANSPORT_VPN}; 95 96 DnsManager mDnsManager; 97 MockContentResolver mContentResolver; 98 99 @Mock Context mCtx; 100 @Mock IDnsResolver mMockDnsResolver; 101 @Mock MockableSystemProperties mSystemProperties; 102 assertResolverOptionsEquals( @onNull ResolverOptionsParcel actual, @NonNull ResolverOptionsParcel expected)103 private void assertResolverOptionsEquals( 104 @NonNull ResolverOptionsParcel actual, 105 @NonNull ResolverOptionsParcel expected) { 106 assertEquals(actual.hosts, expected.hosts); 107 assertEquals(actual.tcMode, expected.tcMode); 108 assertEquals(actual.enforceDnsUid, expected.enforceDnsUid); 109 assertFieldCountEquals(3, ResolverOptionsParcel.class); 110 } 111 assertResolverParamsEquals(@onNull ResolverParamsParcel actual, @NonNull ResolverParamsParcel expected)112 private void assertResolverParamsEquals(@NonNull ResolverParamsParcel actual, 113 @NonNull ResolverParamsParcel expected) { 114 assertEquals(actual.netId, expected.netId); 115 assertEquals(actual.sampleValiditySeconds, expected.sampleValiditySeconds); 116 assertEquals(actual.successThreshold, expected.successThreshold); 117 assertEquals(actual.minSamples, expected.minSamples); 118 assertEquals(actual.maxSamples, expected.maxSamples); 119 assertEquals(actual.baseTimeoutMsec, expected.baseTimeoutMsec); 120 assertEquals(actual.retryCount, expected.retryCount); 121 assertContainsStringsExactly(actual.servers, expected.servers); 122 assertContainsStringsExactly(actual.domains, expected.domains); 123 assertEquals(actual.tlsName, expected.tlsName); 124 assertContainsStringsExactly(actual.tlsServers, expected.tlsServers); 125 assertContainsStringsExactly(actual.tlsFingerprints, expected.tlsFingerprints); 126 assertEquals(actual.caCertificate, expected.caCertificate); 127 assertEquals(actual.tlsConnectTimeoutMs, expected.tlsConnectTimeoutMs); 128 assertResolverOptionsEquals(actual.resolverOptions, expected.resolverOptions); 129 assertContainsExactly(actual.transportTypes, expected.transportTypes); 130 assertFieldCountEquals(16, ResolverParamsParcel.class); 131 } 132 133 @Before setUp()134 public void setUp() throws Exception { 135 MockitoAnnotations.initMocks(this); 136 mContentResolver = new MockContentResolver(); 137 mContentResolver.addProvider(Settings.AUTHORITY, 138 new FakeSettingsProvider()); 139 when(mCtx.getContentResolver()).thenReturn(mContentResolver); 140 mDnsManager = new DnsManager(mCtx, mMockDnsResolver, mSystemProperties); 141 142 // Clear the private DNS settings 143 Settings.Global.putString(mContentResolver, PRIVATE_DNS_DEFAULT_MODE, ""); 144 Settings.Global.putString(mContentResolver, PRIVATE_DNS_MODE, ""); 145 Settings.Global.putString(mContentResolver, PRIVATE_DNS_SPECIFIER, ""); 146 } 147 148 @Test testTrackedValidationUpdates()149 public void testTrackedValidationUpdates() throws Exception { 150 mDnsManager.updatePrivateDns(new Network(TEST_NETID), 151 mDnsManager.getPrivateDnsConfig()); 152 mDnsManager.updatePrivateDns(new Network(TEST_NETID_ALTERNATE), 153 mDnsManager.getPrivateDnsConfig()); 154 LinkProperties lp = new LinkProperties(); 155 lp.setInterfaceName(TEST_IFACENAME); 156 lp.addDnsServer(InetAddress.getByName("3.3.3.3")); 157 lp.addDnsServer(InetAddress.getByName("4.4.4.4")); 158 159 // Send a validation event that is tracked on the alternate netId 160 mDnsManager.updateTransportsForNetwork(TEST_NETID, TEST_TRANSPORT_TYPES); 161 mDnsManager.noteDnsServersForNetwork(TEST_NETID, lp); 162 mDnsManager.setDefaultDnsSystemProperties(lp.getDnsServers()); 163 mDnsManager.flushVmDnsCache(); 164 mDnsManager.updateTransportsForNetwork(TEST_NETID_ALTERNATE, TEST_TRANSPORT_TYPES); 165 mDnsManager.noteDnsServersForNetwork(TEST_NETID_ALTERNATE, lp); 166 mDnsManager.flushVmDnsCache(); 167 mDnsManager.updatePrivateDnsValidation( 168 new DnsManager.PrivateDnsValidationUpdate(TEST_NETID_ALTERNATE, 169 InetAddress.parseNumericAddress("4.4.4.4"), "", true)); 170 LinkProperties fixedLp = new LinkProperties(lp); 171 mDnsManager.updatePrivateDnsStatus(TEST_NETID, fixedLp); 172 assertFalse(fixedLp.isPrivateDnsActive()); 173 assertNull(fixedLp.getPrivateDnsServerName()); 174 fixedLp = new LinkProperties(lp); 175 mDnsManager.updatePrivateDnsStatus(TEST_NETID_ALTERNATE, fixedLp); 176 assertTrue(fixedLp.isPrivateDnsActive()); 177 assertNull(fixedLp.getPrivateDnsServerName()); 178 assertEquals(Arrays.asList(InetAddress.getByName("4.4.4.4")), 179 fixedLp.getValidatedPrivateDnsServers()); 180 181 // Set up addresses for strict mode and switch to it. 182 lp.addLinkAddress(new LinkAddress("192.0.2.4/24")); 183 lp.addRoute(new RouteInfo((IpPrefix) null, InetAddress.getByName("192.0.2.4"), 184 TEST_IFACENAME)); 185 lp.addLinkAddress(new LinkAddress("2001:db8:1::1/64")); 186 lp.addRoute(new RouteInfo((IpPrefix) null, InetAddress.getByName("2001:db8:1::1"), 187 TEST_IFACENAME)); 188 189 Settings.Global.putString(mContentResolver, 190 PRIVATE_DNS_MODE, PRIVATE_DNS_MODE_PROVIDER_HOSTNAME); 191 Settings.Global.putString(mContentResolver, PRIVATE_DNS_SPECIFIER, "strictmode.com"); 192 mDnsManager.updatePrivateDns(new Network(TEST_NETID), 193 new PrivateDnsConfig("strictmode.com", new InetAddress[] { 194 InetAddress.parseNumericAddress("6.6.6.6"), 195 InetAddress.parseNumericAddress("2001:db8:66:66::1") 196 })); 197 mDnsManager.updateTransportsForNetwork(TEST_NETID, TEST_TRANSPORT_TYPES); 198 mDnsManager.noteDnsServersForNetwork(TEST_NETID, lp); 199 mDnsManager.setDefaultDnsSystemProperties(lp.getDnsServers()); 200 mDnsManager.flushVmDnsCache(); 201 fixedLp = new LinkProperties(lp); 202 mDnsManager.updatePrivateDnsStatus(TEST_NETID, fixedLp); 203 assertTrue(fixedLp.isPrivateDnsActive()); 204 assertEquals("strictmode.com", fixedLp.getPrivateDnsServerName()); 205 // No validation events yet. 206 assertEquals(Arrays.asList(new InetAddress[0]), fixedLp.getValidatedPrivateDnsServers()); 207 // Validate one. 208 mDnsManager.updatePrivateDnsValidation( 209 new DnsManager.PrivateDnsValidationUpdate(TEST_NETID, 210 InetAddress.parseNumericAddress("6.6.6.6"), "strictmode.com", true)); 211 fixedLp = new LinkProperties(lp); 212 mDnsManager.updatePrivateDnsStatus(TEST_NETID, fixedLp); 213 assertEquals(Arrays.asList(InetAddress.parseNumericAddress("6.6.6.6")), 214 fixedLp.getValidatedPrivateDnsServers()); 215 // Validate the 2nd one. 216 mDnsManager.updatePrivateDnsValidation( 217 new DnsManager.PrivateDnsValidationUpdate(TEST_NETID, 218 InetAddress.parseNumericAddress("2001:db8:66:66::1"), "strictmode.com", true)); 219 fixedLp = new LinkProperties(lp); 220 mDnsManager.updatePrivateDnsStatus(TEST_NETID, fixedLp); 221 assertEquals(Arrays.asList( 222 InetAddress.parseNumericAddress("2001:db8:66:66::1"), 223 InetAddress.parseNumericAddress("6.6.6.6")), 224 fixedLp.getValidatedPrivateDnsServers()); 225 } 226 227 @Test testIgnoreUntrackedValidationUpdates()228 public void testIgnoreUntrackedValidationUpdates() throws Exception { 229 // The PrivateDnsConfig map is empty, so no validation events will 230 // be tracked. 231 LinkProperties lp = new LinkProperties(); 232 lp.addDnsServer(InetAddress.getByName("3.3.3.3")); 233 mDnsManager.updateTransportsForNetwork(TEST_NETID, TEST_TRANSPORT_TYPES); 234 mDnsManager.noteDnsServersForNetwork(TEST_NETID, lp); 235 mDnsManager.setDefaultDnsSystemProperties(lp.getDnsServers()); 236 mDnsManager.flushVmDnsCache(); 237 mDnsManager.updatePrivateDnsValidation( 238 new DnsManager.PrivateDnsValidationUpdate(TEST_NETID, 239 InetAddress.parseNumericAddress("3.3.3.3"), "", true)); 240 mDnsManager.updatePrivateDnsStatus(TEST_NETID, lp); 241 assertFalse(lp.isPrivateDnsActive()); 242 assertNull(lp.getPrivateDnsServerName()); 243 244 // Validation event has untracked netId 245 mDnsManager.updatePrivateDns(new Network(TEST_NETID), 246 mDnsManager.getPrivateDnsConfig()); 247 mDnsManager.updateTransportsForNetwork(TEST_NETID, TEST_TRANSPORT_TYPES); 248 mDnsManager.noteDnsServersForNetwork(TEST_NETID, lp); 249 mDnsManager.setDefaultDnsSystemProperties(lp.getDnsServers()); 250 mDnsManager.flushVmDnsCache(); 251 mDnsManager.updatePrivateDnsValidation( 252 new DnsManager.PrivateDnsValidationUpdate(TEST_NETID_UNTRACKED, 253 InetAddress.parseNumericAddress("3.3.3.3"), "", true)); 254 mDnsManager.updatePrivateDnsStatus(TEST_NETID, lp); 255 assertFalse(lp.isPrivateDnsActive()); 256 assertNull(lp.getPrivateDnsServerName()); 257 258 // Validation event has untracked ipAddress 259 mDnsManager.updatePrivateDnsValidation( 260 new DnsManager.PrivateDnsValidationUpdate(TEST_NETID, 261 InetAddress.parseNumericAddress("4.4.4.4"), "", true)); 262 mDnsManager.updatePrivateDnsStatus(TEST_NETID, lp); 263 assertFalse(lp.isPrivateDnsActive()); 264 assertNull(lp.getPrivateDnsServerName()); 265 266 // Validation event has untracked hostname 267 mDnsManager.updatePrivateDnsValidation( 268 new DnsManager.PrivateDnsValidationUpdate(TEST_NETID, 269 InetAddress.parseNumericAddress("3.3.3.3"), "hostname", 270 true)); 271 mDnsManager.updatePrivateDnsStatus(TEST_NETID, lp); 272 assertFalse(lp.isPrivateDnsActive()); 273 assertNull(lp.getPrivateDnsServerName()); 274 275 // Validation event failed 276 mDnsManager.updatePrivateDnsValidation( 277 new DnsManager.PrivateDnsValidationUpdate(TEST_NETID, 278 InetAddress.parseNumericAddress("3.3.3.3"), "", false)); 279 mDnsManager.updatePrivateDnsStatus(TEST_NETID, lp); 280 assertFalse(lp.isPrivateDnsActive()); 281 assertNull(lp.getPrivateDnsServerName()); 282 283 // Network removed 284 mDnsManager.removeNetwork(new Network(TEST_NETID)); 285 mDnsManager.updatePrivateDnsValidation( 286 new DnsManager.PrivateDnsValidationUpdate(TEST_NETID, 287 InetAddress.parseNumericAddress("3.3.3.3"), "", true)); 288 mDnsManager.updatePrivateDnsStatus(TEST_NETID, lp); 289 assertFalse(lp.isPrivateDnsActive()); 290 assertNull(lp.getPrivateDnsServerName()); 291 292 // Turn private DNS mode off 293 Settings.Global.putString(mContentResolver, PRIVATE_DNS_MODE, PRIVATE_DNS_MODE_OFF); 294 mDnsManager.updatePrivateDns(new Network(TEST_NETID), 295 mDnsManager.getPrivateDnsConfig()); 296 mDnsManager.updateTransportsForNetwork(TEST_NETID, TEST_TRANSPORT_TYPES); 297 mDnsManager.noteDnsServersForNetwork(TEST_NETID, lp); 298 mDnsManager.setDefaultDnsSystemProperties(lp.getDnsServers()); 299 mDnsManager.flushVmDnsCache(); 300 mDnsManager.updatePrivateDnsValidation( 301 new DnsManager.PrivateDnsValidationUpdate(TEST_NETID, 302 InetAddress.parseNumericAddress("3.3.3.3"), "", true)); 303 mDnsManager.updatePrivateDnsStatus(TEST_NETID, lp); 304 assertFalse(lp.isPrivateDnsActive()); 305 assertNull(lp.getPrivateDnsServerName()); 306 } 307 308 @Test testOverrideDefaultMode()309 public void testOverrideDefaultMode() throws Exception { 310 // Hard-coded default is opportunistic mode. 311 final PrivateDnsConfig cfgAuto = DnsManager.getPrivateDnsConfig(mContentResolver); 312 assertTrue(cfgAuto.useTls); 313 assertEquals("", cfgAuto.hostname); 314 assertEquals(new InetAddress[0], cfgAuto.ips); 315 316 // Pretend a gservices push sets the default to "off". 317 Settings.Global.putString(mContentResolver, PRIVATE_DNS_DEFAULT_MODE, "off"); 318 final PrivateDnsConfig cfgOff = DnsManager.getPrivateDnsConfig(mContentResolver); 319 assertFalse(cfgOff.useTls); 320 assertEquals("", cfgOff.hostname); 321 assertEquals(new InetAddress[0], cfgOff.ips); 322 323 // Strict mode still works. 324 Settings.Global.putString( 325 mContentResolver, PRIVATE_DNS_MODE, PRIVATE_DNS_MODE_PROVIDER_HOSTNAME); 326 Settings.Global.putString(mContentResolver, PRIVATE_DNS_SPECIFIER, "strictmode.com"); 327 final PrivateDnsConfig cfgStrict = DnsManager.getPrivateDnsConfig(mContentResolver); 328 assertTrue(cfgStrict.useTls); 329 assertEquals("strictmode.com", cfgStrict.hostname); 330 assertEquals(new InetAddress[0], cfgStrict.ips); 331 } 332 333 @Test testSendDnsConfiguration()334 public void testSendDnsConfiguration() throws Exception { 335 reset(mMockDnsResolver); 336 mDnsManager.updatePrivateDns(new Network(TEST_NETID), 337 mDnsManager.getPrivateDnsConfig()); 338 final LinkProperties lp = new LinkProperties(); 339 lp.setInterfaceName(TEST_IFACENAME); 340 lp.addDnsServer(InetAddress.getByName("3.3.3.3")); 341 lp.addDnsServer(InetAddress.getByName("4.4.4.4")); 342 mDnsManager.updateTransportsForNetwork(TEST_NETID, TEST_TRANSPORT_TYPES); 343 mDnsManager.noteDnsServersForNetwork(TEST_NETID, lp); 344 mDnsManager.setDefaultDnsSystemProperties(lp.getDnsServers()); 345 mDnsManager.flushVmDnsCache(); 346 347 final ArgumentCaptor<ResolverParamsParcel> resolverParamsParcelCaptor = 348 ArgumentCaptor.forClass(ResolverParamsParcel.class); 349 verify(mMockDnsResolver, times(1)).setResolverConfiguration( 350 resolverParamsParcelCaptor.capture()); 351 final ResolverParamsParcel actualParams = resolverParamsParcelCaptor.getValue(); 352 final ResolverParamsParcel expectedParams = new ResolverParamsParcel(); 353 expectedParams.netId = TEST_NETID; 354 expectedParams.sampleValiditySeconds = TEST_DEFAULT_SAMPLE_VALIDITY_SECONDS; 355 expectedParams.successThreshold = TEST_DEFAULT_SUCCESS_THRESHOLD_PERCENT; 356 expectedParams.minSamples = TEST_DEFAULT_MIN_SAMPLES; 357 expectedParams.maxSamples = TEST_DEFAULT_MAX_SAMPLES; 358 expectedParams.servers = new String[]{"3.3.3.3", "4.4.4.4"}; 359 expectedParams.domains = new String[]{}; 360 expectedParams.tlsName = ""; 361 expectedParams.tlsServers = new String[]{"3.3.3.3", "4.4.4.4"}; 362 expectedParams.transportTypes = TEST_TRANSPORT_TYPES; 363 expectedParams.resolverOptions = new ResolverOptionsParcel(); 364 assertResolverParamsEquals(actualParams, expectedParams); 365 } 366 367 @Test testTransportTypesEqual()368 public void testTransportTypesEqual() throws Exception { 369 SparseArray<String> ncTransTypes = MessageUtils.findMessageNames( 370 new Class[] { NetworkCapabilities.class }, new String[]{ "TRANSPORT_" }); 371 SparseArray<String> dnsTransTypes = MessageUtils.findMessageNames( 372 new Class[] { IDnsResolver.class }, new String[]{ "TRANSPORT_" }); 373 assertEquals(0, MIN_TRANSPORT); 374 assertEquals(MAX_TRANSPORT + 1, ncTransTypes.size()); 375 // TRANSPORT_UNKNOWN in IDnsResolver is defined to -1 and only for resolver. 376 assertEquals("TRANSPORT_UNKNOWN", dnsTransTypes.get(-1)); 377 assertEquals(ncTransTypes.size(), dnsTransTypes.size() - 1); 378 for (int i = MIN_TRANSPORT; i < MAX_TRANSPORT; i++) { 379 String name = ncTransTypes.get(i, null); 380 assertNotNull("Could not find NetworkCapabilies.TRANSPORT_* constant equal to " 381 + i, name); 382 assertEquals(name, dnsTransTypes.get(i)); 383 } 384 } 385 386 @Test testGetPrivateDnsConfigForNetwork()387 public void testGetPrivateDnsConfigForNetwork() throws Exception { 388 final Network network = new Network(TEST_NETID); 389 final InetAddress dnsAddr = InetAddressUtils.parseNumericAddress("3.3.3.3"); 390 final InetAddress[] tlsAddrs = new InetAddress[]{ 391 InetAddressUtils.parseNumericAddress("6.6.6.6"), 392 InetAddressUtils.parseNumericAddress("2001:db8:66:66::1") 393 }; 394 final String tlsName = "strictmode.com"; 395 LinkProperties lp = new LinkProperties(); 396 lp.addDnsServer(dnsAddr); 397 398 // The PrivateDnsConfig map is empty, so the default PRIVATE_DNS_OFF is returned. 399 PrivateDnsConfig privateDnsCfg = mDnsManager.getPrivateDnsConfig(network); 400 assertFalse(privateDnsCfg.useTls); 401 assertEquals("", privateDnsCfg.hostname); 402 assertEquals(new InetAddress[0], privateDnsCfg.ips); 403 404 // An entry with default PrivateDnsConfig is added to the PrivateDnsConfig map. 405 mDnsManager.updatePrivateDns(network, mDnsManager.getPrivateDnsConfig()); 406 mDnsManager.noteDnsServersForNetwork(TEST_NETID, lp); 407 mDnsManager.updatePrivateDnsValidation( 408 new DnsManager.PrivateDnsValidationUpdate(TEST_NETID, dnsAddr, "", true)); 409 mDnsManager.updatePrivateDnsStatus(TEST_NETID, lp); 410 privateDnsCfg = mDnsManager.getPrivateDnsConfig(network); 411 assertTrue(privateDnsCfg.useTls); 412 assertEquals("", privateDnsCfg.hostname); 413 assertEquals(new InetAddress[0], privateDnsCfg.ips); 414 415 // The original entry is overwritten by a new PrivateDnsConfig. 416 mDnsManager.updatePrivateDns(network, new PrivateDnsConfig(tlsName, tlsAddrs)); 417 mDnsManager.updatePrivateDnsStatus(TEST_NETID, lp); 418 privateDnsCfg = mDnsManager.getPrivateDnsConfig(network); 419 assertTrue(privateDnsCfg.useTls); 420 assertEquals(tlsName, privateDnsCfg.hostname); 421 assertEquals(tlsAddrs, privateDnsCfg.ips); 422 423 // The network is removed, so the PrivateDnsConfig map becomes empty again. 424 mDnsManager.removeNetwork(network); 425 privateDnsCfg = mDnsManager.getPrivateDnsConfig(network); 426 assertFalse(privateDnsCfg.useTls); 427 assertEquals("", privateDnsCfg.hostname); 428 assertEquals(new InetAddress[0], privateDnsCfg.ips); 429 } 430 } 431