Hi.
I have a custom authentication from my app which doesnt use identitystore. I used to in my testng test case have:
// disables security, since this is a FacesRequest pages.xml kicks in
invokeMethod("#{identity.setSecurityEnabled(false)}");
// the IdentityManager has an interface for creating user, later we might
// want to use our own service layer instead
IdentityManager m = IdentityManager.instance();
m.createUser("admin", "admin");
m.createRole("admin");
m.grantRole("admin", "admin");
// enables it again
invokeMethod("#{identity.setSecurityEnabled(true)}");However, since I use authenticator:
<security:identity authenticate-method="#{authenticator.authenticate}"/>
I cannot use the identitymanager to login anymore. I also cannot use the login.xhtml because it is too complicated. (I send email with onetime password etc).
If I try to manually login in my test:
invokeMethod("#{identity.setSecurityEnabled(false)}");
Identity.instance().setUsername(name);
Identity.instance().setPassword(passwd);
//Add the username as role
Identity.instance().addRole(name);
Identity.instance().login();
invokeMethod("#{identity.setSecurityEnabled(true)}");
I get the following exception:
[testng] WARN [org.jboss.seam.security.jaas.SeamLoginModule] Error invoking login method [testng] javax.el.ELException: java.lang.NullPointerException
And I can see that it tries to run the authenticator method. Now my question is
1. Can I somehow tell testng to not run authenticator for tests only, so that the above code would just login the test user?
2. If that is not possible, how can I get the identitymanager to work programatically from the tests, even though I am havent enabled it in components.xml?
3. How has anybody else with a custom login method done this? Can I see some examples?
Anybody?