/// <summary>
        /// Starts the containers for scenario run.
        /// </summary>
        /// <param name="scenarioName">Name of the scenario.</param>
        public override async Task StartContainersForScenarioRun(String scenarioName)
        {
            this.HostTraceFolder = FdOs.IsWindows() ? $"D:\\home\\txnproc\\trace\\{scenarioName}" : $"//home//txnproc//trace//{scenarioName}";

            this.SqlServerDetails = (Setup.SqlServerContainerName, Setup.SqlUserName, Setup.SqlPassword);

            this.ClientDetails = ("serviceClient", "Secret1");
            Logging.Enabled();

            Guid testGuid = Guid.NewGuid();

            this.TestId = testGuid;

            this.Logger.LogInformation($"Test Id is {testGuid}");

            // Setup the container names
            this.SecurityServiceContainerName   = $"securityservice{testGuid:N}";
            this.EstateManagementContainerName  = $"estate{testGuid:N}";
            this.EventStoreContainerName        = $"eventstore{testGuid:N}";
            this.EstateReportingContainerName   = $"estatereporting{testGuid:N}";
            this.VoucherManagementContainerName = $"vouchermanagement{testGuid:N}";

            this.DockerCredentials = ("https://www.docker.com", "stuartferguson", "Sc0tland");

            INetworkService testNetwork = DockerHelper.SetupTestNetwork();

            this.TestNetworks.Add(testNetwork);
            IContainerService eventStoreContainer = this.SetupEventStoreContainer("eventstore/eventstore:21.10.0-buster-slim", testNetwork);

            this.EventStoreHttpPort = eventStoreContainer.ToHostExposedEndpoint($"{DockerHelper.EventStoreHttpDockerPort}/tcp").Port;

            String insecureEventStoreEnvironmentVariable    = "EventStoreSettings:Insecure=true";
            String persistentSubscriptionPollingInSeconds   = "AppSettings:PersistentSubscriptionPollingInSeconds=10";
            String internalSubscriptionServiceCacheDuration = "AppSettings:InternalSubscriptionServiceCacheDuration=0";

            IContainerService estateManagementContainer = this.SetupEstateManagementContainer("stuartferguson/estatemanagement", new List <INetworkService>
            {
                testNetwork,
                Setup.DatabaseServerNetwork
            },
                                                                                              true,
                                                                                              additionalEnvironmentVariables: new List <String>
            {
                insecureEventStoreEnvironmentVariable,
                internalSubscriptionServiceCacheDuration,
                persistentSubscriptionPollingInSeconds
            });

            IContainerService securityServiceContainer = this.SetupSecurityServiceContainer("stuartferguson/securityservice",
                                                                                            testNetwork,
                                                                                            true);

            IContainerService voucherManagementContainer = this.SetupVoucherManagementContainer("vouchermanagement",
                                                                                                new List <INetworkService>
            {
                testNetwork,
                Setup.DatabaseServerNetwork
            }, additionalEnvironmentVariables: new List <String>
            {
                insecureEventStoreEnvironmentVariable,
                internalSubscriptionServiceCacheDuration,
                persistentSubscriptionPollingInSeconds
            });

            IContainerService estateReportingContainer = this.SetupEstateReportingContainer("stuartferguson/estatereporting",
                                                                                            new List <INetworkService>
            {
                testNetwork,
                Setup.DatabaseServerNetwork,
            },
                                                                                            true,
                                                                                            additionalEnvironmentVariables: new List <String>
            {
                insecureEventStoreEnvironmentVariable,
                internalSubscriptionServiceCacheDuration,
                persistentSubscriptionPollingInSeconds
            });

            this.Containers.AddRange(new List <IContainerService>
            {
                eventStoreContainer,
                estateManagementContainer,
                securityServiceContainer,
                voucherManagementContainer,
                estateReportingContainer,
            });

            // Cache the ports
            this.EstateManagementApiPort = estateManagementContainer.ToHostExposedEndpoint("5000/tcp").Port;
            this.SecurityServicePort     = securityServiceContainer.ToHostExposedEndpoint("5001/tcp").Port;
            this.EventStoreHttpPort      = eventStoreContainer.ToHostExposedEndpoint("2113/tcp").Port;
            this.VoucherManagementPort   = voucherManagementContainer.ToHostExposedEndpoint("5007/tcp").Port;

            // Setup the base address resolvers
            String EstateManagementBaseAddressResolver(String api) => $"http://127.0.0.1:{this.EstateManagementApiPort}";
            String SecurityServiceBaseAddressResolver(String api) => $"https://127.0.0.1:{this.SecurityServicePort}";
            String VoucherManagementBaseAddressResolver(String api) => $"http://127.0.0.1:{this.VoucherManagementPort}";

            HttpClientHandler clientHandler = new HttpClientHandler
            {
                ServerCertificateCustomValidationCallback = (message,
                                                             certificate2,
                                                             arg3,
                                                             arg4) =>
                {
                    return(true);
                }
            };
            HttpClient httpClient = new HttpClient(clientHandler);

            this.EstateClient            = new EstateClient(EstateManagementBaseAddressResolver, httpClient);
            this.SecurityServiceClient   = new SecurityServiceClient(SecurityServiceBaseAddressResolver, httpClient);
            this.VoucherManagementClient = new VoucherManagementClient(VoucherManagementBaseAddressResolver, httpClient);

            await this.LoadEventStoreProjections(this.EventStoreHttpPort).ConfigureAwait(false);
        }
Exemple #2
0
 public VoucherManagementACLApplicationService(ISecurityServiceClient securityServiceClient,
                                               IVoucherManagementClient voucherManagementClient)
 {
     this.SecurityServiceClient   = securityServiceClient;
     this.VoucherManagementClient = voucherManagementClient;
 }