Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.
/ corefx Public archive

Commit

Permalink
Remove invalid NameResolution tests (#24147)
Browse files Browse the repository at this point in the history
The Dns_GetHostEntryAsync_* are fundamentially invalid because it's
possible for the broadcast address, 255.255.255.255, to have an DNS
mapping via manually modifying the hosts file.  This was actually
happening on Mac systems as well as an virtual environment running on
top of that (i.e. Windows on Parallels).

Ref:
https://github.com/dotnet/corefx/issues/23992#issuecomment-330250642

Contributes to #23992
  • Loading branch information
davidsh authored and stephentoub committed Sep 19, 2017
1 parent 7099d7e commit e33bee8
Showing 1 changed file with 0 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -91,34 +91,6 @@ public async Task Dns_GetHostEntryAsync_AnyIPAddress_Fail(IPAddress address)
await Assert.ThrowsAsync<ArgumentException>(() => Dns.GetHostEntryAsync(addressString));
}

public static IEnumerable<object[]> GetNoneAddresses()
{
yield return new object[] { IPAddress.None };
}

[PlatformSpecific(~TestPlatforms.OSX)] // macOS will resolve IPAddress.None to broadcasthost and produce a valid listing
[Theory]
[MemberData(nameof(GetNoneAddresses))]
public async Task Dns_GetHostEntryAsync_NoneIPAddress_Fail(IPAddress address)
{
string addressString = address.ToString();

await Assert.ThrowsAnyAsync<SocketException>(() => Dns.GetHostEntryAsync(address));
await Assert.ThrowsAnyAsync<SocketException>(() => Dns.GetHostEntryAsync(addressString));
}

[PlatformSpecific(TestPlatforms.OSX)] // macOS will resolve IPAddress.None to broadcasthost and produce a valid listing
[Theory]
[MemberData(nameof(GetNoneAddresses))]
public async Task Dns_GetHostEntryAsync_NoneIPAddress_Success(IPAddress address)
{
IPHostEntry result = await Dns.GetHostEntryAsync(address);
Assert.NotNull(result);
Assert.NotNull(result.AddressList);
Assert.Equal(1, result.AddressList.Length);
Assert.Equal(address, result.AddressList[0]);
}

[Fact]
public void DnsBeginGetHostEntry_BadName_Throws()
{
Expand Down

0 comments on commit e33bee8

Please sign in to comment.