aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean-Baptiste Lievremont <jean-baptiste.lievremont@sonarsource.com>2015-05-06 11:40:41 +0200
committerJean-Baptiste Lievremont <jean-baptiste.lievremont@sonarsource.com>2015-05-07 14:41:36 +0200
commit223cca42ca4f24a6d5790077eb0e638d421276f4 (patch)
tree2aefb402fa44e5c0ba856f33a8e63cab4c0fa2c6
parent7a26b1d96d75751ffebf9d1ea8bbfc3f12d72ca2 (diff)
downloadsonarqube-223cca42ca4f24a6d5790077eb0e638d421276f4.tar.gz
sonarqube-223cca42ca4f24a6d5790077eb0e638d421276f4.zip
SONAR-6468 Remove password_confirmation parameter (validation is delegated to UI)
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/user/ws/ChangePasswordAction.java11
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/user/ws/ChangePasswordActionTest.java2
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/user/ws/UsersWsTest.java7
3 files changed, 6 insertions, 14 deletions
diff --git a/server/sonar-server/src/main/java/org/sonar/server/user/ws/ChangePasswordAction.java b/server/sonar-server/src/main/java/org/sonar/server/user/ws/ChangePasswordAction.java
index 14cbf2edd0a..c813976918a 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/user/ws/ChangePasswordAction.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/user/ws/ChangePasswordAction.java
@@ -32,7 +32,6 @@ public class ChangePasswordAction implements BaseUsersWsAction {
private static final String PARAM_LOGIN = "login";
private static final String PARAM_PASSWORD = "password";
- private static final String PARAM_PASSWORD_CONFIRMATION = "password_confirmation";
private final UserUpdater userUpdater;
@@ -57,11 +56,6 @@ public class ChangePasswordAction implements BaseUsersWsAction {
.setDescription("New password")
.setRequired(true)
.setExampleValue("mypassword");
-
- action.createParam(PARAM_PASSWORD_CONFIRMATION)
- .setDescription("Must be the same value as \"password\"")
- .setRequired(true)
- .setExampleValue("mypassword");
}
@Override
@@ -69,9 +63,10 @@ public class ChangePasswordAction implements BaseUsersWsAction {
UserSession.get().checkLoggedIn().checkGlobalPermission(GlobalPermissions.SYSTEM_ADMIN);
String login = request.mandatoryParam(PARAM_LOGIN);
+ String password = request.mandatoryParam(PARAM_PASSWORD);
UpdateUser updateUser = UpdateUser.create(login)
- .setPassword(request.mandatoryParam(PARAM_PASSWORD))
- .setPasswordConfirmation(request.mandatoryParam(PARAM_PASSWORD_CONFIRMATION));
+ .setPassword(password)
+ .setPasswordConfirmation(password);
userUpdater.update(updateUser);
response.noContent();
diff --git a/server/sonar-server/src/test/java/org/sonar/server/user/ws/ChangePasswordActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/user/ws/ChangePasswordActionTest.java
index 037783c1493..896c251ad4b 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/user/ws/ChangePasswordActionTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/user/ws/ChangePasswordActionTest.java
@@ -115,7 +115,6 @@ public class ChangePasswordActionTest {
tester.newPostRequest("api/users", "change_password")
.setParam("login", "polop")
.setParam("password", "polop")
- .setParam("password_confirmation", "polop")
.execute();
}
@@ -128,7 +127,6 @@ public class ChangePasswordActionTest {
tester.newPostRequest("api/users", "change_password")
.setParam("login", "john")
.setParam("password", "Valar Morghulis")
- .setParam("password_confirmation", "Valar Morghulis")
.execute()
.assertNoContent();
diff --git a/server/sonar-server/src/test/java/org/sonar/server/user/ws/UsersWsTest.java b/server/sonar-server/src/test/java/org/sonar/server/user/ws/UsersWsTest.java
index 73d65418c7e..952d26d1cbc 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/user/ws/UsersWsTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/user/ws/UsersWsTest.java
@@ -43,8 +43,7 @@ public class UsersWsTest {
new UpdateAction(mock(UserIndex.class), mock(UserUpdater.class)),
new CurrentUserAction(),
new DeactivateAction(mock(UserIndex.class), mock(UserUpdater.class)),
- new ChangePasswordAction(mock(UserUpdater.class)),
- new CurrentUserAction()));
+ new ChangePasswordAction(mock(UserUpdater.class))));
controller = tester.controller("api/users");
}
@@ -53,7 +52,7 @@ public class UsersWsTest {
assertThat(controller).isNotNull();
assertThat(controller.description()).isNotEmpty();
assertThat(controller.since()).isEqualTo("3.6");
- assertThat(controller.actions()).hasSize(7);
+ assertThat(controller.actions()).hasSize(6);
}
@Test
@@ -87,7 +86,7 @@ public class UsersWsTest {
WebService.Action action = controller.action("change_password");
assertThat(action).isNotNull();
assertThat(action.isPost()).isTrue();
- assertThat(action.params()).hasSize(3);
+ assertThat(action.params()).hasSize(2);
}
@Test