forked from Archives/Athou_commafeed
set a Max-Age on the auth cookie
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
package com.commafeed.integration;
|
||||
|
||||
import java.net.HttpCookie;
|
||||
import java.util.Base64;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.apache.hc.core5.http.HttpStatus;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
@@ -27,6 +30,30 @@ class SecurityIT extends BaseIT {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void formLogin() {
|
||||
List<HttpCookie> cookies = login();
|
||||
|
||||
try (Response response = getClient().target(getApiBaseUrl() + "user/profile")
|
||||
.request()
|
||||
.header(HttpHeaders.COOKIE, cookies.stream().map(HttpCookie::toString).collect(Collectors.joining(";")))
|
||||
.get()) {
|
||||
Assertions.assertEquals(HttpStatus.SC_OK, response.getStatus());
|
||||
cookies.forEach(c -> Assertions.assertTrue(c.getMaxAge() > 0));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void basicAuthLogin() {
|
||||
String auth = "Basic " + Base64.getEncoder().encodeToString("admin:admin".getBytes());
|
||||
try (Response response = getClient().target(getApiBaseUrl() + "user/profile")
|
||||
.request()
|
||||
.header(HttpHeaders.AUTHORIZATION, auth)
|
||||
.get()) {
|
||||
Assertions.assertEquals(HttpStatus.SC_OK, response.getStatus());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void wrongPassword() {
|
||||
String auth = "Basic " + Base64.getEncoder().encodeToString("admin:wrong-password".getBytes());
|
||||
|
||||
Reference in New Issue
Block a user