Skip to content

Commit

Permalink
Removed redirect uri from InstalledPluginDto & updated tests.
Browse files Browse the repository at this point in the history
Change-Id: Ica0d3730acb4135725ddd22f34267ee1cc0a1e59
  • Loading branch information
margaretha committed Jun 11, 2024
1 parent 60b65d4 commit 1ef2a03
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 18 deletions.
3 changes: 2 additions & 1 deletion Changes
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ public class InstalledPluginDto {
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;

Expand All @@ -33,6 +33,6 @@ public InstalledPluginDto (InstalledPlugin plugin) {
setName(client.getName());
setDescription(client.getDescription());
setUrl(client.getUrl());
setRedirectUri(client.getRedirectURI());
// setRedirectUri(client.getRedirectURI());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,13 @@ public void testRegisterPublicClient ()
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, "");
Expand Down Expand Up @@ -498,7 +505,7 @@ private String testResetConfidentialClientSecret (String clientId,
return newClientSecret;
}

private void requestAuthorizedClientList (String userAuthHeader)
private void testListAuthorizedClients (String userAuthHeader)
throws KustvaktException {
Form form = getSuperClientForm();
form.param("authorized_only", "true");
Expand All @@ -510,8 +517,8 @@ private void requestAuthorizedClientList (String userAuthHeader)
.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());
Expand All @@ -528,7 +535,7 @@ public void testListPublicClient () throws KustvaktException {
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(),
Expand All @@ -542,7 +549,7 @@ public void testListPublicClient () throws KustvaktException {

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");
Expand Down Expand Up @@ -582,7 +589,7 @@ public void testListUserClients () throws KustvaktException {
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);
Expand All @@ -607,7 +614,7 @@ private void testListAuthorizedClientWithMultipleRefreshTokens (
Response response = requestTokenWithAuthorizationCodeAndForm(
confidentialClientId, clientSecret, code);
assertEquals(Status.OK.getStatusCode(), response.getStatus());
requestAuthorizedClientList(userAuthHeader);
testListAuthorizedClients(userAuthHeader);
}

private void testListAuthorizedClientWithMultipleAccessTokens (
Expand All @@ -617,7 +624,7 @@ private void testListAuthorizedClientWithMultipleAccessTokens (
Response response = requestTokenWithAuthorizationCodeAndForm(
publicClientId, "", code);
assertEquals(Status.OK.getStatusCode(), response.getStatus());
requestAuthorizedClientList(userAuthHeader);
testListAuthorizedClients(userAuthHeader);
}

private void testListWithClientsFromAnotherUser (String userAuthHeader)
Expand All @@ -637,8 +644,8 @@ private void testListWithClientsFromAnotherUser (String userAuthHeader)
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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,10 @@ public void testRegisterPlugin ()
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());
Expand All @@ -93,8 +94,7 @@ public void testRegisterPublicPlugin () throws KustvaktException {
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());
Expand All @@ -113,7 +113,7 @@ private void testRetrievePluginInfo (String clientId,
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());
Expand Down Expand Up @@ -457,8 +457,17 @@ public void testListUserInstalledPlugins ()
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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ protected void testRevokeToken (String token, String clientId,
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")
Expand Down

0 comments on commit 1ef2a03

Please sign in to comment.