Hi list,

I'd like to use click-mock for testing my click web-application.

Several times I need to get the username and role from the request, which AFAIK are set by the SecurityRealm.

For example I display the users name on the top of the page using context.getRequest().getUserPrincipal().getName()

For security reasons I check the users role in onSecurityCheck() using
context.getRequest().isUserInRole(<requiredRole>)

Is the a way to inject Username/Role with the mock API?
In the moment I am trying the following, which results in a NPEX

MockContainer container = new MockContainer("C:/dev/projects/clock-mock-test/src/main/webapp");
container.start();
container.setParameter(Form.FORM_NAME, "filter");

//setting parameters for a FormTable
container.setParameter("filterForm_column_0", "entryDate");
container.setParameter("filterForm_operator_0", Operators.AFTER.name());
container.setParameter("filterForm_value_0", "01.07.2009");

//Thats where I get the NPEX
MyTestPage page = (MyTestPage) container.testPage(MyTestPage.class);

//The page forward to itself
assertTrue(MyTestPage.class.getName().equals(container.getForwardPageClass().getName()));

container.stop();

In the MockRequest sources I saw that
isUserInRole(String role) is not implemented yet and getUserPrincipal returns a Principal with name getHeader("REMOTE_USER"), how can I set REMOTE_USER?


Thanks in advance
SVen

Reply via email to