Deprecate API token (JWT) web-service.
Change-Id: I818bf5cbe81b078c1beaf24d8f81929c946c561c
diff --git a/full/src/test/java/de/ids_mannheim/korap/authentication/APIAuthenticationTest.java b/full/src/test/java/de/ids_mannheim/korap/authentication/APIAuthenticationTest.java
index 086169b..a36a27b 100644
--- a/full/src/test/java/de/ids_mannheim/korap/authentication/APIAuthenticationTest.java
+++ b/full/src/test/java/de/ids_mannheim/korap/authentication/APIAuthenticationTest.java
@@ -6,27 +6,54 @@
import java.util.HashMap;
import java.util.Map;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.Response.Status;
+
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.google.common.net.HttpHeaders;
import com.nimbusds.jose.JOSEException;
+import de.ids_mannheim.korap.authentication.http.HttpAuthorizationHandler;
import de.ids_mannheim.korap.config.Attributes;
import de.ids_mannheim.korap.config.FullConfiguration;
-import de.ids_mannheim.korap.config.SpringJerseyTest;
import de.ids_mannheim.korap.constant.TokenType;
import de.ids_mannheim.korap.exceptions.KustvaktException;
+import de.ids_mannheim.korap.exceptions.StatusCodes;
import de.ids_mannheim.korap.security.context.TokenContext;
import de.ids_mannheim.korap.user.KorAPUser;
import de.ids_mannheim.korap.user.User;
+import de.ids_mannheim.korap.utils.JsonUtils;
import de.ids_mannheim.korap.utils.TimeUtils;
+import de.ids_mannheim.korap.web.controller.OAuth2TestBase;
-public class APIAuthenticationTest extends SpringJerseyTest {
+public class APIAuthenticationTest extends OAuth2TestBase {
@Autowired
private FullConfiguration config;
@Test
+ public void testDeprecatedService () throws KustvaktException {
+
+ String userAuthHeader = HttpAuthorizationHandler
+ .createBasicAuthorizationHeaderValue("dory", "password");
+
+ Response response = target().path(API_VERSION).path("auth")
+ .path("apiToken").request()
+ .header(Attributes.AUTHORIZATION, userAuthHeader)
+ .header(HttpHeaders.X_FORWARDED_FOR, "149.27.0.32").get();
+
+ assertEquals(Status.BAD_REQUEST.getStatusCode(), response.getStatus());
+
+ String entity = response.readEntity(String.class);
+ JsonNode node = JsonUtils.readTree(entity);
+
+ assertEquals(StatusCodes.DEPRECATED, node.at("/errors/0/0").asInt());
+ }
+
+ @Test
public void testCreateGetTokenContext () throws KustvaktException,
IOException, InterruptedException, JOSEException {
User user = new KorAPUser();
diff --git a/full/src/test/java/de/ids_mannheim/korap/web/controller/MultipleCorpusQueryTest.java b/full/src/test/java/de/ids_mannheim/korap/web/controller/MultipleCorpusQueryTest.java
index 911e716..f44c1c8 100644
--- a/full/src/test/java/de/ids_mannheim/korap/web/controller/MultipleCorpusQueryTest.java
+++ b/full/src/test/java/de/ids_mannheim/korap/web/controller/MultipleCorpusQueryTest.java
@@ -81,7 +81,7 @@
assertEquals(19387, node.at("/sentences").asInt());
assertEquals(514, node.at("/paragraphs").asInt());
- assertEquals(StatusCodes.DEPRECATED_PARAMETER,
+ assertEquals(StatusCodes.DEPRECATED,
node.at("/warnings/0/0").asInt());
assertEquals("Parameter corpusQuery is deprecated in favor of cq.",
node.at("/warnings/0/1").asText());
diff --git a/full/src/test/java/de/ids_mannheim/korap/web/controller/StatisticsControllerTest.java b/full/src/test/java/de/ids_mannheim/korap/web/controller/StatisticsControllerTest.java
index 29471a0..e2d36c6 100644
--- a/full/src/test/java/de/ids_mannheim/korap/web/controller/StatisticsControllerTest.java
+++ b/full/src/test/java/de/ids_mannheim/korap/web/controller/StatisticsControllerTest.java
@@ -105,7 +105,7 @@
assertEquals(node.get("documents").asInt(),11);
assertEquals(node.get("tokens").asInt(),665842);
- assertEquals(StatusCodes.DEPRECATED_PARAMETER,
+ assertEquals(StatusCodes.DEPRECATED,
node.at("/warnings/0/0").asInt());
assertEquals("Parameter corpusQuery is deprecated in favor of cq.",
node.at("/warnings/0/1").asText());
diff --git a/full/src/test/java/de/ids_mannheim/korap/web/controller/TokenExpiryTest.java b/full/src/test/java/de/ids_mannheim/korap/web/controller/TokenExpiryTest.java
index 3b1d086..4518d1d 100644
--- a/full/src/test/java/de/ids_mannheim/korap/web/controller/TokenExpiryTest.java
+++ b/full/src/test/java/de/ids_mannheim/korap/web/controller/TokenExpiryTest.java
@@ -6,15 +6,16 @@
import javax.ws.rs.client.Entity;
import javax.ws.rs.core.Form;
+import javax.ws.rs.core.Response;
import javax.ws.rs.core.Response.Status;
import org.apache.http.HttpStatus;
import org.apache.http.entity.ContentType;
+import org.junit.Ignore;
import org.junit.Test;
import com.fasterxml.jackson.databind.JsonNode;
import com.google.common.net.HttpHeaders;
-import javax.ws.rs.core.Response;
import de.ids_mannheim.korap.config.Attributes;
import de.ids_mannheim.korap.config.SpringJerseyTest;
@@ -31,7 +32,8 @@
*
*/
public class TokenExpiryTest extends SpringJerseyTest {
-
+
+ @Ignore
@Test
public void requestToken ()
throws KustvaktException, InterruptedException, IOException {
diff --git a/full/src/test/resources/log4j2-test.properties b/full/src/test/resources/log4j2-test.properties
index 2810e0c..872b150 100644
--- a/full/src/test/resources/log4j2-test.properties
+++ b/full/src/test/resources/log4j2-test.properties
@@ -35,9 +35,9 @@
logger.console.appenderRef.file.ref = STDOUT
logger.console.additivity=false
-#loggers=console
-#logger.console.name=de.ids_mannheim.korap
-#logger.console.level = info
-#logger.console.appenderRefs = stdout
-#logger.console.appenderRef.file.ref = STDOUT
-#logger.console.additivity=false
+loggers=console
+logger.console.name=de.ids_mannheim.korap.web.controller.AuthenticationController
+logger.console.level = warn
+logger.console.appenderRefs = stdout
+logger.console.appenderRef.file.ref = STDOUT
+logger.console.additivity=false