Browse Source

add logout method to AccessClient and test

feat-loginClient
Steffen Nitschke 4 years ago
parent
commit
91b655be9e
  1. 4
      fh.fd.ci.client/src/main/java/de/fd/fh/network/AccessClient.java
  2. 10
      fh.fd.ci.client/src/test/java/de/fd/fh/network/AccessClientTest.java

4
fh.fd.ci.client/src/main/java/de/fd/fh/network/AccessClient.java

@ -16,4 +16,8 @@ public interface AccessClient
@RequestLine("POST /accounts/login") @RequestLine("POST /accounts/login")
@Headers(Utils.AUTHENTICATION_HEADER + ":Basic {authToken}") @Headers(Utils.AUTHENTICATION_HEADER + ":Basic {authToken}")
LoginResponse login(@Param("authToken") final String authenticationHeader); LoginResponse login(@Param("authToken") final String authenticationHeader);
@RequestLine("POST /accounts/logout")
@Headers(Utils.AUTHENTICATION_HEADER + ":Bearer {authToken}")
Response logout(@Param("authToken") final String authenticationHeader);
} }

10
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."); 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.");
}
} }
Loading…
Cancel
Save