use of org.haiku.haikudepotserver.api1.model.user.ChangePasswordRequest in project haikudepotserver by haiku.
the class UserApiIT method testChangePassword.
@Test
public void testChangePassword() {
Captcha captcha = captchaService.generate();
ObjectContext context = serverRuntime.newContext();
User user = integrationTestSupportService.createBasicUser(context, "testuser", "U7vqpsu6BB");
setAuthenticatedUser("testuser");
// check that the password is correctly configured.
Assertions.assertThat(userAuthenticationService.authenticateByNicknameAndPassword("testuser", "U7vqpsu6BB").get()).isEqualTo(user.getObjectId());
// now change it.
ChangePasswordRequest request = new ChangePasswordRequest();
request.nickname = "testuser";
request.captchaResponse = captcha.getResponse();
request.captchaToken = captcha.getToken();
request.newPasswordClear = "8R3nlp11gX";
request.oldPasswordClear = "U7vqpsu6BB";
// ------------------------------------
userApi.changePassword(request);
// ------------------------------------
// now check that the old authentication no longer works and the new one does work
Assertions.assertThat(userAuthenticationService.authenticateByNicknameAndPassword("testuser", "U7vqpsu6BB").isPresent()).isFalse();
Assertions.assertThat(userAuthenticationService.authenticateByNicknameAndPassword("testuser", "8R3nlp11gX").get()).isEqualTo(user.getObjectId());
}
Aggregations