public void TestThatEncryptedJsonCanBeDecryptedIntoTypedConfig() { var parser = new EnvConfigParser(); dynamic config; parser.Encrypted(_json, out config); string deploymentPassword = config.DeploymentUser.Password; string lbPassword = config.LoadBalancer.Password; var key = JsonPasswordCrypto.GenerateKey(256); var crypto = new JsonPasswordCrypto(key); parser.EncryptJsonConfig(config, crypto); var encryptedJson = parser.ConvertToJsonText(config); Assert.That(parser.Encrypted(encryptedJson, out config), Is.True); using (var memStream = new MemoryStream(Encoding.UTF8.GetBytes(encryptedJson))) { var decryptedConfig = parser.GetTypedEnvConfig(memStream, key); Assert.That(decryptedConfig.DeploymentUser.Password, Is.EqualTo(deploymentPassword)); Assert.That(decryptedConfig.LoadBalancer.Password, Is.EqualTo(lbPassword)); } }
public void TestThatEncryptTagGetsEncrypted() { var parser = new EnvConfigParser(); dynamic config; parser.Encrypted(_encryptJson, out config); var key = JsonPasswordCrypto.GenerateKey(256); var crypto = new JsonPasswordCrypto(key); parser.EncryptJsonConfig(config, crypto); var encryptedJson = parser.ConvertToJsonText(config); //Assert.That(parser.Encrypted(encryptedJson, out config), Is.True); //using (var memStream = new MemoryStream(Encoding.UTF8.GetBytes(encryptedJson))) //{ // var decryptedConfig = parser.GetTypedEnvConfig(memStream, key); // Assert.That(decryptedConfig.DeploymentUser.Password, Is.EqualTo(password)); //} }