summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorKai Shi <kaishi@google.com>2020-02-14 00:15:36 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2020-02-14 00:15:36 +0000
commit2cafabed0ac47dcade78c12564a2111d446f161d (patch)
tree7315ca9b8e0f7332a2b0f2684d91f177b1f7fc99 /tests
parent2fac385795e3f48d528a51730cb78680477ce593 (diff)
parent8da501dd29ae22e722de2c372570a08b27e10c98 (diff)
Merge "Trigger bugreport at high auth failure rate"
Diffstat (limited to 'tests')
-rw-r--r--tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java7
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiDiagnosticsTest.java13
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiScoreCardTest.java17
3 files changed, 36 insertions, 1 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java b/tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java
index de393e9fb..62f82a084 100644
--- a/tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java
@@ -76,6 +76,7 @@ import android.net.wifi.IActionListener;
import android.net.wifi.ScanResult;
import android.net.wifi.SupplicantState;
import android.net.wifi.WifiConfiguration;
+import android.net.wifi.WifiConfiguration.KeyMgmt;
import android.net.wifi.WifiEnterpriseConfig;
import android.net.wifi.WifiInfo;
import android.net.wifi.WifiManager;
@@ -1707,6 +1708,7 @@ public class ClientModeImplTest extends WifiBaseTest {
verify(mWifiConfigManager).updateNetworkSelectionStatus(anyInt(),
eq(WifiConfiguration.NetworkSelectionStatus.DISABLED_BY_WRONG_PASSWORD));
+ verify(mWifiScoreCard, never()).detectAbnormalAuthFailure(any());
assertEquals("DisconnectedState", getCurrentState().getName());
}
@@ -1731,6 +1733,7 @@ public class ClientModeImplTest extends WifiBaseTest {
WifiConfiguration config = new WifiConfiguration();
config.SSID = sSSID;
config.getNetworkSelectionStatus().setHasEverConnected(true);
+ config.allowedKeyManagement.set(KeyMgmt.IEEE8021X);
config.enterpriseConfig.setEapMethod(WifiEnterpriseConfig.Eap.SIM);
when(mWifiConfigManager.getConfiguredNetwork(anyInt())).thenReturn(config);
MockitoSession mockSession = ExtendedMockito.mockitoSession()
@@ -1748,6 +1751,7 @@ public class ClientModeImplTest extends WifiBaseTest {
WifiNative.EAP_SIM_VENDOR_SPECIFIC_CERT_EXPIRED, config);
verify(mDataTelephonyManager).resetCarrierKeysForImsiEncryption();
mockSession.finishMocking();
+ verify(mWifiScoreCard).detectAbnormalAuthFailure(anyString());
}
/**
@@ -1769,6 +1773,7 @@ public class ClientModeImplTest extends WifiBaseTest {
WifiConfiguration config = new WifiConfiguration();
config.getNetworkSelectionStatus().setHasEverConnected(true);
config.enterpriseConfig.setEapMethod(WifiEnterpriseConfig.Eap.TLS);
+ config.allowedKeyManagement.set(KeyMgmt.IEEE8021X);
when(mWifiConfigManager.getConfiguredNetwork(anyInt())).thenReturn(config);
mCmi.sendMessage(WifiMonitor.AUTHENTICATION_FAILURE_EVENT,
@@ -1777,6 +1782,7 @@ public class ClientModeImplTest extends WifiBaseTest {
mLooper.dispatchAll();
verify(mDataTelephonyManager, never()).resetCarrierKeysForImsiEncryption();
+ verify(mWifiScoreCard).detectAbnormalAuthFailure(null);
}
/**
@@ -1804,6 +1810,7 @@ public class ClientModeImplTest extends WifiBaseTest {
verify(mWifiConfigManager).updateNetworkSelectionStatus(anyInt(),
eq(WifiConfiguration.NetworkSelectionStatus
.DISABLED_AUTHENTICATION_NO_SUBSCRIPTION));
+ verify(mWifiScoreCard, never()).detectAbnormalAuthFailure(null);
}
@Test
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiDiagnosticsTest.java b/tests/wifitests/src/com/android/server/wifi/WifiDiagnosticsTest.java
index a20bb9872..acfc78d7e 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiDiagnosticsTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiDiagnosticsTest.java
@@ -881,6 +881,19 @@ public class WifiDiagnosticsTest extends WifiBaseTest {
}
@Test
+ public void tryTakeBugReportTwiceWithInsufficientTimeGap() {
+ when(mBuildProperties.isUserBuild()).thenReturn(false);
+ // 1st attempt should succeed
+ when(mClock.getWallClockMillis()).thenReturn(10L);
+ mWifiDiagnostics.takeBugReport("", "");
+ verify(mBugreportManager, times(1)).requestBugreport(any(), any(), any());
+ // 2nd attempt should fail
+ when(mClock.getWallClockMillis()).thenReturn(1000_000L);
+ mWifiDiagnostics.takeBugReport("", "");
+ verify(mBugreportManager, times(1)).requestBugreport(any(), any(), any());
+ }
+
+ @Test
public void takeBugReportDoesNothingWhenConfigOverlayDisabled() {
when(mBuildProperties.isUserBuild()).thenReturn(false);
mResources.setBoolean(R.bool.config_wifi_diagnostics_bugreport_enabled, false);
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiScoreCardTest.java b/tests/wifitests/src/com/android/server/wifi/WifiScoreCardTest.java
index 22438d493..61de6ada4 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiScoreCardTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiScoreCardTest.java
@@ -150,6 +150,7 @@ public class WifiScoreCardTest extends WifiBaseTest {
DeviceConfigFacade.DEFAULT_DISCONNECTION_NONLOCAL_LOW_THR_PERCENT);
when(mDeviceConfigFacade.getHealthMonitorMinRssiThrDbm()).thenReturn(
DeviceConfigFacade.DEFAULT_HEALTH_MONITOR_MIN_RSSI_THR_DBM);
+ mWifiScoreCard.enableVerboseLogging(true);
}
/**
@@ -766,6 +767,13 @@ public class WifiScoreCardTest extends WifiBaseTest {
BssidBlocklistMonitor.REASON_WRONG_PASSWORD);
}
+ private void makeAuthFailureExample() {
+ mWifiScoreCard.noteConnectionAttempt(mWifiInfo, -53, mWifiInfo.getSSID());
+ millisecondsPass(500);
+ mWifiScoreCard.noteConnectionFailure(mWifiInfo, -53, mWifiInfo.getSSID(),
+ BssidBlocklistMonitor.REASON_AUTHENTICATION_FAILURE);
+ }
+
/**
* Check network stats after authentication failure and wrong password.
*/
@@ -1060,7 +1068,7 @@ public class WifiScoreCardTest extends WifiBaseTest {
private void makeRecentStatsWithAuthFailure() {
for (int i = 0; i < MIN_NUM_CONNECTION_ATTEMPT; i++) {
- makeAuthFailureAndWrongPassword();
+ makeAuthFailureExample();
}
}
@@ -1168,5 +1176,12 @@ public class WifiScoreCardTest extends WifiBaseTest {
checkStatsDeltaExample(statsDec, 0);
checkStatsDeltaExample(statsInc, 0);
checkStatsDeltaExample(statsHigh, 1);
+ assertEquals(false, mWifiScoreCard.detectAbnormalAuthFailure(mWifiInfo.getSSID()));
+ }
+
+ @Test
+ public void testHighAuthFailureRate() throws Exception {
+ makeRecentStatsWithAuthFailure();
+ assertEquals(true, mWifiScoreCard.detectAbnormalAuthFailure(mWifiInfo.getSSID()));
}
}