Fixed the user db sql.
Change-Id: I44291b3f681c64c70eacefaeebd8821ff14df1e3
diff --git a/src/main/resources/db/mysql/V0.1__userdatabase.sql b/src/main/resources/db/mysql/V0.1__userdatabase.sql
index 6f67575..c069b6e 100644
--- a/src/main/resources/db/mysql/V0.1__userdatabase.sql
+++ b/src/main/resources/db/mysql/V0.1__userdatabase.sql
@@ -16,7 +16,7 @@
CREATE TABLE IF NOT EXISTS admin_users (
id INTEGER PRIMARY KEY AUTO_INCREMENT,
- user_id INTEGER NOT NULL UNIQUE,
+ user_id INTEGER NOT NULL,
foreign key (user_id)
references korap_users (id)
);
diff --git a/src/test/java/de/ids_mannheim/korap/web/service/full/ResouceServiceServerTest.java b/src/test/java/de/ids_mannheim/korap/web/service/full/KustvaktServerTest.java
similarity index 81%
rename from src/test/java/de/ids_mannheim/korap/web/service/full/ResouceServiceServerTest.java
rename to src/test/java/de/ids_mannheim/korap/web/service/full/KustvaktServerTest.java
index 81d3e0e..aa99ac9 100644
--- a/src/test/java/de/ids_mannheim/korap/web/service/full/ResouceServiceServerTest.java
+++ b/src/test/java/de/ids_mannheim/korap/web/service/full/KustvaktServerTest.java
@@ -7,10 +7,13 @@
import java.io.File;
import java.io.FileInputStream;
+import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.net.URI;
import java.net.URISyntaxException;
+import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
import java.security.KeyManagementException;
import java.security.KeyStore;
import java.security.KeyStoreException;
@@ -31,12 +34,14 @@
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
import org.apache.http.conn.ssl.SSLContexts;
import org.apache.http.conn.ssl.TrustSelfSignedStrategy;
+import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.eclipse.jetty.util.ssl.SslContextFactory;
import org.junit.Assert;
import org.junit.Test;
import com.fasterxml.jackson.databind.JsonNode;
+import com.google.common.io.Files;
import com.sun.jersey.api.client.ClientResponse;
import de.ids_mannheim.korap.config.Attributes;
@@ -59,37 +64,17 @@
* @author margaretha
*
*/
-public class ResouceServiceServerTest extends BeanConfigTest {
+public class KustvaktServerTest extends BeanConfigTest {
@Test
public void testCreatePolicy() throws IOException, URISyntaxException {
- String pwd ="password";
- InputStream stream = new FileInputStream(new File(
- "/home/elma/korap-keystore"));
- SSLContext sslcontext = null;
- try {
- KeyStore ks = KeyStore.getInstance(KeyStore.getDefaultType());
- ks.load(stream, pwd.toCharArray());
- sslcontext = SSLContexts.custom()
- .loadTrustMaterial(ks)
- .loadKeyMaterial(ks, pwd.toCharArray())
- .build();
- } catch (KeyStoreException | NoSuchAlgorithmException | CertificateException
- | KeyManagementException | UnrecoverableKeyException e) {
- e.printStackTrace();
- }
-
- SSLConnectionSocketFactory factory = new SSLConnectionSocketFactory(sslcontext,
- SSLConnectionSocketFactory.BROWSER_COMPATIBLE_HOSTNAME_VERIFIER);
- HttpClient httpclient = HttpClients.custom()
- .setSSLSocketFactory(factory)
- .build();
+ HttpClient httpClient = HttpClients.createDefault();;
String id = UUID.randomUUID().toString();
URIBuilder builder = new URIBuilder();
- builder.setScheme("https")
- .setHost("korap.ids-mannheim.de")
- .setPort(8443).setPath("/api/v0.1/admin/createPolicies/" + id)
+ builder.setScheme("http")
+ .setHost("localhost")
+ .setPort(8089).setPath("/api/v0.1/admin/createPolicies/" + id)
.setParameter("type", "virtualcollection")
.setParameter("name", "Goethe VC")
.setParameter("description", "Goethe corpus")
@@ -100,8 +85,9 @@
URI uri = builder.build();
HttpPost httppost = new HttpPost(uri);
+
httppost.addHeader(Attributes.AUTHORIZATION, BasicHttpAuth.encode("kustvakt", "kustvakt2015"));
- HttpResponse response = httpclient.execute(httppost);
+ HttpResponse response = httpClient.execute(httppost);
assertEquals(ClientResponse.Status.OK.getStatusCode(),
response.getStatusLine().getStatusCode());