コード例 #1
0
        public void Test_AddNullThreshold()
        {
            IntrusionDetector detector = Esapi.IntrusionDetector as IntrusionDetector;

            Assert.IsNotNull(detector);

            detector.AddThreshold(null);
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        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));
        }
コード例 #5
0
        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);
        }
コード例 #6
0
        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);
        }
コード例 #7
0
        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);
        }