public void GetAccessPointInfoInfoListInvalidTokenTest() { RunTest(() => { List <AccessPointInfo> fullList = GetFullAccessPointInfoList(); if (fullList == null || fullList.Count == 0) { // should be inaccessible (GetFullAccessPointInfoList checks that list is not empty) return; } string token = Guid.NewGuid().ToString().Substring(0, 8); AccessPointInfo[] infos = null; RunStep(() => { infos = Client.GetAccessPointInfo(new string[] { token }); }, "Get AccessPointInfo with invalid token"); Assert(infos == null || infos.Length == 0, "List of AccessPointInfo is not empty", "Check that the DUT returned no AccessPointInfos"); int maxLimit = GetMaxLimit(); if (maxLimit >= 2) { infos = GetAccessPointInfo(new string[] { fullList[0].token, token }); AccessPointInfo expected = fullList[0]; this.CheckRequestedInfo(infos, expected.token, D => D.token, "AccessPointInfo", Assert); } else { LogTestEvent(string.Format("MaxLimit={0}, skip part with sending request with one correct and one incorrect tokens.", maxLimit) + Environment.NewLine); } }); }
public AccessPointInfo GetAccessPointInfo(string Token) { BeginMethod("GetAccessPointInfo"); AccessPointInfo info = GetInfo(Token, I => I.token, S => S.PacsConfiguration.AccessPointInfoList); EndMethod(); return(info); }
public void DisplayAccessPointInfo(AccessPointInfo info) { _accessPoint = info; if (info != null) { tbToken.Text = info.token; tbName.Text = info.Name; tbDescription.Text = info.Description; tbAreaFrom.Text = info.AreaFrom; tbAreaTo.Text = info.AreaTo; tbEntityType.Text = info.EntityType != null ? info.EntityType.Name : "tdc:Door"; tbEntity.Text = info.Entity; AccessPointCapabilities capabilities = info.Capabilities; if (capabilities != null) { chkAccessTaken.Checked = capabilities.AccessTakenSpecified && capabilities.AccessTaken; chkDisable.Checked = capabilities.DisableAccessPoint; chkTamper.Checked = capabilities.TamperSpecified && capabilities.Tamper; chkExternal.Checked = capabilities.ExternalAuthorizationSpecified && capabilities.ExternalAuthorization; chkAnonymousAccess.Checked = capabilities.AnonymousAccessSpecified && capabilities.AnonymousAccess; chkDuress.Checked = capabilities.DuressSpecified && capabilities.Duress; } } else { tbToken.Text = string.Empty; tbName.Text = string.Empty; tbDescription.Text = string.Empty; tbAreaFrom.Text = string.Empty; tbAreaTo.Text = string.Empty; tbEntityType.Text = string.Empty; tbEntity.Text = string.Empty; chkAccessTaken.Checked = false; chkDisable.Checked = false; chkTamper.Checked = false; chkExternal.Checked = false; chkAnonymousAccess.Checked = false; chkDuress.Checked = false; } foreach (Button btn in new Button[] { }) { btn.Enabled = info != null; } }
public void EnableAccessPoint(string Token) { BeginMethod("EnableAccessPoint"); AccessPointInfo info = GetInfo(Token, I => I.token, S => S.PacsConfiguration.AccessPointInfoList); if (info.Capabilities.DisableAccessPoint) { info.Enabled = true; } else { Transport.CommonUtils.ReturnFault("Receiver", "ActionNotSupported"); } EndMethod(); }
void tvDoors_AfterSelect(object sender, TreeViewEventArgs e) { TreeNode node = e.Node; if (node != null) { while (node.Parent != null) { node = node.Parent; } AccessPointInfo info = node.Tag as AccessPointInfo; DisplayAccessPointInfo(info); } else { DisplayAccessPointInfo(null); } }
public SimulatorConfiguration NormalConfiguration() { SimulatorConfiguration configuration = new SimulatorConfiguration(); configuration.ServicesConfiguration = new ServicesConfiguration(); DeviceServiceCapabilities deviceServiceCapabilities = new DeviceServiceCapabilities(); deviceServiceCapabilities.Network = new NetworkCapabilities(); deviceServiceCapabilities.Network.Dot11Configuration = true; deviceServiceCapabilities.Network.Dot11ConfigurationSpecified = true; deviceServiceCapabilities.Network.DynDNS = true; deviceServiceCapabilities.Network.Dot11ConfigurationSpecified = true; deviceServiceCapabilities.Network.HostnameFromDHCP = true; deviceServiceCapabilities.Network.HostnameFromDHCPSpecified = true; deviceServiceCapabilities.Network.IPFilter = false; deviceServiceCapabilities.Network.IPFilterSpecified = true; deviceServiceCapabilities.Network.IPVersion6 = false; deviceServiceCapabilities.Network.IPVersion6Specified = true; deviceServiceCapabilities.Network.NTP = 1; deviceServiceCapabilities.Network.NTPSpecified = true; deviceServiceCapabilities.Network.ZeroConfiguration = false; deviceServiceCapabilities.Network.ZeroConfigurationSpecified = true; deviceServiceCapabilities.Security = new SecurityCapabilities(); deviceServiceCapabilities.System = new SystemCapabilities(); deviceServiceCapabilities.System.HttpSystemBackup = true; deviceServiceCapabilities.System.HttpSystemBackupSpecified = true; deviceServiceCapabilities.System.SystemLogging = true; deviceServiceCapabilities.System.SystemLoggingSpecified = true; configuration.ServicesConfiguration.DeviceServiceCapabilities = deviceServiceCapabilities; configuration.ServicesConfiguration.CreateOldStyleCapabilities(); configuration.DeviceInformation = new DeviceInformation(); configuration.DeviceInformation.Brand = "ONVIF"; configuration.DeviceInformation.FirmwareVersion = "1.0"; configuration.DeviceInformation.HardwareId = "12345"; configuration.DeviceInformation.Model = "Ideal PACS Device"; configuration.DeviceInformation.SerialNumber = "123456789"; AccessControlServiceCapabilities accessControlServiceCapabilities = new AccessControlServiceCapabilities(); accessControlServiceCapabilities.DisableAccessPoint = true; accessControlServiceCapabilities.DisableAccessPointSpecified = true; accessControlServiceCapabilities.MaxLimit = 10; configuration.ServicesConfiguration.AccessControlCapabilities = accessControlServiceCapabilities; DoorControlServiceCapabilities doorControlServiceCapabilities = new DoorControlServiceCapabilities(); doorControlServiceCapabilities.MaxLimit = 3; configuration.ServicesConfiguration.DoorServiceCapabilities = doorControlServiceCapabilities; configuration.ServicesConfiguration.InitializeXmlElements(); List <Service> services = new List <Service>(); { Service device = new Service(); device.Namespace = Common.Definitions.OnvifService.DEVICE; device.Version = new OnvifVersion(); device.Version.Major = 2; device.Version.Minor = 2; services.Add(device); } { Service events = new Service(); events.Namespace = Common.Definitions.OnvifService.EVENTS; events.Version = new OnvifVersion(); events.Version.Major = 2; events.Version.Minor = 2; services.Add(events); } { Service pacs = new Service(); pacs.Namespace = Common.Definitions.OnvifService.ACCESSCONTROL; pacs.Version = new OnvifVersion(); pacs.Version.Major = 2; pacs.Version.Minor = 2; services.Add(pacs); } { Service doorControl = new Service(); doorControl.Namespace = Common.Definitions.OnvifService.DOORCONTROL; doorControl.Version = new OnvifVersion(); doorControl.Version.Major = 2; doorControl.Version.Minor = 2; services.Add(doorControl); } configuration.ServicesConfiguration.Services = services; List <Scope> scopes = new List <Scope>(); scopes.Add(new Scope() { ScopeItem = "onvif://www.onvif.org/profile/profilec" }); scopes.Add(new Scope() { ScopeItem = "onvif://www.onvif.org/name/Simulator" }); scopes.Add(new Scope() { ScopeItem = "onvif://www.onvif.org/hardware/PC" }); scopes.Add(new Scope() { ScopeItem = "onvif://www.onvif.org/location/scope1" }); configuration.Scopes = scopes; #region PACS initialization configuration.PacsConfiguration = new PacsConfiguration(); { AccessPointInfo info = new AccessPointInfo(); info.token = "tokenAccessPoint1"; info.Name = "AccessPoint1 Name"; info.Description = "AccessPoint1 Description"; info.AreaFrom = "tokenArea1"; info.AreaTo = "tokenArea2"; info.Enabled = true; info.Type = "tdc:Door"; info.Entity = "tokenDoor1"; info.Capabilities = new AccessPointCapabilities(); info.Capabilities.DisableAccessPoint = true; configuration.PacsConfiguration.AccessPointInfoList.Add(info); } { AccessPointInfo info = new AccessPointInfo(); info.token = "tokenAccessPoint2"; info.Name = "AccessPoint2 Name"; info.Description = "AccessPoint2 Description"; info.Enabled = true; info.Type = "tdc:Door"; info.Entity = "tokenDoor1"; info.Capabilities = new AccessPointCapabilities(); info.Capabilities.DisableAccessPoint = false; configuration.PacsConfiguration.AccessPointInfoList.Add(info); } { AreaInfo info = new AreaInfo(); info.token = "tokenArea1"; info.Name = "Area1 Name"; info.Description = "Area1 Description"; configuration.PacsConfiguration.AreaInfoList.Add(info); } { AreaInfo info = new AreaInfo(); info.token = "tokenArea2"; info.Name = "Area2 Name"; info.Description = "Area2Description"; configuration.PacsConfiguration.AreaInfoList.Add(info); } { DoorInfo info = new DoorInfo(); info.token = "tokenDoor1"; info.Name = "Door1 Name"; info.Description = "Door1 Description"; DoorCapabilities value = new DoorCapabilities(); value.Block = true; value.DoubleLock = true; value.Lock = true; value.LockDown = true; value.LockOpen = true; value.MomentaryAccess = true; value.Unlock = true; info.Capabilities = value; configuration.PacsConfiguration.DoorInfoList.Add(info); } { DoorInfo info = new DoorInfo(); info.token = "tokenDoor2"; info.Name = "Door2 Name"; info.Description = "Door2 Description"; DoorCapabilities value = new DoorCapabilities(); value.Block = false; value.DoubleLock = false; value.Lock = false; value.LockDown = false; value.LockOpen = false; value.MomentaryAccess = false; value.Unlock = false; info.Capabilities = value; configuration.PacsConfiguration.DoorInfoList.Add(info); } foreach (DoorInfo door in configuration.PacsConfiguration.DoorInfoList) { configuration.PacsConfiguration.DoorCapabilitiesList.Add(door.token, door.Capabilities); configuration.PacsConfiguration.DoorAccessList.Add(door.token, 0); configuration.PacsConfiguration.DoorAccessPreviousStateList.Add(door.token, DoorModeType.Unknown); } { DoorState value = new DoorState(); value.DoorAlarm = DoorAlarmStateType.Normal; value.DoorDoubleLockMonitor = DoorLockMonitorStateType.Locked; value.DoorDoubleLockMonitorSpecified = true; value.DoorLockMonitor = DoorLockMonitorStateType.Locked; value.DoorMode = DoorModeType.Locked; value.DoorMonitor = DoorMonitorStateType.Closed; value.DoorTamper = DoorTamperStateType.NotInTamper; configuration.PacsConfiguration.DoorStateList.Add("tokenDoor1", value); } { DoorState value = new DoorState(); value.DoorAlarm = DoorAlarmStateType.Normal; value.DoorDoubleLockMonitor = DoorLockMonitorStateType.NotSupported; value.DoorDoubleLockMonitorSpecified = false; value.DoorLockMonitor = DoorLockMonitorStateType.NotSupported; value.DoorMode = DoorModeType.Locked; value.DoorMonitor = DoorMonitorStateType.NotSupported; value.DoorTamper = DoorTamperStateType.NotSupported; configuration.PacsConfiguration.DoorStateList.Add("tokenDoor2", value); } #endregion return(configuration); }
/// <summary> /// Compares two access points /// </summary> /// <param name="info1">First AccessPoint</param> /// <param name="info2">Second AccessPoint</param> /// <param name="dump">Buffer to add error description, if any</param> /// <returns>True if structures hold the same information</returns> bool CompareAccessPoints(AccessPointInfo info1, AccessPointInfo info2, StringBuilder dump) { bool localOk = true; Action <string, Func <AccessPointInfo, string> > checkStringAction = new Action <string, Func <AccessPointInfo, string> >( (name, fieldSelector) => { string value1 = fieldSelector(info1); string value2 = fieldSelector(info2); if (value1 != value2) { localOk = false; dump.AppendFormat(" {0} is different {1}", name, Environment.NewLine); } }); checkStringAction("AreaFrom", S => S.AreaFrom); checkStringAction("AreaTo", S => S.AreaTo); checkStringAction("Description", S => S.Description); checkStringAction("Entity", S => S.Entity); checkStringAction("Name", S => S.Name); if (info1.EntityType != null && info2.EntityType != null) { checkStringAction("Type.Name", S => S.EntityType.Name); checkStringAction("Type.Namespace", S => S.EntityType.Namespace); } else { if (info1.EntityType != null || info2.EntityType != null) { localOk = false; dump.AppendFormat(" Type is specified only for one of entities"); } } //if (info1.Enabled != info2.Enabled) //{ // localOk = false; // dump.AppendFormat(" Enabled is different {0}", Environment.NewLine); //} if (info1.Capabilities != null && info2.Capabilities != null) { if (info1.Capabilities.DisableAccessPoint != info2.Capabilities.DisableAccessPoint) { localOk = false; dump.AppendFormat(" Capabilities.DisableAccessPoint is different {0}", Environment.NewLine); } } else { if (!(info1.Capabilities == null && info2.Capabilities == null)) { localOk = false; dump.AppendFormat(" Capabilities are specified only for one structure{0}", Environment.NewLine); } } return(localOk); }
bool ValidateAccessPointEventSource(XmlElement messageElement, XmlNamespaceManager manager, object data, StringBuilder logger) { bool ok = true; List <AccessPointInfo> infos = data as List <AccessPointInfo>; string token = data as string; EntityListInfo <AccessPointInfo> entityInfo = data as EntityListInfo <AccessPointInfo>; XmlElement sourceElement = messageElement.GetMessageSource(); if (sourceElement == null) { logger.AppendLine(" Message Source element is missing"); ok = false; } else { bool success = false; string err; Dictionary <string, string> sourceSimpleItems = messageElement.GetMessageSourceSimpleItems(out success, out err); if (!success) { ok = false; logger.AppendLine(" " + err); } else { if (sourceSimpleItems.ContainsKey(ACCESSPOINTTOKENSIMPLEITEM)) { string value = sourceSimpleItems[ACCESSPOINTTOKENSIMPLEITEM]; // check value StringBuilder error = new StringBuilder(); if (infos != null) { AccessPointInfo found = infos.Where(I => I.token == value).FirstOrDefault(); if (found == null) { ok = false; logger.Append(string.Format(" AccessPoint with token '{0}' not found", value)); } } else if (entityInfo != null) { AccessPointInfo found = entityInfo.FullList.Where(I => I.token == value).FirstOrDefault(); if (found == null) { ok = false; logger.Append(string.Format(" AccessPoint with token '{0}' not found", value)); } else { found = entityInfo.FilteredList.Where(I => I.token == value).FirstOrDefault(); if (found == null) { ok = false; logger.Append(string.Format(" AccessPoint with token '{0}' does not have required capabilities", value)); } } } else { if (value != token) { ok = false; logger.Append(string.Format(" Token is incorrect. Expected '{0}', actual '{1}'", token, value)); } } } else { logger.AppendLine(" 'AccessPointToken' SimpleItem is missing in Source"); ok = false; } } } return(ok); }