summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorHai Shalom <haishalom@google.com>2018-11-07 18:28:13 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2018-11-07 18:28:13 +0000
commitdbc1ea2b53dac4c92e3d08110c17ac996bf61177 (patch)
tree7732053033071f1b460dfb59795761249cdbddcc /tests
parent60f3e78cefae1f0d59de16e2744840571598350b (diff)
parent7fa44346403d217fef581631f299758abe1e99d6 (diff)
Merge changes from topic "SAE-OWE support"
* changes: [WPA3] WiFi tests: Add unit tests for WPA3, SuiteB and OWE opt/net/wifi: Add support for WPA3 and OWE
Diffstat (limited to 'tests')
-rw-r--r--tests/wifitests/src/com/android/server/wifi/NetworkListStoreDataTest.java6
-rw-r--r--tests/wifitests/src/com/android/server/wifi/SupplicantStaIfaceHalTest.java19
-rw-r--r--tests/wifitests/src/com/android/server/wifi/SupplicantStaNetworkHalTest.java195
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiBackupRestoreTest.java19
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java39
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiConfigStoreTest.java2
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiConfigurationTestUtil.java60
-rw-r--r--tests/wifitests/src/com/android/server/wifi/util/InformationElementUtilTest.java9
8 files changed, 319 insertions, 30 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/NetworkListStoreDataTest.java b/tests/wifitests/src/com/android/server/wifi/NetworkListStoreDataTest.java
index 5fa15e81b..868e3aef6 100644
--- a/tests/wifitests/src/com/android/server/wifi/NetworkListStoreDataTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/NetworkListStoreDataTest.java
@@ -76,6 +76,8 @@ public class NetworkListStoreDataTest {
+ "<byte-array name=\"AllowedAuthAlgos\" num=\"0\"></byte-array>\n"
+ "<byte-array name=\"AllowedGroupCiphers\" num=\"0\"></byte-array>\n"
+ "<byte-array name=\"AllowedPairwiseCiphers\" num=\"0\"></byte-array>\n"
+ + "<byte-array name=\"AllowedGroupMgmtCiphers\" num=\"0\"></byte-array>\n"
+ + "<byte-array name=\"AllowedSuiteBCiphers\" num=\"0\"></byte-array>\n"
+ "<boolean name=\"Shared\" value=\"%s\" />\n"
+ "<int name=\"Status\" value=\"2\" />\n"
+ "<null name=\"FQDN\" />\n"
@@ -128,6 +130,8 @@ public class NetworkListStoreDataTest {
+ "<byte-array name=\"AllowedAuthAlgos\" num=\"0\"></byte-array>\n"
+ "<byte-array name=\"AllowedGroupCiphers\" num=\"0\"></byte-array>\n"
+ "<byte-array name=\"AllowedPairwiseCiphers\" num=\"0\"></byte-array>\n"
+ + "<byte-array name=\"AllowedGroupMgmtCiphers\" num=\"0\"></byte-array>\n"
+ + "<byte-array name=\"AllowedSuiteBCiphers\" num=\"0\"></byte-array>\n"
+ "<boolean name=\"Shared\" value=\"%s\" />\n"
+ "<int name=\"Status\" value=\"2\" />\n"
+ "<null name=\"FQDN\" />\n"
@@ -365,6 +369,8 @@ public class NetworkListStoreDataTest {
+ "<byte-array name=\"AllowedAuthAlgos\" num=\"0\"></byte-array>\n"
+ "<byte-array name=\"AllowedGroupCiphers\" num=\"0\"></byte-array>\n"
+ "<byte-array name=\"AllowedPairwiseCiphers\" num=\"0\"></byte-array>\n"
+ + "<byte-array name=\"AllowedGroupMgmtCiphers\" num=\"0\"></byte-array>\n"
+ + "<byte-array name=\"AllowedSuiteBCiphers\" num=\"0\"></byte-array>\n"
+ "<boolean name=\"Shared\" value=\"%s\" />\n"
+ "<null name=\"FQDN\" />\n"
+ "<null name=\"ProviderFriendlyName\" />\n"
diff --git a/tests/wifitests/src/com/android/server/wifi/SupplicantStaIfaceHalTest.java b/tests/wifitests/src/com/android/server/wifi/SupplicantStaIfaceHalTest.java
index 182b32626..c2bf0dcfa 100644
--- a/tests/wifitests/src/com/android/server/wifi/SupplicantStaIfaceHalTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/SupplicantStaIfaceHalTest.java
@@ -15,7 +15,11 @@
*/
package com.android.server.wifi;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyBoolean;
import static org.mockito.Matchers.anyInt;
@@ -23,7 +27,16 @@ import static org.mockito.Matchers.anyLong;
import static org.mockito.Matchers.anyShort;
import static org.mockito.Matchers.anyString;
import static org.mockito.Matchers.eq;
-import static org.mockito.Mockito.*;
+import static org.mockito.Mockito.doAnswer;
+import static org.mockito.Mockito.doThrow;
+import static org.mockito.Mockito.inOrder;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.reset;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.verifyNoMoreInteractions;
+import static org.mockito.Mockito.when;
import android.annotation.NonNull;
import android.app.test.MockAnswerUtil;
@@ -33,11 +46,11 @@ import android.hardware.wifi.supplicant.V1_0.ISupplicantIface;
import android.hardware.wifi.supplicant.V1_0.ISupplicantStaIface;
import android.hardware.wifi.supplicant.V1_0.ISupplicantStaIfaceCallback;
import android.hardware.wifi.supplicant.V1_0.ISupplicantStaIfaceCallback.BssidChangeReason;
-import android.hardware.wifi.supplicant.V1_0.ISupplicantStaNetwork;
import android.hardware.wifi.supplicant.V1_0.IfaceType;
import android.hardware.wifi.supplicant.V1_0.SupplicantStatus;
import android.hardware.wifi.supplicant.V1_0.SupplicantStatusCode;
import android.hardware.wifi.supplicant.V1_0.WpsConfigMethods;
+import android.hardware.wifi.supplicant.V1_2.ISupplicantStaNetwork;
import android.hidl.manager.V1_0.IServiceManager;
import android.hidl.manager.V1_0.IServiceNotification;
import android.net.IpConfiguration;
diff --git a/tests/wifitests/src/com/android/server/wifi/SupplicantStaNetworkHalTest.java b/tests/wifitests/src/com/android/server/wifi/SupplicantStaNetworkHalTest.java
index a52cca87f..a4d799fcc 100644
--- a/tests/wifitests/src/com/android/server/wifi/SupplicantStaNetworkHalTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/SupplicantStaNetworkHalTest.java
@@ -15,7 +15,12 @@
*/
package com.android.server.wifi;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.ArgumentMatchers.anyBoolean;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.any;
import static org.mockito.Mockito.anyString;
@@ -27,7 +32,6 @@ import static org.mockito.Mockito.when;
import android.app.test.MockAnswerUtil.AnswerWithArguments;
import android.content.Context;
import android.hardware.wifi.supplicant.V1_0.ISupplicantNetwork;
-import android.hardware.wifi.supplicant.V1_0.ISupplicantStaNetwork;
import android.hardware.wifi.supplicant.V1_0.ISupplicantStaNetworkCallback;
import android.hardware.wifi.supplicant.V1_0.ISupplicantStaNetworkCallback
.NetworkRequestEapSimGsmAuthParams;
@@ -35,6 +39,7 @@ import android.hardware.wifi.supplicant.V1_0.ISupplicantStaNetworkCallback
.NetworkRequestEapSimUmtsAuthParams;
import android.hardware.wifi.supplicant.V1_0.SupplicantStatus;
import android.hardware.wifi.supplicant.V1_0.SupplicantStatusCode;
+import android.hardware.wifi.supplicant.V1_2.ISupplicantStaNetwork;
import android.net.wifi.WifiConfiguration;
import android.net.wifi.WifiEnterpriseConfig;
import android.os.RemoteException;
@@ -74,7 +79,7 @@ public class SupplicantStaNetworkHalTest {
private SupplicantStatus mStatusFailure;
@Mock private ISupplicantStaNetwork mISupplicantStaNetworkMock;
@Mock
- private android.hardware.wifi.supplicant.V1_1.ISupplicantStaNetwork mISupplicantStaNetworkV11;
+ private android.hardware.wifi.supplicant.V1_2.ISupplicantStaNetwork mISupplicantStaNetworkV12;
@Mock private Context mContext;
@Mock private WifiMonitor mWifiMonitor;
@@ -83,19 +88,20 @@ public class SupplicantStaNetworkHalTest {
private ISupplicantStaNetworkCallback mISupplicantStaNetworkCallback;
/**
- * Spy used to return the V1_1 ISupplicantStaNetwork mock object to simulate the 1.1 HAL running
+ * Spy used to return the V1_2 ISupplicantStaNetwork mock object to simulate the 1.2 HAL running
* on the device.
*/
- private class SupplicantStaNetworkHalSpyV1_1 extends SupplicantStaNetworkHal {
- SupplicantStaNetworkHalSpyV1_1(ISupplicantStaNetwork iSupplicantStaNetwork,
+ private class SupplicantStaNetworkHalSpyV1_2 extends SupplicantStaNetworkHal {
+ SupplicantStaNetworkHalSpyV1_2(ISupplicantStaNetwork iSupplicantStaNetwork,
String ifaceName,
Context context, WifiMonitor monitor) {
super(iSupplicantStaNetwork, ifaceName, context, monitor);
}
+
@Override
- protected android.hardware.wifi.supplicant.V1_1.ISupplicantStaNetwork
- getSupplicantStaNetworkForV1_1Mockable() {
- return mISupplicantStaNetworkV11;
+ protected android.hardware.wifi.supplicant.V1_2.ISupplicantStaNetwork
+ getSupplicantStaNetworkForV1_2Mockable() {
+ return mISupplicantStaNetworkV12;
}
}
@@ -116,6 +122,20 @@ public class SupplicantStaNetworkHalTest {
* Tests the saving of WifiConfiguration to wpa_supplicant.
*/
@Test
+ public void testOweNetworkWifiConfigurationSaveLoad() throws Exception {
+ // Now expose the V1.2 ISupplicantStaNetwork
+ mSupplicantNetwork = new SupplicantStaNetworkHalSpyV1_2(mISupplicantStaNetworkMock,
+ IFACE_NAME, mContext, mWifiMonitor);
+
+ WifiConfiguration config = WifiConfigurationTestUtil.createOweNetwork();
+ config.updateIdentifier = "46";
+ testWifiConfigurationSaveLoad(config);
+ }
+
+ /**
+ * Tests the saving of WifiConfiguration to wpa_supplicant.
+ */
+ @Test
public void testOpenNetworkWifiConfigurationSaveLoad() throws Exception {
WifiConfiguration config = WifiConfigurationTestUtil.createOpenHiddenNetwork();
config.updateIdentifier = "45";
@@ -123,6 +143,27 @@ public class SupplicantStaNetworkHalTest {
}
/**
+ * Tests the saving/loading of WifiConfiguration to wpa_supplicant with SAE password.
+ */
+ @Test
+ public void testSaePasswordNetworkWifiConfigurationSaveLoad() throws Exception {
+ // Now expose the V1.2 ISupplicantStaNetwork
+ mSupplicantNetwork = new SupplicantStaNetworkHalSpyV1_2(mISupplicantStaNetworkMock,
+ IFACE_NAME, mContext, mWifiMonitor);
+
+ WifiConfiguration config = WifiConfigurationTestUtil.createSaeNetwork();
+ testWifiConfigurationSaveLoad(config);
+ verify(mISupplicantStaNetworkV12).setSaePassword(any(String.class));
+ verify(mISupplicantStaNetworkV12, never())
+ .getSaePassword(any(ISupplicantStaNetwork.getSaePasswordCallback.class));
+ verify(mISupplicantStaNetworkV12, never())
+ .getPskPassphrase(any(ISupplicantStaNetwork.getPskPassphraseCallback.class));
+ verify(mISupplicantStaNetworkV12, never()).setPsk(any(byte[].class));
+ verify(mISupplicantStaNetworkV12, never())
+ .getPsk(any(ISupplicantStaNetwork.getPskCallback.class));
+ }
+
+ /**
* Tests the saving/loading of WifiConfiguration to wpa_supplicant with psk passphrase.
*/
@Test
@@ -223,6 +264,59 @@ public class SupplicantStaNetworkHalTest {
}
/**
+ * Tests the saving/loading of WifiConfiguration to wpa_supplicant with Suite-B-192
+ */
+ @Test
+ public void testEapSuiteBRsaNetworkWifiConfigurationSaveLoad() throws Exception {
+ // Now expose the V1.2 ISupplicantStaNetwork
+ mSupplicantNetwork = new SupplicantStaNetworkHalSpyV1_2(mISupplicantStaNetworkMock,
+ IFACE_NAME, mContext, mWifiMonitor);
+
+ WifiConfiguration config = WifiConfigurationTestUtil.createEapSuiteBNetwork();
+ config.allowedSuiteBCiphers.set(WifiConfiguration.SuiteBCipher.ECDHE_RSA);
+
+ testWifiConfigurationSaveLoad(config);
+ verify(mISupplicantStaNetworkV12, never()).enableSuiteBEapOpenSslCiphers();
+ verify(mISupplicantStaNetworkV12).enableTlsSuiteBEapPhase1Param(anyBoolean());
+
+ verify(mISupplicantStaNetworkV12, never()).setSaePassword(any(String.class));
+ verify(mISupplicantStaNetworkV12, never())
+ .getSaePassword(any(ISupplicantStaNetwork.getSaePasswordCallback.class));
+ verify(mISupplicantStaNetworkV12, never())
+ .getPskPassphrase(any(ISupplicantStaNetwork.getPskPassphraseCallback.class));
+ verify(mISupplicantStaNetworkV12, never()).setPsk(any(byte[].class));
+ verify(mISupplicantStaNetworkV12, never())
+ .getPsk(any(ISupplicantStaNetwork.getPskCallback.class));
+ }
+
+ /**
+ * Tests the saving/loading of WifiConfiguration to wpa_supplicant with Suite-B-192
+ */
+ @Test
+ public void testEapSuiteBEcdsaNetworkWifiConfigurationSaveLoad() throws Exception {
+ // Now expose the V1.2 ISupplicantStaNetwork
+ mSupplicantNetwork = new SupplicantStaNetworkHalSpyV1_2(mISupplicantStaNetworkMock,
+ IFACE_NAME, mContext, mWifiMonitor);
+
+ WifiConfiguration config = WifiConfigurationTestUtil.createEapSuiteBNetwork();
+ config.allowedSuiteBCiphers.set(WifiConfiguration.SuiteBCipher.ECDHE_ECDSA);
+
+ testWifiConfigurationSaveLoad(config);
+ verify(mISupplicantStaNetworkV12).enableSuiteBEapOpenSslCiphers();
+ verify(mISupplicantStaNetworkV12, never())
+ .enableTlsSuiteBEapPhase1Param(any(boolean.class));
+
+ verify(mISupplicantStaNetworkV12, never()).setSaePassword(any(String.class));
+ verify(mISupplicantStaNetworkV12, never())
+ .getSaePassword(any(ISupplicantStaNetwork.getSaePasswordCallback.class));
+ verify(mISupplicantStaNetworkV12, never())
+ .getPskPassphrase(any(ISupplicantStaNetwork.getPskPassphraseCallback.class));
+ verify(mISupplicantStaNetworkV12, never()).setPsk(any(byte[].class));
+ verify(mISupplicantStaNetworkV12, never())
+ .getPsk(any(ISupplicantStaNetwork.getPskCallback.class));
+ }
+
+ /**
* Tests the loading of network ID.
*/
@Test
@@ -281,7 +375,7 @@ public class SupplicantStaNetworkHalTest {
@Test
public void testInvalidKeyMgmtSaveFailure() throws Exception {
WifiConfiguration config = WifiConfigurationTestUtil.createWepHiddenNetwork();
- config.allowedKeyManagement.set(10);
+ config.allowedKeyManagement.set(20);
try {
assertFalse(mSupplicantNetwork.saveWifiConfiguration(config));
} catch (IllegalArgumentException e) {
@@ -631,11 +725,11 @@ public class SupplicantStaNetworkHalTest {
assertTrue(mSupplicantNetwork.sendNetworkEapIdentityResponse(identityStr,
encryptedIdentityStr));
- verify(mISupplicantStaNetworkV11, never()).sendNetworkEapIdentityResponse_1_1(
+ verify(mISupplicantStaNetworkV12, never()).sendNetworkEapIdentityResponse_1_1(
any(ArrayList.class), any(ArrayList.class));
- // Now expose the V1.1 ISupplicantStaNetwork
- mSupplicantNetwork = new SupplicantStaNetworkHalSpyV1_1(mISupplicantStaNetworkMock,
+ // Now expose the V1.2 ISupplicantStaNetwork
+ mSupplicantNetwork = new SupplicantStaNetworkHalSpyV1_2(mISupplicantStaNetworkMock,
IFACE_NAME, mContext, mWifiMonitor);
doAnswer(new AnswerWithArguments() {
public SupplicantStatus answer(ArrayList<Byte> identity,
@@ -646,7 +740,7 @@ public class SupplicantStaNetworkHalTest {
NativeUtil.stringFromByteArrayList(encryptedIdentity));
return mStatusSuccess;
}
- }).when(mISupplicantStaNetworkV11).sendNetworkEapIdentityResponse_1_1(any(ArrayList.class),
+ }).when(mISupplicantStaNetworkV12).sendNetworkEapIdentityResponse_1_1(any(ArrayList.class),
any(ArrayList.class));
assertTrue(mSupplicantNetwork.sendNetworkEapIdentityResponse(identityStr,
encryptedIdentityStr));
@@ -921,6 +1015,21 @@ public class SupplicantStaNetworkHalTest {
}).when(mISupplicantStaNetworkMock)
.getRequirePmf(any(ISupplicantStaNetwork.getRequirePmfCallback.class));
+ /** SAE password */
+ doAnswer(new AnswerWithArguments() {
+ public SupplicantStatus answer(String saePassword) throws RemoteException {
+ mSupplicantVariables.pskPassphrase = saePassword;
+ return mStatusSuccess;
+ }
+ }).when(mISupplicantStaNetworkV12).setSaePassword(any(String.class));
+ doAnswer(new AnswerWithArguments() {
+ public void answer(ISupplicantStaNetwork.getPskPassphraseCallback cb)
+ throws RemoteException {
+ cb.onValues(mStatusSuccess, mSupplicantVariables.pskPassphrase);
+ }
+ }).when(mISupplicantStaNetworkV12)
+ .getSaePassword(any(ISupplicantStaNetwork.getSaePasswordCallback.class));
+
/** PSK passphrase */
doAnswer(new AnswerWithArguments() {
public SupplicantStatus answer(String pskPassphrase) throws RemoteException {
@@ -994,6 +1103,20 @@ public class SupplicantStaNetworkHalTest {
}).when(mISupplicantStaNetworkMock)
.getKeyMgmt(any(ISupplicantStaNetwork.getKeyMgmtCallback.class));
+ /** allowedKeyManagement v1.2 */
+ doAnswer(new AnswerWithArguments() {
+ public SupplicantStatus answer(int mask) throws RemoteException {
+ mSupplicantVariables.keyMgmtMask = mask;
+ return mStatusSuccess;
+ }
+ }).when(mISupplicantStaNetworkV12).setKeyMgmt_1_2(any(int.class));
+ doAnswer(new AnswerWithArguments() {
+ public void answer(ISupplicantStaNetwork.getKeyMgmtCallback cb) throws RemoteException {
+ cb.onValues(mStatusSuccess, mSupplicantVariables.keyMgmtMask);
+ }
+ }).when(mISupplicantStaNetworkV12)
+ .getKeyMgmt_1_2(any(ISupplicantStaNetwork.getKeyMgmt_1_2Callback.class));
+
/** allowedProtocols */
doAnswer(new AnswerWithArguments() {
public SupplicantStatus answer(int mask) throws RemoteException {
@@ -1037,6 +1160,21 @@ public class SupplicantStaNetworkHalTest {
}).when(mISupplicantStaNetworkMock)
.getGroupCipher(any(ISupplicantStaNetwork.getGroupCipherCallback.class));
+ /** allowedGroupCiphers v1.2*/
+ doAnswer(new AnswerWithArguments() {
+ public SupplicantStatus answer(int mask) throws RemoteException {
+ mSupplicantVariables.groupCipherMask = mask;
+ return mStatusSuccess;
+ }
+ }).when(mISupplicantStaNetworkV12).setGroupCipher_1_2(any(int.class));
+ doAnswer(new AnswerWithArguments() {
+ public void answer(ISupplicantStaNetwork.getGroupCipherCallback cb)
+ throws RemoteException {
+ cb.onValues(mStatusSuccess, mSupplicantVariables.groupCipherMask);
+ }
+ }).when(mISupplicantStaNetworkV12)
+ .getGroupCipher_1_2(any(ISupplicantStaNetwork.getGroupCipher_1_2Callback.class));
+
/** allowedPairwiseCiphers */
doAnswer(new AnswerWithArguments() {
public SupplicantStatus answer(int mask) throws RemoteException {
@@ -1052,6 +1190,22 @@ public class SupplicantStaNetworkHalTest {
}).when(mISupplicantStaNetworkMock)
.getPairwiseCipher(any(ISupplicantStaNetwork.getPairwiseCipherCallback.class));
+ /** allowedPairwiseCiphers v1.2 */
+ doAnswer(new AnswerWithArguments() {
+ public SupplicantStatus answer(int mask) throws RemoteException {
+ mSupplicantVariables.pairwiseCipherMask = mask;
+ return mStatusSuccess;
+ }
+ }).when(mISupplicantStaNetworkV12).setPairwiseCipher_1_2(any(int.class));
+ doAnswer(new AnswerWithArguments() {
+ public void answer(ISupplicantStaNetwork.getPairwiseCipherCallback cb)
+ throws RemoteException {
+ cb.onValues(mStatusSuccess, mSupplicantVariables.pairwiseCipherMask);
+ }
+ }).when(mISupplicantStaNetworkV12)
+ .getPairwiseCipher_1_2(any(ISupplicantStaNetwork
+ .getPairwiseCipher_1_2Callback.class));
+
/** metadata: idstr */
doAnswer(new AnswerWithArguments() {
public SupplicantStatus answer(String idStr) throws RemoteException {
@@ -1314,6 +1468,19 @@ public class SupplicantStaNetworkHalTest {
}
}).when(mISupplicantStaNetworkMock)
.registerCallback(any(ISupplicantStaNetworkCallback.class));
+
+ /** Suite-B*/
+ doAnswer(new AnswerWithArguments() {
+ public SupplicantStatus answer(boolean enable) throws RemoteException {
+ return mStatusSuccess;
+ }
+ }).when(mISupplicantStaNetworkV12).enableTlsSuiteBEapPhase1Param(any(boolean.class));
+
+ doAnswer(new AnswerWithArguments() {
+ public SupplicantStatus answer() throws RemoteException {
+ return mStatusSuccess;
+ }
+ }).when(mISupplicantStaNetworkV12).enableSuiteBEapOpenSslCiphers();
}
private SupplicantStatus createSupplicantStatus(int code) {
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiBackupRestoreTest.java b/tests/wifitests/src/com/android/server/wifi/WifiBackupRestoreTest.java
index 53d014b2e..1c238f9de 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiBackupRestoreTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiBackupRestoreTest.java
@@ -85,6 +85,7 @@ public class WifiBackupRestoreTest {
// |AllowedKeyMgmt|, |AllowedProtocols|, |AllowedAuthAlgorithms|, |AllowedGroupCiphers| and
// |AllowedPairwiseCiphers| fields have invalid values in them.
+ // NOTE: The byte values are encoded in little endian
private static final String WIFI_BACKUP_DATA_WITH_UNSUPPORTED_VALUES_IN_BITSETS =
"<?xml version='1.0' encoding='utf-8' standalone='yes' ?>"
+ "<WifiBackupData>"
@@ -101,15 +102,15 @@ public class WifiBackupRestoreTest {
+ "<boolean name=\"HiddenSSID\" value=\"false\" />"
+ "<boolean name=\"RequirePMF\" value=\"false\" />"
// Valid Value: 01
- + "<byte-array name=\"AllowedKeyMgmt\" num=\"2\">0101</byte-array>"
+ + "<byte-array name=\"AllowedKeyMgmt\" num=\"2\">0180</byte-array>"
// Valid Value: 03
+ "<byte-array name=\"AllowedProtocols\" num=\"1\">0b</byte-array>"
// Valid Value: 01
+ "<byte-array name=\"AllowedAuthAlgos\" num=\"1\">09</byte-array>"
// Valid Value: 0f
- + "<byte-array name=\"AllowedGroupCiphers\" num=\"1\">2f</byte-array>"
+ + "<byte-array name=\"AllowedGroupCiphers\" num=\"1\">4f</byte-array>"
// Valid Value: 06
- + "<byte-array name=\"AllowedPairwiseCiphers\" num=\"1\">0e</byte-array>"
+ + "<byte-array name=\"AllowedPairwiseCiphers\" num=\"1\">26</byte-array>"
+ "<boolean name=\"Shared\" value=\"true\" />"
+ "<null name=\"SimSlot\" />"
+ "</WifiConfiguration>"
@@ -432,6 +433,7 @@ public class WifiBackupRestoreTest {
public void testSingleEnterpriseNetworkNotBackupRestore() {
List<WifiConfiguration> configurations = new ArrayList<>();
configurations.add(WifiConfigurationTestUtil.createEapNetwork());
+ configurations.add(WifiConfigurationTestUtil.createEapSuiteBNetwork());
byte[] backupData = mWifiBackupRestore.retrieveBackupDataFromConfigurations(configurations);
List<WifiConfiguration> retrievedConfigurations =
@@ -527,6 +529,8 @@ public class WifiBackupRestoreTest {
configurations.add(WifiConfigurationTestUtil.createWepNetwork());
configurations.add(WifiConfigurationTestUtil.createPskNetwork());
configurations.add(WifiConfigurationTestUtil.createOpenNetwork());
+ configurations.add(WifiConfigurationTestUtil.createOweNetwork());
+ configurations.add(WifiConfigurationTestUtil.createSaeNetwork());
byte[] backupData = mWifiBackupRestore.retrieveBackupDataFromConfigurations(configurations);
List<WifiConfiguration> retrievedConfigurations =
@@ -549,6 +553,7 @@ public class WifiBackupRestoreTest {
expectedConfigurations.add(wepNetwork);
configurations.add(WifiConfigurationTestUtil.createEapNetwork());
+ configurations.add(WifiConfigurationTestUtil.createEapSuiteBNetwork());
WifiConfiguration pskNetwork = WifiConfigurationTestUtil.createPskNetwork();
configurations.add(pskNetwork);
@@ -558,6 +563,14 @@ public class WifiBackupRestoreTest {
configurations.add(openNetwork);
expectedConfigurations.add(openNetwork);
+ WifiConfiguration saeNetwork = WifiConfigurationTestUtil.createSaeNetwork();
+ configurations.add(saeNetwork);
+ expectedConfigurations.add(saeNetwork);
+
+ WifiConfiguration oweNetwork = WifiConfigurationTestUtil.createOweNetwork();
+ configurations.add(oweNetwork);
+ expectedConfigurations.add(oweNetwork);
+
byte[] backupData = mWifiBackupRestore.retrieveBackupDataFromConfigurations(configurations);
List<WifiConfiguration> retrievedConfigurations =
mWifiBackupRestore.retrieveConfigurationsFromBackupData(backupData);
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java b/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java
index 79024c937..5198abf05 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java
@@ -1130,6 +1130,12 @@ public class WifiConfigManagerTest {
WifiConfigurationTestUtil.createPskNetwork());
verifyAddSingleNetworkAndMatchScanDetailToNetworkAndCache(
WifiConfigurationTestUtil.createEapNetwork());
+ verifyAddSingleNetworkAndMatchScanDetailToNetworkAndCache(
+ WifiConfigurationTestUtil.createSaeNetwork());
+ verifyAddSingleNetworkAndMatchScanDetailToNetworkAndCache(
+ WifiConfigurationTestUtil.createOweNetwork());
+ verifyAddSingleNetworkAndMatchScanDetailToNetworkAndCache(
+ WifiConfigurationTestUtil.createEapSuiteBNetwork());
}
/**
@@ -1144,18 +1150,27 @@ public class WifiConfigManagerTest {
WifiConfiguration wepNetwork = WifiConfigurationTestUtil.createWepNetwork();
WifiConfiguration pskNetwork = WifiConfigurationTestUtil.createPskNetwork();
WifiConfiguration eapNetwork = WifiConfigurationTestUtil.createEapNetwork();
+ WifiConfiguration saeNetwork = WifiConfigurationTestUtil.createSaeNetwork();
+ WifiConfiguration oweNetwork = WifiConfigurationTestUtil.createOweNetwork();
+ WifiConfiguration eapSuiteBNetwork = WifiConfigurationTestUtil.createEapSuiteBNetwork();
// Now add them to WifiConfigManager.
verifyAddNetworkToWifiConfigManager(openNetwork);
verifyAddNetworkToWifiConfigManager(wepNetwork);
verifyAddNetworkToWifiConfigManager(pskNetwork);
verifyAddNetworkToWifiConfigManager(eapNetwork);
+ verifyAddNetworkToWifiConfigManager(saeNetwork);
+ verifyAddNetworkToWifiConfigManager(oweNetwork);
+ verifyAddNetworkToWifiConfigManager(eapSuiteBNetwork);
// Now create dummy scan detail corresponding to the networks.
ScanDetail openNetworkScanDetail = createScanDetailForNetwork(openNetwork);
ScanDetail wepNetworkScanDetail = createScanDetailForNetwork(wepNetwork);
ScanDetail pskNetworkScanDetail = createScanDetailForNetwork(pskNetwork);
ScanDetail eapNetworkScanDetail = createScanDetailForNetwork(eapNetwork);
+ ScanDetail saeNetworkScanDetail = createScanDetailForNetwork(saeNetwork);
+ ScanDetail oweNetworkScanDetail = createScanDetailForNetwork(oweNetwork);
+ ScanDetail eapSuiteBNetworkScanDetail = createScanDetailForNetwork(eapSuiteBNetwork);
// Now mix and match parameters from different scan details.
openNetworkScanDetail.getScanResult().SSID =
@@ -1165,8 +1180,15 @@ public class WifiConfigManagerTest {
pskNetworkScanDetail.getScanResult().capabilities =
eapNetworkScanDetail.getScanResult().capabilities;
eapNetworkScanDetail.getScanResult().capabilities =
+ saeNetworkScanDetail.getScanResult().capabilities;
+ saeNetworkScanDetail.getScanResult().capabilities =
+ oweNetworkScanDetail.getScanResult().capabilities;
+ oweNetworkScanDetail.getScanResult().capabilities =
+ eapSuiteBNetworkScanDetail.getScanResult().capabilities;
+ eapSuiteBNetworkScanDetail.getScanResult().capabilities =
openNetworkScanDetail.getScanResult().capabilities;
+
// Try to lookup a saved network using the modified scan details. All of these should fail.
assertNull(mWifiConfigManager.getConfiguredNetworkForScanDetailAndCache(
openNetworkScanDetail));
@@ -1176,12 +1198,21 @@ public class WifiConfigManagerTest {
pskNetworkScanDetail));
assertNull(mWifiConfigManager.getConfiguredNetworkForScanDetailAndCache(
eapNetworkScanDetail));
+ assertNull(mWifiConfigManager.getConfiguredNetworkForScanDetailAndCache(
+ saeNetworkScanDetail));
+ assertNull(mWifiConfigManager.getConfiguredNetworkForScanDetailAndCache(
+ oweNetworkScanDetail));
+ assertNull(mWifiConfigManager.getConfiguredNetworkForScanDetailAndCache(
+ eapSuiteBNetworkScanDetail));
// All the cache's should be empty as well.
assertNull(mWifiConfigManager.getScanDetailCacheForNetwork(openNetwork.networkId));
assertNull(mWifiConfigManager.getScanDetailCacheForNetwork(wepNetwork.networkId));
assertNull(mWifiConfigManager.getScanDetailCacheForNetwork(pskNetwork.networkId));
assertNull(mWifiConfigManager.getScanDetailCacheForNetwork(eapNetwork.networkId));
+ assertNull(mWifiConfigManager.getScanDetailCacheForNetwork(saeNetwork.networkId));
+ assertNull(mWifiConfigManager.getScanDetailCacheForNetwork(oweNetwork.networkId));
+ assertNull(mWifiConfigManager.getScanDetailCacheForNetwork(eapSuiteBNetwork.networkId));
}
/**
@@ -1420,11 +1451,11 @@ public class WifiConfigManagerTest {
}
/**
- * Verifies that hasEverConnected is not cleared when a network config |requirePMF| is
+ * Verifies that hasEverConnected is cleared when a network config |requirePMF| is
* updated.
*/
@Test
- public void testUpdateRequirePMFDoesNotClearHasEverConnected() {
+ public void testUpdateRequirePMFClearsHasEverConnected() {
WifiConfiguration pskNetwork = WifiConfigurationTestUtil.createPskNetwork();
verifyAddNetworkHasEverConnectedFalse(pskNetwork);
verifyUpdateNetworkAfterConnectHasEverConnectedTrue(pskNetwork.networkId);
@@ -1436,9 +1467,9 @@ public class WifiConfigManagerTest {
verifyUpdateNetworkToWifiConfigManagerWithoutIpChange(pskNetwork);
WifiConfiguration retrievedNetwork =
mWifiConfigManager.getConfiguredNetwork(result.getNetworkId());
- assertTrue("Updating network non-credentials config should not clear hasEverConnected.",
+ assertFalse("Updating network credentials config must clear hasEverConnected.",
retrievedNetwork.getNetworkSelectionStatus().getHasEverConnected());
- assertFalse(result.hasCredentialChanged());
+ assertTrue(result.hasCredentialChanged());
}
/**
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiConfigStoreTest.java b/tests/wifitests/src/com/android/server/wifi/WifiConfigStoreTest.java
index 0240a67ab..508cc2630 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiConfigStoreTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiConfigStoreTest.java
@@ -81,6 +81,8 @@ public class WifiConfigStoreTest {
+ "<byte-array name=\"AllowedAuthAlgos\" num=\"0\"></byte-array>\n"
+ "<byte-array name=\"AllowedGroupCiphers\" num=\"0\"></byte-array>\n"
+ "<byte-array name=\"AllowedPairwiseCiphers\" num=\"0\"></byte-array>\n"
+ + "<byte-array name=\"AllowedGroupMgmtCiphers\" num=\"0\"></byte-array>\n"
+ + "<byte-array name=\"AllowedSuiteBCiphers\" num=\"0\"></byte-array>\n"
+ "<boolean name=\"Shared\" value=\"%s\" />\n"
+ "<int name=\"Status\" value=\"2\" />\n"
+ "<null name=\"FQDN\" />\n"
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiConfigurationTestUtil.java b/tests/wifitests/src/com/android/server/wifi/WifiConfigurationTestUtil.java
index 97d7e4f22..6755e5476 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiConfigurationTestUtil.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiConfigurationTestUtil.java
@@ -46,6 +46,9 @@ public class WifiConfigurationTestUtil {
public static final int SECURITY_WEP = 1 << 0;
public static final int SECURITY_PSK = 1 << 1;
public static final int SECURITY_EAP = 1 << 2;
+ public static final int SECURITY_SAE = 1 << 3;
+ public static final int SECURITY_OWE = 1 << 4;
+ public static final int SECURITY_EAP_SUITE_B = 1 << 5;
/**
* These values are used to describe ip configuration parameters for a network.
@@ -138,11 +141,27 @@ public class WifiConfigurationTestUtil {
config.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.WPA_PSK);
}
+ if ((security & SECURITY_SAE) != 0) {
+ config.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.SAE);
+ config.requirePMF = true;
+ }
+
+ if ((security & SECURITY_OWE) != 0) {
+ config.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.OWE);
+ config.requirePMF = true;
+ }
+
if ((security & SECURITY_EAP) != 0) {
config.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.WPA_EAP);
config.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.IEEE8021X);
config.enterpriseConfig.setEapMethod(WifiEnterpriseConfig.Eap.TTLS);
}
+
+ if ((security & SECURITY_EAP_SUITE_B) != 0) {
+ config.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.SUITE_B_192);
+ config.requirePMF = true;
+ }
+
}
return config;
}
@@ -224,6 +243,15 @@ public class WifiConfigurationTestUtil {
* Helper methods to generate predefined WifiConfiguration objects of the required type. These
* use a static index to avoid duplicate configurations.
*/
+ public static WifiConfiguration createOweNetwork() {
+ return createOweNetwork(createNewSSID());
+ }
+
+ public static WifiConfiguration createOweNetwork(String ssid) {
+ return generateWifiConfig(TEST_NETWORK_ID, TEST_UID, ssid, true, true, null,
+ null, SECURITY_OWE);
+ }
+
public static WifiConfiguration createOpenNetwork() {
return createOpenNetwork(createNewSSID());
}
@@ -245,6 +273,17 @@ public class WifiConfigurationTestUtil {
return configuration;
}
+ 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;
+ }
+
public static WifiConfiguration createPskNetwork() {
WifiConfiguration configuration =
generateWifiConfig(TEST_NETWORK_ID, TEST_UID, createNewSSID(), true, true, null,
@@ -317,6 +356,17 @@ public class WifiConfigurationTestUtil {
return configuration;
}
+ public static WifiConfiguration createEapSuiteBNetwork() {
+ WifiConfiguration configuration =
+ generateWifiConfig(TEST_NETWORK_ID, TEST_UID, createNewSSID(), true, true,
+ null, null, SECURITY_EAP_SUITE_B);
+
+ configuration.requirePMF = true;
+ configuration.enterpriseConfig.setEapMethod(WifiEnterpriseConfig.Eap.TLS);
+ configuration.enterpriseConfig.setPhase2Method(WifiEnterpriseConfig.Phase2.NONE);
+ return configuration;
+ }
+
public static WifiConfiguration createPasspointNetwork() {
WifiConfiguration configuration =
generateWifiConfig(TEST_NETWORK_ID, TEST_UID, createNewSSID(), true, true,
@@ -430,13 +480,19 @@ public class WifiConfigurationTestUtil {
public static String getScanResultCapsForNetwork(WifiConfiguration configuration) {
String caps;
if (configuration.allowedKeyManagement.get(WifiConfiguration.KeyMgmt.WPA_PSK)) {
- caps = "[WPA2-PSK-CCMP]";
+ caps = "[RSN-PSK-CCMP]";
} else if (configuration.allowedKeyManagement.get(WifiConfiguration.KeyMgmt.WPA_EAP)
|| configuration.allowedKeyManagement.get(WifiConfiguration.KeyMgmt.IEEE8021X)) {
- caps = "[WPA2-EAP-CCMP]";
+ caps = "[RSN-EAP-CCMP]";
} else if (configuration.allowedKeyManagement.get(WifiConfiguration.KeyMgmt.NONE)
&& WifiConfigurationUtil.hasAnyValidWepKey(configuration.wepKeys)) {
caps = "[WEP]";
+ } else if (configuration.allowedKeyManagement.get(WifiConfiguration.KeyMgmt.SAE)) {
+ caps = "[RSN-SAE-CCMP]";
+ } else if (configuration.allowedKeyManagement.get(WifiConfiguration.KeyMgmt.OWE)) {
+ caps = "[RSN-OWE-CCMP]";
+ } else if (configuration.allowedKeyManagement.get(WifiConfiguration.KeyMgmt.SUITE_B_192)) {
+ caps = "[RSN-SUITE-B-192-CCMP]";
} else {
caps = "[]";
}
diff --git a/tests/wifitests/src/com/android/server/wifi/util/InformationElementUtilTest.java b/tests/wifitests/src/com/android/server/wifi/util/InformationElementUtilTest.java
index a1b37ff7b..d921bf33d 100644
--- a/tests/wifitests/src/com/android/server/wifi/util/InformationElementUtilTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/util/InformationElementUtilTest.java
@@ -267,7 +267,7 @@ public class InformationElementUtilTest {
capabilities.from(ies, beaconCap);
String result = capabilities.generateCapabilitiesString();
- assertEquals("[WPA2-PSK-CCMP+TKIP]", result);
+ assertEquals("[RSN-PSK-CCMP+TKIP]", result);
}
/**
@@ -293,7 +293,7 @@ public class InformationElementUtilTest {
capabilities.from(ies, beaconCap);
String result = capabilities.generateCapabilitiesString();
- assertEquals("[WPA2]", result);
+ assertEquals("[RSN]", result);
}
/**
@@ -383,7 +383,7 @@ public class InformationElementUtilTest {
capabilities.from(ies, beaconCap);
String result = capabilities.generateCapabilitiesString();
- assertEquals("[WPA-PSK-CCMP+TKIP][WPA2-PSK-CCMP+TKIP]", result);
+ assertEquals("[WPA-PSK-CCMP+TKIP][RSN-PSK-CCMP+TKIP]", result);
}
/**
@@ -415,7 +415,7 @@ public class InformationElementUtilTest {
capabilities.from(ies, beaconCap);
String result = capabilities.generateCapabilitiesString();
- assertEquals("[WPA][WPA2]", result);
+ assertEquals("[WPA][RSN]", result);
}
/**
@@ -783,4 +783,5 @@ public class InformationElementUtilTest {
assertEquals(0x112233445566L, interworking.hessid);
}
+ // TODO: SAE, OWN, SUITE_B
}