use of com.faforever.api.data.domain.User in project faf-java-api by FAForever.
the class UserServiceTest method changePasswordInvalidPassword.
@Test
public void changePasswordInvalidPassword() {
expectedException.expect(ApiExceptionWithCode.apiExceptionWithCode(ErrorCode.PASSWORD_CHANGE_FAILED_WRONG_PASSWORD));
User user = createUser(TEST_USERID, TEST_USERNAME, "invalid password", TEST_CURRENT_EMAIL);
instance.changePassword(TEST_CURRENT_PASSWORD, TEST_NEW_PASSWORD, user);
}
use of com.faforever.api.data.domain.User in project faf-java-api by FAForever.
the class UserServiceTest method setUp.
@Before
public void setUp() {
properties = new FafApiProperties();
properties.getJwt().setSecret(TEST_SECRET);
properties.getLinkToSteam().setSteamRedirectUrlFormat("%s");
instance = new UserService(emailService, playerRepository, userRepository, nameRecordRepository, properties, anopeUserRepository, fafTokenService, steamService, Optional.of(mauticService), globalRatingRepository, ladder1v1RatingRepository);
when(fafTokenService.createToken(any(), any(), any())).thenReturn(TOKEN_VALUE);
when(userRepository.save(any(User.class))).then(invocation -> ((User) invocation.getArgument(0)).setId(TEST_USERID));
when(mauticService.createOrUpdateContact(any(), any(), any(), any(), any())).thenReturn(CompletableFuture.completedFuture(null));
}
use of com.faforever.api.data.domain.User in project faf-java-api by FAForever.
the class UserServiceTest method changeLoginWithUsernameInUse.
@Test
public void changeLoginWithUsernameInUse() {
expectedException.expect(ApiExceptionWithCode.apiExceptionWithCode(ErrorCode.USERNAME_TAKEN));
User user = createUser(TEST_USERID, TEST_USERNAME, TEST_CURRENT_PASSWORD, TEST_CURRENT_EMAIL);
when(userRepository.existsByLoginIgnoreCase(TEST_USERNAME_CHANGED)).thenReturn(true);
instance.changeLogin(TEST_USERNAME_CHANGED, user, "127.0.0.1");
}
use of com.faforever.api.data.domain.User in project faf-java-api by FAForever.
the class UserServiceTest method buildSteamLinkUrlAlreadLinked.
@Test
public void buildSteamLinkUrlAlreadLinked() {
expectedException.expect(ApiExceptionWithCode.apiExceptionWithCode(ErrorCode.STEAM_ID_UNCHANGEABLE));
User user = createUser(TEST_USERID, TEST_USERNAME, TEST_CURRENT_PASSWORD, TEST_CURRENT_EMAIL);
user.setSteamId(STEAM_ID);
instance.buildSteamLinkUrl(user, "http://example.com/callback");
}
use of com.faforever.api.data.domain.User in project faf-java-api by FAForever.
the class UserServiceTest method changeLogin.
@Test
public void changeLogin() {
User user = createUser(TEST_USERID, TEST_USERNAME, TEST_CURRENT_PASSWORD, TEST_CURRENT_EMAIL);
when(nameRecordRepository.getDaysSinceLastNewRecord(anyInt(), anyInt())).thenReturn(Optional.empty());
instance.changeLogin(TEST_USERNAME_CHANGED, user, "127.0.0.1");
ArgumentCaptor<User> captorUser = ArgumentCaptor.forClass(User.class);
verify(userRepository).save(captorUser.capture());
assertEquals(captorUser.getValue().getLogin(), TEST_USERNAME_CHANGED);
ArgumentCaptor<NameRecord> captorNameRecord = ArgumentCaptor.forClass(NameRecord.class);
verify(nameRecordRepository).save(captorNameRecord.capture());
assertEquals(captorNameRecord.getValue().getName(), TEST_USERNAME);
verify(mauticService).createOrUpdateContact(eq(TEST_NEW_EMAIL), eq(String.valueOf(TEST_USERID)), eq(TEST_USERNAME_CHANGED), eq("127.0.0.1"), any(OffsetDateTime.class));
}
Aggregations