/// <summary>
        /// Initializes a new instance of the <see cref="AzureDevOpsBuildSettings"/> class using environment variables
        /// as set by an Azure Pipelines build.
        /// </summary>
        /// <param name="credentials">Credentials to use to authenticate against Azure DevOps.</param>
        public AzureDevOpsBuildSettings(IAzureDevOpsCredentials credentials)
        {
            credentials.NotNull(nameof(credentials));

            this.Credentials   = credentials;
            this.CollectionUrl = EnvironmentVariableHelper.GetSystemTeamFoundationCollectionUri();
            this.ProjectName   = EnvironmentVariableHelper.GetSystemTeamProject();

            var buildId = Environment.GetEnvironmentVariable("BUILD_BUILDID", EnvironmentVariableTarget.Process);

            if (string.IsNullOrWhiteSpace(buildId))
            {
                throw new InvalidOperationException(
                          "Failed to read the BUILD_BUILDID environment variable. Make sure you are running in an Azure Pipelines build.");
            }

            if (!int.TryParse(buildId, out int buildIdValue))
            {
                throw new InvalidOperationException("BUILD_BUILDID environment variable should contain integer value");
            }

            if (buildIdValue <= 0)
            {
                throw new InvalidOperationException("BUILD_BUILDID environment variable should contain integer value and it should be greater than zero");
            }

            this.BuildId = buildIdValue;
        }
        protected override void ProcessRecordCode()
        {
            IEnvironmentVariableHelper environmentVariableHelper = new EnvironmentVariableHelper();

            // Update Java Environment Variables
            environmentVariableHelper.UpdateJavaEnvironmentVariables();
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="OtlpExporterOptions"/> class.
        /// </summary>
        public OtlpExporterOptions()
        {
            if (EnvironmentVariableHelper.LoadUri(EndpointEnvVarName, out Uri endpoint))
            {
                this.Endpoint = endpoint;
            }

            if (EnvironmentVariableHelper.LoadString(HeadersEnvVarName, out string headersEnvVar))
            {
                this.Headers = headersEnvVar;
            }

            if (EnvironmentVariableHelper.LoadNumeric(TimeoutEnvVarName, out int timeout))
            {
                this.TimeoutMilliseconds = timeout;
            }

            if (EnvironmentVariableHelper.LoadString(ProtocolEnvVarName, out string protocolEnvVar))
            {
                var protocol = protocolEnvVar.ToOtlpExportProtocol();
                if (protocol.HasValue)
                {
                    this.Protocol = protocol.Value;
                }
                else
                {
                    throw new FormatException($"{ProtocolEnvVarName} environment variable has an invalid value: '${protocolEnvVar}'");
                }
            }
        }
Exemple #4
0
        public void LoadUri_NoValue()
        {
            bool actualBool = EnvironmentVariableHelper.LoadUri(EnvVar, out Uri actualValue);

            Assert.False(actualBool);
            Assert.Null(actualValue);
        }
        private static AppArgs ParseArgsImpl(String[] args)
        {
            if (args.Length == 1 && String.Equals(args[0], HelpOption))
            {
                return(new AppArgs(AppUsageMode.Help));
            }
            if (args.Length == 1 && String.Equals(args[0], VersionOption))
            {
                return(new AppArgs(AppUsageMode.Version));
            }
            ISet <String> parsedOptions = new HashSet <String>();
            AppArgs       appArgs       = new AppArgs(AppUsageMode.Analysis);

            foreach (String arg in args)
            {
                if (arg.StartsWith(SourceOption))
                {
                    if (!parsedOptions.Add(SourceOption))
                    {
                        return(new AppArgs(AppUsageMode.BadSource));
                    }
                    String source = EnvironmentVariableHelper.ExpandEnvironmentVariables(arg.Substring(SourceOption.Length));
                    if (String.IsNullOrEmpty(source))
                    {
                        return(new AppArgs(AppUsageMode.BadSource));
                    }
                    appArgs.Source = source;
                }
                else if (arg.StartsWith(ConfigOption))
                {
                    if (!parsedOptions.Add(ConfigOption))
                    {
                        return(new AppArgs(AppUsageMode.BadConfig));
                    }
                    String config = EnvironmentVariableHelper.ExpandEnvironmentVariables(arg.Substring(ConfigOption.Length));
                    if (String.IsNullOrEmpty(config))
                    {
                        return(new AppArgs(AppUsageMode.BadConfig));
                    }
                    appArgs.Config = config;
                }
                else if (arg.StartsWith(OutputLevelOption))
                {
                    if (!parsedOptions.Add(OutputLevelOption))
                    {
                        return(new AppArgs(AppUsageMode.BadAppUsage));
                    }
                    if (!Enum.TryParse(arg.Substring(OutputLevelOption.Length), out OutputLevel outputLevel))
                    {
                        return(new AppArgs(AppUsageMode.BadAppUsage));
                    }
                    appArgs.OutputLevel = outputLevel;
                }
                else
                {
                    return(new AppArgs(AppUsageMode.BadAppUsage));
                }
            }
            return(String.IsNullOrEmpty(appArgs.Source) ? new AppArgs(AppUsageMode.BadAppUsage) : appArgs);
        }
Exemple #6
0
        public static IServiceCollection AddTracing(this IServiceCollection services, IWebHostEnvironment environment, IConfiguration configuration)
        {
            string agentHost;
            int    agentPort;

            if (environment.IsLocal())
            {
                agentHost = configuration["Jaeger:AgentHost"];
                agentPort = int.Parse(configuration["Jaeger:AgentPort"]);
            }
            else
            {
                agentHost = EnvironmentVariableHelper.Get("Jaeger:AgentHost", configuration);
                agentPort = int.Parse(EnvironmentVariableHelper.Get("Jaeger:AgentPort", configuration));
            }

            var serviceName = $"{environment.ApplicationName}-{environment.EnvironmentName}";

            services.AddOpenTelemetrySdk(builder =>
            {
                builder.AddRequestInstrumentation()
                .AddDependencyInstrumentation()
                .UseJaegerActivityExporter(options =>
                {
                    options.ServiceName = serviceName;
                    options.AgentHost   = agentHost;
                    options.AgentPort   = agentPort;
                })
                .SetResource(Resources.CreateServiceResource(serviceName))
                .SetSampler(new AlwaysOnActivitySampler());
            });

            return(services);
        }
Exemple #7
0
        public void LoadString_NoValue()
        {
            bool actualBool = EnvironmentVariableHelper.LoadString(EnvVar, out string actualValue);

            Assert.False(actualBool);
            Assert.Null(actualValue);
        }
Exemple #8
0
        public static IServiceCollection AddTracing(this IServiceCollection services, IWebHostEnvironment environment, IConfiguration configuration)
        {
            string agentHost;
            int    agentPort;

            if (environment.IsLocal())
            {
                agentHost = configuration["Jaeger:AgentHost"];
                agentPort = int.Parse(configuration["Jaeger:AgentPort"]);
            }
            else
            {
                agentHost = EnvironmentVariableHelper.Get("Jaeger:AgentHost", configuration);
                agentPort = int.Parse(EnvironmentVariableHelper.Get("Jaeger:AgentPort", configuration));
            }

            var connection  = ConnectionMultiplexer.Connect(EnvironmentVariableHelper.Get("Redis:Endpoint", configuration));
            var serviceName = $"{environment.ApplicationName}-{environment.EnvironmentName}";

            services.AddOpenTelemetryTracing(builder =>
            {
                builder.SetResourceBuilder(ResourceBuilder.CreateDefault().AddService(serviceName))
                .AddAspNetCoreInstrumentation()
                .AddHttpClientInstrumentation()
                .AddRedisInstrumentation(connection)
                .AddJaegerExporter(options =>
                {
                    options.AgentHost = agentHost;
                    options.AgentPort = agentPort;
                })
                .SetSampler(new AlwaysOnSampler());
            });

            return(services);
        }
Exemple #9
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ZipkinExporterOptions"/> class.
 /// Initializes zipkin endpoint.
 /// </summary>
 public ZipkinExporterOptions()
 {
     if (EnvironmentVariableHelper.LoadUri(ZipkinEndpointEnvVar, out Uri endpoint))
     {
         this.Endpoint = endpoint;
     }
 }
Exemple #10
0
 protected WapClient(string endPoint, string name)
     : this(string.Empty, 0, endPoint, name)
 {
     ControllerAddress = EnvironmentVariableHelper.Get("WAP_CONTROLLER_ADDRESS", "localhost");
     ControllerPort    = int.Parse(EnvironmentVariableHelper.Get("WAP_CONTROLLER_PORT", "51234"));
     _controllerEp     = WapEndPoint.Parse(EnvironmentVariableHelper.Get("WAP_CONTROLLER_ENDPOINT", ":control"));
 }
Exemple #11
0
        public void LoadNumeric_NoValue()
        {
            bool actualBool = EnvironmentVariableHelper.LoadNumeric(EnvVar, out int actualValue);

            Assert.False(actualBool);
            Assert.Equal(0, actualValue);
        }
        public override void Execute()
        {
            var sid    = EnvironmentVariableHelper.GetEnvironmentVariable(sidKey);
            var token  = EnvironmentVariableHelper.GetEnvironmentVariable(tokenKey);
            var number = EnvironmentVariableHelper.GetEnvironmentVariable(numberKey);

            var client = new TwilioRestClient(sid, token);

            foreach (var reminder in In.DueReminders)
            {
                var contact = "+" + reminder.Contact;
                var result  = client.SendSmsMessage(number, contact, reminder.Message);
                var error   = result.RestException;
                if (error == null)
                {
                    Out.Sent++;
                }
                else
                {
                    Out.Errors++;
                    Console.WriteLine(
                        "SMS to {0} failed with a status of {1} and reason of {2}.",
                        reminder.Contact,
                        error.Status,
                        error.Code + ": " + error.Message
                        );
                }
            }
        }
Exemple #13
0
        public JaegerExporterOptions()
        {
            if (EnvironmentVariableHelper.LoadString(OTelProtocolEnvVarKey, out string protocolEnvVar))
            {
                var protocol = protocolEnvVar.ToJaegerExportProtocol();

                if (protocol.HasValue)
                {
                    this.Protocol = protocol.Value;
                }
                else
                {
                    throw new FormatException($"{OTelProtocolEnvVarKey} environment variable has an invalid value: '{protocolEnvVar}'");
                }
            }

            if (EnvironmentVariableHelper.LoadString(OTelAgentHostEnvVarKey, out string agentHostEnvVar))
            {
                this.AgentHost = agentHostEnvVar;
            }

            if (EnvironmentVariableHelper.LoadNumeric(OTelAgentPortEnvVarKey, out int agentPortEnvVar))
            {
                this.AgentPort = agentPortEnvVar;
            }

            if (EnvironmentVariableHelper.LoadString(OTelEndpointEnvVarKey, out string endpointEnvVar) &&
                Uri.TryCreate(endpointEnvVar, UriKind.Absolute, out Uri endpoint))
            {
                this.Endpoint = endpoint;
            }
        }
Exemple #14
0
        public static IWebHostBuilder CreateHostBuilder(string[] args)
        => WebHost.CreateDefaultBuilder(args)
        .UseKestrel()
        .UseStartup <Startup>()
        .ConfigureAppConfiguration((hostingContext, config) =>
        {
            var environment = hostingContext.HostingEnvironment;

            config.AddJsonFile("appsettings.json", false, true)
            .AddJsonFile($"appsettings.{environment.EnvironmentName}.json", true, true);
            config.AddEnvironmentVariables();
        })
        .ConfigureLogging((hostingContext, logging) =>
        {
            logging.ClearProviders()
            .AddConfiguration(hostingContext.Configuration.GetSection("Logging"));

            var env = hostingContext.HostingEnvironment;
            if (env.IsLocal())
            {
                logging.AddConsole();
            }
            else
            {
                logging
                .AddStdOutLogger(options =>
                {
                    options.IncludeScopes   = false;
                    options.RequestIdHeader = Constants.DefaultRequestIdHeader;
                    options.UseUtcTimestamp = true;
                })
                .AddSentry(options => { options.Dsn = EnvironmentVariableHelper.Get("Logging:Sentry:Endpoint", hostingContext.Configuration); });
            }
        })
        .UseSetting(WebHostDefaults.SuppressStatusMessagesKey, "true");
Exemple #15
0
        public void FindElement()
        {
            Func <IWebElement> firstAttempt = () =>
            {
                return(SeleniumActions.GetWaitDriver.Until(d => d.FindElement(_locator)));
            };

            Func <IWebElement> secondAttempt = () =>
            {
                return(SeleniumActions.GetWaitDriver.Until(SeleniumExtras.WaitHelpers.ExpectedConditions.ElementToBeClickable(_locator)));
            };

            string      errorMessage;
            IWebElement element;

            if (TryFindElement(new[] { firstAttempt, secondAttempt }, out element, out errorMessage))
            {
                _seleniumElement = element;
            }
            else
            {
                _seleniumElement = null;

                //Log
                string message = string.Format("Unable to find the following element: [ {0} ] [ {1} ]. [ {2} ].",
                                               _locator, _controlName, errorMessage);
                LoggerManagerClass.Instance.Error(EnvironmentVariableHelper.GetBddStepDescription() + message);
                TestCaseProvider.Instance.AddStepInCurrentTestCase(LogStepStatus.Failed, message);
                throw new NoSuchElementException(message);
            }
        }
Exemple #16
0
        public void MyScenarioCleanup()
        {
            try
            {
                // Clean up all connections and generate report
                var testFinalStatus = CheckTestCaseStatus();
                var message         = EnvironmentVariableHelper.GetBddStepDescription() +
                                      TestContext.CurrentContext.Result.Message;

                var stackTrace = TestContext.CurrentContext.Result.StackTrace;

                TestCaseProvider.Instance
                .LogTestCaseFinalStatus(testFinalStatus, message, stackTrace,
                                        TestCaseInfo.TestCaseFullName, TestCaseInfo.TestCaseName);

                BaseTestManagerClass.MyTestCleanupClose();
                ProcessManager.KillProcess("chrome");
            }
            catch (Exception e)
            {
                // Clean up all connections and generate report
                BaseTestManagerClass.MyTestCleanupClose();

                //Kill chrome driver
                ProcessManager.KillProcess("chromedriver");
                ProcessManager.KillProcess("chrome");

                ExceptionManager.WarningMessageLog(e.Message);
            }
        }
        public static DbConnection Connect()
        {
            // Reference: github.com/gregoryjscott/chic/TaskExtensions
            var providerName     = EnvironmentVariableHelper.GetEnvironmentVariable(providerKey);
            var connectionString = EnvironmentVariableHelper.GetEnvironmentVariable(connectionKey);

            DbProviderFactory factory;

            try{
                factory = DbProviderFactories.GetFactory(providerName);
            }
            catch (Exception) { // TODO: Figure out how to load config for tests (Shim for db tests)
                factory = Npgsql.NpgsqlFactory.Instance;
            }

            if (factory == null)
            {
                throw new Exception("Could not obtain factory for provider \"" + providerName + "\"");
            }

            DbConnection connection = factory.CreateConnection();

            if (connection == null)
            {
                throw new Exception("Could not obtain connection from factory for " + providerName);
            }

            connection.ConnectionString = connectionString;
            connection.Open();

            return(connection);
        }
        /// <summary>
        /// Constructs the settings object for a specific build using the access token provided by Azure Pipelines.
        /// </summary>
        /// <param name="buildId">ID of the build.</param>
        /// <returns>The instance of <see cref="AzureDevOpsBuildSettings"/> class.</returns>
        public static AzureDevOpsBuildSettings UsingAzurePipelinesOAuthToken(int buildId)
        {
            buildId.NotNegativeOrZero(nameof(buildId));

            var accessToken = EnvironmentVariableHelper.GetSystemAccessToken();

            return(new AzureDevOpsBuildSettings(buildId, new AzureDevOpsOAuthCredentials(accessToken)));
        }
Exemple #19
0
        /// <summary>
        /// Initializes a new instance of the <see cref="AzureDevOpsBuildsSettings"/> class using environment variables
        /// as set by an Azure Pipelines build.
        /// </summary>
        /// <param name="credentials">Credentials to use to authenticate against Azure DevOps.</param>
        public AzureDevOpsBuildsSettings(IAzureDevOpsCredentials credentials)
        {
            credentials.NotNull(nameof(credentials));

            this.Credentials   = credentials;
            this.CollectionUrl = EnvironmentVariableHelper.GetSystemTeamFoundationCollectionUri();
            this.ProjectName   = EnvironmentVariableHelper.GetSystemTeamProject();
        }
Exemple #20
0
        public void LoadNumeric(string value, int expectedValue)
        {
            Environment.SetEnvironmentVariable(EnvVar, value);

            bool actualBool = EnvironmentVariableHelper.LoadNumeric(EnvVar, out int actualValue);

            Assert.True(actualBool);
            Assert.Equal(expectedValue, actualValue);
        }
Exemple #21
0
        [InlineData("http://www.example.com/space here.html", "http://www.example.com/space here.html")]   // characters are escaped
        public void LoadUri(string value, string expectedValue)
        {
            Environment.SetEnvironmentVariable(EnvVar, value);

            bool actualBool = EnvironmentVariableHelper.LoadUri(EnvVar, out Uri actualValue);

            Assert.True(actualBool);
            Assert.Equal(expectedValue, actualValue.ToString());
        }
Exemple #22
0
        /// <summary>
        /// This method is used to login to the Site
        /// </summary>
        /// <returns></returns>
        public static Task <LoginResponse> Login(string emailAddress, string password, bool passwordIsHashed = false)
        {
            // initial value
            LoginResponse loginResponse = new LoginResponse();

            // local
            Artist artist = null;

            // If the emailAddress string exists
            if (TextHelper.Exists(emailAddress))
            {
                // Create a new instance of a 'Gateway' object, and set the connectionName
                Gateway gateway = new Gateway(Connection.Name);

                // load the sites
                artist = gateway.FindArtistByEmailAddress(emailAddress);

                // if the artist exists
                if (NullHelper.Exists(artist))
                {
                    // get the key
                    string key = EnvironmentVariableHelper.GetEnvironmentVariableValue("BlazorImageGallery");

                    // if the key was found
                    if (TextHelper.Exists(key))
                    {
                        // can this artist be verified
                        bool isVerified = CryptographyHelper.VerifyHash(password, key, artist.PasswordHash, passwordIsHashed);

                        // if the password hashes match
                        if (isVerified)
                        {
                            // The user did login
                            loginResponse.Success = true;

                            // Set the artist
                            loginResponse.Artist = artist;
                        }
                        else
                        {
                            // Set the message
                            loginResponse.Message = "The passwords do not match.";
                        }
                    }
                    else
                    {
                        // Set the message
                        loginResponse.Message = "The Environment BlazorImageGallery Key was not found.";
                    }
                }
            }

            // return the list
            return(Task.FromResult(loginResponse));
        }
Exemple #23
0
        public void LoadString()
        {
            const string value = "something";

            Environment.SetEnvironmentVariable(EnvVar, value);

            bool actualBool = EnvironmentVariableHelper.LoadString(EnvVar, out string actualValue);

            Assert.True(actualBool);
            Assert.Equal(value, actualValue);
        }
Exemple #24
0
        public void ConfigureServices(IServiceCollection services)
        {
            using var vaultClient = new VaultClient.VaultClient(new VaultOptions
            {
                BaseUrl = new Uri(EnvironmentVariableHelper.Get("Vault:Endpoint", Configuration)),
                Engine  = Configuration["Vault:Engine"],
                Role    = Configuration["Vault:Role"]
            });
            vaultClient.Login(EnvironmentVariableHelper.Get("Vault:Token", Configuration)).GetAwaiter().GetResult();

            var authorityOptions = vaultClient.Get(Configuration["Authority:Options"]).GetAwaiter().GetResult();

            services.AddHealthChecks()
            .AddDbContextCheck <EdoContext>()
            .AddRedis(EnvironmentVariableHelper.Get("Redis:Endpoint", Configuration));

            services.ConfigureAuthentication(authorityOptions);
            services.AddControllers()
            .AddNewtonsoftJson(opts => opts.SerializerSettings.Converters.Add(new Newtonsoft.Json.Converters.StringEnumConverter()))
            .AddJsonOptions(opts => opts.JsonSerializerOptions.Converters.Add(new JsonStringEnumConverter()))
            .AddFluentValidation(fv =>
            {
                fv.DisableDataAnnotationsValidation         = true;
                fv.ImplicitlyValidateRootCollectionElements = true;
                fv.ImplicitlyValidateChildProperties        = true;
                fv.RegisterValidatorsFromAssembly(Assembly.GetExecutingAssembly());
            });
            services.AddResponseCompression();
            services.ConfigureTracing(Configuration, HostEnvironment);
            services.AddProblemDetailsErrorHandling();
            services.ConfigureApiVersioning();
            services.ConfigureSwagger();
            services.ConfigureCache(Configuration);
            services.ConfigureHttpClients(Configuration, HostEnvironment, vaultClient, authorityOptions["authorityUrl"]);
            services.ConfigureServiceOptions(Configuration, HostEnvironment, vaultClient);
            services.ConfigureUserEventLogging(Configuration, vaultClient);
            services.AddServices(HostEnvironment, Configuration, vaultClient);
            services.AddSignalR().AddStackExchangeRedis(EnvironmentVariableHelper.Get("Redis:Endpoint", Configuration));

            // override services
            services.AddTransient <AccommodationAvailabilitiesService>();
            services.AddTransient <AccommodationService>();
            services.AddTransient <IAgentContextService, AgentContextService>();
            services.AddTransient <BookingCancellationService>();
            services.AddTransient <IBookingEvaluationService, DirectApiBookingEvaluationService>();
            services.AddTransient <INotificationService, EdoDummyNotificationService>();
            services.AddTransient <ValuationService>();
            services.AddTransient <WideAvailabilitySearchService>();
            services.AddTransient <BookingInfoService>();
            services.AddTransient <BookingCreationService>();
            services.AddTransient <IBookingRegistrationService, DirectApiBookingRegistrationService>();
            services.AddTransient <ClientReferenceCodeValidationService>();
            services.ConfigureWideAvailabilityStorage(HostEnvironment, Configuration, vaultClient);
        }
Exemple #25
0
        private VaultClient.VaultClient GetVaultClient()
        {
            var vaultOptions = new VaultOptions
            {
                BaseUrl = new Uri(EnvironmentVariableHelper.Get("Vault:Endpoint", Configuration)),
                Engine  = Configuration["Vault:Engine"],
                Role    = Configuration["Vault:Role"]
            };

            return(new VaultClient.VaultClient(vaultOptions, new NullLoggerFactory()));
        }
Exemple #26
0
        public Resource Detect()
        {
            var resource = Resource.Empty;

            if (EnvironmentVariableHelper.LoadString(EnvVarKey, out string envResourceAttributeValue))
            {
                var attributes = ParseResourceAttributes(envResourceAttributeValue);
                resource = new Resource(attributes);
            }

            return(resource);
        }
Exemple #27
0
        private bool IsBetterRunOnLocalTempStorage()
        {
            bool isKuduAware = KuduHelper.IsKuduAware(
                EnvironmentVariableHelper.GetBuildVariablesFromEnvironmentVariables(_logger),
                _logger);

            bool isBetterRunOnLocalTempStorage = isKuduAware;

            _logger.WriteVerbose("Is Kudu-aware: " + isKuduAware, _Prefix);

            return(isBetterRunOnLocalTempStorage);
        }
Exemple #28
0
        // TODO (std_string) : think about non-recursive version of this impl
        private ConfigData LoadImpl(String sourceImportName, String parentConfig)
        {
            String importName = EnvironmentVariableHelper.ExpandEnvironmentVariables(sourceImportName).Replace("/", "\\");

            if (String.IsNullOrEmpty(importName))
            {
                throw new PorterConfigException($"Bad import name value \"{sourceImportName}\" in the config \"{parentConfig}\"");
            }
            // TODO (std_string) : we must know how to process case when importName will be relative to porter directory (if 'use_porter_home_directory_while_resolving_path' option is enabled)
            String    importConfigName = Path.IsPathRooted(importName) ? importName : Path.Combine(Path.GetDirectoryName(parentConfig) ?? String.Empty, importName);
            XDocument document         = XDocument.Load(importConfigName);

            return(LoadImpl(document.Root, importConfigName));
        }
Exemple #29
0
        public Resource Detect()
        {
            var resource = Resource.Empty;

            if (EnvironmentVariableHelper.LoadString(EnvVarKey, out string envResourceAttributeValue))
            {
                resource = new Resource(new Dictionary <string, object>
                {
                    [ResourceSemanticConventions.AttributeServiceName] = envResourceAttributeValue,
                });
            }

            return(resource);
        }
Exemple #30
0
        private ProfileModel ProcessEnvironmentVariables(ProfileModel profile, IDictionary <string, string> environmentVariables)
        {
            _objectValidator.IsNull(profile, nameof(profile));
            _objectValidator.IsNull(environmentVariables, nameof(environmentVariables));

            var newProfile = new ProfileModel();

            foreach (var field in profile.Fields)
            {
                var value = EnvironmentVariableHelper.TryGetEnvironmentVariableValueForField(field.Value, environmentVariables);
                newProfile.Fields.Add(field.Key, value);
            }

            return(newProfile);
        }