Skip to content

Commit

Permalink
SONAR-6468 Remove password_confirmation parameter (validation is dele…
Browse files Browse the repository at this point in the history
…gated to UI)
  • Loading branch information
jblievremont committed May 7, 2015
1 parent 7a26b1d commit 223cca4
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 14 deletions.
Expand Up @@ -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;

Expand All @@ -57,21 +56,17 @@ public void define(WebService.NewController controller) {
.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
public void handle(Request request, Response response) throws Exception {
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();
Expand Down
Expand Up @@ -115,7 +115,6 @@ public void fail_on_unknown_user() throws Exception {
tester.newPostRequest("api/users", "change_password")
.setParam("login", "polop")
.setParam("password", "polop")
.setParam("password_confirmation", "polop")
.execute();
}

Expand All @@ -128,7 +127,6 @@ public void update_password() throws Exception {
tester.newPostRequest("api/users", "change_password")
.setParam("login", "john")
.setParam("password", "Valar Morghulis")
.setParam("password_confirmation", "Valar Morghulis")
.execute()
.assertNoContent();

Expand Down
Expand Up @@ -43,8 +43,7 @@ public void setUp() throws Exception {
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");
}

Expand All @@ -53,7 +52,7 @@ public void define_controller() throws Exception {
assertThat(controller).isNotNull();
assertThat(controller.description()).isNotEmpty();
assertThat(controller.since()).isEqualTo("3.6");
assertThat(controller.actions()).hasSize(7);
assertThat(controller.actions()).hasSize(6);
}

@Test
Expand Down Expand Up @@ -87,7 +86,7 @@ public void define_change_password_action() throws Exception {
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
Expand Down

0 comments on commit 223cca4

Please sign in to comment.