public void Test_AddNullThreshold() { IntrusionDetector detector = Esapi.IntrusionDetector as IntrusionDetector; Assert.IsNotNull(detector); detector.AddThreshold(null); }
public void Test_AddThresholdMissingAction() { string evtName = Guid.NewGuid().ToString(); IntrusionDetector detector = Esapi.IntrusionDetector as IntrusionDetector; Assert.IsNotNull(detector); Threshold threshold = new Threshold(evtName, 1, 1, new[] { Guid.NewGuid().ToString() }); detector.AddThreshold(threshold); }
public void Test_IntrusionDetected() { string evtName = Guid.NewGuid().ToString(); IntrusionDetector detector = Esapi.IntrusionDetector as IntrusionDetector; Assert.IsNotNull(detector); Threshold threshold = new Threshold(evtName, 1, 1, new[] { "log" }); detector.AddThreshold(threshold); Esapi.IntrusionDetector.AddEvent(evtName); }
public void Test_RemoveThreshold() { string evtName = Guid.NewGuid().ToString(); IntrusionDetector detector = Esapi.IntrusionDetector as IntrusionDetector; Assert.IsNotNull(detector); Threshold threshold = new Threshold(evtName, 1, 1, new[] { "logout" }); detector.AddThreshold(threshold); Assert.IsTrue(detector.RemoveThreshold(evtName)); }
public void Test_AddExceptionSecurityEvent() { string evtName = typeof(ArgumentException).FullName; IntrusionDetector detector = Esapi.IntrusionDetector as IntrusionDetector; Assert.IsNotNull(detector); Threshold threshold = new Threshold(evtName, 1, 1, new[] { "log" }); detector.AddThreshold(threshold); ArgumentException arg = new ArgumentException(); detector.AddException(arg); }
public void Test_AddDuplicateThreshold() { string evtName = Guid.NewGuid().ToString(); IntrusionDetector detector = Esapi.IntrusionDetector as IntrusionDetector; Assert.IsNotNull(detector); Threshold threshold = new Threshold(evtName, 1, 1, new[] { BuiltinActions.FormsAuthenticationLogout }); detector.AddThreshold(threshold); Threshold dup = new Threshold(evtName, 2, 2, null); detector.AddThreshold(dup); }
public void Test_Execute() { IntrusionDetector detector = Esapi.IntrusionDetector as IntrusionDetector; Assert.IsNotNull(detector); // Should be loaded by default BlockAction action = new BlockAction(); // Set context MockHttpContext.InitializeCurrentContext(); SurrogateWebPage page = new SurrogateWebPage(); HttpContext.Current.Handler = page; // Block Assert.AreNotEqual(HttpContext.Current.Response.StatusCode, action.StatusCode); action.Execute(ActionArgs.Empty); Assert.AreEqual(HttpContext.Current.Response.StatusCode, action.StatusCode); }