Search in sources :

Example 1 with GlobalRightsAdministrationSectionPage

use of org.xwiki.administration.test.po.GlobalRightsAdministrationSectionPage in project xwiki-platform by xwiki.

the class CommentAsGuestTest method setRightsOnGuest.

private static void setRightsOnGuest(Right right, State state) {
    GlobalRightsAdministrationSectionPage globalRights = GlobalRightsAdministrationSectionPage.gotoPage();
    // Wait for the rights live table to load before switching in order to prevent any possible race conditions.
    globalRights.getEditRightsPane().getRightsTable().waitUntilReady();
    globalRights.getEditRightsPane().switchToUsers();
    globalRights.getEditRightsPane().setGuestRight(right, state);
}
Also used : GlobalRightsAdministrationSectionPage(org.xwiki.administration.test.po.GlobalRightsAdministrationSectionPage)

Example 2 with GlobalRightsAdministrationSectionPage

use of org.xwiki.administration.test.po.GlobalRightsAdministrationSectionPage in project xwiki-platform by xwiki.

the class LoginTest method testRedirectBackAfterLogin.

/**
 * Verify that the initial URL is not lost after logging in when the session has expired.
 * See XWIKI-5317.
 */
@Test
public void testRedirectBackAfterLogin() {
    try {
        // Test setup: disallow view right for unauthenticated users. We need to be logged as admin in order to
        // do that. Since this is not what we are testing use the fast way to log in
        GlobalRightsAdministrationSectionPage grasp = new GlobalRightsAdministrationSectionPage();
        getDriver().get(getUtil().getURLToLoginAsAdminAndGotoPage(grasp.getURL()));
        getUtil().recacheSecretToken();
        getUtil().setDefaultCredentials(TestUtils.ADMIN_CREDENTIALS);
        grasp.forceAuthenticatedView();
        // Go to a page, log out and expire session by removing cookies, log in again and verify that the user is
        // redirected to the initial page.
        ViewPage page = getUtil().gotoPage("SomeSpace", "SomePage");
        page.logout();
        // Since view is disallowed for unauthenticated users, at this point we see a log in page.
        LoginPage loginPage = new LoginPage();
        // Remove all cookie to simulate a session expiry
        getDriver().manage().deleteAllCookies();
        loginPage.loginAsAdmin();
        // We use startsWith since the URL contains a jsessionid and a srid.
        Assert.assertTrue(getDriver().getCurrentUrl().startsWith(getUtil().getURL("SomeSpace", "SomePage")));
    } finally {
        GlobalRightsAdministrationSectionPage grasp = GlobalRightsAdministrationSectionPage.gotoPage();
        if (!grasp.isAuthenticated()) {
            getDriver().get(getUtil().getURLToLoginAsAdminAndGotoPage(grasp.getURL()));
        }
        grasp.unforceAuthenticatedView();
    }
}
Also used : GlobalRightsAdministrationSectionPage(org.xwiki.administration.test.po.GlobalRightsAdministrationSectionPage) ViewPage(org.xwiki.test.ui.po.ViewPage) LoginPage(org.xwiki.test.ui.po.LoginPage) Test(org.junit.Test)

Aggregations

GlobalRightsAdministrationSectionPage (org.xwiki.administration.test.po.GlobalRightsAdministrationSectionPage)2 Test (org.junit.Test)1 LoginPage (org.xwiki.test.ui.po.LoginPage)1 ViewPage (org.xwiki.test.ui.po.ViewPage)1