use of org.olat.test.rest.UserRestClient 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());
}
use of org.olat.test.rest.UserRestClient 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"));
}
use of org.olat.test.rest.UserRestClient 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());
}
use of org.olat.test.rest.UserRestClient 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();
}
use of org.olat.test.rest.UserRestClient in project OpenOLAT by OpenOLAT.
the class UserTest method importExistingUsers.
/**
* Import 1 new user and 1 existing, change the password and the last name
* of the existing user.
*
* @param loginPage
* @param existingUserBrowser
* @throws IOException
* @throws URISyntaxException
*/
@Test
@RunAsClient
public void importExistingUsers(@InitialPage LoginPage loginPage, @Drone @User WebDriver existingUserBrowser, @Drone @Student WebDriver newUserBrowser) throws IOException, URISyntaxException {
UserVO user1 = new UserRestClient(deploymentUrl).createRandomUser("tsukune");
// login
loginPage.assertOnLoginPage().loginAs("administrator", "openolat").resume();
UserAdminPage userAdminPage = navBar.openUserManagement().openImportUsers();
// start import wizard
ImportUserPage importWizard = userAdminPage.startImport();
String uuid = UUID.randomUUID().toString();
String username1 = "moka-" + uuid;
StringBuilder csv = new StringBuilder();
UserVO newUser = importWizard.append(username1, "rosario02", "Moka", "Akashiya", csv);
user1 = importWizard.append(user1, "Aono", "openolat2", csv);
importWizard.fill(csv.toString()).nextData().assertGreen(1).assertWarn(1).updatePasswords().updateUsers().nextOverview().nextGroups().finish();
OOGraphene.waitAndCloseBlueMessageWindow(browser);
// existing user log in with its new password and check if its name was updated
LoginPage userLoginPage = LoginPage.getLoginPage(existingUserBrowser, deploymentUrl);
// tools
userLoginPage.loginAs(user1.getLogin(), "openolat2").resume().assertLoggedInByLastName("Aono");
// new user log in
LoginPage newLoginPage = LoginPage.getLoginPage(newUserBrowser, deploymentUrl);
// tools
newLoginPage.loginAs(newUser.getLogin(), "rosario02").resume().assertLoggedInByLastName("Akashiya");
}
Aggregations