public void Reload()
        {
            var initialRegionEndpoint      = RegionEndpoint.USWest2;
            var initialTestServiceEndpoint = initialRegionEndpoint.GetEndpointForService(TestService, new GetEndpointForServiceOptions());

            // Get and Mutate the manifest
            var rootData = GetEndpointsManifest();

            ApplySampleValuesToManifest(rootData);

            // Reload with this mutated manifest
            var json = rootData.ToJson();

            using (var ms = new MemoryStream(Encoding.UTF8.GetBytes(json)))
            {
                RegionEndpoint.Reload(ms);
            }

            // Verify the SDK resolves regions and endpoints against the mutated data
            var regionEndpoint = RegionEndpoint.GetBySystemName(TestRegionSystemName);

            Assert.IsNotNull(regionEndpoint);
            Assert.AreEqual(SampleValues.SampleRegionDisplayName, regionEndpoint.DisplayName);
            Assert.AreEqual(SampleValues.SampleDnsSuffix, regionEndpoint.PartitionDnsSuffix);
            var endpoint = regionEndpoint.GetEndpointForService(TestService, new GetEndpointForServiceOptions());

            Assert.IsNotNull(endpoint);
            Assert.AreEqual(SampleValues.SampleAuthRegion, endpoint.AuthRegion);
            Assert.AreEqual(SampleValues.SampleHostName, endpoint.Hostname);

            // Verify the initial region-endpoint is unaffected
            Assert.AreNotEqual(initialRegionEndpoint.DisplayName, regionEndpoint.DisplayName);
            Assert.AreNotEqual(initialTestServiceEndpoint.AuthRegion, endpoint.AuthRegion);
            Assert.AreNotEqual(initialTestServiceEndpoint.Hostname, endpoint.Hostname);
        }
Example #2
0
        public void LoadDeprecatedRegionEndpoint(string region, string serviceName, bool expectToBeDeprecated)
        {
            try
            {
                RegionEndpoint.Reload(Utils.GetResourceStream("testEndpointsWithVariants.json"));

                var regionEndpoint = RegionEndpoint.GetBySystemName(region);
                var isDeprecated   = regionEndpoint.GetEndpointForService(serviceName).Deprecated;

                Assert.AreEqual(expectToBeDeprecated, isDeprecated);
            }
            finally
            {
                RegionEndpoint.Reload(null);
            }
        }
Example #3
0
        private void GetEndpointForServiceHelper(string endpointsFile, string service, bool useDualStackEndpoint, bool useFipsEndpoint, string region, string expectedEndpoint)
        {
            try
            {
                RegionEndpoint.Reload(Utils.GetResourceStream(endpointsFile));

                var regionEndpoint = RegionEndpoint.GetBySystemName(region);

                var getEndpointOptions = new GetEndpointForServiceOptions
                {
                    DualStack = useDualStackEndpoint,
                    FIPS      = useFipsEndpoint
                };
                var hostname = regionEndpoint?.GetEndpointForService(service, getEndpointOptions).Hostname;

                Assert.IsNotNull(regionEndpoint);
                Assert.AreEqual(expectedEndpoint, hostname);
            }
            finally
            {
                RegionEndpoint.Reload(null);
            }
        }
 public void Cleanup()
 {
     // Reset the RegionEndpoint static maps so that other tests don't use
     // sample data from this test.
     RegionEndpoint.Reload(null);
 }