diff options
author | Ecco Park <eccopark@google.com> | 2019-01-16 09:36:27 -0800 |
---|---|---|
committer | Ecco Park <eccopark@google.com> | 2019-01-16 11:53:57 -0800 |
commit | 996891e9bf2b070a56d6e279ea1c986e0cddc10c (patch) | |
tree | 01687106f6296507669119800a3a8477f2369233 /tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java | |
parent | b30c28a7a5208e26cffda888556ae6d2720cc0fc (diff) | |
download | android_frameworks_opt_net_wifi-996891e9bf2b070a56d6e279ea1c986e0cddc10c.tar.gz android_frameworks_opt_net_wifi-996891e9bf2b070a56d6e279ea1c986e0cddc10c.tar.bz2 android_frameworks_opt_net_wifi-996891e9bf2b070a56d6e279ea1c986e0cddc10c.zip |
passpoint-r2: check a permission for NETWORK_SETTINGS and NETWORK_SETUP_WIZARD.
All Passpoint-r2 apis should be checked for the permissions.
Bug: 119514793
Test: ./frameworks/opt/net/wifi/tests/wifitests/runtests.sh
Change-Id: I9089c150c8c7aab4d74b4a89e8a8e006c73eaaf5
Signed-off-by: Ecco Park <eccopark@google.com>
Diffstat (limited to 'tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java')
-rw-r--r-- | tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java | 82 |
1 files changed, 77 insertions, 5 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java b/tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java index 2248e4645..3d82f9016 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java @@ -2172,6 +2172,74 @@ public class WifiServiceImplTest { } /** + * Verify that the call to getAllMatchingFqdnsForScanResults is not redirected to specific API + * syncGetAllMatchingFqdnsForScanResults when the caller doesn't have NETWORK_SETTINGS + * permissions and NETWORK_SETUP_WIZARD. + */ + @Test(expected = SecurityException.class) + public void testGetAllMatchingFqdnsForScanResultsWithOutPermissions() { + when(mContext.checkCallingOrSelfPermission( + eq(android.Manifest.permission.NETWORK_SETTINGS))).thenReturn( + PackageManager.PERMISSION_DENIED); + when(mContext.checkSelfPermission( + eq(android.Manifest.permission.NETWORK_SETUP_WIZARD))).thenReturn( + PackageManager.PERMISSION_DENIED); + + mWifiServiceImpl.getAllMatchingFqdnsForScanResults(new ArrayList<>()); + } + + /** + * Verify that the call to getWifiConfigsForPasspointProfiles is not redirected to specific API + * syncGetWifiConfigsForPasspointProfiles when the caller doesn't have NETWORK_SETTINGS + * permissions and NETWORK_SETUP_WIZARD. + */ + @Test(expected = SecurityException.class) + public void testGetWifiConfigsForPasspointProfilesWithOutPermissions() { + when(mContext.checkCallingOrSelfPermission( + eq(android.Manifest.permission.NETWORK_SETTINGS))).thenReturn( + PackageManager.PERMISSION_DENIED); + when(mContext.checkSelfPermission( + eq(android.Manifest.permission.NETWORK_SETUP_WIZARD))).thenReturn( + PackageManager.PERMISSION_DENIED); + + mWifiServiceImpl.getWifiConfigsForPasspointProfiles(new ArrayList<>()); + } + + /** + * Verify that the call to getMatchingOsuProviders is not redirected to specific API + * syncGetMatchingOsuProviders when the caller doesn't have NETWORK_SETTINGS + * permissions and NETWORK_SETUP_WIZARD. + */ + @Test(expected = SecurityException.class) + public void testGetMatchingOsuProvidersWithOutPermissions() { + when(mContext.checkCallingOrSelfPermission( + eq(android.Manifest.permission.NETWORK_SETTINGS))).thenReturn( + PackageManager.PERMISSION_DENIED); + when(mContext.checkSelfPermission( + eq(android.Manifest.permission.NETWORK_SETUP_WIZARD))).thenReturn( + PackageManager.PERMISSION_DENIED); + + mWifiServiceImpl.getMatchingOsuProviders(new ArrayList<>()); + } + + /** + * Verify that the call to getMatchingPasspointConfigsForOsuProviders is not redirected to + * specific API syncGetMatchingPasspointConfigsForOsuProviders when the caller doesn't have + * NETWORK_SETTINGS permissions and NETWORK_SETUP_WIZARD. + */ + @Test(expected = SecurityException.class) + public void testGetMatchingPasspointConfigsForOsuProvidersWithOutPermissions() { + when(mContext.checkCallingOrSelfPermission( + eq(android.Manifest.permission.NETWORK_SETTINGS))).thenReturn( + PackageManager.PERMISSION_DENIED); + when(mContext.checkSelfPermission( + eq(android.Manifest.permission.NETWORK_SETUP_WIZARD))).thenReturn( + PackageManager.PERMISSION_DENIED); + + mWifiServiceImpl.getMatchingPasspointConfigsForOsuProviders(new ArrayList<>()); + } + + /** * Verify that the call to startSubscriptionProvisioning is redirected to the Passpoint * specific API startSubscriptionProvisioning when the caller has the right permissions. */ @@ -2215,13 +2283,17 @@ public class WifiServiceImplTest { /** * Verify that the call to startSubscriptionProvisioning is not redirected to the Passpoint * specific API startSubscriptionProvisioning when the caller doesn't have NETWORK_SETTINGS - * permissions. + * permissions and NETWORK_SETUP_WIZARD. */ @Test(expected = SecurityException.class) - public void testStartSubscriptionProvisioningWithoutPermission() throws Exception { - doThrow(new SecurityException()).when(mContext) - .enforceCallingOrSelfPermission(eq(android.Manifest.permission.NETWORK_SETTINGS), - eq("WifiService")); + public void testStartSubscriptionProvisioningWithoutPermissions() throws Exception { + when(mContext.checkCallingOrSelfPermission( + eq(android.Manifest.permission.NETWORK_SETTINGS))).thenReturn( + PackageManager.PERMISSION_DENIED); + when(mContext.checkSelfPermission( + eq(android.Manifest.permission.NETWORK_SETUP_WIZARD))).thenReturn( + PackageManager.PERMISSION_DENIED); + mWifiServiceImpl.startSubscriptionProvisioning(mOsuProvider, mProvisioningCallback); } |