Search in sources :

Example 1 with ClientConnection

use of com.faforever.server.client.ClientConnection 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);
}
Also used : User(com.faforever.server.entity.User) ClientConnection(com.faforever.server.client.ClientConnection) FafUserDetails(com.faforever.server.security.FafUserDetails)

Example 2 with ClientConnection

use of com.faforever.server.client.ClientConnection 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);
}
Also used : Player(com.faforever.server.entity.Player) User(com.faforever.server.entity.User) ClientConnection(com.faforever.server.client.ClientConnection) FafUserDetails(com.faforever.server.security.FafUserDetails) TestingAuthenticationToken(org.springframework.security.authentication.TestingAuthenticationToken) Before(org.junit.Before)

Example 3 with ClientConnection

use of com.faforever.server.client.ClientConnection 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 4 with ClientConnection

use of com.faforever.server.client.ClientConnection 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 5 with ClientConnection

use of com.faforever.server.client.ClientConnection in project faf-java-server by FAForever.

the class LegacyServicesActivatorsTest method setUp.

@Before
public void setUp() throws Exception {
    clientConnection = new ClientConnection("1", Protocol.V1_LEGACY_UTF_16, mock(InetAddress.class));
    player = new Player();
    player.setClientConnection(clientConnection);
    when(geoIpService.lookupCountryCode(any())).thenReturn(Optional.empty());
    instance = new LegacyServicesActivators(authenticationManager, clientService, uniqueIdService, geoIpService, playerService, chatService, counterService);
}
Also used : Player(com.faforever.server.entity.Player) ClientConnection(com.faforever.server.client.ClientConnection) Before(org.junit.Before)

Aggregations

ClientConnection (com.faforever.server.client.ClientConnection)9 User (com.faforever.server.entity.User)6 FafUserDetails (com.faforever.server.security.FafUserDetails)6 TestingAuthenticationToken (org.springframework.security.authentication.TestingAuthenticationToken)5 Player (com.faforever.server.entity.Player)4 InetAddress (java.net.InetAddress)4 Before (org.junit.Before)4 Test (org.junit.Test)3 Game (com.faforever.server.entity.Game)2 CloseConnectionEvent (com.faforever.server.client.CloseConnectionEvent)1 SimpMessageHeaderAccessor (org.springframework.messaging.simp.SimpMessageHeaderAccessor)1