diff options
author | Daichi Ueura <daichi.ueura@sony.com> | 2018-11-02 20:56:02 +0900 |
---|---|---|
committer | Ecco Park <eccopark@google.com> | 2018-11-10 01:48:25 +0000 |
commit | 5ca503e12af88171c4aa47c0192c777fb5b27cfe (patch) | |
tree | 202ace7ea4a0e79a30d43a3aa71aeadcee0d6354 /tests | |
parent | 1814bab638b34e51550fa23ccf0b8518b7aaec71 (diff) |
Remove all Passpoint configurations in network settings reset
Network settings reset now removes not only wifi configurations
but also Passpoint configurations.
Bug: 118859444
Test: Unit tests
Test: Network settings reset with/without passpoint support
Signed-off-by: Daichi Ueura <daichi.ueura@sony.com>
Change-Id: Icdaa1057cf562c38446e4c165647ba115eb9a800
Diffstat (limited to 'tests')
-rw-r--r-- | tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java b/tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java index 171b1a907..56f3be516 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java @@ -55,6 +55,7 @@ import static org.mockito.Matchers.eq; import static org.mockito.Mockito.*; import static org.mockito.Mockito.atLeastOnce; +import android.Manifest; import android.app.ActivityManager; import android.app.AppOpsManager; import android.content.BroadcastReceiver; @@ -81,6 +82,7 @@ import android.net.wifi.WifiSsid; import android.net.wifi.hotspot2.IProvisioningCallback; import android.net.wifi.hotspot2.OsuProvider; import android.net.wifi.hotspot2.PasspointConfiguration; +import android.net.wifi.hotspot2.pps.HomeSp; import android.os.Binder; import android.os.Handler; import android.os.HandlerThread; @@ -3090,4 +3092,64 @@ public class WifiServiceImplTest { verify(mClientModeImpl).removeNetworkRequestMatchCallback( TEST_NETWORK_REQUEST_MATCH_CALLBACK_IDENTIFIER); } + + /** + * Verify that Wifi configuration and Passpoint configuration are removed in factoryReset. + */ + @Test + public void testFactoryReset() throws Exception { + final String fqdn = "example.com"; + WifiConfiguration network = WifiConfigurationTestUtil.createOpenNetwork(); + PasspointConfiguration config = new PasspointConfiguration(); + HomeSp homeSp = new HomeSp(); + homeSp.setFqdn(fqdn); + config.setHomeSp(homeSp); + + mWifiServiceImpl.mClientModeImplChannel = mAsyncChannel; + when(mClientModeImpl.syncGetConfiguredNetworks(anyInt(), any())) + .thenReturn(Arrays.asList(network)); + when(mClientModeImpl.syncGetPasspointConfigs(any())).thenReturn(Arrays.asList(config)); + + mWifiServiceImpl.factoryReset(TEST_PACKAGE_NAME); + + verify(mClientModeImpl).syncRemoveNetwork(mAsyncChannel, network.networkId); + verify(mClientModeImpl).syncRemovePasspointConfig(mAsyncChannel, fqdn); + } + + /** + * Verify that Passpoint configuration is not removed in factoryReset if Passpoint feature + * is not supported. + */ + @Test + public void testFactoryResetWithoutPasspointSupport() throws Exception { + mWifiServiceImpl.mClientModeImplChannel = mAsyncChannel; + when(mPackageManager.hasSystemFeature( + PackageManager.FEATURE_WIFI_PASSPOINT)).thenReturn(false); + + mWifiServiceImpl.factoryReset(TEST_PACKAGE_NAME); + + verify(mClientModeImpl).syncGetConfiguredNetworks(anyInt(), any()); + verify(mClientModeImpl, never()).syncGetPasspointConfigs(any()); + verify(mClientModeImpl, never()).syncRemovePasspointConfig(any(), anyString()); + } + + /** + * Verify that a call to factoryReset throws a SecurityException if the caller does not have + * the CONNECTIVITY_INTERNAL permission. + */ + @Test + public void testFactoryResetWithoutConnectivityInternalPermission() throws Exception { + doThrow(new SecurityException()).when(mContext) + .enforceCallingOrSelfPermission(eq(Manifest.permission.CONNECTIVITY_INTERNAL), + eq("ConnectivityService")); + mWifiServiceImpl.mClientModeImplChannel = mAsyncChannel; + + try { + mWifiServiceImpl.factoryReset(TEST_PACKAGE_NAME); + fail(); + } catch (SecurityException e) { + } + verify(mClientModeImpl, never()).syncGetConfiguredNetworks(anyInt(), any()); + verify(mClientModeImpl, never()).syncGetPasspointConfigs(any()); + } } |