From: Arun G. <aru...@gm...> - 2013-12-13 23:41:00
|
Putting down random values for username and password in browser shows the error page, as expected. I'm not seeing that behavior with HtmlUnit though. Arun On Fri, Dec 13, 2013 at 3:34 PM, Ahmed Ashour <asa...@ya...> wrote: > Hi Arun, > > Yes, it is correct. > > Does putting random values in real browsers succeed too? If yes, then > HtmlUnit behaves correctly. > > Ahmed > ________________________________ > From: Arun Gupta <aru...@gm...> > To: htm...@li... > Sent: Saturday, December 14, 2013 2:28 AM > Subject: [Htmlunit-user] Form-based authentication using JSP/Servlet failing > with incorrect credentials > > Trying to write a test for form-based authentication using > JSP/Servlet. The form looks like: > > <form method="POST" action="j_security_check" name="myform"> > Username: <input type="text" name="j_username"> > Password: <input type="password" name="j_password" > autocomplete="off"> > <input type="submit" value="Submit" name="submitButton"> > <input type="reset" value="Reset"> > </form> > > POSTing to a form as: > > HtmlPage page = webClient.getPage(base + "/index.jsp"); > final HtmlForm form = page.getFormByName("myform"); > form.getInputByName("j_username").setValueAttribute("u1"); > form.getInputByName("j_password").setValueAttribute("p1"); > HtmlSubmitInput submitButton = form.getInputByName("submitButton"); > HtmlPage page2 = submitButton.click(); > assertEquals("Form-based Security - Success", page2.getTitleText()); > > succeeds. Changing the username and password to some random value > succeeds as well. > > Complete sample, including deployment descriptor, is available at: > > https://github.com/javaee-samples/javaee7-samples/tree/master/servlet/security-form-based > > Is this the correct way of doing form-based authentication ? > > Arun > > > -- > http://blog.arungupta.me > http://twitter.com/arungupta > > ------------------------------------------------------------------------------ > Rapidly troubleshoot problems before they affect your business. Most IT > organizations don't have a clear picture of how application performance > affects their revenue. With AppDynamics, you get 100% visibility into your > Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics > Pro! > http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk > _______________________________________________ > Htmlunit-user mailing list > Htm...@li... > https://lists.sourceforge.net/lists/listinfo/htmlunit-user > > > > ------------------------------------------------------------------------------ > Rapidly troubleshoot problems before they affect your business. Most IT > organizations don't have a clear picture of how application performance > affects their revenue. With AppDynamics, you get 100% visibility into your > Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics > Pro! > http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk > _______________________________________________ > Htmlunit-user mailing list > Htm...@li... > https://lists.sourceforge.net/lists/listinfo/htmlunit-user > -- http://blog.arungupta.me http://twitter.com/arungupta |