summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorRoshan Pius <rpius@google.com>2020-07-17 08:25:28 -0700
committerRoshan Pius <rpius@google.com>2020-07-22 18:23:31 +0000
commitcc841d2abc81491a4001fe1c46e9ea17fb01581e (patch)
tree6c507662df67d4ecfe80615738f9a5e80807095b /tests
parent725979457913e7addc8c6ffbd921b82011effe1e (diff)
SupplicantStaIfaceHal: Trigger EAP auth failure on disconnect
To fix the ordering of events issue in supplicant, trigger eap authentication failure on disconnect event iff i) Device is connecting to an EAP network. ii) Device has finished association. Bug: 159687884 Test: atest com.android.server.wifi Test: Manual tests (EAP): i) Trigger connection to EAP network with wrong credentials. ii) Ensure that we blacklist the network after a couple of failures. Manual tests (WPA_PSK): i) Trigger connection to PSK network with wrong password. ii) Ensure that we blacklist the network after failure. Change-Id: I08cf5187ee825ce9cf01686f86ff956a2956372a Merged-In: I08cf5187ee825ce9cf01686f86ff956a2956372a (cherry picked from commit b34cba88e54656822d3b855b82e3aa39bddd9ebc)
Diffstat (limited to 'tests')
-rw-r--r--tests/wifitests/src/com/android/server/wifi/SupplicantStaIfaceHalTest.java46
1 files changed, 42 insertions, 4 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/SupplicantStaIfaceHalTest.java b/tests/wifitests/src/com/android/server/wifi/SupplicantStaIfaceHalTest.java
index 95f88bbf1..762691184 100644
--- a/tests/wifitests/src/com/android/server/wifi/SupplicantStaIfaceHalTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/SupplicantStaIfaceHalTest.java
@@ -1040,9 +1040,11 @@ public class SupplicantStaIfaceHalTest extends WifiBaseTest {
* Tests the handling of incorrect network passwords.
*/
@Test
- public void testAuthFailurePassword() throws Exception {
+ public void testAuthFailurePasswordOnDisconnect() throws Exception {
executeAndValidateInitializationSequence();
assertNotNull(mISupplicantStaIfaceCallback);
+ executeAndValidateConnectSequenceWithKeyMgmt(
+ 0, false, WifiConfiguration.KeyMgmt.WPA_PSK, null);
int reasonCode = 3;
mISupplicantStaIfaceCallback.onDisconnected(
@@ -1061,13 +1063,49 @@ public class SupplicantStaIfaceHalTest extends WifiBaseTest {
SUPPLICANT_NETWORK_ID,
NativeUtil.decodeSsid(SUPPLICANT_SSID));
mISupplicantStaIfaceCallback.onDisconnected(
+ NativeUtil.macAddressToByteArray(BSSID), false, reasonCode);
+
+ verify(mWifiMonitor).broadcastAuthenticationFailureEvent(
+ eq(WLAN0_IFACE_NAME), eq(WifiManager.ERROR_AUTH_FAILURE_WRONG_PSWD), eq(-1));
+ }
+
+ /**
+ * Tests the handling of EAP failure disconnects.
+ */
+ @Test
+ public void testAuthFailureEapOnDisconnect() throws Exception {
+ executeAndValidateInitializationSequence();
+ assertNotNull(mISupplicantStaIfaceCallback);
+ executeAndValidateConnectSequenceWithKeyMgmt(
+ 0, false, WifiConfiguration.KeyMgmt.WPA_EAP, null);
+
+ int reasonCode = 3;
+ mISupplicantStaIfaceCallback.onDisconnected(
NativeUtil.macAddressToByteArray(BSSID), true, reasonCode);
+ verify(mWifiMonitor, times(0))
+ .broadcastAuthenticationFailureEvent(any(), anyInt(), anyInt());
+
mISupplicantStaIfaceCallback.onDisconnected(
NativeUtil.macAddressToByteArray(BSSID), false, reasonCode);
+ verify(mWifiMonitor, times(0))
+ .broadcastAuthenticationFailureEvent(any(), anyInt(), anyInt());
- verify(mWifiMonitor, times(2))
- .broadcastAuthenticationFailureEvent(eq(WLAN0_IFACE_NAME),
- eq(WifiManager.ERROR_AUTH_FAILURE_WRONG_PSWD), eq(-1));
+ mISupplicantStaIfaceCallback.onStateChanged(
+ ISupplicantStaIfaceCallback.State.ASSOCIATED,
+ NativeUtil.macAddressToByteArray(BSSID),
+ SUPPLICANT_NETWORK_ID,
+ NativeUtil.decodeSsid(SUPPLICANT_SSID));
+ // Ensure we don't lose our prev state with this state changed event.
+ mISupplicantStaIfaceCallback.onStateChanged(
+ ISupplicantStaIfaceCallback.State.DISCONNECTED,
+ NativeUtil.macAddressToByteArray(BSSID),
+ SUPPLICANT_NETWORK_ID,
+ NativeUtil.decodeSsid(SUPPLICANT_SSID));
+ mISupplicantStaIfaceCallback.onDisconnected(
+ NativeUtil.macAddressToByteArray(BSSID), false, reasonCode);
+
+ verify(mWifiMonitor).broadcastAuthenticationFailureEvent(
+ eq(WLAN0_IFACE_NAME), eq(WifiManager.ERROR_AUTH_FAILURE_EAP_FAILURE), eq(-1));
}
/**