Convert IPsec tests to JUnit4
This patch fixes an incompatibility where some tests in the same hierarchy were using Junit3, and other Junit4 No functional test changes made Bug: 72950854 Test: Ran on devices, working Change-Id: I79d231e202ba25ad5f57b44b387bebd7f012aa95
This commit is contained in:
@@ -25,10 +25,10 @@ import android.net.IpSecManager;
|
||||
import android.net.IpSecTransform;
|
||||
import android.system.Os;
|
||||
import android.system.OsConstants;
|
||||
import android.test.AndroidTestCase;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.test.InstrumentationRegistry;
|
||||
import androidx.test.runner.AndroidJUnit4;
|
||||
|
||||
import java.io.FileDescriptor;
|
||||
import java.io.IOException;
|
||||
@@ -43,7 +43,12 @@ import java.net.SocketException;
|
||||
import java.util.Arrays;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
public class IpSecBaseTest extends AndroidTestCase {
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public class IpSecBaseTest {
|
||||
|
||||
private static final String TAG = IpSecBaseTest.class.getSimpleName();
|
||||
|
||||
@@ -70,9 +75,11 @@ public class IpSecBaseTest extends AndroidTestCase {
|
||||
|
||||
protected ConnectivityManager mCM;
|
||||
protected IpSecManager mISM;
|
||||
protected Context mContext;
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
mContext = InstrumentationRegistry.getContext();
|
||||
mISM =
|
||||
(IpSecManager)
|
||||
InstrumentationRegistry.getContext()
|
||||
@@ -471,6 +478,7 @@ public class IpSecBaseTest extends AndroidTestCase {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testJavaTcpSocketPair() throws Exception {
|
||||
for (String addr : LOOPBACK_ADDRS) {
|
||||
InetAddress local = InetAddress.getByName(addr);
|
||||
@@ -481,6 +489,7 @@ public class IpSecBaseTest extends AndroidTestCase {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testJavaUdpSocketPair() throws Exception {
|
||||
for (String addr : LOOPBACK_ADDRS) {
|
||||
InetAddress local = InetAddress.getByName(addr);
|
||||
@@ -492,6 +501,7 @@ public class IpSecBaseTest extends AndroidTestCase {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testJavaUdpSocketPairUnconnected() throws Exception {
|
||||
for (String addr : LOOPBACK_ADDRS) {
|
||||
InetAddress local = InetAddress.getByName(addr);
|
||||
@@ -503,6 +513,7 @@ public class IpSecBaseTest extends AndroidTestCase {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNativeTcpSocketPair() throws Exception {
|
||||
for (String addr : LOOPBACK_ADDRS) {
|
||||
InetAddress local = InetAddress.getByName(addr);
|
||||
@@ -514,6 +525,7 @@ public class IpSecBaseTest extends AndroidTestCase {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNativeUdpSocketPair() throws Exception {
|
||||
for (String addr : LOOPBACK_ADDRS) {
|
||||
InetAddress local = InetAddress.getByName(addr);
|
||||
@@ -525,6 +537,7 @@ public class IpSecBaseTest extends AndroidTestCase {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNativeUdpSocketPairUnconnected() throws Exception {
|
||||
for (String addr : LOOPBACK_ADDRS) {
|
||||
InetAddress local = InetAddress.getByName(addr);
|
||||
|
||||
@@ -27,7 +27,9 @@ import static android.net.cts.PacketUtils.UDP_HDRLEN;
|
||||
import static android.system.OsConstants.IPPROTO_TCP;
|
||||
import static android.system.OsConstants.IPPROTO_UDP;
|
||||
import static org.junit.Assert.assertArrayEquals;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import android.net.IpSecAlgorithm;
|
||||
import android.net.IpSecManager;
|
||||
@@ -37,6 +39,8 @@ import android.system.ErrnoException;
|
||||
import android.system.Os;
|
||||
import android.system.OsConstants;
|
||||
|
||||
import androidx.test.runner.AndroidJUnit4;
|
||||
|
||||
import java.io.FileDescriptor;
|
||||
import java.io.IOException;
|
||||
import java.net.DatagramPacket;
|
||||
@@ -45,6 +49,11 @@ import java.net.Inet6Address;
|
||||
import java.net.InetAddress;
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public class IpSecManagerTest extends IpSecBaseTest {
|
||||
|
||||
private static final String TAG = IpSecManagerTest.class.getSimpleName();
|
||||
@@ -61,7 +70,9 @@ public class IpSecManagerTest extends IpSecBaseTest {
|
||||
|
||||
private static final byte[] AEAD_KEY = getKey(288);
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
@Before
|
||||
@Override
|
||||
public void setUp() throws Exception {
|
||||
super.setUp();
|
||||
}
|
||||
|
||||
@@ -71,6 +82,7 @@ public class IpSecManagerTest extends IpSecBaseTest {
|
||||
* Realloc the same SPI that was specifically created (expect SpiUnavailable)
|
||||
* Close SPIs
|
||||
*/
|
||||
@Test
|
||||
public void testAllocSpi() throws Exception {
|
||||
for (InetAddress addr : GOOGLE_DNS_LIST) {
|
||||
IpSecManager.SecurityParameterIndex randomSpi = null, droidSpi = null;
|
||||
@@ -222,6 +234,7 @@ public class IpSecManagerTest extends IpSecBaseTest {
|
||||
* release transform
|
||||
* send data (expect exception)
|
||||
*/
|
||||
@Test
|
||||
public void testCreateTransform() throws Exception {
|
||||
InetAddress localAddr = InetAddress.getByName(IPV4_LOOPBACK);
|
||||
IpSecManager.SecurityParameterIndex spi =
|
||||
@@ -591,6 +604,7 @@ public class IpSecManagerTest extends IpSecBaseTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIkeOverUdpEncapSocket() throws Exception {
|
||||
// IPv6 not supported for UDP-encap-ESP
|
||||
InetAddress local = InetAddress.getByName(IPV4_LOOPBACK);
|
||||
@@ -649,24 +663,28 @@ public class IpSecManagerTest extends IpSecBaseTest {
|
||||
// checkTransform(IPPROTO_TCP, IPV4_LOOPBACK, crypt, auth, true, 1000);
|
||||
// }
|
||||
|
||||
@Test
|
||||
public void testInterfaceCountersUdp4() throws Exception {
|
||||
IpSecAlgorithm crypt = new IpSecAlgorithm(IpSecAlgorithm.CRYPT_AES_CBC, CRYPT_KEY);
|
||||
IpSecAlgorithm auth = new IpSecAlgorithm(IpSecAlgorithm.AUTH_HMAC_MD5, getKey(128), 96);
|
||||
checkTransform(IPPROTO_UDP, IPV4_LOOPBACK, crypt, auth, null, false, 1000, false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInterfaceCountersUdp6() throws Exception {
|
||||
IpSecAlgorithm crypt = new IpSecAlgorithm(IpSecAlgorithm.CRYPT_AES_CBC, CRYPT_KEY);
|
||||
IpSecAlgorithm auth = new IpSecAlgorithm(IpSecAlgorithm.AUTH_HMAC_MD5, getKey(128), 96);
|
||||
checkTransform(IPPROTO_UDP, IPV6_LOOPBACK, crypt, auth, null, false, 1000, false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInterfaceCountersUdp4UdpEncap() throws Exception {
|
||||
IpSecAlgorithm crypt = new IpSecAlgorithm(IpSecAlgorithm.CRYPT_AES_CBC, CRYPT_KEY);
|
||||
IpSecAlgorithm auth = new IpSecAlgorithm(IpSecAlgorithm.AUTH_HMAC_MD5, getKey(128), 96);
|
||||
checkTransform(IPPROTO_UDP, IPV4_LOOPBACK, crypt, auth, null, true, 1000, false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAesCbcHmacMd5Tcp4() throws Exception {
|
||||
IpSecAlgorithm crypt = new IpSecAlgorithm(IpSecAlgorithm.CRYPT_AES_CBC, CRYPT_KEY);
|
||||
IpSecAlgorithm auth = new IpSecAlgorithm(IpSecAlgorithm.AUTH_HMAC_MD5, getKey(128), 96);
|
||||
@@ -674,6 +692,7 @@ public class IpSecManagerTest extends IpSecBaseTest {
|
||||
checkTransform(IPPROTO_TCP, IPV4_LOOPBACK, crypt, auth, null, false, 1, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAesCbcHmacMd5Tcp6() throws Exception {
|
||||
IpSecAlgorithm crypt = new IpSecAlgorithm(IpSecAlgorithm.CRYPT_AES_CBC, CRYPT_KEY);
|
||||
IpSecAlgorithm auth = new IpSecAlgorithm(IpSecAlgorithm.AUTH_HMAC_MD5, getKey(128), 96);
|
||||
@@ -681,6 +700,7 @@ public class IpSecManagerTest extends IpSecBaseTest {
|
||||
checkTransform(IPPROTO_TCP, IPV6_LOOPBACK, crypt, auth, null, false, 1, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAesCbcHmacMd5Udp4() throws Exception {
|
||||
IpSecAlgorithm crypt = new IpSecAlgorithm(IpSecAlgorithm.CRYPT_AES_CBC, CRYPT_KEY);
|
||||
IpSecAlgorithm auth = new IpSecAlgorithm(IpSecAlgorithm.AUTH_HMAC_MD5, getKey(128), 96);
|
||||
@@ -688,6 +708,7 @@ public class IpSecManagerTest extends IpSecBaseTest {
|
||||
checkTransform(IPPROTO_UDP, IPV4_LOOPBACK, crypt, auth, null, false, 1, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAesCbcHmacMd5Udp6() throws Exception {
|
||||
IpSecAlgorithm crypt = new IpSecAlgorithm(IpSecAlgorithm.CRYPT_AES_CBC, CRYPT_KEY);
|
||||
IpSecAlgorithm auth = new IpSecAlgorithm(IpSecAlgorithm.AUTH_HMAC_MD5, getKey(128), 96);
|
||||
@@ -695,6 +716,7 @@ public class IpSecManagerTest extends IpSecBaseTest {
|
||||
checkTransform(IPPROTO_UDP, IPV6_LOOPBACK, crypt, auth, null, false, 1, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAesCbcHmacSha1Tcp4() throws Exception {
|
||||
IpSecAlgorithm crypt = new IpSecAlgorithm(IpSecAlgorithm.CRYPT_AES_CBC, CRYPT_KEY);
|
||||
IpSecAlgorithm auth = new IpSecAlgorithm(IpSecAlgorithm.AUTH_HMAC_SHA1, getKey(160), 96);
|
||||
@@ -702,6 +724,7 @@ public class IpSecManagerTest extends IpSecBaseTest {
|
||||
checkTransform(IPPROTO_TCP, IPV4_LOOPBACK, crypt, auth, null, false, 1, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAesCbcHmacSha1Tcp6() throws Exception {
|
||||
IpSecAlgorithm crypt = new IpSecAlgorithm(IpSecAlgorithm.CRYPT_AES_CBC, CRYPT_KEY);
|
||||
IpSecAlgorithm auth = new IpSecAlgorithm(IpSecAlgorithm.AUTH_HMAC_SHA1, getKey(160), 96);
|
||||
@@ -709,6 +732,7 @@ public class IpSecManagerTest extends IpSecBaseTest {
|
||||
checkTransform(IPPROTO_TCP, IPV6_LOOPBACK, crypt, auth, null, false, 1, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAesCbcHmacSha1Udp4() throws Exception {
|
||||
IpSecAlgorithm crypt = new IpSecAlgorithm(IpSecAlgorithm.CRYPT_AES_CBC, CRYPT_KEY);
|
||||
IpSecAlgorithm auth = new IpSecAlgorithm(IpSecAlgorithm.AUTH_HMAC_SHA1, getKey(160), 96);
|
||||
@@ -716,6 +740,7 @@ public class IpSecManagerTest extends IpSecBaseTest {
|
||||
checkTransform(IPPROTO_UDP, IPV4_LOOPBACK, crypt, auth, null, false, 1, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAesCbcHmacSha1Udp6() throws Exception {
|
||||
IpSecAlgorithm crypt = new IpSecAlgorithm(IpSecAlgorithm.CRYPT_AES_CBC, CRYPT_KEY);
|
||||
IpSecAlgorithm auth = new IpSecAlgorithm(IpSecAlgorithm.AUTH_HMAC_SHA1, getKey(160), 96);
|
||||
@@ -723,6 +748,7 @@ public class IpSecManagerTest extends IpSecBaseTest {
|
||||
checkTransform(IPPROTO_UDP, IPV6_LOOPBACK, crypt, auth, null, false, 1, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAesCbcHmacSha256Tcp4() throws Exception {
|
||||
IpSecAlgorithm crypt = new IpSecAlgorithm(IpSecAlgorithm.CRYPT_AES_CBC, CRYPT_KEY);
|
||||
IpSecAlgorithm auth = new IpSecAlgorithm(IpSecAlgorithm.AUTH_HMAC_SHA256, getKey(256), 128);
|
||||
@@ -730,6 +756,7 @@ public class IpSecManagerTest extends IpSecBaseTest {
|
||||
checkTransform(IPPROTO_TCP, IPV4_LOOPBACK, crypt, auth, null, false, 1, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAesCbcHmacSha256Tcp6() throws Exception {
|
||||
IpSecAlgorithm crypt = new IpSecAlgorithm(IpSecAlgorithm.CRYPT_AES_CBC, CRYPT_KEY);
|
||||
IpSecAlgorithm auth = new IpSecAlgorithm(IpSecAlgorithm.AUTH_HMAC_SHA256, getKey(256), 128);
|
||||
@@ -737,6 +764,7 @@ public class IpSecManagerTest extends IpSecBaseTest {
|
||||
checkTransform(IPPROTO_TCP, IPV6_LOOPBACK, crypt, auth, null, false, 1, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAesCbcHmacSha256Udp4() throws Exception {
|
||||
IpSecAlgorithm crypt = new IpSecAlgorithm(IpSecAlgorithm.CRYPT_AES_CBC, CRYPT_KEY);
|
||||
IpSecAlgorithm auth = new IpSecAlgorithm(IpSecAlgorithm.AUTH_HMAC_SHA256, getKey(256), 128);
|
||||
@@ -744,6 +772,7 @@ public class IpSecManagerTest extends IpSecBaseTest {
|
||||
checkTransform(IPPROTO_UDP, IPV4_LOOPBACK, crypt, auth, null, false, 1, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAesCbcHmacSha256Udp6() throws Exception {
|
||||
IpSecAlgorithm crypt = new IpSecAlgorithm(IpSecAlgorithm.CRYPT_AES_CBC, CRYPT_KEY);
|
||||
IpSecAlgorithm auth = new IpSecAlgorithm(IpSecAlgorithm.AUTH_HMAC_SHA256, getKey(256), 128);
|
||||
@@ -751,6 +780,7 @@ public class IpSecManagerTest extends IpSecBaseTest {
|
||||
checkTransform(IPPROTO_UDP, IPV6_LOOPBACK, crypt, auth, null, false, 1, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAesCbcHmacSha384Tcp4() throws Exception {
|
||||
IpSecAlgorithm crypt = new IpSecAlgorithm(IpSecAlgorithm.CRYPT_AES_CBC, CRYPT_KEY);
|
||||
IpSecAlgorithm auth = new IpSecAlgorithm(IpSecAlgorithm.AUTH_HMAC_SHA384, getKey(384), 192);
|
||||
@@ -758,6 +788,7 @@ public class IpSecManagerTest extends IpSecBaseTest {
|
||||
checkTransform(IPPROTO_TCP, IPV4_LOOPBACK, crypt, auth, null, false, 1, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAesCbcHmacSha384Tcp6() throws Exception {
|
||||
IpSecAlgorithm crypt = new IpSecAlgorithm(IpSecAlgorithm.CRYPT_AES_CBC, CRYPT_KEY);
|
||||
IpSecAlgorithm auth = new IpSecAlgorithm(IpSecAlgorithm.AUTH_HMAC_SHA384, getKey(384), 192);
|
||||
@@ -765,6 +796,7 @@ public class IpSecManagerTest extends IpSecBaseTest {
|
||||
checkTransform(IPPROTO_TCP, IPV6_LOOPBACK, crypt, auth, null, false, 1, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAesCbcHmacSha384Udp4() throws Exception {
|
||||
IpSecAlgorithm crypt = new IpSecAlgorithm(IpSecAlgorithm.CRYPT_AES_CBC, CRYPT_KEY);
|
||||
IpSecAlgorithm auth = new IpSecAlgorithm(IpSecAlgorithm.AUTH_HMAC_SHA384, getKey(384), 192);
|
||||
@@ -772,6 +804,7 @@ public class IpSecManagerTest extends IpSecBaseTest {
|
||||
checkTransform(IPPROTO_UDP, IPV4_LOOPBACK, crypt, auth, null, false, 1, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAesCbcHmacSha384Udp6() throws Exception {
|
||||
IpSecAlgorithm crypt = new IpSecAlgorithm(IpSecAlgorithm.CRYPT_AES_CBC, CRYPT_KEY);
|
||||
IpSecAlgorithm auth = new IpSecAlgorithm(IpSecAlgorithm.AUTH_HMAC_SHA384, getKey(384), 192);
|
||||
@@ -779,6 +812,7 @@ public class IpSecManagerTest extends IpSecBaseTest {
|
||||
checkTransform(IPPROTO_UDP, IPV6_LOOPBACK, crypt, auth, null, false, 1, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAesCbcHmacSha512Tcp4() throws Exception {
|
||||
IpSecAlgorithm crypt = new IpSecAlgorithm(IpSecAlgorithm.CRYPT_AES_CBC, CRYPT_KEY);
|
||||
IpSecAlgorithm auth = new IpSecAlgorithm(IpSecAlgorithm.AUTH_HMAC_SHA512, getKey(512), 256);
|
||||
@@ -786,6 +820,7 @@ public class IpSecManagerTest extends IpSecBaseTest {
|
||||
checkTransform(IPPROTO_TCP, IPV4_LOOPBACK, crypt, auth, null, false, 1, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAesCbcHmacSha512Tcp6() throws Exception {
|
||||
IpSecAlgorithm crypt = new IpSecAlgorithm(IpSecAlgorithm.CRYPT_AES_CBC, CRYPT_KEY);
|
||||
IpSecAlgorithm auth = new IpSecAlgorithm(IpSecAlgorithm.AUTH_HMAC_SHA512, getKey(512), 256);
|
||||
@@ -793,6 +828,7 @@ public class IpSecManagerTest extends IpSecBaseTest {
|
||||
checkTransform(IPPROTO_TCP, IPV6_LOOPBACK, crypt, auth, null, false, 1, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAesCbcHmacSha512Udp4() throws Exception {
|
||||
IpSecAlgorithm crypt = new IpSecAlgorithm(IpSecAlgorithm.CRYPT_AES_CBC, CRYPT_KEY);
|
||||
IpSecAlgorithm auth = new IpSecAlgorithm(IpSecAlgorithm.AUTH_HMAC_SHA512, getKey(512), 256);
|
||||
@@ -800,6 +836,7 @@ public class IpSecManagerTest extends IpSecBaseTest {
|
||||
checkTransform(IPPROTO_UDP, IPV4_LOOPBACK, crypt, auth, null, false, 1, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAesCbcHmacSha512Udp6() throws Exception {
|
||||
IpSecAlgorithm crypt = new IpSecAlgorithm(IpSecAlgorithm.CRYPT_AES_CBC, CRYPT_KEY);
|
||||
IpSecAlgorithm auth = new IpSecAlgorithm(IpSecAlgorithm.AUTH_HMAC_SHA512, getKey(512), 256);
|
||||
@@ -807,6 +844,7 @@ public class IpSecManagerTest extends IpSecBaseTest {
|
||||
checkTransform(IPPROTO_UDP, IPV6_LOOPBACK, crypt, auth, null, false, 1, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAesGcm64Tcp4() throws Exception {
|
||||
IpSecAlgorithm authCrypt =
|
||||
new IpSecAlgorithm(IpSecAlgorithm.AUTH_CRYPT_AES_GCM, AEAD_KEY, 64);
|
||||
@@ -814,6 +852,7 @@ public class IpSecManagerTest extends IpSecBaseTest {
|
||||
checkTransform(IPPROTO_TCP, IPV4_LOOPBACK, null, null, authCrypt, false, 1, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAesGcm64Tcp6() throws Exception {
|
||||
IpSecAlgorithm authCrypt =
|
||||
new IpSecAlgorithm(IpSecAlgorithm.AUTH_CRYPT_AES_GCM, AEAD_KEY, 64);
|
||||
@@ -821,6 +860,7 @@ public class IpSecManagerTest extends IpSecBaseTest {
|
||||
checkTransform(IPPROTO_TCP, IPV6_LOOPBACK, null, null, authCrypt, false, 1, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAesGcm64Udp4() throws Exception {
|
||||
IpSecAlgorithm authCrypt =
|
||||
new IpSecAlgorithm(IpSecAlgorithm.AUTH_CRYPT_AES_GCM, AEAD_KEY, 64);
|
||||
@@ -828,6 +868,7 @@ public class IpSecManagerTest extends IpSecBaseTest {
|
||||
checkTransform(IPPROTO_UDP, IPV4_LOOPBACK, null, null, authCrypt, false, 1, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAesGcm64Udp6() throws Exception {
|
||||
IpSecAlgorithm authCrypt =
|
||||
new IpSecAlgorithm(IpSecAlgorithm.AUTH_CRYPT_AES_GCM, AEAD_KEY, 64);
|
||||
@@ -835,6 +876,7 @@ public class IpSecManagerTest extends IpSecBaseTest {
|
||||
checkTransform(IPPROTO_UDP, IPV6_LOOPBACK, null, null, authCrypt, false, 1, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAesGcm96Tcp4() throws Exception {
|
||||
IpSecAlgorithm authCrypt =
|
||||
new IpSecAlgorithm(IpSecAlgorithm.AUTH_CRYPT_AES_GCM, AEAD_KEY, 96);
|
||||
@@ -842,6 +884,7 @@ public class IpSecManagerTest extends IpSecBaseTest {
|
||||
checkTransform(IPPROTO_TCP, IPV4_LOOPBACK, null, null, authCrypt, false, 1, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAesGcm96Tcp6() throws Exception {
|
||||
IpSecAlgorithm authCrypt =
|
||||
new IpSecAlgorithm(IpSecAlgorithm.AUTH_CRYPT_AES_GCM, AEAD_KEY, 96);
|
||||
@@ -849,6 +892,7 @@ public class IpSecManagerTest extends IpSecBaseTest {
|
||||
checkTransform(IPPROTO_TCP, IPV6_LOOPBACK, null, null, authCrypt, false, 1, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAesGcm96Udp4() throws Exception {
|
||||
IpSecAlgorithm authCrypt =
|
||||
new IpSecAlgorithm(IpSecAlgorithm.AUTH_CRYPT_AES_GCM, AEAD_KEY, 96);
|
||||
@@ -856,6 +900,7 @@ public class IpSecManagerTest extends IpSecBaseTest {
|
||||
checkTransform(IPPROTO_UDP, IPV4_LOOPBACK, null, null, authCrypt, false, 1, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAesGcm96Udp6() throws Exception {
|
||||
IpSecAlgorithm authCrypt =
|
||||
new IpSecAlgorithm(IpSecAlgorithm.AUTH_CRYPT_AES_GCM, AEAD_KEY, 96);
|
||||
@@ -863,6 +908,7 @@ public class IpSecManagerTest extends IpSecBaseTest {
|
||||
checkTransform(IPPROTO_UDP, IPV6_LOOPBACK, null, null, authCrypt, false, 1, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAesGcm128Tcp4() throws Exception {
|
||||
IpSecAlgorithm authCrypt =
|
||||
new IpSecAlgorithm(IpSecAlgorithm.AUTH_CRYPT_AES_GCM, AEAD_KEY, 128);
|
||||
@@ -870,6 +916,7 @@ public class IpSecManagerTest extends IpSecBaseTest {
|
||||
checkTransform(IPPROTO_TCP, IPV4_LOOPBACK, null, null, authCrypt, false, 1, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAesGcm128Tcp6() throws Exception {
|
||||
IpSecAlgorithm authCrypt =
|
||||
new IpSecAlgorithm(IpSecAlgorithm.AUTH_CRYPT_AES_GCM, AEAD_KEY, 128);
|
||||
@@ -877,6 +924,7 @@ public class IpSecManagerTest extends IpSecBaseTest {
|
||||
checkTransform(IPPROTO_TCP, IPV6_LOOPBACK, null, null, authCrypt, false, 1, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAesGcm128Udp4() throws Exception {
|
||||
IpSecAlgorithm authCrypt =
|
||||
new IpSecAlgorithm(IpSecAlgorithm.AUTH_CRYPT_AES_GCM, AEAD_KEY, 128);
|
||||
@@ -884,6 +932,7 @@ public class IpSecManagerTest extends IpSecBaseTest {
|
||||
checkTransform(IPPROTO_UDP, IPV4_LOOPBACK, null, null, authCrypt, false, 1, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAesGcm128Udp6() throws Exception {
|
||||
IpSecAlgorithm authCrypt =
|
||||
new IpSecAlgorithm(IpSecAlgorithm.AUTH_CRYPT_AES_GCM, AEAD_KEY, 128);
|
||||
@@ -891,6 +940,7 @@ public class IpSecManagerTest extends IpSecBaseTest {
|
||||
checkTransform(IPPROTO_UDP, IPV6_LOOPBACK, null, null, authCrypt, false, 1, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAesCbcHmacMd5Tcp4UdpEncap() throws Exception {
|
||||
IpSecAlgorithm crypt = new IpSecAlgorithm(IpSecAlgorithm.CRYPT_AES_CBC, CRYPT_KEY);
|
||||
IpSecAlgorithm auth = new IpSecAlgorithm(IpSecAlgorithm.AUTH_HMAC_MD5, getKey(128), 96);
|
||||
@@ -898,6 +948,7 @@ public class IpSecManagerTest extends IpSecBaseTest {
|
||||
checkTransform(IPPROTO_TCP, IPV4_LOOPBACK, crypt, auth, null, true, 1, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAesCbcHmacMd5Udp4UdpEncap() throws Exception {
|
||||
IpSecAlgorithm crypt = new IpSecAlgorithm(IpSecAlgorithm.CRYPT_AES_CBC, CRYPT_KEY);
|
||||
IpSecAlgorithm auth = new IpSecAlgorithm(IpSecAlgorithm.AUTH_HMAC_MD5, getKey(128), 96);
|
||||
@@ -905,6 +956,7 @@ public class IpSecManagerTest extends IpSecBaseTest {
|
||||
checkTransform(IPPROTO_UDP, IPV4_LOOPBACK, crypt, auth, null, true, 1, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAesCbcHmacSha1Tcp4UdpEncap() throws Exception {
|
||||
IpSecAlgorithm crypt = new IpSecAlgorithm(IpSecAlgorithm.CRYPT_AES_CBC, CRYPT_KEY);
|
||||
IpSecAlgorithm auth = new IpSecAlgorithm(IpSecAlgorithm.AUTH_HMAC_SHA1, getKey(160), 96);
|
||||
@@ -912,6 +964,7 @@ public class IpSecManagerTest extends IpSecBaseTest {
|
||||
checkTransform(IPPROTO_TCP, IPV4_LOOPBACK, crypt, auth, null, true, 1, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAesCbcHmacSha1Udp4UdpEncap() throws Exception {
|
||||
IpSecAlgorithm crypt = new IpSecAlgorithm(IpSecAlgorithm.CRYPT_AES_CBC, CRYPT_KEY);
|
||||
IpSecAlgorithm auth = new IpSecAlgorithm(IpSecAlgorithm.AUTH_HMAC_SHA1, getKey(160), 96);
|
||||
@@ -919,6 +972,7 @@ public class IpSecManagerTest extends IpSecBaseTest {
|
||||
checkTransform(IPPROTO_UDP, IPV4_LOOPBACK, crypt, auth, null, true, 1, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAesCbcHmacSha256Tcp4UdpEncap() throws Exception {
|
||||
IpSecAlgorithm crypt = new IpSecAlgorithm(IpSecAlgorithm.CRYPT_AES_CBC, CRYPT_KEY);
|
||||
IpSecAlgorithm auth = new IpSecAlgorithm(IpSecAlgorithm.AUTH_HMAC_SHA256, getKey(256), 128);
|
||||
@@ -926,6 +980,7 @@ public class IpSecManagerTest extends IpSecBaseTest {
|
||||
checkTransform(IPPROTO_TCP, IPV4_LOOPBACK, crypt, auth, null, true, 1, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAesCbcHmacSha256Udp4UdpEncap() throws Exception {
|
||||
IpSecAlgorithm crypt = new IpSecAlgorithm(IpSecAlgorithm.CRYPT_AES_CBC, CRYPT_KEY);
|
||||
IpSecAlgorithm auth = new IpSecAlgorithm(IpSecAlgorithm.AUTH_HMAC_SHA256, getKey(256), 128);
|
||||
@@ -933,6 +988,7 @@ public class IpSecManagerTest extends IpSecBaseTest {
|
||||
checkTransform(IPPROTO_UDP, IPV4_LOOPBACK, crypt, auth, null, true, 1, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAesCbcHmacSha384Tcp4UdpEncap() throws Exception {
|
||||
IpSecAlgorithm crypt = new IpSecAlgorithm(IpSecAlgorithm.CRYPT_AES_CBC, CRYPT_KEY);
|
||||
IpSecAlgorithm auth = new IpSecAlgorithm(IpSecAlgorithm.AUTH_HMAC_SHA384, getKey(384), 192);
|
||||
@@ -940,6 +996,7 @@ public class IpSecManagerTest extends IpSecBaseTest {
|
||||
checkTransform(IPPROTO_TCP, IPV4_LOOPBACK, crypt, auth, null, true, 1, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAesCbcHmacSha384Udp4UdpEncap() throws Exception {
|
||||
IpSecAlgorithm crypt = new IpSecAlgorithm(IpSecAlgorithm.CRYPT_AES_CBC, CRYPT_KEY);
|
||||
IpSecAlgorithm auth = new IpSecAlgorithm(IpSecAlgorithm.AUTH_HMAC_SHA384, getKey(384), 192);
|
||||
@@ -947,6 +1004,7 @@ public class IpSecManagerTest extends IpSecBaseTest {
|
||||
checkTransform(IPPROTO_UDP, IPV4_LOOPBACK, crypt, auth, null, true, 1, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAesCbcHmacSha512Tcp4UdpEncap() throws Exception {
|
||||
IpSecAlgorithm crypt = new IpSecAlgorithm(IpSecAlgorithm.CRYPT_AES_CBC, CRYPT_KEY);
|
||||
IpSecAlgorithm auth = new IpSecAlgorithm(IpSecAlgorithm.AUTH_HMAC_SHA512, getKey(512), 256);
|
||||
@@ -954,6 +1012,7 @@ public class IpSecManagerTest extends IpSecBaseTest {
|
||||
checkTransform(IPPROTO_TCP, IPV4_LOOPBACK, crypt, auth, null, true, 1, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAesCbcHmacSha512Udp4UdpEncap() throws Exception {
|
||||
IpSecAlgorithm crypt = new IpSecAlgorithm(IpSecAlgorithm.CRYPT_AES_CBC, CRYPT_KEY);
|
||||
IpSecAlgorithm auth = new IpSecAlgorithm(IpSecAlgorithm.AUTH_HMAC_SHA512, getKey(512), 256);
|
||||
@@ -961,6 +1020,7 @@ public class IpSecManagerTest extends IpSecBaseTest {
|
||||
checkTransform(IPPROTO_UDP, IPV4_LOOPBACK, crypt, auth, null, true, 1, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAesGcm64Tcp4UdpEncap() throws Exception {
|
||||
IpSecAlgorithm authCrypt =
|
||||
new IpSecAlgorithm(IpSecAlgorithm.AUTH_CRYPT_AES_GCM, AEAD_KEY, 64);
|
||||
@@ -968,6 +1028,7 @@ public class IpSecManagerTest extends IpSecBaseTest {
|
||||
checkTransform(IPPROTO_TCP, IPV4_LOOPBACK, null, null, authCrypt, true, 1, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAesGcm64Udp4UdpEncap() throws Exception {
|
||||
IpSecAlgorithm authCrypt =
|
||||
new IpSecAlgorithm(IpSecAlgorithm.AUTH_CRYPT_AES_GCM, AEAD_KEY, 64);
|
||||
@@ -975,6 +1036,7 @@ public class IpSecManagerTest extends IpSecBaseTest {
|
||||
checkTransform(IPPROTO_UDP, IPV4_LOOPBACK, null, null, authCrypt, true, 1, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAesGcm96Tcp4UdpEncap() throws Exception {
|
||||
IpSecAlgorithm authCrypt =
|
||||
new IpSecAlgorithm(IpSecAlgorithm.AUTH_CRYPT_AES_GCM, AEAD_KEY, 96);
|
||||
@@ -982,6 +1044,7 @@ public class IpSecManagerTest extends IpSecBaseTest {
|
||||
checkTransform(IPPROTO_TCP, IPV4_LOOPBACK, null, null, authCrypt, true, 1, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAesGcm96Udp4UdpEncap() throws Exception {
|
||||
IpSecAlgorithm authCrypt =
|
||||
new IpSecAlgorithm(IpSecAlgorithm.AUTH_CRYPT_AES_GCM, AEAD_KEY, 96);
|
||||
@@ -989,6 +1052,7 @@ public class IpSecManagerTest extends IpSecBaseTest {
|
||||
checkTransform(IPPROTO_UDP, IPV4_LOOPBACK, null, null, authCrypt, true, 1, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAesGcm128Tcp4UdpEncap() throws Exception {
|
||||
IpSecAlgorithm authCrypt =
|
||||
new IpSecAlgorithm(IpSecAlgorithm.AUTH_CRYPT_AES_GCM, AEAD_KEY, 128);
|
||||
@@ -996,6 +1060,7 @@ public class IpSecManagerTest extends IpSecBaseTest {
|
||||
checkTransform(IPPROTO_TCP, IPV4_LOOPBACK, null, null, authCrypt, true, 1, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAesGcm128Udp4UdpEncap() throws Exception {
|
||||
IpSecAlgorithm authCrypt =
|
||||
new IpSecAlgorithm(IpSecAlgorithm.AUTH_CRYPT_AES_GCM, AEAD_KEY, 128);
|
||||
@@ -1003,78 +1068,91 @@ public class IpSecManagerTest extends IpSecBaseTest {
|
||||
checkTransform(IPPROTO_UDP, IPV4_LOOPBACK, null, null, authCrypt, true, 1, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCryptUdp4() throws Exception {
|
||||
IpSecAlgorithm crypt = new IpSecAlgorithm(IpSecAlgorithm.CRYPT_AES_CBC, CRYPT_KEY);
|
||||
checkTransform(IPPROTO_UDP, IPV4_LOOPBACK, crypt, null, null, false, 1, false);
|
||||
checkTransform(IPPROTO_UDP, IPV4_LOOPBACK, crypt, null, null, false, 1, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAuthUdp4() throws Exception {
|
||||
IpSecAlgorithm auth = new IpSecAlgorithm(IpSecAlgorithm.AUTH_HMAC_SHA256, getKey(256), 128);
|
||||
checkTransform(IPPROTO_UDP, IPV4_LOOPBACK, null, auth, null, false, 1, false);
|
||||
checkTransform(IPPROTO_UDP, IPV4_LOOPBACK, null, auth, null, false, 1, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCryptUdp6() throws Exception {
|
||||
IpSecAlgorithm crypt = new IpSecAlgorithm(IpSecAlgorithm.CRYPT_AES_CBC, CRYPT_KEY);
|
||||
checkTransform(IPPROTO_UDP, IPV6_LOOPBACK, crypt, null, null, false, 1, false);
|
||||
checkTransform(IPPROTO_UDP, IPV6_LOOPBACK, crypt, null, null, false, 1, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAuthUdp6() throws Exception {
|
||||
IpSecAlgorithm auth = new IpSecAlgorithm(IpSecAlgorithm.AUTH_HMAC_SHA256, getKey(256), 128);
|
||||
checkTransform(IPPROTO_UDP, IPV6_LOOPBACK, null, auth, null, false, 1, false);
|
||||
checkTransform(IPPROTO_UDP, IPV6_LOOPBACK, null, auth, null, false, 1, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCryptTcp4() throws Exception {
|
||||
IpSecAlgorithm crypt = new IpSecAlgorithm(IpSecAlgorithm.CRYPT_AES_CBC, CRYPT_KEY);
|
||||
checkTransform(IPPROTO_TCP, IPV4_LOOPBACK, crypt, null, null, false, 1, false);
|
||||
checkTransform(IPPROTO_TCP, IPV4_LOOPBACK, crypt, null, null, false, 1, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAuthTcp4() throws Exception {
|
||||
IpSecAlgorithm auth = new IpSecAlgorithm(IpSecAlgorithm.AUTH_HMAC_SHA256, getKey(256), 128);
|
||||
checkTransform(IPPROTO_TCP, IPV4_LOOPBACK, null, auth, null, false, 1, false);
|
||||
checkTransform(IPPROTO_TCP, IPV4_LOOPBACK, null, auth, null, false, 1, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCryptTcp6() throws Exception {
|
||||
IpSecAlgorithm crypt = new IpSecAlgorithm(IpSecAlgorithm.CRYPT_AES_CBC, CRYPT_KEY);
|
||||
checkTransform(IPPROTO_TCP, IPV6_LOOPBACK, crypt, null, null, false, 1, false);
|
||||
checkTransform(IPPROTO_TCP, IPV6_LOOPBACK, crypt, null, null, false, 1, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAuthTcp6() throws Exception {
|
||||
IpSecAlgorithm auth = new IpSecAlgorithm(IpSecAlgorithm.AUTH_HMAC_SHA256, getKey(256), 128);
|
||||
checkTransform(IPPROTO_TCP, IPV6_LOOPBACK, null, auth, null, false, 1, false);
|
||||
checkTransform(IPPROTO_TCP, IPV6_LOOPBACK, null, auth, null, false, 1, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCryptUdp4UdpEncap() throws Exception {
|
||||
IpSecAlgorithm crypt = new IpSecAlgorithm(IpSecAlgorithm.CRYPT_AES_CBC, CRYPT_KEY);
|
||||
checkTransform(IPPROTO_UDP, IPV4_LOOPBACK, crypt, null, null, true, 1, false);
|
||||
checkTransform(IPPROTO_UDP, IPV4_LOOPBACK, crypt, null, null, true, 1, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAuthUdp4UdpEncap() throws Exception {
|
||||
IpSecAlgorithm auth = new IpSecAlgorithm(IpSecAlgorithm.AUTH_HMAC_SHA256, getKey(256), 128);
|
||||
checkTransform(IPPROTO_UDP, IPV4_LOOPBACK, null, auth, null, true, 1, false);
|
||||
checkTransform(IPPROTO_UDP, IPV4_LOOPBACK, null, auth, null, true, 1, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCryptTcp4UdpEncap() throws Exception {
|
||||
IpSecAlgorithm crypt = new IpSecAlgorithm(IpSecAlgorithm.CRYPT_AES_CBC, CRYPT_KEY);
|
||||
checkTransform(IPPROTO_TCP, IPV4_LOOPBACK, crypt, null, null, true, 1, false);
|
||||
checkTransform(IPPROTO_TCP, IPV4_LOOPBACK, crypt, null, null, true, 1, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAuthTcp4UdpEncap() throws Exception {
|
||||
IpSecAlgorithm auth = new IpSecAlgorithm(IpSecAlgorithm.AUTH_HMAC_SHA256, getKey(256), 128);
|
||||
checkTransform(IPPROTO_TCP, IPV4_LOOPBACK, null, auth, null, true, 1, false);
|
||||
checkTransform(IPPROTO_TCP, IPV4_LOOPBACK, null, auth, null, true, 1, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOpenUdpEncapSocketSpecificPort() throws Exception {
|
||||
IpSecManager.UdpEncapsulationSocket encapSocket = null;
|
||||
int port = -1;
|
||||
@@ -1103,6 +1181,7 @@ public class IpSecManagerTest extends IpSecBaseTest {
|
||||
assertTrue("Returned invalid port", encapSocket.getPort() == port);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOpenUdpEncapSocketRandomPort() throws Exception {
|
||||
try (IpSecManager.UdpEncapsulationSocket encapSocket = mISM.openUdpEncapsulationSocket()) {
|
||||
assertTrue("Returned invalid port", encapSocket.getPort() != 0);
|
||||
|
||||
@@ -40,6 +40,7 @@ import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import android.app.AppOpsManager;
|
||||
import android.content.Context;
|
||||
@@ -142,6 +143,7 @@ public class IpSecManagerTunnelTest extends IpSecBaseTest {
|
||||
}
|
||||
|
||||
@Before
|
||||
@Override
|
||||
public void setUp() throws Exception {
|
||||
super.setUp();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user