1 /* 2 * Copyright (C) 2016 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.wifi; 18 19 import static org.junit.Assert.*; 20 21 import android.net.InetAddresses; 22 import android.net.IpConfiguration; 23 import android.net.LinkAddress; 24 import android.net.ProxyInfo; 25 import android.net.StaticIpConfiguration; 26 import android.net.wifi.WifiConfiguration; 27 import android.net.wifi.WifiConfiguration.NetworkSelectionStatus; 28 import android.net.wifi.WifiEnterpriseConfig; 29 import android.net.wifi.WifiSsid; 30 import android.text.TextUtils; 31 32 import java.net.InetAddress; 33 import java.security.cert.X509Certificate; 34 import java.util.Arrays; 35 import java.util.List; 36 37 /** 38 * Helper for creating and populating WifiConfigurations in unit tests. 39 */ 40 public class WifiConfigurationTestUtil { 41 /** 42 * These values are used to describe AP's security setting. One AP can support multiple of them, 43 * only if there is no conflict. 44 */ 45 public static final int SECURITY_NONE = 0; 46 public static final int SECURITY_WEP = 1 << 0; 47 public static final int SECURITY_PSK = 1 << 1; 48 public static final int SECURITY_EAP = 1 << 2; 49 public static final int SECURITY_SAE = 1 << 3; 50 public static final int SECURITY_OWE = 1 << 4; 51 public static final int SECURITY_EAP_SUITE_B = 1 << 5; 52 public static final int SECURITY_WAPI_PSK = 1 << 6; 53 public static final int SECURITY_WAPI_CERT = 1 << 7; 54 55 /** 56 * These values are used to describe ip configuration parameters for a network. 57 */ 58 public static final int STATIC_IP_ASSIGNMENT = 0; 59 public static final int DHCP_IP_ASSIGNMENT = 1; 60 public static final int STATIC_PROXY_SETTING = 0; 61 public static final int PAC_PROXY_SETTING = 1; 62 public static final int NONE_PROXY_SETTING = 2; 63 64 /** 65 * These are constants used to generate predefined WifiConfiguration objects. 66 */ 67 public static final int TEST_NETWORK_ID = -1; 68 public static final int TEST_UID = 5; 69 public static final String TEST_SSID = "WifiConfigurationTestSSID"; 70 public static final String TEST_PSK = "\"WifiConfigurationTestUtilPsk\""; 71 public static final String[] TEST_WEP_KEYS = 72 {"\"WifiConfigurationTestUtilWep1\"", "\"WifiConfigurationTestUtilWep2\"", 73 "45342312ab", "45342312ab45342312ab34ac12"}; 74 public static final String TEST_EAP_PASSWORD = "WifiConfigurationTestUtilEapPassword"; 75 public static final int TEST_WEP_TX_KEY_INDEX = 1; 76 public static final String TEST_FQDN = "WifiConfigurationTestUtilFQDN"; 77 public static final String TEST_PROVIDER_FRIENDLY_NAME = 78 "WifiConfigurationTestUtilFriendlyName"; 79 public static final String TEST_STATIC_IP_LINK_ADDRESS = "192.168.48.2"; 80 public static final int TEST_STATIC_IP_LINK_PREFIX_LENGTH = 8; 81 public static final String TEST_STATIC_IP_GATEWAY_ADDRESS = "192.168.48.1"; 82 public static final String[] TEST_STATIC_IP_DNS_SERVER_ADDRESSES = 83 new String[]{"192.168.48.1", "192.168.48.10"}; 84 public static final String TEST_STATIC_PROXY_HOST = "192.168.48.1"; 85 public static final int TEST_STATIC_PROXY_PORT = 8000; 86 public static final String TEST_STATIC_PROXY_EXCLUSION_LIST = ""; 87 public static final String TEST_PAC_PROXY_LOCATION = "http://"; 88 public static final String TEST_CA_CERT_ALIAS = "WifiConfigurationTestUtilCaCertAlias"; 89 public static final String TEST_CA_CERT_SUITE_B_ALIAS = "SuiteBCaCertAlias"; 90 public static final String TEST_CA_CERT_PATH = "caPath"; 91 public static final String TEST_DOM_SUBJECT_MATCH = "domSubjectMatch"; 92 93 private static final int MAX_SSID_LENGTH = 32; 94 /** 95 * Index used to assign unique SSIDs for the generation of predefined WifiConfiguration objects. 96 */ 97 private static int sNetworkIndex = 0; 98 99 /** 100 * Construct a {@link android.net.wifi.WifiConfiguration}. 101 * @param networkId the configuration's networkId 102 * @param uid the configuration's creator uid 103 * @param ssid the configuration's ssid 104 * @param shared whether the configuration is shared with other users on the device 105 * @param enabled whether the configuration is enabled 106 * @param fqdn the configuration's FQDN (Hotspot 2.0 only) 107 * @param providerFriendlyName the configuration's provider's friendly name (Hotspot 2.0 only) 108 * @return the constructed {@link android.net.wifi.WifiConfiguration} 109 */ generateWifiConfig(int networkId, int uid, String ssid, boolean shared, boolean enabled, String fqdn, String providerFriendlyName)110 public static WifiConfiguration generateWifiConfig(int networkId, int uid, String ssid, 111 boolean shared, boolean enabled, String fqdn, String providerFriendlyName) { 112 final WifiConfiguration config = new WifiConfiguration(); 113 config.SSID = ssid; 114 config.networkId = networkId; 115 config.creatorUid = uid; 116 config.shared = shared; 117 config.status = enabled ? WifiConfiguration.Status.ENABLED 118 : WifiConfiguration.Status.DISABLED; 119 config.FQDN = fqdn; 120 config.providerFriendlyName = providerFriendlyName; 121 if (config.FQDN != null) { 122 int uniqueId = config.FQDN.hashCode() + config.networkId + config.creatorUid; 123 // Generate a Passpoint unique id locally for the test 124 config.setPasspointUniqueId(config.FQDN + "_" + uniqueId); 125 } 126 return config; 127 } 128 129 /** 130 * Construct a {@link android.net.wifi.WifiConfiguration}. 131 * @param networkId the configuration's networkId 132 * @param uid the configuration's creator uid 133 * @param ssid the configuration's ssid 134 * @param shared whether the configuration is shared with other users on the device 135 * @param enabled whether the configuration is enabled 136 * @param fqdn the configuration's FQDN (Hotspot 2.0 only) 137 * @param providerFriendlyName the configuration's provider's friendly name (Hotspot 2.0 only) 138 * @param security the configuration's security type 139 * @return the constructed {@link android.net.wifi.WifiConfiguration} 140 */ generateWifiConfig(int networkId, int uid, String ssid, boolean shared, boolean enabled, String fqdn, String providerFriendlyName, int security)141 public static WifiConfiguration generateWifiConfig(int networkId, int uid, String ssid, 142 boolean shared, boolean enabled, String fqdn, String providerFriendlyName, 143 int security) { 144 WifiConfiguration config = generateWifiConfig(networkId, uid, ssid, shared, enabled, fqdn, 145 providerFriendlyName); 146 147 if ((security == SECURITY_NONE) || ((security & SECURITY_WEP) != 0)) { 148 config.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.NONE); 149 } else { 150 if ((security & SECURITY_PSK) != 0) { 151 config.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.WPA_PSK); 152 } 153 154 if ((security & SECURITY_SAE) != 0) { 155 config.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.SAE); 156 config.requirePmf = true; 157 } 158 159 if ((security & SECURITY_OWE) != 0) { 160 config.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.OWE); 161 config.requirePmf = true; 162 } 163 164 if ((security & SECURITY_EAP) != 0) { 165 config.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.WPA_EAP); 166 config.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.IEEE8021X); 167 config.enterpriseConfig.setEapMethod(WifiEnterpriseConfig.Eap.TTLS); 168 config.enterpriseConfig.setCaPath(TEST_CA_CERT_PATH); 169 config.enterpriseConfig.setDomainSuffixMatch(TEST_DOM_SUBJECT_MATCH); 170 } 171 172 if ((security & SECURITY_EAP_SUITE_B) != 0) { 173 config.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.WPA_EAP); 174 config.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.IEEE8021X); 175 config.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.SUITE_B_192); 176 config.requirePmf = true; 177 } 178 179 if ((security & SECURITY_WAPI_PSK) != 0) { 180 config.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.WAPI_PSK); 181 } 182 183 if ((security & SECURITY_WAPI_CERT) != 0) { 184 config.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.WAPI_CERT); 185 } 186 187 } 188 return config; 189 } 190 191 /** 192 * Construct a {@link android.net.IpConfiguration }. 193 * @param ipAssignmentType One of {@link #STATIC_IP_ASSIGNMENT} or {@link #DHCP_IP_ASSIGNMENT}. 194 * @param proxySettingType One of {@link #STATIC_PROXY_SETTING} or {@link #PAC_PROXY_SETTING} or 195 * {@link #NONE_PROXY_SETTING}. 196 * @param linkAddress static ip address string. 197 * @param linkPrefixLength static ip address prefix length. 198 * @param gatewayAddress static gateway address. 199 * @param dnsServerAddresses list of dns servers for static ip configuration. 200 * @param proxyHost Static proxy server address. 201 * @param proxyPort Static proxy server port. 202 * @param proxyExclusionList Static proxy exclusion list. 203 * @param pacProxyPath Pac proxy server path. 204 * @return the constructed {@link android.net.IpConfiguration} 205 */ generateIpConfig( int ipAssignmentType, int proxySettingType, String linkAddress, int linkPrefixLength, String gatewayAddress, String[] dnsServerAddresses, String proxyHost, int proxyPort, String proxyExclusionList, String pacProxyPath)206 public static IpConfiguration generateIpConfig( 207 int ipAssignmentType, int proxySettingType, String linkAddress, int linkPrefixLength, 208 String gatewayAddress, String[] dnsServerAddresses, String proxyHost, 209 int proxyPort, String proxyExclusionList, String pacProxyPath) { 210 StaticIpConfiguration staticIpConfiguration = null; 211 ProxyInfo proxyInfo = null; 212 IpConfiguration.IpAssignment ipAssignment = IpConfiguration.IpAssignment.UNASSIGNED; 213 IpConfiguration.ProxySettings proxySettings = IpConfiguration.ProxySettings.UNASSIGNED; 214 215 if (ipAssignmentType == STATIC_IP_ASSIGNMENT) { 216 staticIpConfiguration = new StaticIpConfiguration(); 217 if (!TextUtils.isEmpty(linkAddress)) { 218 LinkAddress linkAddr = 219 new LinkAddress( 220 InetAddresses.parseNumericAddress(linkAddress), linkPrefixLength); 221 staticIpConfiguration.ipAddress = linkAddr; 222 } 223 224 if (!TextUtils.isEmpty(gatewayAddress)) { 225 InetAddress gatewayAddr = 226 InetAddresses.parseNumericAddress(gatewayAddress); 227 staticIpConfiguration.gateway = gatewayAddr; 228 } 229 if (dnsServerAddresses != null) { 230 for (String dnsServerAddress : dnsServerAddresses) { 231 if (!TextUtils.isEmpty(dnsServerAddress)) { 232 staticIpConfiguration.dnsServers.add( 233 InetAddresses.parseNumericAddress(dnsServerAddress)); 234 } 235 236 } 237 } 238 ipAssignment = IpConfiguration.IpAssignment.STATIC; 239 } else if (ipAssignmentType == DHCP_IP_ASSIGNMENT) { 240 ipAssignment = IpConfiguration.IpAssignment.DHCP; 241 } 242 243 if (proxySettingType == STATIC_PROXY_SETTING) { 244 proxyInfo = new ProxyInfo(proxyHost, proxyPort, proxyExclusionList); 245 proxySettings = IpConfiguration.ProxySettings.STATIC; 246 } else if (proxySettingType == PAC_PROXY_SETTING) { 247 proxyInfo = new ProxyInfo(pacProxyPath); 248 proxySettings = IpConfiguration.ProxySettings.PAC; 249 } else if (proxySettingType == NONE_PROXY_SETTING) { 250 proxySettings = IpConfiguration.ProxySettings.NONE; 251 } 252 return new IpConfiguration(ipAssignment, proxySettings, staticIpConfiguration, proxyInfo); 253 } 254 255 /** 256 * Create a new SSID for the the network being created. 257 */ createNewSSID()258 private static String createNewSSID() { 259 String ssid = TEST_SSID + sNetworkIndex++; 260 assertTrue(ssid.length() <= MAX_SSID_LENGTH); 261 return "\"" + ssid + "\""; 262 } 263 264 /** 265 * Helper methods to generate predefined WifiConfiguration objects of the required type. These 266 * use a static index to avoid duplicate configurations. 267 */ createOweNetwork()268 public static WifiConfiguration createOweNetwork() { 269 return createOweNetwork(createNewSSID()); 270 } 271 createOweNetwork(String ssid)272 public static WifiConfiguration createOweNetwork(String ssid) { 273 return generateWifiConfig(TEST_NETWORK_ID, TEST_UID, ssid, true, true, null, 274 null, SECURITY_OWE); 275 } 276 createOpenNetwork()277 public static WifiConfiguration createOpenNetwork() { 278 return createOpenNetwork(createNewSSID()); 279 } 280 createOpenNetwork(String ssid)281 public static WifiConfiguration createOpenNetwork(String ssid) { 282 return generateWifiConfig(TEST_NETWORK_ID, TEST_UID, ssid, true, true, null, 283 null, SECURITY_NONE); 284 } 285 createEphemeralNetwork()286 public static WifiConfiguration createEphemeralNetwork() { 287 WifiConfiguration configuration = createOpenNetwork(); 288 configuration.ephemeral = true; 289 return configuration; 290 } 291 createOpenHiddenNetwork()292 public static WifiConfiguration createOpenHiddenNetwork() { 293 WifiConfiguration configuration = createOpenNetwork(); 294 configuration.hiddenSSID = true; 295 return configuration; 296 } 297 createSaeNetwork()298 public static WifiConfiguration createSaeNetwork() { 299 return createSaeNetwork(createNewSSID()); 300 } 301 createPskNetwork()302 public static WifiConfiguration createPskNetwork() { 303 return createPskNetwork(createNewSSID()); 304 } 305 createPskNetwork(String ssid)306 public static WifiConfiguration createPskNetwork(String ssid) { 307 WifiConfiguration configuration = 308 generateWifiConfig(TEST_NETWORK_ID, TEST_UID, ssid, true, true, null, 309 null, SECURITY_PSK); 310 configuration.preSharedKey = TEST_PSK; 311 return configuration; 312 } 313 createSaeNetwork(String ssid)314 public static WifiConfiguration createSaeNetwork(String ssid) { 315 WifiConfiguration configuration = 316 generateWifiConfig(TEST_NETWORK_ID, TEST_UID, ssid, true, true, null, 317 null, SECURITY_SAE); 318 319 // SAE password uses the same member. 320 configuration.preSharedKey = TEST_PSK; 321 configuration.requirePmf = true; 322 return configuration; 323 } 324 createPskHiddenNetwork()325 public static WifiConfiguration createPskHiddenNetwork() { 326 WifiConfiguration configuration = createPskNetwork(); 327 configuration.hiddenSSID = true; 328 return configuration; 329 } 330 createWepNetwork()331 public static WifiConfiguration createWepNetwork() { 332 WifiConfiguration configuration = 333 generateWifiConfig(TEST_NETWORK_ID, TEST_UID, createNewSSID(), true, true, null, 334 null, SECURITY_WEP); 335 configuration.wepKeys = TEST_WEP_KEYS; 336 configuration.wepTxKeyIndex = TEST_WEP_TX_KEY_INDEX; 337 return configuration; 338 } 339 createWepHiddenNetwork()340 public static WifiConfiguration createWepHiddenNetwork() { 341 WifiConfiguration configuration = createWepNetwork(); 342 configuration.hiddenSSID = true; 343 return configuration; 344 } 345 createWepNetworkWithSingleKey()346 public static WifiConfiguration createWepNetworkWithSingleKey() { 347 WifiConfiguration configuration = 348 generateWifiConfig(TEST_NETWORK_ID, TEST_UID, createNewSSID(), true, true, null, 349 null, SECURITY_WEP); 350 configuration.wepKeys[0] = TEST_WEP_KEYS[0]; 351 configuration.wepTxKeyIndex = 0; 352 return configuration; 353 } 354 355 createEapNetwork()356 public static WifiConfiguration createEapNetwork() { 357 WifiConfiguration configuration = 358 generateWifiConfig(TEST_NETWORK_ID, TEST_UID, createNewSSID(), true, true, 359 null, null, SECURITY_EAP); 360 return configuration; 361 } 362 createEapNetwork(String ssid)363 public static WifiConfiguration createEapNetwork(String ssid) { 364 WifiConfiguration configuration = 365 generateWifiConfig(TEST_NETWORK_ID, TEST_UID, ssid, true, true, 366 null, null, SECURITY_EAP); 367 return configuration; 368 } 369 370 createEapNetwork(int eapMethod, int phase2Method)371 public static WifiConfiguration createEapNetwork(int eapMethod, int phase2Method) { 372 WifiConfiguration configuration = 373 generateWifiConfig(TEST_NETWORK_ID, TEST_UID, createNewSSID(), true, true, 374 null, null, SECURITY_EAP); 375 configuration.enterpriseConfig.setEapMethod(eapMethod); 376 configuration.enterpriseConfig.setPhase2Method(phase2Method); 377 return configuration; 378 } 379 createEapSuiteBNetwork()380 public static WifiConfiguration createEapSuiteBNetwork() { 381 return createEapSuiteBNetwork(WifiConfiguration.SuiteBCipher.ECDHE_RSA); 382 } 383 createEapSuiteBNetwork(int signatureType)384 public static WifiConfiguration createEapSuiteBNetwork(int signatureType) { 385 WifiConfiguration configuration = 386 generateWifiConfig(TEST_NETWORK_ID, TEST_UID, createNewSSID(), true, true, 387 null, null, SECURITY_EAP_SUITE_B); 388 389 configuration.requirePmf = true; 390 configuration.enterpriseConfig.setEapMethod(WifiEnterpriseConfig.Eap.TLS); 391 configuration.enterpriseConfig.setPhase2Method(WifiEnterpriseConfig.Phase2.NONE); 392 393 if (signatureType == WifiConfiguration.SuiteBCipher.ECDHE_ECDSA) { 394 configuration.enterpriseConfig.setCaCertificate(FakeKeys.CA_SUITE_B_ECDSA_CERT); 395 configuration.enterpriseConfig.setClientKeyEntryWithCertificateChain( 396 FakeKeys.CLIENT_SUITE_B_ECC_KEY, 397 new X509Certificate[] {FakeKeys.CLIENT_SUITE_B_ECDSA_CERT}); 398 } else { 399 configuration.enterpriseConfig.setCaCertificate(FakeKeys.CA_SUITE_B_RSA3072_CERT); 400 configuration.enterpriseConfig.setClientKeyEntryWithCertificateChain( 401 FakeKeys.CLIENT_SUITE_B_RSA3072_KEY, 402 new X509Certificate[] {FakeKeys.CLIENT_SUITE_B_RSA3072_CERT}); 403 } 404 return configuration; 405 } 406 createPasspointNetwork()407 public static WifiConfiguration createPasspointNetwork() { 408 WifiConfiguration configuration = 409 generateWifiConfig(TEST_NETWORK_ID, TEST_UID, createNewSSID(), true, true, 410 TEST_FQDN, TEST_PROVIDER_FRIENDLY_NAME, SECURITY_EAP); 411 return configuration; 412 } 413 createWapiPskNetwork()414 public static WifiConfiguration createWapiPskNetwork() { 415 WifiConfiguration configuration = 416 generateWifiConfig(TEST_NETWORK_ID, TEST_UID, createNewSSID(), true, true, null, 417 null, SECURITY_WAPI_PSK); 418 configuration.preSharedKey = TEST_PSK; 419 return configuration; 420 } 421 createWapiCertNetwork()422 public static WifiConfiguration createWapiCertNetwork() { 423 WifiEnterpriseConfig enterpriseConfig = new WifiEnterpriseConfig(); 424 enterpriseConfig.setEapMethod(WifiEnterpriseConfig.Eap.WAPI_CERT); 425 enterpriseConfig.setWapiCertSuite("wapiCertSuite"); 426 WifiConfiguration configuration = 427 generateWifiConfig(TEST_NETWORK_ID, TEST_UID, createNewSSID(), true, true, null, 428 null, SECURITY_WAPI_CERT); 429 configuration.enterpriseConfig = enterpriseConfig; 430 return configuration; 431 } 432 createStaticIpConfigurationWithPacProxy()433 public static IpConfiguration createStaticIpConfigurationWithPacProxy() { 434 return generateIpConfig( 435 STATIC_IP_ASSIGNMENT, PAC_PROXY_SETTING, 436 TEST_STATIC_IP_LINK_ADDRESS, TEST_STATIC_IP_LINK_PREFIX_LENGTH, 437 TEST_STATIC_IP_GATEWAY_ADDRESS, TEST_STATIC_IP_DNS_SERVER_ADDRESSES, 438 TEST_STATIC_PROXY_HOST, TEST_STATIC_PROXY_PORT, TEST_STATIC_PROXY_EXCLUSION_LIST, 439 TEST_PAC_PROXY_LOCATION); 440 } 441 createStaticIpConfigurationWithStaticProxy()442 public static IpConfiguration createStaticIpConfigurationWithStaticProxy() { 443 return generateIpConfig( 444 STATIC_IP_ASSIGNMENT, STATIC_PROXY_SETTING, 445 TEST_STATIC_IP_LINK_ADDRESS, TEST_STATIC_IP_LINK_PREFIX_LENGTH, 446 TEST_STATIC_IP_GATEWAY_ADDRESS, TEST_STATIC_IP_DNS_SERVER_ADDRESSES, 447 TEST_STATIC_PROXY_HOST, TEST_STATIC_PROXY_PORT, TEST_STATIC_PROXY_EXCLUSION_LIST, 448 TEST_PAC_PROXY_LOCATION); 449 } 450 createPartialStaticIpConfigurationWithPacProxy()451 public static IpConfiguration createPartialStaticIpConfigurationWithPacProxy() { 452 return generateIpConfig( 453 STATIC_IP_ASSIGNMENT, PAC_PROXY_SETTING, 454 TEST_STATIC_IP_LINK_ADDRESS, TEST_STATIC_IP_LINK_PREFIX_LENGTH, 455 null, null, 456 TEST_STATIC_PROXY_HOST, TEST_STATIC_PROXY_PORT, TEST_STATIC_PROXY_EXCLUSION_LIST, 457 TEST_PAC_PROXY_LOCATION); 458 } 459 createDHCPIpConfigurationWithPacProxy()460 public static IpConfiguration createDHCPIpConfigurationWithPacProxy() { 461 return generateIpConfig( 462 DHCP_IP_ASSIGNMENT, PAC_PROXY_SETTING, 463 TEST_STATIC_IP_LINK_ADDRESS, TEST_STATIC_IP_LINK_PREFIX_LENGTH, 464 TEST_STATIC_IP_GATEWAY_ADDRESS, TEST_STATIC_IP_DNS_SERVER_ADDRESSES, 465 TEST_STATIC_PROXY_HOST, TEST_STATIC_PROXY_PORT, TEST_STATIC_PROXY_EXCLUSION_LIST, 466 TEST_PAC_PROXY_LOCATION); 467 } 468 createDHCPIpConfigurationWithStaticProxy()469 public static IpConfiguration createDHCPIpConfigurationWithStaticProxy() { 470 return generateIpConfig( 471 DHCP_IP_ASSIGNMENT, STATIC_PROXY_SETTING, 472 TEST_STATIC_IP_LINK_ADDRESS, TEST_STATIC_IP_LINK_PREFIX_LENGTH, 473 TEST_STATIC_IP_GATEWAY_ADDRESS, TEST_STATIC_IP_DNS_SERVER_ADDRESSES, 474 TEST_STATIC_PROXY_HOST, TEST_STATIC_PROXY_PORT, TEST_STATIC_PROXY_EXCLUSION_LIST, 475 TEST_PAC_PROXY_LOCATION); 476 } 477 createDHCPIpConfigurationWithNoProxy()478 public static IpConfiguration createDHCPIpConfigurationWithNoProxy() { 479 return generateIpConfig( 480 DHCP_IP_ASSIGNMENT, NONE_PROXY_SETTING, 481 TEST_STATIC_IP_LINK_ADDRESS, TEST_STATIC_IP_LINK_PREFIX_LENGTH, 482 TEST_STATIC_IP_GATEWAY_ADDRESS, TEST_STATIC_IP_DNS_SERVER_ADDRESSES, 483 TEST_STATIC_PROXY_HOST, TEST_STATIC_PROXY_PORT, TEST_STATIC_PROXY_EXCLUSION_LIST, 484 TEST_PAC_PROXY_LOCATION); 485 } 486 487 /** 488 * Creates an IP configuration with specific parameters. 489 * @param proxySetting Must be one of {@link WifiConfigurationTestUtil#STATIC_PROXY_SETTING}, 490 * {@link WifiConfigurationTestUtil#PAC_PROXY_SETTING}, 491 * {@link WifiConfigurationTestUtil#NONE_PROXY_SETTING} 492 */ createDHCPIpConfigurationWithSpecificProxy( int proxySetting, String staticProxyHost, int staticProxyPort, String staticProxyExclusionList, String pacProxyLocation)493 public static IpConfiguration createDHCPIpConfigurationWithSpecificProxy( 494 int proxySetting, 495 String staticProxyHost, 496 int staticProxyPort, 497 String staticProxyExclusionList, 498 String pacProxyLocation) { 499 return generateIpConfig( 500 DHCP_IP_ASSIGNMENT, proxySetting, 501 TEST_STATIC_IP_LINK_ADDRESS, TEST_STATIC_IP_LINK_PREFIX_LENGTH, 502 TEST_STATIC_IP_GATEWAY_ADDRESS, TEST_STATIC_IP_DNS_SERVER_ADDRESSES, 503 staticProxyHost, staticProxyPort, staticProxyExclusionList, 504 pacProxyLocation); 505 } 506 507 // TODO: These enterprise configurations may need more parameters set. createPEAPWifiEnterpriseConfigWithGTCPhase2()508 public static WifiEnterpriseConfig createPEAPWifiEnterpriseConfigWithGTCPhase2() { 509 WifiEnterpriseConfig config = new WifiEnterpriseConfig(); 510 config.setEapMethod(WifiEnterpriseConfig.Eap.PEAP); 511 config.setPhase2Method(WifiEnterpriseConfig.Phase2.GTC); 512 config.setCaCertificateAliases(new String[] {TEST_CA_CERT_ALIAS + "PEAP"}); 513 config.setCaCertificates(new X509Certificate[] {FakeKeys.CA_CERT0, FakeKeys.CA_CERT1}); 514 config.setDomainSuffixMatch(TEST_DOM_SUBJECT_MATCH); 515 return config; 516 } 517 createTLSWifiEnterpriseConfigWithNonePhase2()518 public static WifiEnterpriseConfig createTLSWifiEnterpriseConfigWithNonePhase2() { 519 WifiEnterpriseConfig config = new WifiEnterpriseConfig(); 520 config.setEapMethod(WifiEnterpriseConfig.Eap.TLS); 521 config.setPhase2Method(WifiEnterpriseConfig.Phase2.NONE); 522 config.setCaCertificateAliases(new String[] {TEST_CA_CERT_ALIAS + "TLS"}); 523 config.setCaCertificates(new X509Certificate[] {FakeKeys.CA_CERT0, FakeKeys.CA_CERT1}); 524 config.setDomainSuffixMatch(TEST_DOM_SUBJECT_MATCH); 525 return config; 526 } 527 createTLSWifiEnterpriseConfigWithAkaPhase2()528 public static WifiEnterpriseConfig createTLSWifiEnterpriseConfigWithAkaPhase2() { 529 WifiEnterpriseConfig config = new WifiEnterpriseConfig(); 530 config.setEapMethod(WifiEnterpriseConfig.Eap.TLS); 531 config.setPhase2Method(WifiEnterpriseConfig.Phase2.AKA); 532 config.setDomainSuffixMatch(TEST_DOM_SUBJECT_MATCH); 533 return config; 534 } 535 536 /** 537 * Gets scan result capabilities for a particular network configuration. 538 */ getScanResultCapsForNetwork(WifiConfiguration configuration)539 public static String getScanResultCapsForNetwork(WifiConfiguration configuration) { 540 String caps; 541 if (configuration.allowedKeyManagement.get(WifiConfiguration.KeyMgmt.WPA_PSK)) { 542 caps = "[RSN-PSK-CCMP]"; 543 } else if (configuration.allowedKeyManagement.get(WifiConfiguration.KeyMgmt.WPA_EAP) 544 || configuration.allowedKeyManagement.get(WifiConfiguration.KeyMgmt.IEEE8021X)) { 545 caps = "[RSN-EAP-CCMP]"; 546 } else if (configuration.allowedKeyManagement.get(WifiConfiguration.KeyMgmt.NONE) 547 && WifiConfigurationUtil.hasAnyValidWepKey(configuration.wepKeys)) { 548 caps = "[WEP]"; 549 } else if (configuration.allowedKeyManagement.get(WifiConfiguration.KeyMgmt.SAE)) { 550 caps = "[RSN-SAE-CCMP]"; 551 } else if (configuration.allowedKeyManagement.get(WifiConfiguration.KeyMgmt.OWE)) { 552 caps = "[RSN-OWE-CCMP]"; 553 } else if (configuration.allowedKeyManagement.get(WifiConfiguration.KeyMgmt.SUITE_B_192)) { 554 caps = "[RSN-SUITE-B-192-CCMP]"; 555 } else if (configuration.allowedKeyManagement.get(WifiConfiguration.KeyMgmt.WAPI_PSK)) { 556 caps = "[WAPI-WAPI-PSK-SMS4]"; 557 } else if (configuration.allowedKeyManagement.get(WifiConfiguration.KeyMgmt.WAPI_CERT)) { 558 caps = "[WAPI-WAPI-CERT-SMS4]"; 559 } else { 560 caps = "[]"; 561 } 562 return caps; 563 } 564 565 /** 566 * Gets scan result capabilities for a WPA2/WPA3-Transition mode network configuration 567 */ getScanResultCapsForWpa2Wpa3TransitionNetwork()568 public static String getScanResultCapsForWpa2Wpa3TransitionNetwork() { 569 String caps = "[RSN-PSK+SAE-CCMP]"; 570 return caps; 571 } 572 573 /** 574 * Creates a scan detail corresponding to the provided network and given BSSID, etc. 575 */ createScanDetailForNetwork( WifiConfiguration configuration, String bssid, int level, int frequency, long tsf, long seen)576 public static ScanDetail createScanDetailForNetwork( 577 WifiConfiguration configuration, String bssid, int level, int frequency, 578 long tsf, long seen) { 579 String caps = getScanResultCapsForNetwork(configuration); 580 WifiSsid ssid = WifiSsid.createFromAsciiEncoded(configuration.getPrintableSsid()); 581 return new ScanDetail(ssid, bssid, caps, level, frequency, tsf, seen); 582 } 583 584 /** 585 * Creates a scan detail corresponding to the provided network and given BSSID, but sets 586 * the capabilities to WPA2/WPA3-Transition mode network. 587 */ createScanDetailForWpa2Wpa3TransitionModeNetwork( WifiConfiguration configuration, String bssid, int level, int frequency, long tsf, long seen)588 public static ScanDetail createScanDetailForWpa2Wpa3TransitionModeNetwork( 589 WifiConfiguration configuration, String bssid, int level, int frequency, 590 long tsf, long seen) { 591 String caps = getScanResultCapsForWpa2Wpa3TransitionNetwork(); 592 WifiSsid ssid = WifiSsid.createFromAsciiEncoded(configuration.getPrintableSsid()); 593 return new ScanDetail(ssid, bssid, caps, level, frequency, tsf, seen); 594 } 595 596 /** 597 * Asserts that the 2 WifiConfigurations are equal in the elements saved for both backup/restore 598 * and config store. 599 */ assertCommonConfigurationElementsEqual( WifiConfiguration expected, WifiConfiguration actual)600 private static void assertCommonConfigurationElementsEqual( 601 WifiConfiguration expected, WifiConfiguration actual) { 602 assertNotNull(expected); 603 assertNotNull(actual); 604 assertEquals(expected.SSID, actual.SSID); 605 assertEquals(expected.BSSID, actual.BSSID); 606 assertEquals(expected.preSharedKey, actual.preSharedKey); 607 assertEquals(expected.wepKeys, actual.wepKeys); 608 assertEquals(expected.wepTxKeyIndex, actual.wepTxKeyIndex); 609 assertEquals(expected.hiddenSSID, actual.hiddenSSID); 610 assertEquals(expected.requirePmf, actual.requirePmf); 611 assertEquals(expected.allowedKeyManagement, actual.allowedKeyManagement); 612 assertEquals(expected.allowedProtocols, actual.allowedProtocols); 613 assertEquals(expected.allowedAuthAlgorithms, actual.allowedAuthAlgorithms); 614 assertEquals(expected.allowedGroupCiphers, actual.allowedGroupCiphers); 615 assertEquals(expected.allowedPairwiseCiphers, actual.allowedPairwiseCiphers); 616 assertEquals(expected.shared, actual.shared); 617 assertEquals(expected.getIpConfiguration(), actual.getIpConfiguration()); 618 } 619 620 621 /** 622 * Asserts that the 2 WifiConfigurations are equal. This only compares the elements saved 623 * for softAp used. 624 */ assertConfigurationEqualForSoftAp( WifiConfiguration expected, WifiConfiguration actual)625 public static void assertConfigurationEqualForSoftAp( 626 WifiConfiguration expected, WifiConfiguration actual) { 627 assertEquals(expected.SSID, actual.SSID); 628 assertEquals(expected.BSSID, actual.BSSID); 629 assertEquals(expected.apBand, actual.apBand); 630 assertEquals(expected.apChannel, actual.apChannel); 631 assertEquals(expected.preSharedKey, actual.preSharedKey); 632 assertEquals(expected.getAuthType(), actual.getAuthType()); 633 assertEquals(expected.hiddenSSID, actual.hiddenSSID); 634 } 635 636 /** 637 * Asserts that the 2 WifiConfigurations are equal. This only compares the elements saved 638 * for backup/restore. 639 */ assertConfigurationEqualForBackup( WifiConfiguration expected, WifiConfiguration actual)640 public static void assertConfigurationEqualForBackup( 641 WifiConfiguration expected, WifiConfiguration actual) { 642 assertCommonConfigurationElementsEqual(expected, actual); 643 assertEquals(expected.meteredOverride, actual.meteredOverride); 644 } 645 646 /** 647 * Asserts that the 2 WifiConfigurations are equal. This compares all the elements saved for 648 * config store. 649 */ assertConfigurationEqualForConfigStore( WifiConfiguration expected, WifiConfiguration actual)650 public static void assertConfigurationEqualForConfigStore( 651 WifiConfiguration expected, WifiConfiguration actual) { 652 assertCommonConfigurationElementsEqual(expected, actual); 653 assertEquals(expected.status, actual.status); 654 assertEquals(expected.FQDN, actual.FQDN); 655 assertEquals(expected.providerFriendlyName, actual.providerFriendlyName); 656 assertTrue(Arrays.equals(expected.roamingConsortiumIds, actual.roamingConsortiumIds)); 657 assertEquals(expected.linkedConfigurations, actual.linkedConfigurations); 658 assertEquals(expected.defaultGwMacAddress, actual.defaultGwMacAddress); 659 assertEquals(expected.validatedInternetAccess, actual.validatedInternetAccess); 660 assertEquals(expected.noInternetAccessExpected, actual.noInternetAccessExpected); 661 assertEquals(expected.meteredHint, actual.meteredHint); 662 assertEquals(expected.meteredOverride, actual.meteredOverride); 663 assertEquals(expected.useExternalScores, actual.useExternalScores); 664 assertEquals(0, actual.numAssociation); 665 assertEquals(expected.creatorUid, actual.creatorUid); 666 assertEquals(expected.creatorName, actual.creatorName); 667 assertEquals(expected.lastUpdateUid, actual.lastUpdateUid); 668 assertEquals(expected.lastUpdateName, actual.lastUpdateName); 669 assertEquals(expected.lastConnectUid, actual.lastConnectUid); 670 assertEquals(expected.isLegacyPasspointConfig, actual.isLegacyPasspointConfig); 671 assertEquals(expected.getRandomizedMacAddress(), actual.getRandomizedMacAddress()); 672 assertEquals(expected.macRandomizationSetting, actual.macRandomizationSetting); 673 assertNetworkSelectionStatusEqualForConfigStore( 674 expected.getNetworkSelectionStatus(), actual.getNetworkSelectionStatus()); 675 assertWifiEnterpriseConfigEqualForConfigStore( 676 expected.enterpriseConfig, actual.enterpriseConfig); 677 } 678 679 /** 680 * Asserts that the 2 WifiConfigurations are equal. This compares all the elements that are 681 * saved into internal database by WifiConfigurationManager for network additions/updates. 682 */ assertConfigurationEqualForConfigManagerAddOrUpdate( WifiConfiguration expected, WifiConfiguration actual)683 public static void assertConfigurationEqualForConfigManagerAddOrUpdate( 684 WifiConfiguration expected, WifiConfiguration actual) { 685 assertCommonConfigurationElementsEqual(expected, actual); 686 assertEquals(expected.FQDN, actual.FQDN); 687 assertEquals(expected.providerFriendlyName, actual.providerFriendlyName); 688 assertEquals(expected.noInternetAccessExpected, actual.noInternetAccessExpected); 689 assertEquals(expected.meteredHint, actual.meteredHint); 690 assertEquals(expected.meteredOverride, actual.meteredOverride); 691 assertEquals(expected.useExternalScores, actual.useExternalScores); 692 assertEquals(expected.ephemeral, actual.ephemeral); 693 assertEquals(expected.osu, actual.osu); 694 assertEquals(expected.trusted, actual.trusted); 695 assertEquals(expected.fromWifiNetworkSuggestion, actual.fromWifiNetworkSuggestion); 696 assertEquals(expected.fromWifiNetworkSpecifier, actual.fromWifiNetworkSpecifier); 697 assertEquals(expected.creatorUid, actual.creatorUid); 698 assertEquals(expected.creatorName, actual.creatorName); 699 assertEquals(expected.lastUpdateUid, actual.lastUpdateUid); 700 assertEquals(expected.lastUpdateName, actual.lastUpdateName); 701 assertNetworkSelectionStatusEqualForConfigStore( 702 expected.getNetworkSelectionStatus(), actual.getNetworkSelectionStatus()); 703 assertWifiEnterpriseConfigEqualForConfigStore( 704 expected.enterpriseConfig, actual.enterpriseConfig); 705 } 706 707 /** 708 * Asserts that the 2 WifiConfigurations are equal. This compares all the elements that are 709 * saved into wpa_supplicant by SupplicantStaNetwork. 710 */ assertConfigurationEqualForSupplicant( WifiConfiguration expected, WifiConfiguration actual)711 public static void assertConfigurationEqualForSupplicant( 712 WifiConfiguration expected, WifiConfiguration actual) { 713 assertNotNull(expected); 714 assertNotNull(actual); 715 assertEquals(expected.SSID, actual.SSID); 716 assertEquals(expected.getNetworkSelectionStatus().getNetworkSelectionBSSID(), 717 actual.getNetworkSelectionStatus().getNetworkSelectionBSSID()); 718 assertEquals(expected.preSharedKey, actual.preSharedKey); 719 assertEquals(expected.wepKeys, actual.wepKeys); 720 assertEquals(expected.wepTxKeyIndex, actual.wepTxKeyIndex); 721 assertEquals(expected.hiddenSSID, actual.hiddenSSID); 722 assertEquals(expected.requirePmf, actual.requirePmf); 723 assertEquals(expected.allowedKeyManagement, actual.allowedKeyManagement); 724 assertEquals(expected.allowedProtocols, actual.allowedProtocols); 725 assertEquals(expected.allowedAuthAlgorithms, actual.allowedAuthAlgorithms); 726 assertEquals(expected.allowedGroupCiphers, actual.allowedGroupCiphers); 727 assertEquals(expected.allowedPairwiseCiphers, actual.allowedPairwiseCiphers); 728 assertWifiEnterpriseConfigEqualForConfigStore( 729 expected.enterpriseConfig, actual.enterpriseConfig); 730 } 731 732 /** 733 * Asserts that the 2 WifiConfigurations are equal. This is a generic version of the comparator 734 * which is used in QNS tests for comparing the network selections. 735 * This importantly checks that the networkId's of the 2 configs are equal. 736 */ assertConfigurationEqual( WifiConfiguration expected, WifiConfiguration actual)737 public static void assertConfigurationEqual( 738 WifiConfiguration expected, WifiConfiguration actual) { 739 assertCommonConfigurationElementsEqual(expected, actual); 740 assertEquals(expected.networkId, actual.networkId); 741 assertEquals(expected.ephemeral, actual.ephemeral); 742 assertEquals(expected.fromWifiNetworkSuggestion, actual.fromWifiNetworkSuggestion); 743 assertEquals(expected.fromWifiNetworkSpecifier, actual.fromWifiNetworkSpecifier); 744 assertEquals(expected.trusted, actual.trusted); 745 } 746 747 /** 748 * Assert that the 2 NetworkSelectionStatus's are equal. This compares all the elements saved 749 * for config store. 750 */ assertNetworkSelectionStatusEqualForConfigStore( NetworkSelectionStatus expected, NetworkSelectionStatus actual)751 public static void assertNetworkSelectionStatusEqualForConfigStore( 752 NetworkSelectionStatus expected, NetworkSelectionStatus actual) { 753 if (expected.isNetworkTemporaryDisabled()) { 754 // Temporarily disabled networks are enabled when persisted. 755 assertEquals( 756 NetworkSelectionStatus.NETWORK_SELECTION_ENABLED, 757 actual.getNetworkSelectionStatus()); 758 assertEquals( 759 NetworkSelectionStatus.DISABLED_NONE, 760 actual.getNetworkSelectionDisableReason()); 761 } else { 762 assertEquals(expected.getNetworkSelectionStatus(), actual.getNetworkSelectionStatus()); 763 assertEquals( 764 expected.getNetworkSelectionDisableReason(), 765 actual.getNetworkSelectionDisableReason()); 766 } 767 assertEquals(expected.getConnectChoice(), actual.getConnectChoice()); 768 assertEquals(expected.hasEverConnected(), actual.hasEverConnected()); 769 } 770 771 /** 772 * Assert that the 2 WifiEnterpriseConfig's are equal. This compares all the elements saved 773 * for config store. 774 */ assertWifiEnterpriseConfigEqualForConfigStore( WifiEnterpriseConfig expected, WifiEnterpriseConfig actual)775 public static void assertWifiEnterpriseConfigEqualForConfigStore( 776 WifiEnterpriseConfig expected, WifiEnterpriseConfig actual) { 777 assertEquals(expected.getFieldValue(WifiEnterpriseConfig.IDENTITY_KEY), 778 actual.getFieldValue(WifiEnterpriseConfig.IDENTITY_KEY)); 779 assertEquals(expected.getFieldValue(WifiEnterpriseConfig.ANON_IDENTITY_KEY), 780 actual.getFieldValue(WifiEnterpriseConfig.ANON_IDENTITY_KEY)); 781 assertEquals(expected.getFieldValue(WifiEnterpriseConfig.PASSWORD_KEY), 782 actual.getFieldValue(WifiEnterpriseConfig.PASSWORD_KEY)); 783 assertEquals(expected.getFieldValue(WifiEnterpriseConfig.CLIENT_CERT_KEY), 784 actual.getFieldValue(WifiEnterpriseConfig.CLIENT_CERT_KEY)); 785 assertEquals(expected.getFieldValue(WifiEnterpriseConfig.CA_CERT_KEY), 786 actual.getFieldValue(WifiEnterpriseConfig.CA_CERT_KEY)); 787 assertEquals(expected.getFieldValue(WifiEnterpriseConfig.SUBJECT_MATCH_KEY), 788 actual.getFieldValue(WifiEnterpriseConfig.SUBJECT_MATCH_KEY)); 789 assertEquals(expected.getFieldValue(WifiEnterpriseConfig.ENGINE_KEY), 790 actual.getFieldValue(WifiEnterpriseConfig.ENGINE_KEY)); 791 assertEquals(expected.getFieldValue(WifiEnterpriseConfig.ENGINE_ID_KEY), 792 actual.getFieldValue(WifiEnterpriseConfig.ENGINE_ID_KEY)); 793 assertEquals(expected.getFieldValue(WifiEnterpriseConfig.PRIVATE_KEY_ID_KEY), 794 actual.getFieldValue(WifiEnterpriseConfig.PRIVATE_KEY_ID_KEY)); 795 assertEquals(expected.getFieldValue(WifiEnterpriseConfig.ALTSUBJECT_MATCH_KEY), 796 actual.getFieldValue(WifiEnterpriseConfig.ALTSUBJECT_MATCH_KEY)); 797 assertEquals(expected.getFieldValue(WifiEnterpriseConfig.DOM_SUFFIX_MATCH_KEY), 798 actual.getFieldValue(WifiEnterpriseConfig.DOM_SUFFIX_MATCH_KEY)); 799 assertEquals(expected.getFieldValue(WifiEnterpriseConfig.CA_PATH_KEY), 800 actual.getFieldValue(WifiEnterpriseConfig.CA_PATH_KEY)); 801 assertEquals(expected.getFieldValue(WifiEnterpriseConfig.REALM_KEY), 802 actual.getFieldValue(WifiEnterpriseConfig.REALM_KEY)); 803 assertEquals(expected.getFieldValue(WifiEnterpriseConfig.PLMN_KEY), 804 actual.getFieldValue(WifiEnterpriseConfig.PLMN_KEY)); 805 assertEquals(expected.getEapMethod(), actual.getEapMethod()); 806 assertEquals(expected.getPhase2Method(), actual.getPhase2Method()); 807 } 808 809 /** 810 * Asserts that the 2 lists of WifiConfigurations are equal. This compares all the elements 811 * saved for backup/restore. 812 */ assertConfigurationsEqualForBackup( List<WifiConfiguration> expected, List<WifiConfiguration> actual)813 public static void assertConfigurationsEqualForBackup( 814 List<WifiConfiguration> expected, List<WifiConfiguration> actual) { 815 assertEquals(expected.size(), actual.size()); 816 for (WifiConfiguration expectedConfiguration : expected) { 817 String expectedConfigKey = expectedConfiguration.getKey(); 818 boolean didCompare = false; 819 for (WifiConfiguration actualConfiguration : actual) { 820 String actualConfigKey = actualConfiguration.getKey(); 821 if (actualConfigKey.equals(expectedConfigKey)) { 822 assertConfigurationEqualForBackup( 823 expectedConfiguration, actualConfiguration); 824 didCompare = true; 825 } 826 } 827 assertTrue(didCompare); 828 } 829 } 830 831 /** 832 * Asserts that the 2 lists of WifiConfigurations are equal. This compares all the elements 833 * that are saved into internal database by WifiConfigurationManager for network 834 * additions/updates. 835 */ assertConfigurationsEqualForConfigManagerAddOrUpdate( List<WifiConfiguration> expected, List<WifiConfiguration> actual)836 public static void assertConfigurationsEqualForConfigManagerAddOrUpdate( 837 List<WifiConfiguration> expected, List<WifiConfiguration> actual) { 838 assertEquals(expected.size(), actual.size()); 839 for (WifiConfiguration expectedConfiguration : expected) { 840 String expectedConfigKey = expectedConfiguration.getKey(); 841 boolean didCompare = false; 842 for (WifiConfiguration actualConfiguration : actual) { 843 String actualConfigKey = actualConfiguration.getKey(); 844 if (actualConfigKey.equals(expectedConfigKey)) { 845 assertConfigurationEqualForConfigManagerAddOrUpdate( 846 expectedConfiguration, actualConfiguration); 847 didCompare = true; 848 } 849 } 850 assertTrue(didCompare); 851 } 852 } 853 854 /** 855 * Asserts that the 2 lists of WifiConfigurations are equal. This compares all the elements 856 * saved for config store. 857 */ assertConfigurationsEqualForConfigStore( List<WifiConfiguration> expected, List<WifiConfiguration> actual)858 public static void assertConfigurationsEqualForConfigStore( 859 List<WifiConfiguration> expected, List<WifiConfiguration> actual) { 860 assertEquals(expected.size(), actual.size()); 861 for (WifiConfiguration expectedConfiguration : expected) { 862 String expectedConfigKey = expectedConfiguration.getKey(); 863 boolean didCompare = false; 864 for (WifiConfiguration actualConfiguration : actual) { 865 String actualConfigKey = actualConfiguration.getKey(); 866 if (actualConfigKey.equals(expectedConfigKey)) { 867 assertConfigurationEqualForConfigStore( 868 expectedConfiguration, actualConfiguration); 869 didCompare = true; 870 } 871 } 872 assertTrue(didCompare); 873 } 874 } 875 } 876