From 91b655be9ecc5c34f47f1acfaffc48899f623c23 Mon Sep 17 00:00:00 2001 From: Steffen Nitschke Date: Sun, 31 Jan 2021 14:07:50 +0100 Subject: [PATCH] add logout method to AccessClient and test --- .../src/main/java/de/fd/fh/network/AccessClient.java | 4 ++++ .../test/java/de/fd/fh/network/AccessClientTest.java | 10 ++++++++++ 2 files changed, 14 insertions(+) diff --git a/fh.fd.ci.client/src/main/java/de/fd/fh/network/AccessClient.java b/fh.fd.ci.client/src/main/java/de/fd/fh/network/AccessClient.java index 6ce4d47..77db09a 100644 --- a/fh.fd.ci.client/src/main/java/de/fd/fh/network/AccessClient.java +++ b/fh.fd.ci.client/src/main/java/de/fd/fh/network/AccessClient.java @@ -16,4 +16,8 @@ public interface AccessClient @RequestLine("POST /accounts/login") @Headers(Utils.AUTHENTICATION_HEADER + ":Basic {authToken}") LoginResponse login(@Param("authToken") final String authenticationHeader); + + @RequestLine("POST /accounts/logout") + @Headers(Utils.AUTHENTICATION_HEADER + ":Bearer {authToken}") + Response logout(@Param("authToken") final String authenticationHeader); } diff --git a/fh.fd.ci.client/src/test/java/de/fd/fh/network/AccessClientTest.java b/fh.fd.ci.client/src/test/java/de/fd/fh/network/AccessClientTest.java index 7080233..74cc629 100644 --- a/fh.fd.ci.client/src/test/java/de/fd/fh/network/AccessClientTest.java +++ b/fh.fd.ci.client/src/test/java/de/fd/fh/network/AccessClientTest.java @@ -73,4 +73,14 @@ class AccessClientTest assertEquals("Basic testToken", authHeader, "Should use given token."); } + + @Test + void testLogout() + { + mockClient.ok(HttpMethod.POST, "/accounts/logout"); + + final Response result = client.logout("testToken"); + + assertEquals(200, result.status(), "Should return status code 200."); + } } \ No newline at end of file