From 677a1c155474d3023e81d38962213ba3e0fc5e32 Mon Sep 17 00:00:00 2001 From: evitayan Date: Wed, 6 May 2020 18:47:53 -0700 Subject: [PATCH] Exit test if device does not support IPsec tunnel Bug: 155926216 Test: CtsIkeTestCases Change-Id: I4e426b8f3509e56e7e2e7532e216533ad8bfbc2f --- .../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