use of com.faforever.server.client.LegacyLoginRequest in project faf-java-server by FAForever.
the class LegacyServicesActivatorsTest method loginRequest.
@Test
public void loginRequest() throws Exception {
createAuthentication(player);
instance.loginRequest(new LegacyLoginRequest("JUnit", "password", "uniqueId"), clientConnection);
ArgumentCaptor<Authentication> captor = ArgumentCaptor.forClass(Authentication.class);
verify(authenticationManager).authenticate(captor.capture());
UsernamePasswordAuthenticationToken authentication = (UsernamePasswordAuthenticationToken) captor.getValue();
assertThat(authentication.getPrincipal(), is("JUnit"));
assertThat(authentication.getCredentials(), is("password"));
verify(playerService).setPlayerOnline(player);
}
use of com.faforever.server.client.LegacyLoginRequest in project faf-java-server by FAForever.
the class LegacyRequestTransformerTest method transformLogin.
@Test
public void transformLogin() throws Exception {
LegacyLoginRequest loginRequest = (LegacyLoginRequest) instance.transform(ImmutableMap.of(KEY_COMMAND, "hello", "login", TEST_USERNAME, "password", TEST_PASSWORD, "unique_id", "foobar"));
assertThat(loginRequest, is(notNullValue()));
assertThat(loginRequest.getLogin(), is(TEST_USERNAME));
assertThat(loginRequest.getPassword(), is(TEST_PASSWORD));
assertThat(loginRequest.getUniqueId(), is("foobar"));
}
use of com.faforever.server.client.LegacyLoginRequest in project faf-java-server by FAForever.
the class LegacyServicesActivatorsTest method loginRequestCallsUniqueIdService.
@Test
public void loginRequestCallsUniqueIdService() throws Exception {
createAuthentication(new Player());
instance.loginRequest(new LegacyLoginRequest("JUnit", "password", "uniqueId"), clientConnection);
verify(uniqueIdService).verify(any(), eq("uniqueId"));
}
use of com.faforever.server.client.LegacyLoginRequest in project faf-java-server by FAForever.
the class LegacyServicesActivatorsTest method loginRequestAlreadyOnlineThrowsException.
@Test
public void loginRequestAlreadyOnlineThrowsException() throws Exception {
when(playerService.isPlayerOnline("JUnit")).thenReturn(true);
expectedException.expect(requestExceptionWithCode(ErrorCode.USER_ALREADY_CONNECTED));
instance.loginRequest(new LegacyLoginRequest("JUnit", "password", "uniqueId"), clientConnection);
}
Aggregations