kustvaktmap
diff --git a/src/main/java/de/ids_mannheim/korap/handlers/UserDetailsDao.java b/src/main/java/de/ids_mannheim/korap/handlers/UserDetailsDao.java
index b9fd4dd..e05386b 100644
--- a/src/main/java/de/ids_mannheim/korap/handlers/UserDetailsDao.java
+++ b/src/main/java/de/ids_mannheim/korap/handlers/UserDetailsDao.java
@@ -28,7 +28,7 @@
@Override
public int store(UserDetails data) {
- String sql = "INSERT INTO user_details2 (user_id, data) VALUES (:userid, :data);";
+ String sql = "INSERT INTO user_details (user_id, data) VALUES (:userid, :data);";
MapSqlParameterSource source = new MapSqlParameterSource();
source.addValue("userid", data.getUserID());
source.addValue("data", data.data());
@@ -47,7 +47,7 @@
@Override
public int update(UserDetails data) {
- String sql = "UPDATE user_details2 SET data = :data WHERE user_id=:userid;";
+ String sql = "UPDATE user_details SET data = :data WHERE user_id=:userid;";
MapSqlParameterSource source = new MapSqlParameterSource();
source.addValue("userid", data.getUserID());
source.addValue("data", data.data());
@@ -61,7 +61,7 @@
@Override
public UserDetails get(Integer id) {
- String sql = "SELECT * FROM user_details2 WHERE id=:id;";
+ String sql = "SELECT * FROM user_details WHERE id=:id;";
MapSqlParameterSource source = new MapSqlParameterSource();
source.addValue("id", id);
@@ -87,7 +87,7 @@
@Override
public UserDetails get(User user) {
- String sql = "SELECT * FROM user_details2 WHERE user_id=:userid;";
+ String sql = "SELECT * FROM user_details WHERE user_id=:userid;";
MapSqlParameterSource source = new MapSqlParameterSource();
source.addValue("userid", user.getId());
@@ -114,7 +114,7 @@
@Override
public int delete(UserDetails data) {
- String sql = "DELETE FROM user_details2 WHERE id=:id";
+ String sql = "DELETE FROM user_details WHERE id=:id";
MapSqlParameterSource source = new MapSqlParameterSource();
source.addValue("id", data.getId());
try {
@@ -126,7 +126,7 @@
@Override
public int deleteAll() {
- String sql = "DELETE FROM user_details2;";
+ String sql = "DELETE FROM user_details;";
try {
return this.jdbcTemplate.update(sql, new HashMap<String, Object>());
}catch (DataAccessException e) {
diff --git a/src/main/java/de/ids_mannheim/korap/handlers/UserSettingsDao.java b/src/main/java/de/ids_mannheim/korap/handlers/UserSettingsDao.java
index 948eae3..d343dca 100644
--- a/src/main/java/de/ids_mannheim/korap/handlers/UserSettingsDao.java
+++ b/src/main/java/de/ids_mannheim/korap/handlers/UserSettingsDao.java
@@ -27,7 +27,7 @@
}
@Override
public int store(UserSettings data) {
- String sql = "INSERT INTO user_settings2 (user_id, data) VALUES (:userid, :data);";
+ String sql = "INSERT INTO user_settings (user_id, data) VALUES (:userid, :data);";
MapSqlParameterSource source = new MapSqlParameterSource();
source.addValue("userid", data.getUserID());
source.addValue("data", data.data());
@@ -46,7 +46,7 @@
@Override
public int update(UserSettings data) {
- String sql = "UPDATE user_settings2 SET data = :data WHERE user_id=:userid;";
+ String sql = "UPDATE user_settings SET data = :data WHERE user_id=:userid;";
MapSqlParameterSource source = new MapSqlParameterSource();
source.addValue("userid", data.getUserID());
source.addValue("data", data.data());
@@ -60,7 +60,7 @@
@Override
public UserSettings get(Integer id) {
- String sql = "SELECT * FROM user_settings2 WHERE id=:id;";
+ String sql = "SELECT * FROM user_settings WHERE id=:id;";
MapSqlParameterSource source = new MapSqlParameterSource();
source.addValue("id", id);
@@ -86,7 +86,7 @@
@Override
public UserSettings get(User user) {
- String sql = "SELECT * FROM user_settings2 WHERE user_id=:userid;";
+ String sql = "SELECT * FROM user_settings WHERE user_id=:userid;";
MapSqlParameterSource source = new MapSqlParameterSource();
source.addValue("userid", user.getId());
@@ -113,7 +113,7 @@
@Override
public int delete(UserSettings data) {
- String sql = "DELETE FROM user_settings2 WHERE id=:id";
+ String sql = "DELETE FROM user_settings WHERE id=:id";
MapSqlParameterSource source = new MapSqlParameterSource();
source.addValue("id", data.getId());
try {
@@ -125,7 +125,7 @@
@Override
public int deleteAll() {
- String sql = "DELETE FROM user_settings2;";
+ String sql = "DELETE FROM user_settings;";
try {
return this.jdbcTemplate.update(sql, new HashMap<String, Object>());
}catch (DataAccessException e) {
diff --git a/src/main/java/de/ids_mannheim/korap/resource/LayerMapper.java b/src/main/java/de/ids_mannheim/korap/resource/LayerMapper.java
index e59f849..7c0bc50 100644
--- a/src/main/java/de/ids_mannheim/korap/resource/LayerMapper.java
+++ b/src/main/java/de/ids_mannheim/korap/resource/LayerMapper.java
@@ -1,6 +1,7 @@
package de.ids_mannheim.korap.resource;
import de.ids_mannheim.korap.config.KustvaktConfiguration;
+import de.ids_mannheim.korap.user.Attributes;
import de.ids_mannheim.korap.user.UserSettings;
/**
@@ -32,15 +33,20 @@
//todo: make mapping configurable!
public String findFoundry(String layer) {
if (settings != null) {
+
switch (translateLayer(layer.toLowerCase().trim())) {
case "d":
- return settings.getDefaultRelfoundry();
+ return (String) settings
+ .get(Attributes.DEFAULT_REL_FOUNDRY);
case "c":
- return settings.getDefaultConstfoundry();
+ return (String) settings
+ .get(Attributes.DEFAULT_CONST_FOUNDRY);
case "pos":
- return settings.getDefaultPOSfoundry();
+ return (String) settings
+ .get(Attributes.DEFAULT_POS_FOUNDRY);
case "lemma":
- return settings.getDefaultLemmafoundry();
+ return (String) settings
+ .get(Attributes.DEFAULT_LEMMA_FOUNDRY);
case "surface":
return "opennlp";
default:
diff --git a/src/main/java/de/ids_mannheim/korap/security/auth/KustvaktAuthenticationManager.java b/src/main/java/de/ids_mannheim/korap/security/auth/KustvaktAuthenticationManager.java
index a53cf73..adcb263 100644
--- a/src/main/java/de/ids_mannheim/korap/security/auth/KustvaktAuthenticationManager.java
+++ b/src/main/java/de/ids_mannheim/korap/security/auth/KustvaktAuthenticationManager.java
@@ -23,7 +23,6 @@
import java.io.UnsupportedEncodingException;
import java.security.NoSuchAlgorithmException;
-import java.util.HashMap;
import java.util.Map;
/**
@@ -529,12 +528,20 @@
(String) safeMap.get(Attributes.MAIL),
(String) safeMap.get(Attributes.CN));
user.setAffiliation((String) safeMap.get(Attributes.EDU_AFFIL));
- UserDetails det = UserDetails
- .newDetailsIterator(new HashMap<String, String>());
- user.setDetails(det);
- user.setSettings(new UserSettings());
user.setAccountCreation(TimeUtils.getNow().getMillis());
entHandler.createAccount(user);
+
+ UserDetails d = new UserDetails(user.getId());
+ d.readDefaults(attributes);
+ d.checkRequired();
+
+ UserdataFactory.getDaoInstance(d.getClass()).store(d);
+
+ UserSettings s = new UserSettings(user.getId());
+ s.readDefaults(attributes);
+ s.checkRequired();
+ UserdataFactory.getDaoInstance(s.getClass()).store(s);
+
return user;
}
diff --git a/src/main/java/de/ids_mannheim/korap/user/DemoUser.java b/src/main/java/de/ids_mannheim/korap/user/DemoUser.java
index 70eb878..22da0e8 100644
--- a/src/main/java/de/ids_mannheim/korap/user/DemoUser.java
+++ b/src/main/java/de/ids_mannheim/korap/user/DemoUser.java
@@ -14,10 +14,9 @@
private static final long ACCOUNT_CREATED = 1377102171202L;
public static final String PASSPHRASE = "$2a$15$rGPvLWm5JJ1iYj0V61e5guYIGmSo.rjdBkAVIU1vWS/xdybmABxRa";
+ // todo: test functionality!
protected DemoUser() {
super(DEMOUSER_NAME, 2);
- this.setDetails(new UserDetails());
- this.setSettings(new UserSettings());
this.setAccountCreation(ACCOUNT_CREATED);
// this.setQueries(UserQuery.demoUserQueries());
}
diff --git a/src/main/java/de/ids_mannheim/korap/user/User.java b/src/main/java/de/ids_mannheim/korap/user/User.java
index 22c8188..95330b1 100644
--- a/src/main/java/de/ids_mannheim/korap/user/User.java
+++ b/src/main/java/de/ids_mannheim/korap/user/User.java
@@ -70,20 +70,6 @@
return this.fields.get(cl);
}
- //todo: repair transfer
- public void transfer(User user) {
- // this.setSettings(user.getSettings());
- // this.setDetails(user.getDetails());
- // this.setQueries(user.getQueries());
- if (this instanceof KorAPUser) {
-
- // this.getSettings().setUserID(this.id);
- // this.getDetails().setUserID(this.id);
- // for (UserQuery q : this.getQueries())
- // q.setOwner(this.accountID);
- }
- }
-
public void addUserData(Userdata data) {
if (data != null) {
for (Userdata d : this.userdata) {
@@ -95,20 +81,6 @@
}
}
- @Deprecated
- public void setDetails(UserDetails details) {
- if (details != null)
- details.setUserID(this.id);
- // this.details = details;
- }
-
- @Deprecated
- public void setSettings(UserSettings settings) {
- if (settings != null)
- settings.setUserID(this.id);
- // this.settings = settings;
- }
-
public void setId(Integer id) {
this.id = id;
// if (this.settings != null)
diff --git a/src/main/java/de/ids_mannheim/korap/user/Userdata.java b/src/main/java/de/ids_mannheim/korap/user/Userdata.java
index bf53486..616857d 100644
--- a/src/main/java/de/ids_mannheim/korap/user/Userdata.java
+++ b/src/main/java/de/ids_mannheim/korap/user/Userdata.java
@@ -119,12 +119,13 @@
this.fields = crypto.validateMap(this.fields);
}
- public void readDefaults(Map<String, Object> map) {
+ public void readDefaults(Map<String, Object> map) throws KustvaktException {
for (String k : defaultFields()) {
Object o = map.get(k);
if (o != null)
this.fields.put(k, o);
}
+ this.checkRequired();
}
public abstract String[] requiredFields();
diff --git a/src/main/java/de/ids_mannheim/korap/user/Usersettings.java b/src/main/java/de/ids_mannheim/korap/user/Usersettings.java
index dd4190c..1d0c758 100644
--- a/src/main/java/de/ids_mannheim/korap/user/Usersettings.java
+++ b/src/main/java/de/ids_mannheim/korap/user/Usersettings.java
@@ -16,6 +16,8 @@
return new String[0];
}
+
+ //todo: define default fields and values --> so they can never be null!
@Override
public String[] defaultFields() {
return new String[0];
diff --git a/src/main/java/de/ids_mannheim/korap/utils/CollectionQueryBuilder3.java b/src/main/java/de/ids_mannheim/korap/utils/CollectionQueryBuilder3.java
index 220b6b9..49f7041 100644
--- a/src/main/java/de/ids_mannheim/korap/utils/CollectionQueryBuilder3.java
+++ b/src/main/java/de/ids_mannheim/korap/utils/CollectionQueryBuilder3.java
@@ -5,6 +5,8 @@
import com.fasterxml.jackson.databind.node.ObjectNode;
import de.ids_mannheim.korap.query.serialize.CollectionQueryProcessor;
+import java.util.Map;
+
/**
* convenience builder class for collection query
*
@@ -31,37 +33,38 @@
this.base = null;
}
-// /**
-// * convencience method for equal field value search operation
-// * @param field
-// * @param value
-// * @return
-// */
-// public CollectionQueryBuilder3 eq(String field, String value) {
-// fieldValue(field, "match:eq", value);
-// return this;
-// }
-//
-// /**
-// * convencience method for unequal field value search operation
-// * @param field
-// * @param value
-// * @return
-// */
-// public CollectionQueryBuilder3 uneq(String field, String value) {
-// fieldValue(field, "match:ne", value);
-// return this;
-// }
-
+ // /**
+ // * convencience method for equal field value search operation
+ // * @param field
+ // * @param value
+ // * @return
+ // */
+ // public CollectionQueryBuilder3 eq(String field, String value) {
+ // fieldValue(field, "match:eq", value);
+ // return this;
+ // }
+ //
+ // /**
+ // * convencience method for unequal field value search operation
+ // * @param field
+ // * @param value
+ // * @return
+ // */
+ // public CollectionQueryBuilder3 uneq(String field, String value) {
+ // fieldValue(field, "match:ne", value);
+ // return this;
+ // }
/**
* raw method for field - value pair adding. Supports all operators (leq, geq, contains, etc.)
+ *
* @param field
* @param op
* @param value
* @return
*/
- public CollectionQueryBuilder3 fieldValue(String field, String op, String value) {
+ public CollectionQueryBuilder3 fieldValue(String field, String op,
+ String value) {
if (base == null)
this.builder.append(field + op + value);
else {
@@ -109,8 +112,10 @@
CollectionQueryProcessor tree = new CollectionQueryProcessor(
this.verbose);
tree.process(this.builder.toString());
-
- request = tree.getRequestMap();
+ Map r = tree.getRequestMap();
+ r.remove("query");
+ r.remove("meta");
+ request = r;
}
return request;
}
@@ -144,7 +149,6 @@
return this;
}
-
public static class Utils {
public static JsonNode buildDoc(String key, String value, String op) {
diff --git a/src/main/java/de/ids_mannheim/korap/utils/UserPropertyReader.java b/src/main/java/de/ids_mannheim/korap/utils/UserPropertyReader.java
index 560970d..3369106 100644
--- a/src/main/java/de/ids_mannheim/korap/utils/UserPropertyReader.java
+++ b/src/main/java/de/ids_mannheim/korap/utils/UserPropertyReader.java
@@ -5,10 +5,7 @@
import de.ids_mannheim.korap.exceptions.StatusCodes;
import de.ids_mannheim.korap.interfaces.EncryptionIface;
import de.ids_mannheim.korap.interfaces.db.EntityHandlerIface;
-import de.ids_mannheim.korap.user.KorAPUser;
-import de.ids_mannheim.korap.user.User;
-import de.ids_mannheim.korap.user.UserDetails;
-import de.ids_mannheim.korap.user.UserSettings;
+import de.ids_mannheim.korap.user.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -74,9 +71,10 @@
throw new KustvaktException(StatusCodes.REQUEST_INVALID);
}
user.setPassword(pass);
+ iface.createAccount(user);
}else {
user = User.UserFactory.getUser(username);
- Map<String, String> vals = new HashMap<>();
+ Map<String, Object> vals = new HashMap<>();
for (Map.Entry e : p.entrySet()) {
String key = e.getKey().toString().split("\\.", 2)[1];
vals.put(key, e.getValue().toString());
@@ -97,14 +95,20 @@
user.setAccountCreation(TimeUtils.getNow().getMillis());
//todo: make sure uri is set to 0, so sql queries work with the null value
-// user.setURIExpiration(0L);
+ // user.setURIExpiration(0L);
+ iface.createAccount(user);
+ UserDetails det = new UserDetails(user.getId());
+ det.readDefaults(vals);
+ det.validate(crypto);
+ UserdataFactory.getDaoInstance(det.getClass()).store(det);
- UserDetails det = UserDetails.newDetailsIterator(vals);
+ Userdata set = new UserSettings(user.getId());
+ set.readDefaults(vals);
+ set.validate(crypto);
+ UserdataFactory.getDaoInstance(set.getClass()).store(set);
- user.setDetails(det);
- user.setSettings(new UserSettings());
}
- iface.createAccount(user);
+
jlog.info("successfully created account for user {}",
user.getUsername());
return user;
diff --git a/src/main/java/de/ids_mannheim/korap/web/service/full/AuthService.java b/src/main/java/de/ids_mannheim/korap/web/service/full/AuthService.java
index 5199855..490479d 100644
--- a/src/main/java/de/ids_mannheim/korap/web/service/full/AuthService.java
+++ b/src/main/java/de/ids_mannheim/korap/web/service/full/AuthService.java
@@ -56,12 +56,13 @@
*
* @return String
*/
+ @Deprecated
@GET
@Path("bootstrap")
@Produces(MediaType.APPLICATION_JSON)
public Response bootstrap() {
Map m = new HashMap();
- m.put("settings", new UserSettings().toObjectMap());
+// m.put("settings", new UserSettings().toObjectMap());
m.put("ql", BeanConfiguration.getBeans().getConfiguration()
.getQueryLanguages());
m.put("SortTypes", null); // types of sorting that are supported!
diff --git a/src/main/java/de/ids_mannheim/korap/web/utils/KustvaktMap.java b/src/main/java/de/ids_mannheim/korap/web/utils/KustvaktMap.java
new file mode 100644
index 0000000..c6b618a
--- /dev/null
+++ b/src/main/java/de/ids_mannheim/korap/web/utils/KustvaktMap.java
@@ -0,0 +1,69 @@
+package de.ids_mannheim.korap.web.utils;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * @author hanl
+ * @date 21/01/2016
+ */
+public class KustvaktMap {
+
+ private boolean mono;
+ private Map<String, Object> values;
+
+ public KustvaktMap() {
+ this.values = new HashMap<>();
+ this.mono = false;
+ }
+
+ public KustvaktMap(Map<String, Object> m) {
+ this();
+ setMap(m);
+ }
+
+ public void setMap(Map<String, Object> m) {
+ if (!isGeneric(m) | !this.mono)
+ this.values.putAll(m);
+ }
+
+ public boolean isGeneric() {
+ return !this.mono && isGeneric(this.values);
+ }
+
+ private static boolean isGeneric(Map<String, Object> map) {
+ int i = 0;
+ for (Object o : map.values()) {
+ if (o instanceof String)
+ i++;
+ }
+ return !(i == map.size());
+ }
+
+ public void setMonoValue(boolean monovalue) {
+ this.mono = monovalue;
+ }
+
+ public String get(String key) {
+ Object o = this.values.get(key);
+ if (!isGeneric())
+ return (String) o;
+ return String.valueOf(o);
+ }
+
+ public Object getRaw(String key) {
+ return this.values.get(key);
+ }
+
+ public <T extends Object> Object get(String key, Class<T> cl) {
+ if (isGeneric())
+ return (T) this.values.get(key);
+ return get(key);
+ }
+
+ public Set<String> keySet() {
+ return this.values.keySet();
+ }
+
+}
diff --git a/src/main/resources/db/sqlite/V1__Initial_version.sql b/src/main/resources/db/sqlite/V1__Initial_version.sql
index c26fce3..69fd635 100644
--- a/src/main/resources/db/sqlite/V1__Initial_version.sql
+++ b/src/main/resources/db/sqlite/V1__Initial_version.sql
@@ -23,55 +23,11 @@
CREATE TABLE IF NOT EXISTS user_details (
id INTEGER PRIMARY KEY AUTOINCREMENT,
-user_id INTEGER NOT NULL,
-firstName VARCHAR(100),
-lastName VARCHAR(100),
-gender VARCHAR(100),
-phone VARCHAR(100),
-institution VARCHAR(100),
-email VARCHAR(100),
-address VARCHAR(100),
-country VARCHAR(100),
-privateUsage BOOLEAN,
-foreign key (user_id)
-references korap_users (id)
-on delete cascade
-);
-
-CREATE TABLE IF NOT EXISTS user_settings (
-id INTEGER PRIMARY KEY AUTOINCREMENT,
-user_id INTEGER NOT NULL,
-fileNameForExport VARCHAR(100),
-leftContextItemForExport VARCHAR(100),
-leftContextSizeForExport INTEGER,
-locale VARCHAR(100),
-leftContextItem VARCHAR(100),
-leftContextSize INTEGER,
-rightContextItem VARCHAR(100),
-rightContextItemForExport VARCHAR(100),
-rightContextSize INTEGER,
-rightContextSizeForExport INTEGER,
-selectedCollection VARCHAR(100),
-queryLanguage VARCHAR(100),
-pageLength INTEGER,
-metadataQueryExpertModus BOOLEAN,
-POSFoundry VARCHAR(100),
-lemmaFoundry VARCHAR(100),
-constFoundry VARCHAR(100),
-relFoundry VARCHAR(100),
-collectData BOOLEAN,
-foreign key (user_id)
-references korap_users (id)
-on delete cascade
-);
-
-CREATE TABLE IF NOT EXISTS user_details2 (
-id INTEGER PRIMARY KEY AUTOINCREMENT,
user_id INTEGER UNIQUE NOT NULL,
data BLOB NOT NULL
);
-CREATE TABLE IF NOT EXISTS user_settings2 (
+CREATE TABLE IF NOT EXISTS user_settings (
id INTEGER PRIMARY KEY AUTOINCREMENT,
user_id INTEGER UNIQUE NOT NULL,
data BLOB NOT NULL
diff --git a/src/test/java/FileAuditingTest.java b/src/test/java/FileAuditingTest.java
index 23b589c..0e62e12 100644
--- a/src/test/java/FileAuditingTest.java
+++ b/src/test/java/FileAuditingTest.java
@@ -23,10 +23,6 @@
@AfterClass
public static void finish() {
BeanConfiguration.closeApplication();
-// File f = new File("logs/default_audit.log");
-// System.out.println("------------------------------------------------------");
-// System.out.println("FILE LENGTH "+f.length());
-// assert f.length() > 0;
}
@Test
diff --git a/src/test/java/UserdataTest.java b/src/test/java/UserdataTest.java
index f8cd1b9..c3cc6b8 100644
--- a/src/test/java/UserdataTest.java
+++ b/src/test/java/UserdataTest.java
@@ -1,6 +1,7 @@
import de.ids_mannheim.korap.config.BeanConfiguration;
import de.ids_mannheim.korap.exceptions.KustvaktException;
import de.ids_mannheim.korap.handlers.UserDetailsDao;
+import de.ids_mannheim.korap.handlers.UserSettingsDao;
import de.ids_mannheim.korap.interfaces.db.UserDataDbIface;
import de.ids_mannheim.korap.user.*;
import org.junit.AfterClass;
@@ -28,7 +29,10 @@
public void clear() {
UserDetailsDao dao = new UserDetailsDao(
BeanConfiguration.getBeans().getPersistenceClient());
+ UserSettingsDao sdao = new UserSettingsDao(
+ BeanConfiguration.getBeans().getPersistenceClient());
assert dao.deleteAll() != -1;
+ assert sdao.deleteAll() != -1;
}
@Test
@@ -87,8 +91,7 @@
@Test
public void testUserdatafactory() throws KustvaktException {
- UserDataDbIface dao = UserdataFactory
- .getDaoInstance(UserDetails.class);
+ UserDataDbIface dao = UserdataFactory.getDaoInstance(UserDetails.class);
assert UserDetailsDao.class.equals(dao.getClass());
}
diff --git a/src/test/java/de/ids_mannheim/korap/config/TestHelper.java b/src/test/java/de/ids_mannheim/korap/config/TestHelper.java
index c96906d..c1e2cd1 100644
--- a/src/test/java/de/ids_mannheim/korap/config/TestHelper.java
+++ b/src/test/java/de/ids_mannheim/korap/config/TestHelper.java
@@ -54,6 +54,17 @@
return r;
}
+ public static User getUser() {
+ if (BeanConfiguration.hasContext()) {
+ try {
+ return BeanConfiguration.getBeans().getUserDBHandler()
+ .getAccount(credentials[0]);
+ }catch (KustvaktException e) {
+ }
+ }
+ throw new RuntimeException("User could not be retrieved!");
+ }
+
public static boolean dropUser() {
boolean r = BeanConfiguration.hasContext();
if (r) {
@@ -126,7 +137,8 @@
// don't do anything!
}
}
- }
+ }else
+ throw new RuntimeException("Client not setup properly!");
}
private TestHelper() {
diff --git a/src/test/java/de/ids_mannheim/korap/web/service/KustvaktCoreRestTest.java b/src/test/java/de/ids_mannheim/korap/web/service/KustvaktCoreRestTest.java
index 57d0a3d..d42a446 100644
--- a/src/test/java/de/ids_mannheim/korap/web/service/KustvaktCoreRestTest.java
+++ b/src/test/java/de/ids_mannheim/korap/web/service/KustvaktCoreRestTest.java
@@ -17,7 +17,6 @@
* @author hanl
* @date 26/06/2015
*/
-//todo: check tranferable index config path for test cases
public class KustvaktCoreRestTest extends FastJerseyTest {
@BeforeClass
@@ -83,6 +82,7 @@
}
@Test
+ @Ignore
public void testGetStats2ThrowsNoException() {
ClientResponse response = resource().path(getAPIVersion()).path("stats")
.post(ClientResponse.class, "creationDate in 1787");
diff --git a/src/test/java/de/ids_mannheim/korap/web/service/OAuth2EndpointTest.java b/src/test/java/de/ids_mannheim/korap/web/service/OAuth2EndpointTest.java
index 576eee0..f0865b6 100644
--- a/src/test/java/de/ids_mannheim/korap/web/service/OAuth2EndpointTest.java
+++ b/src/test/java/de/ids_mannheim/korap/web/service/OAuth2EndpointTest.java
@@ -9,18 +9,21 @@
import de.ids_mannheim.korap.utils.JsonUtils;
import org.junit.AfterClass;
import org.junit.BeforeClass;
+import org.junit.Ignore;
+import org.junit.Test;
/**
* @author hanl
* @date 23/09/2015
*/
-// todo: needs servlet container test server!
+// todo: in combination with other tests, causes failures!
public class OAuth2EndpointTest extends FastJerseyTest {
private static String[] credentials;
@AfterClass
public static void close() {
+ System.out.println("RUNNING AFTER CLASS SHUTDOWN");
TestHelper.dropUser();
BeanConfiguration.closeApplication();
}
@@ -36,7 +39,13 @@
credentials = TestHelper.getUserCredentials();
}
-// @Test
+ @Test
+ public void init() {
+
+ }
+
+ @Test
+ @Ignore
public void testAuthorizeClient() {
ClientResponse response = resource().path("v0.1").path("oauth2")
.path("register")
@@ -46,7 +55,8 @@
assert response.getStatus() == ClientResponse.Status.OK.getStatusCode();
}
-// @Test
+ @Test
+ @Ignore
public void testRevokeClient() {
ClientResponse response = resource().path("v0.1").path("oauth2")
.path("register")
@@ -58,7 +68,8 @@
}
-// @Test
+ @Test
+ @Ignore
public void authenticate() {
String enc = BasicHttpAuth.encode(credentials[0], credentials[1]);
ClientResponse response = resource().path("v0.1").path("oauth2")
@@ -79,7 +90,7 @@
.queryParam("client_secret", cl_s)
.queryParam("response_type", "code")
.queryParam("redirect_uri", "korap.ids-mannheim.de/redirect")
-// .header(Attributes.AUTHORIZATION, enc)
+ // .header(Attributes.AUTHORIZATION, enc)
.header("Content-Type", "application/x-www-form-urlencoded")
.post(ClientResponse.class);
diff --git a/src/test/java/de/ids_mannheim/korap/web/service/OAuth2HandlerTest.java b/src/test/java/de/ids_mannheim/korap/web/service/OAuth2HandlerTest.java
index f0d3d2a..a804d69 100644
--- a/src/test/java/de/ids_mannheim/korap/web/service/OAuth2HandlerTest.java
+++ b/src/test/java/de/ids_mannheim/korap/web/service/OAuth2HandlerTest.java
@@ -3,10 +3,10 @@
import de.ids_mannheim.korap.config.AuthCodeInfo;
import de.ids_mannheim.korap.config.BeanConfiguration;
import de.ids_mannheim.korap.config.ClientInfo;
+import de.ids_mannheim.korap.config.TestHelper;
import de.ids_mannheim.korap.exceptions.KustvaktException;
import de.ids_mannheim.korap.handlers.OAuth2Handler;
import de.ids_mannheim.korap.interfaces.EncryptionIface;
-import de.ids_mannheim.korap.user.KorAPUser;
import de.ids_mannheim.korap.user.TokenContext;
import de.ids_mannheim.korap.user.User;
import org.junit.AfterClass;
@@ -25,7 +25,7 @@
private static OAuth2Handler handler;
private static EncryptionIface crypto;
private static final String SCOPES = "search preferences queries account";
- private static final KorAPUser user = User.UserFactory.getUser("test_user");
+ private static User user;
@BeforeClass
public static void setup() throws KustvaktException {
@@ -39,8 +39,8 @@
info.setUrl("http://localhost:8080/api/v0.1");
info.setRedirect_uri("testwebsite/login");
- user.setPassword("testPassword123");
- BeanConfiguration.getBeans().getUserDBHandler().createAccount(user);
+ TestHelper.setupUser();
+ user = TestHelper.getUser();
handler.registerClient(info, user);
}
@@ -48,8 +48,7 @@
public static void drop() throws KustvaktException {
assert handler != null;
handler.removeClient(info, user);
- BeanConfiguration.getBeans().getUserDBHandler()
- .deleteAccount(user.getId());
+ TestHelper.dropUser();
BeanConfiguration.closeApplication();
}