KEYCLOAK-4044 Fix failing adapter tests
This commit is contained in:
parent
c8b22e71f0
commit
ae36b3c832
4 changed files with 19 additions and 7 deletions
|
@ -18,7 +18,6 @@
|
|||
package org.keycloak.testsuite.adapter.servlet;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.keycloak.common.util.UriUtils;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.annotation.WebServlet;
|
||||
|
|
|
@ -32,6 +32,7 @@ import javax.ws.rs.Path;
|
|||
import javax.ws.rs.PathParam;
|
||||
import javax.ws.rs.QueryParam;
|
||||
import javax.ws.rs.core.Context;
|
||||
import javax.ws.rs.core.HttpHeaders;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import javax.ws.rs.core.Response;
|
||||
import java.io.IOException;
|
||||
|
@ -64,7 +65,7 @@ public class SendUsernameServlet {
|
|||
return Response.status(Response.Status.FORBIDDEN).entity("Forbidden").build();
|
||||
}
|
||||
|
||||
return Response.ok(getOutput(), MediaType.TEXT_PLAIN_TYPE.withCharset("UTF-8")).build();
|
||||
return Response.ok(getOutput()).header(HttpHeaders.CONTENT_TYPE, MediaType.TEXT_PLAIN_TYPE + ";charset=UTF-8").build();
|
||||
}
|
||||
|
||||
@POST
|
||||
|
@ -76,7 +77,8 @@ public class SendUsernameServlet {
|
|||
throw new RuntimeException("User: " + httpServletRequest.getUserPrincipal() + " do not have required role");
|
||||
}
|
||||
|
||||
return Response.ok(getOutput(), MediaType.TEXT_HTML_TYPE.withCharset("UTF-8")).build();
|
||||
return Response.ok(getOutput()).header(HttpHeaders.CONTENT_TYPE, MediaType.TEXT_HTML_TYPE + ";charset=UTF-8").build();
|
||||
|
||||
}
|
||||
|
||||
@GET
|
||||
|
@ -84,7 +86,8 @@ public class SendUsernameServlet {
|
|||
public Response getSentPrincipal() throws IOException {
|
||||
System.out.println("In SendUsername Servlet getSentPrincipal()");
|
||||
|
||||
return Response.ok(getAttributes(), MediaType.TEXT_HTML_TYPE.withCharset("UTF-8")).build();
|
||||
return Response.ok(getAttributes()).header(HttpHeaders.CONTENT_TYPE, MediaType.TEXT_HTML_TYPE + ";charset=UTF-8").build();
|
||||
|
||||
}
|
||||
|
||||
@GET
|
||||
|
@ -108,7 +111,8 @@ public class SendUsernameServlet {
|
|||
Integer statusCode = (Integer) httpServletRequest.getAttribute("javax.servlet.error.status_code");
|
||||
System.out.println("In SendUsername Servlet errorPage() status code: " + statusCode);
|
||||
|
||||
return Response.ok(getErrorOutput(statusCode), MediaType.TEXT_HTML_TYPE.withCharset("UTF-8")).build();
|
||||
return Response.ok(getErrorOutput(statusCode)).header(HttpHeaders.CONTENT_TYPE, MediaType.TEXT_HTML_TYPE + ";charset=UTF-8").build();
|
||||
|
||||
}
|
||||
|
||||
@GET
|
||||
|
|
|
@ -24,7 +24,7 @@ public abstract class AbstractJBossOIDCServletsAdapterTest extends AbstractDemoS
|
|||
|
||||
@Deployment(name = CustomerPortalSubsystem.DEPLOYMENT_NAME)
|
||||
protected static WebArchive customerPortalSubsystem() {
|
||||
return servletDeployment(CustomerPortalSubsystem.DEPLOYMENT_NAME, CustomerServlet.class, ErrorServlet.class);
|
||||
return servletDeployment(CustomerPortalSubsystem.DEPLOYMENT_NAME, CustomerServlet.class, ErrorServlet.class, ServletTestUtils.class);
|
||||
}
|
||||
|
||||
@Deployment(name = ProductPortalSubsystem.DEPLOYMENT_NAME)
|
||||
|
|
|
@ -276,7 +276,7 @@ public abstract class AbstractSAMLServletsAdapterTest extends AbstractServletsAd
|
|||
|
||||
@Deployment(name = InputPortal.DEPLOYMENT_NAME)
|
||||
protected static WebArchive inputPortal() {
|
||||
return samlServletDeployment(InputPortal.DEPLOYMENT_NAME, "input-portal/WEB-INF/web.xml" , InputServlet.class);
|
||||
return samlServletDeployment(InputPortal.DEPLOYMENT_NAME, "input-portal/WEB-INF/web.xml" , InputServlet.class, ServletTestUtils.class);
|
||||
}
|
||||
|
||||
@Deployment(name = SalesPost2Servlet.DEPLOYMENT_NAME)
|
||||
|
@ -538,6 +538,9 @@ public abstract class AbstractSAMLServletsAdapterTest extends AbstractServletsAd
|
|||
setPasswordFor(topGroupUser, PASSWORD);
|
||||
|
||||
assertSuccessfulLogin(salesPostServletPage, topGroupUser, testRealmSAMLPostLoginPage, "principal=topgroupuser");
|
||||
|
||||
salesPostServletPage.logout();
|
||||
checkLoggedOut(salesPostServletPage, testRealmSAMLPostLoginPage);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -603,6 +606,9 @@ public abstract class AbstractSAMLServletsAdapterTest extends AbstractServletsAd
|
|||
assertThat("Database seems to be unable to store Unicode for username. Refer to KEYCLOAK-3439 and related issues.", storedUser.getUsername(), equalToIgnoringCase(username));
|
||||
|
||||
assertSuccessfulLogin(salesPostSigServletPage, user, testRealmSAMLPostLoginPage, "principal=" + storedUser.getUsername());
|
||||
|
||||
salesPostSigServletPage.logout();
|
||||
checkLoggedOut(salesPostSigServletPage, testRealmSAMLPostLoginPage);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -624,6 +630,9 @@ public abstract class AbstractSAMLServletsAdapterTest extends AbstractServletsAd
|
|||
assertThat("Database seems to be unable to store Unicode for username. Refer to KEYCLOAK-3439 and related issues.", storedUser.getUsername(), equalToIgnoringCase(username));
|
||||
|
||||
assertSuccessfulLogin(employeeSigServletPage, user, testRealmSAMLRedirectLoginPage, "principal=" + storedUser.getUsername());
|
||||
|
||||
employeeSigServletPage.logout();
|
||||
checkLoggedOut(employeeSigServletPage, testRealmSAMLRedirectLoginPage);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
Loading…
Reference in a new issue