diff options
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)); + } } |