public void DecryptXmlThrowsWhenCryptoIsNull() { var xml = "<foo bar=\"MTIz\"><baz>NDU2</baz><baz>Nzg5</baz><qux>PGdhcnBseSBncmF1bHQ9ImFiYyIgLz4=</qux></foo>"; var keyIdentifier = new object(); ICrypto crypto = null; Assert.That(() => crypto.DecryptXml(xml, new[] { "/foo/@bar", "/foo/baz", "/foo/qux" }, keyIdentifier), Throws.ArgumentNullException); }
public static void DecryptXmlThrowsWhenCryptoIsNull() { var xml = "<foo bar=\"[[123]]\"><baz>[[456]]</baz><baz>[[789]]</baz><qux>[[<garply grault=\"abc\" />]]</qux></foo>"; ICrypto crypto = null !; var act = () => crypto.DecryptXml(xml, new[] { "/foo/@bar", "/foo/baz", "/foo/qux" }); act.Should().ThrowExactly <ArgumentNullException>(); }
/// <summary> /// Decrypts the fields, specified by XPath, that are contained in the given xml document string. /// </summary> /// <param name="crypto"> /// The instance of <see cref="ICrypto"/> that ultimately responsible for performing decryption operations /// on field values. /// </param> /// <param name="xmlString">A string containing an xml document.</param> /// <param name="xpathToDecrypt">The XPath of the field to decrypt.</param> /// <param name="credentialName"> /// The name of the credential to use for this encryption operation, /// or null to use the default credential. /// </param> /// <returns>The same xml document, except with the specified fields decrypted.</returns> public static string DecryptXml(this ICrypto crypto, string xmlString, string xpathToDecrypt, string credentialName = null) => crypto.DecryptXml(xmlString, new[] { xpathToDecrypt }, credentialName);