private void prepare() throws UserNotConnectedException, IOException { DocumentBasePage documentBasePage; DocumentBasePage s = login(); // Create a new user if not exist UsersGroupsBasePage page; UsersTabSubPage usersTab = s.getAdminCenter().getUsersGroupsHomePage().getUsersTab(); usersTab = usersTab.searchUser(TEST_USERNAME); if (!usersTab.isUserFound(TEST_USERNAME)) { page = usersTab .getUserCreatePage() .createUser( TEST_USERNAME, TEST_USERNAME, null, null, TEST_USERNAME, TEST_PASSWORD, "members"); usersTab = page.getUsersTab(true); } // search user usersTab = usersTab.searchUser(TEST_USERNAME); assertTrue(usersTab.isUserFound(TEST_USERNAME)); // create a wokspace1 and grant all rights to the test user documentBasePage = usersTab .exitAdminCenter() .getHeaderLinks() .getNavigationSubPage() .goToDocument("Workspaces"); DocumentBasePage workspacePage = createWorkspace(documentBasePage, WORKSPACE1_TITLE, null); PermissionsSubPage permissionsSubPage = workspacePage.getPermissionsTab(); // Need Read if (!permissionsSubPage.hasPermissionForUser("Read", TEST_USERNAME)) { permissionsSubPage.grantPermissionForUser("Read", TEST_USERNAME); } // Create test File 1 createFile(workspacePage, FILE1_NAME, null, false, null, null, null); workspacePage.getHeaderLinks().getNavigationSubPage().goToDocument("Workspaces"); workspacePage = createWorkspace(documentBasePage, WORKSPACE2_TITLE, null); permissionsSubPage = workspacePage.getPermissionsTab(); if (!permissionsSubPage.hasPermissionForUser("Manage everything", TEST_USERNAME)) { permissionsSubPage.grantPermissionForUser("Manage everything", TEST_USERNAME); } logout(); }
@Test public void testModifyWsDescription() throws Exception { // As an administrator, check that jsmith is created and has rights UsersGroupsBasePage usergroupPage = login().getAdminCenter().getUsersGroupsHomePage(); UsersTabSubPage page = usergroupPage.getUsersTab().searchUser(TEST_USERNAME); if (!page.isUserFound(TEST_USERNAME)) { usergroupPage = page.getUserCreatePage() .createUser( TEST_USERNAME, "John", "Smith", "Nuxeo", "*****@*****.**", TEST_PASSWORD, "members"); } DocumentBasePage documentBasePage = usergroupPage .exitAdminCenter() .getHeaderLinks() .getNavigationSubPage() .goToDocument("Workspaces"); PermissionsSubPage permissionsSubPage = documentBasePage.getPermissionsTab(); // Need WriteSecurity (so in practice Manage everything) to edit a // Workspace if (!permissionsSubPage.hasPermissionForUser("Manage everything", TEST_USERNAME)) { permissionsSubPage.grantPermissionForUser("Manage everything", TEST_USERNAME); } logout(); // Starting the test for real documentBasePage = login(TEST_USERNAME, TEST_PASSWORD).getContentTab().goToDocument("Workspaces"); // Create a new workspace named 'WorkspaceDescriptionModify_{current // time}' DocumentBasePage workspacePage = createWorkspace(documentBasePage, WORKSPACE_TITLE, "A workspace description"); // Modify Workspace description String descriptionModified = "Description modified"; workspacePage = workspacePage.getEditTab().edit(null, descriptionModified, null); assertEquals(descriptionModified, workspacePage.getCurrentFolderishDescription()); assertEquals(WORKSPACE_TITLE, workspacePage.getCurrentDocumentTitle()); // Clean up repository restoreState(); // Logout logout(); }