From: John L. <joh...@ca...> - 2003-03-14 17:25:27
|
An additional issue issue. I am doing a form-based login where the web page is constructed as follows: <form NAME="j_security_check" ACTION="j_security_check" METHOD="POST"> ... <input type="text" value="value1" name="j_username" /> ... <input type="password" value="value2" name="j_password" size="10" maxlength="15" /> ... <input TYPE=submit NAME="login" VALUE="Login"> </form> [ Note, I am initializing the login and password inputs to a VALID set of values. ] The underlying JSP code invokes a second page via the Login post along these lines: response.sendRedirect("j_security_check?j_username="+login+"&j_password="+pass); I press the Login button and it brings me to the second page (because it is successful). The server log is as follows: 192.168.1.15 - value1 [14/Mar/2003:16:16:50 +0000] "POST /order/j_security_check HTTP/1.1" 302 0 "http://john.candata.com/order/Login.jsp;jsessionid=5ifh899gfnnb0" "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.1) Gecko/20020826" When I do the same thing via HtmlUnit, for some reason, it is not passing in the login and password values. It passes all the assertion tests except the final one indicating a successful login to the second page. It is a login failure, and I am returned back to the original page. final HtmlForm form = page1.getFormByName("j_security_check"); final HtmlSubmitInput button = (HtmlSubmitInput)form.getInputByName("login"); final HtmlTextInput textField = (HtmlTextInput)form.getInputByName("j_username"); final HtmlPasswordInput pwdField = (HtmlPasswordInput)form.getInputByName("j_password"); assertEquals("value1, textField.getValueAttribute()); assertEquals("value2", pwdField.getValueAttribute()); final HtmlPage page2 = (HtmlPage)button.click(); assertEquals("Second Page", page2.getTitleText()); The server log does not indicate the value of the Login input, as it does when I manually log in. 192.168.1.15 - - [14/Mar/2003:16:20:17 +0000] "POST /order/j_security_check HTTP/1.1" 302 0 "-" "Mozilla/4.0 (compatible; MSIE 6.0b; Windows 98)" I thought maybe Java.net.authenticator - setting Login and Password - might solve the problem, but the effect was the same. The login failed and I did not reach second page. webClient.setCredentialProvider(new SimpleCredentialProvider ("value1", "value2")); Hints? |