aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-auth-bitbucket
diff options
context:
space:
mode:
authorAntoine Vinot <antoine.vinot@sonarsource.com>2023-04-13 16:57:56 +0200
committersonartech <sonartech@sonarsource.com>2023-04-24 20:04:23 +0000
commit68977b2bedc95c738b58bc8be83a00d21e13c32e (patch)
tree3c77243a1b04651f6cb7031e825901e40a37df79 /server/sonar-auth-bitbucket
parentf6aef43f6848a27861171cc8e757085326a334f2 (diff)
downloadsonarqube-68977b2bedc95c738b58bc8be83a00d21e13c32e.tar.gz
sonarqube-68977b2bedc95c738b58bc8be83a00d21e13c32e.zip
SONAR-19045 Migrate from javaxi.servlet to framework agnostic plugin api classes
Co-authored-by: Eric Giffon <eric.giffon@sonarsource.com> Co-authored-by: Alain Kermis <alain.kermis@sonarsource.com> Co-authored-by: Antoine Vinot <antoine.vinot@sonarsource.com> Co-authored-by: Jacek Poreda <jacek.poreda@sonarsource.com>
Diffstat (limited to 'server/sonar-auth-bitbucket')
-rw-r--r--server/sonar-auth-bitbucket/build.gradle1
-rwxr-xr-xserver/sonar-auth-bitbucket/src/main/java/org/sonar/auth/bitbucket/BitbucketIdentityProvider.java4
-rw-r--r--server/sonar-auth-bitbucket/src/test/java/org/sonar/auth/bitbucket/IntegrationTest.java27
3 files changed, 28 insertions, 4 deletions
diff --git a/server/sonar-auth-bitbucket/build.gradle b/server/sonar-auth-bitbucket/build.gradle
index 445a0c2be16..8329723c6e2 100644
--- a/server/sonar-auth-bitbucket/build.gradle
+++ b/server/sonar-auth-bitbucket/build.gradle
@@ -22,4 +22,5 @@ dependencies {
testImplementation 'junit:junit'
testImplementation 'org.assertj:assertj-core'
testImplementation 'org.mockito:mockito-core'
+ testImplementation project(path: ':server:sonar-webserver-api')
}
diff --git a/server/sonar-auth-bitbucket/src/main/java/org/sonar/auth/bitbucket/BitbucketIdentityProvider.java b/server/sonar-auth-bitbucket/src/main/java/org/sonar/auth/bitbucket/BitbucketIdentityProvider.java
index ad0a29ebda1..58dd889d670 100755
--- a/server/sonar-auth-bitbucket/src/main/java/org/sonar/auth/bitbucket/BitbucketIdentityProvider.java
+++ b/server/sonar-auth-bitbucket/src/main/java/org/sonar/auth/bitbucket/BitbucketIdentityProvider.java
@@ -33,12 +33,12 @@ import java.util.List;
import java.util.Set;
import java.util.concurrent.ExecutionException;
import javax.annotation.CheckForNull;
-import javax.servlet.http.HttpServletRequest;
import org.sonar.api.server.ServerSide;
import org.sonar.api.server.authentication.Display;
import org.sonar.api.server.authentication.OAuth2IdentityProvider;
import org.sonar.api.server.authentication.UnauthorizedException;
import org.sonar.api.server.authentication.UserIdentity;
+import org.sonar.api.server.http.HttpRequest;
import org.sonar.api.utils.log.Logger;
import org.sonar.api.utils.log.Loggers;
@@ -122,7 +122,7 @@ public class BitbucketIdentityProvider implements OAuth2IdentityProvider {
}
private void onCallback(CallbackContext context) throws InterruptedException, ExecutionException, IOException {
- HttpServletRequest request = context.getRequest();
+ HttpRequest request = context.getHttpRequest();
OAuth20Service scribe = newScribeBuilder(context).build(scribeApi);
String code = request.getParameter(OAuthConstants.CODE);
OAuth2AccessToken accessToken = scribe.getAccessToken(code);
diff --git a/server/sonar-auth-bitbucket/src/test/java/org/sonar/auth/bitbucket/IntegrationTest.java b/server/sonar-auth-bitbucket/src/test/java/org/sonar/auth/bitbucket/IntegrationTest.java
index cce09beccf3..9b47ec7abc3 100644
--- a/server/sonar-auth-bitbucket/src/test/java/org/sonar/auth/bitbucket/IntegrationTest.java
+++ b/server/sonar-auth-bitbucket/src/test/java/org/sonar/auth/bitbucket/IntegrationTest.java
@@ -36,7 +36,10 @@ import org.sonar.api.config.internal.MapSettings;
import org.sonar.api.server.authentication.OAuth2IdentityProvider;
import org.sonar.api.server.authentication.UnauthorizedException;
import org.sonar.api.server.authentication.UserIdentity;
+import org.sonar.api.server.http.HttpRequest;
+import org.sonar.api.server.http.HttpResponse;
import org.sonar.api.utils.System2;
+import org.sonar.server.http.JavaxHttpRequest;
import static java.lang.String.format;
import static java.net.URLEncoder.encode;
@@ -254,13 +257,23 @@ public class IntegrationTest {
}
@Override
+ public HttpRequest getHttpRequest() {
+ return new JavaxHttpRequest(request);
+ }
+
+ @Override
+ public HttpResponse getHttpResponse() {
+ throw new UnsupportedOperationException("not used");
+ }
+
+ @Override
public HttpServletRequest getRequest() {
- return request;
+ throw new UnsupportedOperationException("deprecated");
}
@Override
public HttpServletResponse getResponse() {
- throw new UnsupportedOperationException("not used");
+ throw new UnsupportedOperationException("deprecated");
}
}
@@ -288,6 +301,16 @@ public class IntegrationTest {
}
@Override
+ public HttpRequest getHttpRequest() {
+ return null;
+ }
+
+ @Override
+ public HttpResponse getHttpResponse() {
+ return null;
+ }
+
+ @Override
public HttpServletRequest getRequest() {
return null;
}