We have a Java EE 7 application and use Arquillian to test stuff. Now we want to check for some permissions of the currently logged in user. My question is quite basic, how do I login a user when inside a testcase? I have read ProgrammaticLogin doesnt work in arquillian tests and Embedded Glassfish, security and Arquillian questions but they are not clearly answered. My current approach is something like this:
// Inject services etc.
@Test
public void testLogin(){
UserAccount user = new UserAccount();
user.setUsername("bob");
user.setPassword("bob");
userAccountService.save(user);
ProgrammaticLogin pl = new ProgrammaticLogin();
String realmName = "secureJDBCRealm";
try {
pl.login("bob", "bob".toCharArray(), realmName, true);
} catch (Exception e){
e.printStackTrace();
}
}
Now when I try to run this, a get a LoginException claiming that I have no LoginModule configured for "fileRealm". But "fileRealm" is not the realm i am searching for (I put it there to test first time, but then i changed it to "secureJDBCRealm", which is our custom Security Realm for GlassFish). We use arquillian-glassfish-embedded-3.1
for testing.
- Does anybody know where to define the Realm for Arquillian?
- Why does my application keep looking for fileRealm? Is this the default value? (couldn't find any specs here)