Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 27ce00a7 authored by Lorenzo Colitti's avatar Lorenzo Colitti Committed by Automerger Merge Worker
Browse files

Test that DhcpClient sets the server address in LinkProperties. am: 46a78740...

Test that DhcpClient sets the server address in LinkProperties. am: 46a78740 am: 5c9f3ca4 am: 13d3bbb0

Change-Id: Iad0e16a105f80b313686858f9b70a74d1b78348f
parents 270edb44 13d3bbb0
Loading
Loading
Loading
Loading
+15 −0
Original line number Original line Diff line number Diff line
@@ -130,6 +130,7 @@ import com.android.networkstack.arp.ArpPacket;
import com.android.server.NetworkObserverRegistry;
import com.android.server.NetworkObserverRegistry;
import com.android.server.NetworkStackService.NetworkStackServiceManager;
import com.android.server.NetworkStackService.NetworkStackServiceManager;
import com.android.server.connectivity.ipmemorystore.IpMemoryStoreService;
import com.android.server.connectivity.ipmemorystore.IpMemoryStoreService;
import com.android.testutils.DevSdkIgnoreRule.IgnoreUpTo;
import com.android.testutils.HandlerUtilsKt;
import com.android.testutils.HandlerUtilsKt;
import com.android.testutils.TapPacketReader;
import com.android.testutils.TapPacketReader;


@@ -658,6 +659,12 @@ public class IpClientIntegrationTest {
                null /* captivePortalApiUrl */, null /* displayName */, null /* scanResultInfo */);
                null /* captivePortalApiUrl */, null /* displayName */, null /* scanResultInfo */);
    }
    }


    private List<DhcpPacket> performDhcpHandshake() throws Exception {
        return performDhcpHandshake(true /* isSuccessLease */, TEST_LEASE_DURATION_S,
                false /* isDhcpLeaseCacheEnabled */, false /* shouldReplyRapidCommitAck */,
                TEST_DEFAULT_MTU, false /* isDhcpIpConflictDetectEnabled */);
    }

    private DhcpPacket getNextDhcpPacket() throws ParseException {
    private DhcpPacket getNextDhcpPacket() throws ParseException {
        byte[] packet;
        byte[] packet;
        while ((packet = mPacketReader.popPacket(PACKET_TIMEOUT_MS)) != null) {
        while ((packet = mPacketReader.popPacket(PACKET_TIMEOUT_MS)) != null) {
@@ -1051,6 +1058,14 @@ public class IpClientIntegrationTest {
        assertTrue(packet instanceof DhcpDiscoverPacket);
        assertTrue(packet instanceof DhcpDiscoverPacket);
    }
    }


    @Test @IgnoreUpTo(Build.VERSION_CODES.Q)
    public void testDhcpServerInLinkProperties() throws Exception {
        performDhcpHandshake();
        ArgumentCaptor<LinkProperties> captor = ArgumentCaptor.forClass(LinkProperties.class);
        verify(mCb, timeout(TEST_TIMEOUT_MS)).onProvisioningSuccess(captor.capture());
        assertEquals(SERVER_ADDR, captor.getValue().getDhcpServerAddress());
    }

    @Test
    @Test
    public void testRestoreInitialInterfaceMtu() throws Exception {
    public void testRestoreInitialInterfaceMtu() throws Exception {
        doRestoreInitialMtuTest(true /* shouldChangeMtu */, false /* shouldRemoveTapInterface */);
        doRestoreInitialMtuTest(true /* shouldChangeMtu */, false /* shouldRemoveTapInterface */);