summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenedict Wong <benedictwong@google.com>2019-05-08 13:25:51 -0700
committerandroid-build-merger <android-build-merger@google.com>2019-05-08 13:25:51 -0700
commited7b6a7ebfc62e87786112932b36c458dc298aa0 (patch)
tree1dd2003ae307e2601df17cae0e53641c622b6864
parent2c8318e0dc6199072c016a0cc601947b235c37a4 (diff)
parent1c1e36171819901d8a759dee379b7c55f50b6a71 (diff)
downloadcts-temp_b_131756210_stage-aosp-master.tar.gz
Merge "Check for IPSEC_TUNNELS feature before running CTS tests"temp_b_131756210_stage-aosp-master
am: 1c1e361718 Change-Id: Ia996f994fdfc373ffbe634a40cb13002128fe98d
-rw-r--r--tests/tests/net/src/android/net/cts/IpSecManagerTunnelTest.java13
1 files changed, 13 insertions, 0 deletions
diff --git a/tests/tests/net/src/android/net/cts/IpSecManagerTunnelTest.java b/tests/tests/net/src/android/net/cts/IpSecManagerTunnelTest.java
index 5dc9b63b879..c8c99f4a376 100644
--- a/tests/tests/net/src/android/net/cts/IpSecManagerTunnelTest.java
+++ b/tests/tests/net/src/android/net/cts/IpSecManagerTunnelTest.java
@@ -21,6 +21,7 @@ import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
+import android.content.pm.PackageManager;
import android.net.IpSecAlgorithm;
import android.net.IpSecManager;
import android.net.IpSecTransform;
@@ -56,6 +57,12 @@ public class IpSecManagerTunnelTest extends IpSecBaseTest {
setAppop(false);
}
+ private boolean hasTunnelsFeature() {
+ return getContext()
+ .getPackageManager()
+ .hasSystemFeature(PackageManager.FEATURE_IPSEC_TUNNELS);
+ }
+
private void setAppop(boolean allow) {
// Under normal circumstances, the MANAGE_IPSEC_TUNNELS appop would be auto-granted by the
// telephony framework, and the only permission that is sufficient is NETWORK_STACK. So we
@@ -69,6 +76,8 @@ public class IpSecManagerTunnelTest extends IpSecBaseTest {
}
public void testSecurityExceptionsCreateTunnelInterface() throws Exception {
+ if (!hasTunnelsFeature()) return;
+
// Ensure we don't have the appop. Permission is not requested in the Manifest
setAppop(false);
@@ -81,6 +90,8 @@ public class IpSecManagerTunnelTest extends IpSecBaseTest {
}
public void testSecurityExceptionsBuildTunnelTransform() throws Exception {
+ if (!hasTunnelsFeature()) return;
+
// Ensure we don't have the appop. Permission is not requested in the Manifest
setAppop(false);
@@ -97,6 +108,8 @@ public class IpSecManagerTunnelTest extends IpSecBaseTest {
private void checkTunnel(InetAddress inner, InetAddress outer, boolean useEncap)
throws Exception {
+ if (!hasTunnelsFeature()) return;
+
setAppop(true);
int innerPrefixLen = inner instanceof Inet6Address ? IP6_PREFIX_LEN : IP4_PREFIX_LEN;