Example #1
0
        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);
                }
            });
        }
Example #2
0
        DNSInformation GetOriginalDnsConfiguration()
        {
            DNSInformation originalInformation = GetDnsConfiguration();

            Assert(originalInformation != null, "Failed to get original DNS configuration", "Check that original DNS configuration returned from the DUT");
            return(originalInformation);
        }
Example #3
0
        protected DNSInformation GetDnsConfiguration()
        {
            DNSInformation dnsInformation = null;

            RunStep(() => { dnsInformation = Client.GetDNS(); }, "Get DNS configuration");
            return(dnsInformation);
        }
Example #4
0
 protected void SetDnsConfiguration(DNSInformation information, string stepName)
 {
     RunStep(() =>
     {
         Client.SetDNS(
             information.FromDHCP,
             information.SearchDomain,
             information.DNSManual);
     }, stepName);
 }
Example #5
0
        public void SetDnsConfigurationSearchDomainTest()
        {
            RunTest <DNSInformation>(

                new Backup <DNSInformation>(() =>
            {
                DNSInformation originalInformation = GetDnsConfiguration();
                Assert(originalInformation != null, "Failed to get original DNS configuration", "Check that original DNS configuration returned from the DUT");
                return(originalInformation);
            }),

                () =>
            {
                DNSInformation testInformation = new DNSInformation();
                testInformation.SearchDomain   = new string[] { "domain.name" };
                testInformation.FromDHCP       = false;

                SetDnsConfiguration(testInformation);

                double timeout = ((double)_operationDelay) / 1000;

                BeginStep(string.Format("Wait {0} seconds to allow the DUT to apply settings", timeout.ToString("0.000")));
                Sleep(_operationDelay);
                StepPassed();

                DNSInformation actual = GetDnsConfiguration();

                Assert(actual != null, "Failed to get current DNS configuration", "Check that DNS configuration returned from the DUT");

                Assert(actual.FromDHCP == false, "FromDHCP is TRUE", "Check that FromDHCP is false");

                Assert(actual.SearchDomain != null, "No Search Domains returned from the DUT", "Check that the DUT returned Search Domains");

                string actualDomainsDescription = DumpStringArray(actual.SearchDomain);

                bool domainFound = actual.SearchDomain.Contains(testInformation.SearchDomain[0],
                                                                StringComparer.InvariantCultureIgnoreCase);

                Assert(domainFound,
                       string.Format("SearchDomain does not equal to the value was set. "),
                       "Validate SearchDomain value",
                       string.Format("Expected: '{0}' should be presented, actual: {1}", testInformation.SearchDomain[0], actualDomainsDescription));
            },

                (originalInformation) =>
            {
                SetDnsConfiguration(originalInformation, "Restore DNS configuration");
            }

                );
        }
Example #6
0
        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");
            });
        }
Example #7
0
 /// <summary>
 /// Checks if DNS information is valid.
 /// </summary>
 /// <param name="dnsInformation">DNS information.</param>
 /// <param name="ipAddressMandatory">True, if IP address cannot be omitted.</param>
 /// <param name="reason">Failure reason.</param>
 /// <returns></returns>
 public static bool IsValidDnsInformation(this DNSInformation dnsInformation, bool ipAddressMandatory, out string reason)
 {
     reason = string.Empty;
     if (dnsInformation.FromDHCP)
     {
         if ((dnsInformation.DNSManual != null) &&
             (dnsInformation.DNSManual.Length > 0))
         {
             reason = "DNSManual is not empty, while FromDHCP is true";
             return(false);
         }
         if ((dnsInformation.DNSFromDHCP != null) &&
             !AreValidAddresses(dnsInformation.DNSFromDHCP, ipAddressMandatory, out reason))
         {
             return(false);
         }
     }
     else
     {
         if ((dnsInformation.DNSFromDHCP != null) &&
             (dnsInformation.DNSFromDHCP.Length > 0))
         {
             reason = "DNSFromDHCP is not empty, while FromDHCP is false";
             return(false);
         }
         if ((dnsInformation.DNSManual != null) &&
             !AreValidAddresses(dnsInformation.DNSManual, ipAddressMandatory, out reason))
         {
             return(false);
         }
     }
     if (dnsInformation.SearchDomain != null)
     {
         foreach (string hostname in dnsInformation.SearchDomain)
         {
             if (!IsValidHostName(hostname))
             {
                 reason = string.Format("Invalid host name ({0})", hostname);
                 return(false);
             }
         }
     }
     return(true);
 }
Example #8
0
        void SetDnsConfiguration()
        {
            DNSInformation testInformation = new DNSInformation();

            testInformation.FromDHCP  = false;
            testInformation.DNSManual =
                new IPAddress[]
            {
                new IPAddress()
                {
                    IPv4Address = _environmentSettings.DnsIpv4, Type = IPType.IPv4
                }
            };

            SetDnsConfiguration(testInformation);

            double timeout = ((double)_operationDelay) / 1000;

            BeginStep(string.Format("Wait {0} seconds to allow the DUT to apply settings", timeout.ToString("0.000")));
            Sleep(_operationDelay);
            StepPassed();

            DNSInformation actualInformation = GetDnsConfiguration();

            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 = DumpIPArray(actualInformation.DNSManual);

            string expectedAddress = testInformation.DNSManual[0].IPv4Address;
            IPType expectedType    = testInformation.DNSManual[0].Type;

            if (actualInformation.DNSManual.Where(
                    A => A.Type == expectedType && A.IPv4Address == expectedAddress).Count() > 0)
            {
                bEquals = true;
            }
            else
            {
                bEquals = false;
            }

            LogStepEvent(string.Format("DNSManual: expected - {0} should be presented, actual - {1}",
                                       expectedAddress, actualIpDescription));

            bAllEquals = bAllEquals && bEquals;

            // Compare DNSFromDHCP part

            actualIpDescription = DumpIPArray(actualInformation.DNSFromDHCP);

            if (actualInformation.DNSFromDHCP == null)
            {
                bEquals = true;
            }
            else
            {
                bEquals = (actualInformation.DNSFromDHCP.Length == 0);
            }

            string expectedDescription = "No DNSFromDHCP";

            LogStepEvent(string.Format("DNSFromDHCP: expected - {0}, actual - {1}",
                                       expectedDescription, actualIpDescription));

            bAllEquals = bAllEquals && bEquals;

            // Compare Search Domain

            // ToDo : remove search domain validation.
            // The DUT may leave old Search Domain (TT Release Notes)
            //expectedDescription = "no Search Domains";
            //string actualDomainsDescription = DumpStringArray(actualInformation.SearchDomain);
            //if (actualInformation.SearchDomain == null)
            //{
            //    bEquals = true;
            //}
            //else
            //{
            //    bEquals = (actualInformation.SearchDomain.Length == 0);
            //}

            //LogStepEvent(string.Format("SearchDomain: expected - {0}, actual - {1}",
            //expectedDescription, actualDomainsDescription));

            //bAllEquals = bAllEquals && bEquals;

            // Dump total result

            if (!bAllEquals)
            {
                throw new AssertException("Current DNS configuration differs from configuration was set");
            }

            StepPassed();
        }
Example #9
0
 void RestoreOriginalDnsConfiguration(DNSInformation originalInformation)
 {
     SetDnsConfiguration(originalInformation, "Restore DNS configuration");
 }
Example #10
0
        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);
                }
            }
                );
        }
Example #11
0
        public void SetDnsConfigurationDnsManualIpv6Test()
        {
            NetworkInterface ni = null;

            RunTest <DNSInformation>(

                new Backup <DNSInformation>(() =>
            {
                DNSInformation originalInformation = GetDnsConfiguration();
                Assert(originalInformation != null, "Failed to get original DNS configuration", "Check that original DNS configuration returned from the DUT");

                ni = TurnOffDhcpIpv6();

                return(originalInformation);
            }),

                () =>
            {
                DNSInformation testInformation = new DNSInformation();
                testInformation.FromDHCP       = false;
                testInformation.DNSManual      =
                    new IPAddress[]
                {
                    new IPAddress()
                    {
                        IPv6Address = _environmentSettings.DnsIpv6, Type = IPType.IPv6
                    }
                };

                SetDnsConfiguration(testInformation);

                double timeout = ((double)_operationDelay) / 1000;

                BeginStep(string.Format("Wait {0} seconds to allow the DUT to apply settings", timeout.ToString("0.000")));
                Sleep(_operationDelay);
                StepPassed();

                DNSInformation actualInformation = GetDnsConfiguration();

                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 = testInformation.DNSManual[0].IPv6Address;
                IPType expectedType    = testInformation.DNSManual[0].Type;

                if (actualInformation.DNSManual.Where(
                        A => A.Type == expectedType && A.IPv6Address == expectedAddress).Count() > 0)
                {
                    bEquals = true;
                }
                else
                {
                    bEquals = false;
                }

                LogStepEvent(string.Format("DNSManual: expected - {0} should be presented, actual - {1}",
                                           expectedAddress, actualIpDescription));

                bAllEquals = bAllEquals && bEquals;

                /*************************************************/

                actualIpDescription = DeviceManagementNetworkTestSuite.DumpIPArray(actualInformation.DNSFromDHCP);

                if (actualInformation.DNSFromDHCP == null)
                {
                    bEquals = true;
                }
                else
                {
                    bEquals = (actualInformation.DNSFromDHCP.Length == 0);
                }

                string expectedDescription = "No DNSFromDHCP";

                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 (ni.IPv6.Config.DHCP != IPv6DHCPConfiguration.Off)
                {
                    // restore network interface configuration
                    RestoreNetworkInterface(ni.token, ni);
                }
            }
                );
        }
 protected void SetDnsConfiguration(DNSInformation information)
 {
     SetDnsConfiguration(information, "Set DNS configuration");
 }