Exemplo n.º 1
0
 public void SoapFaultMessageTest()
 {
     RunTest(() =>
     {
         RunStep(() =>
         {
             try
             {
                 SoapMessage <WSD.ProbeMatchesType> response = ProbeDevice(
                     false,
                     //new DiscoveryUtils.DiscoveryType[][] { DiscoveryUtils.GetOnvif10Type(), DiscoveryUtils.GetOnvif20Type() },
                     null,
                     DiscoveryUtils.GetManadatoryScopes(), "InvalidMatchRule");
                 throw new AssertException(response != null ? "DUT responded to invalid probe message" :
                                           "DUT did not respond");
             }
             catch (SoapFaultException ex)
             {
                 string reason;
                 if (!DiscoveryUtils.IsCorrectSoapFault(
                         ex.Fault,
                         "Sender",
                         SoapBuilder.SoapEnvelopeUri,
                         "MatchingRuleNotSupported",
                         DiscoveryUtils.WS_DISCOVER_NS,
                         out reason))
                 {
                     throw new AssertException(reason);
                 }
             }
         }, Resources.StepInvalidProbe_Title);
     });
 }
Exemplo n.º 2
0
        protected void SearchDeviceScopeTypesTestWithTransofrmation(XmlTransformation transformation)
        {
            RunTest(
                () =>
            {
                Scope[] scopes      = GetScopes();
                string missingScope = DiscoveryUtils.GetMissingMandatoryScope(scopes);
                Assert(string.IsNullOrEmpty(missingScope),
                       string.Format(Resources.ErrorMissingMandatoryScope_Format, missingScope),
                       "Validating device scopes");

                XmlNamespacesTransformer transformer = new XmlNamespacesTransformer(transformation, false);

                SoapMessage <WSD.ProbeMatchesType> probeMatch = ProbeDeviceStep(
                    true,
                    //new DiscoveryUtils.DiscoveryType[][] { DiscoveryUtils.GetOnvif10Type() },
                    null,
                    DiscoveryUtils.GetManadatoryScopes(), null, transformer.ProcessMessage);

                string reason = null;
                Assert(ValidateProbeMatchMessage(probeMatch, out reason), reason, Resources.StepValidateProbeMatch_Title);
            });
        }
Exemplo n.º 3
0
        public void SearchDeviceScopeTypesTest()
        {
            RunTest(() =>
            {
                TestTool.Proxies.Onvif.Scope[] scopes = GetScopes();
                string missingScope = DiscoveryUtils.GetMissingMandatoryScope(scopes);
                Assert(string.IsNullOrEmpty(missingScope),
                       string.Format(Resources.ErrorMissingMandatoryScope_Format, missingScope),
                       "Validating device scopes");

                SoapMessage <WSD.ProbeMatchesType> probeMatch = ProbeDeviceStep(true, DiscoveryUtils.GetManadatoryScopes());

                string reason = null;
                Assert(ValidateProbeMatchMessage(probeMatch, out reason), reason, Resources.StepValidateProbeMatch_Title);
            });
        }
Exemplo n.º 4
0
        public void DeviceScopesConfigurationTest()
        {
            bool scopesAdded = false;

            string[]      newScopes         = null;
            bool          scopesReplaced    = false;
            List <string> oldNonfixedScopes = new List <string>();

            RunTest <string[]>(
                new Backup <string[]>(() => { return(null); }),
                () =>
            {
                //get and validate fixed scopes
                Scope[] scopes = GetScopes();

                string missingScope = DiscoveryUtils.GetMissingMandatoryScope(scopes);
                Assert(string.IsNullOrEmpty(missingScope),
                       string.Format(Resources.ErrorMissingMandatoryScope_Format, missingScope),
                       "Validating device scopes");

                //set fixed scopes fault validation
                SetFixedScopes(scopes);

                //set configurable scopes
                List <string> newNonfixedScopes = new List <string>();
                newNonfixedScopes.Add("onvif://www.onvif.org/" + Guid.NewGuid().ToString());
                foreach (Scope scope in scopes)
                {
                    if (scope.ScopeDef == ScopeDefinition.Configurable)
                    {
                        oldNonfixedScopes.Add(scope.ScopeItem);
                        foreach (string mandatoryScope in DiscoveryUtils.GetManadatoryScopes())
                        {
                            if (scope.ScopeItem.Contains(mandatoryScope))
                            {
                                if (!newNonfixedScopes.Contains(mandatoryScope))
                                {
                                    newNonfixedScopes.Add(mandatoryScope);
                                }
                            }
                        }
                    }
                }
                SetScopes(newNonfixedScopes.ToArray());

                // fix for 10767
                Sleep(2000);

                scopesReplaced = true;

                //add new scopes
                //begin wait before sending AddScopes, because Hello can be sent by NVT before response to AddScopes
                newScopes         = new string[] { "onvif://www.onvif.org/" + Guid.NewGuid().ToString(), "onvif://www.onvif.org/" + Guid.NewGuid().ToString() };
                bool canAddScopes = true;
                SoapMessage <WSD.HelloType> hello = null;
                try
                {
                    hello = ReceiveHelloMessage(
                        true,
                        true,
                        () => {
                        AddScopes(newScopes);
                        scopesAdded = true;
                    });
                }
                catch (FaultException fault)
                {
                    if (fault.IsValidOnvifFault("Receiver/Action/TooManyScopes"))
                    {
                        StepPassed();
                        canAddScopes = false;
                    }
                    else
                    {
                        throw;
                    }
                }
                //According to CR26, if device cannot add scopes, consider test as passed.
                if (canAddScopes)
                {
                    List <string> currentScopes = new List <string>(ScopesToStringArray(scopes)
                                                                    .Except(oldNonfixedScopes).Concat(newNonfixedScopes).Concat(newScopes));
                    string reason;
                    Assert(ValidateHelloMessage(hello, currentScopes.ToArray(), out reason), reason, "Hello message validation");

                    //probe new scopes
                    SoapMessage <WSD.ProbeMatchesType> probeMatch = ProbeDeviceStep(true, newScopes);

                    Assert(ValidateProbeMatchMessage(probeMatch, out reason), reason, Resources.StepValidateProbeMatch_Title);

                    //delete create scopes
                    hello = ReceiveHelloMessage(
                        true,
                        true,
                        () =>
                    {
                        RemoveScopes(newScopes);
                        scopesAdded = false;
                    });

                    Assert(ValidateHelloMessage(hello, currentScopes.Except(newScopes).ToArray(), out reason),
                           reason, "Hello message validation");

                    //probe deleted scopes
                    InvalidProbeDeviceStep(true, newScopes);
                }
            },
                (param) =>
            {
                if (scopesAdded && (newScopes != null))
                {
                    RemoveScopes(newScopes);
                }
                if (scopesReplaced && oldNonfixedScopes.Count > 0)
                {
                    if (oldNonfixedScopes.Count > 0)
                    {
                        SetScopes(oldNonfixedScopes.ToArray());
                    }
                }
            });
        }
Exemplo n.º 5
0
 public void UnicastProbeMessageTest()
 {
     RunTest(() =>
     {
         //5.3
         Scope[] scopes      = GetScopes();
         string missingScope = DiscoveryUtils.GetMissingMandatoryScope(scopes);
         Assert(string.IsNullOrEmpty(missingScope),
                string.Format(Resources.ErrorMissingMandatoryScope_Format, missingScope),
                "Validating device scopes");
         SoapMessage <WSD.ProbeMatchesType> probeMatch = ProbeDeviceStep(false, DiscoveryUtils.GetManadatoryScopes());
         string reason = null;
         Assert(ValidateProbeMatchMessage(probeMatch, out reason), reason, Resources.StepValidateProbeMatch_Title);
         //5.4
         probeMatch = ProbeDeviceStep(false, null);
         Assert(ValidateProbeMatchMessage(probeMatch, out reason), reason, Resources.StepValidateProbeMatch_Title);
         //5.5
         InvalidProbeDeviceStep(false, new string[] { "InvalidScope1", "InvalidScope1" });
     });
 }