Merge remote-tracking branch 'upstream/master'
This commit is contained in:
commit
4bad1fea86
5 changed files with 26 additions and 10 deletions
|
@ -78,9 +78,11 @@ public class AdapterDeploymentContext {
|
||||||
if (deployment == null) return null;
|
if (deployment == null) return null;
|
||||||
if (deployment.getAuthServerBaseUrl() == null) return deployment;
|
if (deployment.getAuthServerBaseUrl() == null) return deployment;
|
||||||
|
|
||||||
deployment = resolveUrls(deployment, facade);
|
KeycloakDeployment resolvedDeployment = resolveUrls(deployment, facade);
|
||||||
if (deployment.getRealmKey() == null) resolveRealmKey(deployment);
|
if (resolvedDeployment.getRealmKey() == null) {
|
||||||
return deployment;
|
resolveRealmKey(resolvedDeployment);
|
||||||
|
}
|
||||||
|
return resolvedDeployment;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected KeycloakDeployment resolveUrls(KeycloakDeployment deployment, HttpFacade facade) {
|
protected KeycloakDeployment resolveUrls(KeycloakDeployment deployment, HttpFacade facade) {
|
||||||
|
@ -404,6 +406,16 @@ public class AdapterDeploymentContext {
|
||||||
public boolean isRegisterNodeAtStartup() {
|
public boolean isRegisterNodeAtStartup() {
|
||||||
return delegate.isRegisterNodeAtStartup();
|
return delegate.isRegisterNodeAtStartup();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPrincipalAttribute() {
|
||||||
|
return delegate.getPrincipalAttribute();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setPrincipalAttribute(String principalAttribute) {
|
||||||
|
delegate.setPrincipalAttribute(principalAttribute);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected KeycloakUriBuilder getBaseBuilder(HttpFacade facade, String base) {
|
protected KeycloakUriBuilder getBaseBuilder(HttpFacade facade, String base) {
|
||||||
|
|
|
@ -24,7 +24,7 @@ public class KeycloakDeployment {
|
||||||
|
|
||||||
protected RelativeUrlsUsed relativeUrls;
|
protected RelativeUrlsUsed relativeUrls;
|
||||||
protected String realm;
|
protected String realm;
|
||||||
protected PublicKey realmKey;
|
protected volatile PublicKey realmKey;
|
||||||
protected String authServerBaseUrl;
|
protected String authServerBaseUrl;
|
||||||
protected String realmInfoUrl;
|
protected String realmInfoUrl;
|
||||||
protected KeycloakUriBuilder authUrl;
|
protected KeycloakUriBuilder authUrl;
|
||||||
|
|
|
@ -20,6 +20,7 @@ import org.keycloak.testsuite.rule.AbstractKeycloakRule;
|
||||||
import org.keycloak.testsuite.rule.WebResource;
|
import org.keycloak.testsuite.rule.WebResource;
|
||||||
import org.keycloak.testsuite.rule.WebRule;
|
import org.keycloak.testsuite.rule.WebRule;
|
||||||
import org.keycloak.testutils.KeycloakServer;
|
import org.keycloak.testutils.KeycloakServer;
|
||||||
|
import org.keycloak.util.Time;
|
||||||
import org.openqa.selenium.Cookie;
|
import org.openqa.selenium.Cookie;
|
||||||
import org.openqa.selenium.WebDriver;
|
import org.openqa.selenium.WebDriver;
|
||||||
|
|
||||||
|
@ -90,15 +91,16 @@ public class CookieTokenStoreAdapterTest {
|
||||||
KeycloakSession session = keycloakRule.startSession();
|
KeycloakSession session = keycloakRule.startSession();
|
||||||
RealmModel realm = session.realms().getRealmByName("demo");
|
RealmModel realm = session.realms().getRealmByName("demo");
|
||||||
int originalTokenTimeout = realm.getAccessTokenLifespan();
|
int originalTokenTimeout = realm.getAccessTokenLifespan();
|
||||||
realm.setAccessTokenLifespan(1);
|
realm.setAccessTokenLifespan(3);
|
||||||
session.getTransaction().commit();
|
session.getTransaction().commit();
|
||||||
session.close();
|
session.close();
|
||||||
|
|
||||||
// login to customer-cookie-portal
|
// login to customer-cookie-portal
|
||||||
String tokenCookie1 = loginToCustomerCookiePortal();
|
String tokenCookie1 = loginToCustomerCookiePortal();
|
||||||
|
|
||||||
// wait 2 secs
|
// Simulate waiting 4 seconds (Running testsuite in real env like Wildfly or EAP may still require to do Thread.sleep to really wait 4 seconds...)
|
||||||
Thread.sleep(2000);
|
Time.setOffset(4);
|
||||||
|
//Thread.sleep(4000);
|
||||||
|
|
||||||
// assert cookie was refreshed
|
// assert cookie was refreshed
|
||||||
driver.navigate().to("http://localhost:8081/customer-cookie-portal");
|
driver.navigate().to("http://localhost:8081/customer-cookie-portal");
|
||||||
|
@ -117,14 +119,15 @@ public class CookieTokenStoreAdapterTest {
|
||||||
driver.navigate().to("http://localhost:8081/customer-portal");
|
driver.navigate().to("http://localhost:8081/customer-portal");
|
||||||
Assert.assertTrue(driver.getCurrentUrl().startsWith(LOGIN_URL));
|
Assert.assertTrue(driver.getCurrentUrl().startsWith(LOGIN_URL));
|
||||||
|
|
||||||
// wait 2 secs until accessToken expires for customer-cookie-portal too.
|
// Simulate another 4 seconds
|
||||||
Thread.sleep(2000);
|
Time.setOffset(8);
|
||||||
|
|
||||||
// assert not logged in customer-cookie-portal
|
// assert not logged in customer-cookie-portal
|
||||||
driver.navigate().to("http://localhost:8081/customer-cookie-portal");
|
driver.navigate().to("http://localhost:8081/customer-cookie-portal");
|
||||||
Assert.assertTrue(driver.getCurrentUrl().startsWith(LOGIN_URL));
|
Assert.assertTrue(driver.getCurrentUrl().startsWith(LOGIN_URL));
|
||||||
|
|
||||||
// Change timeout back
|
// Change timeout back
|
||||||
|
Time.setOffset(0);
|
||||||
session = keycloakRule.startSession();
|
session = keycloakRule.startSession();
|
||||||
realm = session.realms().getRealmByName("demo");
|
realm = session.realms().getRealmByName("demo");
|
||||||
realm.setAccessTokenLifespan(originalTokenTimeout);
|
realm.setAccessTokenLifespan(originalTokenTimeout);
|
||||||
|
|
|
@ -52,6 +52,7 @@ public class TomcatServer {
|
||||||
|
|
||||||
server = new Embedded();
|
server = new Embedded();
|
||||||
server.setName("TomcatEmbeddedServer");
|
server.setName("TomcatEmbeddedServer");
|
||||||
|
server.setCatalinaBase(TomcatTest.getBaseDirectory());
|
||||||
|
|
||||||
Host localHost = server.createHost("localhost", appBase);
|
Host localHost = server.createHost("localhost", appBase);
|
||||||
localHost.setAutoDeploy(false);
|
localHost.setAutoDeploy(false);
|
||||||
|
|
|
@ -162,7 +162,7 @@ public class TomcatTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static String getBaseDirectory() {
|
static String getBaseDirectory() {
|
||||||
String dirPath = null;
|
String dirPath = null;
|
||||||
String relativeDirPath = "testsuite" + File.separator + "tomcat6" + File.separator + "target";
|
String relativeDirPath = "testsuite" + File.separator + "tomcat6" + File.separator + "target";
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue