Merge "Force creation of Socket upon Transform application" am: 4acfd60844
am: 1f8c0950b1
Change-Id: I2034448a22461d51728e66bcc0e965821aa4a42f
This commit is contained in:
@@ -38,6 +38,7 @@ import android.system.Os;
|
||||
import com.android.server.IpSecService;
|
||||
|
||||
import java.net.InetAddress;
|
||||
import java.net.Socket;
|
||||
import java.net.UnknownHostException;
|
||||
|
||||
import org.junit.Before;
|
||||
@@ -194,6 +195,33 @@ public class IpSecManagerTest {
|
||||
verify(mMockIpSecService).closeUdpEncapsulationSocket(DUMMY_RESOURCE_ID);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testApplyTransportModeTransformEnsuresSocketCreation() throws Exception {
|
||||
Socket socket = new Socket();
|
||||
IpSecConfig dummyConfig = new IpSecConfig();
|
||||
IpSecTransform dummyTransform = new IpSecTransform(null, dummyConfig);
|
||||
|
||||
// Even if underlying SocketImpl is not initalized, this should force the init, and
|
||||
// thereby succeed.
|
||||
mIpSecManager.applyTransportModeTransform(
|
||||
socket, IpSecManager.DIRECTION_IN, dummyTransform);
|
||||
|
||||
// Check to make sure the FileDescriptor is non-null
|
||||
assertNotNull(socket.getFileDescriptor$());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRemoveTransportModeTransformsForcesSocketCreation() throws Exception {
|
||||
Socket socket = new Socket();
|
||||
|
||||
// Even if underlying SocketImpl is not initalized, this should force the init, and
|
||||
// thereby succeed.
|
||||
mIpSecManager.removeTransportModeTransforms(socket);
|
||||
|
||||
// Check to make sure the FileDescriptor is non-null
|
||||
assertNotNull(socket.getFileDescriptor$());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOpenEncapsulationSocketOnRandomPort() throws Exception {
|
||||
IpSecUdpEncapResponse udpEncapResp =
|
||||
|
||||
Reference in New Issue
Block a user