public void SetInvalidIpv6DnsConfigurationTest() { // turn OFF DHCP RunTest <NetworkInterface>( new Backup <NetworkInterface>( () => { NetworkInterface ni = TurnOffDhcpIpv6(); return(ni); }), () => { DNSInformation testInformation = new DNSInformation(); testInformation.FromDHCP = false; testInformation.DNSManual = new IPAddress[] { new IPAddress() { IPv6Address = "FF02:1", Type = IPType.IPv6 } }; string reason = string.Empty; RunStep(() => { Client.SetDNS(testInformation.FromDHCP, testInformation.SearchDomain, testInformation.DNSManual); }, "Set DNS configuration - negative test", "Sender/InvalidArgVal/InvalidIPv6Address", true); DoRequestDelay(); DNSInformation actualInformation = GetDnsConfiguration(); Assert(actualInformation != null, "Failed to get current DNS configuration", "Check that current DNS configuration returned from the DUT"); bool bValid = actualInformation.IsValidDnsInformation(false, out reason); Assert(bValid, reason, "Validate current DNS configuration"); bool bFound = (actualInformation.DNSManual != null && actualInformation.DNSManual.Length > 0) && actualInformation.DNSManual.Where( IP => IP.IPv4Address == testInformation.DNSManual[0].IPv6Address). Count() > 0; Assert(!bFound, "DUT set address to invalid value", "Check that current IPv6 addresses list does not contain invalid value"); }, (ni) => { if (ni.IPv6.Config.DHCP != IPv6DHCPConfiguration.Off) { RestoreNetworkInterface(ni.token, ni); } }); }
public void GetDnsConfigurationTest() { RunTest(() => { DNSInformation dnsInformation = GetDnsConfiguration(); Assert(dnsInformation != null, "DNSInformation not returned", "Check that DUT returned DNSInformation"); string error; bool dnsInformationOk = dnsInformation.IsValidDnsInformation(false, out error); Assert(dnsInformationOk, error, "Validate DNS information"); }); }
public void SetDnsConfigurationDnsFromDHCPTest() { NetworkInterface ni = null; RunTest <DNSInformation>( new Backup <DNSInformation>(() => { DNSInformation originalInformation = GetDnsConfiguration(); string reason = null; Assert((originalInformation != null) && originalInformation.IsValidDnsInformation(false, out reason), reason == null ? "Failed to get original DNS configuration" : reason, "Check that valid DNS configuration returned from the DUT"); ni = TurnOnDhcpIpv4(); return(originalInformation); }), () => { DNSInformation testInformation = new DNSInformation(); testInformation.FromDHCP = true; SetDnsConfiguration(testInformation); double timeout = ((double)_operationDelay) / 1000; BeginStep(string.Format("Wait {0} seconds to allow the DUT to interact with DHCP server", timeout.ToString("0.000"))); Sleep(_operationDelay); StepPassed(); DNSInformation actualInformation = GetDnsConfiguration(); string reason = null; Assert((actualInformation != null) && actualInformation.IsValidDnsInformation(false, out reason), reason == null ? "Failed to get original DNS configuration" : reason, "Check that original DNS configuration returned from the DUT"); Assert(actualInformation != null, "Failed to get current DNS configuration", "Check that current DNS configuration returned from the DUT"); BeginStep("Check current DNS configuration"); bool bAllEquals; bool bEquals = (actualInformation.FromDHCP == testInformation.FromDHCP); LogStepEvent(string.Format("FromDHCP: expected - {0}, actual - {1}", testInformation.FromDHCP, actualInformation.FromDHCP)); bAllEquals = bEquals; string actualIpDescription; actualIpDescription = DeviceManagementNetworkTestSuite.DumpIPArray(actualInformation.DNSManual); string expectedAddress = "No IP Address"; if (actualInformation.DNSManual != null && actualInformation.DNSManual.Count() > 0) { bEquals = false; } else { bEquals = true; } LogStepEvent(string.Format("DNSManual: expected - {0}, actual - {1}", expectedAddress, actualIpDescription)); bAllEquals = bAllEquals && bEquals; /*************************************************/ actualIpDescription = DeviceManagementNetworkTestSuite.DumpIPArray(actualInformation.DNSFromDHCP); if (actualInformation.DNSFromDHCP == null) { bEquals = false; } else { bEquals = (actualInformation.DNSFromDHCP.Length > 0); } string expectedDescription = "List of DNS servers"; LogStepEvent(string.Format("DNSFromDHCP: expected - {0}, actual - {1}", expectedDescription, actualIpDescription)); bAllEquals = bAllEquals && bEquals; /*********************************************************/ if (!bAllEquals) { throw new AssertException("Current DNS configuration differs from configuration was set"); } StepPassed(); }, (originalInformation) => { SetDnsConfiguration(originalInformation, "Restore DNS configuration"); // if DHCP was ON, it has not been changed if (!ni.IPv4.Config.DHCP) { // restore network interface configuration RestoreNetworkInterface(ni.token, ni); } } ); }