Browse Source

rename LoginRequest to LoginResponse

feat-loginClient
Steffen Nitschke 4 years ago
parent
commit
f394ba7b62
  1. 14
      fh.fd.ci.server/src/main/java/de/fd/fh/server/access/AccessService.java
  2. 4
      fh.fd.ci.server/src/main/java/de/fd/fh/server/access/web/AccessController.java
  3. 6
      fh.fd.ci.server/src/test/java/de/fd/fh/server/access/AccessServiceTest.java
  4. 2
      fh.fd.ci.shared/src/main/java/de/fd/fh/shared/network/messages/LoginResponse.java

14
fh.fd.ci.server/src/main/java/de/fd/fh/server/access/AccessService.java

@ -3,7 +3,7 @@ package de.fd.fh.server.access;
import de.fd.fh.server.access.events.AccountCreatedEvent;
import de.fd.fh.server.access.events.AccountDeletedEvent;
import de.fd.fh.server.user.UserId;
import de.fd.fh.shared.network.messages.LoginRequest;
import de.fd.fh.shared.network.messages.LoginResponse;
import de.fd.fh.shared.network.messages.RegistrateRequest;
import lombok.RequiredArgsConstructor;
import org.bson.types.ObjectId;
@ -97,7 +97,7 @@ public class AccessService extends Observable
}
}
public LoginRequest authorization(final String header)
public LoginResponse authorization(final String header)
{
System.out.println("authorization");
final String auth = header.substring("Basic ".length());
@ -117,12 +117,12 @@ public class AccessService extends Observable
access.setToken(AccessToken.of(access));
accessRepository.save(access);
final LoginRequest loginRequest = new LoginRequest();
loginRequest.setUserId(access.getUserId().getIdentifier());
loginRequest.setToken(access.getToken().getToken());
loginRequest.setName(access.getName());
final LoginResponse loginResponse = new LoginResponse();
loginResponse.setUserId(access.getUserId().getIdentifier());
loginResponse.setToken(access.getToken().getToken());
loginResponse.setName(access.getName());
return loginRequest;
return loginResponse;
}
return null;

4
fh.fd.ci.server/src/main/java/de/fd/fh/server/access/web/AccessController.java

@ -5,7 +5,7 @@ import de.fd.fh.server.access.AccessService;
import de.fd.fh.server.access.AccessToken;
import de.fd.fh.server.user.UserId;
import de.fd.fh.shared.Utils;
import de.fd.fh.shared.network.messages.LoginRequest;
import de.fd.fh.shared.network.messages.LoginResponse;
import de.fd.fh.shared.network.messages.RegistrateRequest;
import static spark.Spark.*;
@ -51,7 +51,7 @@ public class AccessController
{
final String header = request.headers(Utils.AUTHENTICATION_HEADER);
final LoginRequest login = service.authorization(header);
final LoginResponse login = service.authorization(header);
if (login == null)
{

6
fh.fd.ci.server/src/test/java/de/fd/fh/server/access/AccessServiceTest.java

@ -2,7 +2,7 @@ package de.fd.fh.server.access;
import com.mongodb.WriteResult;
import de.fd.fh.server.user.UserId;
import de.fd.fh.shared.network.messages.LoginRequest;
import de.fd.fh.shared.network.messages.LoginResponse;
import de.fd.fh.shared.network.messages.RegistrateRequest;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@ -176,7 +176,7 @@ class AccessServiceTest implements Observer
when(repository.findByUserName(any()))
.thenReturn(access);
final LoginRequest result = new AccessService(repository).authorization(header);
final LoginResponse result = new AccessService(repository).authorization(header);
assertNotNull(result);
assertEquals(result.getName(), "testName", "Wrong UserName");
@ -191,7 +191,7 @@ class AccessServiceTest implements Observer
final String header = "Basic " + new String(message);
final AccessRepository repository = mock(AccessRepository.class);
final LoginRequest result = new AccessService(repository).authorization(header);
final LoginResponse result = new AccessService(repository).authorization(header);
assertNull(result, "Return LoginRequest but wrong permissions");
}

2
fh.fd.ci.shared/src/main/java/de/fd/fh/shared/network/messages/LoginRequest.java → fh.fd.ci.shared/src/main/java/de/fd/fh/shared/network/messages/LoginResponse.java

@ -3,7 +3,7 @@ package de.fd.fh.shared.network.messages;
import lombok.Data;
@Data
public class LoginRequest
public class LoginResponse
{
private String name;
private String userId;
Loading…
Cancel
Save