Search in sources :

Example 1 with User

use of com.faforever.server.entity.User 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 User

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

the class FafUserDetailsTest method userWithValidBanDetailsIsLocked.

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

Example 3 with User

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

the class FafUserDetailsTest method userWithGroup1IsAdmin.

@Test
public void userWithGroup1IsAdmin() throws Exception {
    User user = (User) new User().setGroupAssociation(new GroupAssociation().setGroup(Group.ADMIN)).setPassword(TEST_PASSWORD).setLogin(TEST_USERNAME);
    FafUserDetails fafUserDetails = new FafUserDetails(user);
    assertThat(fafUserDetails.getAuthorities(), CoreMatchers.hasItems(new SimpleGrantedAuthority("ROLE_USER"), new SimpleGrantedAuthority("ROLE_ADMIN")));
}
Also used : SimpleGrantedAuthority(org.springframework.security.core.authority.SimpleGrantedAuthority) User(com.faforever.server.entity.User) GroupAssociation(com.faforever.server.entity.GroupAssociation) Test(org.junit.Test)

Example 4 with User

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

the class FafUserDetailsTest method userWithoutGroupIsNotAdmin.

@Test
public void userWithoutGroupIsNotAdmin() throws Exception {
    User user = (User) new User().setGroupAssociation(null).setPassword(TEST_PASSWORD).setLogin(TEST_USERNAME);
    FafUserDetails fafUserDetails = new FafUserDetails(user);
    assertThat(fafUserDetails.getAuthorities(), hasSize(1));
    assertThat(fafUserDetails.getAuthorities().iterator().next().getAuthority(), is("ROLE_USER"));
}
Also used : User(com.faforever.server.entity.User) Test(org.junit.Test)

Example 5 with User

use of com.faforever.server.entity.User 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)

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