Implemented OAuth2 client registration.
Change-Id: I0c51bb1ee031e2a6ff9d0181de7dcb1da53d1d07
diff --git a/full/src/test/java/de/ids_mannheim/korap/config/SpringJerseyTest.java b/full/src/test/java/de/ids_mannheim/korap/config/SpringJerseyTest.java
index 930e454..9173038 100644
--- a/full/src/test/java/de/ids_mannheim/korap/config/SpringJerseyTest.java
+++ b/full/src/test/java/de/ids_mannheim/korap/config/SpringJerseyTest.java
@@ -20,7 +20,7 @@
public abstract class SpringJerseyTest extends JerseyTest {
private static String[] classPackages =
- new String[] { "de.ids_mannheim.korap.web.service.full",
+ new String[] { "de.ids_mannheim.korap.web.controller",
"de.ids_mannheim.korap.web.filter",
"de.ids_mannheim.korap.web.utils" };
diff --git a/full/src/test/java/de/ids_mannheim/korap/dao/UserGroupDaoTest.java b/full/src/test/java/de/ids_mannheim/korap/dao/UserGroupDaoTest.java
index 11f326f..40d4abd 100644
--- a/full/src/test/java/de/ids_mannheim/korap/dao/UserGroupDaoTest.java
+++ b/full/src/test/java/de/ids_mannheim/korap/dao/UserGroupDaoTest.java
@@ -2,15 +2,11 @@
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
import java.util.ArrayList;
-import java.util.Iterator;
import java.util.List;
import java.util.Set;
-import javax.validation.constraints.AssertTrue;
-
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
diff --git a/full/src/test/java/de/ids_mannheim/korap/web/controller/OAuth2ClientControllerTest.java b/full/src/test/java/de/ids_mannheim/korap/web/controller/OAuth2ClientControllerTest.java
new file mode 100644
index 0000000..26a11bc
--- /dev/null
+++ b/full/src/test/java/de/ids_mannheim/korap/web/controller/OAuth2ClientControllerTest.java
@@ -0,0 +1,34 @@
+package de.ids_mannheim.korap.web.controller;
+
+import static org.junit.Assert.assertEquals;
+
+import org.apache.http.entity.ContentType;
+import org.junit.Test;
+
+import com.google.common.net.HttpHeaders;
+import com.sun.jersey.api.client.ClientResponse;
+import com.sun.jersey.api.client.ClientResponse.Status;
+
+import de.ids_mannheim.korap.config.SpringJerseyTest;
+import de.ids_mannheim.korap.constant.ClientType;
+import de.ids_mannheim.korap.exceptions.KustvaktException;
+import de.ids_mannheim.korap.web.input.OAuth2ClientJson;
+
+public class OAuth2ClientControllerTest extends SpringJerseyTest {
+
+ @Test
+ public void testRegisterClient () throws KustvaktException {
+
+ OAuth2ClientJson json = new OAuth2ClientJson();
+ json.setName("OAuth2ClientControllerTest");
+ json.setType(ClientType.CONFIDENTIAL);
+ json.setUrl("http://example.client.com");
+ json.setRedirectURI("http://example.client.com/redirect");
+
+ ClientResponse response = resource().path("client").path("register")
+ .header(HttpHeaders.CONTENT_TYPE, ContentType.APPLICATION_JSON)
+ .entity(json).post(ClientResponse.class);
+
+ assertEquals(Status.OK.getStatusCode(), response.getStatus());
+ }
+}
diff --git a/full/src/test/resources/test-config.xml b/full/src/test/resources/test-config.xml
index 83291a9..ffd8c9e 100644
--- a/full/src/test/resources/test-config.xml
+++ b/full/src/test/resources/test-config.xml
@@ -165,6 +165,10 @@
<constructor-arg value="${krill.indexDir}" />
</bean>
+ <!-- URLValidator -->
+ <bean id="urlValidator" class="org.apache.commons.validator.routines.UrlValidator">
+ <constructor-arg value="http,https"/>
+ </bean>
<bean id="kustvakt_rewrite" class="de.ids_mannheim.korap.rewrite.FullRewriteHandler">
<constructor-arg ref="kustvakt_config" />