Search in sources :

Example 6 with User

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

the class SocialServiceTest method onAuthenticationSuccessNullRelations.

@Test
public void onAuthenticationSuccessNullRelations() throws Exception {
    User user = (User) new User().setPlayer(new Player().setSocialRelations(null)).setPassword("pw").setLogin("junit");
    FafUserDetails userDetails = new FafUserDetails(user);
    instance.onPlayerOnlineEvent(new PlayerOnlineEvent(this, userDetails.getPlayer()));
    verify(clientService, never()).sendSocialRelations(any(), any());
}
Also used : Player(com.faforever.server.entity.Player) User(com.faforever.server.entity.User) FafUserDetails(com.faforever.server.security.FafUserDetails) PlayerOnlineEvent(com.faforever.server.player.PlayerOnlineEvent) Test(org.junit.Test)

Example 7 with User

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

the class GameServiceTest method restoreGameSessionOpenGame.

@Test
public void restoreGameSessionOpenGame() throws Exception {
    Game game = hostGame(player1);
    assertThat(player2.getCurrentGame(), is(nullValue()));
    instance.joinGame(game.getId(), game.getPassword(), player2);
    assertThat(player2.getCurrentGame(), is(game));
    assertThat(player2.getGameState(), is(PlayerGameState.INITIALIZING));
    instance.updatePlayerGameState(PlayerGameState.LOBBY, player2);
    instance.updatePlayerGameState(PlayerGameState.LAUNCHING, player2);
    assertThat(player2.getGameState(), is(PlayerGameState.LAUNCHING));
    ClientConnection clientConnection = new ClientConnection("1", Protocol.V1_LEGACY_UTF_16, mock(InetAddress.class));
    clientConnection.setAuthentication(new TestingAuthenticationToken(new FafUserDetails((User) new User().setPlayer(player2).setPassword("pw").setLogin("JUnit")), null));
    player2.setClientConnection(clientConnection);
    instance.removePlayer(player2);
    assertThat(player2.getCurrentGame(), is(nullValue()));
    assertThat(player2.getGameState(), is(PlayerGameState.NONE));
    instance.restoreGameSession(player2, game.getId());
    assertThat(player2.getCurrentGame(), is(game));
    assertThat(player2.getGameState(), is(PlayerGameState.LOBBY));
}
Also used : Game(com.faforever.server.entity.Game) User(com.faforever.server.entity.User) ClientConnection(com.faforever.server.client.ClientConnection) FafUserDetails(com.faforever.server.security.FafUserDetails) TestingAuthenticationToken(org.springframework.security.authentication.TestingAuthenticationToken) InetAddress(java.net.InetAddress) Test(org.junit.Test)

Example 8 with User

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

the class GameServiceTest method restoreGameSessionPlayingGame.

@Test
public void restoreGameSessionPlayingGame() throws Exception {
    Game game = hostGame(player1);
    instance.joinGame(game.getId(), game.getPassword(), player2);
    assertThat(player2.getCurrentGame(), is(game));
    instance.updatePlayerGameState(PlayerGameState.LOBBY, player2);
    instance.updatePlayerGameState(PlayerGameState.LAUNCHING, player2);
    assertThat(player2.getGameState(), is(PlayerGameState.LAUNCHING));
    instance.updatePlayerGameState(PlayerGameState.LAUNCHING, player1);
    ClientConnection clientConnection = new ClientConnection("1", Protocol.V1_LEGACY_UTF_16, mock(InetAddress.class));
    clientConnection.setAuthentication(new TestingAuthenticationToken(new FafUserDetails((User) new User().setPlayer(player2).setPassword("pw").setLogin("JUnit")), null));
    player2.setClientConnection(clientConnection);
    instance.removePlayer(player2);
    assertThat(player2.getCurrentGame(), is(nullValue()));
    assertThat(player2.getGameState(), is(PlayerGameState.NONE));
    instance.restoreGameSession(player2, game.getId());
    assertThat(player2.getCurrentGame(), is(game));
    assertThat(player2.getGameState(), is(PlayerGameState.LAUNCHING));
}
Also used : Game(com.faforever.server.entity.Game) User(com.faforever.server.entity.User) ClientConnection(com.faforever.server.client.ClientConnection) FafUserDetails(com.faforever.server.security.FafUserDetails) TestingAuthenticationToken(org.springframework.security.authentication.TestingAuthenticationToken) InetAddress(java.net.InetAddress) Test(org.junit.Test)

Example 9 with User

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

the class LegacyServicesActivatorsTest method createAuthentication.

private void createAuthentication(Player player) {
    FafUserDetails fafUserDetails = new FafUserDetails((User) new User().setPlayer(player).setPassword("password").setLogin("JUnit"));
    TestingAuthenticationToken token = new TestingAuthenticationToken(fafUserDetails, "password");
    when(authenticationManager.authenticate(any())).thenReturn(token);
}
Also used : User(com.faforever.server.entity.User) FafUserDetails(com.faforever.server.security.FafUserDetails) TestingAuthenticationToken(org.springframework.security.authentication.TestingAuthenticationToken)

Example 10 with User

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

the class AvatarServiceActivatorTest 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 AvatarServiceActivator(avatarService);
}
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)

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