KEYCLOAK-12849 Exclude SameSite tests in non-SSL test runs

This commit is contained in:
mhajas 2020-01-30 17:09:55 +01:00 committed by Pavel Drozd
parent d39dfd8688
commit 66350f415c
6 changed files with 29 additions and 0 deletions

View file

@ -21,6 +21,8 @@ import org.jboss.logging.Logger;
import org.junit.Assume;
import org.keycloak.testsuite.arquillian.AuthServerTestEnricher;
import static org.keycloak.testsuite.arquillian.AuthServerTestEnricher.AUTH_SERVER_SSL_REQUIRED;
public class ContainerAssume {
private static final Logger log = Logger.getLogger(ContainerAssume.class);
@ -45,4 +47,8 @@ public class ContainerAssume {
String.format("Ignoring test since %s is set to false",
AuthServerTestEnricher.AUTH_SERVER_CLUSTER_PROPERTY), AuthServerTestEnricher.AUTH_SERVER_CLUSTER);
}
public static void assumeAuthServerSSL() {
Assume.assumeTrue("Only works with the SSL configured", AUTH_SERVER_SSL_REQUIRED);
}
}

View file

@ -3,6 +3,7 @@ package org.keycloak.testsuite.adapter.servlet;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.graphene.page.Page;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.junit.BeforeClass;
import org.junit.Test;
import org.keycloak.adapters.rotation.PublicKeyLocator;
import org.keycloak.testsuite.adapter.filter.AdapterActionsFilter;
@ -11,6 +12,7 @@ import org.keycloak.testsuite.adapter.page.EmployeeSigServlet;
import org.keycloak.testsuite.arquillian.annotation.AppServerContainer;
import org.keycloak.testsuite.arquillian.annotation.AuthServerContainerExclude;
import org.keycloak.testsuite.updaters.ClientAttributeUpdater;
import org.keycloak.testsuite.util.ContainerAssume;
import org.keycloak.testsuite.utils.arquillian.ContainerConstants;
import org.openqa.selenium.By;
@ -51,6 +53,11 @@ public class SAMLSameSiteTest extends AbstractSAMLServletAdapterTest {
@Page
protected Employee2Servlet employee2ServletPage;
@BeforeClass
public static void enabledOnlyWithSSL() {
ContainerAssume.assumeAuthServerSSL();
}
@Test
public void samlWorksWithSameSiteCookieTest() throws URISyntaxException {
getCleanup(SAMLSERVLETDEMO).addCleanup(ClientAttributeUpdater.forClient(adminClient, SAMLSERVLETDEMO, SAML_CLIENT_ID_EMPLOYEE_2)

View file

@ -26,11 +26,13 @@ import org.apache.http.protocol.BasicHttpContext;
import org.apache.http.protocol.HttpContext;
import org.apache.http.util.EntityUtils;
import org.jboss.arquillian.graphene.page.Page;
import org.junit.BeforeClass;
import org.junit.Test;
import org.keycloak.representations.idm.RealmRepresentation;
import org.keycloak.testsuite.AbstractKeycloakTest;
import org.keycloak.testsuite.auth.page.AuthRealm;
import org.keycloak.testsuite.pages.LoginPage;
import org.keycloak.testsuite.util.ContainerAssume;
import org.keycloak.testsuite.util.OAuthClient;
import org.keycloak.testsuite.util.OAuthClient.AuthorizationEndpointResponse;
import org.keycloak.testsuite.util.RealmBuilder;
@ -161,6 +163,8 @@ public class CookieTest extends AbstractKeycloakTest {
@Test
public void legacyCookiesTest() {
ContainerAssume.assumeAuthServerSSL();
accountPage.navigateTo();
assertCurrentUrlStartsWithLoginUrlOf(accountPage);

View file

@ -26,6 +26,7 @@ import org.keycloak.services.managers.AuthenticationSessionManager;
import org.keycloak.testsuite.AbstractKeycloakTest;
import org.keycloak.testsuite.ActionURIUtils;
import org.keycloak.testsuite.pages.LoginPage;
import org.keycloak.testsuite.util.ContainerAssume;
import org.keycloak.testsuite.util.OAuthClient;
import org.keycloak.testsuite.util.RealmBuilder;
import org.keycloak.testsuite.util.URLUtils;
@ -154,6 +155,8 @@ public class CookiesPathTest extends AbstractKeycloakTest {
@Test
public void testOldCookieWithWrongPath() {
ContainerAssume.assumeAuthServerSSL();
Cookie wrongCookie = new Cookie(AuthenticationSessionManager.AUTH_SESSION_ID, AUTH_SESSION_VALUE,
null, OLD_COOKIE_PATH, null, false, true);

View file

@ -51,6 +51,7 @@ import org.keycloak.testsuite.pages.ErrorPage;
import org.keycloak.testsuite.pages.LoginPage;
import org.keycloak.testsuite.pages.LoginPasswordUpdatePage;
import org.keycloak.testsuite.updaters.RealmAttributeUpdater;
import org.keycloak.testsuite.util.ContainerAssume;
import org.keycloak.testsuite.util.DroneUtils;
import org.keycloak.testsuite.util.JavascriptBrowser;
import org.keycloak.testsuite.util.OAuthClient;
@ -416,6 +417,8 @@ public class LoginTest extends AbstractTestRealmKeycloakTest {
@Test
public void loginSuccessRealmSigningAlgorithms() throws JWSInputException {
ContainerAssume.assumeAuthServerSSL();
loginPage.open();
loginPage.login("login-test", "password");

View file

@ -3,6 +3,7 @@ package org.keycloak.testsuite.javascript;
import org.jboss.arquillian.drone.api.annotation.Drone;
import org.jboss.arquillian.graphene.page.Page;
import org.junit.Before;
import org.junit.BeforeClass;
import org.keycloak.admin.client.resource.ClientResource;
import org.keycloak.representations.idm.ClientRepresentation;
import org.keycloak.representations.idm.RealmRepresentation;
@ -13,6 +14,7 @@ import org.keycloak.testsuite.Assert;
import org.keycloak.testsuite.admin.ApiUtil;
import org.keycloak.testsuite.auth.page.login.OIDCLogin;
import org.keycloak.testsuite.util.ClientBuilder;
import org.keycloak.testsuite.util.ContainerAssume;
import org.keycloak.testsuite.util.JavascriptBrowser;
import org.keycloak.testsuite.util.RealmBuilder;
import org.keycloak.testsuite.util.RolesBuilder;
@ -82,6 +84,10 @@ public abstract class AbstractJavascriptTest extends AbstractAuthTest {
unauthorizedUser = UserBuilder.create().username("unauthorized").password("password").build();
}
@BeforeClass
public static void enabledOnlyWithSSL() {
ContainerAssume.assumeAuthServerSSL();
}
@Before
public void beforeJavascriptTest() {