diff options
author | Jimmy Chen <jimmycmchen@google.com> | 2019-09-16 15:57:57 +0800 |
---|---|---|
committer | Jimmy Chen <jimmycmchen@google.com> | 2019-12-18 17:33:25 +0800 |
commit | e8c8be569130aa75a3370cc4d4e50aad9aad3a7c (patch) | |
tree | a4ec962a2dcf1146e8184c633f947c28171bb048 /tests | |
parent | 6365f9620376f5541ee7f67b025b9f09ae9d02d4 (diff) |
Wifi: framework adaption for WAPI configuration
Support passing WAPI configuration to native service.
Bug: 139257562
Test: atest FrameworksWifiTests
Change-Id: I9b8a21f594fa358a4bfa68a888a32e32baddec37
Diffstat (limited to 'tests')
6 files changed, 174 insertions, 5 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/NetworkListStoreDataTest.java b/tests/wifitests/src/com/android/server/wifi/NetworkListStoreDataTest.java index 694dfdedd..272ff56ce 100644 --- a/tests/wifitests/src/com/android/server/wifi/NetworkListStoreDataTest.java +++ b/tests/wifitests/src/com/android/server/wifi/NetworkListStoreDataTest.java @@ -189,6 +189,7 @@ public class NetworkListStoreDataTest extends WifiBaseTest { + "<string name=\"PLMN\"></string>\n" + "<string name=\"Realm\"></string>\n" + "<int name=\"Ocsp\" value=\"0\" />\n" + + "<string name=\"WapiCertSuite\"></string>\n" + "</WifiEnterpriseConfiguration>\n" + "</Network>\n"; diff --git a/tests/wifitests/src/com/android/server/wifi/SupplicantStaIfaceHalTest.java b/tests/wifitests/src/com/android/server/wifi/SupplicantStaIfaceHalTest.java index 5615e4ffa..69766aaa4 100644 --- a/tests/wifitests/src/com/android/server/wifi/SupplicantStaIfaceHalTest.java +++ b/tests/wifitests/src/com/android/server/wifi/SupplicantStaIfaceHalTest.java @@ -19,6 +19,7 @@ import static android.net.wifi.WifiManager.WIFI_FEATURE_DPP; import static android.net.wifi.WifiManager.WIFI_FEATURE_MBO; import static android.net.wifi.WifiManager.WIFI_FEATURE_OCE; import static android.net.wifi.WifiManager.WIFI_FEATURE_OWE; +import static android.net.wifi.WifiManager.WIFI_FEATURE_WAPI; import static android.net.wifi.WifiManager.WIFI_FEATURE_WPA3_SAE; import static android.net.wifi.WifiManager.WIFI_FEATURE_WPA3_SUITE_B; @@ -1517,6 +1518,19 @@ public class SupplicantStaIfaceHalTest extends WifiBaseTest { } } + private class GetKeyMgmtCapabilities_1_3Answer extends MockAnswerUtil.AnswerWithArguments { + private int mKeyMgmtCapabilities; + + GetKeyMgmtCapabilities_1_3Answer(int keyMgmtCapabilities) { + mKeyMgmtCapabilities = keyMgmtCapabilities; + } + + public void answer(android.hardware.wifi.supplicant.V1_3.ISupplicantStaIface + .getKeyMgmtCapabilities_1_3Callback cb) { + cb.onValues(mStatusSuccess, mKeyMgmtCapabilities); + } + } + /** * Test get key management capabilities API on old HAL, should return 0 (not supported) */ @@ -1623,6 +1637,24 @@ public class SupplicantStaIfaceHalTest extends WifiBaseTest { } /** + * Test WAPI key may management support + */ + @Test + public void testGetKeyMgmtCapabilitiesWapi() throws Exception { + setupMocksForHalV1_3(); + + executeAndValidateInitializationSequenceV1_3(); + + doAnswer(new GetKeyMgmtCapabilities_1_3Answer(android.hardware.wifi.supplicant.V1_3 + .ISupplicantStaNetwork.KeyMgmtMask.WAPI_PSK)) + .when(mISupplicantStaIfaceMockV13).getKeyMgmtCapabilities_1_3(any( + android.hardware.wifi.supplicant.V1_3.ISupplicantStaIface + .getKeyMgmtCapabilities_1_3Callback.class)); + + assertEquals(WIFI_FEATURE_WAPI, mDut.getAdvancedKeyMgmtCapabilities(WLAN0_IFACE_NAME)); + } + + /** * Test Easy Connect (DPP) calls return failure if hal version is less than 1_2 */ @Test diff --git a/tests/wifitests/src/com/android/server/wifi/SupplicantStaNetworkHalTest.java b/tests/wifitests/src/com/android/server/wifi/SupplicantStaNetworkHalTest.java index 902300745..9c6596257 100644 --- a/tests/wifitests/src/com/android/server/wifi/SupplicantStaNetworkHalTest.java +++ b/tests/wifitests/src/com/android/server/wifi/SupplicantStaNetworkHalTest.java @@ -385,6 +385,30 @@ public class SupplicantStaNetworkHalTest extends WifiBaseTest { } /** + * Tests the saving of WifiConfiguration to wpa_supplicant. + */ + @Test + public void testWapiPskNetworkWifiConfigurationSaveLoad() throws Exception { + // Now expose the V1.3 ISupplicantStaNetwork + createSupplicantStaNetwork(SupplicantStaNetworkVersion.V1_3); + + WifiConfiguration config = WifiConfigurationTestUtil.createWapiPskNetwork(); + testWifiConfigurationSaveLoad(config); + } + + /** + * Tests the saving of WifiConfiguration to wpa_supplicant. + */ + @Test + public void testWapiCertNetworkWifiConfigurationSaveLoad() throws Exception { + // Now expose the V1.3 ISupplicantStaNetwork + createSupplicantStaNetwork(SupplicantStaNetworkVersion.V1_3); + + WifiConfiguration config = WifiConfigurationTestUtil.createWapiCertNetwork(); + testWifiConfigurationSaveLoad(config); + } + + /** * Tests the failure to save ssid. */ @Test @@ -1192,6 +1216,22 @@ public class SupplicantStaNetworkHalTest extends WifiBaseTest { .getKeyMgmt_1_2(any(android.hardware.wifi.supplicant.V1_2.ISupplicantStaNetwork .getKeyMgmt_1_2Callback.class)); + /** allowedKeyManagement v1.3 */ + doAnswer(new AnswerWithArguments() { + public SupplicantStatus answer(int mask) throws RemoteException { + mSupplicantVariables.keyMgmtMask = mask; + return mStatusSuccess; + } + }).when(mISupplicantStaNetworkV13).setKeyMgmt_1_3(any(int.class)); + doAnswer(new AnswerWithArguments() { + public void answer(android.hardware.wifi.supplicant.V1_3.ISupplicantStaNetwork + .getKeyMgmt_1_3Callback cb) throws RemoteException { + cb.onValues(mStatusSuccess, mSupplicantVariables.keyMgmtMask); + } + }).when(mISupplicantStaNetworkV13) + .getKeyMgmt_1_3(any(android.hardware.wifi.supplicant.V1_3.ISupplicantStaNetwork + .getKeyMgmt_1_3Callback.class)); + /** allowedProtocols */ doAnswer(new AnswerWithArguments() { public SupplicantStatus answer(int mask) throws RemoteException { @@ -1206,6 +1246,22 @@ public class SupplicantStaNetworkHalTest extends WifiBaseTest { }).when(mISupplicantStaNetworkMock) .getProto(any(ISupplicantStaNetwork.getProtoCallback.class)); + /** allowedProtocols v1.3*/ + doAnswer(new AnswerWithArguments() { + public SupplicantStatus answer(int mask) throws RemoteException { + mSupplicantVariables.protoMask = mask; + return mStatusSuccess; + } + }).when(mISupplicantStaNetworkV13).setProto_1_3(any(int.class)); + doAnswer(new AnswerWithArguments() { + public void answer(android.hardware.wifi.supplicant.V1_3.ISupplicantStaNetwork + .getProto_1_3Callback cb) throws RemoteException { + cb.onValues(mStatusSuccess, mSupplicantVariables.protoMask); + } + }).when(mISupplicantStaNetworkV13) + .getProto_1_3(any(android.hardware.wifi.supplicant.V1_3.ISupplicantStaNetwork + .getProto_1_3Callback.class)); + /** allowedAuthAlgorithms */ doAnswer(new AnswerWithArguments() { public SupplicantStatus answer(int mask) throws RemoteException { @@ -1251,6 +1307,23 @@ public class SupplicantStaNetworkHalTest extends WifiBaseTest { .getGroupCipher_1_2(any(android.hardware.wifi.supplicant.V1_2.ISupplicantStaNetwork .getGroupCipher_1_2Callback.class)); + /** allowedGroupCiphers v1.3*/ + doAnswer(new AnswerWithArguments() { + public SupplicantStatus answer(int mask) throws RemoteException { + mSupplicantVariables.groupCipherMask = mask; + return mStatusSuccess; + } + }).when(mISupplicantStaNetworkV13).setGroupCipher_1_3(any(int.class)); + doAnswer(new AnswerWithArguments() { + public void answer(android.hardware.wifi.supplicant.V1_3.ISupplicantStaNetwork + .getGroupCipher_1_3Callback cb) + throws RemoteException { + cb.onValues(mStatusSuccess, mSupplicantVariables.groupCipherMask); + } + }).when(mISupplicantStaNetworkV13) + .getGroupCipher_1_3(any(android.hardware.wifi.supplicant.V1_3.ISupplicantStaNetwork + .getGroupCipher_1_3Callback.class)); + /** allowedPairwiseCiphers */ doAnswer(new AnswerWithArguments() { public SupplicantStatus answer(int mask) throws RemoteException { @@ -1282,6 +1355,23 @@ public class SupplicantStaNetworkHalTest extends WifiBaseTest { .getPairwiseCipher_1_2(any(android.hardware.wifi.supplicant.V1_2 .ISupplicantStaNetwork.getPairwiseCipher_1_2Callback.class)); + /** allowedPairwiseCiphers v1.3 */ + doAnswer(new AnswerWithArguments() { + public SupplicantStatus answer(int mask) throws RemoteException { + mSupplicantVariables.pairwiseCipherMask = mask; + return mStatusSuccess; + } + }).when(mISupplicantStaNetworkV13).setPairwiseCipher_1_3(any(int.class)); + doAnswer(new AnswerWithArguments() { + public void answer(android.hardware.wifi.supplicant.V1_3.ISupplicantStaNetwork + .getPairwiseCipher_1_3Callback cb) + throws RemoteException { + cb.onValues(mStatusSuccess, mSupplicantVariables.pairwiseCipherMask); + } + }).when(mISupplicantStaNetworkV13) + .getPairwiseCipher_1_3(any(android.hardware.wifi.supplicant.V1_3 + .ISupplicantStaNetwork.getPairwiseCipher_1_3Callback.class)); + /** metadata: idstr */ doAnswer(new AnswerWithArguments() { public SupplicantStatus answer(String idStr) throws RemoteException { @@ -1583,6 +1673,22 @@ public class SupplicantStaNetworkHalTest extends WifiBaseTest { } }).when(mISupplicantStaNetworkV13).setPmkCache(any(ArrayList.class)); + /** WAPI Cert */ + doAnswer(new AnswerWithArguments() { + public SupplicantStatus answer(String cert) throws RemoteException { + mSupplicantVariables.wapiCertSuite = cert; + return mStatusSuccess; + } + }).when(mISupplicantStaNetworkV13).setWapiCertSuite(any(String.class)); + doAnswer(new AnswerWithArguments() { + public void answer(android.hardware.wifi.supplicant.V1_3 + .ISupplicantStaNetwork.getWapiCertSuiteCallback cb) + throws RemoteException { + cb.onValues(mStatusSuccess, mSupplicantVariables.wapiCertSuite); + } + }).when(mISupplicantStaNetworkV13) + .getWapiCertSuite(any(android.hardware.wifi.supplicant.V1_3 + .ISupplicantStaNetwork.getWapiCertSuiteCallback.class)); } private SupplicantStatus createSupplicantStatus(int code) { @@ -1648,5 +1754,6 @@ public class SupplicantStaNetworkHalTest extends WifiBaseTest { public boolean eapProactiveKeyCaching; public int ocsp; public ArrayList<Byte> serializedPmkCache; + public String wapiCertSuite; } } diff --git a/tests/wifitests/src/com/android/server/wifi/WifiBackupRestoreTest.java b/tests/wifitests/src/com/android/server/wifi/WifiBackupRestoreTest.java index 5b69421a3..bbd99ce02 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiBackupRestoreTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiBackupRestoreTest.java @@ -105,11 +105,11 @@ public class WifiBackupRestoreTest extends WifiBaseTest { // Valid Value: 01 + "<byte-array name=\"AllowedKeyMgmt\" num=\"2\">0180</byte-array>" // Valid Value: 03 - + "<byte-array name=\"AllowedProtocols\" num=\"1\">0b</byte-array>" + + "<byte-array name=\"AllowedProtocols\" num=\"1\">13</byte-array>" // Valid Value: 01 + "<byte-array name=\"AllowedAuthAlgos\" num=\"1\">09</byte-array>" // Valid Value: 0f - + "<byte-array name=\"AllowedGroupCiphers\" num=\"1\">4f</byte-array>" + + "<byte-array name=\"AllowedGroupCiphers\" num=\"1\">8f</byte-array>" // Valid Value: 06 + "<byte-array name=\"AllowedPairwiseCiphers\" num=\"1\">26</byte-array>" + "<boolean name=\"Shared\" value=\"true\" />" diff --git a/tests/wifitests/src/com/android/server/wifi/WifiConfigurationTestUtil.java b/tests/wifitests/src/com/android/server/wifi/WifiConfigurationTestUtil.java index 23f068410..f87e2d42f 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiConfigurationTestUtil.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiConfigurationTestUtil.java @@ -49,6 +49,8 @@ public class WifiConfigurationTestUtil { 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; + public static final int SECURITY_WAPI_PSK = 1 << 6; + public static final int SECURITY_WAPI_CERT = 1 << 7; /** * These values are used to describe ip configuration parameters for a network. @@ -162,6 +164,14 @@ public class WifiConfigurationTestUtil { config.requirePMF = true; } + if ((security & SECURITY_WAPI_PSK) != 0) { + config.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.WAPI_PSK); + } + + if ((security & SECURITY_WAPI_CERT) != 0) { + config.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.WAPI_CERT); + } + } return config; } @@ -380,6 +390,25 @@ public class WifiConfigurationTestUtil { return configuration; } + public static WifiConfiguration createWapiPskNetwork() { + WifiConfiguration configuration = + generateWifiConfig(TEST_NETWORK_ID, TEST_UID, createNewSSID(), true, true, null, + null, SECURITY_WAPI_PSK); + configuration.preSharedKey = TEST_PSK; + return configuration; + } + + public static WifiConfiguration createWapiCertNetwork() { + WifiEnterpriseConfig enterpriseConfig = new WifiEnterpriseConfig(); + enterpriseConfig.setEapMethod(WifiEnterpriseConfig.Eap.WAPI_CERT); + enterpriseConfig.setWapiCertSuite("wapiCertSuite"); + WifiConfiguration configuration = + generateWifiConfig(TEST_NETWORK_ID, TEST_UID, createNewSSID(), true, true, null, + null, SECURITY_WAPI_CERT); + configuration.enterpriseConfig = enterpriseConfig; + return configuration; + } + public static IpConfiguration createStaticIpConfigurationWithPacProxy() { return generateIpConfig( STATIC_IP_ASSIGNMENT, PAC_PROXY_SETTING, diff --git a/tests/wifitests/src/com/android/server/wifi/WifiConfigurationUtilTest.java b/tests/wifitests/src/com/android/server/wifi/WifiConfigurationUtilTest.java index d2e6f1f78..eb6686d9d 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiConfigurationUtilTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiConfigurationUtilTest.java @@ -480,7 +480,7 @@ public class WifiConfigurationUtilTest extends WifiBaseTest { WifiConfiguration config = WifiConfigurationTestUtil.createOpenNetwork(); assertTrue(WifiConfigurationUtil.validate(config, WifiConfigurationUtil.VALIDATE_FOR_ADD)); - config.allowedProtocols.set(3); + config.allowedProtocols.set(4); assertFalse(WifiConfigurationUtil.validate(config, WifiConfigurationUtil.VALIDATE_FOR_ADD)); } @@ -506,7 +506,7 @@ public class WifiConfigurationUtilTest extends WifiBaseTest { WifiConfiguration config = WifiConfigurationTestUtil.createOpenNetwork(); assertTrue(WifiConfigurationUtil.validate(config, WifiConfigurationUtil.VALIDATE_FOR_ADD)); - config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.GTK_NOT_USED + 2); + config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.GTK_NOT_USED + 3); assertFalse(WifiConfigurationUtil.validate(config, WifiConfigurationUtil.VALIDATE_FOR_ADD)); } @@ -519,7 +519,7 @@ public class WifiConfigurationUtilTest extends WifiBaseTest { WifiConfiguration config = WifiConfigurationTestUtil.createOpenNetwork(); assertTrue(WifiConfigurationUtil.validate(config, WifiConfigurationUtil.VALIDATE_FOR_ADD)); - config.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.CCMP + 2); + config.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.CCMP + 3); assertFalse(WifiConfigurationUtil.validate(config, WifiConfigurationUtil.VALIDATE_FOR_ADD)); } |