use of com.faforever.server.entity.User 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);
}
use of com.faforever.server.entity.User in project faf-java-server by FAForever.
the class ChatService method onPlayerOnlineEvent.
@EventListener
public void onPlayerOnlineEvent(PlayerOnlineEvent event) {
Chat chat = properties.getChat();
Set<String> channels = new HashSet<>(3, 1);
channels.addAll(chat.getDefaultChannels());
Optional.ofNullable(event.getPlayer().getClan()).map(clan -> (String.format(chat.getClanChannelFormat(), clan.getTag()))).ifPresent(channels::add);
User user = event.getPlayer().getUser();
GroupAssociation groupAssociation = user.getGroupAssociation();
if (groupAssociation != null) {
switch(groupAssociation.getGroup()) {
case ADMIN:
channels.addAll(chat.getAdminChannels());
break;
case MODERATOR:
channels.addAll(chat.getModeratorChannels());
break;
default:
throw new ProgrammingError("Uncovered group: " + groupAssociation.getGroup());
}
}
clientService.sendChatChannels(channels, event.getPlayer());
}
use of com.faforever.server.entity.User in project faf-java-server by FAForever.
the class FafUserDetailsTest method userWithoutGroup1IsNotAdmin.
@Test
public void userWithoutGroup1IsNotAdmin() throws Exception {
User user = (User) new User().setGroupAssociation(new GroupAssociation().setGroup(Group.MODERATOR)).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"));
}
use of com.faforever.server.entity.User in project faf-java-server by FAForever.
the class GameServiceTest method onAuthenticationSuccess.
@Test
@SuppressWarnings("unchecked")
public void onAuthenticationSuccess() throws Exception {
player1.setCurrentGame(null);
instance.createGame("Test game", FAF_TECHNICAL_NAME, MAP_NAME, null, GameVisibility.PUBLIC, GAME_MIN_RATING, GAME_MAX_RATING, player1);
TestingAuthenticationToken authentication = new TestingAuthenticationToken("JUnit", "foo");
authentication.setDetails(new TestingAuthenticationToken(new FafUserDetails((User) new User().setPlayer(player2).setPassword("pw").setLogin("JUnit")), null));
instance.onPlayerOnlineEvent(new PlayerOnlineEvent(this, player2));
ArgumentCaptor<GameResponses> captor = ArgumentCaptor.forClass((Class) Collection.class);
verify(clientService).sendGameList(captor.capture(), eq(player2));
GameResponses games = captor.getValue();
assertThat(games.getResponses(), hasSize(1));
assertThat(games.getResponses().iterator().next().getTitle(), is("Test game"));
}
use of com.faforever.server.entity.User in project faf-java-server by FAForever.
the class IceServiceActivatorsTest method setUp.
@Before
public void setUp() throws Exception {
player = new Player();
player.setClientConnection(clientConnection);
clientConnection = new ClientConnection("1", Protocol.V1_LEGACY_UTF_16, mock(InetAddress.class)).setAuthentication(new TestingAuthenticationToken(new FafUserDetails((User) new User().setPlayer(player).setPassword("pw").setLogin("JUnit")), null));
instance = new IceServiceActivators(iceService);
}
Aggregations