Details
-
Feature Request
-
Resolution: Unresolved
-
Major
-
None
-
None
-
None
-
None
Description
Motivation:
1) Testing the similar functionality under different logins (and therefore roles) should be easy.
2) Each in-container test is scope request.
If you inject a request or session scoped bean in the test, that requires an Identity to be injected, it will be created with a dummy Identity (username = null).
This can leave the bean in an illegal state (especially when using @PostConstruct or @Produces).
Proposal A:
@Deployment @OverProtocol("Authenticated Servlet") public static WebArchive createDeployment() {...} @Test @LoginAs("admin", "admin") public void changeThemeAsAdmin() {...} @Test(exception = AuthenticationException.class) @LoginAs("guest", "guest") public void changeThemeAsGuest() {...}
Furthermore, @LoginAs should also be defaultable for all tests on the class itself:
@LoginAs("admin", "admin") public class MyTest { @Deployment @OverProtocol("Authenticated Servlet") public static WebArchive createDeployment() {...} @Test public void changeThemeAsAdmin() {...} @Test public void changeImportAsAdmin() {...} ... }