summaryrefslogtreecommitdiff
path: root/tests/vcn/java/com/android/server/VcnManagementServiceTest.java
diff options
context:
space:
mode:
authorCody Kesting <ckesting@google.com>2021-05-07 10:49:27 -0700
committerCody Kesting <ckesting@google.com>2021-05-11 18:32:32 -0700
commitfd57083e391763a91bb078289b90867728ed5860 (patch)
tree5eb26c7385ef7a8db6a3da4323b667d1e0a13511 /tests/vcn/java/com/android/server/VcnManagementServiceTest.java
parent92959d677495644ed7c1bf6bb895bb5c3c148596 (diff)
Create test-mode for VcnConfig.
This CL creates a test-mode for VcnConfig so that they will only match with Test Networks. This is necessary for CTS testing so that VCNs can run on test networks and IKE negotiations can be injected over the Test Networks. Bug: 182291467 Test: atest FrameworksVcnTests CtsVcnTestCases Change-Id: I5cc340e5aaa34c5de8efafa52de49185a18d4bd3
Diffstat (limited to 'tests/vcn/java/com/android/server/VcnManagementServiceTest.java')
-rw-r--r--tests/vcn/java/com/android/server/VcnManagementServiceTest.java23
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/vcn/java/com/android/server/VcnManagementServiceTest.java b/tests/vcn/java/com/android/server/VcnManagementServiceTest.java
index 9ecd82ff6bcb..8d87348ac48f 100644
--- a/tests/vcn/java/com/android/server/VcnManagementServiceTest.java
+++ b/tests/vcn/java/com/android/server/VcnManagementServiceTest.java
@@ -66,6 +66,7 @@ import android.net.vcn.IVcnStatusCallback;
import android.net.vcn.IVcnUnderlyingNetworkPolicyListener;
import android.net.vcn.VcnConfig;
import android.net.vcn.VcnConfigTest;
+import android.net.vcn.VcnGatewayConnectionConfigTest;
import android.net.vcn.VcnManager;
import android.net.vcn.VcnUnderlyingNetworkPolicy;
import android.os.IBinder;
@@ -528,6 +529,28 @@ public class VcnManagementServiceTest {
}
@Test
+ public void testSetVcnConfigTestModeRequiresPermission() throws Exception {
+ doThrow(new SecurityException("Requires MANAGE_TEST_NETWORKS"))
+ .when(mMockContext)
+ .enforceCallingPermission(
+ eq(android.Manifest.permission.MANAGE_TEST_NETWORKS), any());
+
+ final VcnConfig vcnConfig =
+ new VcnConfig.Builder(mMockContext)
+ .addGatewayConnectionConfig(
+ VcnGatewayConnectionConfigTest.buildTestConfig())
+ .setIsTestModeProfile()
+ .build();
+
+ try {
+ mVcnMgmtSvc.setVcnConfig(TEST_UUID_2, vcnConfig, TEST_PACKAGE_NAME);
+ fail("Expected exception due to using test-mode without permission");
+ } catch (SecurityException e) {
+ verify(mMockPolicyListener, never()).onPolicyChanged();
+ }
+ }
+
+ @Test
public void testSetVcnConfigNotifiesStatusCallback() throws Exception {
triggerSubscriptionTrackerCbAndGetSnapshot(Collections.singleton(TEST_UUID_2));