Search in sources :

Example 16 with User

use of com.faforever.server.entity.User in project faf-java-server by FAForever.

the class MatchMakerServiceActivatorTest method setUp.

@Before
public void setUp() throws Exception {
    player = new Player();
    authentication = new TestingAuthenticationToken(new FafUserDetails((User) new User().setPlayer(player).setPassword("pw").setLogin("JUnit")), null);
    instance = new MatchMakerServiceActivator(matchmakerService, matchMakerMapper);
}
Also used : Player(com.faforever.server.entity.Player) User(com.faforever.server.entity.User) FafUserDetails(com.faforever.server.security.FafUserDetails) TestingAuthenticationToken(org.springframework.security.authentication.TestingAuthenticationToken) Before(org.junit.Before)

Example 17 with User

use of com.faforever.server.entity.User in project faf-java-server by FAForever.

the class ChatServiceTest method testJoinChannels.

@SuppressWarnings("unchecked")
private void testJoinChannels(Group group, String... expectedChannels) {
    User user = (User) new User().setPassword("pw").setGroupAssociation(group == null ? null : new GroupAssociation().setGroup(group)).setLogin("junit");
    Player player = new Player().setUser(user).setClanMemberships(Collections.singletonList(new ClanMembership().setClan(new Clan().setTag("junit"))));
    instance.onPlayerOnlineEvent(new PlayerOnlineEvent(this, player));
    ArgumentCaptor<Set<String>> captor = ArgumentCaptor.forClass((Class) Set.class);
    verify(clientService).sendChatChannels(captor.capture(), any());
    Set<String> channels = captor.getValue();
    assertThat(channels, containsInAnyOrder(expectedChannels));
}
Also used : Player(com.faforever.server.entity.Player) User(com.faforever.server.entity.User) GroupAssociation(com.faforever.server.entity.GroupAssociation) Set(java.util.Set) Clan(com.faforever.server.entity.Clan) ClanMembership(com.faforever.server.entity.ClanMembership) PlayerOnlineEvent(com.faforever.server.player.PlayerOnlineEvent)

Example 18 with User

use of com.faforever.server.entity.User in project faf-java-server by FAForever.

the class ClientConnectionServiceTest method disconnectClient.

@Test
public void disconnectClient() throws Exception {
    ClientConnection clientConnection12 = new ClientConnection("1", Protocol.V1_LEGACY_UTF_16, mock(InetAddress.class));
    Player player12 = new Player().setClientConnection(clientConnection12);
    when(playerService.getOnlinePlayer(12)).thenReturn(Optional.of(player12));
    instance.disconnectClient(new TestingAuthenticationToken(new User(), null), 12);
    ArgumentCaptor<CloseConnectionEvent> captor = ArgumentCaptor.forClass(CloseConnectionEvent.class);
    verify(eventPublisher).publishEvent(captor.capture());
    CloseConnectionEvent value = captor.getValue();
    assertThat(value.getClientConnection(), is(clientConnection12));
}
Also used : Player(com.faforever.server.entity.Player) User(com.faforever.server.entity.User) TestingAuthenticationToken(org.springframework.security.authentication.TestingAuthenticationToken) InetAddress(java.net.InetAddress) Test(org.junit.Test)

Example 19 with User

use of com.faforever.server.entity.User in project faf-java-server by FAForever.

the class FafUserDetailsTest method userWithoutBanDetailsIsNonLocked.

@Test
public void userWithoutBanDetailsIsNonLocked() throws Exception {
    User user = (User) new User().setPassword(TEST_PASSWORD).setBanDetails(null).setLogin(TEST_USERNAME);
    FafUserDetails fafUserDetails = new FafUserDetails(user);
    assertThat(fafUserDetails.isAccountNonLocked(), is(true));
}
Also used : User(com.faforever.server.entity.User) Test(org.junit.Test)

Example 20 with User

use of com.faforever.server.entity.User in project faf-java-server by FAForever.

the class FafUserDetailsTest method userWithExpiredBanDetailsIsNonLocked.

@Test
public void userWithExpiredBanDetailsIsNonLocked() throws Exception {
    User user = (User) new User().setPassword(TEST_PASSWORD).setBanDetails(new BanDetails().setExpiresAt(Timestamp.from(Instant.now().minusSeconds(1)))).setLogin(TEST_USERNAME);
    FafUserDetails fafUserDetails = new FafUserDetails(user);
    assertThat(fafUserDetails.isAccountNonLocked(), is(true));
}
Also used : User(com.faforever.server.entity.User) BanDetails(com.faforever.server.entity.BanDetails) Test(org.junit.Test)

Aggregations

User (com.faforever.server.entity.User)21 FafUserDetails (com.faforever.server.security.FafUserDetails)12 Test (org.junit.Test)12 TestingAuthenticationToken (org.springframework.security.authentication.TestingAuthenticationToken)10 Player (com.faforever.server.entity.Player)9 ClientConnection (com.faforever.server.client.ClientConnection)6 PlayerOnlineEvent (com.faforever.server.player.PlayerOnlineEvent)5 Before (org.junit.Before)5 GroupAssociation (com.faforever.server.entity.GroupAssociation)4 InetAddress (java.net.InetAddress)4 BanDetails (com.faforever.server.entity.BanDetails)2 Game (com.faforever.server.entity.Game)2 Set (java.util.Set)2 ClientService (com.faforever.server.client.ClientService)1 GameResponses (com.faforever.server.client.GameResponses)1 ServerProperties (com.faforever.server.config.ServerProperties)1 Chat (com.faforever.server.config.ServerProperties.Chat)1 Clan (com.faforever.server.entity.Clan)1 ClanMembership (com.faforever.server.entity.ClanMembership)1 SocialRelation (com.faforever.server.entity.SocialRelation)1