Merge "Use #setNetwork and #getNetwork for IkeSessionParams"
This commit is contained in:
@@ -83,7 +83,7 @@ public final class IkeSessionParamsUtils {
|
|||||||
/** Serializes an IkeSessionParams to a PersistableBundle. */
|
/** Serializes an IkeSessionParams to a PersistableBundle. */
|
||||||
@NonNull
|
@NonNull
|
||||||
public static PersistableBundle toPersistableBundle(@NonNull IkeSessionParams params) {
|
public static PersistableBundle toPersistableBundle(@NonNull IkeSessionParams params) {
|
||||||
if (params.getConfiguredNetwork() != null || params.getIke3gppExtension() != null) {
|
if (params.getNetwork() != null || params.getIke3gppExtension() != null) {
|
||||||
throw new IllegalStateException(
|
throw new IllegalStateException(
|
||||||
"Cannot convert a IkeSessionParams with a caller configured network or with"
|
"Cannot convert a IkeSessionParams with a caller configured network or with"
|
||||||
+ " 3GPP extension enabled");
|
+ " 3GPP extension enabled");
|
||||||
|
|||||||
@@ -2106,7 +2106,7 @@ public class VcnGatewayConnection extends StateMachine {
|
|||||||
(VcnControlPlaneIkeConfig) mConnectionConfig.getControlPlaneConfig();
|
(VcnControlPlaneIkeConfig) mConnectionConfig.getControlPlaneConfig();
|
||||||
final IkeSessionParams.Builder builder =
|
final IkeSessionParams.Builder builder =
|
||||||
new IkeSessionParams.Builder(controlPlaneConfig.getIkeSessionParams());
|
new IkeSessionParams.Builder(controlPlaneConfig.getIkeSessionParams());
|
||||||
builder.setConfiguredNetwork(network);
|
builder.setNetwork(network);
|
||||||
|
|
||||||
return builder.build();
|
return builder.build();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,12 +22,7 @@ import static android.net.ipsec.ike.SaProposal.PSEUDORANDOM_FUNCTION_AES128_XCBC
|
|||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.fail;
|
import static org.junit.Assert.fail;
|
||||||
import static org.mockito.Mockito.doReturn;
|
|
||||||
import static org.mockito.Mockito.mock;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.net.ConnectivityManager;
|
|
||||||
import android.net.Network;
|
|
||||||
import android.net.ipsec.ike.ChildSaProposal;
|
import android.net.ipsec.ike.ChildSaProposal;
|
||||||
import android.net.ipsec.ike.IkeFqdnIdentification;
|
import android.net.ipsec.ike.IkeFqdnIdentification;
|
||||||
import android.net.ipsec.ike.IkeSaProposal;
|
import android.net.ipsec.ike.IkeSaProposal;
|
||||||
@@ -56,20 +51,13 @@ public class VcnControlPlaneIkeConfigTest {
|
|||||||
.addPseudorandomFunction(PSEUDORANDOM_FUNCTION_AES128_XCBC)
|
.addPseudorandomFunction(PSEUDORANDOM_FUNCTION_AES128_XCBC)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
Context mockContext = mock(Context.class);
|
|
||||||
ConnectivityManager mockConnectManager = mock(ConnectivityManager.class);
|
|
||||||
doReturn(mockConnectManager)
|
|
||||||
.when(mockContext)
|
|
||||||
.getSystemService(Context.CONNECTIVITY_SERVICE);
|
|
||||||
doReturn(mock(Network.class)).when(mockConnectManager).getActiveNetwork();
|
|
||||||
|
|
||||||
final String serverHostname = "192.0.2.100";
|
final String serverHostname = "192.0.2.100";
|
||||||
final String testLocalId = "test.client.com";
|
final String testLocalId = "test.client.com";
|
||||||
final String testRemoteId = "test.server.com";
|
final String testRemoteId = "test.server.com";
|
||||||
final byte[] psk = "psk".getBytes();
|
final byte[] psk = "psk".getBytes();
|
||||||
|
|
||||||
IKE_PARAMS =
|
IKE_PARAMS =
|
||||||
new IkeSessionParams.Builder(mockContext)
|
new IkeSessionParams.Builder()
|
||||||
.setServerHostname(serverHostname)
|
.setServerHostname(serverHostname)
|
||||||
.addSaProposal(ikeProposal)
|
.addSaProposal(ikeProposal)
|
||||||
.setLocalIdentification(new IkeFqdnIdentification(testLocalId))
|
.setLocalIdentification(new IkeFqdnIdentification(testLocalId))
|
||||||
|
|||||||
@@ -58,8 +58,7 @@ public class VcnGatewayConnectionConnectingStateTest extends VcnGatewayConnectio
|
|||||||
ArgumentCaptor.forClass(IkeSessionParams.class);
|
ArgumentCaptor.forClass(IkeSessionParams.class);
|
||||||
verify(mDeps).newIkeSession(any(), paramsCaptor.capture(), any(), any(), any());
|
verify(mDeps).newIkeSession(any(), paramsCaptor.capture(), any(), any(), any());
|
||||||
assertEquals(
|
assertEquals(
|
||||||
TEST_UNDERLYING_NETWORK_RECORD_1.network,
|
TEST_UNDERLYING_NETWORK_RECORD_1.network, paramsCaptor.getValue().getNetwork());
|
||||||
paramsCaptor.getValue().getConfiguredNetwork());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
Reference in New Issue
Block a user