Added logic to the XmlConnectionsDocumentCompiler to respect the FullFileEncryption flag

This commit is contained in:
David Sparer
2016-10-24 14:54:08 -06:00
parent 513edc58ab
commit e9ead72e79
2 changed files with 12 additions and 1 deletions

View File

@@ -55,6 +55,14 @@ namespace mRemoteNGTests.Config.Serializers
Assert.That(con4, Is.Not.Null);
}
[Test]
public void XmlContentEncryptedWhenFullFileEncryptionTurnedOn()
{
var xdoc = _documentCompiler.CompileDocument(_connectionTreeModel, true, false);
var rootElementValue = xdoc.Root?.Value;
Assert.That(rootElementValue, Is.Not.EqualTo(string.Empty));
}
private ConnectionTreeModel SetupConnectionTreeModel()
{

View File

@@ -32,7 +32,10 @@ namespace mRemoteNG.Config.Serializers
CompileRecursive(serializationTarget, rootElement);
var xmlDeclaration = new XDeclaration("1.0", "utf-8", "");
return new XDocument(xmlDeclaration, rootElement);
var xmlDocument = new XDocument(xmlDeclaration, rootElement);
if (fullFileEncryption)
xmlDocument = new XmlConnectionsDocumentEncryptor(_cryptographyProvider).EncryptDocument(xmlDocument, rootNodeInfo.PasswordString.ConvertToSecureString());
return xmlDocument;
}
private void CompileRecursive(ConnectionInfo serializationTarget, XContainer parentElement)