Beispiel #1
0
        public void Test_Execute()
        {
            IIntrusionDetector detector = Esapi.IntrusionDetector;

            string         url    = Guid.NewGuid().ToString();
            TransferAction action = new TransferAction(url);

            // Set context
            MockHttpContext.InitializeCurrentContext();
            SurrogateWebPage page = new SurrogateWebPage();

            HttpContext.Current.Handler = page;

            // Block
            try {
                Assert.AreNotEqual(HttpContext.Current.Request.RawUrl, action.Url);
                action.Execute(ActionArgs.Empty);

                Assert.Fail("Request not terminated");
            }
            catch (Exception exp) {
                // FIXME : so far there is no other way to test the transfer except to check
                // the stack of the exception. Ideally we should be able to mock the request
                // transfer itself
                Assert.IsTrue(exp.StackTrace.Contains("at System.Web.HttpServerUtility.TransferRequest(String path)"));
            }
        }