diff options
author | Les Lee <lesl@google.com> | 2020-03-26 00:23:14 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2020-03-26 00:23:14 +0000 |
commit | 776f77aa028f52fc08c51da38b502014938850ce (patch) | |
tree | 4a0356866c366dd0c074b041b45f9c3fa7d5e620 /tests | |
parent | 8a4c5e709e27c306e2d8562bdb5eca40ac003cbc (diff) | |
parent | a9d77c4c1ff8f730d0d188934721b061feb310aa (diff) |
Merge "wifi: Support setBssid in tethered mode hotspot" into rvc-dev
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 0996ce43c..3abdb067a 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiApConfigStoreTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiApConfigStoreTest.java @@ -436,7 +436,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)); } /** @@ -451,7 +451,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)); } /** @@ -465,7 +465,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 @@ -550,30 +550,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)); } /** @@ -588,7 +588,7 @@ public class WifiApConfigStoreTest extends WifiBaseTest { assertTrue(WifiApConfigStore.validateApWifiConfiguration( new SoftApConfiguration.Builder() .setSsid(TEST_DEFAULT_HOTSPOT_SSID) - .build())); + .build(), true)); } /** @@ -609,7 +609,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)); } /** @@ -635,7 +635,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)); } @@ -655,4 +655,26 @@ public class WifiApConfigStoreTest extends WifiBaseTest { assertFalse(resetedConfig.isClientControlByUserEnabled()); verify(mWifiMetrics).noteSoftApConfigReset(sae_config, resetedConfig); } + + /** + * 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)); + } } |