Removed redirect uri from InstalledPluginDto & updated tests.
Change-Id: Ica0d3730acb4135725ddd22f34267ee1cc0a1e59
diff --git a/Changes b/Changes
index a7d713a..f9e67dc 100644
--- a/Changes
+++ b/Changes
@@ -1,4 +1,4 @@
-# version 0.73.2-SNAPSHOT
+# version 0.73.2
- Added tests for the DNB scenario with custom max match
and context size. (#745)
@@ -7,6 +7,7 @@
- Added deprecation warning for the old matchInfo service (#757)
- Fixed empty named VC path in configuration (solves #754)
- Restrict registration info for plugins (solves #572)
+- Removed redirect uri from InstalledPluginDto & updated tests.
# version 0.73.1
diff --git a/src/main/java/de/ids_mannheim/korap/dto/InstalledPluginDto.java b/src/main/java/de/ids_mannheim/korap/dto/InstalledPluginDto.java
index ac31ba0..c792b8b 100644
--- a/src/main/java/de/ids_mannheim/korap/dto/InstalledPluginDto.java
+++ b/src/main/java/de/ids_mannheim/korap/dto/InstalledPluginDto.java
@@ -20,8 +20,8 @@
private String name;
private String description;
private String url;
- @JsonProperty("redirect_uri")
- private String redirectUri;
+// @JsonProperty("redirect_uri")
+// private String redirectUri;
@JsonProperty("installed_date")
private String installedDate;
@@ -33,6 +33,6 @@
setName(client.getName());
setDescription(client.getDescription());
setUrl(client.getUrl());
- setRedirectUri(client.getRedirectURI());
+// setRedirectUri(client.getRedirectURI());
}
}
diff --git a/src/test/java/de/ids_mannheim/korap/web/controller/OAuth2ClientControllerTest.java b/src/test/java/de/ids_mannheim/korap/web/controller/OAuth2ClientControllerTest.java
index 6c8652d..20179fb 100644
--- a/src/test/java/de/ids_mannheim/korap/web/controller/OAuth2ClientControllerTest.java
+++ b/src/test/java/de/ids_mannheim/korap/web/controller/OAuth2ClientControllerTest.java
@@ -291,6 +291,13 @@
String clientId = node.at("/client_id").asText();
assertNotNull(clientId);
assertTrue(node.at("/client_secret").isMissingNode());
+
+ node = listUserClients(username);
+ assertFalse(node.at("/0/client_redirect_uri").isMissingNode());
+ assertFalse(node.at("/0/registration_date").isMissingNode());
+ assertEquals(username,
+ node.at("/0/registered_by").asText());
+
testRegisterClientUnauthorizedScope(clientId);
testResetPublicClientSecret(clientId);
testAccessTokenAfterDeregistration(clientId, null, "");
@@ -498,7 +505,7 @@
return newClientSecret;
}
- private void requestAuthorizedClientList (String userAuthHeader)
+ private void testListAuthorizedClients (String userAuthHeader)
throws KustvaktException {
Form form = getSuperClientForm();
form.param("authorized_only", "true");
@@ -510,8 +517,8 @@
.post(Entity.form(form));
assertEquals(Status.OK.getStatusCode(), response.getStatus());
String entity = response.readEntity(String.class);
- // System.out.println(entity);
JsonNode node = JsonUtils.readTree(entity);
+
assertEquals(2, node.size());
assertEquals(confidentialClientId, node.at("/0/client_id").asText());
assertEquals(publicClientId, node.at("/1/client_id").asText());
@@ -528,7 +535,7 @@
OAuth2ClientJson json = createOAuth2ClientJson(clientName,
OAuth2ClientType.PUBLIC, "Dory's client.");
registerClient("dory", json);
- JsonNode node = listUserRegisteredClients("dory");
+ JsonNode node = listUserClients("dory");
assertEquals(1, node.size());
assertEquals(clientName, node.at("/0/client_name").asText());
assertEquals(OAuth2ClientType.PUBLIC.name(),
@@ -542,7 +549,7 @@
private void testListConfidentialClient (String username, String clientId)
throws ProcessingException, KustvaktException {
- JsonNode node = listUserRegisteredClients(username);
+ JsonNode node = listUserClients(username);
assertEquals(1, node.size());
assertEquals(clientId, node.at("/0/client_id").asText());
assertEquals(node.at("/0/client_name").asText(), "OAuth2ClientTest");
@@ -582,7 +589,7 @@
confidentialClientId, clientSecret, code);
String refreshToken = node.at("/refresh_token").asText();
assertEquals(Status.OK.getStatusCode(), response.getStatus());
- requestAuthorizedClientList(userAuthHeader);
+ testListAuthorizedClients(userAuthHeader);
testListAuthorizedClientWithMultipleRefreshTokens(userAuthHeader);
testListAuthorizedClientWithMultipleAccessTokens(userAuthHeader);
testListWithClientsFromAnotherUser(userAuthHeader);
@@ -607,7 +614,7 @@
Response response = requestTokenWithAuthorizationCodeAndForm(
confidentialClientId, clientSecret, code);
assertEquals(Status.OK.getStatusCode(), response.getStatus());
- requestAuthorizedClientList(userAuthHeader);
+ testListAuthorizedClients(userAuthHeader);
}
private void testListAuthorizedClientWithMultipleAccessTokens (
@@ -617,7 +624,7 @@
Response response = requestTokenWithAuthorizationCodeAndForm(
publicClientId, "", code);
assertEquals(Status.OK.getStatusCode(), response.getStatus());
- requestAuthorizedClientList(userAuthHeader);
+ testListAuthorizedClients(userAuthHeader);
}
private void testListWithClientsFromAnotherUser (String userAuthHeader)
@@ -637,8 +644,8 @@
node = JsonUtils.readTree(response.readEntity(String.class));
String accessToken2 = node.at("/access_token").asText();
String refreshToken = node.at("/refresh_token").asText();
- requestAuthorizedClientList(aaaAuthHeader);
- requestAuthorizedClientList(userAuthHeader);
+ testListAuthorizedClients(aaaAuthHeader);
+ testListAuthorizedClients(userAuthHeader);
testRevokeAllTokenViaSuperClient(publicClientId, aaaAuthHeader,
accessToken1);
testRevokeAllTokenViaSuperClient(confidentialClientId, aaaAuthHeader,
diff --git a/src/test/java/de/ids_mannheim/korap/web/controller/OAuth2PluginTest.java b/src/test/java/de/ids_mannheim/korap/web/controller/OAuth2PluginTest.java
index d72787f..a8c2139 100644
--- a/src/test/java/de/ids_mannheim/korap/web/controller/OAuth2PluginTest.java
+++ b/src/test/java/de/ids_mannheim/korap/web/controller/OAuth2PluginTest.java
@@ -66,9 +66,10 @@
assertNotNull(clientId);
assertNotNull(clientSecret);
testInstallPluginNotPermitted(clientId);
- testRetrievePluginInfo(clientId, refreshTokenExpiry);
+ testRetrievePluginInfo(clientId);
node = listPlugins(false);
assertEquals(3, node.size());
+
// permitted only
node = listPlugins(true);
assertEquals(2, node.size());
@@ -93,8 +94,7 @@
assertFalse(node.at("/error_description").isMissingNode());
}
- private void testRetrievePluginInfo (String clientId,
- int refreshTokenExpiry)
+ private void testRetrievePluginInfo (String clientId)
throws ProcessingException, KustvaktException {
JsonNode clientInfo = retrieveClientInfo(clientId, "other-user");
assertEquals(clientId, clientInfo.at("/client_id").asText());
@@ -113,7 +113,7 @@
private void testListUserRegisteredPlugins (String username,
String clientId, String clientName, int refreshTokenExpiry)
throws ProcessingException, KustvaktException {
- JsonNode node = listUserRegisteredClients(username);
+ JsonNode node = listUserClients(username);
assertEquals(1, node.size());
assertEquals(clientId, node.at("/0/client_id").asText());
assertEquals(clientName, node.at("/0/client_name").asText());
@@ -457,8 +457,17 @@
testSearchWithOAuth2Token(accessToken);
testInstallConfidentialPlugin(superClientId, confidentialClientId2,
username);
+
node = retrieveUserInstalledPlugin(getSuperClientForm());
assertEquals(2, node.size());
+ assertFalse(node.at("/0/name").isMissingNode());
+ assertFalse(node.at("/0/description").isMissingNode());
+ assertFalse(node.at("/0/url").isMissingNode());
+ assertFalse(node.at("/0/client_id").isMissingNode());
+ assertFalse(node.at("/0/super_client_id").isMissingNode());
+ assertFalse(node.at("/0/installed_date").isMissingNode());
+ assertTrue(node.at("/0/redirect_uri").isMissingNode());
+
Response response = uninstallPlugin(confidentialClientId, username);
assertEquals(Status.OK.getStatusCode(), response.getStatus());
node = retrieveUserInstalledPlugin(getSuperClientForm());
diff --git a/src/test/java/de/ids_mannheim/korap/web/controller/OAuth2TestBase.java b/src/test/java/de/ids_mannheim/korap/web/controller/OAuth2TestBase.java
index bd57686..4ce03d1 100644
--- a/src/test/java/de/ids_mannheim/korap/web/controller/OAuth2TestBase.java
+++ b/src/test/java/de/ids_mannheim/korap/web/controller/OAuth2TestBase.java
@@ -430,7 +430,7 @@
assertEquals("SUCCESS", response.readEntity(String.class));
}
- protected JsonNode listUserRegisteredClients (String username)
+ protected JsonNode listUserClients (String username)
throws ProcessingException, KustvaktException {
Form form = getSuperClientForm();
Response response = target().path(API_VERSION).path("oauth2")