Exemplo n.º 1
0
        protected override IWebResponse GetResponse(string address)
        {
            switch (requestNum)
            {
            case 1:
                Assert.AreEqual(address, UnitRequest.Objects("filter_objid=1001"));
                return(new ProbeResponse(new ProbeItem(objid: "1001", name: "Local Probe")));

            case 2:
                Assert.AreEqual(address, UnitRequest.Probes("filter_objid=1001&filter_parentid=0"));
                return(new ProbeResponse(new ProbeItem(objid: "1001", name: "Local Probe")));

            //Probe -> Devices
            case 3:
                Assert.AreEqual(address, UnitRequest.Devices("filter_parentid=1001"));
                return(new DeviceResponse(
                           new DeviceItem(objid: "3001", name: "dc-1", position: "10", positionRaw: "10"),
                           new DeviceItem(objid: "3002", name: "dc-2", position: "20", positionRaw: "20")
                           ));

            //Probe -> Groups
            case 4:
                Assert.AreEqual(address, UnitRequest.Groups("filter_parentid=1001"));
                return(new GroupResponse(new GroupItem(objid: "2001", name: "Servers", position: "30", positionRaw: "30")));

            //Probe -> Triggers
            case 5:
                Assert.AreEqual(address, UnitRequest.Triggers(1001));
                return(new NotificationTriggerResponse(
                           NotificationTriggerItem.StateTrigger(onNotificationAction: "300|Trigger1", parentId: "1001"),
                           NotificationTriggerItem.StateTrigger(onNotificationAction: "301|Trigger2", parentId: "1001"),
                           NotificationTriggerItem.StateTrigger(onNotificationAction: "302|Trigger3", parentId: "1001")
                           ));

            //Probe -> Devices -> Sensors
            case 6:
                Assert.AreEqual(address, UnitRequest.Sensors("filter_parentid=3001"));
                return(new SensorResponse(
                           new SensorItem(name: "Sensor2", objid: "4002", position: "20", positionRaw: "20"),
                           new SensorItem(name: "Sensor1", objid: "4001", position: "10", positionRaw: "10")
                           ));

            case 7:
                Assert.AreEqual(address, UnitRequest.Sensors("filter_parentid=3002"));
                return(new SensorResponse());

            //Probe -> Groups -> Devices
            case 8:
                Assert.AreEqual(address, UnitRequest.Devices("filter_parentid=2001"));
                return(new DeviceResponse());

            //Probe -> Groups -> Groups
            case 9:
                Assert.AreEqual(address, UnitRequest.Groups("filter_parentid=2001"));
                return(new GroupResponse());

            default:
                throw UnknownRequest(address);
            }
        }
Exemplo n.º 2
0
 private void QueryProbe(System.Linq.Expressions.Expression <Func <Probe, bool> > predicate, string url)
 {
     ExecuteClient(c => c.QueryProbes(predicate), new[]
     {
         UnitRequest.Probes($"count=500" + (string.IsNullOrEmpty(url) ? url : $"&{url}") + "&filter_parentid=0", UrlFlag.Columns)
     }, s => s.ToList());
 }
Exemplo n.º 3
0
        public void Tree_Lazy_Child_ResolvesOnlyOnce()
        {
            var client = BaseTest.Initialize_Client(new TreeRequestResponse(TreeRequestScenario.MultiLevelContainer));

            var validator = new EventValidator(client, new[]
            {
                //Get Object
                UnitRequest.Objects("filter_objid=1001"),

                //Get Probe
                UnitRequest.Probes("filter_objid=1001&filter_parentid=0"),

                //Probe -> Devices/Groups
                UnitRequest.Devices("filter_parentid=1001"),
                UnitRequest.Groups("filter_parentid=1001"),

                //Probe -> Device -> Sensors
                UnitRequest.Sensors("filter_parentid=3001")
            });

            validator.MoveNext(2);
            var tree = client.GetTreeLazy(1001);

            validator.MoveNext(2);
            var child      = tree.Children[0];
            var childAgain = tree.Children[0];

            validator.MoveNext();
            var grandChild      = child.Children[0];
            var grandChildAgain = child.Children[0];
        }
Exemplo n.º 4
0
        public void ProbeParameters_SearchFilter_ParentId_Equals_ArrayWith_0()
        {
            var parameters = new ProbeParameters(new SearchFilter(Property.ParentId, new[] { 0 }));

            var url = PrtgRequestMessageTests.CreateUrl(parameters, false);

            Assert.AreEqual(UnitRequest.Probes("filter_parentid=0"), url);
        }
Exemplo n.º 5
0
        protected override IWebResponse GetResponse(string address)
        {
            switch (requestNum)
            {
            case 1:
                Assert.AreEqual(UnitRequest.Objects("filter_objid=1001"), address);
                return(new ProbeResponse(new ProbeItem(objid: "1001")));

            case 2:
                Assert.AreEqual(UnitRequest.Probes("filter_objid=1001&filter_parentid=0"), address);
                return(new ProbeResponse(new ProbeItem(objid: "1001", notifiesx: "Inherited 1 State")));

            case 3:
                Assert.AreEqual(UnitRequest.Triggers(1001), address);
                return(new NotificationTriggerResponse(NotificationTriggerItem.StateTrigger(parentId: "1001")));

            case 4:
                if (!async)
                {
                    goto default;
                }
                Assert.AreEqual(UnitRequest.Notifications("filter_objid=301"), address);
                return(new NotificationActionResponse(new NotificationActionItem()));

            case 5:
                if (!async)
                {
                    goto default;
                }
                Assert.AreEqual(UnitRequest.NotificationProperties(301), address);
                return(new NotificationActionResponse(new NotificationActionItem()));

            case 6:
                if (!async)
                {
                    goto default;
                }
                Assert.AreEqual(UnitRequest.Schedules(), address);
                return(new ScheduleResponse(new ScheduleItem()));

            case 7:
                if (!async)
                {
                    goto default;
                }
                Assert.AreEqual(UnitRequest.ScheduleProperties(623), address);
                return(new ScheduleResponse(new ScheduleItem()));

            default:
                throw UnknownRequest(address);
            }
        }
Exemplo n.º 6
0
        public void Tree_Lazy_Id_OneAPIRequest()
        {
            var client = BaseTest.Initialize_Client(new TreeRequestResponse(TreeRequestScenario.ContainerWithGrandChild));

            var validator = new EventValidator(client, new[]
            {
                UnitRequest.Objects("filter_objid=1001"),
                UnitRequest.Probes("filter_objid=1001&filter_parentid=0")
            });

            validator.MoveNext(2);

            var tree = client.GetTreeLazy(1001);
        }
Exemplo n.º 7
0
        protected override IWebResponse GetResponse(string address)
        {
            switch (requestNum)
            {
            case 1:     //We want probes, so we get probes!
                Assert.AreEqual(UnitRequest.Probes("filter_parentid=0"), address);
                return(new ProbeResponse(new ProbeItem(objid: "1001", groupnum: "0", groupnumRaw: "0", devicenum: "0", devicenumRaw: "0")));

            case 2:     //Requesting any objects without the root node is incoherent
                Assert.AreEqual(UnitRequest.Groups("filter_objid=0"), address);
                return(new GroupResponse(new GroupItem(name: "Root", objid: "0")));

            default:
                throw UnknownRequest(address);
            }
        }
Exemplo n.º 8
0
        protected override IWebResponse GetResponse(string address)
        {
            switch (requestNum)
            {
            case 1:     //Resolve Object
                Assert.AreEqual(UnitRequest.Objects("filter_objid=1001"), address);
                return(new ProbeResponse(new ProbeItem(objid: "1001", devicenum: "0", devicenumRaw: "0", groupnum: "0", groupnumRaw: "0")));

            case 2:
                Assert.AreEqual(UnitRequest.Probes("filter_objid=1001&filter_parentid=0"), address);
                return(new ProbeResponse(new ProbeItem(objid: "1001", devicenum: "0", devicenumRaw: "0", groupnum: "0", groupnumRaw: "0")));

            default:
                throw UnknownRequest(address);
            }
        }
Exemplo n.º 9
0
        protected override IWebResponse GetResponse(string address)
        {
            switch (requestNum)
            {
            case 1:
                Assert.AreEqual(UnitRequest.Objects("filter_objid=1001"), address);
                return(new ProbeResponse(new ProbeItem(objid: "1001")));

            case 2:
                Assert.AreEqual(UnitRequest.Probes("filter_objid=1001&filter_parentid=0"), address);
                return(new ProbeResponse(new ProbeItem(objid: "1001")));

            case 3:
                Assert.AreEqual(UnitRequest.RequestObjectData(1001), address);
                return(new SensorSettingsResponse());

            default:
                throw UnknownRequest(address);
            }
        }
Exemplo n.º 10
0
        protected override IWebResponse GetResponse(string address)
        {
            switch (requestNum)
            {
            case 1:
                Assert.AreEqual(UnitRequest.Groups("filter_objid=0"), address);
                return(new GroupResponse(new GroupItem(objid: "0", name: "Root")));

            case 2:
                Assert.AreEqual(UnitRequest.Probes("filter_parentid=0"), address);
                return(new ProbeResponse(new ProbeItem(objid: "1001", groupnum: "2", groupnumRaw: "2", devicenum: "3", devicenumRaw: "3")));

            case 3:
                Assert.AreEqual(UnitRequest.Groups(), address);
                return(new GroupResponse(
                           new GroupItem(objid: "0", parentId: "-1000", name: "Root"),
                           new GroupItem(objid: "2001", parentId: "1001", groupnum: "1", groupnumRaw: "1", devicenum: "2", devicenumRaw: "2"),
                           new GroupItem(objid: "2002", parentId: "2001", name: "VMware", groupnum: "0", groupnumRaw: "0", devicenum: "1", devicenumRaw: "1")
                           ));

            case 4:
                Assert.AreEqual(UnitRequest.Devices(), address);
                return(new DeviceResponse(
                           new DeviceItem(objid: "3001", parentId: "1001", totalsens: "2", totalsensRaw: "2"),
                           new DeviceItem(objid: "3002", parentId: "2001", totalsens: "2", totalsensRaw: "2"),
                           new DeviceItem(objid: "3003", parentId: "2002", totalsens: "2", totalsensRaw: "2")
                           ));

            case 5:
                Assert.AreEqual(UnitRequest.Sensors(), address);
                return(new SensorResponse(
                           new SensorItem(objid: "4001", parentId: "3001"),
                           new SensorItem(objid: "4002", parentId: "3002"),
                           new SensorItem(objid: "4003", parentId: "3003")
                           ));

            default:
                throw UnknownRequest(address);
            }
        }
        protected override IWebResponse GetResponse(string address)
        {
            switch (requestNum)
            {
            case 1:
                Assert.AreEqual(UnitRequest.Probes("count=1&filter_parentid=0", UrlFlag.Columns), address);
                return(new BasicResponse(standardResponse.GetResponseText(ref address)));

            //Probe 1

            case 2:
                Assert.AreEqual(UnitRequest.Groups("filter_probe=127.0.0.10"), address);
                return(new BasicResponse(standardResponse.GetResponseText(ref address)));

            //Tree

            case 3:
                Assert.AreEqual(UnitRequest.Devices("filter_parentid=2000"), address);
                return(new DeviceResponse(new DeviceItem(objid: "3000", totalsens: "1", totalsensRaw: "1")));

            case 4:
                Assert.AreEqual(UnitRequest.Sensors("filter_parentid=3000"), address);
                return(new SensorResponse(new SensorItem(objid: "4000")));

            case 5:
                Assert.AreEqual(UnitRequest.Devices("filter_parentid=2001"), address);
                return(new DeviceResponse(new DeviceItem(objid: "3001", totalsens: "1", totalsensRaw: "1")));

            case 6:
                Assert.AreEqual(UnitRequest.Sensors("filter_parentid=3001"), address);
                return(new SensorResponse(new SensorItem(objid: "4001")));

            default:
                throw UnknownRequest(address);
            }
        }
Exemplo n.º 12
0
        protected override IWebResponse GetResponse(string address)
        {
            switch (requestNum)
            {
            case 1:
                Assert.AreEqual(UnitRequest.Objects("filter_objid=1001"), address);
                return(new ProbeResponse(new ProbeItem(objid: "1001")));

            case 2:
                Assert.AreEqual(UnitRequest.Probes("filter_objid=1001&filter_parentid=0"), address);
                return(new ProbeResponse(new ProbeItem(objid: "1001")));

            case 3:
                Assert.AreEqual(UnitRequest.Groups("filter_parentid=1001"), address);
                return(new GroupResponse(new GroupItem(objid: "3001", name: "Servers", parentId: "1001")));

            case 4:
                Assert.AreEqual(UnitRequest.Groups("filter_parentid=3001"), address);
                return(new GroupResponse());

            default:
                throw UnknownRequest(address);
            }
        }
Exemplo n.º 13
0
        protected override IWebResponse GetResponse(string address)
        {
            switch (requestNum)
            {
            case 1:
                Assert.AreEqual(UnitRequest.Probes("filter_parentid=0"), address);
                return(new ProbeResponse(new ProbeItem(objid: "1001", groupnum: "2", groupnumRaw: "2", devicenum: "3", devicenumRaw: "3")));

            case 2:
                Assert.AreEqual(UnitRequest.Groups(), address);
                return(new GroupResponse(
                           new GroupItem(objid: "0", parentId: "-1000", name: "Root"),
                           new GroupItem(objid: "2001", parentId: "1001", groupnum: "1", groupnumRaw: "1", devicenum: "2", devicenumRaw: "2"),
                           new GroupItem(objid: "2002", parentId: "2001", name: "VMware", groupnum: "0", groupnumRaw: "0", devicenum: "1", devicenumRaw: "1")
                           ));

            case 3:
                Assert.AreEqual(UnitRequest.Devices(), address);
                return(new DeviceResponse(
                           new DeviceItem(objid: "3001", parentId: "1001", totalsens: "2", totalsensRaw: "2"),
                           new DeviceItem(objid: "3002", parentId: "2001", totalsens: "2", totalsensRaw: "2"),
                           new DeviceItem(objid: "3003", parentId: "2002", totalsens: "2", totalsensRaw: "2")
                           ));

            case 4:
                Assert.AreEqual(UnitRequest.Sensors(), address);
                return(new SensorResponse(
                           new SensorItem(objid: "4001", parentId: "3001"),
                           new SensorItem(objid: "4002", parentId: "3002"),
                           new SensorItem(objid: "4003", parentId: "3003")
                           ));

            case 5:
                Assert.AreEqual(UnitRequest.Triggers(1001), address);
                return(new NotificationTriggerResponse(NotificationTriggerItem.StateTrigger(parentId: "1001")));

            case 6:
                if (!async)
                {
                    goto default;
                }
                Assert.AreEqual(UnitRequest.Notifications("filter_objid=301"), address);
                return(new NotificationActionResponse(new NotificationActionItem()));

            case 7:
                if (!async)
                {
                    goto default;
                }
                Assert.AreEqual(UnitRequest.NotificationProperties(301), address);
                return(new NotificationActionResponse(new NotificationActionItem()));

            case 8:
                if (!async)
                {
                    goto default;
                }
                Assert.AreEqual(UnitRequest.Schedules(), address);
                return(new ScheduleResponse(new ScheduleItem()));

            case 9:
                if (!async)
                {
                    goto default;
                }
                Assert.AreEqual(UnitRequest.ScheduleProperties(623), address);
                return(new ScheduleResponse(new ScheduleItem()));

            default:
                throw UnknownRequest(address);
            }
        }
Exemplo n.º 14
0
        protected override IWebResponse GetResponse(string address)
        {
            switch (requestNum)
            {
            case 1:     //Resolve Object
                Assert.AreEqual(UnitRequest.Objects("filter_objid=1001"), address);
                return(new ProbeResponse(new ProbeItem(objid: "1001", groupnum: "2", groupnumRaw: "2", devicenum: "3", devicenumRaw: "3")));

            case 2:     //Probes
                Assert.AreEqual(UnitRequest.Probes("filter_objid=1001&filter_parentid=0"), address);
                return(new ProbeResponse(new ProbeItem(objid: "1001", groupnum: "2", groupnumRaw: "2", devicenum: "3", devicenumRaw: "3", notifiesx: "Inherited 1 State")));

            case 3:     //Probe -> Device
                Assert.AreEqual(UnitRequest.Devices("filter_parentid=1001"), address);
                return(new DeviceResponse(new DeviceItem(objid: "3001", totalsens: "2", totalsensRaw: "2")));

            case 4:     //Probe -> Group
                Assert.AreEqual(UnitRequest.Groups("filter_parentid=1001"), address);
                return(new GroupResponse(new GroupItem(objid: "2001", groupnum: "1", groupnumRaw: "1", devicenum: "2", devicenumRaw: "2")));

            case 5:     //Probe -> Device -> Sensor
                Assert.AreEqual(UnitRequest.Sensors("filter_parentid=3001"), address);
                return(new SensorResponse(new SensorItem(objid: "4001")));

            case 6:     //Probe -> Group -> Device
                Assert.AreEqual(UnitRequest.Devices("filter_parentid=2001"), address);
                return(new DeviceResponse(new DeviceItem(objid: "3002", totalsens: "2", totalsensRaw: "2")));

            case 7:     //Probe -> Group -> Group
                Assert.AreEqual(UnitRequest.Groups("filter_parentid=2001"), address);
                return(new GroupResponse(new GroupItem(objid: "2002", name: "VMware", groupnum: "0", groupnumRaw: "0", devicenum: "1", devicenumRaw: "1")));

            case 8:     //Probe -> Group -> Device -> Sensor
                Assert.AreEqual(UnitRequest.Sensors("filter_parentid=3002"), address);
                return(new SensorResponse(new SensorItem(objid: "4002")));

            case 9:     //Probe -> Group -> Group -> Device
                Assert.AreEqual(UnitRequest.Devices("filter_parentid=2002"), address);
                return(new DeviceResponse(new DeviceItem(objid: "3003", totalsens: "2", totalsensRaw: "2")));

            case 10:     //Probe -> Group -> Group -> Sensor
                Assert.AreEqual(UnitRequest.Sensors("filter_parentid=3003"), address);
                return(new SensorResponse(new SensorItem(objid: "4003")));

            case 11:
                Assert.AreEqual(UnitRequest.Triggers(1001), address);
                return(new NotificationTriggerResponse(NotificationTriggerItem.StateTrigger(parentId: "1001")));

            case 12:
                if (!async)
                {
                    goto default;
                }
                Assert.AreEqual(UnitRequest.Notifications("filter_objid=301"), address);
                return(new NotificationActionResponse(new NotificationActionItem()));

            case 13:
                if (!async)
                {
                    goto default;
                }
                Assert.AreEqual(UnitRequest.NotificationProperties(301), address);
                return(new NotificationActionResponse(new NotificationActionItem()));

            case 14:
                if (!async)
                {
                    goto default;
                }
                Assert.AreEqual(UnitRequest.Schedules(), address);
                return(new ScheduleResponse(new ScheduleItem()));

            case 15:
                if (!async)
                {
                    goto default;
                }
                Assert.AreEqual(UnitRequest.ScheduleProperties(623), address);
                return(new ScheduleResponse(new ScheduleItem()));

            default:
                throw UnknownRequest(address);
            }
        }
Exemplo n.º 15
0
        protected override IWebResponse GetResponse(string address)
        {
            switch (requestNum)
            {
            case 1:
                Assert.AreEqual(UnitRequest.Probes("filter_parentid=0"), address);
                return(new ProbeResponse(new ProbeItem(objid: "1001", groupnum: "2", groupnumRaw: "2", devicenum: "3", devicenumRaw: "3", notifiesx: "Inherited")));

            case 2:
                Assert.AreEqual(UnitRequest.Groups(), address);
                return(new GroupResponse(
                           new GroupItem(objid: "0", parentId: "-1000", name: "Root"),
                           new GroupItem(objid: "2001", parentId: "1001", groupnum: "1", groupnumRaw: "1", devicenum: "2", devicenumRaw: "2"),
                           new GroupItem(objid: "2002", parentId: "2001", name: "VMware", groupnum: "0", groupnumRaw: "0", devicenum: "1", devicenumRaw: "1")
                           ));

            case 3:
                Assert.AreEqual(UnitRequest.Devices(), address);
                return(new DeviceResponse(
                           new DeviceItem(objid: "3001", parentId: "1001", totalsens: "2", totalsensRaw: "2"),
                           new DeviceItem(objid: "3002", parentId: "2001", totalsens: "2", totalsensRaw: "2"),
                           new DeviceItem(objid: "3003", parentId: "2002", totalsens: "2", totalsensRaw: "2")
                           ));

            case 4:
                Assert.AreEqual(UnitRequest.Sensors(), address);
                return(new SensorResponse(
                           new SensorItem(objid: "4001", parentId: "3001"),
                           new SensorItem(objid: "4002", parentId: "3002"),
                           new SensorItem(objid: "4003", parentId: "3003")
                           ));

            case 5:
                Assert.AreEqual(UnitRequest.RequestObjectData(4001), address);
                return(new SensorSettingsResponse());

            case 6:
                Assert.AreEqual(UnitRequest.RequestObjectData(3001), address);
                return(new SensorSettingsResponse());

            case 7:
                Assert.AreEqual(UnitRequest.RequestObjectData(4002), address);
                return(new SensorSettingsResponse());

            case 8:
                Assert.AreEqual(UnitRequest.RequestObjectData(3002), address);
                return(new SensorSettingsResponse());

            case 9:
                Assert.AreEqual(UnitRequest.RequestObjectData(4003), address);
                return(new SensorSettingsResponse());

            case 10:
                Assert.AreEqual(UnitRequest.RequestObjectData(3003), address);
                return(new SensorSettingsResponse());

            case 11:
                Assert.AreEqual(UnitRequest.RequestObjectData(2002), address);
                return(new SensorSettingsResponse());

            case 12:
                Assert.AreEqual(UnitRequest.RequestObjectData(2001), address);
                return(new SensorSettingsResponse());

            case 13:
                Assert.AreEqual(UnitRequest.RequestObjectData(1001), address);
                return(new SensorSettingsResponse());

            case 14:
                Assert.AreEqual(UnitRequest.RequestObjectData(0), address);
                return(new SensorSettingsResponse());

            default:
                throw UnknownRequest(address);
            }
        }