public void LogInProcess() { string securedActionUrl = "/home/SecretAction"; appHost.Start(browsingSession => { // First try to request a secured page without being logged in RequestResult initialRequestResult = browsingSession.Get(securedActionUrl); string loginRedirectUrl = initialRequestResult.Response.RedirectLocation; Assert.IsTrue(loginRedirectUrl.StartsWith("/Account/LogOn"), "Didn't redirect to logon page"); // Now follow redirection to logon page string loginFormResponseText = browsingSession.Get(loginRedirectUrl).ResponseText; string suppliedAntiForgeryToken = MvcUtils.ExtractAntiForgeryToken(loginFormResponseText); // Now post the login form, including the verification token RequestResult loginResult = browsingSession.Post(loginRedirectUrl, new { UserName = "******", Password = "******", __RequestVerificationToken = suppliedAntiForgeryToken }); string afterLoginRedirectUrl = loginResult.Response.RedirectLocation; Assert.AreEqual(securedActionUrl, afterLoginRedirectUrl, "Didn't redirect back to SecretAction"); // Check that we can now follow the redirection back to the protected action, and are let in RequestResult afterLoginResult = browsingSession.Get(securedActionUrl); Assert.AreEqual("Hello, you're logged in as steve", afterLoginResult.ResponseText); }); }
private void RegisterViewEngines() { // For versions greater than 8.0 routes are registered in HccUrlRoutingModule // since all view engines are cleared in DNN's MvcHttpModule module var versionofDNN = typeof(DotNetNukeContext).Assembly.GetName().Version; if (versionofDNN < new Version("8.0")) { MvcUtils.RegisterViewEngines(); } }
private void RegisterViewEngines(object sender, EventArgs e) { // For versions less than 8.0 routes are registered in ServiceRouteMapper // to prevent registration of same view engine on each request var versionofDNN = typeof(DotNetNukeContext).Assembly.GetName().Version; if (versionofDNN >= new Version("8.0")) { MvcUtils.RegisterViewEngines(); } }
public void TestFixtureSetUp() { //If you MVC project is not in the root of your solution directory then include the path //e.g. AppHost.Simulate("Website\MyMvcApplication") appHost = AppHost.Simulate("MyMvcApplication"); appHost.StartBrowsingSession(); //login appHost.Start(browsingSession => { //follow redirection to logon page var loginRedirectUrl = "/Account/LogOn"; string loginFormResponseText = browsingSession.Get(loginRedirectUrl).ResponseText; string suppliedAntiForgeryToken = MvcUtils.ExtractAntiForgeryToken(loginFormResponseText); // Now post the login form, including the verification token browsingSession.Post(loginRedirectUrl, new { UserName = "******", Password = "******", __RequestVerificationToken = suppliedAntiForgeryToken }); }); }
private void RegisterViewEngines(object sender, EventArgs e) { MvcUtils.RegisterViewEngines(); }