diff options
author | Benedict Wong <benedictwong@google.com> | 2021-04-20 15:09:43 -0700 |
---|---|---|
committer | Benedict Wong <benedictwong@google.com> | 2021-04-21 13:49:14 -0700 |
commit | 6e8c1d6da72fb4358f033ef86ff57e312bd58dc0 (patch) | |
tree | 67b1bbabac889590e8321a2f49aedb6bb9e2c7cb /tests/vcn/java/com/android/server/VcnManagementServiceTest.java | |
parent | 598675abefa4dbd5d1d3404256a7a4d92032d88b (diff) |
Add support for retrieval of configured VCNs by carrier privilege
This change adds support for retrieval of a list of subscription groups
that have a VCN configured.
Bug: 184612525
Test: atest FrameworksVcnTests
Change-Id: I40553a7bb45d9b1f948c7d0a791f1b22a422d55c
Diffstat (limited to 'tests/vcn/java/com/android/server/VcnManagementServiceTest.java')
-rw-r--r-- | tests/vcn/java/com/android/server/VcnManagementServiceTest.java | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/tests/vcn/java/com/android/server/VcnManagementServiceTest.java b/tests/vcn/java/com/android/server/VcnManagementServiceTest.java index bbc9bb600f6d..38d2bb1c954a 100644 --- a/tests/vcn/java/com/android/server/VcnManagementServiceTest.java +++ b/tests/vcn/java/com/android/server/VcnManagementServiceTest.java @@ -96,6 +96,7 @@ import org.mockito.ArgumentCaptor; import java.io.FileNotFoundException; import java.util.Collections; +import java.util.List; import java.util.Map; import java.util.Set; import java.util.UUID; @@ -617,6 +618,43 @@ public class VcnManagementServiceTest { } @Test + public void testGetConfiguredSubscriptionGroupsRequiresSystemUser() throws Exception { + doReturn(UserHandle.getUid(UserHandle.MIN_SECONDARY_USER_ID, TEST_UID)) + .when(mMockDeps) + .getBinderCallingUid(); + + try { + mVcnMgmtSvc.getConfiguredSubscriptionGroups(TEST_PACKAGE_NAME); + fail("Expected security exception for non system user"); + } catch (SecurityException expected) { + } + } + + @Test + public void testGetConfiguredSubscriptionGroupsMismatchedPackages() throws Exception { + final String badPackage = "IncorrectPackage"; + doThrow(new SecurityException()).when(mAppOpsMgr).checkPackage(TEST_UID, badPackage); + + try { + mVcnMgmtSvc.getConfiguredSubscriptionGroups(badPackage); + fail("Expected security exception due to mismatched packages"); + } catch (SecurityException expected) { + } + } + + @Test + public void testGetConfiguredSubscriptionGroups() throws Exception { + mVcnMgmtSvc.setVcnConfig(TEST_UUID_2, TEST_VCN_CONFIG, TEST_PACKAGE_NAME); + + // Assert that if both UUID 1 and 2 are provisioned, the caller only gets ones that they are + // privileged for. + triggerSubscriptionTrackerCbAndGetSnapshot(Collections.singleton(TEST_UUID_1)); + final List<ParcelUuid> subGrps = + mVcnMgmtSvc.getConfiguredSubscriptionGroups(TEST_PACKAGE_NAME); + assertEquals(Collections.singletonList(TEST_UUID_1), subGrps); + } + + @Test public void testAddVcnUnderlyingNetworkPolicyListener() throws Exception { mVcnMgmtSvc.addVcnUnderlyingNetworkPolicyListener(mMockPolicyListener); |