From 9604af354406406dd4df72c77c676cced4f14f63 Mon Sep 17 00:00:00 2001 From: Automerger Merge Worker Date: Fri, 22 May 2020 00:27:02 +0000 Subject: [PATCH] Exit test if device does not support IPsec tunnel Bug: 155926216 Test: CtsIkeTestCases Change-Id: I4e426b8f3509e56e7e2e7532e216533ad8bfbc2f Merged-In: I4e426b8f3509e56e7e2e7532e216533ad8bfbc2f (cherry picked from commit eb70555351725a608afac0fb9f94a327e9236729) --- .../android/net/ipsec/ike/cts/IkeSessionPskTest.java | 12 +++++++++--- .../net/ipsec/ike/cts/IkeSessionTestBase.java | 6 ++++++ 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/tests/cts/net/ipsec/src/android/net/ipsec/ike/cts/IkeSessionPskTest.java b/tests/cts/net/ipsec/src/android/net/ipsec/ike/cts/IkeSessionPskTest.java index ed67dd1bd7..336d12dad1 100644 --- a/tests/cts/net/ipsec/src/android/net/ipsec/ike/cts/IkeSessionPskTest.java +++ b/tests/cts/net/ipsec/src/android/net/ipsec/ike/cts/IkeSessionPskTest.java @@ -122,7 +122,9 @@ public class IkeSessionPskTest extends IkeSessionTestBase { } @Test - public void testIkeSessionSetupAndManageChildSas() throws Exception { + public void testIkeSessionSetupAndChildSessionSetupWithTunnelMode() throws Exception { + if (!hasTunnelsFeature()) return; + // Open IKE Session IkeSession ikeSession = openIkeSession(createIkeSessionParams(mRemoteAddress)); int expectedMsgId = 0; @@ -210,7 +212,9 @@ public class IkeSessionPskTest extends IkeSessionTestBase { } @Test - public void testIkeSessionKill() throws Exception { + public void testIkeSessionKillWithTunnelMode() throws Exception { + if (!hasTunnelsFeature()) return; + // Open IKE Session IkeSession ikeSession = openIkeSession(createIkeSessionParams(mRemoteAddress)); int expectedMsgId = 0; @@ -254,5 +258,7 @@ public class IkeSessionPskTest extends IkeSessionTestBase { assertArrayEquals(EXPECTED_PROTOCOL_ERROR_DATA_NONE, protocolException.getErrorData()); } - // TODO(b/148689509): Verify rekey process and handling IKE_AUTH failure + // TODO(b/155821007): Verify rekey process and handling IKE_AUTH failure + + // TODO(b/155821007): Test creating transport mode Child SA } diff --git a/tests/cts/net/ipsec/src/android/net/ipsec/ike/cts/IkeSessionTestBase.java b/tests/cts/net/ipsec/src/android/net/ipsec/ike/cts/IkeSessionTestBase.java index deba8fd985..1c1ffc922f 100644 --- a/tests/cts/net/ipsec/src/android/net/ipsec/ike/cts/IkeSessionTestBase.java +++ b/tests/cts/net/ipsec/src/android/net/ipsec/ike/cts/IkeSessionTestBase.java @@ -20,6 +20,7 @@ import static android.app.AppOpsManager.OP_MANAGE_IPSEC_TUNNELS; import android.annotation.NonNull; import android.app.AppOpsManager; import android.content.Context; +import android.content.pm.PackageManager; import android.net.ConnectivityManager; import android.net.InetAddresses; import android.net.IpSecTransform; @@ -368,6 +369,11 @@ abstract class IkeSessionTestBase extends IkeTestBase { } } + /** Package private method to check if device has IPsec tunnels feature */ + static boolean hasTunnelsFeature() { + return sContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_IPSEC_TUNNELS); + } + // TODO(b/148689509): Verify IKE Session setup using EAP and digital-signature-based auth // TODO(b/148689509): Verify hostname based creation