use of org.haiku.haikudepotserver.api1.model.user.CreateUserResult in project haikudepotserver by haiku.
the class UserApiIT method testCreateUser.
@Test
public void testCreateUser() {
Captcha captcha = captchaService.generate();
CreateUserRequest request = new CreateUserRequest();
request.captchaToken = captcha.getToken();
request.captchaResponse = captcha.getResponse();
request.nickname = "testuser";
request.passwordClear = "Ue4nI92Rw";
request.naturalLanguageCode = "en";
request.userUsageConditionsCode = "UUC2021V01";
// ------------------------------------
CreateUserResult result = userApi.createUser(request);
// ------------------------------------
Assertions.assertThat(result).isNotNull();
ObjectContext context = serverRuntime.newContext();
Optional<User> userOptional = User.tryGetByNickname(context, "testuser");
Assertions.assertThat(userOptional.isPresent()).isTrue();
User user = userOptional.get();
Assertions.assertThat(user.getActive()).isTrue();
Assertions.assertThat(user.getIsRoot()).isFalse();
Assertions.assertThat(user.getNickname()).isEqualTo("testuser");
Assertions.assertThat(user.getNaturalLanguage().getCode()).isEqualTo("en");
Assertions.assertThat(user.getLastAuthenticationTimestamp()).isNull();
Assertions.assertThat(user.tryGetUserUsageConditionsAgreement().get().getUserUsageConditions().getCode()).isEqualTo("UUC2021V01");
Assertions.assertThat(userAuthenticationService.authenticateByNicknameAndPassword("testuser", "Ue4nI92Rw").get()).isEqualTo(userOptional.get().getObjectId());
}
Aggregations