summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorLes Lee <lesl@google.com>2020-06-24 11:43:41 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2020-06-24 11:43:41 +0000
commitf5a1794ec14fe6c329e6ed0af630c698fb94416c (patch)
tree82727dd706572d035781f34909a8c1b331999ddb /tests
parent77f43d544032477fe5cb6be7fdbc740cdd5c007d (diff)
parent698c277154b762ecd788d7d1be69d05899710e28 (diff)
Merge changes from topic "sap_blocked_list_enhancement" into rvc-dev am: 698c277154
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/opt/net/wifi/+/11932655 Change-Id: If8a0f042fbfcf6b89efaae05384f41e8710c348c
Diffstat (limited to 'tests')
-rw-r--r--tests/wifitests/src/com/android/server/wifi/SoftApManagerTest.java86
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiApConfigStoreTest.java109
2 files changed, 182 insertions, 13 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/SoftApManagerTest.java b/tests/wifitests/src/com/android/server/wifi/SoftApManagerTest.java
index 99cd2db82..ddd8fe515 100644
--- a/tests/wifitests/src/com/android/server/wifi/SoftApManagerTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/SoftApManagerTest.java
@@ -1190,6 +1190,92 @@ public class SoftApManagerTest extends WifiBaseTest {
}
@Test
+ public void testClientConnectFailureWhenClientInBlcokedListAndClientAuthorizationDisabled()
+ throws Exception {
+ ArrayList<MacAddress> blockedClientList = new ArrayList<>();
+ mTestSoftApCapability.setMaxSupportedClients(10);
+ Builder configBuilder = new SoftApConfiguration.Builder();
+ configBuilder.setBand(SoftApConfiguration.BAND_2GHZ);
+ configBuilder.setSsid(TEST_SSID);
+ configBuilder.setClientControlByUserEnabled(false);
+ // Client in blocked list
+ blockedClientList.add(TEST_MAC_ADDRESS);
+ configBuilder.setBlockedClientList(blockedClientList);
+ SoftApModeConfiguration apConfig =
+ new SoftApModeConfiguration(WifiManager.IFACE_IP_MODE_TETHERED,
+ configBuilder.build(), mTestSoftApCapability);
+ startSoftApAndVerifyEnabled(apConfig);
+
+ verify(mCallback).onConnectedClientsChanged(new ArrayList<>());
+
+ mSoftApListenerCaptor.getValue().onConnectedClientsChanged(
+ TEST_NATIVE_CLIENT, true);
+ mLooper.dispatchAll();
+
+ // Client is not allow verify
+ verify(mWifiNative).forceClientDisconnect(
+ TEST_INTERFACE_NAME, TEST_MAC_ADDRESS,
+ WifiManager.SAP_CLIENT_BLOCK_REASON_CODE_BLOCKED_BY_USER);
+ verify(mWifiMetrics, never()).addSoftApNumAssociatedStationsChangedEvent(
+ 1, apConfig.getTargetMode());
+ verify(mCallback, never()).onConnectedClientsChanged(
+ Mockito.argThat((List<WifiClient> clients) ->
+ clients.contains(TEST_CONNECTED_CLIENT))
+ );
+
+ }
+
+ @Test
+ public void testClientDisconnectWhenClientInBlcokedLisUpdatedtAndClientAuthorizationDisabled()
+ throws Exception {
+ ArrayList<MacAddress> blockedClientList = new ArrayList<>();
+ mTestSoftApCapability.setMaxSupportedClients(10);
+ Builder configBuilder = new SoftApConfiguration.Builder();
+ configBuilder.setBand(SoftApConfiguration.BAND_2GHZ);
+ configBuilder.setSsid(TEST_SSID);
+ configBuilder.setClientControlByUserEnabled(false);
+ SoftApModeConfiguration apConfig =
+ new SoftApModeConfiguration(WifiManager.IFACE_IP_MODE_TETHERED,
+ configBuilder.build(), mTestSoftApCapability);
+ startSoftApAndVerifyEnabled(apConfig);
+
+ verify(mCallback).onConnectedClientsChanged(new ArrayList<>());
+
+ mSoftApListenerCaptor.getValue().onConnectedClientsChanged(
+ TEST_NATIVE_CLIENT, true);
+ mLooper.dispatchAll();
+
+ // Client connected check
+ verify(mWifiNative, never()).forceClientDisconnect(
+ TEST_INTERFACE_NAME, TEST_MAC_ADDRESS,
+ WifiManager.SAP_CLIENT_BLOCK_REASON_CODE_BLOCKED_BY_USER);
+ verify(mWifiMetrics).addSoftApNumAssociatedStationsChangedEvent(
+ 1, apConfig.getTargetMode());
+ verify(mCallback, times(2)).onConnectedClientsChanged(
+ Mockito.argThat((List<WifiClient> clients) ->
+ clients.contains(TEST_CONNECTED_CLIENT))
+ );
+
+ reset(mCallback);
+ reset(mWifiNative);
+ // Update configuration
+ blockedClientList.add(TEST_MAC_ADDRESS);
+ configBuilder.setBlockedClientList(blockedClientList);
+ mSoftApManager.updateConfiguration(configBuilder.build());
+ mLooper.dispatchAll();
+ // Client difconnected
+ verify(mWifiNative).forceClientDisconnect(
+ TEST_INTERFACE_NAME, TEST_MAC_ADDRESS,
+ WifiManager.SAP_CLIENT_BLOCK_REASON_CODE_BLOCKED_BY_USER);
+ // The callback should not trigger in configuration update case.
+ verify(mCallback, never()).onBlockedClientConnecting(TEST_CONNECTED_CLIENT,
+ WifiManager.SAP_CLIENT_BLOCK_REASON_CODE_BLOCKED_BY_USER);
+
+ }
+
+
+
+ @Test
public void testForceClientDisconnectInvokeBecauseClientAuthorizationEnabled()
throws Exception {
mTestSoftApCapability.setMaxSupportedClients(10);
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiApConfigStoreTest.java b/tests/wifitests/src/com/android/server/wifi/WifiApConfigStoreTest.java
index bc646c1eb..90e01719f 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiApConfigStoreTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiApConfigStoreTest.java
@@ -659,24 +659,107 @@ public class WifiApConfigStoreTest extends WifiBaseTest {
@Test
public void testResetToDefaultForUnsupportedConfig() throws Exception {
- mResources.setBoolean(R.bool.config_wifiSofapClientForceDisconnectSupported, false);
- mResources.setBoolean(R.bool.config_wifi_softap_sae_supported, false);
- mResources.setBoolean(R.bool.config_wifiSoftapResetChannelConfig, true);
- SoftApConfiguration sae_config = new SoftApConfiguration.Builder()
- .setPassphrase("secretsecret", SoftApConfiguration.SECURITY_TYPE_WPA3_SAE)
- .setMaxNumberOfClients(10)
- .setClientControlByUserEnabled(true)
- .setChannel(149, SoftApConfiguration.BAND_5GHZ)
- .build();
+ mResources.setBoolean(R.bool.config_wifiSofapClientForceDisconnectSupported, true);
+ mResources.setBoolean(R.bool.config_wifi_softap_sae_supported, true);
+ mResources.setBoolean(R.bool.config_wifi6ghzSupport, true);
+ mResources.setBoolean(R.bool.config_wifi5ghzSupport, true);
+
+ // Test all of the features support and all of the reset config are false.
+ String testPassphrase = "secretsecret";
+ SoftApConfiguration.Builder configBuilder = new SoftApConfiguration.Builder();
+ configBuilder.setPassphrase(testPassphrase, SoftApConfiguration.SECURITY_TYPE_WPA3_SAE);
WifiApConfigStore store = createWifiApConfigStore();
+ SoftApConfiguration resetedConfig = store.resetToDefaultForUnsupportedConfig(
+ configBuilder.build());
+ assertEquals(resetedConfig, configBuilder.build());
- SoftApConfiguration resetedConfig = store.resetToDefaultForUnsupportedConfig(sae_config);
- assertEquals(resetedConfig.getMaxNumberOfClients(), 0);
- assertFalse(resetedConfig.isClientControlByUserEnabled());
+ verify(mWifiMetrics).noteSoftApConfigReset(configBuilder.build(), resetedConfig);
+
+ // Test SAE not support case.
+ mResources.setBoolean(R.bool.config_wifi_softap_sae_supported, false);
+ resetedConfig = store.resetToDefaultForUnsupportedConfig(configBuilder.build());
+ assertEquals(resetedConfig.getSecurityType(), SoftApConfiguration.SECURITY_TYPE_WPA2_PSK);
+ // Test force channel
+ configBuilder.setChannel(149, SoftApConfiguration.BAND_5GHZ);
+ mResources.setBoolean(
+ R.bool.config_wifiSoftapResetChannelConfig, true);
+ resetedConfig = store.resetToDefaultForUnsupportedConfig(configBuilder.build());
assertEquals(resetedConfig.getChannel(), 0);
assertEquals(resetedConfig.getBand(),
SoftApConfiguration.BAND_2GHZ | SoftApConfiguration.BAND_5GHZ);
- verify(mWifiMetrics).noteSoftApConfigReset(sae_config, resetedConfig);
+
+ // Test forced channel band doesn't support.
+ mResources.setBoolean(R.bool.config_wifi5ghzSupport, false);
+ resetedConfig = store.resetToDefaultForUnsupportedConfig(configBuilder.build());
+ assertEquals(resetedConfig.getChannel(), 0);
+ assertEquals(resetedConfig.getBand(),
+ SoftApConfiguration.BAND_2GHZ);
+
+ // Test band not support with auto channel
+ configBuilder.setBand(SoftApConfiguration.BAND_5GHZ);
+ resetedConfig = store.resetToDefaultForUnsupportedConfig(configBuilder.build());
+ assertEquals(resetedConfig.getBand(), SoftApConfiguration.BAND_2GHZ);
+
+ // Test reset hidden network
+ mResources.setBoolean(
+ R.bool.config_wifiSoftapResetHiddenConfig, true);
+ configBuilder.setHiddenSsid(true);
+ resetedConfig = store.resetToDefaultForUnsupportedConfig(configBuilder.build());
+ assertFalse(resetedConfig.isHiddenSsid());
+
+ // Test auto shutdown timer
+ mResources.setBoolean(
+ R.bool.config_wifiSoftapResetAutoShutdownTimerConfig, true);
+ configBuilder.setShutdownTimeoutMillis(8888);
+ resetedConfig = store.resetToDefaultForUnsupportedConfig(configBuilder.build());
+ assertEquals(resetedConfig.getShutdownTimeoutMillis(), 0);
+
+ // Test max client setting when force client disconnect doesn't support
+ mResources.setBoolean(R.bool.config_wifiSofapClientForceDisconnectSupported, false);
+ configBuilder.setMaxNumberOfClients(10);
+ resetedConfig = store.resetToDefaultForUnsupportedConfig(configBuilder.build());
+ assertEquals(resetedConfig.getMaxNumberOfClients(), 0);
+
+ // Test client control setting when force client disconnect doesn't support
+ mResources.setBoolean(R.bool.config_wifiSofapClientForceDisconnectSupported, false);
+ ArrayList<MacAddress> blockedClientList = new ArrayList<>();
+ ArrayList<MacAddress> allowedClientList = new ArrayList<>();
+ blockedClientList.add(MacAddress.fromString("11:22:33:44:55:66"));
+ allowedClientList.add(MacAddress.fromString("aa:bb:cc:dd:ee:ff"));
+ configBuilder.setBlockedClientList(blockedClientList);
+ configBuilder.setAllowedClientList(allowedClientList);
+
+ configBuilder.setClientControlByUserEnabled(true);
+ resetedConfig = store.resetToDefaultForUnsupportedConfig(configBuilder.build());
+ assertFalse(resetedConfig.isClientControlByUserEnabled());
+ // The blocked list will be clean
+ assertEquals(resetedConfig.getBlockedClientList().size(), 0);
+ // The allowed list will be keep
+ assertEquals(resetedConfig.getAllowedClientList(), allowedClientList);
+
+ // Test max client setting when reset enabled but force client disconnect supported
+ mResources.setBoolean(R.bool.config_wifiSofapClientForceDisconnectSupported, true);
+ mResources.setBoolean(
+ R.bool.config_wifiSoftapResetMaxClientSettingConfig, true);
+ assertEquals(resetedConfig.getMaxNumberOfClients(), 0);
+
+ // Test client control setting when reset enabled but force client disconnect supported
+ mResources.setBoolean(R.bool.config_wifiSofapClientForceDisconnectSupported, true);
+ mResources.setBoolean(
+ R.bool.config_wifiSoftapResetUserControlConfig, true);
+ resetedConfig = store.resetToDefaultForUnsupportedConfig(configBuilder.build());
+ assertFalse(resetedConfig.isClientControlByUserEnabled());
+ assertEquals(resetedConfig.getBlockedClientList().size(), 0);
+ assertEquals(resetedConfig.getAllowedClientList(), allowedClientList);
+
+ // Test blocked list setting will be reset even if client control disabled
+ mResources.setBoolean(
+ R.bool.config_wifiSoftapResetUserControlConfig, true);
+ configBuilder.setClientControlByUserEnabled(false);
+ resetedConfig = store.resetToDefaultForUnsupportedConfig(configBuilder.build());
+ assertFalse(resetedConfig.isClientControlByUserEnabled());
+ assertEquals(resetedConfig.getBlockedClientList().size(), 0);
+ assertEquals(resetedConfig.getAllowedClientList(), allowedClientList);
}
/**