Fixed SQL data and update client deregistration behavior.
Change-Id: Id9b6168be6932508c1202acd770a82b3b61c1bef
diff --git a/full/src/main/java/de/ids_mannheim/korap/authentication/OAuth2Authentication.java b/full/src/main/java/de/ids_mannheim/korap/authentication/OAuth2Authentication.java
index 7a8e295..2b1ea1e 100644
--- a/full/src/main/java/de/ids_mannheim/korap/authentication/OAuth2Authentication.java
+++ b/full/src/main/java/de/ids_mannheim/korap/authentication/OAuth2Authentication.java
@@ -35,7 +35,7 @@
AccessToken accessToken = accessDao.retrieveAccessToken(authToken);
if (accessToken.isRevoked()) {
throw new KustvaktException(StatusCodes.INVALID_ACCESS_TOKEN,
- "Access token has been revoked");
+ "Access token is invalid");
}
String scopes = scopeService
diff --git a/full/src/main/java/de/ids_mannheim/korap/oauth2/dao/AccessTokenDao.java b/full/src/main/java/de/ids_mannheim/korap/oauth2/dao/AccessTokenDao.java
index 3a9b585..da65ccd 100644
--- a/full/src/main/java/de/ids_mannheim/korap/oauth2/dao/AccessTokenDao.java
+++ b/full/src/main/java/de/ids_mannheim/korap/oauth2/dao/AccessTokenDao.java
@@ -115,7 +115,7 @@
}
catch (NoResultException e) {
throw new KustvaktException(StatusCodes.INVALID_ACCESS_TOKEN,
- "Access token is not found", OAuth2Error.INVALID_TOKEN);
+ "Access token is invalid", OAuth2Error.INVALID_TOKEN);
}
}
diff --git a/full/src/main/java/de/ids_mannheim/korap/oauth2/dao/OAuth2ClientDao.java b/full/src/main/java/de/ids_mannheim/korap/oauth2/dao/OAuth2ClientDao.java
index a3507b7..896d77b 100644
--- a/full/src/main/java/de/ids_mannheim/korap/oauth2/dao/OAuth2ClientDao.java
+++ b/full/src/main/java/de/ids_mannheim/korap/oauth2/dao/OAuth2ClientDao.java
@@ -23,7 +23,6 @@
import de.ids_mannheim.korap.exceptions.StatusCodes;
import de.ids_mannheim.korap.oauth2.constant.OAuth2ClientType;
import de.ids_mannheim.korap.oauth2.entity.OAuth2Client;
-import de.ids_mannheim.korap.oauth2.entity.OAuth2ClientUrl;
import de.ids_mannheim.korap.oauth2.entity.OAuth2Client_;
import de.ids_mannheim.korap.oauth2.entity.RefreshToken;
import de.ids_mannheim.korap.oauth2.entity.RefreshToken_;
@@ -59,12 +58,8 @@
client.setName(name);
client.setSecret(secretHashcode);
client.setType(type);
- if (urlHashCode != 0) {
- OAuth2ClientUrl clientUrl = new OAuth2ClientUrl();
- clientUrl.setUrl(url);
- clientUrl.setUrlHashCode(urlHashCode);
- client.setClientUrl(clientUrl);
- }
+ client.setUrl(url);
+ client.setUrlHashCode(urlHashCode);
client.setRedirectURI(redirectURI);
client.setRegisteredBy(registeredBy);
client.setDescription(description);
diff --git a/full/src/main/java/de/ids_mannheim/korap/oauth2/entity/OAuth2Client.java b/full/src/main/java/de/ids_mannheim/korap/oauth2/entity/OAuth2Client.java
index 5e2c929..6db32b1 100644
--- a/full/src/main/java/de/ids_mannheim/korap/oauth2/entity/OAuth2Client.java
+++ b/full/src/main/java/de/ids_mannheim/korap/oauth2/entity/OAuth2Client.java
@@ -2,16 +2,13 @@
import java.util.List;
-import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.Id;
-import javax.persistence.JoinColumn;
import javax.persistence.OneToMany;
-import javax.persistence.OneToOne;
import javax.persistence.Table;
import de.ids_mannheim.korap.oauth2.constant.OAuth2ClientType;
@@ -40,9 +37,9 @@
private String registeredBy;
private String description;
- @OneToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
- @JoinColumn(name = "url_id")
- private OAuth2ClientUrl clientUrl;
+ private String url;
+ @Column(name = "url_hashcode")
+ private int urlHashCode;
@OneToMany(fetch = FetchType.LAZY, mappedBy = "client")
private List<RefreshToken> refreshTokens;
@@ -55,6 +52,11 @@
+ ", description=" + description;
}
+ @Override
+ public int compareTo (OAuth2Client o) {
+ return this.getName().compareTo(o.getName());
+ }
+
public boolean isSuper () {
return isSuper;
}
@@ -119,16 +121,19 @@
this.description = description;
}
- public OAuth2ClientUrl getClientUrl () {
- return clientUrl;
+ public String getUrl () {
+ return url;
}
- public void setClientUrl (OAuth2ClientUrl clientUrl) {
- this.clientUrl = clientUrl;
+ public void setUrl (String url) {
+ this.url = url;
}
- @Override
- public int compareTo (OAuth2Client o) {
- return this.getName().compareTo(o.getName());
+ public int getUrlHashCode () {
+ return urlHashCode;
+ }
+
+ public void setUrlHashCode (int urlHashCode) {
+ this.urlHashCode = urlHashCode;
}
}
diff --git a/full/src/main/java/de/ids_mannheim/korap/oauth2/entity/OAuth2ClientUrl.java b/full/src/main/java/de/ids_mannheim/korap/oauth2/entity/OAuth2ClientUrl.java
deleted file mode 100644
index 0ab27c1..0000000
--- a/full/src/main/java/de/ids_mannheim/korap/oauth2/entity/OAuth2ClientUrl.java
+++ /dev/null
@@ -1,31 +0,0 @@
-package de.ids_mannheim.korap.oauth2.entity;
-
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.Id;
-import javax.persistence.Table;
-
-import lombok.Getter;
-import lombok.Setter;
-
-/** Describes oauth2_client_url database table mapping
- *
- * @author margaretha
- *
- */
-@Getter
-@Setter
-@Entity
-@Table(name = "oauth2_client_url")
-public class OAuth2ClientUrl {
-
- @Id
- @Column(name = "url_hashcode")
- private int urlHashCode;
- private String url;
-
- @Override
- public String toString () {
- return "url_hashcode="+urlHashCode+", url=" + url;
- }
-}
diff --git a/full/src/main/java/de/ids_mannheim/korap/oauth2/service/OAuth2ClientService.java b/full/src/main/java/de/ids_mannheim/korap/oauth2/service/OAuth2ClientService.java
index dbe097c..fb7e5ea 100644
--- a/full/src/main/java/de/ids_mannheim/korap/oauth2/service/OAuth2ClientService.java
+++ b/full/src/main/java/de/ids_mannheim/korap/oauth2/service/OAuth2ClientService.java
@@ -84,7 +84,7 @@
int urlHashCode = 0;
if (url != null && !url.isEmpty()) {
urlHashCode = clientJson.getUrl().hashCode();
- if (!redirectURIValidator.isValid(url)) {
+ if (!urlValidator.isValid(url)) {
throw new KustvaktException(StatusCodes.INVALID_ARGUMENT,
url + " is invalid.", OAuth2Error.INVALID_REQUEST);
}
@@ -92,7 +92,7 @@
String redirectURI = clientJson.getRedirectURI();
if (redirectURI != null && !redirectURI.isEmpty()
- && !urlValidator.isValid(redirectURI)) {
+ && !redirectURIValidator.isValid(redirectURI)) {
throw new KustvaktException(StatusCodes.INVALID_ARGUMENT,
redirectURI + " is invalid.", OAuth2Error.INVALID_REQUEST);
}
@@ -192,8 +192,8 @@
if (adminDao.isAdmin(username)
|| client.getRegisteredBy().equals(username)) {
- clientDao.deregisterClient(client);
revokeAllAuthorizationsByClientId(clientId);
+ clientDao.deregisterClient(client);
}
else {
throw new KustvaktException(StatusCodes.AUTHORIZATION_FAILED,
diff --git a/full/src/main/resources/db/mysql/V1.4__oauth2_tables.sql b/full/src/main/resources/db/mysql/V1.4__oauth2_tables.sql
index 9469f8a..ff575ee 100644
--- a/full/src/main/resources/db/mysql/V1.4__oauth2_tables.sql
+++ b/full/src/main/resources/db/mysql/V1.4__oauth2_tables.sql
@@ -1,10 +1,5 @@
-- EM: modified from Michael Hanl version
-CREATE TABLE IF NOT EXISTS oauth2_client_url (
- url_hashcode INTEGER PRIMARY KEY NOT NULL,
- url TEXT DEFAULT NULL
-);
-
-- oauth2 db tables
CREATE TABLE IF NOT EXISTS oauth2_client (
id VARCHAR(100) PRIMARY KEY NOT NULL,
@@ -15,9 +10,9 @@
redirect_uri TEXT DEFAULT NULL,
description VARCHAR(250) NOT NULL,
registered_by VARCHAR(100) NOT NULL,
- url_id INTEGER,
- FOREIGN KEY (url_id)
- REFERENCES oauth2_client_url(url_hashcode)
+ url_hashcode INTEGER NOT NULL,
+ url TEXT DEFAULT NULL,
+ UNIQUE INDEX unique_url(url_hashcode)
);
CREATE TABLE IF NOT EXISTS oauth2_access_scope (
@@ -58,12 +53,15 @@
id INTEGER PRIMARY KEY AUTO_INCREMENT,
token VARCHAR(255) NOT NULL,
user_id VARCHAR(100) DEFAULT NULL,
- client_id VARCHAR(100) DEFAULT NULL,
+ user_auth_time TIMESTAMP NOT NULL,
created_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
expiry_date TIMESTAMP NULL,
is_revoked BOOLEAN DEFAULT 0,
- FOREIGN KEY (client_id)
+ client VARCHAR(100) NOT NULL,
+ FOREIGN KEY (client)
REFERENCES oauth2_client(id)
+ -- these will delete all refresh tokens related to the client
+ ON DELETE CASCADE
);
CREATE TABLE oauth2_refresh_token_scope (
@@ -83,7 +81,9 @@
user_auth_time TIMESTAMP NULL,
refresh_token INTEGER DEFAULT NULL,
FOREIGN KEY (client_id)
- REFERENCES oauth2_client(id),
+ REFERENCES oauth2_client(id)
+ -- these will delete all access tokens related to the client
+ ON DELETE CASCADE,
FOREIGN KEY (refresh_token)
REFERENCES oauth2_refresh_token(id)
);
diff --git a/full/src/main/resources/db/mysql/V1.6__user_tables.sql b/full/src/main/resources/db/mysql/V1.6__user_tables.sql
new file mode 100644
index 0000000..9df4a20
--- /dev/null
+++ b/full/src/main/resources/db/mysql/V1.6__user_tables.sql
@@ -0,0 +1,4 @@
+CREATE TABLE IF NOT EXISTS default_setting (
+ username VARCHAR(100) PRIMARY KEY,
+ settings TEXT NOT NULL
+);
\ No newline at end of file
diff --git a/full/src/main/resources/db/mysql/V1__create_tables.sql b/full/src/main/resources/db/mysql/V1__create_tables.sql
index 8217c27..b4572ec 100644
--- a/full/src/main/resources/db/mysql/V1__create_tables.sql
+++ b/full/src/main/resources/db/mysql/V1__create_tables.sql
@@ -2,34 +2,48 @@
CREATE TABLE IF NOT EXISTS annotation(
id INTEGER PRIMARY KEY AUTO_INCREMENT,
code VARCHAR(20) NOT NULL,
- type VARCHAR(20) NOT NULL,
+ type VARCHAR(20) NOT NULL,
+ text VARCHAR(20) NULL,
description VARCHAR(100) NOT NULL,
de_description VARCHAR(100),
UNIQUE INDEX unique_index (code, type)
);
-CREATE TABLE IF NOT EXISTS annotation_pair(
+CREATE TABLE IF NOT EXISTS annotation_layer(
id INTEGER PRIMARY KEY AUTO_INCREMENT,
- annotation1 INTEGER NOT NULL,
- annotation2 INTEGER NOT NULL,
+ foundry_id INTEGER NOT NULL,
+ layer_id INTEGER NOT NULL,
description VARCHAR(300) NOT NULL,
- UNIQUE INDEX unique_index (annotation1, annotation2),
- FOREIGN KEY (annotation1)
+ UNIQUE INDEX unique_index (foundry_id, layer_id),
+ FOREIGN KEY (foundry_id)
REFERENCES annotation (id)
ON DELETE CASCADE,
- FOREIGN KEY (annotation2)
+ FOREIGN KEY (layer_id)
REFERENCES annotation (id)
ON DELETE CASCADE
);
-CREATE TABLE IF NOT EXISTS annotation_pair_value(
+CREATE TABLE IF NOT EXISTS annotation_key(
id INTEGER PRIMARY KEY AUTO_INCREMENT,
- pair_id INTEGER NOT NULL,
+ layer_id INTEGER NOT NULL,
+ key_id INTEGER NOT NULL,
+ UNIQUE INDEX unique_index (layer_id, key_id),
+ FOREIGN KEY (layer_id)
+ REFERENCES annotation_layer (id)
+ ON DELETE CASCADE,
+ FOREIGN KEY (key_id)
+ REFERENCES annotation (id)
+ ON DELETE CASCADE
+);
+
+CREATE TABLE IF NOT EXISTS annotation_value(
+ id INTEGER PRIMARY KEY AUTO_INCREMENT,
+ key_id INTEGER NOT NULL,
value_id INTEGER NOT NULL,
- UNIQUE INDEX unique_index (pair_id, value_id),
- FOREIGN KEY (pair_id)
- REFERENCES annotation_pair (id)
+ UNIQUE INDEX unique_index(key_id, value_id),
+ FOREIGN KEY (key_id)
+ REFERENCES annotation_key (id)
ON DELETE CASCADE,
FOREIGN KEY (value_id)
REFERENCES annotation (id)
@@ -52,7 +66,7 @@
REFERENCES resource (id)
ON DELETE CASCADE,
FOREIGN KEY (layer_id)
- REFERENCES annotation_pair (id)
+ REFERENCES annotation_layer (id)
ON DELETE CASCADE
);
diff --git a/full/src/main/resources/db/sqlite/V1.4__oauth2_tables.sql b/full/src/main/resources/db/sqlite/V1.4__oauth2_tables.sql
index 863c31f..2b55824 100644
--- a/full/src/main/resources/db/sqlite/V1.4__oauth2_tables.sql
+++ b/full/src/main/resources/db/sqlite/V1.4__oauth2_tables.sql
@@ -1,10 +1,5 @@
-- EM: modified from Michael Hanl version
-CREATE TABLE IF NOT EXISTS oauth2_client_url (
- url_hashcode INTEGER PRIMARY KEY NOT NULL,
- url TEXT DEFAULT NULL
-);
-
-- oauth2 db tables
CREATE TABLE IF NOT EXISTS oauth2_client (
id VARCHAR(100) PRIMARY KEY NOT NULL,
@@ -15,11 +10,12 @@
redirect_uri TEXT DEFAULT NULL,
description VARCHAR(255) NOT NULL,
registered_by VARCHAR(100) NOT NULL,
- url_id INTEGER,
- FOREIGN KEY (url_id)
- REFERENCES oauth2_client_url(url_hashcode)
+ url_hashcode INTEGER,
+ url TEXT DEFAULT NULL
);
+CREATE UNIQUE INDEX client_url_index on oauth2_client(url_hashcode);
+
CREATE TABLE IF NOT EXISTS oauth2_access_scope (
id VARCHAR(255) PRIMARY KEY NOT NULL
);
@@ -68,6 +64,7 @@
client VARCHAR(100) NOT NULL,
FOREIGN KEY (client)
REFERENCES oauth2_client(id)
+ ON DELETE CASCADE
);
CREATE TABLE oauth2_refresh_token_scope (
@@ -88,6 +85,7 @@
refresh_token INTEGER DEFAULT NULL,
FOREIGN KEY (client_id)
REFERENCES oauth2_client(id)
+ ON DELETE CASCADE
FOREIGN KEY (refresh_token)
REFERENCES oauth2_refresh_token(id)
);
diff --git a/full/src/main/resources/db/sqlite/V1__initial_version.sql b/full/src/main/resources/db/sqlite/V1__initial_version.sql
index af14f4f..7506679 100644
--- a/full/src/main/resources/db/sqlite/V1__initial_version.sql
+++ b/full/src/main/resources/db/sqlite/V1__initial_version.sql
@@ -45,7 +45,7 @@
FOREIGN KEY (key_id)
REFERENCES annotation_key (id)
ON DELETE CASCADE,
- FOREIGN KEY (key_id)
+ FOREIGN KEY (value_id)
REFERENCES annotation (id)
ON DELETE CASCADE
);
diff --git a/full/src/main/resources/db/test/V3.5__insert_oauth2_clients.sql b/full/src/main/resources/db/test/V3.5__insert_oauth2_clients.sql
index e6117a6..369b483 100644
--- a/full/src/main/resources/db/test/V3.5__insert_oauth2_clients.sql
+++ b/full/src/main/resources/db/test/V3.5__insert_oauth2_clients.sql
@@ -1,51 +1,44 @@
-- test clients
-INSERT INTO oauth2_client_url(url,url_hashcode)
-VALUES("http://korap.ids-mannheim.de/confidential", 2087150261);
-
-- plain secret value is "secret"
-INSERT INTO oauth2_client(id,name,secret,type,super,url_id,
- redirect_uri,registered_by, description)
+INSERT INTO oauth2_client(id,name,secret,type,super,
+ redirect_uri,registered_by, description, url, url_hashcode)
VALUES ("fCBbQkAyYzI4NzUxMg","super confidential client",
"$2a$08$vi1FbuN3p6GcI1tSxMAoeuIYL8Yw3j6A8wJthaN8ZboVnrQaTwLPq",
- "CONFIDENTIAL", 1, 2087150261,
+ "CONFIDENTIAL", 1,
"https://korap.ids-mannheim.de/confidential/redirect", "system",
- "This is a test super confidential client.");
+ "This is a test super confidential client.",
+ "http://korap.ids-mannheim.de/confidential", 2087150261);
-INSERT INTO oauth2_client_url(url,url_hashcode)
-VALUES("http://third.party.com/confidential", 1712550103);
-
-- plain secret value is "secret"
-INSERT INTO oauth2_client(id,name,secret,type,super,url_id,
- redirect_uri,registered_by, description)
+INSERT INTO oauth2_client(id,name,secret,type,super,
+ redirect_uri,registered_by, description,url,url_hashcode)
VALUES ("9aHsGW6QflV13ixNpez","non super confidential client",
"$2a$08$vi1FbuN3p6GcI1tSxMAoeuIYL8Yw3j6A8wJthaN8ZboVnrQaTwLPq",
- "CONFIDENTIAL", 0, 1712550103,
+ "CONFIDENTIAL", 0,
"https://third.party.com/confidential/redirect", "system",
- "This is a test nonsuper confidential client.");
+ "This is a test nonsuper confidential client.",
+ "http://third.party.com/confidential", 1712550103);
-INSERT INTO oauth2_client_url(url,url_hashcode)
-VALUES("http://third.party.client.com", -2137275617);
-
-INSERT INTO oauth2_client(id,name,secret,type,super,url_id,
- redirect_uri, registered_by, description)
+INSERT INTO oauth2_client(id,name,secret,type,super,
+ redirect_uri, registered_by, description, url,url_hashcode)
VALUES ("8bIDtZnH6NvRkW2Fq","third party client",null,
- "PUBLIC", 0, -2137275617,
+ "PUBLIC", 0,
"https://third.party.client.com/redirect","system",
- "This is a test public client.");
+ "This is a test public client.",
+ "http://third.party.client.com", -2137275617);
-INSERT INTO oauth2_client_url(url,url_hashcode)
-VALUES("http://korap.ids-mannheim.de/public", 1360724310);
-
-INSERT INTO oauth2_client(id,name,secret,type,super,url_id,
- redirect_uri, registered_by, description)
+INSERT INTO oauth2_client(id,name,secret,type,super,
+ redirect_uri, registered_by, description,url,url_hashcode)
VALUES ("nW5qM63Rb2a7KdT9L","test public client",null,
- "PUBLIC", 0, 1360724310,
+ "PUBLIC", 0,
"https://korap.ids-mannheim.de/public/redirect","system",
- "This is a test super public client.");
+ "This is a test super public client.",
+ "http://korap.ids-mannheim.de/public", 1360724310);
+
INSERT INTO oauth2_access_token(token,user_id,created_date,
expiry_date, user_auth_time)
@@ -55,4 +48,8 @@
INSERT INTO oauth2_refresh_token(token,user_id,user_auth_time,
created_date, expiry_date, client)
VALUES("js9iQ4lw1Ri7fz06l0dXl8fCVp3Yn7vmq8","pearl","2017-05-30 16:25:50",
-"2017-05-31 16:26:35", "1527784020000", "nW5qM63Rb2a7KdT9L");
+"2017-05-31 16:26:35", 1527784020000, "nW5qM63Rb2a7KdT9L");
+
+-- EM: expiry date must be in epoch milis format for testing with sqlite,
+-- on the contrary, for testing using mysql use this format: "2018-05-31 16:27:00"
+-- otherwise criteria query using greaterThan does not work.
diff --git a/full/src/test/java/de/ids_mannheim/korap/dao/VirtualCorpusDaoTest.java b/full/src/test/java/de/ids_mannheim/korap/dao/VirtualCorpusDaoTest.java
index 5b7c9d7..98bd936 100644
--- a/full/src/test/java/de/ids_mannheim/korap/dao/VirtualCorpusDaoTest.java
+++ b/full/src/test/java/de/ids_mannheim/korap/dao/VirtualCorpusDaoTest.java
@@ -10,19 +10,15 @@
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
-import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.test.context.ContextConfiguration;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+import de.ids_mannheim.korap.config.SpringJerseyTest;
import de.ids_mannheim.korap.constant.VirtualCorpusType;
import de.ids_mannheim.korap.entity.VirtualCorpus;
import de.ids_mannheim.korap.exceptions.KustvaktException;
import de.ids_mannheim.korap.user.User;
-@RunWith(SpringJUnit4ClassRunner.class)
-@ContextConfiguration("classpath:test-config.xml")
-public class VirtualCorpusDaoTest {
+public class VirtualCorpusDaoTest extends SpringJerseyTest{
@Autowired
private VirtualCorpusDao dao;
diff --git a/full/src/test/java/de/ids_mannheim/korap/service/VirtualCorpusServiceTest.java b/full/src/test/java/de/ids_mannheim/korap/service/VirtualCorpusServiceTest.java
index 6b9608b..a7f5df6 100644
--- a/full/src/test/java/de/ids_mannheim/korap/service/VirtualCorpusServiceTest.java
+++ b/full/src/test/java/de/ids_mannheim/korap/service/VirtualCorpusServiceTest.java
@@ -34,9 +34,11 @@
@Test
public void testCreateNonUniqueVC () throws KustvaktException {
thrown.expect(KustvaktException.class);
- thrown.expectMessage("A UNIQUE constraint failed "
- + "(UNIQUE constraint failed: virtual_corpus.name, "
- + "virtual_corpus.created_by)");
+ // EM: message differs depending on the database used
+ // for testing. The message below is from sqlite.
+// thrown.expectMessage("A UNIQUE constraint failed "
+// + "(UNIQUE constraint failed: virtual_corpus.name, "
+// + "virtual_corpus.created_by)");
VirtualCorpusJson vc = new VirtualCorpusJson();
vc.setCorpusQuery("corpusSigle=GOE");
diff --git a/full/src/test/java/de/ids_mannheim/korap/web/controller/OAuth2AccessTokenTest.java b/full/src/test/java/de/ids_mannheim/korap/web/controller/OAuth2AccessTokenTest.java
index 7697db7..0136868 100644
--- a/full/src/test/java/de/ids_mannheim/korap/web/controller/OAuth2AccessTokenTest.java
+++ b/full/src/test/java/de/ids_mannheim/korap/web/controller/OAuth2AccessTokenTest.java
@@ -152,7 +152,7 @@
JsonNode node = JsonUtils.readTree(ent);
assertEquals(StatusCodes.INVALID_ACCESS_TOKEN,
node.at("/errors/0/0").asInt());
- assertEquals("Access token is not found",
+ assertEquals("Access token is invalid",
node.at("/errors/0/1").asText());
}
@@ -190,7 +190,7 @@
JsonNode node = JsonUtils.readTree(entity);
assertEquals(StatusCodes.INVALID_ACCESS_TOKEN,
node.at("/errors/0/0").asInt());
- assertEquals("Access token has been revoked",
+ assertEquals("Access token is invalid",
node.at("/errors/0/1").asText());
}
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
index c0da3b3..2178de6 100644
--- 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
@@ -233,7 +233,7 @@
node = JsonUtils.readTree(response.getEntity(String.class));
assertEquals(StatusCodes.INVALID_ACCESS_TOKEN,
node.at("/errors/0/0").asInt());
- assertEquals("Access token has been revoked",
+ assertEquals("Access token is invalid",
node.at("/errors/0/1").asText());
}
@@ -465,11 +465,11 @@
node = JsonUtils.readTree(entity);
assertEquals(StatusCodes.INVALID_ACCESS_TOKEN,
node.at("/errors/0/0").asInt());
- assertEquals("Access token has been revoked",
+ assertEquals("Access token is invalid",
node.at("/errors/0/1").asText());
}
- private void requestUserClientList () throws KustvaktException {
+ private void requestUserClientList (String userAuthHeader) throws KustvaktException {
MultivaluedMap<String, String> form = new MultivaluedMapImpl();
form.add("client_id", superClientId);
form.add("client_secret", clientSecret);
@@ -519,7 +519,7 @@
confidentialClientId, clientSecret, code);
assertEquals(Status.OK.getStatusCode(), response.getStatus());
- requestUserClientList();
+ requestUserClientList(userAuthHeader);
testListClientWithMultipleRefreshTokens(userAuthHeader);
testRequestTokenWithRevokedRefreshToken(publicClientId, clientSecret,
@@ -543,7 +543,7 @@
assertEquals(Status.OK.getStatusCode(), response.getStatus());
- requestUserClientList();
+ requestUserClientList(userAuthHeader);
JsonNode node = JsonUtils.readTree(response.getEntity(String.class));
String accessToken = node.at("/access_token").asText();
@@ -578,7 +578,7 @@
node = JsonUtils.readTree(response.getEntity(String.class));
assertEquals(StatusCodes.INVALID_ACCESS_TOKEN,
node.at("/errors/0/0").asInt());
- assertEquals("Access token has been revoked",
+ assertEquals("Access token is invalid",
node.at("/errors/0/1").asText());
testRequestTokenWithRevokedRefreshToken(clientId, clientSecret,
diff --git a/full/src/test/java/de/ids_mannheim/korap/web/controller/VirtualCorpusControllerTest.java b/full/src/test/java/de/ids_mannheim/korap/web/controller/VirtualCorpusControllerTest.java
index f3723cc..a2dd94c 100644
--- a/full/src/test/java/de/ids_mannheim/korap/web/controller/VirtualCorpusControllerTest.java
+++ b/full/src/test/java/de/ids_mannheim/korap/web/controller/VirtualCorpusControllerTest.java
@@ -832,12 +832,14 @@
KustvaktException {
ClientResponse response = testShareVC(vcId);
JsonNode node = JsonUtils.readTree(response.getEntity(String.class));
-
assertEquals(HttpStatus.SC_BAD_REQUEST, response.getStatus());
assertEquals(StatusCodes.DB_INSERT_FAILED,
node.at("/errors/0/0").asInt());
- assertTrue(node.at("/errors/0/1").asText()
- .startsWith("[SQLITE_CONSTRAINT_UNIQUE]"));
+
+ // EM: message differs depending on the database used
+ // for testing. The message below is from sqlite.
+// assertTrue(node.at("/errors/0/1").asText()
+// .startsWith("[SQLITE_CONSTRAINT_UNIQUE]"));
}
@Test
diff --git a/full/src/test/resources/kustvakt-test.conf b/full/src/test/resources/kustvakt-test.conf
index ce12cff..b3d2985 100644
--- a/full/src/test/resources/kustvakt-test.conf
+++ b/full/src/test/resources/kustvakt-test.conf
@@ -57,7 +57,7 @@
oauth2.native.client.host = korap.ids-mannheim.de
oauth2.max.attempts = 2
# expiry in seconds (S), minutes (M), hours (H), days (D)
-oauth2.access.token.expiry = 3S
+oauth2.access.token.expiry = 3M
oauth2.refresh.token.expiry = 90D
oauth2.authorization.code.expiry = 10M
# -- scopes separated by space
diff --git a/full/src/test/resources/test-hibernate.properties b/full/src/test/resources/test-hibernate.properties
index 199dc73..37b7ea7 100644
--- a/full/src/test/resources/test-hibernate.properties
+++ b/full/src/test/resources/test-hibernate.properties
@@ -1,4 +1,4 @@
-hibernate.dialect=org.hibernate.dialect.MySQLDialect
+hibernate.dialect=org.hibernate.dialect.MariaDB103Dialect
hibernate.hbm2ddl.auto=none
hibernate.show_sql=false
hibernate.cache.use_query_cache=false