diff options
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); |