diff options
author | Antoine Vinot <antoine.vinot@sonarsource.com> | 2023-04-13 16:57:56 +0200 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2023-04-24 20:04:23 +0000 |
commit | 68977b2bedc95c738b58bc8be83a00d21e13c32e (patch) | |
tree | 3c77243a1b04651f6cb7031e825901e40a37df79 /server/sonar-auth-saml/src/test | |
parent | f6aef43f6848a27861171cc8e757085326a334f2 (diff) | |
download | sonarqube-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-saml/src/test')
2 files changed, 11 insertions, 7 deletions
diff --git a/server/sonar-auth-saml/src/test/java/org/sonar/auth/saml/SamlAuthStatusPageGeneratorTest.java b/server/sonar-auth-saml/src/test/java/org/sonar/auth/saml/SamlAuthStatusPageGeneratorTest.java index 9fd398321f2..2f84a89a6d7 100644 --- a/server/sonar-auth-saml/src/test/java/org/sonar/auth/saml/SamlAuthStatusPageGeneratorTest.java +++ b/server/sonar-auth-saml/src/test/java/org/sonar/auth/saml/SamlAuthStatusPageGeneratorTest.java @@ -21,8 +21,8 @@ package org.sonar.auth.saml; import java.util.ArrayList; import java.util.HashMap; -import javax.servlet.http.HttpServletRequest; import org.junit.Test; +import org.sonar.api.server.http.HttpRequest; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.mock; @@ -35,16 +35,16 @@ public class SamlAuthStatusPageGeneratorTest { @Test public void getSamlAuthStatusHtml_whenCalled_shouldGeneratePageWithData() { SamlAuthenticationStatus samlAuthenticationStatus = mock(SamlAuthenticationStatus.class); - HttpServletRequest httpServletRequest = mock(HttpServletRequest.class); + HttpRequest request = mock(HttpRequest.class); when(samlAuthenticationStatus.getStatus()).thenReturn(null); when(samlAuthenticationStatus.getErrors()).thenReturn(new ArrayList<>()); when(samlAuthenticationStatus.getWarnings()).thenReturn(new ArrayList<>()); when(samlAuthenticationStatus.getAvailableAttributes()).thenReturn(new HashMap<>()); when(samlAuthenticationStatus.getMappedAttributes()).thenReturn(new HashMap<>()); - when(httpServletRequest.getContextPath()).thenReturn("context"); + when(request.getContextPath()).thenReturn("context"); - String completeHtmlTemplate = getSamlAuthStatusHtml(httpServletRequest, samlAuthenticationStatus); + String completeHtmlTemplate = getSamlAuthStatusHtml(request, samlAuthenticationStatus); assertThat(completeHtmlTemplate).contains(EMPTY_DATA_RESPONSE); } diff --git a/server/sonar-auth-saml/src/test/java/org/sonar/auth/saml/SamlAuthenticatorTest.java b/server/sonar-auth-saml/src/test/java/org/sonar/auth/saml/SamlAuthenticatorTest.java index 1c473879e3d..fb6e9f2cdeb 100644 --- a/server/sonar-auth-saml/src/test/java/org/sonar/auth/saml/SamlAuthenticatorTest.java +++ b/server/sonar-auth-saml/src/test/java/org/sonar/auth/saml/SamlAuthenticatorTest.java @@ -22,8 +22,12 @@ package org.sonar.auth.saml; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.junit.Test; +import org.sonar.api.server.http.HttpRequest; +import org.sonar.api.server.http.HttpResponse; +import org.sonar.server.http.JavaxHttpRequest; +import org.sonar.server.http.JavaxHttpResponse; -import static org.junit.Assert.*; +import static org.junit.Assert.assertFalse; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -32,8 +36,8 @@ public class SamlAuthenticatorTest { @Test public void authentication_status_with_errors_returned_when_init_fails() { SamlAuthenticator samlAuthenticator = new SamlAuthenticator(mock(SamlSettings.class), mock(SamlMessageIdChecker.class)); - HttpServletRequest request = mock(HttpServletRequest.class); - HttpServletResponse response = mock(HttpServletResponse.class); + HttpRequest request = new JavaxHttpRequest(mock(HttpServletRequest.class)); + HttpResponse response = new JavaxHttpResponse(mock(HttpServletResponse.class)); when(request.getContextPath()).thenReturn("context"); String authenticationStatus = samlAuthenticator.getAuthenticationStatusPage(request, response); |