aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-auth-github
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-github
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-github')
-rw-r--r--server/sonar-auth-github/build.gradle1
-rw-r--r--server/sonar-auth-github/src/main/java/org/sonar/auth/github/GitHubIdentityProvider.java4
-rw-r--r--server/sonar-auth-github/src/test/java/org/sonar/auth/github/IntegrationTest.java27
3 files changed, 28 insertions, 4 deletions
diff --git a/server/sonar-auth-github/build.gradle b/server/sonar-auth-github/build.gradle
index 811d44118a3..f78f4ba0b22 100644
--- a/server/sonar-auth-github/build.gradle
+++ b/server/sonar-auth-github/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-github/src/main/java/org/sonar/auth/github/GitHubIdentityProvider.java b/server/sonar-auth-github/src/main/java/org/sonar/auth/github/GitHubIdentityProvider.java
index caf4ddc05db..3acf65ff2cd 100644
--- a/server/sonar-auth-github/src/main/java/org/sonar/auth/github/GitHubIdentityProvider.java
+++ b/server/sonar-auth-github/src/main/java/org/sonar/auth/github/GitHubIdentityProvider.java
@@ -24,11 +24,11 @@ import com.github.scribejava.core.model.OAuth2AccessToken;
import com.github.scribejava.core.oauth.OAuth20Service;
import java.io.IOException;
import java.util.concurrent.ExecutionException;
-import javax.servlet.http.HttpServletRequest;
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 static com.google.common.base.Preconditions.checkState;
import static java.lang.String.format;
@@ -106,7 +106,7 @@ public class GitHubIdentityProvider implements OAuth2IdentityProvider {
private void onCallback(CallbackContext context) throws InterruptedException, ExecutionException, IOException {
context.verifyCsrfState();
- HttpServletRequest request = context.getRequest();
+ HttpRequest request = context.getHttpRequest();
OAuth20Service scribe = newScribeBuilder(context).build(scribeApi);
String code = request.getParameter("code");
OAuth2AccessToken accessToken = scribe.getAccessToken(code);
diff --git a/server/sonar-auth-github/src/test/java/org/sonar/auth/github/IntegrationTest.java b/server/sonar-auth-github/src/test/java/org/sonar/auth/github/IntegrationTest.java
index 390ba079e9e..3d8a1f0d8d3 100644
--- a/server/sonar-auth-github/src/test/java/org/sonar/auth/github/IntegrationTest.java
+++ b/server/sonar-auth-github/src/test/java/org/sonar/auth/github/IntegrationTest.java
@@ -37,7 +37,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 org.assertj.core.api.Assertions.assertThat;
@@ -404,13 +407,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");
}
}
@@ -438,6 +451,16 @@ public class IntegrationTest {
}
@Override
+ public HttpRequest getHttpRequest() {
+ return null;
+ }
+
+ @Override
+ public HttpResponse getHttpResponse() {
+ return null;
+ }
+
+ @Override
public HttpServletRequest getRequest() {
return null;
}