Browse Source

extract login routing to ServerApp

chore-betterServerTestCoverage
Steffen Nitschke 4 years ago
parent
commit
2624e63baa
  1. 1
      fh.fd.ci.server/src/main/java/de/fd/fh/ServerApp.java
  2. 2
      fh.fd.ci.server/src/main/java/de/fd/fh/server/access/web/AccessController.java
  3. 16
      fh.fd.ci.server/src/test/java/de/fd/fh/ServerAppTest.java

1
fh.fd.ci.server/src/main/java/de/fd/fh/ServerApp.java

@ -42,6 +42,7 @@ public class ServerApp
before("/*", (req, res) -> accessController.before(req));
post("/accounts/registrate", accessController::registrate);
post("/accounts/login", accessController::login);
get("/hello", (req, res) -> "Hello World");

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

@ -102,8 +102,6 @@ public class AccessController
{
this.service = service;
post("/accounts/login", this::login);
post("/accounts/logout",this::logout);
delete("/accounts/:player_id", this::deletePlayer);

16
fh.fd.ci.server/src/test/java/de/fd/fh/ServerAppTest.java

@ -1,5 +1,6 @@
package de.fd.fh;
import com.fasterxml.jackson.core.JsonProcessingException;
import de.fd.fh.server.ApiTestUtils;
import de.fd.fh.server.access.web.AccessController;
import de.fd.fh.server.user.web.UserController;
@ -69,4 +70,19 @@ class ServerAppTest
assertEquals(200, res.getStatus());
then(accessController).should().registrate(any(), any());
}
@Test
void testLogin() throws JsonProcessingException
{
when(accessController.login(any(), any())).thenReturn("Test");
String url = "/accounts/login";
ApiTestUtils.TestResponse<String> res = new ApiTestUtils<String>()
.request("POST", url, null, null, String.class);
assertNotNull(res);
assertEquals(200, res.getStatus());
then(accessController).should().login(any(), any());
}
}
Loading…
Cancel
Save