Browse Source

extract logout routing to ServerApp

chore-betterServerTestCoverage
Steffen Nitschke 4 years ago
parent
commit
dae84ef1f6
  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. 15
      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

@ -43,6 +43,7 @@ public class ServerApp
before("/*", (req, res) -> accessController.before(req));
post("/accounts/registrate", accessController::registrate);
post("/accounts/login", accessController::login);
post("/accounts/logout", accessController::logout);
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/logout",this::logout);
delete("/accounts/:player_id", this::deletePlayer);
}
}

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

@ -85,4 +85,19 @@ class ServerAppTest
assertEquals(200, res.getStatus());
then(accessController).should().login(any(), any());
}
@Test
void testLogout()
{
when(accessController.logout(any(), any())).thenReturn("Test");
String url = "/accounts/logout";
ApiTestUtils.TestResponse<String> res = new ApiTestUtils<String>()
.request("POST", url, null, null, String.class);
assertNotNull(res);
assertEquals(200, res.getStatus());
then(accessController).should().logout(any(), any());
}
}
Loading…
Cancel
Save