diff options
author | 2020-05-01 10:12:51 -0600 | |
---|---|---|
committer | 2020-05-01 10:14:13 -0600 | |
commit | f81e9e9dc38abff8c805db77f853338bd61a3ab9 (patch) | |
tree | ad0623ad402be31f9f27d0acaebf852eca5ca2da | |
parent | 64b88db3d279e63301e150c1cd150f6f60451d65 (diff) |
More cross-user Uri granting tests.
Bug: 155466646
Test: atest FrameworksServicesTests:com.android.server.uri
Change-Id: I6bc958b0cce5ecd876bfb14f53a552e470b61fe4
-rw-r--r-- | services/tests/servicestests/src/com/android/server/uri/UriGrantsManagerServiceTest.java | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/services/tests/servicestests/src/com/android/server/uri/UriGrantsManagerServiceTest.java b/services/tests/servicestests/src/com/android/server/uri/UriGrantsManagerServiceTest.java index e5486473e93b..0e48e7ed2682 100644 --- a/services/tests/servicestests/src/com/android/server/uri/UriGrantsManagerServiceTest.java +++ b/services/tests/servicestests/src/com/android/server/uri/UriGrantsManagerServiceTest.java @@ -70,8 +70,12 @@ public class UriGrantsManagerServiceTest { mLocalService = mService.getLocalService(); } + /** + * Verify that a camera sharing a normally-private photo with a social media + * app in the same user issues a grant. + */ @Test - public void testNeeded_normal() { + public void testNeeded_normal_sameUser() { final Intent intent = new Intent(Intent.ACTION_VIEW, URI_PHOTO_1).addFlags(FLAG_READ); final GrantUri expectedGrant = new GrantUri(USER_PRIMARY, URI_PHOTO_1, FLAG_READ); @@ -85,6 +89,24 @@ public class UriGrantsManagerServiceTest { } /** + * Verify that a camera sharing a normally-private photo with a social media + * app in a different user issues a grant. + */ + @Test + public void testNeeded_normal_differentUser() { + final Intent intent = new Intent(Intent.ACTION_VIEW, URI_PHOTO_1).addFlags(FLAG_READ); + final GrantUri expectedGrant = new GrantUri(USER_PRIMARY, URI_PHOTO_1, FLAG_READ); + + final NeededUriGrants needed = mService.checkGrantUriPermissionFromIntent( + UID_PRIMARY_CAMERA, PKG_SOCIAL, intent, intent.getFlags(), null, + USER_SECONDARY); + assertEquals(PKG_SOCIAL, needed.targetPkg); + assertEquals(UID_SECONDARY_SOCIAL, needed.targetUid); + assertEquals(FLAG_READ, needed.flags); + assertEquals(asSet(expectedGrant), needed.uris); + } + + /** * No need to issue grants for public authorities. */ @Test |