Uploaded image for project: 'Arquillian'
  1. Arquillian
  2. ARQ-739

Login simulation in tests with @LoginAs("username", "password") and an authenticated servlet protocol

    XMLWordPrintable

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() {...}
      
          ...
      }
      

      Attachments

        Activity

          People

            Unassigned Unassigned
            gdesmet@redhat.com Geoffrey De Smet (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: