Search in sources :

Example 1 with UserVO

use of org.olat.user.restapi.UserVO in project OpenOLAT by OpenOLAT.

the class LoginTest method loginAsNewUser.

/**
 * Create a new user and try to login with its credentials.
 *
 * @param loginPage
 * @throws IOException
 * @throws URISyntaxException
 */
@Test
@RunAsClient
public void loginAsNewUser(@InitialPage LoginPage loginPage) throws IOException, URISyntaxException {
    // create a random user
    UserRestClient userClient = new UserRestClient(deploymentUrl);
    UserVO user = userClient.createRandomUser();
    // load dmz
    loginPage.assertOnLoginPage();
    // login
    loginPage.loginAs(user.getLogin(), user.getPassword());
}
Also used : 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 2 with UserVO

use of org.olat.user.restapi.UserVO in project OpenOLAT by OpenOLAT.

the class CatalogTest method testGetOwners.

@Test
public void testGetOwners() throws IOException, URISyntaxException {
    RestConnection conn = new RestConnection();
    assertTrue(conn.login("administrator", "openolat"));
    URI uri = UriBuilder.fromUri(getContextURI()).path("catalog").path(entry1.getKey().toString()).path("owners").build();
    HttpGet method = conn.createGet(uri, MediaType.APPLICATION_JSON, true);
    HttpResponse response = conn.execute(method);
    assertEquals(200, response.getStatusLine().getStatusCode());
    InputStream body = response.getEntity().getContent();
    List<UserVO> voes = parseUserArray(body);
    assertNotNull(voes);
    CatalogEntry entry = catalogManager.loadCatalogEntry(entry1.getKey());
    List<Identity> identities = BaseSecurityManager.getInstance().getIdentitiesOfSecurityGroup(entry.getOwnerGroup());
    assertNotNull(identities);
    assertEquals(identities.size(), voes.size());
    conn.shutdown();
}
Also used : UserVO(org.olat.user.restapi.UserVO) InputStream(java.io.InputStream) HttpGet(org.apache.http.client.methods.HttpGet) CatalogEntry(org.olat.repository.CatalogEntry) HttpResponse(org.apache.http.HttpResponse) Identity(org.olat.core.id.Identity) URI(java.net.URI) Test(org.junit.Test)

Example 3 with UserVO

use of org.olat.user.restapi.UserVO in project OpenOLAT by OpenOLAT.

the class UserTest method movePortletToTheTop.

/**
 * Go to the portal, edit it, move the notes to the
 * top, quit editing, check the notes are the first
 * portlet in the view mode.
 *
 * @param loginPage
 * @throws IOException
 * @throws URISyntaxException
 */
@Test
@RunAsClient
public void movePortletToTheTop(@InitialPage LoginPage loginPage) throws IOException, URISyntaxException {
    UserVO user = new UserRestClient(deploymentUrl).createRandomUser();
    loginPage.loginAs(user.getLogin(), user.getPassword());
    PortalPage portal = navBar.openPortal().assertPortlet(PortalPage.notesBy).edit().moveLeft(PortalPage.notesBy).moveUp(PortalPage.notesBy).moveUp(PortalPage.notesBy).moveUp(PortalPage.notesBy).moveRight(PortalPage.quickStartBy).moveDown(PortalPage.quickStartBy);
    // finish editing
    portal.finishEditing();
    // no inactive panel -> we are in view mode
    List<WebElement> portalInactive = browser.findElements(PortalPage.inactiveBy);
    Assert.assertTrue(portalInactive.isEmpty());
    // notes must be first
    List<WebElement> portlets = browser.findElements(By.className("o_portlet"));
    Assert.assertFalse(portlets.isEmpty());
    WebElement notesPortlet = portlets.get(0);
    String cssClass = notesPortlet.getAttribute("class");
    Assert.assertNotNull(cssClass);
    Assert.assertTrue(cssClass.contains("o_portlet_notes"));
}
Also used : UserVO(org.olat.user.restapi.UserVO) WebElement(org.openqa.selenium.WebElement) PortalPage(org.olat.selenium.page.user.PortalPage) UserRestClient(org.olat.test.rest.UserRestClient) RunAsClient(org.jboss.arquillian.container.test.api.RunAsClient) Test(org.junit.Test)

Example 4 with UserVO

use of org.olat.user.restapi.UserVO in project OpenOLAT by OpenOLAT.

the class UserTest method userSwitchLanguageSwitchToEnglish.

/**
 * Switch the language to german and after logout login to english
 * and check every time.
 *
 * @param loginPage
 * @throws IOException
 * @throws URISyntaxException
 */
@Test
@RunAsClient
public void userSwitchLanguageSwitchToEnglish(@InitialPage LoginPage loginPage) throws IOException, URISyntaxException {
    UserVO user = new UserRestClient(deploymentUrl).createRandomUser();
    loginPage.loginAs(user.getLogin(), user.getPassword()).resume();
    // set the languages preferences to german
    UserToolsPage userTools = new UserToolsPage(browser);
    userTools.openUserToolsMenu().openMySettings().assertOnUserSettings().openPreferences().assertOnUserPreferences().setLanguage("de");
    userTools.logout();
    loginPage.loginAs(user.getLogin(), user.getPassword()).resume();
    WebElement usernameDE = browser.findElement(LoginPage.usernameFooterBy);
    boolean de = usernameDE.getText().contains("Eingeloggt als");
    Assert.assertTrue(de);
    List<WebElement> deMarker = browser.findElements(By.className("o_lang_de"));
    Assert.assertFalse(deMarker.isEmpty());
    // set the languages preferences to english
    userTools.openUserToolsMenu().openMySettings().openPreferences().setLanguage("en");
    userTools.logout();
    loginPage.loginAs(user.getLogin(), user.getPassword()).resume();
    WebElement usernameEN = browser.findElement(LoginPage.usernameFooterBy);
    boolean en = usernameEN.getText().contains("Logged in as");
    Assert.assertTrue(en);
    List<WebElement> enMarker = browser.findElements(By.className("o_lang_en"));
    Assert.assertFalse(enMarker.isEmpty());
}
Also used : UserToolsPage(org.olat.selenium.page.user.UserToolsPage) UserVO(org.olat.user.restapi.UserVO) WebElement(org.openqa.selenium.WebElement) UserRestClient(org.olat.test.rest.UserRestClient) RunAsClient(org.jboss.arquillian.container.test.api.RunAsClient) Test(org.junit.Test)

Example 5 with UserVO

use of org.olat.user.restapi.UserVO in project OpenOLAT by OpenOLAT.

the class UserTest method userResetItsPreferences.

/**
 * Reset the preferences and check that a log out happens
 *
 * @param loginPage
 * @throws IOException
 * @throws URISyntaxException
 */
@Test
@RunAsClient
public void userResetItsPreferences(@InitialPage LoginPage loginPage) throws IOException, URISyntaxException {
    UserVO user = new UserRestClient(deploymentUrl).createRandomUser();
    loginPage.loginAs(user.getLogin(), user.getPassword()).resume();
    UserToolsPage userTools = new UserToolsPage(browser);
    UserPreferencesPageFragment prefs = userTools.openUserToolsMenu().openMySettings().openPreferences();
    // reset the preferences
    prefs.resetPreferences();
    // check the user is log out
    loginPage.assertOnLoginPage();
}
Also used : UserToolsPage(org.olat.selenium.page.user.UserToolsPage) UserVO(org.olat.user.restapi.UserVO) UserPreferencesPageFragment(org.olat.selenium.page.user.UserPreferencesPageFragment) UserRestClient(org.olat.test.rest.UserRestClient) RunAsClient(org.jboss.arquillian.container.test.api.RunAsClient) Test(org.junit.Test)

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