Skip to content

Commit

Permalink
Merge pull request #44 from ron-bhy/ron/fix-neuter-password
Browse files Browse the repository at this point in the history
fixing neuter password issue #43
  • Loading branch information
VantivSDK authored Jul 23, 2021
2 parents 345c5cd + 0f3fb21 commit 504da51
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
2 changes: 1 addition & 1 deletion CnpSdkForNet/CnpSdkForNet/Communications.cs
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ public void NeuterUserCredentials(ref string inputXml)
if (!neuterUserCredentials) return;

const string pattern1 = "(?i)<user>.*?</user>";
const string pattern2 = "(?i)<password>.*></password>";
const string pattern2 = "(?i)<password>.*?</password>";

var rgx1 = new Regex(pattern1);
var rgx2 = new Regex(pattern2);
Expand Down
24 changes: 24 additions & 0 deletions CnpSdkForNet/CnpSdkForNetTest/Unit/TestCommunications.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,29 @@ public void TestConfigNotPresentInDictionary()
{
Assert.IsFalse(objectUnderTest.IsValidConfigValueSet("logFile"));
}

[Test]
public void TestNeuterUserCredentialsActuallyNeuters()
{
string inputXml = "<test><user>abc</user><password>123</password></test>";
config["neuterUserCredentials"] = "true";

objectUnderTest.NeuterUserCredentials(ref inputXml);

Assert.That(inputXml.Contains("<user>xxxxxx</user>"));
Assert.That(inputXml.Contains("<password>xxxxxxxx</password>"));
}

[Test]
public void TestNeuterUserCredentialsDoesNotNeuter()
{
string inputXml = "<test><user>abc</user><password>123</password></test>";
config["neuterUserCredentials"] = "false";

objectUnderTest.NeuterUserCredentials(ref inputXml);

Assert.That(inputXml.Contains("<user>abc</user>"));
Assert.That(inputXml.Contains("<password>123</password>"));
}
}
}

0 comments on commit 504da51

Please sign in to comment.