Class LoginHelper


  • public class LoginHelper
    extends Object
    Helps to manage the user session for a http client for testing. Use this in preference to com.atlassian.confluence.AbstractConfluenceAcceptanceTest.logout().
    • Field Detail

      • log

        protected static final org.slf4j.Logger log
    • Constructor Detail

      • LoginHelper

        public LoginHelper()
      • LoginHelper

        public LoginHelper​(net.sourceforge.jwebunit.junit.WebTester webTester)
    • Method Detail

      • logOutAndIn

        public void logOutAndIn​(User user)
        Log out the current user and then log back in with the given user. The logIn is a fast decoratorless one.
        Parameters:
        user - user to log in
      • logOutAndStayAnonymous

        public void logOutAndStayAnonymous()
        Log out the current user and then begin a new session as the anonymous user. The beginAt is a fast decoratorless one.
      • logIn

        public void logIn​(String username,
                          String password,
                          boolean rememberMe)
        Log in with a specific username and password plus options.
      • logInDecorated

        @Deprecated
        public void logInDecorated​(User user)
        Deprecated.
        since 6.7. noop.jsp no longer supports having a decorator.
      • logout

        public void logout()
        Log out to the super-fast test logout screen. This logs your user out quickly, freeing up resources, but doesn't return the appropriate result for testing. It also sets up the WebTester by calling WebTester.beginAt(String). You should use this method to log out most of the time, and also to begin tests where Confluence is being used anonymously. But use logOutSlowly() if you're testing log-out functionality specifically.

        Note, this method will only actually invalidate your user's existing session on the server if the functest plugin is installed.

        See Also:
        logOutSlowly()
      • logOutFast

        public void logOutFast()
        Logs the current user out as quickly as possible. It does not call WebTester.beginAt(String) so you can not use it to ensure the WebTester is appropriately set up.
      • logOutSlowly

        public void logOutSlowly()
        Log out by clicking the Log Out link in the UI. This method assumes you are already on a page with the Log Out menu visible. You can use it to test that the results of clicking that link are appropriate. It does not call WebTester.beginAt(String) so you can not use it to ensure the WebTester is appropriately set up.
        See Also:
        logout()
      • isLoggedInAs

        public boolean isLoggedInAs​(String username)
        Returns true if logged in as the passed user.
      • isLoggedInAs

        public boolean isLoggedInAs​(User user)
        Returns true if logged in as the passed user.
      • logInViaForm

        public void logInViaForm​(User user)
      • logInViaForm

        public void logInViaForm​(String username,
                                 String password,
                                 boolean rememberMe)
      • logInViaFormOnCurrentPage

        public void logInViaFormOnCurrentPage​(User user)
      • logInViaFormOnCurrentPage

        public void logInViaFormOnCurrentPage​(String username,
                                              String password,
                                              boolean rememberMe)
      • getLoginButtonId

        public String getLoginButtonId()
        HACK - temp method to get tests checking for login screen working. Needs refactoring out to something like the Selenium stack's "Suite" class.
        Returns:
        the id or name of the login button that we can assert to be present on the Login screen
      • logInAs

        public void logInAs​(User user)
      • logInAsAtHomepage

        public void logInAsAtHomepage​(User user)
      • logInAsAtHomepage

        public void logInAsAtHomepage​(String username,
                                      String password)
        Logs in and then goes straight to "/"
      • logInToDestination

        public void logInToDestination​(User user,
                                       String destination)