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