From dae84ef1f629055cf3aad5a2ccc6776600e3c74f Mon Sep 17 00:00:00 2001 From: Steffen Nitschke Date: Sun, 31 Jan 2021 03:51:29 +0100 Subject: [PATCH] extract logout routing to ServerApp --- .../src/main/java/de/fd/fh/ServerApp.java | 1 + .../fd/fh/server/access/web/AccessController.java | 2 -- .../src/test/java/de/fd/fh/ServerAppTest.java | 15 +++++++++++++++ 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/fh.fd.ci.server/src/main/java/de/fd/fh/ServerApp.java b/fh.fd.ci.server/src/main/java/de/fd/fh/ServerApp.java index dbef579..954ff09 100644 --- a/fh.fd.ci.server/src/main/java/de/fd/fh/ServerApp.java +++ b/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"); diff --git a/fh.fd.ci.server/src/main/java/de/fd/fh/server/access/web/AccessController.java b/fh.fd.ci.server/src/main/java/de/fd/fh/server/access/web/AccessController.java index ab504ac..ce9c09e 100644 --- a/fh.fd.ci.server/src/main/java/de/fd/fh/server/access/web/AccessController.java +++ b/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); } } diff --git a/fh.fd.ci.server/src/test/java/de/fd/fh/ServerAppTest.java b/fh.fd.ci.server/src/test/java/de/fd/fh/ServerAppTest.java index 0efea84..8f5dc24 100644 --- a/fh.fd.ci.server/src/test/java/de/fd/fh/ServerAppTest.java +++ b/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 res = new ApiTestUtils() + .request("POST", url, null, null, String.class); + + assertNotNull(res); + assertEquals(200, res.getStatus()); + then(accessController).should().logout(any(), any()); + } } \ No newline at end of file