public void AddIPAddressFilterIPv4Test() { IPAddressFilter originalConfig = null; bool restoreSettings = false; RunTest(() => { originalConfig = GetIPAddressFilter(); SetIPAddressFilter(new IPAddressFilter() { Type = IPAddressFilterType.Deny }); restoreSettings = true; var netAddress = NotClientAddress(); var uploadedConfig = new IPAddressFilter() { Type = IPAddressFilterType.Deny, IPv4Address = new[] { netAddress } }; AddIPAddressFilter(uploadedConfig); var updatedConfig = GetIPAddressFilter(); CompareIPAddressFilters(uploadedConfig, updatedConfig); }, () => { if (restoreSettings) { SetIPAddressFilter(originalConfig); } }); }
public void RemoveIPAddressFilterIPv4Test() { IPAddressFilter originalConfig = null; bool restoreSettings = false; RunTest(() => { originalConfig = GetIPAddressFilter(); var netAddress = NotClientAddress(); var newConfig = new IPAddressFilter() { Type = IPAddressFilterType.Deny, IPv4Address = new[] { netAddress } }; SetIPAddressFilter(newConfig); restoreSettings = true; CompareIPAddressFilters(newConfig, GetIPAddressFilter()); RemoveIPAddressFilter(new IPAddressFilter() { Type = IPAddressFilterType.Allow, IPv4Address = new[] { netAddress } }); var referenceConfig = new IPAddressFilter() { Type = IPAddressFilterType.Deny }; CompareIPAddressFilters(referenceConfig, GetIPAddressFilter()); }, () => { if (restoreSettings) { SetIPAddressFilter(originalConfig); } }); }
private IPAddressFilter GetIPAddressFilter() { IPAddressFilter r = null; RunStep(() => r = Client.GetIPAddressFilter(), "Get IP Address Filter"); RunStep(() => { bool passed = true; if (null != r.IPv4Address) { foreach (var ip in r.IPv4Address) { passed = passed && ValidateIPAddress(ip); } } if (null != r.IPv6Address) { foreach (var ip in r.IPv6Address) { passed = passed && ValidateIPAddress(ip); } } if (!passed) { throw new FormatException("There is one or more invalid IP ranges in filter"); } }, "Validate received IP Address Filter"); return(r); }
public override void RemoveIPAddressFilter(IPAddressFilter IPAddressFilter) { throw new NotImplementedException(); }
private void CompareIPAddressFilters(IPAddressFilter uploaded, IPAddressFilter received) { const string logPrefix = " "; var log = new StringBuilder(); bool flag = true; if (uploaded.Type != received.Type) { flag = false; log.AppendLine(string.Format("{0}Field 'Type' has unexpected value: expected '{1}', actually '{2}'", logPrefix, uploaded.Type, received.Type)); } var uEmptyv4 = null == uploaded.IPv4Address || !uploaded.IPv4Address.Any(); var rEmptyv4 = null == received.IPv4Address || !received.IPv4Address.Any(); if (uEmptyv4 != rEmptyv4) { flag = false; if (uEmptyv4) { log.AppendLine(string.Format("{0}Field 'IPv4Address' is empty in uploaded IPAddressFilter and isn't empty in received one.", logPrefix)); } else { log.AppendLine(string.Format("{0}Field 'IPv4Address' is empty in received IPAddressFilter and isn't empty in uploaded one.", logPrefix)); } } else if (!uEmptyv4) { if (uploaded.IPv4Address.Count() != received.IPv4Address.Count()) { flag = false; log.AppendLine(string.Format("{0}Field 'IPv4Address' in received IPAddressFilter has different count of items than in uploaded one.", logPrefix)); } else { foreach (var ripa in received.IPv4Address) { var contains = uploaded.IPv4Address.Any(e => e.Address == ripa.Address && e.PrefixLength == ripa.PrefixLength); if (!contains) { flag = false; log.AppendLine(string.Format("{0}Field 'IPv4Address' in received IPAddressFilter contains item than is not present in uploaded one: Address '{1}', PrefixLength '{2}'", logPrefix, ripa.Address, ripa.PrefixLength)); break; } } } } //var uEmptyv6 = null == uploaded.IPv6Address || !uploaded.IPv6Address.Any(); //var rEmptyv6 = null == received.IPv6Address || !received.IPv6Address.Any(); //if (uEmptyv6 != rEmptyv6) //{ // flag = false; // if (uEmptyv6) // log.AppendLine(string.Format("{0}Field 'IPv6Address' is empty in uploaded IPAddressFilter and isn't empty in received one.", logPrefix)); // else // log.AppendLine(string.Format("{0}Field 'IPv6Address' is empty in received IPAddressFilter and isn't empty in uploaded one.", logPrefix)); //} //else if (!uEmptyv6) //{ // if (uploaded.IPv6Address.Count() != received.IPv6Address.Count()) // { // flag = false; // log.AppendLine(string.Format("{0}Field 'IPv6Address' in received IPAddressFilter has different count of items than in uploaded one.", logPrefix)); // } // else // { // foreach (var ripa in received.IPv6Address) // { // var contains = uploaded.IPv6Address.Any(e => e.Address == ripa.Address && e.PrefixLength == ripa.PrefixLength); // if (!contains) // { // flag = false; // log.AppendLine(string.Format("{0}Field 'IPv6Address' in received IPAddressFilter contains item than is not present in uploaded one: Address '{1}', PrefixLength '{2}'", // logPrefix, ripa.Address, ripa.PrefixLength)); // break; // } // } // } //} Assert(flag, string.Format("Received IPAddressFilter is different from uploaded one:{0}{1}", Environment.NewLine, log), "Compare uploaded and received IPAddressFilters"); }
private void RemoveIPAddressFilter(IPAddressFilter filter) { RunStep(() => Client.RemoveIPAddressFilter(filter), "Remove IP Address Filter"); }
private void AddIPAddressFilter(IPAddressFilter filter) { RunStep(() => Client.AddIPAddressFilter(filter), "Add IP Address Filter"); }
private void SetIPAddressFilter(IPAddressFilter filter) { RunStep(() => Client.SetIPAddressFilter(filter), "Set IP Address Filter"); }
void IOnVifDevice.SetIPAddressFilter(IPAddressFilter IPAddressFilter) { throw new NotImplementedException(); }
// GET: AuditLogs public ActionResult Index(string currentURLFilter, string URLFilter, string currentIPAddressFilter, string IPAddressFilter, string currentUserFilter, string UserFilter, int?page) { if (UserFilter != null) { page = 1; } else { UserFilter = currentUserFilter; } if (IPAddressFilter != null) { page = 1; } else { IPAddressFilter = currentIPAddressFilter; } if (URLFilter != null) { page = 1; } else { URLFilter = currentURLFilter; } ViewBag.CurrentUserFilter = UserFilter; ViewBag.CurrentIPAddressFilter = IPAddressFilter; ViewBag.CurrentURLFilter = URLFilter; List <AuditLog> AuditRecords = db.AuditRecords.OrderByDescending(x => x.TimeAccessed).ToList(); if (!String.IsNullOrEmpty(UserFilter)) { AuditRecords = AuditRecords.Where(s => s.UserName.ToLower().Contains(UserFilter.ToLower())).ToList(); } if (!String.IsNullOrEmpty(IPAddressFilter)) { AuditRecords = AuditRecords.Where(s => s.IPAddress.ToLower().Contains(IPAddressFilter.ToLower())).ToList(); } if (!String.IsNullOrEmpty(URLFilter)) { AuditRecords = AuditRecords.Where(s => (s.URLAccessed ?? "").ToLower().Contains(URLFilter.ToLower())).ToList(); } int pageSize = 100; int pageNumber = (page ?? 1); return(View(AuditRecords.ToPagedList(pageNumber, pageSize))); }