private void CreateEndpointAndAddToServiceMap(JsonData result, string regionName, string serviceName, bool dualStack)
        {
            string text = ((string)result["hostname"]).Replace("{service}", serviceName).Replace("{region}", regionName).Replace("{dnsSuffix}", (string)_partitionJsonData["dnsSuffix"]);

            if (dualStack)
            {
                if (serviceName.Equals("s3", StringComparison.OrdinalIgnoreCase))
                {
                    if (text.Equals("s3.amazonaws.com", StringComparison.OrdinalIgnoreCase))
                    {
                        text = "s3.dualstack.us-east-1.amazonaws.com";
                    }
                    else if (!text.StartsWith("s3-external-", StringComparison.OrdinalIgnoreCase))
                    {
                        if (text.StartsWith("s3-", StringComparison.OrdinalIgnoreCase))
                        {
                            text = "s3." + text.Substring(3);
                        }
                        if (text.StartsWith("s3.", StringComparison.OrdinalIgnoreCase))
                        {
                            text = text.Replace("s3.", "s3.dualstack.");
                        }
                    }
                }
                else
                {
                    text = string.Format(CultureInfo.InvariantCulture, "{0}.{1}.{2}", serviceName, "dualstack." + regionName, (string)_partitionJsonData["dnsSuffix"]);
                }
            }
            string   authregion = null;
            string   text2      = null;
            JsonData jsonData   = result["credentialScope"];

            if (jsonData != null)
            {
                authregion = DetermineAuthRegion(jsonData);
                if (jsonData["service"] != null && string.Compare((string)jsonData["service"], serviceName, StringComparison.OrdinalIgnoreCase) != 0)
                {
                    text2 = (string)jsonData["service"];
                }
            }
            string signatureVersionOverride = DetermineSignatureOverride(result, serviceName);

            RegionEndpoint.Endpoint endpoint = new RegionEndpoint.Endpoint(text, authregion, signatureVersionOverride);
            _serviceMap.Add(serviceName, dualStack, endpoint);
            if (!string.IsNullOrEmpty(text2) && !_serviceMap.ContainsKey(text2))
            {
                _serviceMap.Add(text2, dualStack, endpoint);
            }
        }
Exemple #2
0
        /// <summary>
        /// Returns the service map.
        /// </summary>
        private ServiceMap CreateServiceMap()
        {
            var serviceMap = new ServiceMap();

            //---------------------------------------------
            // web-service:

            var description = new ServiceDescription()
            {
                Name    = "web-service",
                Address = "127.0.0.10"
            };

            description.Endpoints.Add(
                new ServiceEndpoint()
            {
                Protocol   = ServiceEndpointProtocol.Http,
                PathPrefix = "/",
                Port       = 666
            });

            serviceMap.Add(description);

            //---------------------------------------------
            // relay-service:

            description = new ServiceDescription()
            {
                Name    = "relay-service",
                Address = "127.0.0.10"
            };

            description.Endpoints.Add(
                new ServiceEndpoint()
            {
                Protocol   = ServiceEndpointProtocol.Http,
                PathPrefix = "/",
                Port       = 777
            });

            serviceMap.Add(description);

            return(serviceMap);
        }
Exemple #3
0
        /// <summary>
        /// Returns the service map.
        /// </summary>
        private ServiceMap CreateServiceMap()
        {
            var description = new ServiceDescription()
            {
                Name = "queue-service",
            };

            var serviceMap = new ServiceMap();

            serviceMap.Add(description);

            return(serviceMap);
        }
Exemple #4
0
            //-----------------------------------------------------------------
            // Static members

            private static ServiceMap CreateServiceMap()
            {
                var serviceMap = new ServiceMap();

                var description = new ServiceDescription()
                {
                    Name = "test-service"
                };

                serviceMap.Add(description);

                return(serviceMap);
            }
Exemple #5
0
        /// <summary>
        /// Returns the service map.
        /// </summary>
        private ServiceMap CreateServiceMap()
        {
            var serviceMap = new ServiceMap();

            var description = new ServiceDescription()
            {
                Name    = "web-0",
                Address = "127.0.0.10"
            };

            description.Endpoints.Add(
                new ServiceEndpoint()
            {
                Protocol   = ServiceEndpointProtocol.Http,
                PathPrefix = "/",
                Port       = 8080
            });

            serviceMap.Add(description);

            description = new ServiceDescription()
            {
                Name    = "web-1",
                Address = "127.0.0.11"
            };

            description.Endpoints.Add(
                new ServiceEndpoint()
            {
                Protocol   = ServiceEndpointProtocol.Http,
                PathPrefix = "/",
                Port       = 8081
            });

            serviceMap.Add(description);

            return(serviceMap);
        }
Exemple #6
0
 public void Register <TService>(IViewService service) where TService : IViewService
 {
     ServiceMap.Add(typeof(TService), service);
 }
Exemple #7
0
        public Test_ComposedParallelFixtures(ComposedFixture composedFixture)
        {
            composedFixture.Start(
                () =>
            {
                // Start Couchbase and Cadence together as [group=0].

                composedFixture.AddFixture("couchbase", new CouchbaseFixture(),
                                           couchbaseFixture =>
                {
                    couchbaseFixture.StartAsComposed();
                },
                                           group: 0);

                composedFixture.AddFixture("cadence", new CadenceFixture(),
                                           cadenceFixture =>
                {
                    cadenceFixture.StartAsComposed();
                },
                                           group: 0);

                // Add a [CodeFixture] as [group=1] and have it initialize write to
                // Couchbase to simulate initializing a database and also configure
                // environment variables and configuration files for the services
                // via a service map.

                var serviceMap = new ServiceMap();

                serviceMap.Add("my-service-1", new ServiceDescription());
                serviceMap.Add("my-service-2", new ServiceDescription());

                composedFixture.AddFixture <CodeFixture>("code", new CodeFixture(),
                                                         codeFixture =>
                {
                    // Write a key to the database.

                    var couchbaseFixture = (CouchbaseFixture)composedFixture["couchbase"];
                    var bucket           = couchbaseFixture.Bucket;

                    bucket.UpsertSafeAsync("test", "HELLO WORLD!").WaitWithoutAggregate();

                    // Configure the services via the service map.

                    var service1Description = serviceMap["my-service-1"];
                    var service2Description = serviceMap["my-service-2"];

                    service1Description.TestEnvironmentVariables.Add("service", "service1");
                    service1Description.TestTextConfigFiles.Add("/config.txt", "HELLO SERVICE1!");
                    service1Description.TestBinaryConfigFiles.Add("/config.dat", new byte[] { 0, 1, 2, 3, 4 });

                    service2Description.TestEnvironmentVariables.Add("service", "service2");
                    service2Description.TestTextConfigFiles.Add("/config.txt", "HELLO SERVICE2!");
                    service2Description.TestBinaryConfigFiles.Add("/config.dat", new byte[] { 5, 6, 7, 8, 9 });
                },
                                                         group: 1);

                // Start NATS and a container as [group=2].

                composedFixture.AddFixture("nats", new NatsFixture(),
                                           natsFixture =>
                {
                    natsFixture.StartAsComposed();
                },
                                           group: 2);

                composedFixture.AddFixture("container", new ContainerFixture(),
                                           containerFixture =>
                {
                    containerFixture.StartAsComposed("my-container", $"{NeonHelper.NeonLibraryBranchRegistry}/test:latest");
                },
                                           group: 2);

                // Start two Neon services as [group=3].

                composedFixture.AddServiceFixture("service1", new NeonServiceFixture <MyService1>(), () => new MyService1(), serviceMap, group: 3);
                composedFixture.AddServiceFixture("service2", new NeonServiceFixture <MyService2>(), () => new MyService2(), serviceMap, group: 3);
            });

            this.fixture = composedFixture;
        }