From 1706a2cf7cd315fd19cd8b7ec3ec3209e9769a02 Mon Sep 17 00:00:00 2001 From: David Jansons Date: Mon, 3 Jun 2024 09:47:20 +1000 Subject: [PATCH] Fixed failing bitbucket integration tests - Delete unused SlackLinkUninstallPermissionResourceFilter. Use correct URI builder method in AddQueryParamSlackFunction --- ...LinkUninstallPermissionResourceFilter.java | 43 ------------------- .../slack/soy/AddQueryParamSlackFunction.java | 5 ++- 2 files changed, 4 insertions(+), 44 deletions(-) delete mode 100644 slack-server-integration-common/src/main/java/com/atlassian/plugins/slack/rest/SlackLinkUninstallPermissionResourceFilter.java diff --git a/slack-server-integration-common/src/main/java/com/atlassian/plugins/slack/rest/SlackLinkUninstallPermissionResourceFilter.java b/slack-server-integration-common/src/main/java/com/atlassian/plugins/slack/rest/SlackLinkUninstallPermissionResourceFilter.java deleted file mode 100644 index bb24d65a..00000000 --- a/slack-server-integration-common/src/main/java/com/atlassian/plugins/slack/rest/SlackLinkUninstallPermissionResourceFilter.java +++ /dev/null @@ -1,43 +0,0 @@ -package com.atlassian.plugins.slack.rest; - -import com.atlassian.plugins.slack.spi.SlackLinkAccessManager; -import com.atlassian.sal.api.user.UserManager; -import org.springframework.beans.factory.annotation.Qualifier; - -import javax.inject.Inject; -import javax.ws.rs.container.ContainerRequestContext; -import javax.ws.rs.container.ContainerRequestFilter; -import javax.ws.rs.core.Context; -import javax.ws.rs.core.UriInfo; -import javax.ws.rs.ext.Provider; - -/** - * Determines whether the user has permission to uninstall an existing Slack link. - * If not link id is provided, the default link is used. - */ -@Provider -public class SlackLinkUninstallPermissionResourceFilter implements ContainerRequestFilter { - @Context - private UriInfo uriInfo; - - private final UserManager userManager; - private final SlackLinkAccessManager slackLinkAccessManager; - - @Inject - public SlackLinkUninstallPermissionResourceFilter(@Qualifier("salUserManager") final UserManager userManager, - final SlackLinkAccessManager slackLinkAccessManager) { - this.userManager = userManager; - this.slackLinkAccessManager = slackLinkAccessManager; - } - - @Override - public void filter(final ContainerRequestContext containerRequest) { - if (!hasAccess(containerRequest)) { - throw new SecurityException("User must be an Administrator to uninstall this plugin."); - } - } - - private boolean hasAccess(final ContainerRequestContext containerRequest) { - return slackLinkAccessManager.hasAccess(userManager.getRemoteUser(), containerRequest); - } -} diff --git a/slack-server-integration-common/src/main/java/com/atlassian/plugins/slack/soy/AddQueryParamSlackFunction.java b/slack-server-integration-common/src/main/java/com/atlassian/plugins/slack/soy/AddQueryParamSlackFunction.java index 666d7347..f9e78505 100644 --- a/slack-server-integration-common/src/main/java/com/atlassian/plugins/slack/soy/AddQueryParamSlackFunction.java +++ b/slack-server-integration-common/src/main/java/com/atlassian/plugins/slack/soy/AddQueryParamSlackFunction.java @@ -3,6 +3,8 @@ import com.atlassian.soy.renderer.SoyServerFunction; import javax.ws.rs.core.UriBuilder; +import java.net.URLDecoder; +import java.nio.charset.StandardCharsets; import java.util.Collections; import java.util.Set; @@ -22,7 +24,8 @@ public Set validArgSizes() { @Override public String apply(final Object... args) { - return UriBuilder.fromUri(args[0].toString()) + String decodedUri = URLDecoder.decode(args[0].toString(), StandardCharsets.UTF_8); + return UriBuilder.fromUri(decodedUri) .replaceQueryParam(args[1].toString(), args[2].toString()) .build() .toString();