This repository has been archived by the owner on Nov 9, 2017. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'integration/master' into dashboard
- Loading branch information
Showing
12 changed files
with
409 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
91 changes: 91 additions & 0 deletions
91
functional-test/src/main/java/org/zanata/page/account/ChangePasswordPage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
/* | ||
* Copyright 2013, Red Hat, Inc. and individual contributors as indicated by the | ||
* @author tags. See the copyright.txt file in the distribution for a full | ||
* listing of individual contributors. | ||
* | ||
* This is free software; you can redistribute it and/or modify it under the | ||
* terms of the GNU Lesser General Public License as published by the Free | ||
* Software Foundation; either version 2.1 of the License, or (at your option) | ||
* any later version. | ||
* | ||
* This software is distributed in the hope that it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | ||
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more | ||
* details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with this software; if not, write to the Free Software Foundation, | ||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA, or see the FSF | ||
* site: http://www.fsf.org. | ||
*/ | ||
package org.zanata.page.account; | ||
|
||
|
||
import org.openqa.selenium.WebDriver; | ||
import org.openqa.selenium.WebElement; | ||
import org.openqa.selenium.support.FindBy; | ||
import org.zanata.page.BasePage; | ||
|
||
/** | ||
* @author Damian Jansen <a href="mailto:djansen@redhat.com">djansen@redhat.com</a> | ||
*/ | ||
public class ChangePasswordPage extends BasePage | ||
{ | ||
|
||
@FindBy(id = "passwordChangeForm:passwordOldField:passwordOld") | ||
private WebElement oldPasswordField; | ||
|
||
@FindBy(id = "passwordChangeForm:passwordNewField:passwordNew") | ||
private WebElement newPasswordField; | ||
|
||
@FindBy(id = "passwordChangeForm:passwordConfirmField:passwordConfirm") | ||
private WebElement confirmPasswordField; | ||
|
||
@FindBy(id = "passwordChangeForm:changePasswordButton") | ||
private WebElement changePasswordButton; | ||
|
||
@FindBy(id = "passwordChangeForm:cancelChangePasswordButton") | ||
private WebElement cancelChangePasswordButton; | ||
|
||
public ChangePasswordPage(WebDriver driver) | ||
{ | ||
super(driver); | ||
} | ||
|
||
public ChangePasswordPage enterOldPassword(String password) | ||
{ | ||
oldPasswordField.sendKeys(password); | ||
return new ChangePasswordPage(getDriver()); | ||
} | ||
|
||
public ChangePasswordPage enterNewPassword(String password) | ||
{ | ||
newPasswordField.sendKeys(password); | ||
return new ChangePasswordPage(getDriver()); | ||
} | ||
|
||
public ChangePasswordPage enterConfirmNewPassword(String password) | ||
{ | ||
confirmPasswordField.sendKeys(password); | ||
return new ChangePasswordPage(getDriver()); | ||
} | ||
|
||
public MyAccountPage changePassword() | ||
{ | ||
changePasswordButton.click(); | ||
return new MyAccountPage(getDriver()); | ||
} | ||
|
||
public MyAccountPage cancelChangePassword() | ||
{ | ||
cancelChangePasswordButton.click(); | ||
return new MyAccountPage(getDriver()); | ||
} | ||
|
||
public ChangePasswordPage changePasswordExpectingFailure() | ||
{ | ||
changePasswordButton.click(); | ||
return new ChangePasswordPage(getDriver()); | ||
} | ||
|
||
} |
51 changes: 51 additions & 0 deletions
51
functional-test/src/main/java/org/zanata/page/account/MyAccountPage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* | ||
* Copyright 2013, Red Hat, Inc. and individual contributors as indicated by the | ||
* @author tags. See the copyright.txt file in the distribution for a full | ||
* listing of individual contributors. | ||
* | ||
* This is free software; you can redistribute it and/or modify it under the | ||
* terms of the GNU Lesser General Public License as published by the Free | ||
* Software Foundation; either version 2.1 of the License, or (at your option) | ||
* any later version. | ||
* | ||
* This software is distributed in the hope that it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | ||
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more | ||
* details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with this software; if not, write to the Free Software Foundation, | ||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA, or see the FSF | ||
* site: http://www.fsf.org. | ||
*/ | ||
package org.zanata.page.account; | ||
|
||
|
||
import org.openqa.selenium.WebDriver; | ||
import org.openqa.selenium.WebElement; | ||
import org.openqa.selenium.support.FindBy; | ||
import org.zanata.page.BasePage; | ||
|
||
/** | ||
* @author Damian Jansen <a href="mailto:djansen@redhat.com">djansen@redhat.com</a> | ||
*/ | ||
public class MyAccountPage extends BasePage | ||
{ | ||
|
||
@FindBy(linkText = "Edit Profile") | ||
private WebElement editProfileButton; | ||
|
||
@FindBy(linkText = "Change Password") | ||
private WebElement changePasswordButton; | ||
|
||
public MyAccountPage(WebDriver driver) | ||
{ | ||
super(driver); | ||
} | ||
|
||
public ChangePasswordPage goToChangePassword() | ||
{ | ||
changePasswordButton.click(); | ||
return new ChangePasswordPage(getDriver()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
149 changes: 149 additions & 0 deletions
149
functional-test/src/test/java/org/zanata/feature/account/ChangePasswordTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,149 @@ | ||
/* | ||
* Copyright 2013, Red Hat, Inc. and individual contributors as indicated by the | ||
* @author tags. See the copyright.txt file in the distribution for a full | ||
* listing of individual contributors. | ||
* | ||
* This is free software; you can redistribute it and/or modify it under the | ||
* terms of the GNU Lesser General Public License as published by the Free | ||
* Software Foundation; either version 2.1 of the License, or (at your option) | ||
* any later version. | ||
* | ||
* This software is distributed in the hope that it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | ||
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more | ||
* details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with this software; if not, write to the Free Software Foundation, | ||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA, or see the FSF | ||
* site: http://www.fsf.org. | ||
*/ | ||
package org.zanata.feature.account; | ||
|
||
import org.hamcrest.Matchers; | ||
import org.junit.Rule; | ||
import org.junit.Test; | ||
import org.junit.experimental.categories.Category; | ||
import org.zanata.feature.BasicAcceptanceTest; | ||
import org.zanata.feature.DetailedTest; | ||
import org.zanata.page.account.ChangePasswordPage; | ||
import org.zanata.page.account.MyAccountPage; | ||
import org.zanata.page.utility.HomePage; | ||
import org.zanata.util.ResetDatabaseRule; | ||
import org.zanata.workflow.LoginWorkFlow; | ||
|
||
import static org.hamcrest.MatcherAssert.assertThat; | ||
|
||
/** | ||
* @author Damian Jansen <a href="mailto:djansen@redhat.com">djansen@redhat.com</a> | ||
*/ | ||
@Category(DetailedTest.class) | ||
public class ChangePasswordTest | ||
{ | ||
@Rule | ||
public ResetDatabaseRule resetDatabaseRule = new ResetDatabaseRule(); | ||
|
||
@Test | ||
@Category(BasicAcceptanceTest.class) | ||
public void changePasswordSuccessful() | ||
{ | ||
MyAccountPage myAccountPage = new LoginWorkFlow().signIn("translator", "translator") | ||
.goToMyProfile() | ||
.goToChangePassword() | ||
.enterOldPassword("translator") | ||
.enterNewPassword("newpassword") | ||
.enterConfirmNewPassword("newpassword") | ||
.changePassword(); | ||
|
||
assertThat("Confirmation message is displayed", myAccountPage.getNotificationMessage(), | ||
Matchers.equalTo("Your password has been successfully changed.")); | ||
|
||
HomePage homePage = myAccountPage.signOut(); | ||
assertThat("User is logged out", !homePage.hasLoggedIn()); | ||
homePage = new LoginWorkFlow().signIn("translator", "newpassword"); | ||
assertThat("User has logged in with the new password", homePage.hasLoggedIn()); | ||
} | ||
|
||
@Test | ||
public void changePasswordCurrentPasswordFailure() | ||
{ | ||
String incorrectPassword = "Old password is incorrect, please check and try again."; | ||
ChangePasswordPage changePasswordPage = new LoginWorkFlow().signIn("translator", "translator") | ||
.goToMyProfile() | ||
.goToChangePassword() | ||
.enterOldPassword("nottherightpassword") | ||
.enterNewPassword("somenewpassword") | ||
.enterConfirmNewPassword("somenewpassword") | ||
.changePasswordExpectingFailure(); | ||
|
||
assertThat("Incorrect password message displayed", changePasswordPage.getErrors(), | ||
Matchers.contains(incorrectPassword)); | ||
} | ||
|
||
@Test | ||
public void changePasswordConfirmationMismatch() | ||
{ | ||
String incorrectPassword = "Passwords do not match"; | ||
ChangePasswordPage changePasswordPage = new LoginWorkFlow().signIn("translator", "translator") | ||
.goToMyProfile() | ||
.goToChangePassword() | ||
.enterOldPassword("translator") | ||
.enterNewPassword("somenewpassword") | ||
.enterConfirmNewPassword("differentpassword") | ||
.changePasswordExpectingFailure(); | ||
|
||
assertThat("Incorrect password message displayed", changePasswordPage.getErrors(), | ||
Matchers.contains(incorrectPassword)); | ||
} | ||
|
||
@Test | ||
public void changePasswordCancel() | ||
{ | ||
MyAccountPage myAccountPage = new LoginWorkFlow().signIn("translator", "translator") | ||
.goToMyProfile() | ||
.goToChangePassword() | ||
.enterOldPassword("translator") | ||
.enterNewPassword("notnewpassword") | ||
.enterConfirmNewPassword("notnewpassword") | ||
.cancelChangePassword(); | ||
|
||
HomePage homePage = myAccountPage.signOut(); | ||
assertThat("User is logged out", !homePage.hasLoggedIn()); | ||
homePage = new LoginWorkFlow().signIn("translator", "translator"); | ||
assertThat("User has logged in with the original password", homePage.hasLoggedIn()); | ||
} | ||
|
||
@Test | ||
public void changePasswordRequiredFieldsAreNotEmpty() | ||
{ | ||
String emptyPassword = "value is required"; | ||
ChangePasswordPage changePasswordPage = new LoginWorkFlow().signIn("translator", "translator") | ||
.goToMyProfile() | ||
.goToChangePassword() | ||
.changePasswordExpectingFailure(); | ||
|
||
assertThat("Incorrect password message displayed", changePasswordPage.getErrors(), | ||
Matchers.contains(emptyPassword, emptyPassword, emptyPassword)); | ||
} | ||
|
||
@Test | ||
public void changePasswordAreOfRequiredLength() | ||
{ | ||
String passwordSizeError = "size must be between 6 and 20"; | ||
String tooShort = "test5"; | ||
String tooLong = "t12345678901234567890"; | ||
ChangePasswordPage changePasswordPage = new LoginWorkFlow().signIn("translator", "translator") | ||
.goToMyProfile() | ||
.goToChangePassword() | ||
.enterNewPassword("test5") | ||
.enterConfirmNewPassword(tooShort); | ||
|
||
assertThat("Incorrect password message displayed", changePasswordPage.waitForErrors(), | ||
Matchers.hasItem(passwordSizeError)); | ||
|
||
changePasswordPage = changePasswordPage.enterNewPassword(tooLong).enterConfirmNewPassword(tooLong); | ||
|
||
assertThat("Incorrect password message displayed", changePasswordPage.waitForErrors(), | ||
Matchers.hasItem(passwordSizeError)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.