summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMichael Plass <mplass@google.com>2017-03-10 16:54:26 -0800
committerMichael Plass <mplass@google.com>2017-03-14 13:57:06 -0700
commit92e43feb3eb54736a28226b588bc087fdda1646e (patch)
tree8bc8a9309b4e7940a4948e36bc19b80e4a51d625 /tests
parent4fdbb2cd44da9cd50bfdc022e7fcf7eec53986a6 (diff)
[SupplicantStaIfaceHal] Detect PSK mismatch
Use checks analogous to those in wpa_supplicant_8/wpa_supplicant/events.c to decide whether or not a disconnect is likely due to an incorrect password. Test: Attempt to join a PSK network with the wrong password Test: Unit tests added Bug: 35464954 Change-Id: I47196cf89dbd602c22a61b430b764c7ea76f04d5
Diffstat (limited to 'tests')
-rw-r--r--tests/wifitests/src/com/android/server/wifi/SupplicantStaIfaceHalTest.java55
1 files changed, 55 insertions, 0 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/SupplicantStaIfaceHalTest.java b/tests/wifitests/src/com/android/server/wifi/SupplicantStaIfaceHalTest.java
index 04ebf2200..bb5221730 100644
--- a/tests/wifitests/src/com/android/server/wifi/SupplicantStaIfaceHalTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/SupplicantStaIfaceHalTest.java
@@ -926,6 +926,61 @@ public class SupplicantStaIfaceHalTest {
}
/**
+ * Tests the handling of incorrect network passwords.
+ */
+ @Test
+ public void testAuthFailurePassword() throws Exception {
+ executeAndValidateInitializationSequence();
+ assertNotNull(mISupplicantStaIfaceCallback);
+
+ int reasonCode = 3;
+ mISupplicantStaIfaceCallback.onDisconnected(
+ NativeUtil.macAddressToByteArray(BSSID), true, reasonCode);
+ verify(mWifiMonitor, times(0)).broadcastAuthenticationFailureEvent(any(), anyInt());
+
+ mISupplicantStaIfaceCallback.onDisconnected(
+ NativeUtil.macAddressToByteArray(BSSID), false, reasonCode);
+ verify(mWifiMonitor, times(0)).broadcastAuthenticationFailureEvent(any(), anyInt());
+
+ mISupplicantStaIfaceCallback.onStateChanged(
+ ISupplicantStaIfaceCallback.State.FOURWAY_HANDSHAKE,
+ NativeUtil.macAddressToByteArray(BSSID),
+ SUPPLICANT_NETWORK_ID,
+ NativeUtil.decodeSsid(SUPPLICANT_SSID));
+ mISupplicantStaIfaceCallback.onDisconnected(
+ NativeUtil.macAddressToByteArray(BSSID), true, reasonCode);
+ mISupplicantStaIfaceCallback.onDisconnected(
+ NativeUtil.macAddressToByteArray(BSSID), false, reasonCode);
+
+ verify(mWifiMonitor, times(2)).broadcastAuthenticationFailureEvent(eq(WLAN_IFACE_NAME),
+ eq(WifiMonitor.AUTHENTICATION_FAILURE_REASON_WRONG_PSWD));
+
+ }
+
+ /**
+ * Tests the handling of incorrect network passwords, edge case.
+ *
+ * If the disconnect reason is "IE in 4way differs", do not call it a password mismatch.
+ */
+ @Test
+ public void testIeDiffers() throws Exception {
+ executeAndValidateInitializationSequence();
+ assertNotNull(mISupplicantStaIfaceCallback);
+
+ int reasonCode = 17; // IEEE 802.11i WLAN_REASON_IE_IN_4WAY_DIFFERS
+
+ mISupplicantStaIfaceCallback.onStateChanged(
+ ISupplicantStaIfaceCallback.State.FOURWAY_HANDSHAKE,
+ NativeUtil.macAddressToByteArray(BSSID),
+ SUPPLICANT_NETWORK_ID,
+ NativeUtil.decodeSsid(SUPPLICANT_SSID));
+ mISupplicantStaIfaceCallback.onDisconnected(
+ NativeUtil.macAddressToByteArray(BSSID), true, reasonCode);
+ verify(mWifiMonitor, times(0)).broadcastAuthenticationFailureEvent(any(), anyInt());
+ }
+
+
+ /**
* Tests the handling of association rejection notification.
*/
@Test