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

Commit 45676f0f authored by Xiao Ma's avatar Xiao Ma
Browse files

Fix the failure testCustomizedDhcpOptions_disallowedOption.

This test intends to verify that a "disallowed" customized DHCP client
option shouldn't appear in DHCPDISCOVER/DHCPREQUEST packet, hostname
option might not be a good candidate for this case, because it's enabled
since S, device still can fetch the hostname from system settings and
includes it in DHCPDISCOVER even if that's a "disallowed" customized
option. Update the test with MTU option(ideally only DHCP Server should
assign MTU option, but it's just for testing here).

Bug: 185867658
Test: atest NetworkStackIntegrationTests
Change-Id: Iebbf0d6db3c888826db0471d1fb8c82751470167
parent 2b9d86d4
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -200,7 +200,8 @@ public abstract class DhcpPacket {
     * DHCP Optional Type: DHCP Interface MTU
     */
    public static final byte DHCP_MTU = 26;
    protected Short mMtu;
    @VisibleForTesting(otherwise = VisibleForTesting.PROTECTED)
    public Short mMtu;

    /**
     * DHCP Optional Type: DHCP BROADCAST ADDRESS
+4 −3
Original line number Diff line number Diff line
@@ -135,6 +135,7 @@ import androidx.test.InstrumentationRegistry;
import androidx.test.filters.SmallTest;
import androidx.test.runner.AndroidJUnit4;

import com.android.internal.util.HexDump;
import com.android.internal.util.StateMachine;
import com.android.net.module.util.ArrayTrackRecord;
import com.android.net.module.util.Ipv6Utils;
@@ -2748,8 +2749,8 @@ public abstract class IpClientIntegrationTestCommon {
        final List<DhcpOption> options = Arrays.asList(
                makeDhcpOption((byte) 60, TEST_OEM_VENDOR_ID.getBytes()),
                makeDhcpOption((byte) 77, TEST_OEM_USER_CLASS_INFO),
                // DHCP_HOST_NAME
                makeDhcpOption((byte) 12, new String("Pixel 3 XL").getBytes()));
                // Option 26: MTU
                makeDhcpOption((byte) 26, HexDump.toByteArray(TEST_DEFAULT_MTU)));
        final ScanResultInfo info = makeScanResultInfo(0xdd /* vendor-specificIE */, TEST_OEM_OUI,
                (byte) 0x17 /* vendor-specific IE type */);
        final DhcpPacket packet = doCustomizedDhcpOptionsTest(options, info);
@@ -2757,7 +2758,7 @@ public abstract class IpClientIntegrationTestCommon {
        assertTrue(packet instanceof DhcpDiscoverPacket);
        assertEquals(packet.mVendorId, TEST_OEM_VENDOR_ID);
        assertArrayEquals(packet.mUserClass, TEST_OEM_USER_CLASS_INFO);
        assertNull(packet.mHostName);
        assertNull(packet.mMtu);
    }

    @Test