Search in sources :

Example 1 with FafUserDetails

use of com.faforever.server.security.FafUserDetails in project faf-java-server by FAForever.

the class PlayerServiceTest method onClientDisconnectRemovesPlayerAndUnsetsGameAndRemovesGameIfLastPlayer.

@Test
public void onClientDisconnectRemovesPlayerAndUnsetsGameAndRemovesGameIfLastPlayer() throws Exception {
    FafUserDetails fafUserDetails = createFafUserDetails();
    instance.setPlayerOnline(fafUserDetails.getPlayer());
    assertThat(instance.getOnlinePlayer(player.getId()).isPresent(), is(true));
    instance.removePlayer(fafUserDetails.getPlayer());
    assertThat(instance.getOnlinePlayer(player.getId()).isPresent(), is(false));
}
Also used : FafUserDetails(com.faforever.server.security.FafUserDetails) Test(org.junit.Test)

Example 2 with FafUserDetails

use of com.faforever.server.security.FafUserDetails 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 3 with FafUserDetails

use of com.faforever.server.security.FafUserDetails in project faf-java-server by FAForever.

the class PlayerServiceTest method isPlayerOnline.

@Test
public void isPlayerOnline() {
    FafUserDetails fafUserDetails = createFafUserDetails();
    assertThat(instance.isPlayerOnline(fafUserDetails.getPlayer().getLogin()), is(false));
    instance.setPlayerOnline(fafUserDetails.getPlayer());
    assertThat(instance.isPlayerOnline(fafUserDetails.getPlayer().getLogin()), is(true));
}
Also used : FafUserDetails(com.faforever.server.security.FafUserDetails) Test(org.junit.Test)

Example 4 with FafUserDetails

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

use of com.faforever.server.security.FafUserDetails 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)

Aggregations

FafUserDetails (com.faforever.server.security.FafUserDetails)15 User (com.faforever.server.entity.User)12 TestingAuthenticationToken (org.springframework.security.authentication.TestingAuthenticationToken)9 Player (com.faforever.server.entity.Player)8 Test (org.junit.Test)7 ClientConnection (com.faforever.server.client.ClientConnection)6 Before (org.junit.Before)5 PlayerOnlineEvent (com.faforever.server.player.PlayerOnlineEvent)3 InetAddress (java.net.InetAddress)3 Game (com.faforever.server.entity.Game)2 GameResponses (com.faforever.server.client.GameResponses)1 SocialRelation (com.faforever.server.entity.SocialRelation)1 RequestException (com.faforever.server.error.RequestException)1 SocialRelationResponse (com.faforever.server.social.SocialRelationListResponse.SocialRelationResponse)1 Collection (java.util.Collection)1 ServiceActivator (org.springframework.integration.annotation.ServiceActivator)1 BadCredentialsException (org.springframework.security.authentication.BadCredentialsException)1 UsernamePasswordAuthenticationToken (org.springframework.security.authentication.UsernamePasswordAuthenticationToken)1 Authentication (org.springframework.security.core.Authentication)1 Transactional (org.springframework.transaction.annotation.Transactional)1