public void WriteEncryptedConfigurationTest() { var config = new JsonFileConfiguration(); config.Initialize(STR_JSONCONFIGFILE); // write secure properties config.Password = "******"; config.AppConnectionString = "server=.;database=unsecured"; config.Write(); string jsonConfig = File.ReadAllText(STR_JSONCONFIGFILE); Console.WriteLine(jsonConfig); // Password and AppSettings should be encrypted in config file Assert.IsTrue(jsonConfig.Contains(@"""Password"": ""ADoCNO6L1HIm8V7TyI4deg==""")); // now re-read settings into a new object var config2 = new JsonFileConfiguration(); config2.Initialize(STR_JSONCONFIGFILE); // check secure properties Assert.IsTrue(config.Password == "seekrit2"); Assert.IsTrue(config.AppConnectionString == "server=.;database=unsecured"); }
public void WriteConfigurationTest() { var config = new JsonFileConfiguration(); config.Initialize(STR_JSONCONFIGFILE); config.MaxDisplayListItems = 12; config.DebugMode = DebugModes.DeveloperErrorMessage; config.ApplicationName = "Changed"; config.SendAdminEmailConfirmations = true; // secure properties config.Password = "******"; config.AppConnectionString = "server=.;database=unsecured"; config.Write(); string jsonConfig = File.ReadAllText(STR_JSONCONFIGFILE); Console.WriteLine(jsonConfig); Assert.IsTrue(jsonConfig.Contains(@"""DebugMode"": ""DeveloperErrorMessage""")); Assert.IsTrue(jsonConfig.Contains(@"""MaxDisplayListItems"": 12")); Assert.IsTrue(jsonConfig.Contains(@"""SendAdminEmailConfirmations"": true")); // Password and AppSettings should be encrypted in config file #if NETFULL Assert.IsTrue(jsonConfig.Contains(@"""Password"": ""ADoCNO6L1HIm8V7TyI4deg==""")); #else Assert.IsTrue(jsonConfig.Contains("\"Password\": \"FpFibfJwF1idGqAb0vCc8g==\"")); #endif }
public void WriteConfigurationTest() { var config = new JsonFileConfiguration(); config.Initialize(STR_JSONCONFIGFILE); config.MaxDisplayListItems = 12; config.DebugMode = DebugModes.DeveloperErrorMessage; config.ApplicationName = "Changed"; config.SendAdminEmailConfirmations = true; // secure properties config.Password = "******"; config.AppConnectionString = "server=.;database=unsecured"; config.Write(); string jsonConfig = File.ReadAllText(STR_JSONCONFIGFILE); Console.WriteLine(jsonConfig); Assert.IsTrue(jsonConfig.Contains(@"""DebugMode"": ""DeveloperErrorMessage""")); Assert.IsTrue(jsonConfig.Contains(@"""MaxDisplayListItems"": 12") ); Assert.IsTrue(jsonConfig.Contains(@"""SendAdminEmailConfirmations"": true")); // Password and AppSettings should be encrypted in config file Assert.IsTrue(jsonConfig.Contains(@"""Password"": ""ADoCNO6L1HIm8V7TyI4deg==""")); }
public void WriteConfigurationTest() { File.Delete(STR_JSONCONFIGFILE); var config = new JsonFileConfiguration(); config.Initialize(STR_JSONCONFIGFILE); config.MaxDisplayListItems = 12; config.DebugMode = DebugModes.DeveloperErrorMessage; config.ApplicationName = "Changed"; config.SendAdminEmailConfirmations = true; // secure properties config.Password = "******"; config.AppConnectionString = "server=.;database=unsecured"; config.License.Company = "West Wind 3"; config.License.LicenseKey = "RickWestWind3-61123222"; config.Write(); string jsonConfig = File.ReadAllText(STR_JSONCONFIGFILE); Console.WriteLine(jsonConfig); Assert.IsTrue(jsonConfig.Contains(@"""DebugMode"": ""DeveloperErrorMessage""")); Assert.IsTrue(jsonConfig.Contains(@"""MaxDisplayListItems"": 12")); Assert.IsTrue(jsonConfig.Contains(@"""SendAdminEmailConfirmations"": true")); // Password and AppSettings should be encrypted in config file Assert.IsTrue(jsonConfig.Contains(@"""Password"": ""ADoCNO6L1HIm8V7TyI4deg==""")); }
public void DefaultConstructorInstanceTest() { var config = new JsonFileConfiguration(); config.Initialize(configData: STR_JSONCONFIGFILE); Assert.IsNotNull(config); Assert.IsFalse(string.IsNullOrEmpty(config.ApplicationName)); string text = File.ReadAllText(STR_JSONCONFIGFILE); Console.WriteLine(text); }
public void WriteEncryptedConfigurationTest() { File.Delete(STR_JSONCONFIGFILE); var config = new JsonFileConfiguration(); config.Initialize(STR_JSONCONFIGFILE); // write secure properties config.Password = "******"; config.AppConnectionString = "server=.;database=unsecured"; config.License.Company = "West Wind 2"; config.License.LicenseKey = "RickWestWind2-51123222"; config.Write(); // completely reload settings config = new JsonFileConfiguration(); config.Initialize(STR_JSONCONFIGFILE); Assert.IsTrue(config.Password == "seekrit2"); Assert.IsTrue(config.License.Company == "West Wind 2"); Assert.IsTrue(config.License.LicenseKey == "RickWestWind2-51123222"); string jsonConfig = File.ReadAllText(STR_JSONCONFIGFILE); Console.WriteLine(jsonConfig); // Password and AppSettings should be encrypted in config file #if NETFULL Assert.IsTrue(jsonConfig.Contains(@"""Password"": ""ADoCNO6L1HIm8V7TyI4deg==""")); #else Assert.IsTrue(jsonConfig.Contains("\"Password\": \"FpFibfJwF1idGqAb0vCc8g==\"")); #endif // now re-read settings into a new object var config2 = new JsonFileConfiguration(); config2.Initialize(STR_JSONCONFIGFILE); // check secure properties Assert.IsTrue(config.Password == "seekrit2"); Assert.IsTrue(config.AppConnectionString == "server=.;database=unsecured"); }