Merge "Add tests for Tunnel, Transport mode application with released SPIs" am: 27a2f1dff8
Change-Id: I60b9f6f52ba6aa64e6329f15ef1529b52c8a1b6a
This commit is contained in:
@@ -547,6 +547,16 @@ public class IpSecServiceParameterizedTest {
|
||||
|
||||
@Test
|
||||
public void testApplyTransportModeTransform() throws Exception {
|
||||
verifyApplyTransportModeTransformCommon(false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testApplyTransportModeTransformReleasedSpi() throws Exception {
|
||||
verifyApplyTransportModeTransformCommon(true);
|
||||
}
|
||||
|
||||
public void verifyApplyTransportModeTransformCommon(
|
||||
boolean closeSpiBeforeApply) throws Exception {
|
||||
IpSecConfig ipSecConfig = new IpSecConfig();
|
||||
addDefaultSpisAndRemoteAddrToIpSecConfig(ipSecConfig);
|
||||
addAuthAndCryptToIpSecConfig(ipSecConfig);
|
||||
@@ -554,6 +564,10 @@ public class IpSecServiceParameterizedTest {
|
||||
IpSecTransformResponse createTransformResp =
|
||||
mIpSecService.createTransform(ipSecConfig, new Binder(), "blessedPackage");
|
||||
|
||||
if (closeSpiBeforeApply) {
|
||||
mIpSecService.releaseSecurityParameterIndex(ipSecConfig.getSpiResourceId());
|
||||
}
|
||||
|
||||
Socket socket = new Socket();
|
||||
socket.bind(null);
|
||||
ParcelFileDescriptor pfd = ParcelFileDescriptor.fromSocket(socket);
|
||||
@@ -689,6 +703,15 @@ public class IpSecServiceParameterizedTest {
|
||||
|
||||
@Test
|
||||
public void testApplyTunnelModeTransform() throws Exception {
|
||||
verifyApplyTunnelModeTransformCommon(false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testApplyTunnelModeTransformReleasedSpi() throws Exception {
|
||||
verifyApplyTunnelModeTransformCommon(true);
|
||||
}
|
||||
|
||||
public void verifyApplyTunnelModeTransformCommon(boolean closeSpiBeforeApply) throws Exception {
|
||||
IpSecConfig ipSecConfig = new IpSecConfig();
|
||||
ipSecConfig.setMode(IpSecTransform.MODE_TUNNEL);
|
||||
addDefaultSpisAndRemoteAddrToIpSecConfig(ipSecConfig);
|
||||
@@ -699,6 +722,10 @@ public class IpSecServiceParameterizedTest {
|
||||
IpSecTunnelInterfaceResponse createTunnelResp =
|
||||
createAndValidateTunnel(mSourceAddr, mDestinationAddr, "blessedPackage");
|
||||
|
||||
if (closeSpiBeforeApply) {
|
||||
mIpSecService.releaseSecurityParameterIndex(ipSecConfig.getSpiResourceId());
|
||||
}
|
||||
|
||||
int transformResourceId = createTransformResp.resourceId;
|
||||
int tunnelResourceId = createTunnelResp.resourceId;
|
||||
mIpSecService.applyTunnelModeTransform(tunnelResourceId, IpSecManager.DIRECTION_OUT,
|
||||
|
||||
Reference in New Issue
Block a user