diff options
author | lesl <lesl@google.com> | 2020-03-24 21:31:27 +0800 |
---|---|---|
committer | lesl <lesl@google.com> | 2020-03-25 23:50:06 +0800 |
commit | a9d77c4c1ff8f730d0d188934721b061feb310aa (patch) | |
tree | 96ab0bdd478c492557a5c48336420a4e527a1d92 /tests | |
parent | 70f3e3846b6544788a56dcb62eee807e4e6dd77b (diff) |
wifi: Support setBssid in tethered mode hotspot
Also fix: Remove BSSID field when convert to SoftApConfiguration since BSSID
field doesn't use for softap in WifiConfiguration.
PS: Merged to master first to avoid conflict.
Bug: 152180102
Test: atest FrameworksWifiTest
Test: atest android.net.wifi.cts.WifiManagerTest#testStartLocalOnlyHotspotSingleRequestByApps
Test: atest android.net.wifi.cts.WifiManagerTest#testStartLocalOnlyHotspotSuccess
Test: atest atest android.net.wifi.cts.WifiManagerTest#testStartLocalOnlyHotspotWithConfig
Test: atest android.net.wifi.cts.WifiManagerTest#testSetGetSoftApConfigurationAndSoftApCapabilityCallback
Change-Id: I7955b84ef025bf8cb97b55eaac6a8fecda551750
Merged-In: I7955b84ef025bf8cb97b55eaac6a8fecda551750
Diffstat (limited to 'tests')
-rw-r--r-- | tests/wifitests/src/com/android/server/wifi/WifiApConfigStoreTest.java | 48 |
1 files changed, 35 insertions, 13 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiApConfigStoreTest.java b/tests/wifitests/src/com/android/server/wifi/WifiApConfigStoreTest.java index 4aacb1d78..ad8acbcea 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiApConfigStoreTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiApConfigStoreTest.java @@ -435,7 +435,7 @@ public class WifiApConfigStoreTest extends WifiBaseTest { public void getDefaultApConfigurationIsValid() throws Exception { WifiApConfigStore store = createWifiApConfigStore(); SoftApConfiguration config = store.getApConfiguration(); - assertTrue(WifiApConfigStore.validateApWifiConfiguration(config)); + assertTrue(WifiApConfigStore.validateApWifiConfiguration(config, true)); } /** @@ -450,7 +450,7 @@ public class WifiApConfigStoreTest extends WifiBaseTest { SoftApConfiguration.BAND_2GHZ); // verify that the config passes the validateApWifiConfiguration check - assertTrue(WifiApConfigStore.validateApWifiConfiguration(config)); + assertTrue(WifiApConfigStore.validateApWifiConfiguration(config, true)); } /** @@ -464,7 +464,7 @@ public class WifiApConfigStoreTest extends WifiBaseTest { SoftApConfiguration.BAND_5GHZ); // verify that the config passes the validateApWifiConfiguration check - assertTrue(WifiApConfigStore.validateApWifiConfiguration(config)); + assertTrue(WifiApConfigStore.validateApWifiConfiguration(config, true)); } @Test @@ -549,30 +549,30 @@ public class WifiApConfigStoreTest extends WifiBaseTest { public void testSsidVerificationInValidateApWifiConfigurationCheck() { Builder configBuilder = new SoftApConfiguration.Builder(); configBuilder.setSsid(null); - assertFalse(WifiApConfigStore.validateApWifiConfiguration(configBuilder.build())); + assertFalse(WifiApConfigStore.validateApWifiConfiguration(configBuilder.build(), true)); // check a string if it's larger than 32 bytes with UTF-8 encode // Case 1 : one byte per character (use english words and Arabic numerals) configBuilder.setSsid(generateRandomString(WifiApConfigStore.SSID_MAX_LEN + 1)); - assertFalse(WifiApConfigStore.validateApWifiConfiguration(configBuilder.build())); + assertFalse(WifiApConfigStore.validateApWifiConfiguration(configBuilder.build(), true)); // Case 2 : two bytes per character configBuilder.setSsid(TEST_STRING_UTF8_WITH_34_BYTES); - assertFalse(WifiApConfigStore.validateApWifiConfiguration(configBuilder.build())); + assertFalse(WifiApConfigStore.validateApWifiConfiguration(configBuilder.build(), true)); // Case 3 : three bytes per character configBuilder.setSsid(TEST_STRING_UTF8_WITH_33_BYTES); - assertFalse(WifiApConfigStore.validateApWifiConfiguration(configBuilder.build())); + assertFalse(WifiApConfigStore.validateApWifiConfiguration(configBuilder.build(), true)); // now check a valid SSID within 32 bytes // Case 1 : one byte per character with random length int validLength = WifiApConfigStore.SSID_MAX_LEN - WifiApConfigStore.SSID_MIN_LEN; configBuilder.setSsid(generateRandomString( mRandom.nextInt(validLength) + WifiApConfigStore.SSID_MIN_LEN)); - assertTrue(WifiApConfigStore.validateApWifiConfiguration(configBuilder.build())); + assertTrue(WifiApConfigStore.validateApWifiConfiguration(configBuilder.build(), true)); // Case 2 : two bytes per character configBuilder.setSsid(TEST_STRING_UTF8_WITH_32_BYTES); - assertTrue(WifiApConfigStore.validateApWifiConfiguration(configBuilder.build())); + assertTrue(WifiApConfigStore.validateApWifiConfiguration(configBuilder.build(), true)); // Case 3 : three bytes per character configBuilder.setSsid(TEST_STRING_UTF8_WITH_30_BYTES); - assertTrue(WifiApConfigStore.validateApWifiConfiguration(configBuilder.build())); + assertTrue(WifiApConfigStore.validateApWifiConfiguration(configBuilder.build(), true)); } /** @@ -587,7 +587,7 @@ public class WifiApConfigStoreTest extends WifiBaseTest { assertTrue(WifiApConfigStore.validateApWifiConfiguration( new SoftApConfiguration.Builder() .setSsid(TEST_DEFAULT_HOTSPOT_SSID) - .build())); + .build(), true)); } /** @@ -608,7 +608,7 @@ public class WifiApConfigStoreTest extends WifiBaseTest { configBuilder.setPassphrase( generateRandomString(mRandom.nextInt(maxLen - minLen) + minLen), SoftApConfiguration.SECURITY_TYPE_WPA2_PSK); - assertTrue(WifiApConfigStore.validateApWifiConfiguration(configBuilder.build())); + assertTrue(WifiApConfigStore.validateApWifiConfiguration(configBuilder.build(), true)); } /** @@ -634,7 +634,7 @@ public class WifiApConfigStoreTest extends WifiBaseTest { SoftApConfiguration.BAND_5GHZ, true); // verify that the config passes the validateApWifiConfiguration check - assertTrue(WifiApConfigStore.validateApWifiConfiguration(config)); + assertTrue(WifiApConfigStore.validateApWifiConfiguration(config, true)); } @@ -653,4 +653,26 @@ public class WifiApConfigStoreTest extends WifiBaseTest { assertEquals(resetedConfig.getMaxNumberOfClients(), 0); assertFalse(resetedConfig.isClientControlByUserEnabled()); } + + /** + * Verify Bssid field deny to set if caller without setting permission. + */ + @Test + public void testBssidDenyIfCallerWithoutPrivileged() throws Exception { + WifiApConfigStore store = createWifiApConfigStore(); + SoftApConfiguration config = new SoftApConfiguration.Builder(store.getApConfiguration()) + .setBssid(MacAddress.fromString("aa:bb:cc:dd:ee:ff")).build(); + assertFalse(WifiApConfigStore.validateApWifiConfiguration(config, false)); + } + + /** + * Verify Bssid field only allow to set if caller own setting permission. + */ + @Test + public void testBssidAllowIfCallerOwnPrivileged() throws Exception { + WifiApConfigStore store = createWifiApConfigStore(); + SoftApConfiguration config = new SoftApConfiguration.Builder(store.getApConfiguration()) + .setBssid(MacAddress.fromString("aa:bb:cc:dd:ee:ff")).build(); + assertTrue(WifiApConfigStore.validateApWifiConfiguration(config, true)); + } } |