diff options
author | Stas Vilchik <vilchiks@gmail.com> | 2016-01-26 15:46:59 +0100 |
---|---|---|
committer | Stas Vilchik <vilchiks@gmail.com> | 2016-01-28 16:14:24 +0100 |
commit | f87501399cd3a6ad2970606521daa2867313bfff (patch) | |
tree | 7a13155db2c44eaa579c0ed5cd15f2dfc1cfcac2 /it | |
parent | de0b07fffd01cc2552c9a4a50ebbc994fb684400 (diff) | |
download | sonarqube-f87501399cd3a6ad2970606521daa2867313bfff.tar.gz sonarqube-f87501399cd3a6ad2970606521daa2867313bfff.zip |
SONAR-7231 Create new "Security" page in "My Space"
Diffstat (limited to 'it')
3 files changed, 145 insertions, 20 deletions
diff --git a/it/it-tests/src/test/java/it/Category1Suite.java b/it/it-tests/src/test/java/it/Category1Suite.java index 16333217c23..5153eb1c298 100644 --- a/it/it-tests/src/test/java/it/Category1Suite.java +++ b/it/it-tests/src/test/java/it/Category1Suite.java @@ -65,6 +65,7 @@ import it.settings.PropertySetsTest; import it.settings.SettingsTest; import it.settings.SettingsTestRestartingOrchestrator; import it.settings.SubCategoriesTest; +import it.user.MyAccountPageTest; import org.junit.ClassRule; import org.junit.runner.RunWith; import org.junit.runners.Suite; @@ -110,7 +111,8 @@ import static util.ItUtils.xooPlugin; TimeMachineTest.class, // action plan ActionPlanTest.class, - ActionPlanUiTest.class + ActionPlanUiTest.class, + MyAccountPageTest.class }) public class Category1Suite { diff --git a/it/it-tests/src/test/java/it/user/MyAccountPageTest.java b/it/it-tests/src/test/java/it/user/MyAccountPageTest.java index e3425497689..5188171ec23 100644 --- a/it/it-tests/src/test/java/it/user/MyAccountPageTest.java +++ b/it/it-tests/src/test/java/it/user/MyAccountPageTest.java @@ -22,26 +22,31 @@ package it.user; import com.sonar.orchestrator.Orchestrator; import com.sonar.orchestrator.selenium.Selenese; import it.Category1Suite; -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; -import org.sonar.wsclient.SonarClient; -import org.sonar.wsclient.user.UserParameters; +import org.junit.*; +import org.sonarqube.ws.client.PostRequest; +import org.sonarqube.ws.client.WsClient; import util.selenium.SeleneseTest; +import static util.ItUtils.newAdminWsClient; + public class MyAccountPageTest { @ClassRule public static Orchestrator orchestrator = Category1Suite.ORCHESTRATOR; + private static WsClient adminWsClient; @BeforeClass - public static void initUser() { + public static void setUp() { + adminWsClient = newAdminWsClient(orchestrator); + } + + @Before + public void initUser() { createUser("account-user", "User With Account", "user@example.com"); } - @AfterClass - public static void deleteTestUser() { + @After + public void deleteTestUser() { deactivateUser("account-user"); } @@ -53,19 +58,27 @@ public class MyAccountPageTest { new SeleneseTest(selenese).runOn(orchestrator); } + @Test + public void should_change_password() throws Exception { + Selenese selenese = Selenese.builder().setHtmlTestsInClasspath("should_change_password", + "/user/MyAccountPageTest/should_change_password.html" + ).build(); + new SeleneseTest(selenese).runOn(orchestrator); + } + private static void createUser(String login, String name, String email) { - SonarClient client = orchestrator.getServer().adminWsClient(); - UserParameters userCreationParameters = UserParameters.create() - .login(login) - .name(name) - .email(email) - .password("password") - .passwordConfirmation("password"); - client.userClient().create(userCreationParameters); + adminWsClient.wsConnector().call( + new PostRequest("api/users/create") + .setParam("login", login) + .setParam("name", name) + .setParam("email", email) + .setParam("password", "password")); } - private static void deactivateUser(String user) { - orchestrator.getServer().adminWsClient().userClient().deactivate(user); + private static void deactivateUser(String login) { + adminWsClient.wsConnector().call( + new PostRequest("api/users/deactivate") + .setParam("login", login)); } } diff --git a/it/it-tests/src/test/resources/user/MyAccountPageTest/should_change_password.html b/it/it-tests/src/test/resources/user/MyAccountPageTest/should_change_password.html new file mode 100644 index 00000000000..50da6be2ed7 --- /dev/null +++ b/it/it-tests/src/test/resources/user/MyAccountPageTest/should_change_password.html @@ -0,0 +1,110 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> +<head profile="http://selenium-ide.openqa.org/profiles/test-case"> + <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> + <link rel="selenium.base" href="http://localhost:49506"/> + <title>should_change_password</title> +</head> +<body> +<table cellpadding="1" cellspacing="1" border="1"> +<thead> +<tr> +<td rowspan="1" colspan="3">should_change_password</td> +</tr> +</thead> +<tbody> +<tr> + <td>open</td> + <td>/sonar/sessions/login</td> + <td></td> +</tr> +<tr> + <td>type</td> + <td>login</td> + <td>account-user</td> +</tr> +<tr> + <td>type</td> + <td>password</td> + <td>password</td> +</tr> +<tr> + <td>clickAndWait</td> + <td>commit</td> + <td></td> +</tr> +<tr> + <td>open</td> + <td>/sonar/account/security</td> + <td></td> +</tr> +<tr> + <td>waitForElementPresent</td> + <td>id=change-password</td> + <td></td> +</tr> +<tr> + <td>click</td> + <td>id=change-password</td> + <td></td> +</tr> +<tr> + <td>waitForElementPresent</td> + <td>id=old_password</td> + <td></td> +</tr> +<tr> + <td>type</td> + <td>id=old_password</td> + <td>password</td> +</tr> +<tr> + <td>type</td> + <td>id=password</td> + <td>new_password</td> +</tr> +<tr> + <td>type</td> + <td>id=password_confirmation</td> + <td>new_password</td> +</tr> +<tr> + <td>click</td> + <td>commit</td> + <td></td> +</tr> +<tr> + <td>open</td> + <td>/sonar/sessions/logout</td> + <td></td> +</tr> +<tr> + <td>open</td> + <td>/sonar/sessions/login</td> + <td></td> +</tr> +<tr> + <td>type</td> + <td>login</td> + <td>account-user</td> +</tr> +<tr> + <td>type</td> + <td>password</td> + <td>new_password</td> +</tr> +<tr> + <td>clickAndWait</td> + <td>commit</td> + <td></td> +</tr> +<tr> + <td>waitForText</td> + <td>id=global-navigation</td> + <td>*User With Account*</td> +</tr> +</tbody> +</table> +</body> +</html> |