public void Execute_StrategyExecuted_Redirected() {
			var formsAuthentication = A.Fake<IFormsAuthentication>();
			var httpContextHandler = A.Fake<IHttpContextHandler>();

			A.CallTo(() => httpContextHandler.Current.Request.Url).Returns(new Uri("http://anyuri.org/"));
	
			var strategy = new FormsAuthenticationUnauthorizedStrategy(httpContextHandler, formsAuthentication);

			strategy.Execute();

			A.CallTo(() => httpContextHandler.Current.Response.Redirect(A<string>.Ignored, true)).MustHaveHappened(Repeated.Exactly.Once);
		}
		public void Constructor_SendInAHttpContextBaseFactoryMethodAndStrategyExecuted_RedirectedExecutedOnHttpContextReturned() {
			var formsAuthentication = A.Fake<IFormsAuthentication>();
			var httpContextBase = A.Fake<HttpContextBase>();
			HttpContext.Current = new HttpContext(new HttpRequest(string.Empty, "http://anyuri.org/", string.Empty), new HttpResponse(null));

			A.CallTo(() => httpContextBase.Request.Url).Returns(new Uri("http://anyuri.org/"));
	
			var strategy = new FormsAuthenticationUnauthorizedStrategy(() => httpContextBase, formsAuthentication);

			strategy.Execute();

			A.CallTo(() => httpContextBase.Response.Redirect(A<string>.Ignored, true)).MustHaveHappened(Repeated.Exactly.Once);
		}
Ejemplo n.º 3
0
        public void Execute_StrategyExecuted_Redirected()
        {
            var formsAuthentication = A.Fake <IFormsAuthentication>();
            var httpContextHandler  = A.Fake <IHttpContextHandler>();

            A.CallTo(() => httpContextHandler.Current.Request.Url).Returns(new Uri("http://anyuri.org/"));

            var strategy = new FormsAuthenticationUnauthorizedStrategy(httpContextHandler, formsAuthentication);

            strategy.Execute();

            A.CallTo(() => httpContextHandler.Current.Response.Redirect(A <string> .Ignored, true)).MustHaveHappened(Repeated.Exactly.Once);
        }
		public void Execute_StrategyExecutedWithNoCurrentUrl_RedirectedToFormsLoginUrlWithRedirectToRoot() {
			var formsAuthentication = A.Fake<IFormsAuthentication>();
			var httpContextHandler = A.Fake<IHttpContextHandler>();

			A.CallTo(() => formsAuthentication.LoginUrl).Returns("http://loginuri.org/");
			A.CallTo(() => httpContextHandler.Current.Request.Url).Returns(null);
			A.CallTo(() => httpContextHandler.Current.Server.UrlEncode(A<string>.Ignored)).ReturnsLazily(v => v.GetArgument<string>(0));
			
			var strategy = new FormsAuthenticationUnauthorizedStrategy(httpContextHandler, formsAuthentication);

			strategy.Execute();

			A.CallTo(() => httpContextHandler.Current.Response.Redirect("http://loginuri.org/?ReturnUrl=/", true)).MustHaveHappened(Repeated.Exactly.Once);
		}
Ejemplo n.º 5
0
        public void Constructor_SendInAHttpContextBaseFactoryMethodAndStrategyExecuted_RedirectedExecutedOnHttpContextReturned()
        {
            var formsAuthentication = A.Fake <IFormsAuthentication>();
            var httpContextBase     = A.Fake <HttpContextBase>();

            HttpContext.Current = new HttpContext(new HttpRequest(string.Empty, "http://anyuri.org/", string.Empty), new HttpResponse(null));

            A.CallTo(() => httpContextBase.Request.Url).Returns(new Uri("http://anyuri.org/"));

            var strategy = new FormsAuthenticationUnauthorizedStrategy(() => httpContextBase, formsAuthentication);

            strategy.Execute();

            A.CallTo(() => httpContextBase.Response.Redirect(A <string> .Ignored, true)).MustHaveHappened(Repeated.Exactly.Once);
        }
Ejemplo n.º 6
0
        public void Execute_StrategyExecutedWithNoCurrentUrl_RedirectedToFormsLoginUrlWithRedirectToRoot()
        {
            var formsAuthentication = A.Fake <IFormsAuthentication>();
            var httpContextHandler  = A.Fake <IHttpContextHandler>();

            A.CallTo(() => formsAuthentication.LoginUrl).Returns("http://loginuri.org/");
            A.CallTo(() => httpContextHandler.Current.Request.Url).Returns(null);
            A.CallTo(() => httpContextHandler.Current.Server.UrlEncode(A <string> .Ignored)).ReturnsLazily(v => v.GetArgument <string>(0));

            var strategy = new FormsAuthenticationUnauthorizedStrategy(httpContextHandler, formsAuthentication);

            strategy.Execute();

            A.CallTo(() => httpContextHandler.Current.Response.Redirect("http://loginuri.org/?ReturnUrl=/", true)).MustHaveHappened(Repeated.Exactly.Once);
        }