from test case

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view

from test case


I'm trying to write a test case for my application in which I need to sign in a user so a certain Panel is displayed and I can interact with it (and do other tasks using the user role).

My problem is that databinder default authentication components send a challenge + password encrypted with RSA, so I can't simply set the password field of the authentication form to the password string value.

The classes don't expose the challenge field, so I couldn't access it to  encrypt the value on the test case. I could try to disable authentication when doing the test case, but I want to run the test case using the 'most real' scenario I can ;). Also tried creating a session, signing in, and then trying to set the request cookies so that session is used, but couldn't figure out how to do the last part, yet ;).

Is there any way I can overcome this while using the auth components? I'm totally new to databinder AND wicket, so I might be missing something.

My current code is as follows, but of course, doesn't work:

        public void testLoginTaskBook() {
                FormTester f = tester.newFormTester("signinSocket:signInForm");
                f.setValue("username-border:username", "admin");
                f.setValue("password-border:password", "admin");
Reply | Threaded
Open this post in threaded view

Re: Sign-in from test case

OK, I figured out I could do:

(AuthDataSession) tester.getWicketSession();

And sign-in on that session. It would be nice to do it by submitting the form instead of bypassing it, but I think I can live without it.