public void TestLoadAndParse() { var ranges = AWSPublicIpAddressRanges.Load(); Assert.IsNotNull(ranges); Assert.IsTrue(ranges.AllAddressRanges.Any()); }
public void TestQueryByServiceKey() { var ranges = AWSPublicIpAddressRanges.Load(); var ec2Ranges = ranges.AddressRangesByServiceKey(AWSPublicIpAddressRanges.EC2ServiceKey); Assert.IsTrue(ec2Ranges.Any()); }
protected override void ProcessRecord() { base.ProcessRecord(); var settings = ProxySettings.GetSettings(this); var proxy = settings.GetWebProxy(); var ranges = AWSPublicIpAddressRanges.Load(proxy); if (OutputServiceKeys.IsPresent) { WriteObject(ranges.ServiceKeys, true); } else if (OutputPublicationDate.IsPresent) { WriteObject(ranges.CreateDate); } else { HashSet <string> serviceKeyHash = null; HashSet <string> regionHash = null; if ((ServiceKey != null && ServiceKey.Length != 0)) { serviceKeyHash = new HashSet <string>(ServiceKey, StringComparer.OrdinalIgnoreCase); } if (Region != null && Region.Length != 0) { regionHash = new HashSet <string>(Region, StringComparer.OrdinalIgnoreCase); } var output = new List <AWSPublicIpAddressRange>(); foreach (var addressRange in ranges.AllAddressRanges) { var addToCollection = true; if (serviceKeyHash != null && !serviceKeyHash.Contains(addressRange.Service)) { addToCollection = false; } if (regionHash != null && !regionHash.Contains(addressRange.Region)) { addToCollection = false; } if (addToCollection) { output.Add(addressRange); } } WriteObject(output, true); } }
public void TestQueryByRegion() { var ranges = AWSPublicIpAddressRanges.Load(); var uswest1Ranges = ranges.AddressRangesByRegion("us-west-1"); Assert.IsTrue(uswest1Ranges.Any()); var globalRanges = ranges.AddressRangesByRegion(AWSPublicIpAddressRanges.GlobalRegionIdentifier); Assert.IsTrue(globalRanges.Any()); }
public void Init() { _addressRanges = AWSPublicIpAddressRanges.Load(); }