summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorXiao Ma <xiaom@google.com>2020-05-07 15:25:09 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2020-05-07 15:25:09 +0000
commitdb6652aaef0d72b8300a88060053bcbe48e57d4d (patch)
treef0dc046356af8df58ab0bcfff98a3f25f31a6aa1 /tests
parent88384a2c3893cc83a41c33252172f4c9afd3a9ba (diff)
parent1eb4c9d55b8e15badb58d0531c1b20c54a54d0f8 (diff)
Merge "Fix the potential NPE when starting provisioning with FILS." into rvc-dev
Diffstat (limited to 'tests')
-rw-r--r--tests/integration/src/android/net/ip/IpClientIntegrationTest.java45
1 files changed, 36 insertions, 9 deletions
diff --git a/tests/integration/src/android/net/ip/IpClientIntegrationTest.java b/tests/integration/src/android/net/ip/IpClientIntegrationTest.java
index e286439..a18d908 100644
--- a/tests/integration/src/android/net/ip/IpClientIntegrationTest.java
+++ b/tests/integration/src/android/net/ip/IpClientIntegrationTest.java
@@ -830,27 +830,32 @@ public class IpClientIntegrationTest {
}
}
+ private DhcpPacket assertDiscoverPacketOnPreconnectionStart() throws Exception {
+ final ArgumentCaptor<List<Layer2PacketParcelable>> l2PacketList =
+ ArgumentCaptor.forClass(List.class);
+
+ verify(mCb, timeout(TEST_TIMEOUT_MS)).onPreconnectionStart(l2PacketList.capture());
+ final byte[] payload = l2PacketList.getValue().get(0).payload;
+ DhcpPacket packet = DhcpPacket.decodeFullPacket(payload, payload.length, ENCAP_L2);
+ assertTrue(packet instanceof DhcpDiscoverPacket);
+ assertArrayEquals(INADDR_BROADCAST.getAddress(),
+ Arrays.copyOfRange(payload, IPV4_DST_ADDR_OFFSET, IPV4_DST_ADDR_OFFSET + 4));
+ return packet;
+ }
+
private void doIpClientProvisioningWithPreconnectionTest(
final boolean shouldReplyRapidCommitAck, final boolean shouldAbortPreconnection,
final boolean shouldFirePreconnectionTimeout,
final boolean timeoutBeforePreconnectionComplete) throws Exception {
final long currentTime = System.currentTimeMillis();
- final ArgumentCaptor<List<Layer2PacketParcelable>> l2PacketList =
- ArgumentCaptor.forClass(List.class);
final ArgumentCaptor<InterfaceConfigurationParcel> ifConfig =
ArgumentCaptor.forClass(InterfaceConfigurationParcel.class);
startIpClientProvisioning(true /* isDhcpLeaseCacheEnabled */,
shouldReplyRapidCommitAck, true /* isDhcpPreConnectionEnabled */,
false /* isDhcpIpConflictDetectEnabled */);
- verify(mCb, timeout(TEST_TIMEOUT_MS).times(1))
- .onPreconnectionStart(l2PacketList.capture());
- final byte[] payload = l2PacketList.getValue().get(0).payload;
- DhcpPacket packet = DhcpPacket.decodeFullPacket(payload, payload.length, ENCAP_L2);
+ DhcpPacket packet = assertDiscoverPacketOnPreconnectionStart();
final int preconnDiscoverTransId = packet.getTransactionId();
- assertTrue(packet instanceof DhcpDiscoverPacket);
- assertArrayEquals(INADDR_BROADCAST.getAddress(),
- Arrays.copyOfRange(payload, IPV4_DST_ADDR_OFFSET, IPV4_DST_ADDR_OFFSET + 4));
if (shouldAbortPreconnection) {
if (shouldFirePreconnectionTimeout && timeoutBeforePreconnectionComplete) {
@@ -1721,6 +1726,28 @@ public class IpClientIntegrationTest {
}
@Test
+ public void testDhcpClientPreconnection_WithoutLayer2InfoWhenStartingProv() throws Exception {
+ // For FILS connection, current bssid (also l2key and grouphint) is still null when
+ // starting provisioning since the L2 link hasn't been established yet. Ensure that
+ // IpClient won't crash even if initializing an Layer2Info class with null members.
+ ProvisioningConfiguration.Builder prov = new ProvisioningConfiguration.Builder()
+ .withoutIpReachabilityMonitor()
+ .withoutIPv6()
+ .withPreconnection()
+ .withLayer2Information(new Layer2Information(null /* l2key */, null /* grouphint */,
+ null /* bssid */));
+
+ mIpc.startProvisioning(prov.build());
+ assertDiscoverPacketOnPreconnectionStart();
+ verify(mCb).setNeighborDiscoveryOffload(true);
+
+ // Force IpClient transition to RunningState from PreconnectionState.
+ mIpc.notifyPreconnectionComplete(false /* success */);
+ HandlerUtilsKt.waitForIdle(mDependencies.mDhcpClient.getHandler(), TEST_TIMEOUT_MS);
+ verify(mCb, timeout(TEST_TIMEOUT_MS)).setFallbackMulticastFilter(false);
+ }
+
+ @Test
public void testDhcpDecline_conflictByArpReply() throws Exception {
doIpAddressConflictDetectionTest(true /* causeIpAddressConflict */,
false /* shouldReplyRapidCommitAck */, true /* isDhcpIpConflictDetectEnabled */,