use of com.faforever.server.entity.User in project faf-java-server by FAForever.
the class PlayerServiceTest method createFafUserDetails.
private FafUserDetails createFafUserDetails() {
User user = new User();
user.setPassword("pw");
user.setLogin(player.getLogin());
user.setCountry("CH");
user.setPlayer(player);
player.setClientConnection(new ClientConnection("1", Protocol.V1_LEGACY_UTF_16, mock(InetAddress.class)));
return new FafUserDetails(user);
}
use of com.faforever.server.entity.User in project faf-java-server by FAForever.
the class FafUserDetailsTest method userWithValidBanDetailsIsLocked.
@Test
public void userWithValidBanDetailsIsLocked() throws Exception {
User user = (User) new User().setPassword(TEST_PASSWORD).setBanDetails(new BanDetails().setExpiresAt(Timestamp.from(Instant.now().plus(1, ChronoUnit.HOURS)))).setLogin(TEST_USERNAME);
FafUserDetails fafUserDetails = new FafUserDetails(user);
assertThat(fafUserDetails.isAccountNonLocked(), is(false));
}
use of com.faforever.server.entity.User in project faf-java-server by FAForever.
the class FafUserDetailsTest method userWithGroup1IsAdmin.
@Test
public void userWithGroup1IsAdmin() throws Exception {
User user = (User) new User().setGroupAssociation(new GroupAssociation().setGroup(Group.ADMIN)).setPassword(TEST_PASSWORD).setLogin(TEST_USERNAME);
FafUserDetails fafUserDetails = new FafUserDetails(user);
assertThat(fafUserDetails.getAuthorities(), CoreMatchers.hasItems(new SimpleGrantedAuthority("ROLE_USER"), new SimpleGrantedAuthority("ROLE_ADMIN")));
}
use of com.faforever.server.entity.User in project faf-java-server by FAForever.
the class FafUserDetailsTest method userWithoutGroupIsNotAdmin.
@Test
public void userWithoutGroupIsNotAdmin() throws Exception {
User user = (User) new User().setGroupAssociation(null).setPassword(TEST_PASSWORD).setLogin(TEST_USERNAME);
FafUserDetails fafUserDetails = new FafUserDetails(user);
assertThat(fafUserDetails.getAuthorities(), hasSize(1));
assertThat(fafUserDetails.getAuthorities().iterator().next().getAuthority(), is("ROLE_USER"));
}
use of com.faforever.server.entity.User in project faf-java-server by FAForever.
the class SocialServiceActivatorsTest method setUp.
@Before
public void setUp() throws Exception {
player = (Player) new Player().setId(1);
clientConnection = new ClientConnection("1", Protocol.V1_LEGACY_UTF_16, mock(InetAddress.class));
clientConnection.setAuthentication(new TestingAuthenticationToken(new FafUserDetails((User) new User().setPlayer(player).setPassword("pw").setLogin("JUnit")), null));
instance = new SocialServiceActivators(socialService);
}
Aggregations