summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorTreeHugger Robot <treehugger-gerrit@google.com>2019-11-18 20:27:56 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2019-11-18 20:27:56 +0000
commit8632ce63c665ab3537133631bdd169a5b2cb16a8 (patch)
tree81fef641c8aa309ded1153d73c07409e89bd1b0a /tests
parentf8773d7e3b5bda7236c355d64751abb4eedba023 (diff)
parenteee1af6676eddc4da3ccd7efdbfd530080bdbee1 (diff)
Merge "[WPA3] Fix WPA3-Personal transition mode"
Diffstat (limited to 'tests')
-rw-r--r--tests/wifitests/src/com/android/server/wifi/ConfigurationMapTest.java51
-rw-r--r--tests/wifitests/src/com/android/server/wifi/ScanResultMatchInfoTest.java2
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java137
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiConfigurationTestUtil.java40
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiNetworkFactoryTest.java46
5 files changed, 219 insertions, 57 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/ConfigurationMapTest.java b/tests/wifitests/src/com/android/server/wifi/ConfigurationMapTest.java
index 0b3cc45e8..40cc4b391 100644
--- a/tests/wifitests/src/com/android/server/wifi/ConfigurationMapTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/ConfigurationMapTest.java
@@ -281,6 +281,7 @@ public class ConfigurationMapTest extends WifiBaseTest {
verifyScanResultMatchWithNetwork(WifiConfigurationTestUtil.createPskNetwork());
verifyScanResultMatchWithNetwork(WifiConfigurationTestUtil.createWepNetwork());
verifyScanResultMatchWithNetwork(WifiConfigurationTestUtil.createEapNetwork());
+ verifyScanResultMatchWithNetwork(WifiConfigurationTestUtil.createSaeNetwork());
}
/**
@@ -333,4 +334,54 @@ public class ConfigurationMapTest extends WifiBaseTest {
mConfigs.clear();
assertNull(mConfigs.getByScanResultForCurrentUser(scanResult));
}
+
+ /**
+ * Verifies that {@link ConfigurationMap#getPskNetworkByScanResultForCurrentUser(ScanResult)}
+ * can positively match a PSK network for transition mode AP.
+ */
+ @Test
+ public void testFindPskNetworkFromSaeScanResult() {
+ final String wpa2Wpa3TransitionSsid = "\"WPA3-Transition\"";
+ WifiConfiguration saePskConfig =
+ WifiConfigurationTestUtil.createSaeNetwork(wpa2Wpa3TransitionSsid);
+ WifiConfiguration pskConfig =
+ WifiConfigurationTestUtil.createPskNetwork(wpa2Wpa3TransitionSsid);
+ mConfigs.put(saePskConfig);
+ mConfigs.put(pskConfig);
+
+ ScanDetail scanDetail = WifiConfigurationTestUtil
+ .createScanDetailForWpa2Wpa3TransitionModeNetwork(saePskConfig,
+ "AA:BB:CC:DD:CC:BB", -40, 2402, 0, 1);
+ ScanResult scanResult = scanDetail.getScanResult();
+
+ WifiConfiguration retrievedConfig =
+ mConfigs.getPskNetworkByScanResultForCurrentUser(scanResult);
+ assertNotNull(retrievedConfig);
+ assertEquals(pskConfig.configKey(), retrievedConfig.configKey());
+ }
+
+ /**
+ * Verifies that {@link ConfigurationMap#getOpenNetworkByScanResultForCurrentUser(ScanResult)}
+ * can positively match a PSK network for transition mode AP.
+ */
+ @Test
+ public void testFindOpenNetworkFromOweScanResult() {
+ final String oweTransitionSsid = "\"OWE-Transition\"";
+ WifiConfiguration oweOpenConfig =
+ WifiConfigurationTestUtil.createOweNetwork(oweTransitionSsid);
+ WifiConfiguration openConfig =
+ WifiConfigurationTestUtil.createOpenNetwork(oweTransitionSsid);
+ mConfigs.put(oweOpenConfig);
+ mConfigs.put(openConfig);
+
+ ScanDetail scanDetail = WifiConfigurationTestUtil
+ .createScanDetailForOweTransitionModeNetwork(oweOpenConfig,
+ "AA:BB:CC:DD:CC:BB", -40, 2402, 0, 1);
+ ScanResult scanResult = scanDetail.getScanResult();
+
+ WifiConfiguration retrievedConfig =
+ mConfigs.getOpenNetworkByScanResultForCurrentUser(scanResult);
+ assertNotNull(retrievedConfig);
+ assertEquals(openConfig.configKey(), retrievedConfig.configKey());
+ }
}
diff --git a/tests/wifitests/src/com/android/server/wifi/ScanResultMatchInfoTest.java b/tests/wifitests/src/com/android/server/wifi/ScanResultMatchInfoTest.java
index 1cc7fa83f..4192da68c 100644
--- a/tests/wifitests/src/com/android/server/wifi/ScanResultMatchInfoTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/ScanResultMatchInfoTest.java
@@ -92,7 +92,7 @@ public class ScanResultMatchInfoTest extends WifiBaseTest {
@Test
public void testEqualityRulesForTransitionMode() {
WifiConfiguration wifiConfiguration =
- WifiConfigurationTestUtil.createPskNetwork("\"Transition is Hard\"");
+ WifiConfigurationTestUtil.createSaeNetwork("\"Transition is Hard\"");
ScanDetail scanDetail = createScanDetailForWpa2Wpa3TransitionModeNetwork(wifiConfiguration,
"AA:BB:CC:DD:CC:BB");
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java b/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java
index 895a169a1..d48966143 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java
@@ -190,6 +190,8 @@ public class WifiConfigManagerTest extends WifiBaseTest {
return TEST_NO_PERM_NAME;
} else if (uid == Process.WIFI_UID) {
return TEST_WIFI_NAME;
+ } else if (uid == Process.SYSTEM_UID) {
+ return TEST_WIFI_NAME;
}
fail("Unexpected UID: " + uid);
return "";
@@ -5590,4 +5592,139 @@ public class WifiConfigManagerTest extends WifiBaseTest {
assertFalse(mWifiConfigManager.getConfiguredNetwork(networkId)
.getNetworkSelectionStatus().isNetworkTemporaryDisabled());
}
+
+ /**
+ * Verifies that when scanning a WPA3 in transition mode AP, and there is a matching WPA2 saved
+ * network, {@link WifiConfigManager#getConfiguredNetworkForScanDetailAndCache(ScanDetail)}
+ * clones a new WPA3 saved network that will be used to connect to it.
+ *
+ * The test also verifies that the new network is marked as cloned.
+ */
+ @Test
+ public void testCloningPskNetworkForTransitionMode() {
+ final String wpa2Wpa3TransitionSsid = "\"WPA3-Transition\"";
+ WifiConfiguration saeNetwork = WifiConfigurationTestUtil
+ .createSaeNetwork(wpa2Wpa3TransitionSsid);
+ WifiConfiguration pskNetwork = WifiConfigurationTestUtil
+ .createPskNetwork(wpa2Wpa3TransitionSsid);
+
+ // First add the WPA2 saved network.
+ verifyAddNetworkToWifiConfigManager(pskNetwork);
+
+ // Now create a dummy scan detail for WPA3-Transition.
+ ScanDetail scanDetail = WifiConfigurationTestUtil
+ .createScanDetailForWpa2Wpa3TransitionModeNetwork(saeNetwork,
+ "AA:BB:CC:DD:CC:BB", -40, 2402, 0, 1);
+
+
+ WifiConfiguration retrievedNetwork =
+ mWifiConfigManager.getConfiguredNetworkForScanDetailAndCache(scanDetail);
+ // Retrieve the network with password data for comparison.
+ retrievedNetwork =
+ mWifiConfigManager.getConfiguredNetworkWithPassword(retrievedNetwork.networkId);
+
+ // Verify cloned network matches the expected WPA3 network
+ assertEquals(saeNetwork.SSID, retrievedNetwork.SSID);
+ assertEquals(saeNetwork.BSSID, retrievedNetwork.BSSID);
+ assertEquals(saeNetwork.preSharedKey, retrievedNetwork.preSharedKey);
+ assertEquals(saeNetwork.requirePMF, retrievedNetwork.requirePMF);
+ assertEquals(saeNetwork.allowedKeyManagement, retrievedNetwork.allowedKeyManagement);
+ assertNotNull(retrievedNetwork.clonedNetworkConfigKey);
+ assertEquals(retrievedNetwork.clonedNetworkConfigKey, pskNetwork.configKey());
+ }
+
+ /**
+ * Verifies that when scanning a WPA3 in transition mode AP, and there is a matching WPA2 saved
+ * network, {@link WifiConfigManager#getConfiguredNetworkForScanDetailAndCache(ScanDetail)}
+ * clones a new WPA3 saved network that will be used to connect to it.
+ *
+ * The test also verifies that the new network is marked as cloned.
+ */
+ @Test
+ public void testCloningOweNetworkForTransitionMode() {
+ final String oweTransitionSsid = "\"OWE-Transition\"";
+ WifiConfiguration oweNetwork = WifiConfigurationTestUtil
+ .createOweNetwork(oweTransitionSsid);
+ WifiConfiguration openNetwork = WifiConfigurationTestUtil
+ .createOpenNetwork(oweTransitionSsid);
+
+ // First add the Open saved network.
+ verifyAddNetworkToWifiConfigManager(openNetwork);
+
+ // Now create a dummy scan detail for OWE-Transition.
+ ScanDetail scanDetail = WifiConfigurationTestUtil
+ .createScanDetailForOweTransitionModeNetwork(oweNetwork,
+ "AA:BB:CC:DD:CC:BB", -40, 2402, 0, 1);
+
+
+ WifiConfiguration retrievedNetwork =
+ mWifiConfigManager.getConfiguredNetworkForScanDetailAndCache(scanDetail);
+ // Retrieve the network with password data for comparison.
+ retrievedNetwork =
+ mWifiConfigManager.getConfiguredNetworkWithPassword(retrievedNetwork.networkId);
+
+ // Verify cloned network matches the expected OWE network
+ assertEquals(oweNetwork.SSID, retrievedNetwork.SSID);
+ assertEquals(oweNetwork.BSSID, retrievedNetwork.BSSID);
+ assertEquals(oweNetwork.preSharedKey, retrievedNetwork.preSharedKey);
+ assertEquals(oweNetwork.requirePMF, retrievedNetwork.requirePMF);
+ assertEquals(oweNetwork.allowedKeyManagement, retrievedNetwork.allowedKeyManagement);
+ assertNotNull(retrievedNetwork.clonedNetworkConfigKey);
+ assertEquals(retrievedNetwork.clonedNetworkConfigKey, openNetwork.configKey());
+ }
+
+ /**
+ * Verifies that when a cloned network is removed, its original pair is removed as well
+ * {@link WifiConfigManager#removeNetwork(int)}
+ */
+ @Test
+ public void testRemoveClonedSaeNetwork() {
+ final String wpa2Wpa3TransitionSsid = "\"WPA3-Transition\"";
+ WifiConfiguration saeNetwork = WifiConfigurationTestUtil
+ .createSaeNetwork(wpa2Wpa3TransitionSsid);
+ WifiConfiguration pskNetwork = WifiConfigurationTestUtil
+ .createPskNetwork(wpa2Wpa3TransitionSsid);
+ ArgumentCaptor<WifiConfiguration> wifiConfigCaptor =
+ ArgumentCaptor.forClass(WifiConfiguration.class);
+
+ // First add the WPA2 saved network.
+ NetworkUpdateResult result = verifyAddNetworkToWifiConfigManager(pskNetwork);
+ verify(mWcmListener).onNetworkAdded(wifiConfigCaptor.capture());
+ assertEquals(pskNetwork.networkId, wifiConfigCaptor.getValue().networkId);
+ reset(mWcmListener);
+
+ // Now create a dummy scan detail for WPA3-Transition.
+ ScanDetail scanDetail = WifiConfigurationTestUtil
+ .createScanDetailForWpa2Wpa3TransitionModeNetwork(saeNetwork,
+ "AA:BB:CC:DD:CC:BB", -40, 2402, 0, 1);
+
+ WifiConfiguration retrievedNetwork =
+ mWifiConfigManager.getConfiguredNetworkForScanDetailAndCache(scanDetail);
+ // Retrieve the network with password data for comparison.
+ retrievedNetwork =
+ mWifiConfigManager.getConfiguredNetworkWithPassword(retrievedNetwork.networkId);
+
+ // Verify cloned network matches the expected WPA3 network
+ assertEquals(saeNetwork.SSID, retrievedNetwork.SSID);
+ assertEquals(saeNetwork.BSSID, retrievedNetwork.BSSID);
+ assertEquals(saeNetwork.preSharedKey, retrievedNetwork.preSharedKey);
+ assertEquals(saeNetwork.requirePMF, retrievedNetwork.requirePMF);
+ assertEquals(saeNetwork.allowedKeyManagement, retrievedNetwork.allowedKeyManagement);
+ assertNotNull(retrievedNetwork.clonedNetworkConfigKey);
+ assertEquals(retrievedNetwork.clonedNetworkConfigKey, pskNetwork.configKey());
+
+ // Ensure that configured network list is not empty.
+ assertTrue(mWifiConfigManager.getConfiguredNetworks().size() == 2);
+ verify(mWcmListener).onNetworkAdded(wifiConfigCaptor.capture());
+ assertEquals(retrievedNetwork.networkId, wifiConfigCaptor.getValue().networkId);
+ reset(mWcmListener);
+
+ assertTrue(mWifiConfigManager.removeNetwork(retrievedNetwork.networkId, TEST_CREATOR_UID,
+ TEST_CREATOR_NAME));
+
+ // Ensure that configured network list is empty now.
+ assertTrue(mWifiConfigManager.getConfiguredNetworks().isEmpty());
+ verify(mWcmListener).onNetworkRemoved(wifiConfigCaptor.capture());
+ assertEquals(retrievedNetwork.networkId, wifiConfigCaptor.getValue().networkId);
+ }
}
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiConfigurationTestUtil.java b/tests/wifitests/src/com/android/server/wifi/WifiConfigurationTestUtil.java
index 9e2783e1b..ba5f0056a 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiConfigurationTestUtil.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiConfigurationTestUtil.java
@@ -248,8 +248,11 @@ public class WifiConfigurationTestUtil {
}
public static WifiConfiguration createOweNetwork(String ssid) {
- return generateWifiConfig(TEST_NETWORK_ID, TEST_UID, ssid, true, true, null,
- null, SECURITY_OWE);
+ WifiConfiguration configuration = generateWifiConfig(TEST_NETWORK_ID, TEST_UID, ssid,
+ true, true, null, null, SECURITY_OWE);
+
+ configuration.requirePMF = true;
+ return configuration;
}
public static WifiConfiguration createOpenNetwork() {
@@ -274,14 +277,7 @@ public class WifiConfigurationTestUtil {
}
public static WifiConfiguration createSaeNetwork() {
- WifiConfiguration configuration =
- generateWifiConfig(TEST_NETWORK_ID, TEST_UID, createNewSSID(), true, true, null,
- null, SECURITY_SAE);
-
- // SAE password uses the same member.
- configuration.preSharedKey = TEST_PSK;
- configuration.requirePMF = true;
- return configuration;
+ return createSaeNetwork(createNewSSID());
}
public static WifiConfiguration createPskNetwork() {
@@ -304,6 +300,10 @@ public class WifiConfigurationTestUtil {
WifiConfiguration configuration =
generateWifiConfig(TEST_NETWORK_ID, TEST_UID, ssid, true, true, null,
null, SECURITY_SAE);
+
+ // SAE password uses the same member.
+ configuration.preSharedKey = TEST_PSK;
+ configuration.requirePMF = true;
return configuration;
}
@@ -514,6 +514,15 @@ public class WifiConfigurationTestUtil {
}
/**
+ * Gets scan result capabilities for a WPA2/WPA3-Transition mode network configuration
+ */
+ private static String
+ getScanResultCapsForOweTransitionNetwork(WifiConfiguration configuration) {
+ String caps = "[OWE_TRANSITION-CCMP]";
+ return caps;
+ }
+
+ /**
* Creates a scan detail corresponding to the provided network and given BSSID, etc.
*/
public static ScanDetail createScanDetailForNetwork(
@@ -536,6 +545,17 @@ public class WifiConfigurationTestUtil {
return new ScanDetail(ssid, bssid, caps, level, frequency, tsf, seen);
}
+ /**
+ * Creates a scan detail corresponding to the provided network and given BSSID, but sets
+ * the capabilities to OWE-Transition mode network.
+ */
+ public static ScanDetail createScanDetailForOweTransitionModeNetwork(
+ WifiConfiguration configuration, String bssid, int level, int frequency,
+ long tsf, long seen) {
+ String caps = getScanResultCapsForOweTransitionNetwork(configuration);
+ WifiSsid ssid = WifiSsid.createFromAsciiEncoded(configuration.getPrintableSsid());
+ return new ScanDetail(ssid, bssid, caps, level, frequency, tsf, seen);
+ }
/**
* Asserts that the 2 WifiConfigurations are equal in the elements saved for both backup/restore
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiNetworkFactoryTest.java b/tests/wifitests/src/com/android/server/wifi/WifiNetworkFactoryTest.java
index f312756dd..f7cd39c43 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiNetworkFactoryTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiNetworkFactoryTest.java
@@ -749,49 +749,6 @@ public class WifiNetworkFactoryTest extends WifiBaseTest {
}
/**
- * Verify network specifier matching for a specifier containing a specific SSID match using
- * 4 WPA_PSK + SAE transition scan results, each with unique SSID.
- */
- @Test
- public void testNetworkSpecifierMatchSuccessUsingLiteralSsidMatchForSaeTransitionScanResult()
- throws Exception {
- setupScanData(SCAN_RESULT_TYPE_WPA_PSK_SAE_TRANSITION,
- TEST_SSID_1, TEST_SSID_2, TEST_SSID_3, TEST_SSID_4);
-
- // Setup network specifier for open networks.
- PatternMatcher ssidPatternMatch =
- new PatternMatcher(TEST_SSID_1, PatternMatcher.PATTERN_LITERAL);
- Pair<MacAddress, MacAddress> bssidPatternMatch =
- Pair.create(MacAddress.ALL_ZEROS_ADDRESS, MacAddress.ALL_ZEROS_ADDRESS);
- WifiConfiguration wifiConfiguration = new WifiConfiguration();
- wifiConfiguration.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.WPA_PSK);
- WifiNetworkSpecifier specifier = new WifiNetworkSpecifier(
- ssidPatternMatch, bssidPatternMatch, wifiConfiguration, TEST_UID_1,
- TEST_PACKAGE_NAME_1);
-
- mNetworkRequest.networkCapabilities.setNetworkSpecifier(specifier);
- mWifiNetworkFactory.needNetworkFor(mNetworkRequest, 0);
-
- validateUiStartParams(true);
-
- mWifiNetworkFactory.addCallback(mAppBinder, mNetworkRequestMatchCallback,
- TEST_CALLBACK_IDENTIFIER);
-
- verifyPeriodicScans(0, PERIODIC_SCAN_INTERVAL_MS);
-
- ArgumentCaptor<List<ScanResult>> matchedScanResultsCaptor =
- ArgumentCaptor.forClass(List.class);
- verify(mNetworkRequestMatchCallback).onMatch(matchedScanResultsCaptor.capture());
-
- assertNotNull(matchedScanResultsCaptor.getValue());
- // We only expect 1 network match in this case.
- validateScanResults(matchedScanResultsCaptor.getValue(), mTestScanDatas[0].getResults()[0]);
-
- verify(mWifiMetrics).incrementNetworkRequestApiMatchSizeHistogram(
- matchedScanResultsCaptor.getValue().size());
- }
-
- /**
* Verify network specifier matching for a specifier containing a Prefix SSID match using
* 4 open scan results, each with unique SSID.
*/
@@ -2766,7 +2723,6 @@ public class WifiNetworkFactoryTest extends WifiBaseTest {
private static final int SCAN_RESULT_TYPE_OPEN = 0;
private static final int SCAN_RESULT_TYPE_WPA_PSK = 1;
private static final int SCAN_RESULT_TYPE_WPA_EAP = 2;
- private static final int SCAN_RESULT_TYPE_WPA_PSK_SAE_TRANSITION = 3;
private String getScanResultCapsForType(int scanResultType) {
switch (scanResultType) {
@@ -2779,8 +2735,6 @@ public class WifiNetworkFactoryTest extends WifiBaseTest {
case SCAN_RESULT_TYPE_WPA_EAP:
return WifiConfigurationTestUtil.getScanResultCapsForNetwork(
WifiConfigurationTestUtil.createEapNetwork());
- case SCAN_RESULT_TYPE_WPA_PSK_SAE_TRANSITION:
- return WifiConfigurationTestUtil.getScanResultCapsForWpa2Wpa3TransitionNetwork();
}
fail("Invalid scan result type " + scanResultType);
return "";