public void GetAlerts() { Alert alert = new Alert { id = Guid.NewGuid().ToString(), filterProfile = "default", strategyId = "1", context = "context", documentId = "documentId", filterType = "credit-card", date = "2020-05-27T13:57:47.016Z" }; List <Alert> mockResponse = new List <Alert> { alert }; string json = Newtonsoft.Json.JsonConvert.SerializeObject(mockResponse); _simulator.Get("/api/alerts").Responds(json).WithCode(200); PhilterClient philterClient = new PhilterClient(GetClient()); List <Alert> alerts = philterClient.GetAlerts(); Assert.IsNotNull(alerts); Assert.AreEqual(1, alerts.Count); }
public void FilterBadRequestTest() { _simulator.Post("/api/filter").Responds("His SSN was {{{REDACTED-ssn}}}.").WithCode(400); PhilterClient philterClient = new PhilterClient(GetClient()); Assert.ThrowsException <ClientException>(() => philterClient.Filter("His SSN was 123-45-6789.", "context", "invalid")); }
public void GetReplacementsBadRequestTest() { _simulator.Get("/api/replacements").WithParameter("d", "").Responds("").WithCode(400); PhilterClient philterClient = new PhilterClient(GetClient()); Assert.ThrowsException <ClientException>(() => philterClient.Filter("His SSN was 123-45-6789.", "context", "default")); }
public void FilterWithDocumentIdTest() { _simulator.Post("/api/filter").Responds("His SSN was {{{REDACTED-ssn}}}.").WithCode(200); PhilterClient philterClient = new PhilterClient(GetClient()); string filteredText = philterClient.Filter("His SSN was 123-45-6789.", "context", "docid", "default"); Assert.AreEqual("His SSN was {{{REDACTED-ssn}}}.", filteredText); }
public void FilterAuthorizedTest() { _simulator.Post("/api/filter").WithHeader("Authorization", "token:token").Responds("His SSN was {{{REDACTED-ssn}}}.").WithCode(200); PhilterClient philterClient = new PhilterClient(GetClient()); string filteredText = philterClient.Filter("His SSN was 123-45-6789.", "context", "default"); Assert.AreEqual("His SSN was {{{REDACTED-ssn}}}.", filteredText); }
public void StatusText() { _simulator.Get("/api/status").Responds("{\"Status\": \"Healthy\", \"Version\": \"1.0.0\"}").WithCode(200); PhilterClient philterClient = new PhilterClient(GetClient()); StatusResponse statusResponse = philterClient.GetStatus(); Assert.AreEqual("Healthy", statusResponse.Status); Assert.AreEqual("1.0.0", statusResponse.Version); }
//[TestMethod] public void FilterTest() { string certificate = "c:\\client-test.pfx"; SecureString password = new NetworkCredential("", "changeit").SecurePassword; PhilterClient philterClient = new PhilterClient(GetClient(certificate, password)); string filteredText = philterClient.Filter("His SSN was 123-45-6789.", "context", "default"); Assert.AreEqual("His SSN was {{{REDACTED-ssn}}}.", filteredText); Console.WriteLine(filteredText); }
public void ExplainWithDocumentIdTest() { Span span = new Span { CharacterStart = 1, CharacterEnd = 2, Text = "A" }; List <Span> spans = new List <Span> { span }; Explanation explanation = new Explanation { AppliedSpans = spans, IgnoredSpans = new List <Span>() }; ExplainResponse mockResponse = new ExplainResponse { FilteredText = "His SSN was {{{REDACTED-ssn}}}.", DocumentId = "docid", Explanation = explanation }; string json = Newtonsoft.Json.JsonConvert.SerializeObject(mockResponse); _simulator.Post("/api/explain").Responds(json).WithCode(200); PhilterClient philterClient = new PhilterClient(GetClient()); ExplainResponse explainResponse = philterClient.Explain("His SSN was 123-45-6789.", "context", "docid", "invalid"); Assert.IsNotNull(explainResponse); Assert.AreEqual(1, explainResponse.Explanation.AppliedSpans.Count); Assert.AreEqual(0, explainResponse.Explanation.IgnoredSpans.Count); Assert.AreEqual("docid", explainResponse.DocumentId); }
public void GetReplacementsTest() { Span span = new Span { CharacterStart = 1, CharacterEnd = 2, Text = "A" }; List <Span> spans = new List <Span> { span }; string json = Newtonsoft.Json.JsonConvert.SerializeObject(spans); _simulator.Get("/api/replacements").WithParameter("d", "1234").Responds(json).WithCode(200); PhilterClient philterClient = new PhilterClient(GetClient()); List <Span> replacementSpans = philterClient.GetReplacements("1234"); Assert.IsNotNull(replacementSpans); Assert.AreEqual(1, replacementSpans.Count); }