Search in sources :

Example 96 with UserVO

use of org.olat.user.restapi.UserVO in project openolat by klemens.

the class UserTest method deleteUser.

/**
 * Test if deleted user cannot login anymore. An administrator
 * create a user. This user log in and log out. The administrator
 * use the direct delete workflow in user management to delete
 * it.<br>
 * The user try to log in again, unsuccessfully. The
 * administrator doesn't find it anymore in the user
 * search of the user management tab.
 */
@Test
@RunAsClient
public void deleteUser(@InitialPage LoginPage loginPage, @Drone @User WebDriver userBrowser) {
    // login
    loginPage.assertOnLoginPage().loginAs("administrator", "openolat").resume();
    String uuid = UUID.randomUUID().toString();
    String username = "miku-" + uuid;
    String lastName = "Hatsune" + uuid;
    UserVO userVo = UserAdminPage.createUserVO(username, "Miku", lastName, "miku-" + uuid + "@openolat.com", "miku01");
    UserAdminPage userAdminPage = navBar.openUserManagement().openCreateUser().fillUserForm(userVo).assertOnUserEditView(username);
    // user log in
    LoginPage userLoginPage = LoginPage.getLoginPage(userBrowser, deploymentUrl);
    // tools
    userLoginPage.loginAs(username, "miku01").resume().assertLoggedIn(userVo);
    // log out
    new UserToolsPage(userBrowser).logout();
    // admin delete
    userAdminPage.openDirectDeleteUser().searchUserToDelete(username).selectAndDeleteUser(lastName);
    // user try the login
    userLoginPage = LoginPage.getLoginPage(userBrowser, deploymentUrl);
    userLoginPage.loginDenied(username, "miku01");
    // assert on error message
    By errorMessageby = By.cssSelector("div.modal-body.alert.alert-danger");
    OOGraphene.waitElement(errorMessageby, 2, userBrowser);
    // administrator search the deleted user
    userAdminPage.openSearchUser().searchByUsername(username).assertNotInUserList(username);
}
Also used : UserToolsPage(org.olat.selenium.page.user.UserToolsPage) UserVO(org.olat.user.restapi.UserVO) By(org.openqa.selenium.By) UserAdminPage(org.olat.selenium.page.user.UserAdminPage) LoginPage(org.olat.selenium.page.LoginPage) RunAsClient(org.jboss.arquillian.container.test.api.RunAsClient) Test(org.junit.Test)

Example 97 with UserVO

use of org.olat.user.restapi.UserVO in project openolat by klemens.

the class UserTest method loginInHomeWithRestUrl.

/**
 * Jump to notifications in home, go to the courses and return
 * to home's notification with a REST url.
 *
 * @see https://jira.openolat.org/browse/OO-1962
 * @param loginPage
 * @throws IOException
 * @throws URISyntaxException
 */
@Test
@RunAsClient
public void loginInHomeWithRestUrl(@InitialPage LoginPage loginPage) throws IOException, URISyntaxException {
    // create a random user
    UserRestClient userClient = new UserRestClient(deploymentUrl);
    UserVO user = userClient.createRandomUser();
    // load dmz
    loginPage.assertOnLoginPage();
    String jumpToNotificationsUrl = deploymentUrl.toString() + "url/HomeSite/" + user.getKey() + "/notifications/0";
    browser.get(jumpToNotificationsUrl);
    loginPage.loginAs(user.getLogin(), user.getPassword());
    // must see the notification
    new UserToolsPage(browser).assertOnNotifications();
    // go to courses
    navBar.openMyCourses();
    // use url to go to notifications
    String goToNotificationsUrl = deploymentUrl.toString() + "auth/HomeSite/" + user.getKey() + "/notifications/0";
    browser.get(goToNotificationsUrl);
    // must see the notification
    new UserToolsPage(browser).assertOnNotifications();
}
Also used : UserToolsPage(org.olat.selenium.page.user.UserToolsPage) UserVO(org.olat.user.restapi.UserVO) UserRestClient(org.olat.test.rest.UserRestClient) RunAsClient(org.jboss.arquillian.container.test.api.RunAsClient) Test(org.junit.Test)

Example 98 with UserVO

use of org.olat.user.restapi.UserVO in project openolat by klemens.

the class UserTest method resumeCourseOnDemand.

/**
 * Set the resume preferences to resume the session on request,
 * open a course, log out, log in, resume the session and check
 * if the course is resumed.
 *
 * @param loginPage
 * @throws IOException
 * @throws URISyntaxException
 */
@Test
public void resumeCourseOnDemand(@InitialPage LoginPage loginPage) throws IOException, URISyntaxException {
    // create a random user
    UserVO user = new UserRestClient(deploymentUrl).createRandomUser();
    // deploy a course
    CourseVO course = new RepositoryRestClient(deploymentUrl).deployDemoCourse();
    // login
    loginPage.loginAs(user.getLogin(), user.getPassword());
    // set the preferences to resume automatically
    UserToolsPage userTools = new UserToolsPage(browser);
    userTools.openUserToolsMenu().openMySettings().openPreferences().setResume(ResumeOption.ondemand);
    // open a course via REST url and click it
    CoursePageFragment.getCourse(browser, deploymentUrl, course).clickTree();
    // logout
    userTools.logout();
    // login again
    loginPage.assertOnLoginPage().loginAs(user.getLogin(), user.getPassword());
    // resume
    loginPage.resumeWithAssert();
    // check the title of the course if any
    WebElement courseTitle = browser.findElement(By.tagName("h2"));
    Assert.assertNotNull(courseTitle);
    Assert.assertTrue(courseTitle.isDisplayed());
    Assert.assertTrue(courseTitle.getText().contains(course.getTitle()));
}
Also used : RepositoryRestClient(org.olat.test.rest.RepositoryRestClient) CourseVO(org.olat.restapi.support.vo.CourseVO) UserToolsPage(org.olat.selenium.page.user.UserToolsPage) UserVO(org.olat.user.restapi.UserVO) WebElement(org.openqa.selenium.WebElement) UserRestClient(org.olat.test.rest.UserRestClient) Test(org.junit.Test)

Example 99 with UserVO

use of org.olat.user.restapi.UserVO in project openolat by klemens.

the class UserTest method createUser.

/**
 * The administrator create an user, the user log in.
 *
 * @param loginPage
 * @throws IOException
 * @throws URISyntaxException
 */
@Test
@RunAsClient
public void createUser(@InitialPage LoginPage loginPage, @Drone @User WebDriver userBrowser) throws IOException, URISyntaxException {
    // login
    loginPage.assertOnLoginPage().loginAs("administrator", "openolat").resume();
    String uuid = UUID.randomUUID().toString();
    String username = "miku-" + uuid;
    UserVO userVo = UserAdminPage.createUserVO(username, "Miku", "Hatsune", "miku-" + uuid + "@openolat.com", "miku01");
    UserAdminPage userAdminPage = navBar.openUserManagement().openCreateUser().fillUserForm(userVo).assertOnUserEditView(username);
    userAdminPage.openSearchUser().searchByUsername(username).assertOnUserInList(username).selectByUsername(username).assertOnUserEditView(username);
    // user log in
    LoginPage userLoginPage = LoginPage.getLoginPage(userBrowser, deploymentUrl);
    // tools
    userLoginPage.loginAs(username, "miku01").resume().assertLoggedIn(userVo);
}
Also used : UserVO(org.olat.user.restapi.UserVO) UserAdminPage(org.olat.selenium.page.user.UserAdminPage) LoginPage(org.olat.selenium.page.LoginPage) RunAsClient(org.jboss.arquillian.container.test.api.RunAsClient) Test(org.junit.Test)

Example 100 with UserVO

use of org.olat.user.restapi.UserVO in project openolat by klemens.

the class MembersWizardPage method setMembers.

public MembersWizardPage setMembers(UserVO... users) {
    StringBuilder sb = new StringBuilder();
    for (UserVO user : users) {
        if (sb.length() > 0)
            sb.append("\\n");
        sb.append(user.getLogin());
    }
    By importAreaBy = By.cssSelector(".modal-content textarea");
    WebElement importAreaEl = browser.findElement(importAreaBy);
    OOGraphene.textarea(importAreaEl, sb.toString(), browser);
    return this;
}
Also used : UserVO(org.olat.user.restapi.UserVO) By(org.openqa.selenium.By) WebElement(org.openqa.selenium.WebElement)

Aggregations

UserVO (org.olat.user.restapi.UserVO)364 Test (org.junit.Test)332 RunAsClient (org.jboss.arquillian.container.test.api.RunAsClient)260 UserRestClient (org.olat.test.rest.UserRestClient)258 LoginPage (org.olat.selenium.page.LoginPage)114 NavigationPage (org.olat.selenium.page.NavigationPage)110 CoursePageFragment (org.olat.selenium.page.course.CoursePageFragment)102 QTI21Page (org.olat.selenium.page.qti.QTI21Page)96 URL (java.net.URL)90 File (java.io.File)88 CourseEditorPageFragment (org.olat.selenium.page.course.CourseEditorPageFragment)84 URI (java.net.URI)72 HttpResponse (org.apache.http.HttpResponse)72 Identity (org.olat.core.id.Identity)72 UserToolsPage (org.olat.selenium.page.user.UserToolsPage)64 WebElement (org.openqa.selenium.WebElement)48 QTI21EditorPage (org.olat.selenium.page.qti.QTI21EditorPage)46 HttpGet (org.apache.http.client.methods.HttpGet)40 MembersPage (org.olat.selenium.page.course.MembersPage)36 AuthoringEnvPage (org.olat.selenium.page.repository.AuthoringEnvPage)34