use of com.faforever.server.security.FafUserDetails 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));
}
use of com.faforever.server.security.FafUserDetails 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));
}
use of com.faforever.server.security.FafUserDetails 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);
}
use of com.faforever.server.security.FafUserDetails 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);
}
use of com.faforever.server.security.FafUserDetails in project faf-java-server by FAForever.
the class GameServiceActivatorsTest method setUp.
@Before
public void setUp() throws Exception {
clientConnection = new ClientConnection("1", Protocol.V1_LEGACY_UTF_16, mock(InetAddress.class));
player = new Player();
User user = (User) new User().setPlayer(player).setPassword("password").setLogin("JUnit");
clientConnection.setAuthentication(new TestingAuthenticationToken(new FafUserDetails(user), null));
instance = new GameServiceActivators(gameService);
}
Aggregations