Exemple #1
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);
        }
        private Pbkdf2Model ProcessEnvironmentVariables(Pbkdf2Model model, IDictionary <string, string> environmentVariables)
        {
            _objectValidator.IsNull(model, nameof(model));
            _objectValidator.IsNull(environmentVariables, nameof(environmentVariables));

            var newModel = new Pbkdf2Model();

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

            return(newModel);
        }
        private ConfigurationModel ProcessEnvironmentVariables(ConfigurationModel configuration, IDictionary <string, string> environmentVariables)
        {
            _objectValidator.IsNull(configuration, nameof(configuration));
            _objectValidator.IsNull(environmentVariables, nameof(environmentVariables));

            var newConfiguration = new ConfigurationModel
            {
                TemplatePath         = EnvironmentVariableHelper.TryGetEnvironmentVariableValueForField(configuration.TemplatePath, environmentVariables),
                ResultPath           = EnvironmentVariableHelper.TryGetEnvironmentVariableValueForField(configuration.ResultPath, environmentVariables),
                ProfilePath          = EnvironmentVariableHelper.TryGetEnvironmentVariableValueForField(configuration.ProfilePath, environmentVariables),
                SecureVaultPath      = EnvironmentVariableHelper.TryGetEnvironmentVariableValueForField(configuration.SecureVaultPath, environmentVariables),
                SecureVaultPass      = EnvironmentVariableHelper.TryGetEnvironmentVariableValueForField(configuration.SecureVaultPass, environmentVariables),
                ProtectedFilePath    = EnvironmentVariableHelper.TryGetEnvironmentVariableValueForField(configuration.ProtectedFilePath, environmentVariables),
                ProtectedFileEntropy = EnvironmentVariableHelper.TryGetEnvironmentVariableValueForField(configuration.ProtectedFileEntropy, environmentVariables),
            };

            return(newConfiguration);
        }
 public void When_try_get_environment_variable_value_for_field_And_field_is_not_present_Then_throws_key_not_found_rxception()
 {
     Assert.Throws <KeyNotFoundException>(() => EnvironmentVariableHelper.TryGetEnvironmentVariableValueForField(Variable3Line, EnvVarValues));
 }
 public void When_try_get_environment_variable_value_for_field_And_env_var_dictionary_is_null_Then_throws_invalid_operation_exception()
 {
     Assert.Throws <InvalidOperationException>(() => EnvironmentVariableHelper.TryGetEnvironmentVariableValueForField(Variable1Line, null));
 }
        public void When_try_get_environment_variable_value_for_field_And_field_is_not_env_var_Then_returns_field()
        {
            var result = EnvironmentVariableHelper.TryGetEnvironmentVariableValueForField(InvalidEnvName, EnvVarValues);

            Assert.AreEqual(InvalidEnvName, result);
        }
        public void When_try_get_environment_variable_value_for_field_Then_returns_found_variable()
        {
            var result = EnvironmentVariableHelper.TryGetEnvironmentVariableValueForField(Variable2Line, EnvVarValues);

            Assert.AreEqual(VariableValue2, result);
        }