public void Should_Not_Filter_Credit_Card_Less_Than_13_Digits() { var id = Convert.ToString(Guid.NewGuid()); var apiLog = Utility.GetApiLog(); apiLog.Id = id; apiLog.SetValue("CreditInfo1", "345621234673"); var filter = new PaymentDataFilter(); var filteredLog = filter.Apply(apiLog); var formatter = JsonLogFormatter.Instance; var firehoseSink = Utility.GetFirehoseSink(); var redisSink = Utility.GetRedisSink(); var compositeSink = Utility.GetCompositeSink(formatter, redisSink, firehoseSink); var logWriter = new LogWriter(formatter, compositeSink); logWriter.WriteAsync(filteredLog).GetAwaiter().GetResult(); //Thread.Sleep(60000); var logData = Utility.GetEsLogDataById(id); var esLogId = string.Empty; var expected1 = "345621234673"; string actual1; logData.TryGetValue("CreditInfo1", out actual1); Assert.AreEqual(expected1, actual1); }
public void Should_Filter_Credit_Card_As_Payload() { var id = Convert.ToString(Guid.NewGuid()); var apiLog = Utility.GetApiLog(); apiLog.Id = id; var creditCardPayload = new Payload("4444555555555555"); apiLog.SetValue("CreditInfo", creditCardPayload); var filter = new PaymentDataFilter(); var filteredLog = filter.Apply(apiLog); var formatter = JsonLogFormatter.Instance; var firehoseSink = Utility.GetFirehoseSink(); var redisSink = Utility.GetRedisSink(); var compositeSink = Utility.GetCompositeSink(formatter, redisSink, firehoseSink); var logWriter = new LogWriter(formatter, compositeSink); logWriter.WriteAsync(filteredLog).GetAwaiter().GetResult(); //Thread.Sleep(40000); var logData = Utility.GetEsLogDataById(id); var esLogId = string.Empty; var expected = "444455******5555"; string actualUrl; logData.TryGetValue("CreditInfo", out actualUrl); var actual = Utility.GetOutputFromUrl(actualUrl); Assert.AreEqual(expected, actual); }
public void Should_Not_Filter_Incorrect_Credit_Card() { var id = Convert.ToString(Guid.NewGuid()); var apiLog = Utility.GetApiLog(); apiLog.Id = id; apiLog.SetValue("CreditInfo2", "1235345621234673"); apiLog.SetValue("CreditInfo3", "44445555555555552"); apiLog.SetValue("CreditInfo4", "AAAA555555555555"); var filter = new PaymentDataFilter(); var filteredLog = filter.Apply(apiLog); var formatter = JsonLogFormatter.Instance; var firehoseSink = Utility.GetFirehoseSink(); var redisSink = Utility.GetRedisSink(); var compositeSink = Utility.GetCompositeSink(formatter, redisSink, firehoseSink); var logWriter = new LogWriter(formatter, compositeSink); logWriter.WriteAsync(filteredLog).GetAwaiter().GetResult(); //Thread.Sleep(60000); var logData = Utility.GetEsLogDataById(id); var esLogId = string.Empty; var expected2 = "1235345621234673"; string actual2; logData.TryGetValue("CreditInfo2", out actual2); var expected3 = "44445555555555552"; string actual3; logData.TryGetValue("CreditInfo3", out actual3); var expected4 = "AAAA555555555555"; string actual4; logData.TryGetValue("CreditInfo4", out actual4); Assert.AreEqual(expected2, actual2); Assert.AreEqual(expected3, actual3); Assert.AreEqual(expected4, actual4); }