Search in sources :

Example 1 with LegacyLoginRequest

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);
}
Also used : Authentication(org.springframework.security.core.Authentication) LegacyLoginRequest(com.faforever.server.client.LegacyLoginRequest) UsernamePasswordAuthenticationToken(org.springframework.security.authentication.UsernamePasswordAuthenticationToken) Test(org.junit.Test)

Example 2 with LegacyLoginRequest

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"));
}
Also used : LegacyLoginRequest(com.faforever.server.client.LegacyLoginRequest) Test(org.junit.Test)

Example 3 with LegacyLoginRequest

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"));
}
Also used : Player(com.faforever.server.entity.Player) LegacyLoginRequest(com.faforever.server.client.LegacyLoginRequest) Test(org.junit.Test)

Example 4 with LegacyLoginRequest

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);
}
Also used : LegacyLoginRequest(com.faforever.server.client.LegacyLoginRequest) Test(org.junit.Test)

Aggregations

LegacyLoginRequest (com.faforever.server.client.LegacyLoginRequest)4 Test (org.junit.Test)4 Player (com.faforever.server.entity.Player)1 UsernamePasswordAuthenticationToken (org.springframework.security.authentication.UsernamePasswordAuthenticationToken)1 Authentication (org.springframework.security.core.Authentication)1